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

修改身份证号和姓名分开

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