Commit 3ad75783 authored by cq990612's avatar cq990612

优化代码结构

parent 124f4f03
...@@ -46,7 +46,7 @@ public enum BASE_RESP_CODE_ENUM { ...@@ -46,7 +46,7 @@ public enum BASE_RESP_CODE_ENUM {
PROJECT_NOT_HAVE_USER("624", "该部门下没有项目"), PROJECT_NOT_HAVE_USER("624", "该部门下没有项目"),
USER_LOGIN_NAME_OR_PASSWORD_IS_ERROR("625", "用户名或密码不正确"), USER_LOGIN_NAME_OR_PASSWORD_IS_ERROR("625", "用户名或密码不正确"),
DELETE_OLD_WORK_ORDER_FAIL("626","删除旧工单数据失败"), DELETE_OLD_WORK_ORDER_FAIL("626","删除旧工单数据失败"),
WORK_DAY_THAN_DATE("627","超过3天的工单不能补报"), DUPLICATEROLEPERMISSIONS("627","角色权限重复!"),
DES_NOT_NULL("628","工作简述不能为空"), DES_NOT_NULL("628","工作简述不能为空"),
WORK_PROJECT_IS_NULL("629","项目或商机为空"), WORK_PROJECT_IS_NULL("629","项目或商机为空"),
WORK_ORDER_END("630", "该项目暂无待审批工单"), WORK_ORDER_END("630", "该项目暂无待审批工单"),
...@@ -78,7 +78,8 @@ public enum BASE_RESP_CODE_ENUM { ...@@ -78,7 +78,8 @@ public enum BASE_RESP_CODE_ENUM {
THEPERIOD_CANNOT_BELESS_THANONEDAY("658", "设置的期限不能小于1天"), THEPERIOD_CANNOT_BELESS_THANONEDAY("658", "设置的期限不能小于1天"),
DUPLICATE_HOLIDAY_NAME("659", "节假日名称重复"), DUPLICATE_HOLIDAY_NAME("659", "节假日名称重复"),
DEPARTMENT_MANAGER_ALREADY_EXISTS("660", "该部门已有部门负责人"), DEPARTMENT_MANAGER_ALREADY_EXISTS("660", "该部门已有部门负责人"),
CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人") CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"),
ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"),
; ;
......
...@@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode; ...@@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ApiModel(value="WorkLevel", description="权限实体类") @ApiModel(value="WorkLevel", description="权限实体类")
public class WorkLevel { public class WorkLevel implements Comparable<WorkLevel>{
@ApiModelProperty(name = "id",value = "主键") @ApiModelProperty(name = "id",value = "主键")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
...@@ -23,12 +23,18 @@ public class WorkLevel { ...@@ -23,12 +23,18 @@ public class WorkLevel {
@ApiModelProperty(name = "rank",value = "权限等级->1:项目级 2:部门级 3:中心级") @ApiModelProperty(name = "rank",value = "权限等级->1:项目级 2:部门级 3:中心级")
private Integer rank; private Integer rank;
@ApiModelProperty(name = "icon",value = "图标") @ApiModelProperty(name = "icon",value = "图标")
private String icon; private String icon;
@ApiModelProperty(name = "path",value = "路径") @ApiModelProperty(name = "path",value = "路径")
private String path; private String path;
@ApiModelProperty(name = "sort", value = "排序")
private Integer sort;
@Override
public int compareTo(WorkLevel o) {
return this.sort-o.sort;
}
} }
...@@ -18,7 +18,7 @@ import java.io.Serializable; ...@@ -18,7 +18,7 @@ import java.io.Serializable;
@ApiModel(value="WorkType", description="项目类型类") @ApiModel(value="WorkType", description="项目类型类")
public class WorkType implements Serializable, Comparable{ public class WorkType implements Serializable, Comparable{
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4}; private final static Integer[] TYPE_ORDER = {1,3,2};
private static final long serialVersionUID = 8842083047098059912L; private static final long serialVersionUID = 8842083047098059912L;
@ApiModelProperty(name = "id",value = "主键id") @ApiModelProperty(name = "id",value = "主键id")
...@@ -38,10 +38,10 @@ public class WorkType implements Serializable, Comparable{ ...@@ -38,10 +38,10 @@ public class WorkType implements Serializable, Comparable{
int thisI = 0; int thisI = 0;
int oI = 0; int oI = 0;
for (int i = 0; i < TYPE_ORDER.length; i++) { for (int i = 0; i < TYPE_ORDER.length; i++) {
if (id.equals(TYPE_ORDER[i])) { if (reviewer.equals(TYPE_ORDER[i])) {
thisI = i; thisI = i;
} }
if (workType.getId().equals(TYPE_ORDER[i])) { if (workType.getReviewer().equals(TYPE_ORDER[i])) {
oI = i; oI = i;
} }
} }
......
...@@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
...@@ -191,7 +188,9 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -191,7 +188,9 @@ public class WorkUserServiceImpl implements WorkUserService {
public Boolean modifyRole(Integer userId, List<Integer> roleIds,Integer status) { public Boolean modifyRole(Integer userId, List<Integer> roleIds,Integer status) {
log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{},status:{}" + userId, roleIds,status); log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{},status:{}" + userId, roleIds,status);
PageHelper.clearPage(); PageHelper.clearPage();
if (UserRoleLevelUtils.levelIsRepeat(roleIds)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DUPLICATEROLEPERMISSIONS);
}
WorkUser workUser = workUserMapper.selectById(userId); WorkUser workUser = workUserMapper.selectById(userId);
if (null == workUser) { if (null == workUser) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL);
...@@ -291,7 +290,11 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -291,7 +290,11 @@ public class WorkUserServiceImpl implements WorkUserService {
ResultUser resultUser = getResultUser(user); ResultUser resultUser = getResultUser(user);
resultUser.setDay(byId.getSubmitTime()); resultUser.setDay(byId.getSubmitTime());
List<Integer> levelIds = UserRoleLevelUtils.getlevelIds(roles); List<Integer> levelIds = UserRoleLevelUtils.getlevelIds(roles);
resultUser.setWorkLevels(UserRoleLevelUtils.getlevelByIds(levelIds)); List<WorkLevel> workLevels = UserRoleLevelUtils.getlevelByIds(levelIds);
if (!CollectionUtils.isEmpty(workLevels)) {
Collections.sort(workLevels);
resultUser.setWorkLevels(workLevels);
}
return resultUser; return resultUser;
} }
......
...@@ -9,7 +9,6 @@ import cn.wisenergy.mapper.WorkUserRoleMapper; ...@@ -9,7 +9,6 @@ import cn.wisenergy.mapper.WorkUserRoleMapper;
import cn.wisenergy.model.app.WorkLevel; import cn.wisenergy.model.app.WorkLevel;
import cn.wisenergy.model.app.WorkRole; import cn.wisenergy.model.app.WorkRole;
import cn.wisenergy.model.dto.UserRoleLevelDto; import cn.wisenergy.model.dto.UserRoleLevelDto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -18,7 +17,9 @@ import org.springframework.util.CollectionUtils; ...@@ -18,7 +17,9 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
@Component @Component
public class UserRoleLevelUtils { public class UserRoleLevelUtils {
...@@ -162,5 +163,24 @@ public class UserRoleLevelUtils { ...@@ -162,5 +163,24 @@ public class UserRoleLevelUtils {
return false; return false;
} }
/**
* 判断权限是否重复
*/
public static Boolean levelIsRepeat(List<Integer> roles) {
if (CollectionUtils.isEmpty(roles)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ROLE_CANNOTBE_EMPTY);
}
List<Integer> getlevelIds = getlevelIds(roles);
Set<Integer> hashSet = new HashSet<>();
for (Integer id : getlevelIds) {
if (!hashSet.add(id)){
//有重复值
return true;
}
}
return false;
}
} }
...@@ -3,7 +3,7 @@ spring: ...@@ -3,7 +3,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.110.84:3306/work_hours?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.110.84:3306/work_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root username: root
password: admin!@#123 password: admin!@#123
initial-size: 10 initial-size: 10
......
...@@ -3,7 +3,7 @@ server: ...@@ -3,7 +3,7 @@ server:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-threads: 1000 max-threads: 1000
min-spare-threads: 30 min-spare-threads: 30
port: 8081 port: 8080
connection-timeout: 5000ms connection-timeout: 5000ms
spring: spring:
......
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