diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java index 6528f86..117b60f 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java @@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.List; /** @@ -34,7 +35,7 @@ public class WindowController { @PostMapping("/save") @WebLog("窗口新增或修改") @ApiOperation("窗口新增或修改") - public void saveOrUpdate(@RequestBody WindowSaveReq req) { + public void saveOrUpdate(@RequestBody @Valid WindowSaveReq req) { windowManage.windowSaveOrUpdate(req); } diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java index 6287d06..ba0eda8 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java @@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.List; /** @@ -34,7 +35,7 @@ public class ZoneController { @PostMapping("/save") @WebLog("专区保存或修改") @ApiOperation("专区保存或修改") - public void zoneSaveOrUpdate(@RequestBody ZoneSaveReq req) { + public void zoneSaveOrUpdate(@RequestBody @Valid ZoneSaveReq req) { zoneManage.zoneSaveOrUpdate(req); } diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java index d71352f..24d011b 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java @@ -3,6 +3,9 @@ package com.ningdatech.kqapi.admin.model.req; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + /** *

* WindowSaveReq @@ -18,12 +21,15 @@ public class WindowSaveReq { private Integer id; @ApiModelProperty("专区ID") + @NotNull(message = "专区ID不能为空") private Integer zoneId; @ApiModelProperty("专区名称") + @NotBlank(message = "专区名称不能为空") private String zoneName; @ApiModelProperty("窗口名称") + @NotBlank(message = "窗口名称不能为空") private String windowName; } diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java index b6ed691..c43ab01 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java +++ b/kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java @@ -3,6 +3,8 @@ package com.ningdatech.kqapi.admin.model.req; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; + /** *

* ZoneSaveReq @@ -18,9 +20,11 @@ public class ZoneSaveReq { private Integer id; @ApiModelProperty("专区名称") + @NotBlank(message = "专区名称不能为空") private String zoneName; @ApiModelProperty("专区图标") + @NotBlank(message = "专区图标不能为空") private String zoneIcon; } 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 6f09200..ee2ce0c 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 @@ -4,11 +4,13 @@ package com.ningdatech.kqapi.user.controller; import com.ningdatech.basic.model.IdVo; import com.ningdatech.basic.model.PageVo; import com.ningdatech.kqapi.user.manage.UserInfoManage; -import com.ningdatech.kqapi.user.model.po.*; +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.UserListVO; import com.ningdatech.kqapi.user.model.vo.UserDetailVO; -import com.ningdatech.kqapi.user.service.IUserInfoService; +import com.ningdatech.kqapi.user.model.vo.UserListVO; import com.ningdatech.log.annotation.WebLog; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,7 +34,6 @@ import javax.validation.Valid; public class UserInfoController { private final UserInfoManage userInfoManage; - private final IUserInfoService iUserInfoService; @PostMapping(value = "/save") @ApiOperation(value = "保存用户") 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 f3dd0e2..301c9db 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 @@ -91,42 +91,51 @@ public class UserInfoManage { entity.setRealName(req.getRealName()); entity.setUsername(req.getUserName()); entity.setAvatarFileId(req.getAvatarFileId()); + entity.setAccountStatus(AccountStatus.ENABLE); userInfoService.saveOrUpdate(entity); if (userId == null) { - String password = passwordEncoder.encode(req.getPassword()); - List auths = new ArrayList<>(); - UserAuth accountAuth = new UserAuth(); - accountAuth.setAuthType(AuthTypeEnum.ACCOUNT_PASSWORD.name()); - accountAuth.setUserId(entity.getId()); - accountAuth.setIdentifier(entity.getUsername()); - accountAuth.setCredential(password); - auths.add(accountAuth); - UserAuth phoneAuth = new UserAuth(); - phoneAuth.setAuthType(AuthTypeEnum.PHONE_PASSWORD.name()); - phoneAuth.setUserId(entity.getId()); - phoneAuth.setIdentifier(entity.getMobile()); - phoneAuth.setCredential(password); - auths.add(phoneAuth); - userAuthService.saveBatch(auths); + saveUserAuth(req, entity); } else { - // 用户ID不为空时修改账号 - if (!oldUser.getMobile().equals(req.getPhoneNo())) { - LambdaUpdateWrapper phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getIdentifier, req.getPhoneNo()) - .eq(UserAuth::getUserId, userId) - .eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); - userAuthService.update(phoneAuth); - } - if (!oldUser.getUsername().equals(req.getUserName())) { - LambdaUpdateWrapper accountAuth = Wrappers.lambdaUpdate(UserAuth.class) - .set(UserAuth::getIdentifier, req.getUserName()) - .eq(UserAuth::getUserId, userId) - .eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); - userAuthService.update(accountAuth); - } + modifyAccount(req, oldUser, userId); + } + } + + private void modifyAccount(SaveUserReq req, UserInfo oldUser, Long userId) { + // 用户ID不为空时修改账号 + if (!oldUser.getMobile().equals(req.getPhoneNo())) { + Wrapper phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) + .set(UserAuth::getIdentifier, req.getPhoneNo()) + .eq(UserAuth::getUserId, userId) + .eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); + userAuthService.update(phoneAuth); + } + if (!oldUser.getUsername().equals(req.getUserName())) { + Wrapper accountAuth = Wrappers.lambdaUpdate(UserAuth.class) + .set(UserAuth::getIdentifier, req.getUserName()) + .eq(UserAuth::getUserId, userId) + .eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); + userAuthService.update(accountAuth); } } + private void saveUserAuth(SaveUserReq req, UserInfo entity) { + String password = passwordEncoder.encode(req.getPassword()); + List auths = new ArrayList<>(); + UserAuth accountAuth = new UserAuth(); + accountAuth.setAuthType(AuthTypeEnum.ACCOUNT_PASSWORD.name()); + accountAuth.setUserId(entity.getId()); + accountAuth.setIdentifier(entity.getUsername()); + accountAuth.setCredential(password); + auths.add(accountAuth); + UserAuth phoneAuth = new UserAuth(); + phoneAuth.setAuthType(AuthTypeEnum.PHONE_PASSWORD.name()); + phoneAuth.setUserId(entity.getId()); + phoneAuth.setIdentifier(entity.getMobile()); + phoneAuth.setCredential(password); + auths.add(phoneAuth); + userAuthService.saveBatch(auths); + } + public UserDetailVO getUserDetail(Long userId) { UserInfo info = userInfoService.getById(userId); Assert.notNull(info, "用户不存在"); diff --git a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml index 2df43e3..5e0848c 100644 --- a/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml +++ b/kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml @@ -4,7 +4,7 @@