@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import javax.validation.Valid; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@@ -34,7 +35,7 @@ public class WindowController { | |||||
@PostMapping("/save") | @PostMapping("/save") | ||||
@WebLog("窗口新增或修改") | @WebLog("窗口新增或修改") | ||||
@ApiOperation("窗口新增或修改") | @ApiOperation("窗口新增或修改") | ||||
public void saveOrUpdate(@RequestBody WindowSaveReq req) { | |||||
public void saveOrUpdate(@RequestBody @Valid WindowSaveReq req) { | |||||
windowManage.windowSaveOrUpdate(req); | windowManage.windowSaveOrUpdate(req); | ||||
} | } | ||||
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import javax.validation.Valid; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@@ -34,7 +35,7 @@ public class ZoneController { | |||||
@PostMapping("/save") | @PostMapping("/save") | ||||
@WebLog("专区保存或修改") | @WebLog("专区保存或修改") | ||||
@ApiOperation("专区保存或修改") | @ApiOperation("专区保存或修改") | ||||
public void zoneSaveOrUpdate(@RequestBody ZoneSaveReq req) { | |||||
public void zoneSaveOrUpdate(@RequestBody @Valid ZoneSaveReq req) { | |||||
zoneManage.zoneSaveOrUpdate(req); | zoneManage.zoneSaveOrUpdate(req); | ||||
} | } | ||||
@@ -3,6 +3,9 @@ package com.ningdatech.kqapi.admin.model.req; | |||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* WindowSaveReq | * WindowSaveReq | ||||
@@ -18,12 +21,15 @@ public class WindowSaveReq { | |||||
private Integer id; | private Integer id; | ||||
@ApiModelProperty("专区ID") | @ApiModelProperty("专区ID") | ||||
@NotNull(message = "专区ID不能为空") | |||||
private Integer zoneId; | private Integer zoneId; | ||||
@ApiModelProperty("专区名称") | @ApiModelProperty("专区名称") | ||||
@NotBlank(message = "专区名称不能为空") | |||||
private String zoneName; | private String zoneName; | ||||
@ApiModelProperty("窗口名称") | @ApiModelProperty("窗口名称") | ||||
@NotBlank(message = "窗口名称不能为空") | |||||
private String windowName; | private String windowName; | ||||
} | } |
@@ -3,6 +3,8 @@ package com.ningdatech.kqapi.admin.model.req; | |||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
import javax.validation.constraints.NotBlank; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* ZoneSaveReq | * ZoneSaveReq | ||||
@@ -18,9 +20,11 @@ public class ZoneSaveReq { | |||||
private Integer id; | private Integer id; | ||||
@ApiModelProperty("专区名称") | @ApiModelProperty("专区名称") | ||||
@NotBlank(message = "专区名称不能为空") | |||||
private String zoneName; | private String zoneName; | ||||
@ApiModelProperty("专区图标") | @ApiModelProperty("专区图标") | ||||
@NotBlank(message = "专区图标不能为空") | |||||
private String zoneIcon; | private String zoneIcon; | ||||
} | } |
@@ -4,11 +4,13 @@ package com.ningdatech.kqapi.user.controller; | |||||
import com.ningdatech.basic.model.IdVo; | import com.ningdatech.basic.model.IdVo; | ||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.kqapi.user.manage.UserInfoManage; | 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.UserBasicInfoVO; | ||||
import com.ningdatech.kqapi.user.model.vo.UserListVO; | |||||
import com.ningdatech.kqapi.user.model.vo.UserDetailVO; | 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 com.ningdatech.log.annotation.WebLog; | ||||
import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
@@ -32,7 +34,6 @@ import javax.validation.Valid; | |||||
public class UserInfoController { | public class UserInfoController { | ||||
private final UserInfoManage userInfoManage; | private final UserInfoManage userInfoManage; | ||||
private final IUserInfoService iUserInfoService; | |||||
@PostMapping(value = "/save") | @PostMapping(value = "/save") | ||||
@ApiOperation(value = "保存用户") | @ApiOperation(value = "保存用户") | ||||
@@ -91,42 +91,51 @@ public class UserInfoManage { | |||||
entity.setRealName(req.getRealName()); | entity.setRealName(req.getRealName()); | ||||
entity.setUsername(req.getUserName()); | entity.setUsername(req.getUserName()); | ||||
entity.setAvatarFileId(req.getAvatarFileId()); | entity.setAvatarFileId(req.getAvatarFileId()); | ||||
entity.setAccountStatus(AccountStatus.ENABLE); | |||||
userInfoService.saveOrUpdate(entity); | userInfoService.saveOrUpdate(entity); | ||||
if (userId == null) { | if (userId == null) { | ||||
String password = passwordEncoder.encode(req.getPassword()); | |||||
List<UserAuth> 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 { | } else { | ||||
// 用户ID不为空时修改账号 | |||||
if (!oldUser.getMobile().equals(req.getPhoneNo())) { | |||||
LambdaUpdateWrapper<UserAuth> 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<UserAuth> 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<UserAuth> 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<UserAuth> 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<UserAuth> 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) { | public UserDetailVO getUserDetail(Long userId) { | ||||
UserInfo info = userInfoService.getById(userId); | UserInfo info = userInfoService.getById(userId); | ||||
Assert.notNull(info, "用户不存在"); | Assert.notNull(info, "用户不存在"); | ||||
@@ -4,7 +4,7 @@ | |||||
<select id="selectMatterCountByWindowIds" | <select id="selectMatterCountByWindowIds" | ||||
resultType="com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO"> | resultType="com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO"> | ||||
select window_id as windowId, count(1) as matterCount from nd_zzsfw_menu | |||||
select window_id as windowId, count(1) as matterCount from nd_kq_zzsfw_menu | |||||
where deleted = 0 and window_id in | where deleted = 0 and window_id in | ||||
<foreach collection="windowIds" item="windowId" open="(" separator="," close=")"> | <foreach collection="windowIds" item="windowId" open="(" separator="," close=")"> | ||||
#{windowId} | #{windowId} | ||||
@@ -1,5 +1,5 @@ | |||||
#Generated by Maven | #Generated by Maven | ||||
#Mon Apr 22 11:25:10 CST 2024 | |||||
#Mon Apr 22 14:37:24 CST 2024 | |||||
version=1.0.0 | version=1.0.0 | ||||
groupId=com.ningdatech | groupId=com.ningdatech | ||||
artifactId=kqapi | artifactId=kqapi |