Browse Source

Merge branch 'dev1.0' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev1.0-resiguide

# Conflicts:
#	epmet-module/resi-guide/resi-guide-server/pom.xml
master
sunyuchao 6 years ago
parent
commit
103f797b54
  1. 10
      epmet-gateway/pom.xml
  2. 8
      epmet-gateway/src/main/resources/bootstrap.yml
  3. 25
      epmet-module/epmet-api/db/mysql.sql
  4. 24
      epmet-module/epmet-api/db/oracle.sql
  5. 24
      epmet-module/epmet-api/db/postgresql.sql
  6. 24
      epmet-module/epmet-api/db/sqlserver.sql
  7. 34
      epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/LoginDTO.java
  8. 33
      epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/RegisterDTO.java
  9. 21
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/Login.java
  10. 25
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/LoginUser.java
  11. 35
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/FilterConfig.java
  12. 42
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/WebConfig.java
  13. 61
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiLoginController.java
  14. 54
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiRegisterController.java
  15. 63
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiTestController.java
  16. 25
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/TokenDao.java
  17. 25
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/UserDao.java
  18. 47
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/TokenEntity.java
  19. 52
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/UserEntity.java
  20. 25
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/exception/ModuleErrorCode.java
  21. 73
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/interceptor/AuthorizationInterceptor.java
  22. 53
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/resolver/LoginUserHandlerMethodArgumentResolver.java
  23. 36
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/TokenService.java
  24. 34
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/UserService.java
  25. 92
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/TokenServiceImpl.java
  26. 63
      epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java
  27. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages.properties
  28. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_en_US.properties
  29. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_CN.properties
  30. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_TW.properties
  31. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation.properties
  32. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_en_US.properties
  33. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_CN.properties
  34. 3
      epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_TW.properties
  35. 14
      epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/TokenDao.xml
  36. 13
      epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/UserDao.xml
  37. 1
      epmet-module/pom.xml
  38. 4
      epmet-module/resi-guide/resi-guide-server/pom.xml
  39. 4
      epmet-user/epmet-user-client/pom.xml
  40. 121
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java
  41. 26
      epmet-user/epmet-user-server/pom.xml
  42. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java
  43. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
  44. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/config/SwaggerConfig.java
  45. 94
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java
  46. 33
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java
  47. 91
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java
  48. 86
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java
  49. 47
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java
  50. 95
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java
  51. 104
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java
  52. 29
      epmet-user/epmet-user-server/src/main/resources/bootstrap.yml
  53. 8
      epmet-user/epmet-user-server/src/main/resources/logback-spring.xml
  54. 27
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml
  55. 8
      epmet-user/pom.xml
  56. 1
      pom.xml

10
epmet-gateway/pom.xml

@ -117,9 +117,9 @@
<!-- 7、定时任务服务 -->
<!-- <gateway.routes.epmet-job-server.uri>lb://epmet-job-server</gateway.routes.epmet-job-server.uri>-->
<gateway.routes.epmet-job-server.uri>http://localhost:8084</gateway.routes.epmet-job-server.uri>
<!-- 8、APP流服务 -->
<!-- <gateway.routes.epmet-api-server.uri>lb://epmet-api-server</gateway.routes.epmet-api-server.uri>-->
<gateway.routes.epmet-api-server.uri>http://localhost:8087</gateway.routes.epmet-api-server.uri>
<!-- 8、用户模块 -->
<!-- <gateway.routes.epmet-user-server.uri>lb://epmet-user-server</gateway.routes.epmet-user-server.uri>-->
<gateway.routes.epmet-user-server.uri>http://localhost:8087</gateway.routes.epmet-user-server.uri>
<!-- 9、新模块结构demo -->
<gateway.routes.epmet-demo-server.uri>lb://epmet-demo-server</gateway.routes.epmet-demo-server.uri>
<!-- <gateway.routes.epmet-demo-server.uri>http://localhost:8088</gateway.routes.epmet-demo-server.uri>-->
@ -171,8 +171,8 @@
<gateway.routes.epmet-activiti-server.uri>lb://epmet-activiti-server</gateway.routes.epmet-activiti-server.uri>
<!-- 7、定时任务服务 -->
<gateway.routes.epmet-job-server.uri>lb://epmet-job-server</gateway.routes.epmet-job-server.uri>
<!-- 8、APP流服务 -->
<gateway.routes.epmet-api-server.uri>lb://epmet-api-server</gateway.routes.epmet-api-server.uri>
<!-- 8、用户模块 -->
<gateway.routes.epmet-user-server.uri>lb://epmet-user-server</gateway.routes.epmet-user-server.uri>
<!-- 9、新模块结构demo -->
<gateway.routes.epmet-demo-server.uri>lb://epmet-demo-server</gateway.routes.epmet-demo-server.uri>
<!-- 10、运营端客户定制化服务 -->

8
epmet-gateway/src/main/resources/bootstrap.yml

@ -82,12 +82,12 @@ spring:
- Path=${server.servlet.context-path}/job/**
filters:
- StripPrefix=1
#APP流服务
- id: epmet-api-server
uri: @gateway.routes.epmet-api-server.uri@
#用户服务
- id: epmet-user-server
uri: @gateway.routes.epmet-user-server.uri@
order: 7
predicates:
- Path=${server.servlet.context-path}/api/**
- Path=${server.servlet.context-path}/epmetuser/**
filters:
- StripPrefix=1
#demo流服务

25
epmet-module/epmet-api/db/mysql.sql

@ -1,25 +0,0 @@
-- 用户表
CREATE TABLE tb_user (
id bigint NOT NULL COMMENT 'id',
username varchar(50) NOT NULL COMMENT '用户名',
mobile varchar(20) NOT NULL COMMENT '手机号',
password varchar(64) COMMENT '密码',
create_date datetime COMMENT '创建时间',
PRIMARY KEY (id),
UNIQUE INDEX (username)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户';
-- 用户Token表
CREATE TABLE tb_token (
id bigint NOT NULL COMMENT 'id',
user_id bigint NOT NULL COMMENT '用户ID',
token varchar(100) NOT NULL COMMENT 'token',
expire_date datetime COMMENT '过期时间',
update_date datetime COMMENT '更新时间',
PRIMARY KEY (id),
UNIQUE INDEX (user_id),
UNIQUE INDEX (token)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户Token';
-- 账号:13612345678 密码:admin
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', now());

24
epmet-module/epmet-api/db/oracle.sql

@ -1,24 +0,0 @@
CREATE TABLE tb_user (
id NUMBER(20, 0) NOT NULL,
username varchar(50) NOT NULL,
mobile varchar(20) NOT NULL,
password varchar(64),
create_date date,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_user_username on tb_user(username);
CREATE TABLE tb_token (
id NUMBER(20, 0) NOT NULL,
user_id NUMBER(20, 0) NOT NULL,
token varchar(100) NOT NULL,
expire_date date,
update_date date,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_token_user_id on tb_token(user_id);
CREATE UNIQUE INDEX idx_token on tb_token(token);
-- 账号:13612345678 密码:admin
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', CURRENT_DATE);

24
epmet-module/epmet-api/db/postgresql.sql

@ -1,24 +0,0 @@
CREATE TABLE tb_user (
id int8 NOT NULL,
username varchar(50) NOT NULL,
mobile varchar(20) NOT NULL,
password varchar(64),
create_date timestamp,
PRIMARY KEY (id),
UNIQUE (username)
);
CREATE TABLE tb_token (
id int8 NOT NULL,
user_id int8 NOT NULL,
token varchar(100) NOT NULL,
expire_date timestamp,
update_date timestamp,
PRIMARY KEY (id),
UNIQUE (user_id),
UNIQUE (token)
);
-- 账号:13612345678 密码:admin
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', now());

24
epmet-module/epmet-api/db/sqlserver.sql

@ -1,24 +0,0 @@
CREATE TABLE tb_user (
id bigint NOT NULL,
username varchar(50) NOT NULL,
mobile varchar(20) NOT NULL,
password varchar(64),
create_date datetime,
PRIMARY KEY (id),
UNIQUE (username)
);
CREATE TABLE tb_token (
id bigint NOT NULL,
user_id bigint NOT NULL,
token varchar(100) NOT NULL,
expire_date datetime,
update_date datetime,
PRIMARY KEY (id),
UNIQUE (user_id),
UNIQUE (token)
);
-- 账号:13612345678 密码:admin
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', getdate());

34
epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/LoginDTO.java

@ -1,34 +0,0 @@
/**
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 登录表单
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@ApiModel(value = "登录表单")
public class LoginDTO {
@ApiModelProperty(value = "手机号")
@NotBlank(message="{api.mobile.require}")
private String mobile;
@ApiModelProperty(value = "密码")
@NotBlank(message="{api.password.require}")
private String password;
}

33
epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/RegisterDTO.java

@ -1,33 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 注册表单
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@ApiModel(value = "注册表单")
public class RegisterDTO {
@ApiModelProperty(value = "手机号")
@NotBlank(message="{api.mobile.require}")
private String mobile;
@ApiModelProperty(value = "密码")
@NotBlank(message="{api.password.require}")
private String password;
}

21
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/Login.java

@ -1,21 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.annotation;
import java.lang.annotation.*;
/**
* 登录效验
* @author Mark sunlightcs@gmail.com
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Login {
}

25
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/LoginUser.java

@ -1,25 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 登录用户信息
*
* @author Mark sunlightcs@gmail.com
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface LoginUser {
}

35
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/FilterConfig.java

@ -1,35 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.config;
import com.epmet.commons.tools.xss.XssFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.DispatcherType;
/**
* Filter配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public class FilterConfig {
@Bean
public FilterRegistrationBean xssFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
registration.addUrlPatterns("/*");
registration.setName("xssFilter");
return registration;
}
}

42
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/WebConfig.java

@ -1,42 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.config;
import com.epmet.interceptor.AuthorizationInterceptor;
import com.epmet.resolver.LoginUserHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
/**
* MVC配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private AuthorizationInterceptor authorizationInterceptor;
@Autowired
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**");
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
}
}

61
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiLoginController.java

@ -1,61 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.controller;
import com.epmet.annotation.Login;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.LoginDTO;
import com.epmet.service.TokenService;
import com.epmet.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
* 登录接口
*
* @author Mark sunlightcs@gmail.com
*/
@RestController
@RequestMapping("auth")
@Api(tags="登录接口")
public class ApiLoginController {
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
@PostMapping("login")
@ApiOperation("登录")
public Result<Map<String, Object>> login(@RequestBody LoginDTO dto){
//表单校验
ValidatorUtils.validateEntity(dto);
//用户登录
Map<String, Object> map = userService.login(dto);
return new Result().ok(map);
}
@Login
@PostMapping("logout")
@ApiOperation("退出")
public Result logout(@ApiIgnore @RequestAttribute("userId") Long userId){
tokenService.expireToken(userId);
return new Result();
}
}

54
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiRegisterController.java

@ -1,54 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.entity.UserEntity;
import com.epmet.dto.RegisterDTO;
import com.epmet.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* 注册接口
*
* @author Mark sunlightcs@gmail.com
*/
@RestController
@RequestMapping("register")
@Api(tags="注册接口")
public class ApiRegisterController {
@Autowired
private UserService userService;
@PostMapping
@ApiOperation("注册")
public Result register(@RequestBody RegisterDTO dto){
//表单校验
ValidatorUtils.validateEntity(dto);
UserEntity user = new UserEntity();
user.setMobile(dto.getMobile());
user.setUsername(dto.getMobile());
user.setPassword(DigestUtils.sha256Hex(dto.getPassword()));
user.setCreateDate(new Date());
userService.insert(user);
return new Result();
}
}

63
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiTestController.java

@ -1,63 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.controller;
import com.epmet.annotation.Login;
import com.epmet.annotation.LoginUser;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UploadDTO;
import com.epmet.entity.UserEntity;
import com.epmet.feign.OssFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
/**
* 测试接口
*
* @author Mark sunlightcs@gmail.com
*/
@RestController
@RequestMapping("test")
@Api(tags="测试接口")
public class ApiTestController {
@Autowired
private OssFeignClient ossFeignClient;
@Login
@GetMapping("userInfo")
@ApiOperation(value="获取用户信息", response=UserEntity.class)
public Result<UserEntity> userInfo(@ApiIgnore @LoginUser UserEntity user){
return new Result<UserEntity>().ok(user);
}
@Login
@GetMapping("userId")
@ApiOperation("获取用户ID")
public Result<Long> userInfo(@ApiIgnore @RequestAttribute("userId") Long userId){
return new Result<Long>().ok(userId);
}
@GetMapping("notToken")
@ApiOperation("忽略Token验证测试")
public Result<String> notToken(){
return new Result<String>().ok("无需token也能访问。。。");
}
@PostMapping("upload")
@ApiOperation(value = "上传文件")
public Result<UploadDTO> upload(@RequestParam("file") MultipartFile file) {
Result<UploadDTO> dto = ossFeignClient.upload(file);
return dto;
}
}

25
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/TokenDao.java

@ -1,25 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.TokenEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户Token
*
* @author Mark sunlightcs@gmail.com
*/
@Mapper
public interface TokenDao extends BaseDao<TokenEntity> {
TokenEntity getByToken(String token);
TokenEntity getByUserId(Long userId);
}

25
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/UserDao.java

@ -1,25 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
@Mapper
public interface UserDao extends BaseDao<UserEntity> {
UserEntity getUserByMobile(String mobile);
UserEntity getUserByUserId(Long userId);
}

47
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/TokenEntity.java

@ -1,47 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户Token
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@TableName("tb_token")
public class TokenEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 用户token
*/
private String token;
/**
* 过期时间
*/
private Date expireDate;
/**
* 更新时间
*/
private Date updateDate;
}

52
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/UserEntity.java

@ -1,52 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@TableName("tb_user")
public class UserEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableId
private Long id;
/**
* 用户名
*/
private String username;
/**
* 手机号
*/
private String mobile;
/**
* 密码
*/
@JSONField(serialize=false)
private String password;
/**
* 创建时间
*/
private Date createDate;
}

25
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/exception/ModuleErrorCode.java

@ -1,25 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.exception;
import com.epmet.commons.tools.exception.ErrorCode;
/**
* 模块错误编码由9位数字组成前6位为模块编码后3位为业务编码
* <p>
* 100001001100001代表模块001代表业务代码
* </p>
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
public interface ModuleErrorCode extends ErrorCode {
int TOKEN_NOT_EMPTY = 100005001;
int TOKEN_INVALID = 100005002;
}

73
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/interceptor/AuthorizationInterceptor.java

@ -1,73 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.interceptor;
import com.epmet.annotation.Login;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.entity.TokenEntity;
import com.epmet.exception.ModuleErrorCode;
import com.epmet.service.TokenService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 权限(Token)验证
*
* @author Mark sunlightcs@gmail.com
*/
@Component
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
@Autowired
private TokenService tokenService;
public static final String USER_KEY = "userId";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Login annotation;
if(handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
}else{
return true;
}
if(annotation == null){
return true;
}
//从header中获取token
String token = request.getHeader("token");
//如果header中不存在token,则从参数中获取token
if(StringUtils.isBlank(token)){
token = request.getParameter("token");
}
//token为空
if(StringUtils.isBlank(token)){
throw new RenException(ModuleErrorCode.TOKEN_NOT_EMPTY);
}
//查询token信息
TokenEntity tokenEntity = tokenService.getByToken(token);
if(tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
throw new RenException(ModuleErrorCode.TOKEN_INVALID);
}
//设置userId到request里,后续根据userId,获取用户信息
request.setAttribute(USER_KEY, tokenEntity.getUserId());
return true;
}
}

53
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/resolver/LoginUserHandlerMethodArgumentResolver.java

@ -1,53 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.resolver;
import com.epmet.annotation.LoginUser;
import com.epmet.entity.UserEntity;
import com.epmet.interceptor.AuthorizationInterceptor;
import com.epmet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
/**
* @LoginUser注解的方法参数注入当前登录用户
*
* @author Mark sunlightcs@gmail.com
*/
@Component
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Autowired
private UserService userService;
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
//获取用户ID
Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST);
if(object == null){
return null;
}
//获取用户信息
UserEntity user = userService.getUserByUserId((Long)object);
return user;
}
}

36
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/TokenService.java

@ -1,36 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.TokenEntity;
/**
* 用户Token
*
* @author Mark sunlightcs@gmail.com
*/
public interface TokenService extends BaseService<TokenEntity> {
TokenEntity getByToken(String token);
/**
* 生成token
* @param userId 用户ID
* @return 返回token信息
*/
TokenEntity createToken(Long userId);
/**
* 设置token过期
* @param userId 用户ID
*/
void expireToken(Long userId);
}

34
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/UserService.java

@ -1,34 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.UserEntity;
import com.epmet.dto.LoginDTO;
import java.util.Map;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
public interface UserService extends BaseService<UserEntity> {
UserEntity getByMobile(String mobile);
UserEntity getUserByUserId(Long userId);
/**
* 用户登录
* @param dto 登录表单
* @return 返回登录信息
*/
Map<String, Object> login(LoginDTO dto);
}

92
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/TokenServiceImpl.java

@ -1,92 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.TokenDao;
import com.epmet.entity.TokenEntity;
import com.epmet.service.TokenService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.UUID;
@Service
public class TokenServiceImpl extends BaseServiceImpl<TokenDao, TokenEntity> implements TokenService {
/**
* 12小时后过期
*/
private final static int EXPIRE = 3600 * 12;
@Override
public TokenEntity getByToken(String token) {
return baseDao.getByToken(token);
}
@Override
public TokenEntity createToken(Long userId) {
//当前时间
Date now = new Date();
//过期时间
Date expireTime = new Date(now.getTime() + EXPIRE * 1000);
//用户token
String token;
//判断是否生成过token
TokenEntity tokenEntity = baseDao.getByUserId(userId);
if(tokenEntity == null){
//生成一个token
token = generateToken();
tokenEntity = new TokenEntity();
tokenEntity.setUserId(userId);
tokenEntity.setToken(token);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(expireTime);
//保存token
this.insert(tokenEntity);
}else{
//判断token是否过期
if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
//token过期,重新生成token
token = generateToken();
}else {
token = tokenEntity.getToken();
}
tokenEntity.setToken(token);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(expireTime);
//更新token
this.updateById(tokenEntity);
}
return tokenEntity;
}
@Override
public void expireToken(Long userId){
Date now = new Date();
TokenEntity tokenEntity = new TokenEntity();
tokenEntity.setUserId(userId);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(now);
this.updateById(tokenEntity);
}
private String generateToken(){
return UUID.randomUUID().toString().replace("-", "");
}
}

63
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

@ -1,63 +0,0 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.ErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.dao.UserDao;
import com.epmet.entity.TokenEntity;
import com.epmet.entity.UserEntity;
import com.epmet.dto.LoginDTO;
import com.epmet.service.TokenService;
import com.epmet.service.UserService;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService {
@Autowired
private TokenService tokenService;
@Override
public UserEntity getByMobile(String mobile) {
return baseDao.getUserByMobile(mobile);
}
@Override
public UserEntity getUserByUserId(Long userId) {
return baseDao.getUserByUserId(userId);
}
@Override
public Map<String, Object> login(LoginDTO dto) {
UserEntity user = getByMobile(dto.getMobile());
AssertUtils.isNull(user, ErrorCode.ACCOUNT_PASSWORD_ERROR);
//密码错误
if(!user.getPassword().equals(DigestUtils.sha256Hex(dto.getPassword()))){
throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
}
//获取登录token
TokenEntity tokenEntity = tokenService.createToken(user.getId());
Map<String, Object> map = new HashMap<>(2);
map.put("token", tokenEntity.getToken());
map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
return map;
}
}

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages.properties

@ -1,3 +0,0 @@
#Default
100005001=token\u4E0D\u80FD\u4E3A\u7A7A
100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_en_US.properties

@ -1,3 +0,0 @@
#English
100005001=Token cannot be empty
100005002=Token is invalid, please log in again

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_CN.properties

@ -1,3 +0,0 @@
#\u7B80\u4F53\u4E2D\u6587
100005001=token\u4E0D\u80FD\u4E3A\u7A7A
100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_TW.properties

@ -1,3 +0,0 @@
#\u7E41\u4F53\u4E2D\u6587
100005001=token\u4E0D\u80FD\u70BA\u7A7A
100005002=token\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u767B\u9304

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation.properties

@ -1,3 +0,0 @@
#Default
api.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A
api.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_en_US.properties

@ -1,3 +0,0 @@
#English
api.mobile.require=The phone number cannot be empty
api.password.require=Password cannot be empty

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_CN.properties

@ -1,3 +0,0 @@
#\u7B80\u4F53\u4E2D\u6587
api.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A
api.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A

3
epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_TW.properties

@ -1,3 +0,0 @@
#\u7E41\u4F53\u4E2D\u6587
api.mobile.require=\u624B\u6A5F\u865F\u4E0D\u80FD\u70BA\u7A7A
api.password.require=\u5BC6\u78BC\u4E0D\u80FD\u70BA\u7A7A

14
epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/TokenDao.xml

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.TokenDao">
<select id="getByToken" resultType="com.epmet.entity.TokenEntity">
select * from tb_token where token = #{value}
</select>
<select id="getByUserId" resultType="com.epmet.entity.TokenEntity">
select * from tb_token where user_id = #{value}
</select>
</mapper>

13
epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/UserDao.xml

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.UserDao">
<select id="getUserByMobile" resultType="com.epmet.entity.UserEntity">
select * from tb_user where mobile = #{value}
</select>
<select id="getUserByUserId" resultType="com.epmet.entity.UserEntity">
select * from tb_user where id = #{value}
</select>
</mapper>

1
epmet-module/pom.xml

@ -18,7 +18,6 @@
<module>epmet-job</module>
<module>epmet-message</module>
<module>epmet-activiti</module>
<module>epmet-api</module>
<module>epmet-demo</module>
<module>oper-customize</module>
<module>oper-crm</module>

4
epmet-module/resi-guide/resi-guide-server/pom.xml

@ -89,7 +89,7 @@
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_common_user?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_resi_guide?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet</spring.datasource.druid.username>
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password>
@ -119,7 +119,7 @@
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_resi_guide?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet</spring.datasource.druid.username>
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password>

4
epmet-module/epmet-api/epmet-api-client/pom.xml → epmet-user/epmet-user-client/pom.xml

@ -5,11 +5,11 @@
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-api</artifactId>
<artifactId>epmet-user</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>epmet-api-client</artifactId>
<artifactId>epmet-user-client</artifactId>
<packaging>jar</packaging>
<dependencies>

121
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java

@ -0,0 +1,121 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
public class CustomerUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 唯一标识
*/
private String id;
/**
* 客户Id CUSTOMER.id
*/
private String customerId;
/**
* 微信openId
*/
private String wxOpenId;
/**
* 手机号
*/
private String mobile;
/**
* 昵称
*/
private String nickname;
/**
* 性别:0.未知 1.男性2女性
*/
private Integer sex;
/**
* 头像
*/
private String headImgUrl;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 语言
*/
private String language;
/**
* 删除标识0.未删除 1.已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

26
epmet-module/epmet-api/epmet-api-server/pom.xml → epmet-user/epmet-user-server/pom.xml

@ -5,32 +5,27 @@
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-api</artifactId>
<artifactId>epmet-user</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>epmet-api-server</artifactId>
<artifactId>epmet-user-server</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-api-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<artifactId>epmet-commons-mybatis</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-mybatis</artifactId>
<artifactId>epmet-commons-dynamic-datasource</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
@ -70,6 +65,7 @@
</configuration>
</plugin>
</plugins>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
@ -78,21 +74,20 @@
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<server.port>8087</server.port>
<spring.profiles.active>dev</spring.profiles.active>
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_user?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet</spring.datasource.druid.username>
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password>
@ -113,13 +108,16 @@
</profile>
<profile>
<id>test</id>
<!--<activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<properties>
<server.port>8087</server.port>
<spring.profiles.active>test</spring.profiles.active>
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://47.104.224.45:3308/epmet_user?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet</spring.datasource.druid.username>
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password>

10
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/ApiApplication.java → epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java

@ -10,22 +10,18 @@ package com.epmet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* API模块
* 管理后台
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class ApiApplication {
public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
SpringApplication.run(UserApplication.class, args);
}
}

2
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/ModuleConfigImpl.java → epmet-user/epmet-user-server/src/main/java/com/epmet/config/ModuleConfigImpl.java

@ -21,6 +21,6 @@ import org.springframework.stereotype.Service;
public class ModuleConfigImpl implements ModuleConfig {
@Override
public String getName() {
return "api";
return "epmetuser";
}
}

12
epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/SwaggerConfig.java → epmet-user/epmet-user-server/src/main/java/com/epmet/config/SwaggerConfig.java

@ -12,7 +12,6 @@ import com.epmet.commons.tools.constant.Constant;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@ -34,7 +33,7 @@ import static com.google.common.collect.Lists.newArrayList;
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer {
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
@ -43,19 +42,20 @@ public class SwaggerConfig implements WebMvcConfigurer {
.select()
//加了ApiOperation注解的类,才生成接口文档
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//包下的类,才生成接口文档
//.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
.paths(PathSelectors.any())
.build()
.directModelSubstitute(java.util.Date.class, String.class)
.securitySchemes(security());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("人人开源")
.description("API接口文档")
.termsOfServiceUrl("https://www.renren.io")
.version("1.1.0")
.description("系统模块开发文档")
.termsOfServiceUrl("https://www.renren.io/community")
.version("1.4.0")
.build();
}

94
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.excel.CustomerUserExcel;
import com.epmet.service.CustomerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@RestController
@RequestMapping("customeruser")
public class CustomerUserController {
@Autowired
private CustomerUserService customerUserService;
@GetMapping("page")
public Result<PageData<CustomerUserDTO>> page(@RequestParam Map<String, Object> params){
PageData<CustomerUserDTO> page = customerUserService.page(params);
return new Result<PageData<CustomerUserDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerUserDTO> get(@PathVariable("id") String id){
CustomerUserDTO data = customerUserService.get(id);
return new Result<CustomerUserDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CustomerUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerUserService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody CustomerUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerUserService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
customerUserService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CustomerUserDTO> list = customerUserService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CustomerUserExcel.class);
}
}

33
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java

@ -0,0 +1,33 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.CustomerUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Mapper
public interface CustomerUserDao extends BaseDao<CustomerUserEntity> {
}

91
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java

@ -0,0 +1,91 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_user")
public class CustomerUserEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id CUSTOMER.id
*/
private String customerId;
/**
* 微信openId
*/
private String wxOpenId;
/**
* 手机号
*/
private String mobile;
/**
* 昵称
*/
private String nickname;
/**
* 性别:0.未知 1.男性2女性
*/
private Integer sex;
/**
* 头像
*/
private String headImgUrl;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 语言
*/
private String language;
}

86
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java

@ -0,0 +1,86 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
public class CustomerUserExcel {
@Excel(name = "唯一标识")
private String id;
@Excel(name = "客户Id CUSTOMER.id")
private String customerId;
@Excel(name = "微信openId")
private String wxOpenId;
@Excel(name = "手机号")
private String mobile;
@Excel(name = "昵称")
private String nickname;
@Excel(name = "性别:0.未知 1.男性2女性")
private Integer sex;
@Excel(name = "头像")
private String headImgUrl;
@Excel(name = "国家")
private String country;
@Excel(name = "省份")
private String province;
@Excel(name = "城市")
private String city;
@Excel(name = "语言")
private String language;
@Excel(name = "删除标识:0.未删除 1.已删除")
private String delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
}

47
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Component
public class CustomerUserRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

95
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java

@ -0,0 +1,95 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.entity.CustomerUserEntity;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
public interface CustomerUserService extends BaseService<CustomerUserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CustomerUserDTO>
* @author generator
* @date 2020-03-16
*/
PageData<CustomerUserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CustomerUserDTO>
* @author generator
* @date 2020-03-16
*/
List<CustomerUserDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CustomerUserDTO
* @author generator
* @date 2020-03-16
*/
CustomerUserDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-03-16
*/
void save(CustomerUserDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-03-16
*/
void update(CustomerUserDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-03-16
*/
void delete(String[] ids);
}

104
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java

@ -0,0 +1,104 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.CustomerUserDao;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.entity.CustomerUserEntity;
import com.epmet.redis.CustomerUserRedis;
import com.epmet.service.CustomerUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Service
public class CustomerUserServiceImpl extends BaseServiceImpl<CustomerUserDao, CustomerUserEntity> implements CustomerUserService {
@Autowired
private CustomerUserRedis customerUserRedis;
@Override
public PageData<CustomerUserDTO> page(Map<String, Object> params) {
IPage<CustomerUserEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerUserDTO.class);
}
@Override
public List<CustomerUserDTO> list(Map<String, Object> params) {
List<CustomerUserEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerUserDTO.class);
}
private QueryWrapper<CustomerUserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CustomerUserDTO get(String id) {
CustomerUserEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerUserDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerUserDTO dto) {
CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerUserDTO dto) {
CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

29
epmet-module/epmet-api/epmet-api-server/src/main/resources/bootstrap.yml → epmet-user/epmet-user-server/src/main/resources/bootstrap.yml

@ -1,17 +1,19 @@
server:
port: @server.port@
servlet:
context-path: /api
context-path: /epmetuser
spring:
main:
allow-bean-definition-overriding: true
application:
name: epmet-api-server
name: epmet-user-server
#环境 dev|test|prod
profiles:
active: dev
messages:
encoding: UTF-8
basename: i18n/messages,i18n/messages_common
basename: i18n/messages_common
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
@ -28,6 +30,27 @@ spring:
url: @spring.datasource.druid.url@
username: @spring.datasource.druid.username@
password: @spring.datasource.druid.password@
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
cloud:
nacos:
discovery:

8
epmet-module/epmet-api/epmet-api-server/src/main/resources/logback-spring.xml → epmet-user/epmet-user-server/src/main/resources/logback-spring.xml

@ -2,7 +2,7 @@
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="log.path" value="logs/admin"/>
<property name="log.path" value="logs/epmetuser"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
@ -132,8 +132,8 @@
<springProfile name="dev,test">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet" level="INFO"/>
<logger name="com.epmet" level="DEBUG"/>
<logger name="com.epmet.dao" level="INFO"/>
<logger name="com.epmet.dao" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="INFO_FILE"/>
@ -146,7 +146,7 @@
<springProfile name="prod">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="DEBUG_FILE"/>

27
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.CustomerUserDao">
<resultMap type="com.epmet.entity.CustomerUserEntity" id="customerUserMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="wxOpenId" column="WX_OPEN_ID"/>
<result property="mobile" column="MOBILE"/>
<result property="nickname" column="NICKNAME"/>
<result property="sex" column="SEX"/>
<result property="headImgUrl" column="HEAD_IMG_URL"/>
<result property="country" column="COUNTRY"/>
<result property="province" column="PROVINCE"/>
<result property="city" column="CITY"/>
<result property="language" column="LANGUAGE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

8
epmet-module/epmet-api/pom.xml → epmet-user/pom.xml

@ -5,17 +5,17 @@
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-module</artifactId>
<artifactId>epmet-cloud</artifactId>
<version>2.0.0</version>
</parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-api</artifactId>
<artifactId>epmet-user</artifactId>
<packaging>pom</packaging>
<modules>
<module>epmet-api-client</module>
<module>epmet-api-server</module>
<module>epmet-user-client</module>
<module>epmet-user-server</module>
</modules>
</project>

1
pom.xml

@ -26,6 +26,7 @@
<module>epmet-auth</module>
<module>epmet-admin</module>
<module>epmet-module</module>
<module>epmet-user</module>
</modules>
<properties>

Loading…
Cancel
Save