2021-07-12 14:51:34 +08:00
|
|
|
package com.xkrs.service.impl;
|
|
|
|
|
|
|
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
2021-09-24 16:24:12 +08:00
|
|
|
import com.xkrs.dao.*;
|
2021-11-17 14:55:09 +08:00
|
|
|
import com.xkrs.model.entity.*;
|
2021-07-12 14:51:34 +08:00
|
|
|
import com.xkrs.model.qo.SysUserQo;
|
|
|
|
import com.xkrs.model.vo.SysUserVo;
|
2021-08-03 18:03:44 +08:00
|
|
|
import com.xkrs.service.RedisService;
|
2021-07-12 14:51:34 +08:00
|
|
|
import com.xkrs.service.SysUserService;
|
2021-07-14 16:06:34 +08:00
|
|
|
import com.xkrs.utils.DateTimeUtil;
|
2022-05-06 13:46:59 +08:00
|
|
|
import org.apache.http.util.TextUtils;
|
2021-07-12 14:51:34 +08:00
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import org.springframework.security.crypto.keygen.KeyGenerators;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
2021-07-14 16:06:34 +08:00
|
|
|
import java.time.LocalDateTime;
|
2021-07-12 14:51:34 +08:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
2021-09-24 16:24:12 +08:00
|
|
|
import java.util.Map;
|
2021-07-12 14:51:34 +08:00
|
|
|
|
|
|
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
2021-07-14 16:06:34 +08:00
|
|
|
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
2021-07-12 14:51:34 +08:00
|
|
|
import static com.xkrs.utils.EncryptDecryptUtil.encry256;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 系统用户服务实现
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @author tajochen
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
public class SysUserServiceImpl implements SysUserService {
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private SysUserDao sysUserDao;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private SysRoleDao sysRoleDao;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private RelUserRoleDao relUserRoleDao;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private RelRoleAuthorityDao relRoleAuthorityDao;
|
|
|
|
|
2021-08-03 18:03:44 +08:00
|
|
|
@Resource
|
|
|
|
private RedisService redisService;
|
|
|
|
|
2021-09-24 16:24:12 +08:00
|
|
|
@Resource
|
|
|
|
private NationwideDao nationwideDao;
|
|
|
|
|
2021-11-17 14:55:09 +08:00
|
|
|
@Resource
|
|
|
|
private CountyDao countyDao;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private CityDao cityDao;
|
|
|
|
|
2021-07-12 14:51:34 +08:00
|
|
|
/**
|
|
|
|
* 检查用户名是否存在
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param userName
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean checkUserName(String userName) {
|
|
|
|
int num = sysUserDao.checkUserName(userName);
|
|
|
|
return (num == 0);
|
2022-05-06 13:46:59 +08:00
|
|
|
}
|
2021-07-12 14:51:34 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增用户
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param sysUserQo
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
2021-08-03 18:03:44 +08:00
|
|
|
public String addUser(SysUserQo sysUserQo) {
|
|
|
|
// 获取区域信息
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
2021-07-12 14:51:34 +08:00
|
|
|
String salt = KeyGenerators.string().generateKey();
|
|
|
|
SysUserEntity sysUserEntity = new SysUserEntity();
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserEntity.setStreet(0);
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserEntity.setUserName(sysUserQo.getUserName());
|
2021-11-17 14:55:09 +08:00
|
|
|
String o = (String) redisService.get(sysUserQo.getUserName());
|
2022-05-06 13:46:59 +08:00
|
|
|
if ("".equals(o) || o == null) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "请先发送验证码!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2022-05-06 13:46:59 +08:00
|
|
|
if (!redisService.get(sysUserQo.getUserName()).equals(sysUserQo.getVerificationCode())) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "验证码错误,请重新输入!", locale);
|
2021-08-03 18:03:44 +08:00
|
|
|
}
|
2022-05-06 13:46:59 +08:00
|
|
|
if ("".equals(sysUserQo.getReallyName()) || sysUserQo.getReallyName() == null) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "真实姓名不能为空!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
|
|
|
sysUserEntity.setSalt(salt);
|
|
|
|
sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt));
|
|
|
|
sysUserEntity.setTelephone(sysUserQo.getUserName());
|
2021-11-17 14:55:09 +08:00
|
|
|
|
2022-05-06 13:46:59 +08:00
|
|
|
if (TextUtils.isEmpty(sysUserQo.getCountyName())) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道名称不能为空!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserEntity.setCountyCode(sysUserQo.getCountyCode());
|
2021-11-17 14:55:09 +08:00
|
|
|
|
2022-05-06 13:46:59 +08:00
|
|
|
if (1 == sysUserQo.getStreet()) {
|
|
|
|
sysUserEntity.setActiveFlag(0);
|
|
|
|
sysUserEntity.setAccountType("街道级");
|
|
|
|
} else if ("0000".equals(sysUserQo.getCountyCode().substring(2))) {
|
2021-11-17 14:55:09 +08:00
|
|
|
List<CityEntity> byProCode = cityDao.findByProCode(sysUserQo.getCountyCode());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byProCode == null || byProCode.size() == 0) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省编码不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
|
|
|
List<CityEntity> byProName = cityDao.findByProName(sysUserQo.getCountyName());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byProName == null || byProName.size() == 0) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2021-08-06 11:36:13 +08:00
|
|
|
sysUserEntity.setActiveFlag(1);
|
|
|
|
sysUserEntity.setAccountType("省级");
|
2022-05-06 13:46:59 +08:00
|
|
|
} else if ("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))) {
|
2021-12-01 14:13:05 +08:00
|
|
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byCityCode == null || byCityCode.size() == 0) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "市编码不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2021-12-01 14:13:05 +08:00
|
|
|
List<CountyEntity> byCityName = countyDao.findByCityName(sysUserQo.getCountyName());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byCityName == null || byCityName.size() == 0) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2021-08-06 11:36:13 +08:00
|
|
|
sysUserEntity.setActiveFlag(1);
|
|
|
|
sysUserEntity.setAccountType("市级");
|
2022-05-06 13:46:59 +08:00
|
|
|
} else {
|
2021-11-17 14:55:09 +08:00
|
|
|
CountyEntity byCountyCode = countyDao.findByCountyCode(sysUserQo.getCountyCode());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byCountyCode == null) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "编码不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
|
|
|
CountyEntity byCountyName = countyDao.findByCountyName(sysUserQo.getCountyName());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (byCountyName == null) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
2021-08-06 11:36:13 +08:00
|
|
|
sysUserEntity.setActiveFlag(0);
|
|
|
|
sysUserEntity.setAccountType("县级");
|
|
|
|
}
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserEntity.setStatusCode(0);
|
2021-07-14 16:06:34 +08:00
|
|
|
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserEntity.setDeleteFlag(0);
|
2021-07-14 09:23:53 +08:00
|
|
|
sysUserEntity.setDayNum(7);
|
2021-11-17 14:55:09 +08:00
|
|
|
String string = dateTimeToString(LocalDateTime.now().plusDays(3L));
|
2021-07-14 16:06:34 +08:00
|
|
|
sysUserEntity.setOverTime(string);
|
2021-08-10 09:06:16 +08:00
|
|
|
sysUserEntity.setLoginNum(0);
|
2021-08-10 08:41:17 +08:00
|
|
|
sysUserEntity.setCountyName(sysUserQo.getCountyName());
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserDao.save(sysUserEntity);
|
|
|
|
|
|
|
|
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
|
|
|
|
relUserRoleEntity.setUserId(sysUserEntity.getId().longValue());
|
|
|
|
relUserRoleEntity.setRoleId(2);
|
|
|
|
|
|
|
|
RelRoleAuthorityEntity relRoleAuthorityEntity = new RelRoleAuthorityEntity();
|
|
|
|
relRoleAuthorityEntity.setRoleId(2);
|
|
|
|
relRoleAuthorityEntity.setAuthorityId(2);
|
|
|
|
relRoleAuthorityEntity.setUserId(sysUserEntity.getId());
|
|
|
|
relUserRoleDao.save(relUserRoleEntity);
|
|
|
|
|
|
|
|
relRoleAuthorityDao.save(relRoleAuthorityEntity);
|
2022-05-06 13:46:59 +08:00
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询所有用户Vo
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
/*@Transactional(rollbackFor=Exception.class)
|
|
|
|
@Override
|
|
|
|
public Iterable<SysUserVo> getAllSysUser() {
|
|
|
|
Iterable<SysUserVo> ls = sysUserDao.selectAllSysUser();
|
|
|
|
return ls;
|
|
|
|
}*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public SysUserEntity getSysUserByUserName(String userName) {
|
|
|
|
return sysUserDao.selectByUserName(userName);
|
|
|
|
}
|
|
|
|
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
2022-05-06 13:46:59 +08:00
|
|
|
public int updateSysUserLogin(String userName, String ipAddress) {
|
|
|
|
return sysUserDao.updateSysUserLogin(userName, ipAddress);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新用户
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param sysUserQo
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public int updateSysUser(SysUserQo sysUserQo) {
|
|
|
|
SysUserEntity sysUserEntity = new SysUserEntity();
|
|
|
|
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
|
|
|
sysUserDao.save(sysUserEntity);
|
2022-05-06 13:46:59 +08:00
|
|
|
return 1;
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 软删除普通用户
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public int softDeleteGeneralUser(Integer id) {
|
|
|
|
String adminRole = "role_administor";
|
2022-05-06 13:46:59 +08:00
|
|
|
String sysRole = "role_system_manager";
|
2021-07-12 14:51:34 +08:00
|
|
|
|
2022-05-06 13:46:59 +08:00
|
|
|
List<SysRoleEntity> list = sysRoleDao.selectByUserId(id);
|
|
|
|
if (list.size() > 0) {
|
2021-07-12 14:51:34 +08:00
|
|
|
SysRoleEntity sysRoleEntity = list.get(1);
|
2022-05-06 13:46:59 +08:00
|
|
|
if (sysRole.equals(sysRoleEntity.getRoleName()) || adminRole.equals(sysRoleEntity.getRoleName())) {
|
2021-07-12 14:51:34 +08:00
|
|
|
sysUserDao.softDeleteGeneralUserById(id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询用户的信息
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<SysUserVo> selectAllUser() {
|
|
|
|
return sysUserDao.selectAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 启用
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param userId
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public void updateEnable(Integer userId) {
|
|
|
|
sysUserDao.updateEnable(userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 禁用
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param userId
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public void updateDisable(Integer userId) {
|
|
|
|
sysUserDao.updateDisable(userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户修改密码
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param oldPassword
|
|
|
|
* @param newPassword
|
|
|
|
* @param confirmPassword
|
|
|
|
* @param sysUserEntity
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
String oldFrontPassword = encry256(oldPassword + sysUserEntity.getSalt());
|
2022-05-06 13:46:59 +08:00
|
|
|
if (!oldFrontPassword.equals(sysUserEntity.getPassword())) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "旧密码输入错误", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
2022-05-06 13:46:59 +08:00
|
|
|
if (!newPassword.equals(confirmPassword)) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updatePassword(sysUserEntity.getId(), newAfterPassword);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 管理员修改用户的密码
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-07-12 14:51:34 +08:00
|
|
|
* @param userId
|
|
|
|
* @param newPassword
|
|
|
|
* @param confirmPassword
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-07-12 14:51:34 +08:00
|
|
|
@Override
|
|
|
|
public String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
2022-05-06 13:46:59 +08:00
|
|
|
if (!newPassword.equals(confirmPassword)) {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
|
|
|
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updatePassword(userId, newAfterPassword);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|
|
|
|
|
2021-07-15 14:31:07 +08:00
|
|
|
@Override
|
|
|
|
public SysUserVo getUserByUserName(String userName) {
|
|
|
|
return sysUserDao.selectUserByUserName(userName);
|
|
|
|
}
|
|
|
|
|
2021-08-04 16:17:58 +08:00
|
|
|
/**
|
|
|
|
* 按天数修改账号到期时间
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-04 16:17:58 +08:00
|
|
|
* @param userId
|
|
|
|
* @param dayNum
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-04 16:17:58 +08:00
|
|
|
@Override
|
|
|
|
public String updateExpireDateDay(Integer userId, Integer dayNum) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
long l = dayNum.longValue();
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
2022-05-06 13:46:59 +08:00
|
|
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = now.plusDays(l);
|
|
|
|
String time = dateTimeToString(localDateTime);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
|
|
|
} else {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.plusDays(l);
|
|
|
|
String time = dateTimeToString(localDateTime1);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2021-08-04 16:17:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 按月份修改账号过期时间
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-04 16:17:58 +08:00
|
|
|
* @param userId
|
|
|
|
* @param dayNum
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-04 16:17:58 +08:00
|
|
|
@Override
|
|
|
|
public String updateExpireDateMonth(Integer userId, Integer dayNum) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
long l = dayNum.longValue();
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
2022-05-06 13:46:59 +08:00
|
|
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = now.plusMonths(l);
|
|
|
|
String time = dateTimeToString(localDateTime);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
|
|
|
} else {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.plusMonths(l);
|
|
|
|
String time = dateTimeToString(localDateTime1);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2021-08-04 16:17:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 按年份修改账号到期时间
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-04 16:17:58 +08:00
|
|
|
* @param userId
|
|
|
|
* @param dayNum
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-04 16:17:58 +08:00
|
|
|
@Override
|
|
|
|
public String updateExpireDateYear(Integer userId, Integer dayNum) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
long l = dayNum.longValue();
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
2022-05-06 13:46:59 +08:00
|
|
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = now.plusYears(l);
|
|
|
|
String time = dateTimeToString(localDateTime);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
|
|
|
} else {
|
2021-08-04 16:17:58 +08:00
|
|
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.plusYears(l);
|
|
|
|
String time = dateTimeToString(localDateTime1);
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, time);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2021-08-04 16:17:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置账号永久有效
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-04 16:17:58 +08:00
|
|
|
* @param userId
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-04 16:17:58 +08:00
|
|
|
@Override
|
|
|
|
public String updatePermanent(Integer userId) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
sysUserDao.updateDayNum(userId);
|
2022-05-06 13:46:59 +08:00
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2021-08-04 16:17:58 +08:00
|
|
|
}
|
|
|
|
|
2021-08-06 16:32:57 +08:00
|
|
|
/**
|
|
|
|
* 修改账号到期时间
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-06 16:32:57 +08:00
|
|
|
* @param userId
|
|
|
|
* @param overTime
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-06 16:32:57 +08:00
|
|
|
@Override
|
|
|
|
public String updateOverTime(Integer userId, String overTime) {
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateOverTime(userId, overTime);
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2021-08-06 16:32:57 +08:00
|
|
|
}
|
|
|
|
|
2021-08-10 09:06:16 +08:00
|
|
|
/**
|
|
|
|
* 记录用户登录次数
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-08-10 09:06:16 +08:00
|
|
|
* @param userId
|
|
|
|
* @param loginNum
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-08-10 09:06:16 +08:00
|
|
|
@Override
|
|
|
|
public void updateLoginNum(Integer userId, Integer loginNum) {
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateLoginNum(userId, loginNum);
|
2021-08-10 09:06:16 +08:00
|
|
|
}
|
|
|
|
|
2021-11-17 14:55:09 +08:00
|
|
|
/**
|
|
|
|
* 记录用户登录时间
|
2022-05-06 13:46:59 +08:00
|
|
|
*
|
2021-11-17 14:55:09 +08:00
|
|
|
* @param userId
|
|
|
|
* @param loginLastTime
|
|
|
|
*/
|
2022-05-06 13:46:59 +08:00
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2021-11-17 14:55:09 +08:00
|
|
|
@Override
|
|
|
|
public void updateLoginLastTime(Integer userId, String loginLastTime) {
|
2022-05-06 13:46:59 +08:00
|
|
|
sysUserDao.updateLoginLastTime(userId, loginLastTime);
|
2021-11-17 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
2021-09-24 16:24:12 +08:00
|
|
|
@Override
|
|
|
|
public List<Map<String, String>> findCityByProCode(String proCode) {
|
|
|
|
return nationwideDao.findCityByProCode(proCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Map<String, String>> findCountyByProCode(String proCode) {
|
|
|
|
return nationwideDao.findCountyByProCode(proCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Map<String, String>> findCountyByCityCode(String cityCode) {
|
|
|
|
return nationwideDao.findCountyByCityCode(cityCode);
|
|
|
|
}
|
|
|
|
|
2021-07-12 14:51:34 +08:00
|
|
|
}
|