TRX 1 年間 前
コミット
72bec6fdfe

+ 20 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/UserCountUpdateParam.java

@@ -0,0 +1,20 @@
+package com.zhongshu.card.client.model.org;
+
+import com.zhongshu.card.client.utils.type.Sex;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 用户基本信息编辑
+ *
+ * @author TRX
+ * @date 2024/6/17
+ */
+@Data
+public class UserCountUpdateParam {
+    @Schema(description = "姓名")
+    private String name;
+
+    @Schema(description = "性别")
+    private Sex sex;
+}

+ 6 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/service/org/UserAccountService.java

@@ -36,6 +36,12 @@ public interface UserAccountService {
     // 当前用户修改密码
     ResultContent updatePassWord(PassWordModel param);
 
+    // 修改用户头像
+    ResultContent updateUserHead(String url);
+
+    // 编辑当前用户的基本信息
+    ResultContent updateUserInfo(UserCountUpdateParam param);
+
     // 重置用户密码(默认密码)
     ResultContent resetPassWord(UserIdModel param);
 

+ 20 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/UserInfoController.java

@@ -4,22 +4,18 @@ import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.model.base.AuthTypeParam;
-import com.zhongshu.card.client.model.org.OrganizationModel;
-import com.zhongshu.card.client.model.org.OrganizationUserSearch;
-import com.zhongshu.card.client.model.org.PassWordModel;
-import com.zhongshu.card.client.model.org.UserCountDetailsModel;
+import com.zhongshu.card.client.model.org.*;
 import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.client.service.org.UserAccountService;
 import com.zhongshu.card.client.utils.type.UserState;
 import com.zhongshu.card.server.core.service.org.IndexService;
 import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -69,6 +65,22 @@ public class UserInfoController {
         return userAccountService.updatePassWord(param);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "修改用户头像", description = "修改用户头像")
+    @RequestMapping(value = {"updateUserHead"}, method = {RequestMethod.GET})
+    public ResultContent<UserCountDetailsModel> updateUserHead(@Parameter(name = "url", description = "头像url", example = "")
+    @RequestParam("url") String url) {
+        return userAccountService.updateUserHead(url);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "编辑当前用户的基本信息", description = "编辑当前用户的基本信息")
+    @RequestMapping(value = {"updateUserInfo"}, method = {RequestMethod.GET})
+    public ResultContent<UserCountDetailsModel> updateUserInfo(UserCountUpdateParam param) {
+        Assert.hasText(param.getName(), "name不能为空");
+        return userAccountService.updateUserInfo(param);
+    }
+
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "查询用户加入的平台数据列表", description = "查询用户加入的 平台数据列表")
     @RequestMapping(value = {"getUserPlatform"}, method = {RequestMethod.GET})

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/UserAccount.java

@@ -65,7 +65,7 @@ public class UserAccount extends SuperMain {
     UserType userType;
 
     @Schema(description = "是否已修改了密码 (登录时提示)")
-    private Boolean isUpdatedPsw;
+    private Boolean isUpdatedPsw = Boolean.FALSE;
 
     @Schema(description = "是否登录过")
     private Boolean isLogined = Boolean.FALSE;

+ 23 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/UserAccountServiceImpl.java

@@ -247,8 +247,7 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
                 passWord = passWord.toLowerCase().replace("x", "0");
             }
             //权限中心:添加用户
-            com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(UserAuthModel.builder().loginType(LoginType.Phone)
-                    .loginValue(loginName).passWord(passWord).build());
+            com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(UserAuthModel.builder().loginType(LoginType.Phone).loginValue(loginName).passWord(passWord).build());
             if (addModelResult.getState() != ResultState.Success) {
                 return ResultContent.buildFail(String.format("权限中心添加用户出错:%s", addModelResult.getMsg()));
             }
@@ -391,6 +390,7 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
         return ResultContent.buildSuccess();
     }
 
+
     /**
      * 编辑当前用户头像
      *
@@ -409,6 +409,25 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 编辑当前用户的基本信息
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent updateUserInfo(UserCountUpdateParam param) {
+        String userId = getCurrentUserId();
+        Assert.hasText(userId, "当前用户userId为空");
+        UserAccount account = userCountDao.findTopByUserId(userId);
+        if (ObjectUtils.isEmpty(account)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, userId));
+        }
+        BeanUtils.copyProperties(param, account);
+        account.setSpellCode(CommonUtil.getPinyin(account.getName()));
+        userCountDao.save(account);
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * 重置密码
      *
@@ -560,14 +579,12 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
 
             // 角色信息
             if (ObjectUtils.isNotEmpty(entity.getRoles())) {
-                List<RoleModel> roleModels = entity.getRoles().stream().map(roleServiceImpl::toModel)
-                        .collect(Collectors.toList());
+                List<RoleModel> roleModels = entity.getRoles().stream().map(roleServiceImpl::toModel).collect(Collectors.toList());
                 model.setRoles(roleModels);
             }
             // 部门信息
             if (ObjectUtils.isNotEmpty(entity.getDepartments())) {
-                List<DepartmentModel> roleModels = entity.getDepartments().stream().map(departmentService::toModel)
-                        .collect(Collectors.toList());
+                List<DepartmentModel> roleModels = entity.getDepartments().stream().map(departmentService::toModel).collect(Collectors.toList());
                 model.setDepartments(roleModels);
             }
         }