diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 01d5a69b93..e63f9f7d69 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -117,9 +117,9 @@ http://localhost:8084 - - - http://localhost:8087 + + + http://localhost:8087 lb://epmet-demo-server @@ -171,8 +171,8 @@ lb://epmet-activiti-server lb://epmet-job-server - - lb://epmet-api-server + + lb://epmet-user-server lb://epmet-demo-server diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index 02ef41965f..a6cb5e4252 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/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流服务 diff --git a/epmet-module/epmet-api/db/mysql.sql b/epmet-module/epmet-api/db/mysql.sql deleted file mode 100644 index 184a3008be..0000000000 --- a/epmet-module/epmet-api/db/mysql.sql +++ /dev/null @@ -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()); diff --git a/epmet-module/epmet-api/db/oracle.sql b/epmet-module/epmet-api/db/oracle.sql deleted file mode 100644 index 06eef1fd2b..0000000000 --- a/epmet-module/epmet-api/db/oracle.sql +++ /dev/null @@ -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); diff --git a/epmet-module/epmet-api/db/postgresql.sql b/epmet-module/epmet-api/db/postgresql.sql deleted file mode 100644 index 93e2554c1c..0000000000 --- a/epmet-module/epmet-api/db/postgresql.sql +++ /dev/null @@ -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()); diff --git a/epmet-module/epmet-api/db/sqlserver.sql b/epmet-module/epmet-api/db/sqlserver.sql deleted file mode 100644 index 03e87976a9..0000000000 --- a/epmet-module/epmet-api/db/sqlserver.sql +++ /dev/null @@ -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()); diff --git a/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/LoginDTO.java b/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/LoginDTO.java deleted file mode 100644 index 11c7d5ac8e..0000000000 --- a/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/LoginDTO.java +++ /dev/null @@ -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; - -} diff --git a/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/RegisterDTO.java b/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/RegisterDTO.java deleted file mode 100644 index c4b15658a7..0000000000 --- a/epmet-module/epmet-api/epmet-api-client/src/main/java/com/epmet/dto/RegisterDTO.java +++ /dev/null @@ -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; - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/Login.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/Login.java deleted file mode 100644 index 8a03066f1e..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/Login.java +++ /dev/null @@ -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 { -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/LoginUser.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/LoginUser.java deleted file mode 100644 index 017b439028..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/annotation/LoginUser.java +++ /dev/null @@ -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 { - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/FilterConfig.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/FilterConfig.java deleted file mode 100644 index cb684c9043..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/FilterConfig.java +++ /dev/null @@ -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; - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/WebConfig.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/WebConfig.java deleted file mode 100644 index 076cf7740a..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/WebConfig.java +++ /dev/null @@ -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 argumentResolvers) { - argumentResolvers.add(loginUserHandlerMethodArgumentResolver); - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiLoginController.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiLoginController.java deleted file mode 100644 index de546dd5d8..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiLoginController.java +++ /dev/null @@ -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> login(@RequestBody LoginDTO dto){ - //表单校验 - ValidatorUtils.validateEntity(dto); - - //用户登录 - Map 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(); - } - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiRegisterController.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiRegisterController.java deleted file mode 100644 index b2f2e72595..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiRegisterController.java +++ /dev/null @@ -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(); - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiTestController.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiTestController.java deleted file mode 100644 index c51494f062..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/controller/ApiTestController.java +++ /dev/null @@ -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 userInfo(@ApiIgnore @LoginUser UserEntity user){ - return new Result().ok(user); - } - - @Login - @GetMapping("userId") - @ApiOperation("获取用户ID") - public Result userInfo(@ApiIgnore @RequestAttribute("userId") Long userId){ - return new Result().ok(userId); - } - - @GetMapping("notToken") - @ApiOperation("忽略Token验证测试") - public Result notToken(){ - return new Result().ok("无需token也能访问。。。"); - } - - @PostMapping("upload") - @ApiOperation(value = "上传文件") - public Result upload(@RequestParam("file") MultipartFile file) { - Result dto = ossFeignClient.upload(file); - - return dto; - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/TokenDao.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/TokenDao.java deleted file mode 100644 index 11906f4033..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/TokenDao.java +++ /dev/null @@ -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 getByToken(String token); - - TokenEntity getByUserId(Long userId); -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/UserDao.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/UserDao.java deleted file mode 100644 index bb3b664e91..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/dao/UserDao.java +++ /dev/null @@ -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 getUserByMobile(String mobile); - - UserEntity getUserByUserId(Long userId); -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/TokenEntity.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/TokenEntity.java deleted file mode 100644 index 454b237385..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/TokenEntity.java +++ /dev/null @@ -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; - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/UserEntity.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/UserEntity.java deleted file mode 100644 index 35bcfadc50..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/entity/UserEntity.java +++ /dev/null @@ -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; - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/exception/ModuleErrorCode.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/exception/ModuleErrorCode.java deleted file mode 100644 index c8495b2193..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/exception/ModuleErrorCode.java +++ /dev/null @@ -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位为业务编码 - *

- * 如:100001001(100001代表模块,001代表业务代码) - *

- * - * @author Mark sunlightcs@gmail.com - * @since 1.0.0 - */ -public interface ModuleErrorCode extends ErrorCode { - int TOKEN_NOT_EMPTY = 100005001; - int TOKEN_INVALID = 100005002; -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/interceptor/AuthorizationInterceptor.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/interceptor/AuthorizationInterceptor.java deleted file mode 100644 index d55649798b..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/interceptor/AuthorizationInterceptor.java +++ /dev/null @@ -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; - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/resolver/LoginUserHandlerMethodArgumentResolver.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/resolver/LoginUserHandlerMethodArgumentResolver.java deleted file mode 100644 index cda063fb97..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/resolver/LoginUserHandlerMethodArgumentResolver.java +++ /dev/null @@ -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; - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/TokenService.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/TokenService.java deleted file mode 100644 index f60b102c14..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/TokenService.java +++ /dev/null @@ -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 getByToken(String token); - - /** - * 生成token - * @param userId 用户ID - * @return 返回token信息 - */ - TokenEntity createToken(Long userId); - - /** - * 设置token过期 - * @param userId 用户ID - */ - void expireToken(Long userId); - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/UserService.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/UserService.java deleted file mode 100644 index 3ddb6d3d13..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/UserService.java +++ /dev/null @@ -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 getByMobile(String mobile); - - UserEntity getUserByUserId(Long userId); - - /** - * 用户登录 - * @param dto 登录表单 - * @return 返回登录信息 - */ - Map login(LoginDTO dto); -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/TokenServiceImpl.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/TokenServiceImpl.java deleted file mode 100644 index 67ad5136e9..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/TokenServiceImpl.java +++ /dev/null @@ -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 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("-", ""); - } -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java b/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java deleted file mode 100644 index 21ada0489f..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java +++ /dev/null @@ -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 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 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 map = new HashMap<>(2); - map.put("token", tokenEntity.getToken()); - map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis()); - - return map; - } - -} diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages.properties deleted file mode 100644 index fa686c6ce3..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages.properties +++ /dev/null @@ -1,3 +0,0 @@ -#Default -100005001=token\u4E0D\u80FD\u4E3A\u7A7A -100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_en_US.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_en_US.properties deleted file mode 100644 index 274cb2bf64..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_en_US.properties +++ /dev/null @@ -1,3 +0,0 @@ -#English -100005001=Token cannot be empty -100005002=Token is invalid, please log in again \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_CN.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_CN.properties deleted file mode 100644 index 7fa4392c30..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,3 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -100005001=token\u4E0D\u80FD\u4E3A\u7A7A -100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_TW.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_TW.properties deleted file mode 100644 index a31a2407b1..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,3 +0,0 @@ -#\u7E41\u4F53\u4E2D\u6587 -100005001=token\u4E0D\u80FD\u70BA\u7A7A -100005002=token\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u767B\u9304 \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation.properties deleted file mode 100644 index 4392e7d7a2..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation.properties +++ /dev/null @@ -1,3 +0,0 @@ -#Default -api.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A -api.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_en_US.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_en_US.properties deleted file mode 100644 index 190187fc07..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_en_US.properties +++ /dev/null @@ -1,3 +0,0 @@ -#English -api.mobile.require=The phone number cannot be empty -api.password.require=Password cannot be empty \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_CN.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_CN.properties deleted file mode 100644 index 830527147e..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_CN.properties +++ /dev/null @@ -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 \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_TW.properties b/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_TW.properties deleted file mode 100644 index 9864e110bb..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/i18n/validation_zh_TW.properties +++ /dev/null @@ -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 \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/TokenDao.xml b/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/TokenDao.xml deleted file mode 100644 index 8fe7fdd3ff..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/TokenDao.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/UserDao.xml b/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/UserDao.xml deleted file mode 100644 index 1097fb6474..0000000000 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/mapper/UserDao.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/epmet-module/pom.xml b/epmet-module/pom.xml index 5ab568cb98..9aca2a1ae1 100644 --- a/epmet-module/pom.xml +++ b/epmet-module/pom.xml @@ -18,7 +18,6 @@ epmet-job epmet-message epmet-activiti - epmet-api epmet-demo oper-customize oper-crm diff --git a/epmet-module/resi-guide/resi-guide-server/pom.xml b/epmet-module/resi-guide/resi-guide-server/pom.xml index eb98658a1f..f50ad1cf6d 100644 --- a/epmet-module/resi-guide/resi-guide-server/pom.xml +++ b/epmet-module/resi-guide/resi-guide-server/pom.xml @@ -89,7 +89,7 @@ - + epmet elink@833066 @@ -119,7 +119,7 @@ - + epmet elink@833066 diff --git a/epmet-module/epmet-api/epmet-api-client/pom.xml b/epmet-user/epmet-user-client/pom.xml similarity index 91% rename from epmet-module/epmet-api/epmet-api-client/pom.xml rename to epmet-user/epmet-user-client/pom.xml index e0c81bbe61..da75b38ba7 100644 --- a/epmet-module/epmet-api/epmet-api-client/pom.xml +++ b/epmet-user/epmet-user-client/pom.xml @@ -5,11 +5,11 @@ com.epmet - epmet-api + epmet-user 2.0.0 - epmet-api-client + epmet-user-client jar diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java new file mode 100644 index 0000000000..348dc373d2 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java @@ -0,0 +1,121 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/pom.xml b/epmet-user/epmet-user-server/pom.xml similarity index 90% rename from epmet-module/epmet-api/epmet-api-server/pom.xml rename to epmet-user/epmet-user-server/pom.xml index 1cbb7b6674..80043ebabe 100644 --- a/epmet-module/epmet-api/epmet-api-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -5,32 +5,27 @@ com.epmet - epmet-api + epmet-user 2.0.0 - epmet-api-server + epmet-user-server jar com.epmet - epmet-oss-client + epmet-user-client 2.0.0 com.epmet - epmet-api-client - 2.0.0 - - - com.epmet - epmet-commons-tools + epmet-commons-mybatis 2.0.0 com.epmet - epmet-commons-mybatis + epmet-commons-dynamic-datasource 2.0.0 @@ -70,6 +65,7 @@ + ${project.basedir}/src/main/java @@ -78,21 +74,20 @@ + dev - true - 8087 dev - + epmet elink@833066 @@ -113,13 +108,16 @@ test + 8087 test - + epmet elink@833066 diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/ApiApplication.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java similarity index 59% rename from epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/ApiApplication.java rename to epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java index d7c39bbe4e..7d54b4e248 100644 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/ApiApplication.java +++ b/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); } } diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/config/ModuleConfigImpl.java similarity index 94% rename from epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/ModuleConfigImpl.java rename to epmet-user/epmet-user-server/src/main/java/com/epmet/config/ModuleConfigImpl.java index 0417544104..583ecbea38 100644 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/ModuleConfigImpl.java +++ b/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"; } } diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/SwaggerConfig.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/config/SwaggerConfig.java similarity index 85% rename from epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/SwaggerConfig.java rename to epmet-user/epmet-user-server/src/main/java/com/epmet/config/SwaggerConfig.java index 6e70b9a800..e4ceef42ee 100644 --- a/epmet-module/epmet-api/epmet-api-server/src/main/java/com/epmet/config/SwaggerConfig.java +++ b/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(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java new file mode 100644 index 0000000000..ae4187b65d --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> page(@RequestParam Map params){ + PageData page = customerUserService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CustomerUserDTO data = customerUserService.get(id); + return new Result().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 params, HttpServletResponse response) throws Exception { + List list = customerUserService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, CustomerUserExcel.class); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java new file mode 100644 index 0000000000..e41ca338d6 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java new file mode 100644 index 0000000000..11a6e86b09 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java new file mode 100644 index 0000000000..e1d2bc9aec --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java new file mode 100644 index 0000000000..f70ed57881 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java new file mode 100644 index 0000000000..39ebe54c91 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-16 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-16 + */ + List list(Map 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); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java new file mode 100644 index 0000000000..59e3ccafaa --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 implements CustomerUserService { + + @Autowired + private CustomerUserRedis customerUserRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerUserDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerUserDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper 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)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml similarity index 74% rename from epmet-module/epmet-api/epmet-api-server/src/main/resources/bootstrap.yml rename to epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index 0ccc09e3b7..f7070de4b7 100644 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/bootstrap.yml +++ b/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: diff --git a/epmet-module/epmet-api/epmet-api-server/src/main/resources/logback-spring.xml b/epmet-user/epmet-user-server/src/main/resources/logback-spring.xml similarity index 97% rename from epmet-module/epmet-api/epmet-api-server/src/main/resources/logback-spring.xml rename to epmet-user/epmet-user-server/src/main/resources/logback-spring.xml index 18a82fd8e0..c34321a409 100644 --- a/epmet-module/epmet-api/epmet-api-server/src/main/resources/logback-spring.xml +++ b/epmet-user/epmet-user-server/src/main/resources/logback-spring.xml @@ -2,7 +2,7 @@ - + - - + + @@ -146,7 +146,7 @@ - + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml new file mode 100644 index 0000000000..14a5b36bc6 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-api/pom.xml b/epmet-user/pom.xml similarity index 75% rename from epmet-module/epmet-api/pom.xml rename to epmet-user/pom.xml index 58f74bf69f..9e06fd4e2f 100644 --- a/epmet-module/epmet-api/pom.xml +++ b/epmet-user/pom.xml @@ -5,17 +5,17 @@ com.epmet - epmet-module + epmet-cloud 2.0.0 com.epmet - epmet-api + epmet-user pom - epmet-api-client - epmet-api-server + epmet-user-client + epmet-user-server diff --git a/pom.xml b/pom.xml index 5f1a213922..741f491b12 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ epmet-auth epmet-admin epmet-module + epmet-user