临时用户生效日期
This commit is contained in:
parent
4fdf46420a
commit
a5c5cfb4f9
|
|
@ -172,12 +172,12 @@ public class SysUser extends BaseEntity {
|
||||||
/** 临时用户生效开始日期 */
|
/** 临时用户生效开始日期 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "生效开始日期", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "生效开始日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private String effectiveStartDay;
|
private Date effectiveStartDay;
|
||||||
|
|
||||||
/** 临时用户生效截止日期 */
|
/** 临时用户生效截止日期 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "生效截止日期", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "生效截止日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private String effectiveEndDay;
|
private Date effectiveEndDay;
|
||||||
|
|
||||||
public SysUser() {
|
public SysUser() {
|
||||||
|
|
||||||
|
|
@ -439,19 +439,19 @@ public class SysUser extends BaseEntity {
|
||||||
this.isBuiltIn = isBuiltIn;
|
this.isBuiltIn = isBuiltIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffectiveStartDay() {
|
public Date getEffectiveStartDay() {
|
||||||
return effectiveStartDay;
|
return effectiveStartDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEffectiveStartDay(String effectiveStartDay) {
|
public void setEffectiveStartDay(Date effectiveStartDay) {
|
||||||
this.effectiveStartDay = effectiveStartDay;
|
this.effectiveStartDay = effectiveStartDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffectiveEndDay() {
|
public Date getEffectiveEndDay() {
|
||||||
return effectiveEndDay;
|
return effectiveEndDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEffectiveEndDay(String effectiveEndDay) {
|
public void setEffectiveEndDay(Date effectiveEndDay) {
|
||||||
this.effectiveEndDay = effectiveEndDay;
|
this.effectiveEndDay = effectiveEndDay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.bonus.common.core.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否长期用户
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
public enum UserPermanentEnum
|
||||||
|
{
|
||||||
|
//正常
|
||||||
|
TEMP_USER("0", "临时用户"),
|
||||||
|
//停用
|
||||||
|
LONG_USER("1", "长期用户");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
UserPermanentEnum(String code, String info)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo()
|
||||||
|
{
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,8 @@ package com.bonus.system.controller;
|
||||||
|
|
||||||
import com.bonus.common.core.constant.CacheConstants;
|
import com.bonus.common.core.constant.CacheConstants;
|
||||||
import com.bonus.common.core.domain.R;
|
import com.bonus.common.core.domain.R;
|
||||||
|
import com.bonus.common.core.enums.UserPermanentEnum;
|
||||||
|
import com.bonus.common.core.enums.UserStatus;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
|
@ -330,7 +332,7 @@ public class SysUserController extends BaseController {
|
||||||
}
|
}
|
||||||
user.setCreateBy(SecurityUtils.getUsername());
|
user.setCreateBy(SecurityUtils.getUsername());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
setUserStatus(user);
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.toString(), e);
|
logger.error(e.toString(), e);
|
||||||
|
|
@ -338,6 +340,16 @@ public class SysUserController extends BaseController {
|
||||||
return error("系统异常,请联系管理员");
|
return error("系统异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setUserStatus(SysUser user) {
|
||||||
|
if (UserPermanentEnum.TEMP_USER.getCode().equals(user.getIsPermanent())) {
|
||||||
|
Date now = new Date();
|
||||||
|
if (Objects.nonNull(user.getEffectiveStartDay()) && user.getEffectiveStartDay().after(now)
|
||||||
|
|| Objects.nonNull(user.getEffectiveEndDay()) && user.getEffectiveEndDay().before(now)) {
|
||||||
|
user.setStatus(UserStatus.DISABLE.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
|
|
@ -360,6 +372,7 @@ public class SysUserController extends BaseController {
|
||||||
return error("内置用户不允许修改");
|
return error("内置用户不允许修改");
|
||||||
}
|
}
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
setUserStatus(user);
|
||||||
return toAjax(userService.updateUser(user));
|
return toAjax(userService.updateUser(user));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.toString(), e);
|
logger.error(e.toString(), e);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue