Browse Source

增加参数校验

master
WendyYang 8 months ago
parent
commit
23991a2d08
10 changed files with 60 additions and 38 deletions
  1. +2
    -1
      kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java
  2. +2
    -1
      kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java
  3. +6
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java
  4. +4
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java
  5. +5
    -4
      kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java
  6. +39
    -30
      kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java
  7. +1
    -1
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml
  8. BIN
      kqapi/target/kqapi.jar
  9. BIN
      kqapi/target/kqapi.jar.original
  10. +1
    -1
      kqapi/target/maven-archiver/pom.properties

+ 2
- 1
kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/WindowController.java View File

@@ -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);
}



+ 2
- 1
kqapi/src/main/java/com/ningdatech/kqapi/admin/controller/ZoneController.java View File

@@ -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);
}



+ 6
- 0
kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/WindowSaveReq.java View File

@@ -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;

/**
* <p>
* 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;

}

+ 4
- 0
kqapi/src/main/java/com/ningdatech/kqapi/admin/model/req/ZoneSaveReq.java View File

@@ -3,6 +3,8 @@ package com.ningdatech.kqapi.admin.model.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
* <p>
* ZoneSaveReq
@@ -18,9 +20,11 @@ public class ZoneSaveReq {
private Integer id;

@ApiModelProperty("专区名称")
@NotBlank(message = "专区名称不能为空")
private String zoneName;

@ApiModelProperty("专区图标")
@NotBlank(message = "专区图标不能为空")
private String zoneIcon;

}

+ 5
- 4
kqapi/src/main/java/com/ningdatech/kqapi/user/controller/UserInfoController.java View File

@@ -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 = "保存用户")


+ 39
- 30
kqapi/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java View File

@@ -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<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 {
// 用户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) {
UserInfo info = userInfoService.getById(userId);
Assert.notNull(info, "用户不存在");


+ 1
- 1
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/KqZzsfwMenuMapper.xml View File

@@ -4,7 +4,7 @@

<select id="selectMatterCountByWindowIds"
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
<foreach collection="windowIds" item="windowId" open="(" separator="," close=")">
#{windowId}


BIN
kqapi/target/kqapi.jar View File


BIN
kqapi/target/kqapi.jar.original View File


+ 1
- 1
kqapi/target/maven-archiver/pom.properties View File

@@ -1,5 +1,5 @@
#Generated by Maven
#Mon Apr 22 11:25:10 CST 2024
#Mon Apr 22 14:37:24 CST 2024
version=1.0.0
groupId=com.ningdatech
artifactId=kqapi

Loading…
Cancel
Save