修改 新增用户 接口

This commit is contained in:
liuchengqian 2022-05-06 13:46:59 +08:00
parent 5f680532b6
commit 209985cdf0
3 changed files with 145 additions and 132 deletions

View File

@ -7,6 +7,7 @@ import java.time.LocalDateTime;
/**
* SysUser 表实体类
*
* @author tajochen
*/
@Entity
@ -97,6 +98,8 @@ public class SysUserEntity implements Serializable {
*/
private String loginLastTime;
private Integer street;
public Integer getId() {
return id;
}
@ -257,29 +260,16 @@ public class SysUserEntity implements Serializable {
this.loginLastTime = loginLastTime;
}
public Integer getStreet() {
return street;
}
public void setStreet(Integer street) {
this.street = street;
}
@Override
public String toString() {
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 + '\'' +
'}';
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 + '}';
}
}

View File

@ -11,6 +11,7 @@ import javax.validation.constraints.Size;
/**
* SysUserQo
*
* @author tajochen
*/
public class SysUserQo {
@ -18,29 +19,22 @@ public class SysUserQo {
@NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class})
private Integer id;
@NotBlank(message = "{SysUser.userName.blank}",groups={SysUserQoInsert.class})
@Size(min = 4,max = 16, message = "{SysUser.userName.length.illegal}",groups = {SysUserQoInsert.class,
SysUserQoUpdate.class})
@NotBlank(message = "{SysUser.userName.blank}", groups = {SysUserQoInsert.class}) @Size(min = 4, max = 16, message = "{SysUser.userName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
/**
* 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,
SysUserQoUpdate.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})
private String userName;
@Size(max = 32, message = "{SysUser.nickName.length.illegal}",groups = {SysUserQoInsert.class,
SysUserQoUpdate.class})
@Size(max = 32, message = "{SysUser.nickName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class})
private String reallyName;
@NotBlank(message = "{SysUser.password.blank}", groups = {SysUserQoInsert.class})
@Size(min = 6,max = 16, message = "{SysUser.password.length.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})
@Size(min = 6, max = 16, message = "{SysUser.password.length.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;
@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})
@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})
private String telephone;
@NotNull(message = "{SysUser.statusCode.illegal}", groups = {SysUserQoUpdate.class})
@ -62,6 +56,9 @@ public class SysUserQo {
private String countyName;
@NotNull(message = "{SysUser.street.blank}", groups = {SysUserQoUpdate.class})
private Integer street;
public Integer getId() {
return id;
}
@ -165,4 +162,12 @@ public class SysUserQo {
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public Integer getStreet() {
return street;
}
public void setStreet(Integer street) {
this.street = street;
}
}

View File

@ -8,8 +8,7 @@ import com.xkrs.model.vo.SysUserVo;
import com.xkrs.service.RedisService;
import com.xkrs.service.SysUserService;
import com.xkrs.utils.DateTimeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.crypto.keygen.KeyGenerators;
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.utils.DateTimeUtil.dateTimeToString;
import static com.xkrs.utils.DateTimeUtil.getNowTime;
import static com.xkrs.utils.EncryptDecryptUtil.encry256;
/**
* 系统用户服务实现
*
* @author tajochen
*/
@Service
@ -59,6 +58,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 检查用户名是否存在
*
* @param userName
* @return
*/
@ -66,10 +66,11 @@ public class SysUserServiceImpl implements SysUserService {
public boolean checkUserName(String userName) {
int num = sysUserDao.checkUserName(userName);
return (num == 0);
};
}
/**
* 新增用户
*
* @param sysUserQo
*/
@Transactional(rollbackFor = Exception.class)
@ -79,6 +80,7 @@ public class SysUserServiceImpl implements SysUserService {
Locale locale = LocaleContextHolder.getLocale();
String salt = KeyGenerators.string().generateKey();
SysUserEntity sysUserEntity = new SysUserEntity();
sysUserEntity.setStreet(0);
sysUserEntity.setUserName(sysUserQo.getUserName());
String o = (String) redisService.get(sysUserQo.getUserName());
if ("".equals(o) || o == null) {
@ -95,12 +97,15 @@ public class SysUserServiceImpl implements SysUserService {
sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt));
sysUserEntity.setTelephone(sysUserQo.getUserName());
sysUserEntity.setCountyCode(sysUserQo.getCountyCode());
if("".equals(sysUserQo.getCountyName()) || sysUserQo.getCountyName() == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"省市区名称不能为空!",locale);
if (TextUtils.isEmpty(sysUserQo.getCountyName())) {
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());
if (byProCode == null || byProCode.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省编码不存在!", locale);
@ -142,7 +147,6 @@ public class SysUserServiceImpl implements SysUserService {
sysUserEntity.setOverTime(string);
sysUserEntity.setLoginNum(0);
sysUserEntity.setCountyName(sysUserQo.getCountyName());
sysUserDao.save(sysUserEntity);
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
@ -161,6 +165,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 查询所有用户Vo
*
* @return
*/
/*@Transactional(rollbackFor=Exception.class)
@ -169,7 +174,6 @@ public class SysUserServiceImpl implements SysUserService {
Iterable<SysUserVo> ls = sysUserDao.selectAllSysUser();
return ls;
}*/
@Transactional(rollbackFor = Exception.class)
@Override
public SysUserEntity getSysUserByUserName(String userName) {
@ -184,6 +188,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 更新用户
*
* @param sysUserQo
* @return
*/
@ -198,6 +203,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 软删除普通用户
*
* @param id
* @return
*/
@ -220,6 +226,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 查询用户的信息
*
* @return
*/
@Override
@ -229,6 +236,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 启用
*
* @param userId
*/
@Transactional(rollbackFor = Exception.class)
@ -239,6 +247,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 禁用
*
* @param userId
*/
@Transactional(rollbackFor = Exception.class)
@ -249,6 +258,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 用户修改密码
*
* @param oldPassword
* @param newPassword
* @param confirmPassword
@ -273,6 +283,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 管理员修改用户的密码
*
* @param userId
* @param newPassword
* @param confirmPassword
@ -298,6 +309,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 按天数修改账号到期时间
*
* @param userId
* @param dayNum
* @return
@ -325,6 +337,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 按月份修改账号过期时间
*
* @param userId
* @param dayNum
* @return
@ -352,6 +365,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 按年份修改账号到期时间
*
* @param userId
* @param dayNum
* @return
@ -379,6 +393,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 设置账号永久有效
*
* @param userId
* @return
*/
@ -392,6 +407,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 修改账号到期时间
*
* @param userId
* @param overTime
* @return
@ -406,6 +422,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 记录用户登录次数
*
* @param userId
* @param loginNum
*/
@ -417,6 +434,7 @@ public class SysUserServiceImpl implements SysUserService {
/**
* 记录用户登录时间
*
* @param userId
* @param loginLastTime
*/