修改 新增用户 接口
This commit is contained in:
parent
5f680532b6
commit
209985cdf0
@ -7,10 +7,11 @@ import java.time.LocalDateTime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SysUser 表实体类
|
* SysUser 表实体类
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="sys_user")
|
@Table(name = "sys_user")
|
||||||
public class SysUserEntity implements Serializable {
|
public class SysUserEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +19,7 @@ public class SysUserEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_user_seq_gen")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_user_seq_gen")
|
||||||
@SequenceGenerator(name = "sys_user_seq_gen", sequenceName = "sys_user_id_seq",allocationSize = 1)
|
@SequenceGenerator(name = "sys_user_seq_gen", sequenceName = "sys_user_id_seq", allocationSize = 1)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +55,7 @@ public class SysUserEntity implements Serializable {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Integer activeFlag;
|
private Integer activeFlag;
|
||||||
|
|
||||||
@Column(nullable = false,columnDefinition = "smallint")
|
@Column(nullable = false, columnDefinition = "smallint")
|
||||||
private Integer statusCode;
|
private Integer statusCode;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@ -81,10 +82,10 @@ public class SysUserEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 账号类别
|
* 账号类别
|
||||||
*/
|
*/
|
||||||
@Column(length = 64,columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String accountType;
|
private String accountType;
|
||||||
|
|
||||||
@Column(length = 64,columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String countyName;
|
private String countyName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +98,8 @@ public class SysUserEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String loginLastTime;
|
private String loginLastTime;
|
||||||
|
|
||||||
|
private Integer street;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -257,29 +260,16 @@ public class SysUserEntity implements Serializable {
|
|||||||
this.loginLastTime = loginLastTime;
|
this.loginLastTime = loginLastTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreet(Integer street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SysUserEntity{" +
|
return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", lastEntryTime=" + lastEntryTime + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", dayNum=" + dayNum + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + ", street=" + street + '}';
|
||||||
"id=" + id +
|
|
||||||
", userName='" + userName + '\'' +
|
|
||||||
", reallyName='" + reallyName + '\'' +
|
|
||||||
", password='" + password + '\'' +
|
|
||||||
", salt='" + salt + '\'' +
|
|
||||||
", telephone='" + telephone + '\'' +
|
|
||||||
", countyCode='" + countyCode + '\'' +
|
|
||||||
", signature='" + signature + '\'' +
|
|
||||||
", activeFlag=" + activeFlag +
|
|
||||||
", statusCode=" + statusCode +
|
|
||||||
", addTime='" + addTime + '\'' +
|
|
||||||
", lastEntryTime=" + lastEntryTime +
|
|
||||||
", deleteFlag=" + deleteFlag +
|
|
||||||
", lastEntryIp='" + lastEntryIp + '\'' +
|
|
||||||
", dayNum=" + dayNum +
|
|
||||||
", overTime='" + overTime + '\'' +
|
|
||||||
", accountType='" + accountType + '\'' +
|
|
||||||
", countyName='" + countyName + '\'' +
|
|
||||||
", loginNum=" + loginNum +
|
|
||||||
", loginLastTime='" + loginLastTime + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,45 +11,39 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SysUserQo
|
* SysUserQo
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
public class SysUserQo {
|
public class SysUserQo {
|
||||||
|
|
||||||
@NotNull( message = "{SysUser.id.blank}",groups={SysUserQoUpdate.class})
|
@NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class})
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotBlank(message = "{SysUser.userName.blank}",groups={SysUserQoInsert.class})
|
@NotBlank(message = "{SysUser.userName.blank}", groups = {SysUserQoInsert.class}) @Size(min = 4, max = 16, message = "{SysUser.userName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
@Size(min = 4,max = 16, message = "{SysUser.userName.length.illegal}",groups = {SysUserQoInsert.class,
|
|
||||||
SysUserQoUpdate.class})
|
|
||||||
/**
|
/**
|
||||||
* regexp = "^([A-Za-z0-9_]+)$"
|
* regexp = "^([A-Za-z0-9_]+)$"
|
||||||
*/
|
*/
|
||||||
@Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$",message = "{SysUser.userName.format.illegal}",groups = {SysUserQoInsert.class,
|
@Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", message = "{SysUser.userName.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
SysUserQoUpdate.class})
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Size(max = 32, message = "{SysUser.nickName.length.illegal}",groups = {SysUserQoInsert.class,
|
@Size(max = 32, message = "{SysUser.nickName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
SysUserQoUpdate.class})
|
|
||||||
private String reallyName;
|
private String reallyName;
|
||||||
|
|
||||||
@NotBlank(message = "{SysUser.password.blank}",groups = {SysUserQoInsert.class})
|
@NotBlank(message = "{SysUser.password.blank}", groups = {SysUserQoInsert.class})
|
||||||
@Size(min = 6,max = 16, message = "{SysUser.password.length.illegal}",groups = {SysUserQoInsert.class,
|
@Size(min = 6, max = 16, message = "{SysUser.password.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
SysUserQoUpdate.class})
|
@Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$", message = "{SysUser.password.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
@Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "{SysUser.password.format.illegal}",
|
|
||||||
groups = {SysUserQoInsert.class,SysUserQoUpdate.class})
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$",
|
@Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", message = "{SysUser.telephone.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
message = "{SysUser.telephone.format.illegal}",groups = {SysUserQoInsert.class,SysUserQoUpdate.class})
|
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
|
||||||
@NotNull(message = "{SysUser.statusCode.illegal}",groups={SysUserQoUpdate.class})
|
@NotNull(message = "{SysUser.statusCode.illegal}", groups = {SysUserQoUpdate.class})
|
||||||
@Range(min=0,max=2,message = "{SysUser.statusCode.illegal}",groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
@Range(min = 0, max = 2, message = "{SysUser.statusCode.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
|
||||||
private Integer statusCode;
|
private Integer statusCode;
|
||||||
|
|
||||||
private String countyCode;
|
private String countyCode;
|
||||||
|
|
||||||
@NotNull(message = "{SysUser.deleteFlag.null}",groups={SysUserQoUpdate.class})
|
@NotNull(message = "{SysUser.deleteFlag.null}", groups = {SysUserQoUpdate.class})
|
||||||
private Integer deleteFlag;
|
private Integer deleteFlag;
|
||||||
|
|
||||||
private Integer roleId;
|
private Integer roleId;
|
||||||
@ -62,6 +56,9 @@ public class SysUserQo {
|
|||||||
|
|
||||||
private String countyName;
|
private String countyName;
|
||||||
|
|
||||||
|
@NotNull(message = "{SysUser.street.blank}", groups = {SysUserQoUpdate.class})
|
||||||
|
private Integer street;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -165,4 +162,12 @@ public class SysUserQo {
|
|||||||
public void setCountyName(String countyName) {
|
public void setCountyName(String countyName) {
|
||||||
this.countyName = countyName;
|
this.countyName = countyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreet(Integer street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,7 @@ import com.xkrs.model.vo.SysUserVo;
|
|||||||
import com.xkrs.service.RedisService;
|
import com.xkrs.service.RedisService;
|
||||||
import com.xkrs.service.SysUserService;
|
import com.xkrs.service.SysUserService;
|
||||||
import com.xkrs.utils.DateTimeUtil;
|
import com.xkrs.utils.DateTimeUtil;
|
||||||
import org.slf4j.Logger;
|
import org.apache.http.util.TextUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.security.crypto.keygen.KeyGenerators;
|
import org.springframework.security.crypto.keygen.KeyGenerators;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -23,11 +22,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
||||||
import static com.xkrs.utils.DateTimeUtil.getNowTime;
|
|
||||||
import static com.xkrs.utils.EncryptDecryptUtil.encry256;
|
import static com.xkrs.utils.EncryptDecryptUtil.encry256;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户服务实现
|
* 系统用户服务实现
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@ -59,6 +58,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户名是否存在
|
* 检查用户名是否存在
|
||||||
|
*
|
||||||
* @param userName
|
* @param userName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -66,70 +66,75 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
public boolean checkUserName(String userName) {
|
public boolean checkUserName(String userName) {
|
||||||
int num = sysUserDao.checkUserName(userName);
|
int num = sysUserDao.checkUserName(userName);
|
||||||
return (num == 0);
|
return (num == 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
|
*
|
||||||
* @param sysUserQo
|
* @param sysUserQo
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String addUser(SysUserQo sysUserQo) {
|
public String addUser(SysUserQo sysUserQo) {
|
||||||
// 获取区域信息
|
// 获取区域信息
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String salt = KeyGenerators.string().generateKey();
|
String salt = KeyGenerators.string().generateKey();
|
||||||
SysUserEntity sysUserEntity = new SysUserEntity();
|
SysUserEntity sysUserEntity = new SysUserEntity();
|
||||||
|
sysUserEntity.setStreet(0);
|
||||||
sysUserEntity.setUserName(sysUserQo.getUserName());
|
sysUserEntity.setUserName(sysUserQo.getUserName());
|
||||||
String o = (String) redisService.get(sysUserQo.getUserName());
|
String o = (String) redisService.get(sysUserQo.getUserName());
|
||||||
if("".equals(o) || o == null){
|
if ("".equals(o) || o == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "请先发送验证码!", locale);
|
||||||
}
|
}
|
||||||
if(!redisService.get(sysUserQo.getUserName()).equals(sysUserQo.getVerificationCode())){
|
if (!redisService.get(sysUserQo.getUserName()).equals(sysUserQo.getVerificationCode())) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "验证码错误,请重新输入!", locale);
|
||||||
}
|
}
|
||||||
if("".equals(sysUserQo.getReallyName()) || sysUserQo.getReallyName() == null){
|
if ("".equals(sysUserQo.getReallyName()) || sysUserQo.getReallyName() == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"真实姓名不能为空!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "真实姓名不能为空!", locale);
|
||||||
}
|
}
|
||||||
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
||||||
sysUserEntity.setSalt(salt);
|
sysUserEntity.setSalt(salt);
|
||||||
sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt));
|
sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt));
|
||||||
sysUserEntity.setTelephone(sysUserQo.getUserName());
|
sysUserEntity.setTelephone(sysUserQo.getUserName());
|
||||||
|
|
||||||
sysUserEntity.setCountyCode(sysUserQo.getCountyCode());
|
if (TextUtils.isEmpty(sysUserQo.getCountyName())) {
|
||||||
if("".equals(sysUserQo.getCountyName()) || sysUserQo.getCountyName() == null){
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道名称不能为空!", locale);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"省市区名称不能为空!",locale);
|
|
||||||
}
|
}
|
||||||
|
sysUserEntity.setCountyCode(sysUserQo.getCountyCode());
|
||||||
|
|
||||||
if("0000".equals(sysUserQo.getCountyCode().substring(2))){
|
if (1 == sysUserQo.getStreet()) {
|
||||||
|
sysUserEntity.setActiveFlag(0);
|
||||||
|
sysUserEntity.setAccountType("街道级");
|
||||||
|
} else if ("0000".equals(sysUserQo.getCountyCode().substring(2))) {
|
||||||
List<CityEntity> byProCode = cityDao.findByProCode(sysUserQo.getCountyCode());
|
List<CityEntity> byProCode = cityDao.findByProCode(sysUserQo.getCountyCode());
|
||||||
if(byProCode == null || byProCode.size() == 0){
|
if (byProCode == null || byProCode.size() == 0) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"省编码不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省编码不存在!", locale);
|
||||||
}
|
}
|
||||||
List<CityEntity> byProName = cityDao.findByProName(sysUserQo.getCountyName());
|
List<CityEntity> byProName = cityDao.findByProName(sysUserQo.getCountyName());
|
||||||
if(byProName == null || byProName.size() == 0){
|
if (byProName == null || byProName.size() == 0) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
||||||
}
|
}
|
||||||
sysUserEntity.setActiveFlag(1);
|
sysUserEntity.setActiveFlag(1);
|
||||||
sysUserEntity.setAccountType("省级");
|
sysUserEntity.setAccountType("省级");
|
||||||
}else if("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))){
|
} else if ("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))) {
|
||||||
List<CountyEntity> byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode());
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode());
|
||||||
if(byCityCode == null || byCityCode.size() == 0){
|
if (byCityCode == null || byCityCode.size() == 0) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"市编码不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "市编码不存在!", locale);
|
||||||
}
|
}
|
||||||
List<CountyEntity> byCityName = countyDao.findByCityName(sysUserQo.getCountyName());
|
List<CountyEntity> byCityName = countyDao.findByCityName(sysUserQo.getCountyName());
|
||||||
if(byCityName == null || byCityName.size() == 0){
|
if (byCityName == null || byCityName.size() == 0) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
||||||
}
|
}
|
||||||
sysUserEntity.setActiveFlag(1);
|
sysUserEntity.setActiveFlag(1);
|
||||||
sysUserEntity.setAccountType("市级");
|
sysUserEntity.setAccountType("市级");
|
||||||
}else {
|
} else {
|
||||||
CountyEntity byCountyCode = countyDao.findByCountyCode(sysUserQo.getCountyCode());
|
CountyEntity byCountyCode = countyDao.findByCountyCode(sysUserQo.getCountyCode());
|
||||||
if(byCountyCode == null){
|
if (byCountyCode == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"编码不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "编码不存在!", locale);
|
||||||
}
|
}
|
||||||
CountyEntity byCountyName = countyDao.findByCountyName(sysUserQo.getCountyName());
|
CountyEntity byCountyName = countyDao.findByCountyName(sysUserQo.getCountyName());
|
||||||
if(byCountyName == null){
|
if (byCountyName == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
||||||
}
|
}
|
||||||
sysUserEntity.setActiveFlag(0);
|
sysUserEntity.setActiveFlag(0);
|
||||||
sysUserEntity.setAccountType("县级");
|
sysUserEntity.setAccountType("县级");
|
||||||
@ -142,7 +147,6 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
sysUserEntity.setOverTime(string);
|
sysUserEntity.setOverTime(string);
|
||||||
sysUserEntity.setLoginNum(0);
|
sysUserEntity.setLoginNum(0);
|
||||||
sysUserEntity.setCountyName(sysUserQo.getCountyName());
|
sysUserEntity.setCountyName(sysUserQo.getCountyName());
|
||||||
|
|
||||||
sysUserDao.save(sysUserEntity);
|
sysUserDao.save(sysUserEntity);
|
||||||
|
|
||||||
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
|
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
|
||||||
@ -156,11 +160,12 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
relUserRoleDao.save(relUserRoleEntity);
|
relUserRoleDao.save(relUserRoleEntity);
|
||||||
|
|
||||||
relRoleAuthorityDao.save(relRoleAuthorityEntity);
|
relRoleAuthorityDao.save(relRoleAuthorityEntity);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"注册成功!",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有用户Vo
|
* 查询所有用户Vo
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
/*@Transactional(rollbackFor=Exception.class)
|
/*@Transactional(rollbackFor=Exception.class)
|
||||||
@ -169,48 +174,49 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
Iterable<SysUserVo> ls = sysUserDao.selectAllSysUser();
|
Iterable<SysUserVo> ls = sysUserDao.selectAllSysUser();
|
||||||
return ls;
|
return ls;
|
||||||
}*/
|
}*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Transactional(rollbackFor=Exception.class)
|
|
||||||
@Override
|
@Override
|
||||||
public SysUserEntity getSysUserByUserName(String userName) {
|
public SysUserEntity getSysUserByUserName(String userName) {
|
||||||
return sysUserDao.selectByUserName(userName);
|
return sysUserDao.selectByUserName(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public int updateSysUserLogin(String userName,String ipAddress) {
|
public int updateSysUserLogin(String userName, String ipAddress) {
|
||||||
return sysUserDao.updateSysUserLogin(userName,ipAddress);
|
return sysUserDao.updateSysUserLogin(userName, ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户
|
* 更新用户
|
||||||
|
*
|
||||||
* @param sysUserQo
|
* @param sysUserQo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public int updateSysUser(SysUserQo sysUserQo) {
|
public int updateSysUser(SysUserQo sysUserQo) {
|
||||||
SysUserEntity sysUserEntity = new SysUserEntity();
|
SysUserEntity sysUserEntity = new SysUserEntity();
|
||||||
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
sysUserEntity.setReallyName(sysUserQo.getReallyName());
|
||||||
sysUserDao.save(sysUserEntity);
|
sysUserDao.save(sysUserEntity);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 软删除普通用户
|
* 软删除普通用户
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public int softDeleteGeneralUser(Integer id) {
|
public int softDeleteGeneralUser(Integer id) {
|
||||||
String adminRole = "role_administor";
|
String adminRole = "role_administor";
|
||||||
String sysRole ="role_system_manager";
|
String sysRole = "role_system_manager";
|
||||||
|
|
||||||
List<SysRoleEntity> list = sysRoleDao.selectByUserId(id);
|
List<SysRoleEntity> list = sysRoleDao.selectByUserId(id);
|
||||||
if(list.size()>0){
|
if (list.size() > 0) {
|
||||||
SysRoleEntity sysRoleEntity = list.get(1);
|
SysRoleEntity sysRoleEntity = list.get(1);
|
||||||
if(sysRole.equals(sysRoleEntity.getRoleName())||adminRole.equals(sysRoleEntity.getRoleName())){
|
if (sysRole.equals(sysRoleEntity.getRoleName()) || adminRole.equals(sysRoleEntity.getRoleName())) {
|
||||||
sysUserDao.softDeleteGeneralUserById(id);
|
sysUserDao.softDeleteGeneralUserById(id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -220,6 +226,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户的信息
|
* 查询用户的信息
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -229,9 +236,10 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用
|
* 启用
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void updateEnable(Integer userId) {
|
public void updateEnable(Integer userId) {
|
||||||
sysUserDao.updateEnable(userId);
|
sysUserDao.updateEnable(userId);
|
||||||
@ -239,9 +247,10 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 禁用
|
* 禁用
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void updateDisable(Integer userId) {
|
public void updateDisable(Integer userId) {
|
||||||
sysUserDao.updateDisable(userId);
|
sysUserDao.updateDisable(userId);
|
||||||
@ -249,46 +258,48 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户修改密码
|
* 用户修改密码
|
||||||
|
*
|
||||||
* @param oldPassword
|
* @param oldPassword
|
||||||
* @param newPassword
|
* @param newPassword
|
||||||
* @param confirmPassword
|
* @param confirmPassword
|
||||||
* @param sysUserEntity
|
* @param sysUserEntity
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity) {
|
public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String oldFrontPassword = encry256(oldPassword + sysUserEntity.getSalt());
|
String oldFrontPassword = encry256(oldPassword + sysUserEntity.getSalt());
|
||||||
if(!oldFrontPassword.equals(sysUserEntity.getPassword())){
|
if (!oldFrontPassword.equals(sysUserEntity.getPassword())) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"旧密码输入错误",locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "旧密码输入错误", locale);
|
||||||
}
|
}
|
||||||
if(!newPassword.equals(confirmPassword)){
|
if (!newPassword.equals(confirmPassword)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"两次密码输入不一致",locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale);
|
||||||
}
|
}
|
||||||
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
||||||
sysUserDao.updatePassword(sysUserEntity.getId(),newAfterPassword);
|
sysUserDao.updatePassword(sysUserEntity.getId(), newAfterPassword);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员修改用户的密码
|
* 管理员修改用户的密码
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param newPassword
|
* @param newPassword
|
||||||
* @param confirmPassword
|
* @param confirmPassword
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword) {
|
public String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
if(!newPassword.equals(confirmPassword)){
|
if (!newPassword.equals(confirmPassword)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"两次密码输入不一致",locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale);
|
||||||
}
|
}
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
||||||
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
|
||||||
sysUserDao.updatePassword(userId,newAfterPassword);
|
sysUserDao.updatePassword(userId, newAfterPassword);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -298,132 +309,139 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按天数修改账号到期时间
|
* 按天数修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updateExpireDateDay(Integer userId, Integer dayNum) {
|
public String updateExpireDateDay(Integer userId, Integer dayNum) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
long l = dayNum.longValue();
|
long l = dayNum.longValue();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
||||||
if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
||||||
LocalDateTime localDateTime = now.plusDays(l);
|
LocalDateTime localDateTime = now.plusDays(l);
|
||||||
String time = dateTimeToString(localDateTime);
|
String time = dateTimeToString(localDateTime);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}else {
|
} else {
|
||||||
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
||||||
LocalDateTime localDateTime1 = localDateTime.plusDays(l);
|
LocalDateTime localDateTime1 = localDateTime.plusDays(l);
|
||||||
String time = dateTimeToString(localDateTime1);
|
String time = dateTimeToString(localDateTime1);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按月份修改账号过期时间
|
* 按月份修改账号过期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updateExpireDateMonth(Integer userId, Integer dayNum) {
|
public String updateExpireDateMonth(Integer userId, Integer dayNum) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
long l = dayNum.longValue();
|
long l = dayNum.longValue();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
||||||
if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
||||||
LocalDateTime localDateTime = now.plusMonths(l);
|
LocalDateTime localDateTime = now.plusMonths(l);
|
||||||
String time = dateTimeToString(localDateTime);
|
String time = dateTimeToString(localDateTime);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}else {
|
} else {
|
||||||
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
||||||
LocalDateTime localDateTime1 = localDateTime.plusMonths(l);
|
LocalDateTime localDateTime1 = localDateTime.plusMonths(l);
|
||||||
String time = dateTimeToString(localDateTime1);
|
String time = dateTimeToString(localDateTime1);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按年份修改账号到期时间
|
* 按年份修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updateExpireDateYear(Integer userId, Integer dayNum) {
|
public String updateExpireDateYear(Integer userId, Integer dayNum) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
long l = dayNum.longValue();
|
long l = dayNum.longValue();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
|
||||||
if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){
|
if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) {
|
||||||
LocalDateTime localDateTime = now.plusYears(l);
|
LocalDateTime localDateTime = now.plusYears(l);
|
||||||
String time = dateTimeToString(localDateTime);
|
String time = dateTimeToString(localDateTime);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}else {
|
} else {
|
||||||
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
||||||
LocalDateTime localDateTime1 = localDateTime.plusYears(l);
|
LocalDateTime localDateTime1 = localDateTime.plusYears(l);
|
||||||
String time = dateTimeToString(localDateTime1);
|
String time = dateTimeToString(localDateTime1);
|
||||||
sysUserDao.updateOverTime(userId,time);
|
sysUserDao.updateOverTime(userId, time);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置账号永久有效
|
* 设置账号永久有效
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updatePermanent(Integer userId) {
|
public String updatePermanent(Integer userId) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
sysUserDao.updateDayNum(userId);
|
sysUserDao.updateDayNum(userId);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改账号到期时间
|
* 修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param overTime
|
* @param overTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String updateOverTime(Integer userId, String overTime) {
|
public String updateOverTime(Integer userId, String overTime) {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
sysUserDao.updateOverTime(userId,overTime);
|
sysUserDao.updateOverTime(userId, overTime);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录用户登录次数
|
* 记录用户登录次数
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param loginNum
|
* @param loginNum
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void updateLoginNum(Integer userId, Integer loginNum) {
|
public void updateLoginNum(Integer userId, Integer loginNum) {
|
||||||
sysUserDao.updateLoginNum(userId,loginNum);
|
sysUserDao.updateLoginNum(userId, loginNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录用户登录时间
|
* 记录用户登录时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param loginLastTime
|
* @param loginLastTime
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void updateLoginLastTime(Integer userId, String loginLastTime) {
|
public void updateLoginLastTime(Integer userId, String loginLastTime) {
|
||||||
sysUserDao.updateLoginLastTime(userId,loginLastTime);
|
sysUserDao.updateLoginLastTime(userId, loginLastTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user