Commit 62a173c5 authored by 技术部-任文超's avatar 技术部-任文超

清除重置账号的接口

parent 30485d11
......@@ -33,7 +33,6 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.HttpStatus;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
......@@ -1256,35 +1255,6 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("用户已禁用.", flushed);
}
/**
* 重置账号(手机号)接口
* -- 供内部系统免密调用
*
* 注意:此操作会级联更新UserDetail的phoneNo
*
* @param userId - 用户主键
* @param account - 旧账号
* @param phoneNo - 新账号
*/
@LogHttpCaller
@RequestMapping("/user/resetAccount/{userId}/{account}")
public JsonResult resetAccount(@PathVariable("userId") Long userId, @PathVariable("account") String account, @RequestParam("phoneNo") String phoneNo) {
log.info("重置用户账号 userId:{},account_old:{},account_new:{}", userId, account, phoneNo);
if(ValidationUtil.validatePhoneNo(account) && ValidationUtil.validatePhoneNo(phoneNo)){
try {
// 重置账号
boolean result = userService.resetAccount(userId, account, phoneNo);
log.info("重置用户账号,结果:{},account_old:{},account_new:{}", result, account, (result ? phoneNo : account));
return JsonResult.buildSuccessResult("用户账号已重置.".concat(String.valueOf(result)), (result ? phoneNo : account));
} catch (Exception e) {
log.error("账号重置失败,phone[{}],err:[{}]", phoneNo, e);
}
return JsonResult.buildErrorStateResult("用户账号重置失败.", "Error phone");
}else{
return JsonResult.buildErrorStateResult("用户账号重置失败.", "Error phone");
}
}
/**
* 重置用户实名信息接口
* -- 供内部系统免密调用
......
......@@ -10,8 +10,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static org.springframework.transaction.annotation.Propagation.MANDATORY;
/**
* @author mengfan.feng
* @time 2015-09-11 11:22
......@@ -57,8 +55,4 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,J
@Query(value = "update user_detail set name=?1 where phone_no=?2", nativeQuery = true)
int updateNameByPhoneNo(String name, String phoneNo);
@Transactional(propagation = MANDATORY)
@Modifying
@Query(value = "update user_detail set phone_no=?2 where user_id=?1", nativeQuery = true)
int resetPhoneNo(Long userId, String phoneNo);
}
......@@ -9,7 +9,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static org.springframework.transaction.annotation.Propagation.MANDATORY;
/**
* Created by Miraculous on 15/7/4.
......@@ -32,9 +31,4 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
@Query(value = "update user set enable=?1 where phone_no=?2", nativeQuery = true)
int forbiddenUser(Boolean enable, String phoneNo);
@Transactional(propagation = MANDATORY)
@Modifying
@Query(value = "update user set phone_no=?3 where id=?1 and phone_no=?2", nativeQuery = true)
int resetAccount(Long userId, String account, String phoneNo);
}
......@@ -18,17 +18,6 @@ public interface IUserService {
boolean resetPassword(String phoneNo, String password);
/**
* 重置账号
* 注意:此操作会级联更新UserDetail的phoneNo
*
* @param userId - 用户主键
* @param account - 旧账号
* @param phoneNo - 新账号
* @return
*/
boolean resetAccount(Long userId, String account, String phoneNo);
User findByPhoneInDb(String phone);
User findByUuidInDb(String uuid);
......
......@@ -163,21 +163,6 @@ public class UserServiceImpl implements IUserService {
}
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = "usercache", key = "'xyqbuser' + #account", cacheManager = "cacheManager")
public boolean resetAccount(Long userId, String account, String phoneNo){
int rowUser = userRepository.resetAccount(userId, account, phoneNo);
if(rowUser != 1){
throw new RuntimeException("重置账号失败!");
}
int rowUserDetail = userDetailRepository.resetPhoneNo(userId, phoneNo);
if(rowUserDetail != 1){
throw new RuntimeException("重置账号失败!");
}
return true;
}
@Override
public List<User> findRegisterUserByTime(String beginTime, String endTime) {
return userRepository.findRegisterUserByTime(beginTime,endTime);
......
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