From 88bf00901b5c152a6113ab7f4ae5e00b50917c08 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 22 Apr 2024 15:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kqapi/pom.xml | 4 +++ .../kqapi/user/controller/UserInfoController.java | 6 ++-- .../kqapi/user/manage/UserInfoManage.java | 38 ++++++++++------------ .../kqapi/user/model/vo/LoginUserDetailVO.java | 28 ++++++++++++++++ .../kqapi/user/model/vo/UserBasicInfoVO.java | 28 ---------------- kqapi/src/main/resources/application-prod.yml | 2 +- .../classes/BOOT-INF/classes/application-prod.yml | 2 +- .../META-INF/spring-configuration-metadata.json | 3 +- kqapi/target/classes/application-prod.yml | 2 +- 9 files changed, 56 insertions(+), 57 deletions(-) create mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java delete mode 100644 kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserBasicInfoVO.java diff --git a/kqapi/pom.xml b/kqapi/pom.xml index 652d3ef..1d58531 100644 --- a/kqapi/pom.xml +++ b/kqapi/pom.xml @@ -145,6 +145,10 @@ com.ningdatech nd-swagger2-starter + + com.ningdatech + nd-file-starter + diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java index ee2ce0c..c56b5c5 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java @@ -8,7 +8,7 @@ import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; import com.ningdatech.kqapi.user.model.po.SaveUserReq; import com.ningdatech.kqapi.user.model.po.UserListReq; -import com.ningdatech.kqapi.user.model.vo.UserBasicInfoVO; +import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; import com.ningdatech.kqapi.user.model.vo.UserDetailVO; import com.ningdatech.kqapi.user.model.vo.UserListVO; import com.ningdatech.log.annotation.WebLog; @@ -73,8 +73,8 @@ public class UserInfoController { @PostMapping(value = "/basic-info") @ApiOperation("获取用户基本信息") @WebLog(value = "获取用户基本信息") - public UserBasicInfoVO getBasicInfo() { - return userInfoManage.getBasicInfo(); + public LoginUserDetailVO loginUserDetail() { + return userInfoManage.loginUserDetail(); } @PostMapping("/kick-off/{userId}") diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java index 301c9db..1b2f101 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java @@ -21,7 +21,7 @@ import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; import com.ningdatech.kqapi.user.model.po.SaveUserReq; import com.ningdatech.kqapi.user.model.po.UserListReq; import com.ningdatech.kqapi.user.model.vo.UserListVO; -import com.ningdatech.kqapi.user.model.vo.UserBasicInfoVO; +import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; import com.ningdatech.kqapi.user.model.vo.UserDetailVO; import com.ningdatech.kqapi.user.service.IUserAuthService; import com.ningdatech.kqapi.user.service.IUserInfoService; @@ -36,7 +36,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.*; -import java.util.function.Function; +import java.util.stream.Collectors; /** @@ -158,27 +158,24 @@ public class UserInfoManage { .eq(StrUtil.isNotBlank(req.getMobile()), UserInfo::getMobile, req.getMobile()) .orderByDesc(UserInfo::getUpdateOn); Page page = userInfoService.page(req.page(), query); - PageVo pageVo = new PageVo<>(); - long total = page.getTotal(); - pageVo.setTotal(total); - if (total > 0) { - Function mapping = r -> { - UserListVO res = new UserListVO(); - res.setUserId(r.getId()); - res.setRealName(r.getRealName()); - res.setCreateTime(r.getCreateOn()); - res.setPhoneNo(r.getMobile()); - res.setAccountStatus(r.getAccountStatus()); - return res; - }; - pageVo.setRecords(CollUtils.convert(page.getRecords(), mapping)); + if (page.getTotal() == 0) { + return PageVo.empty(); } - return pageVo; + List data = page.getRecords().stream().map(r -> { + UserListVO res = new UserListVO(); + res.setUserId(r.getId()); + res.setRealName(r.getRealName()); + res.setCreateTime(r.getCreateOn()); + res.setPhoneNo(r.getMobile()); + res.setAccountStatus(r.getAccountStatus()); + return res; + }).collect(Collectors.toList()); + return PageVo.of(data, page.getTotal()); } - public UserBasicInfoVO getBasicInfo() { + public LoginUserDetailVO loginUserDetail() { UserInfoDetails details = LoginUserUtil.loginUserDetail(); - UserBasicInfoVO result = new UserBasicInfoVO(); + LoginUserDetailVO result = new LoginUserDetailVO(); result.setUserId(details.getUserId()); result.setRealName(details.getRealName()); return result; @@ -189,8 +186,7 @@ public class UserInfoManage { .eq(UserAuth::getIdentifier, identifier) .ne(userId != null, UserAuth::getUserId, userId) .last(BizConst.LIMIT_1); - UserAuth userAuth = userAuthService.getOne(query); - if (Objects.nonNull(userAuth)) { + if (userAuthService.count(query) > 0) { throw new BizException("当前账号已经注册"); } diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java new file mode 100644 index 0000000..f914631 --- /dev/null +++ b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/LoginUserDetailVO.java @@ -0,0 +1,28 @@ +package com.ningdatech.kqapi.user.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * ResUserBasicInfoVO + *

+ * + * @author WendyYang + * @since 10:30 2024/4/20 + */ +@Data +@ApiModel("用户基本信息") +public class LoginUserDetailVO { + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("用户真实姓名") + private String realName; + + @ApiModelProperty("用户手机号") + private String phoneNo; + +} diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserBasicInfoVO.java b/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserBasicInfoVO.java deleted file mode 100644 index bad231c..0000000 --- a/kqapi/src/main/java/com/ningdatech/kqapi/user/model/vo/UserBasicInfoVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ningdatech.kqapi.user.model.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - *

- * ResUserBasicInfoVO - *

- * - * @author WendyYang - * @since 10:30 2024/4/20 - */ -@Data -@ApiModel("用户基本信息") -public class UserBasicInfoVO { - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("用户真实姓名") - private String realName; - - @ApiModelProperty("用户手机号") - private String phoneNo; - -} diff --git a/kqapi/src/main/resources/application-prod.yml b/kqapi/src/main/resources/application-prod.yml index 786db38..56dfaa5 100644 --- a/kqapi/src/main/resources/application-prod.yml +++ b/kqapi/src/main/resources/application-prod.yml @@ -118,7 +118,7 @@ log: total-size: 50MB swagger: - enabled: true + enabled: false hostname: iZut201mqskxt0mwme4tjfZ diff --git a/kqapi/target/classes/BOOT-INF/classes/application-prod.yml b/kqapi/target/classes/BOOT-INF/classes/application-prod.yml index 786db38..56dfaa5 100644 --- a/kqapi/target/classes/BOOT-INF/classes/application-prod.yml +++ b/kqapi/target/classes/BOOT-INF/classes/application-prod.yml @@ -118,7 +118,7 @@ log: total-size: 50MB swagger: - enabled: true + enabled: false hostname: iZut201mqskxt0mwme4tjfZ diff --git a/kqapi/target/classes/META-INF/spring-configuration-metadata.json b/kqapi/target/classes/META-INF/spring-configuration-metadata.json index b67fca4..e7eb022 100644 --- a/kqapi/target/classes/META-INF/spring-configuration-metadata.json +++ b/kqapi/target/classes/META-INF/spring-configuration-metadata.json @@ -85,8 +85,7 @@ { "name": "security.auth.post-only-by-login", "type": "java.lang.Boolean", - "sourceType": "com.ningdatech.kqapi.security.AuthProperties", - "defaultValue": true + "sourceType": "com.ningdatech.kqapi.security.AuthProperties" }, { "name": "security.auth.role-map", diff --git a/kqapi/target/classes/application-prod.yml b/kqapi/target/classes/application-prod.yml index 786db38..56dfaa5 100644 --- a/kqapi/target/classes/application-prod.yml +++ b/kqapi/target/classes/application-prod.yml @@ -118,7 +118,7 @@ log: total-size: 50MB swagger: - enabled: true + enabled: false hostname: iZut201mqskxt0mwme4tjfZ