Commit 5e6176c8 authored by 贷前—徐菲's avatar 贷前—徐菲

修改身份证号和姓名分开

parent 89832dd7
......@@ -977,8 +977,8 @@ public class InnerController implements IBaseController {
}
@RequestMapping("/updateIdCard")
public JsonResult updateIdCard(@RequestParam String name, @RequestParam String idNo, @RequestParam String phoneNo,
@RequestParam String reason, @RequestParam String content) {
public JsonResult updateIdCard(@RequestParam(required = false)String name, @RequestParam(required = false)String idNo,
@RequestParam String phoneNo, @RequestParam String reason, @RequestParam String content) {
//密文
if (null != content) {
content = content.replaceAll(" ", "+");
......@@ -987,17 +987,16 @@ public class InnerController implements IBaseController {
if (null == str || !str.equals(phoneNo)) {
return JsonResult.buildErrorStateResult("解密有误", null);
}
if (StringUtils.isBlank(name) || StringUtils.isBlank(idNo) || StringUtils.isBlank(phoneNo) || StringUtils.isBlank(reason)) {
if(StringUtils.isBlank(name) && StringUtils.isBlank(idNo)){
return JsonResult.buildErrorStateResult("不能全为空", null);
}
if ( StringUtils.isBlank(phoneNo) || StringUtils.isBlank(reason)) {
return JsonResult.buildErrorStateResult("参数有误", null);
}
if (!ValidationUtil.validatePhoneNo(phoneNo)) {
LOGGER.info("手机号有误, phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("用户手机号错误", null);
}
if (!ValidationUtil.validateChinese(name)) {
LOGGER.info("名字有误, name:{}", name);
return JsonResult.buildErrorStateResult("用户姓名错误", null);
}
int affectedRows=userDetailService.updateIdCard(name, idNo, phoneNo);
LOGGER.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason,affectedRows);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
......@@ -1009,7 +1008,7 @@ public class InnerController implements IBaseController {
LOGGER.info("去清除函谷关的缓存");
Map<String, String> param = builder.build();
httpService.get(hanguguanUrl.concat("/innerapi/updateIdCard"), param);
return JsonResult.buildSuccessResult("修改用户身份证号成功", affectedRows);
return JsonResult.buildSuccessResult("修改用户身份证号或姓名成功", affectedRows);
}
@RequestMapping("/forbiddenUserOrNot")
......
......@@ -42,6 +42,11 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,J
@Transactional
@Modifying
@Query(value = "update user_detail set name=?1,id_no=?2,gender=?3 where phone_no=?4", nativeQuery = true)
int updateIdNoByPhoneNo(String name, String idNo, String gender, String phoneNo);
@Query(value = "update user_detail set id_no=?1,gender=?2 where phone_no=?3", nativeQuery = true)
int updateIdNoByPhoneNo(String idNo, int gender, String phoneNo);
@Transactional
@Modifying
@Query(value = "update user_detail set name=?1 where phone_no=?2", nativeQuery = true)
int updateNameByPhoneNo(String name, String phoneNo);
}
......@@ -3,11 +3,13 @@ package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.util.ValidationUtil;
import com.google.common.collect.Maps;
import java.text.ParseException;
import java.util.ArrayList;
......@@ -204,19 +206,21 @@ public class UserDetailServiceImpl implements IUserDetailService {
@Override
public int updateIdCard(String name, String idNo, String phoneNo) {
String lastChar = "";
if (idNo.length() == 18) {
lastChar = idNo.substring(16, 17).toLowerCase();
} else if (idNo.length() == 15) {
lastChar = idNo.substring(13, 14).toLowerCase();
}
// 判断男女
if (Integer.parseInt(lastChar) % 2 == 0) {
//女
return userDetailRepository.updateIdNoByPhoneNo(name, idNo, "1", phoneNo);
} else {
//男
return userDetailRepository.updateIdNoByPhoneNo(name, idNo, "2", phoneNo);
UserDetail userDetail = userDetailRepository.findByPhoneNo(phoneNo);
if (null != userDetail) {
if (!StringUtils.isBlank(idNo)) {
try {
IdCardInfo idCardInfo = idCardService.getIdCardInfo(idNo);
return userDetailRepository.updateIdNoByPhoneNo(idCardInfo.getIdNo(), idCardInfo.getGender().ordinal(), phoneNo);
} catch (ParseException e) {
LOGGER.error("用户的身份证错误,phoneNo:{},e:{}", phoneNo, e);
return 0;
}
}
if (!StringUtils.isBlank(name) && ValidationUtil.validateChinese(name)) {
return userDetailRepository.updateNameByPhoneNo(name, phoneNo);
}
}
return 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment