修改 新增用户 接口
This commit is contained in:
parent
5f680532b6
commit
209985cdf0
@ -7,6 +7,7 @@ import java.time.LocalDateTime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SysUser 表实体类
|
* SysUser 表实体类
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@ -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,6 +11,7 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SysUserQo
|
* SysUserQo
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
public class SysUserQo {
|
public class SysUserQo {
|
||||||
@ -18,29 +19,22 @@ 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})
|
||||||
@ -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,10 +66,11 @@ 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)
|
||||||
@ -79,6 +80,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
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) {
|
||||||
@ -95,12 +97,15 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
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);
|
||||||
@ -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();
|
||||||
@ -161,6 +165,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有用户Vo
|
* 查询所有用户Vo
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
/*@Transactional(rollbackFor=Exception.class)
|
/*@Transactional(rollbackFor=Exception.class)
|
||||||
@ -169,7 +174,6 @@ 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) {
|
||||||
@ -184,6 +188,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户
|
* 更新用户
|
||||||
|
*
|
||||||
* @param sysUserQo
|
* @param sysUserQo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -198,6 +203,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 软删除普通用户
|
* 软删除普通用户
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -220,6 +226,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户的信息
|
* 查询用户的信息
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -229,6 +236,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用
|
* 启用
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -239,6 +247,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 禁用
|
* 禁用
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -249,6 +258,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户修改密码
|
* 用户修改密码
|
||||||
|
*
|
||||||
* @param oldPassword
|
* @param oldPassword
|
||||||
* @param newPassword
|
* @param newPassword
|
||||||
* @param confirmPassword
|
* @param confirmPassword
|
||||||
@ -273,6 +283,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员修改用户的密码
|
* 管理员修改用户的密码
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param newPassword
|
* @param newPassword
|
||||||
* @param confirmPassword
|
* @param confirmPassword
|
||||||
@ -298,6 +309,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按天数修改账号到期时间
|
* 按天数修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
@ -325,6 +337,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按月份修改账号过期时间
|
* 按月份修改账号过期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
@ -352,6 +365,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按年份修改账号到期时间
|
* 按年份修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param dayNum
|
* @param dayNum
|
||||||
* @return
|
* @return
|
||||||
@ -379,6 +393,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置账号永久有效
|
* 设置账号永久有效
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -392,6 +407,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改账号到期时间
|
* 修改账号到期时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param overTime
|
* @param overTime
|
||||||
* @return
|
* @return
|
||||||
@ -406,6 +422,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录用户登录次数
|
* 记录用户登录次数
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param loginNum
|
* @param loginNum
|
||||||
*/
|
*/
|
||||||
@ -417,6 +434,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录用户登录时间
|
* 记录用户登录时间
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param loginLastTime
|
* @param loginLastTime
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user