fix: 优化代码
This commit is contained in:
parent
26931a5fbc
commit
15c5938dfe
@ -188,12 +188,13 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case "stationName":
|
case "stationName":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
importRow.getWarnings().add("ennm");
|
importRow.getWarnings().add("rstcd");
|
||||||
data.setEnnm(cellValue.trim());
|
data.setEnnm(cellValue.trim());
|
||||||
|
data.setRstcd(cellValue);
|
||||||
} else {
|
} else {
|
||||||
String stcd = resolveStationCode(cellValue.trim());
|
String stcd = resolveStationCode(cellValue.trim());
|
||||||
if (stcd == null) {
|
if (stcd == null) {
|
||||||
importRow.getWarnings().add("ennm");
|
importRow.getWarnings().add("rstcd");
|
||||||
data.setEnnm(cellValue.trim());
|
data.setEnnm(cellValue.trim());
|
||||||
} else {
|
} else {
|
||||||
data.setEnnm(cellValue.trim());
|
data.setEnnm(cellValue.trim());
|
||||||
@ -330,6 +331,8 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
if (StringUtils.hasText(cellValue)) {
|
if (StringUtils.hasText(cellValue)) {
|
||||||
String isfs = resolveIsfs(cellValue.trim(), importRow);
|
String isfs = resolveIsfs(cellValue.trim(), importRow);
|
||||||
data.setIsfs("1".equals(isfs) ? 1 : 0);
|
data.setIsfs("1".equals(isfs) ? 1 : 0);
|
||||||
|
}else{
|
||||||
|
importRow.getWarnings().add("isfs");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "sourceType":
|
case "sourceType":
|
||||||
@ -337,7 +340,8 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
break;
|
break;
|
||||||
case "stnm":
|
case "stnm":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("stcd");
|
importRow.getWarnings().add("stcd");
|
||||||
|
data.setStcd(cellValue);
|
||||||
} else {
|
} else {
|
||||||
String stcd = resolveFpssCode(cellValue.trim());
|
String stcd = resolveFpssCode(cellValue.trim());
|
||||||
if (stcd == null) {
|
if (stcd == null) {
|
||||||
|
|||||||
@ -66,16 +66,18 @@ public class SdHycdDicController {
|
|||||||
@Operation(summary = "下拉框列表查询")
|
@Operation(summary = "下拉框列表查询")
|
||||||
public ResponseResult selectForDropdown(
|
public ResponseResult selectForDropdown(
|
||||||
@RequestParam(required = false) String hynm,
|
@RequestParam(required = false) String hynm,
|
||||||
@RequestParam(required = false) Integer grd) {
|
@RequestParam(required = false) Integer grd,
|
||||||
return ResponseResult.successData(hycdDicService.selectForDropdown(hynm, grd));
|
@RequestParam(required = false) Integer lx) {
|
||||||
|
return ResponseResult.successData(hycdDicService.selectForDropdown(hynm, grd,lx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/regDropdown")
|
@GetMapping("/regDropdown")
|
||||||
@Operation(summary = "下拉框列表查询(注册)")
|
@Operation(summary = "下拉框列表查询(注册)")
|
||||||
public ResponseResult regDropdown(
|
public ResponseResult regDropdown(
|
||||||
@RequestParam(required = false) String hynm,
|
@RequestParam(required = false) String hynm,
|
||||||
@RequestParam(required = false) Integer grd) {
|
@RequestParam(required = false) Integer grd,
|
||||||
return ResponseResult.successData(hycdDicService.regDropdown(hynm, grd));
|
@RequestParam(required = false) Integer lx) {
|
||||||
|
return ResponseResult.successData(hycdDicService.regDropdown(hynm, grd,lx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,6 @@ public class SdHycdDic implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 类型 1:集团 ;2:公司
|
* 类型 1:集团 ;2:公司
|
||||||
*/
|
*/
|
||||||
private String lx;
|
private Integer lx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public interface ISdHycdDicService extends IService<SdHycdDic> {
|
|||||||
/**
|
/**
|
||||||
* 下拉框列表查询(支持名称和级别过滤)
|
* 下拉框列表查询(支持名称和级别过滤)
|
||||||
*/
|
*/
|
||||||
List<SdHycdDic> selectForDropdown(String hynm, Integer grd);
|
List<SdHycdDic> selectForDropdown(String hynm, Integer grd,Integer lx);
|
||||||
|
|
||||||
List<SdHycdDic> regDropdown(String hynm, Integer grd);
|
List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,19 +58,21 @@ public class SdHycdDicServiceImpl extends ServiceImpl<SdHycdDicMapper, SdHycdDic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SdHycdDic> selectForDropdown(String hynm, Integer grd) {
|
public List<SdHycdDic> selectForDropdown(String hynm, Integer grd, Integer lx) {
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
||||||
.eq(grd != null, SdHycdDic::getGrd, grd)
|
.eq(grd != null, SdHycdDic::getGrd, grd)
|
||||||
|
.eq(lx != null, SdHycdDic::getLx, lx)
|
||||||
.orderByAsc(SdHycdDic::getOrderIndex)
|
.orderByAsc(SdHycdDic::getOrderIndex)
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SdHycdDic> regDropdown(String hynm, Integer grd) {
|
public List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx) {
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
||||||
.eq(grd != null, SdHycdDic::getGrd, grd)
|
.eq(grd != null, SdHycdDic::getGrd, grd)
|
||||||
|
.eq(lx != null, SdHycdDic::getLx, lx)
|
||||||
.orderByAsc(SdHycdDic::getOrderIndex)
|
.orderByAsc(SdHycdDic::getOrderIndex)
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -60,26 +58,42 @@ public class SmsVerifyCodeController {
|
|||||||
public ResponseResult sendVerifyCode(@RequestBody SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
public ResponseResult sendVerifyCode(@RequestBody SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
||||||
String phone = smsVerifyCodeRequest.getPhone();
|
String phone = smsVerifyCodeRequest.getPhone();
|
||||||
Integer type = smsVerifyCodeRequest.getType();
|
Integer type = smsVerifyCodeRequest.getType();
|
||||||
|
|
||||||
if (phone == null || phone.isEmpty()) {
|
if (phone == null || phone.isEmpty()) {
|
||||||
return ResponseResult.error("手机号不能为空");
|
return ResponseResult.error("手机号不能为空");
|
||||||
}
|
}
|
||||||
if (type == null || (!type.equals(SmsVerifyCode.TYPE_REGISTER) && !type.equals(SmsVerifyCode.TYPE_FIND_PASSWORD))) {
|
if (type == null) {
|
||||||
return ResponseResult.error("类型错误:1-注册 2-找回密码");
|
return ResponseResult.error("类型不能为空:1-注册 2-找回密码 3-登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1. 注册验证码校验
|
||||||
if (type.equals(SmsVerifyCode.TYPE_REGISTER)) {
|
if (type.equals(SmsVerifyCode.TYPE_REGISTER)) {
|
||||||
SysUser existUser = userService.getUserByPhone(phone);
|
SysUser existUser = userService.getUserByPhone(phone);
|
||||||
if (existUser != null) {
|
if (existUser != null) {
|
||||||
return ResponseResult.error("该手机号已注册");
|
return ResponseResult.error("该手机号已注册");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 2. 找回密码验证码校验
|
||||||
if (type.equals(SmsVerifyCode.TYPE_FIND_PASSWORD)) {
|
else if (type.equals(SmsVerifyCode.TYPE_FIND_PASSWORD)) {
|
||||||
SysUser existUser = userService.getUserByPhone(phone);
|
SysUser existUser = userService.getUserByPhone(phone);
|
||||||
if (existUser == null) {
|
if (existUser == null) {
|
||||||
return ResponseResult.error("该手机号未注册");
|
return ResponseResult.error("该手机号未注册");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 3. 登录验证码校验(新增)
|
||||||
|
else if (type.equals(SmsVerifyCode.TYPE_LOGIN)) {
|
||||||
|
SysUser existUser = userService.getUserByPhone(phone);
|
||||||
|
if (existUser == null) {
|
||||||
|
return ResponseResult.error("该手机号未注册,请先注册");
|
||||||
|
}
|
||||||
|
// 可选:如果用户状态异常(如被禁用),也可以在此处拦截
|
||||||
|
// if (existUser.getStatus() == 0) {
|
||||||
|
// return ResponseResult.error("账号已被禁用");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ResponseResult.error("类型错误:1-注册 2-找回密码 3-登录");
|
||||||
|
}
|
||||||
|
|
||||||
String code = smsVerifyCodeService.sendVerifyCode(phone, type);
|
String code = smsVerifyCodeService.sendVerifyCode(phone, type);
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
@ -89,6 +103,7 @@ public class SmsVerifyCodeController {
|
|||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户
|
* 注册用户
|
||||||
*/
|
*/
|
||||||
@ -118,17 +133,16 @@ public class SmsVerifyCodeController {
|
|||||||
if (existUser != null) {
|
if (existUser != null) {
|
||||||
return ResponseResult.error("该手机号已注册");
|
return ResponseResult.error("该手机号已注册");
|
||||||
}
|
}
|
||||||
|
SysUser user = new SysUser();
|
||||||
try {
|
try {
|
||||||
RsaUtils.decryptByPrivateKey(privateKey, smsVerifyCodeRequest.getPassword());
|
String password = RsaUtils.decryptByPrivateKey(privateKey, smsVerifyCodeRequest.getPassword());
|
||||||
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
user.setPassword(passwordEncoder.encode(password));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseResult.error("密码解密失败");
|
return ResponseResult.error("密码解密失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
SysUser user = new SysUser();
|
|
||||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
|
||||||
user.setRegStatus(0);
|
user.setRegStatus(0);
|
||||||
|
user.setPhone(smsVerifyCodeRequest.getPhone());
|
||||||
user.setBelongingUnit(smsVerifyCodeRequest.getBelongingUnit());
|
user.setBelongingUnit(smsVerifyCodeRequest.getBelongingUnit());
|
||||||
user.setRegTime(new Date());
|
user.setRegTime(new Date());
|
||||||
user.setNickname(smsVerifyCodeRequest.getRealName());
|
user.setNickname(smsVerifyCodeRequest.getRealName());
|
||||||
@ -151,7 +165,9 @@ public class SmsVerifyCodeController {
|
|||||||
String companyCode = smsVerifyCodeRequest.getCompanyCode();
|
String companyCode = smsVerifyCodeRequest.getCompanyCode();
|
||||||
String groupCode = smsVerifyCodeRequest.getGroupCode();
|
String groupCode = smsVerifyCodeRequest.getGroupCode();
|
||||||
String hbrvcdCode = smsVerifyCodeRequest.getHbrvcdCode();
|
String hbrvcdCode = smsVerifyCodeRequest.getHbrvcdCode();
|
||||||
|
List<String> roleIds=new ArrayList<>();
|
||||||
|
roleIds.add("c13481a486c9ee559cf305284df4d207");
|
||||||
|
roleIds.add("c13481a486c9ee559cf305284df4d207");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +243,7 @@ public class SmsVerifyCodeController {
|
|||||||
return ResponseResult.error("验证码不能为空");
|
return ResponseResult.error("验证码不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean verified = smsVerifyCodeService.verifyCode(phone, code, SmsVerifyCode.TYPE_REGISTER);
|
boolean verified = smsVerifyCodeService.verifyCode(phone, code, SmsVerifyCode.TYPE_LOGIN);
|
||||||
if (!verified) {
|
if (!verified) {
|
||||||
return ResponseResult.error("验证码错误或已过期");
|
return ResponseResult.error("验证码错误或已过期");
|
||||||
}
|
}
|
||||||
@ -290,7 +306,7 @@ public class SmsVerifyCodeController {
|
|||||||
webConfig.loginuserCache().put("login:" + userId, jsonStr);
|
webConfig.loginuserCache().put("login:" + userId, jsonStr);
|
||||||
webConfig.loginuserCache().put("expire_time:" + userId, map.get("expire_time").toString());
|
webConfig.loginuserCache().put("expire_time:" + userId, map.get("expire_time").toString());
|
||||||
|
|
||||||
map.put("user", user);
|
// map.put("user", user);
|
||||||
|
|
||||||
return ResponseResult.successData(map);
|
return ResponseResult.successData(map);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class LoginUser implements UserDetails {
|
|||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private List<String> permissions;
|
private List<String> permissions=new ArrayList<>();
|
||||||
|
|
||||||
public LoginUser(SysUser user, List<String> permissions) {
|
public LoginUser(SysUser user, List<String> permissions) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ public class SmsVerifyCode implements Serializable {
|
|||||||
|
|
||||||
public static final Integer TYPE_REGISTER = 1;
|
public static final Integer TYPE_REGISTER = 1;
|
||||||
public static final Integer TYPE_FIND_PASSWORD = 2;
|
public static final Integer TYPE_FIND_PASSWORD = 2;
|
||||||
|
public static final Integer TYPE_LOGIN = 3;
|
||||||
|
|
||||||
public static final Integer STATUS_UNUSED = 0;
|
public static final Integer STATUS_UNUSED = 0;
|
||||||
public static final Integer STATUS_USED = 1;
|
public static final Integer STATUS_USED = 1;
|
||||||
|
|||||||
@ -610,7 +610,13 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
|
|||||||
.like(SysUser::getRealName, name)
|
.like(SysUser::getRealName, name)
|
||||||
);
|
);
|
||||||
queryWrapper.orderByDesc(SysUser::getRegTime);
|
queryWrapper.orderByDesc(SysUser::getRegTime);
|
||||||
return this.page(page, queryWrapper);
|
Page<SysUser> mapPage = this.page(page, queryWrapper);
|
||||||
|
mapPage.getRecords().forEach(record -> {
|
||||||
|
String id = record.getId();
|
||||||
|
List<SysRole> sysRoles = sysRoleMapper.getRoleByUserId(id);
|
||||||
|
record.setRoles(sysRoles);
|
||||||
|
});
|
||||||
|
return mapPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user