Commit 5b84dcfd by guojuxing

新建临时账号

parent a3811d71
package com.gic.auth.constant;
public enum AccountPositionEnum {
area_manager(1, "区域经理"),
OFFLINE_OPERATION(2, "线下运营"),
E_OPERATION(3, "电商运营"),
IT_COMMISSIONER(4, "IT专员"),
DATA_COMMISSIONER(5, "数据专员");
private Integer code;
private String message;
AccountPositionEnum(Integer code, String message){
this.code = code;
this.message = message;
}
public static boolean isRightCode(Integer code) {
if (code == null) {
return true;
}
for (AccountPositionEnum accountPositionEnum : values()) {
if (accountPositionEnum.getCode().intValue() == code) {
return true;
}
}
return false;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
......@@ -103,6 +103,27 @@ public class UserDTO implements Serializable{
* 登陆账号类型 1:运营 0:默认GIC
*/
private Integer loginType;
/**
* 账号类型 1:永久账号 2:临时账号
*/
private Integer accountType;
/**
* 临时账号到期时间
*/
private Date accountDueDate;
/**
* 临时账号到期时间 前端
*/
private String accountDueDateStr;
/**
* 职位 1:区域经理、2:线下运营、3:电商运营、4:IT专员、5:数据专员 子管理员必填
*/
private Integer userPosition;
/**
* 用户角色,可以多选,用英文逗号隔开
*/
......@@ -263,4 +284,40 @@ public class UserDTO implements Serializable{
public void setAccountGroupIds(String accountGroupIds) {
this.accountGroupIds = accountGroupIds;
}
public Integer getAccountType() {
return accountType;
}
public UserDTO setAccountType(Integer accountType) {
this.accountType = accountType;
return this;
}
public Date getAccountDueDate() {
return accountDueDate;
}
public UserDTO setAccountDueDate(Date accountDueDate) {
this.accountDueDate = accountDueDate;
return this;
}
public Integer getUserPosition() {
return userPosition;
}
public UserDTO setUserPosition(Integer userPosition) {
this.userPosition = userPosition;
return this;
}
public String getAccountDueDateStr() {
return accountDueDateStr;
}
public UserDTO setAccountDueDateStr(String accountDueDateStr) {
this.accountDueDateStr = accountDueDateStr;
return this;
}
}
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
/**
* 管理员列表
* @ClassName: UserListDTO

......@@ -40,6 +42,26 @@ public class UserListDTO implements Serializable{
*/
private String userResourceNames;
/**
* 账号类型 1:永久账号 2:临时账号
*/
private Integer accountType;
/**
* 临时账号到期时间
*/
private Date accountDueDate;
/**
* 临时账号状态 1:生效中 2:已过期
*/
private Integer accountDueDateType;
/**
* 职位 1:区域经理、2:线下运营、3:电商运营、4:IT专员、5:数据专员 子管理员必填
*/
private Integer userPosition;
public Integer getUserId() {
return userId;
}
......@@ -87,4 +109,48 @@ public class UserListDTO implements Serializable{
public void setUserResourceNames(String userResourceNames) {
this.userResourceNames = userResourceNames;
}
public Integer getAccountType() {
return accountType;
}
public UserListDTO setAccountType(Integer accountType) {
this.accountType = accountType;
return this;
}
public Date getAccountDueDate() {
return accountDueDate;
}
public UserListDTO setAccountDueDate(Date accountDueDate) {
this.accountDueDate = accountDueDate;
return this;
}
public Integer getAccountDueDateType() {
if (accountType != null && accountType == 2) {
//如果是临时账号
if (accountDueDate.getTime() >= System.currentTimeMillis()) {
return 1;
} else {
return 2;
}
}
return accountDueDateType;
}
public UserListDTO setAccountDueDateType(Integer accountDueDateType) {
this.accountDueDateType = accountDueDateType;
return this;
}
public Integer getUserPosition() {
return userPosition;
}
public UserListDTO setUserPosition(Integer userPosition) {
this.userPosition = userPosition;
return this;
}
}
......@@ -27,6 +27,15 @@ public class UserListQO extends PageQO{
private List<Integer> userIdList;
private Integer accountType;
private Integer userPosition;
/**
* 临时账号状态 生效中 已过期
*/
private Integer accountDueDateType;
public String getSearch() {
return search;
}
......@@ -74,4 +83,31 @@ public class UserListQO extends PageQO{
public void setUserIdList(List<Integer> userIdList) {
this.userIdList = userIdList;
}
public Integer getAccountType() {
return accountType;
}
public UserListQO setAccountType(Integer accountType) {
this.accountType = accountType;
return this;
}
public Integer getUserPosition() {
return userPosition;
}
public UserListQO setUserPosition(Integer userPosition) {
this.userPosition = userPosition;
return this;
}
public Integer getAccountDueDateType() {
return accountDueDateType;
}
public UserListQO setAccountDueDateType(Integer accountDueDateType) {
this.accountDueDateType = accountDueDateType;
return this;
}
}
......@@ -71,6 +71,21 @@ public class TabSysUser {
*/
private Integer passwordType;
/**
* 账号类型 1:永久账号 2:临时账号
*/
private Integer accountType;
/**
* 临时账号到期时间
*/
private Date accountDueDate;
/**
* 职位 1:区域经理、2:线下运营、3:电商运营、4:IT专员、5:数据专员 子管理员必填
*/
private Integer userPosition;
public Integer getUserId() {
return userId;
}
......@@ -174,4 +189,31 @@ public class TabSysUser {
public void setPasswordType(Integer passwordType) {
this.passwordType = passwordType;
}
public Integer getAccountType() {
return accountType;
}
public TabSysUser setAccountType(Integer accountType) {
this.accountType = accountType;
return this;
}
public Date getAccountDueDate() {
return accountDueDate;
}
public TabSysUser setAccountDueDate(Date accountDueDate) {
this.accountDueDate = accountDueDate;
return this;
}
public Integer getUserPosition() {
return userPosition;
}
public TabSysUser setUserPosition(Integer userPosition) {
this.userPosition = userPosition;
return this;
}
}
\ No newline at end of file
......@@ -35,6 +35,10 @@ public class UserServiceImpl implements UserService {
userDTO.setUpdateTime(new Date());
userDTO.setStatus(1);
TabSysUser tabUser = EntityUtil.changeEntityNew(TabSysUser.class, userDTO);
if (tabUser.getAccountType() == null) {
//永久有效账号
tabUser.setAccountType(1);
}
tabSysUserMapper.insert(tabUser);
return tabUser.getUserId();
}
......@@ -48,6 +52,7 @@ public class UserServiceImpl implements UserService {
//设置超管权限
userDTO.setSuperAdmin(1);
TabSysUser tabUser = EntityUtil.changeEntityNew(TabSysUser.class, userDTO);
tabUser.setAccountType(1);
tabSysUserMapper.insertSelective(tabUser);
return tabUser.getUserId();
}
......
......@@ -3,6 +3,7 @@ package com.gic.auth.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.AccountGroupMemberTypeEnum;
import com.gic.auth.constant.AccountPositionEnum;
import com.gic.auth.constant.LoginUserTypeEnum;
import com.gic.auth.dto.*;
import com.gic.auth.entity.*;
......@@ -17,11 +18,15 @@ import com.gic.redis.data.util.RedisUtil;
import com.gic.store.utils.valid.ValidUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
......@@ -32,6 +37,7 @@ import java.util.stream.Collectors;
*/
@Service("userApiService")
public class UserApiServiceImpl implements UserApiService {
private static final Logger LOGGER = LogManager.getLogger(UserApiServiceImpl.class);
@Autowired
private UserService userService;
@Autowired
......@@ -95,6 +101,30 @@ public class UserApiServiceImpl implements UserApiService {
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
userDTO.setPhoneAreaCode("86");
}
Integer accountType = userDTO.getAccountType();
boolean isNotRightAccountType = accountType != null && accountType != 1 && accountType != 2;
if (isNotRightAccountType) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "管理员账号类型值非法");
}
boolean isTempAccount = accountType != null && accountType == 2;
if (isTempAccount && StringUtils.isBlank(userDTO.getAccountDueDateStr())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "临时账号必须填写账号到期时间");
}
if (isTempAccount) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
userDTO.setAccountDueDate(sdf.parse(userDTO.getAccountDueDateStr()));
} catch (ParseException e) {
LOGGER.warn("新建临时账号到期时间解析:{}", e.getMessage(), e);
}
}
if (!AccountPositionEnum.isRightCode(userDTO.getUserPosition())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "职位值非法");
}
Integer userId = userService.saveUser(userDTO);
userRoleService.deleteByUserId(userId);
......
......@@ -15,10 +15,13 @@
<result column="user_group_ids" jdbcType="VARCHAR" property="userGroupIds" />
<result column="login_type" jdbcType="INTEGER" property="loginType" />
<result column="password_type" jdbcType="INTEGER" property="passwordType" />
<result column="account_type" jdbcType="INTEGER" property="accountType" />
<result column="account_due_date" jdbcType="TIMESTAMP" property="accountDueDate" />
<result column="user_position" jdbcType="INTEGER" property="userPosition" />
</resultMap>
<sql id="Base_Column_List">
user_id, user_name, phone_number, password, super_admin, status, create_time, update_time,
enterprise_id, phone_area_code, user_group_ids, login_type, password_type
enterprise_id, phone_area_code, user_group_ids, login_type, password_type, account_type, account_due_date, user_position
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
......@@ -34,13 +37,13 @@
insert into tab_sys_user (user_id, user_name, phone_number,
password, super_admin, status,
create_time, update_time, enterprise_id,
phone_area_code, user_group_ids, login_type, password_type
phone_area_code, user_group_ids, login_type, password_type, account_type, account_due_date, user_position
)
values (#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{superAdmin,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{enterpriseId,jdbcType=INTEGER},
#{phoneAreaCode,jdbcType=VARCHAR}, #{userGroupIds,jdbcType=VARCHAR}, #{loginType,jdbcType=INTEGER},
#{passwordType,jdbcType=INTEGER}
#{passwordType,jdbcType=INTEGER}, #{accountType,jdbcType=INTEGER}, #{accountDueDate,jdbcType=TIMESTAMP}, #{userPosition,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.auth.entity.TabSysUser" useGeneratedKeys="true" keyProperty="userId">
......@@ -85,6 +88,15 @@
<if test="passwordType != null">
password_type,
</if>
<if test="accountType != null">
account_type,
</if>
<if test="accountDueDate != null">
account_due_date,
</if>
<if test="userPosition != null">
user_position,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
......@@ -126,6 +138,15 @@
<if test="passwordType != null">
#{passwordType,jdbcType=INTEGER},
</if>
<if test="accountType != null">
#{accountType,jdbcType=INTEGER},
</if>
<if test="accountDueDate != null">
#{accountDueDate,jdbcType=TIMESTAMP},
</if>
<if test="userPosition != null">
#{userPosition,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabSysUser">
......@@ -167,6 +188,15 @@
<if test="passwordType != null">
password_type = #{passwordType,jdbcType=INTEGER},
</if>
<if test="accountType != null">
account_type = #{accountType,jdbcType=INTEGER},
</if>
<if test="accountDueDate != null">
account_due_date = #{accountDueDate,jdbcType=TIMESTAMP},
</if>
<if test="userPosition != null">
user_position = #{userPosition,jdbcType=INTEGER},
</if>
</set>
where user_id = #{userId,jdbcType=INTEGER}
</update>
......@@ -183,7 +213,10 @@
phone_area_code = #{phoneAreaCode,jdbcType=VARCHAR},
user_group_ids = #{userGroupIds,jdbcType=VARCHAR},
login_type = #{loginType,jdbcType=INTEGER},
password_type = #{passwordType,jdbcType=INTEGER}
password_type = #{passwordType,jdbcType=INTEGER},
account_type = #{accountType,jdbcType=INTEGER},
account_due_date = #{accountDueDate,jdbcType=TIMESTAMP},
user_position = #{userPosition,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
......@@ -273,6 +306,20 @@
<if test="resourceId != null">
and c.resource_id = #{resourceId}
</if>
<if test="accountType != null">
and a.account_type = #{accountType}
</if>
<if test="userPosition != null">
and a.user_position = #{userPosition}
</if>
<if test="accountDueDateType != null and accountType == 2">
<if test="accountDueDateType == 1">
and a.account_due_date >= now()
</if>
<if test="accountDueDateType == 2">
and a.account_due_date &lt; now()
</if>
</if>
<if test="userIdList != null and userIdList.size() > 0">
and a.user_id in
<foreach collection="userIdList" index="index" item="item" open="(" separator="," close=")">
......
......@@ -40,10 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
public class LoginController {
......@@ -125,6 +122,13 @@ public class LoginController {
if (userDTO == null) {
return EnterpriseRestResponse.failure(ErrorCode.LOGIN_ERR);
}
//判断,如果是临时账号,还需要判断是否过期
boolean isExpireAccount = userDTO.getAccountType() == 2 && (userDTO.getAccountDueDate().getTime() < System.currentTimeMillis());
if (isExpireAccount) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号已失效,请联系管理员!");
}
UserDetail userDetail = new UserDetail();
userDetail.setUserId(userDTO.getUserId());
userDetail.setUserInfo(EntityUtil.changeEntityNew(UserInfo.class, userDTO));
......
......@@ -132,6 +132,10 @@ public class UserController {
@RequestMapping("/list-user")
public RestResponse listUser(UserListQO params) {
if (params.getAccountType() == null) {
//默认查询永久账号
params.setAccountType(1);
}
params.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonResult(userApiService.pageUser(params));
}
......
package com.gic.auth.web.vo;
import java.io.Serializable;
import java.util.Date;
/**
* 用户详情
* @ClassName: UserDetailVO

......@@ -60,6 +62,21 @@ public class UserDetailVO implements Serializable{
*/
private String accountGroupIds;
/**
* 账号类型 1:永久账号 2:临时账号
*/
private Integer accountType;
/**
* 临时账号到期时间
*/
private Date accountDueDate;
/**
* 职位 1:区域经理、2:线下运营、3:电商运营、4:IT专员、5:数据专员 子管理员必填
*/
private Integer userPosition;
public Integer getUserId() {
return userId;
}
......@@ -139,4 +156,31 @@ public class UserDetailVO implements Serializable{
public void setAccountGroupIds(String accountGroupIds) {
this.accountGroupIds = accountGroupIds;
}
public Integer getAccountType() {
return accountType;
}
public UserDetailVO setAccountType(Integer accountType) {
this.accountType = accountType;
return this;
}
public Date getAccountDueDate() {
return accountDueDate;
}
public UserDetailVO setAccountDueDate(Date accountDueDate) {
this.accountDueDate = accountDueDate;
return this;
}
public Integer getUserPosition() {
return userPosition;
}
public UserDetailVO setUserPosition(Integer userPosition) {
this.userPosition = userPosition;
return this;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment