From 25047e081ca2a84d9287b8158d735871b3c951f1 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Thu, 23 Jul 2020 07:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=94=A8=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9A=84=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/user/UserController.http | 31 +++++++++++++++++++ .../user/vo/UserUpdateStatusReqVO.java | 2 +- .../convert/user/UserConvert.java | 2 ++ .../manager/user/UserManager.java | 2 +- .../dto/OAuth2RemoveTokenByUserReqDTO.java | 3 +- .../userservice/rpc/user/dto/UserRespDTO.java | 5 +++ user-service-project/user-service-app/pom.xml | 4 +-- .../userservice/service/user/bo/UserBO.java | 6 ++++ .../src/main/resources/application-local.yaml | 8 +++-- .../src/main/resources/application.yaml | 2 +- 10 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http new file mode 100644 index 000000000..06f1b3356 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http @@ -0,0 +1,31 @@ +### /user/page 成功 +GET {{baseUrl}}/user/page?pageNo=1&pageSize=10 +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} +dubbo-tag: {{dubboTag}} + +### /user/update 成功 +POST {{baseUrl}}/user/update +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} +dubbo-tag: {{dubboTag}} + +id=31&username=user02&password=buzhidao&name=测试管理员&departmentId=1 + +### /user/update-status 成功 +POST {{baseUrl}}/user/update-status +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} +dubbo-tag: {{dubboTag}} + +userId=243&status=2 + +### /user/update-status 失败,参数缺失 +POST {{baseUrl}}/user/update-status +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} +dubbo-tag: {{dubboTag}} + +userId=31 + +### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java index 2b2103e89..6f3569f03 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java @@ -14,7 +14,7 @@ public class UserUpdateStatusReqVO { @ApiModelProperty(value = "用户编号", required = true) @NotNull(message = "用户编号不能为空") - private Integer id; + private Integer userId; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") @NotNull(message = "状态不能为空") @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java index b95492fba..844147223 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java @@ -9,6 +9,7 @@ import cn.iocoder.mall.userservice.rpc.user.dto.UserPageReqDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; @@ -28,6 +29,7 @@ public interface UserConvert { PageResult convertPage(PageResult bean); + @Mapping(source = "userId", target = "id") UserUpdateReqDTO convert(UserUpdateStatusReqVO bean); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java index 36ccc3afc..b02b0c062 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java @@ -21,7 +21,7 @@ import java.util.List; @Service public class UserManager { - @Reference(version = "$ {dubbo.consumer.UserRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.UserRpc.version}", validation = "false") private UserRpc userRpc; /** diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java index e77e8fb43..dd21a33ee 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; /** * OAuth2.0 移除用户令牌 Request DTO @@ -14,7 +15,7 @@ import javax.validation.constraints.NotNull; */ @Data @Accessors(chain = true) -public class OAuth2RemoveTokenByUserReqDTO { +public class OAuth2RemoveTokenByUserReqDTO implements Serializable { /** * 用户编号 diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java index f521bf95e..02ab476d9 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.experimental.Accessors; import java.io.Serializable; +import java.util.Date; /** * 用户信息 Response DTO @@ -35,5 +36,9 @@ public class UserRespDTO implements Serializable { * 枚举 {@link CommonStatusEnum} */ private Integer status; + /** + * 注册时间 + */ + private Date createTime; } diff --git a/user-service-project/user-service-app/pom.xml b/user-service-project/user-service-app/pom.xml index 8a4711ff9..cf93ccd66 100644 --- a/user-service-project/user-service-app/pom.xml +++ b/user-service-project/user-service-app/pom.xml @@ -13,8 +13,8 @@ - com.alibaba.cloud - spring-cloud-starter-dubbo + cn.iocoder.mall + mall-spring-boot-starter-dubbo diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserBO.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserBO.java index e366f8e2c..95647520d 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserBO.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserBO.java @@ -4,6 +4,8 @@ import cn.iocoder.common.framework.enums.CommonStatusEnum; import lombok.Data; import lombok.experimental.Accessors; +import java.util.Date; + /** * 用户信息 */ @@ -41,5 +43,9 @@ public class UserBO { * {@link #password} 的盐 */ private String passwordSalt; + /** + * 注册时间 + */ + private Date createTime; } diff --git a/user-service-project/user-service-app/src/main/resources/application-local.yaml b/user-service-project/user-service-app/src/main/resources/application-local.yaml index c64c2a1c0..0e29f2d56 100644 --- a/user-service-project/user-service-app/src/main/resources/application-local.yaml +++ b/user-service-project/user-service-app/src/main/resources/application-local.yaml @@ -11,10 +11,14 @@ spring: # Spring Cloud Nacos Discovery 配置项 discovery: server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址 - namespace: local # Nacos 命名空间 + namespace: dev # Nacos 命名空间 # Dubbo 配置项 dubbo: # Dubbo 注册中心 registry: - address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 +# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 + address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址 + # Dubbo 服务提供者的配置 + provider: + tag: ${DUBBO_TAG} # Dubbo 路由分组 diff --git a/user-service-project/user-service-app/src/main/resources/application.yaml b/user-service-project/user-service-app/src/main/resources/application.yaml index dcb6a7079..d8c2748e8 100644 --- a/user-service-project/user-service-app/src/main/resources/application.yaml +++ b/user-service-project/user-service-app/src/main/resources/application.yaml @@ -41,4 +41,4 @@ dubbo: # Dubbo 服务消费者的配置 consumer: OAuth2Rpc: - versoin: 1.0.0 + version: 1.0.0