diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java index bd84712..055d52c 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java @@ -39,13 +39,13 @@ import org.springframework.web.bind.annotation.RestController; @EnableCreateCacheAnnotation @ComponentScan( excludeFilters = { - @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.nl.modules.quartz.*")} + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.nl.modules.quartz.*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.github.loki4j.*")} ) public class AppRun { public static void main(String[] args) { - SpringApplication.run(AppRun.class, args); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseEntity.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseEntity.java index 600f17f..08fc74e 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseEntity.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseEntity.java @@ -15,12 +15,15 @@ */ package org.nl.modules.common.base; +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Column; import javax.persistence.EntityListeners; @@ -55,10 +58,16 @@ public class BaseEntity implements Serializable { @Column(name = "create_time", updatable = false) @ApiModelProperty(value = "创建时间", hidden = true) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JSONField(format="yyyy-MM-dd HH:mm:ss") private Date create_time; @Column(name = "update_time") @ApiModelProperty(value = "更新时间", hidden = true) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JSONField(format="yyyy-MM-dd HH:mm:ss") private Date update_time; /* 分组校验 */ diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java index e0a9e93..ee94af9 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/Role.java @@ -62,15 +62,12 @@ public class Role extends BaseEntity implements Serializable { @ApiModelProperty(value = "名称", hidden = true) private String name; - @ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义") - private String dataScope = DataScopeEnum.THIS_LEVEL.getValue(); - @Column(name = "level") @ApiModelProperty(value = "级别,数值越小,级别越大") private Integer level = 3; @ApiModelProperty(value = "描述") - private String description; + private String remark; @Override public boolean equals(Object o) { diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java index 8da0d35..01f16be 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java @@ -41,7 +41,6 @@ public class User extends BaseEntity implements Serializable { @Id @Column(name = "role_id") - @NotNull(groups = {Update.class}) @GeneratedValue(strategy = GenerationType.IDENTITY) @ApiModelProperty(value = "ID", hidden = true) private Long id; @@ -79,7 +78,7 @@ public class User extends BaseEntity implements Serializable { @NotNull @ApiModelProperty(value = "是否启用") - private Boolean is_used; + private String is_used; @ApiModelProperty(value = "是否为admin账号", hidden = true) private Boolean isAdmin = false; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/repository/RoleRepository.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/repository/RoleRepository.java index 4d59261..d199a64 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/repository/RoleRepository.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/repository/RoleRepository.java @@ -50,7 +50,7 @@ public interface RoleRepository extends JpaRepository, JpaSpecificat */ @Query(value = "SELECT r.* FROM sys_role r, sys_users_roles u WHERE " + "r.role_id = u.role_id AND u.user_id = ?1",nativeQuery = true) - Set findByUserId(Long id); + List findByUserId(Long id); /** * 解绑角色菜单 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/RoleController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/RoleController.java index e9ea75c..70187c5 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/RoleController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/RoleController.java @@ -145,7 +145,7 @@ public class RoleController { * @return / */ private int getLevels(Integer level){ - List levels = roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()); + List levels = roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList()); int min = Collections.min(levels); if(level != null){ if(level < min){ diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java index 0315be9..7b74e6a 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java @@ -30,6 +30,7 @@ import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.RsaUtils; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.logging.annotation.Log; +import org.nl.modules.system.domain.Role; import org.nl.modules.system.domain.User; import org.nl.modules.system.domain.vo.UserPassVo; import org.nl.modules.system.service.DataService; @@ -148,8 +149,8 @@ public class UserController { @SaCheckPermission("user:del") public ResponseEntity delete(@RequestBody Set ids) { for (Long id : ids) { - Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); - Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList())); + Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList())); + Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList())); if (currentLevel > optLevel) { throw new BadRequestException("角色权限不足,不能删除:" + userService.findById(id).getUsername()); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/RoleService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/RoleService.java index 43f0b6d..cbeee8a 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/RoleService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/RoleService.java @@ -71,7 +71,7 @@ public interface RoleService { * @param id 用户ID * @return / */ - List findByUsersId(Long id); + List findByUsersId(Long id); /** * 根据角色查询角色级别 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/dto/RoleSmallDto.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/dto/RoleSmallDto.java index 150b191..49eb37b 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/dto/RoleSmallDto.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/dto/RoleSmallDto.java @@ -32,5 +32,4 @@ public class RoleSmallDto implements Serializable { private Integer level; - private String dataScope; } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java index f435fe9..d3a3d8b 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/DataServiceImpl.java @@ -56,23 +56,23 @@ public class DataServiceImpl implements DataService { // 用于存储部门id Set deptIds = new HashSet<>(); // 查询用户角色 - List roleSet = roleService.findByUsersId(user.getUser_id()); +// List roleSet = roleService.findByUsersId(user.getUser_id()); // 获取对应的部门ID - for (RoleSmallDto role : roleSet) { - DataScopeEnum dataScopeEnum = DataScopeEnum.find(role.getDataScope()); - switch (Objects.requireNonNull(dataScopeEnum)) { - case THIS_LEVEL: - /*if (ObjectUtil.isNotEmpty(user.getDept())){ - deptIds.add(user.getDept().getId()); - }*/ - break; - case CUSTOMIZE: - deptIds.addAll(getCustomize(deptIds, role)); - break; - default: - return new ArrayList<>(deptIds); - } - } +// for (RoleSmallDto role : roleSet) { +// DataScopeEnum dataScopeEnum = DataScopeEnum. +// switch (Objects.requireNonNull(dataScopeEnum)) { +// case THIS_LEVEL: +// /*if (ObjectUtil.isNotEmpty(user.getDept())){ +// deptIds.add(user.getDept().getId()); +// }*/ +// break; +// case CUSTOMIZE: +// deptIds.addAll(getCustomize(deptIds, role)); +// break; +// default: +// return new ArrayList<>(deptIds); +// } +// } return new ArrayList<>(deptIds); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java index 2726677..d1d9dc2 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/RoleServiceImpl.java @@ -17,6 +17,7 @@ package org.nl.modules.system.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; @@ -122,8 +123,7 @@ public class RoleServiceImpl implements RoleService { throw new EntityExistException(Role.class, "username", resources.getName()); } role.setName(resources.getName()); - role.setDescription(resources.getDescription()); - role.setDataScope(resources.getDataScope()); + role.setRemark(resources.getRemark()); role.setLevel(resources.getLevel()); roleRepository.save(role); // 更新相关缓存 @@ -163,8 +163,8 @@ public class RoleServiceImpl implements RoleService { } @Override - public List findByUsersId(Long id) { - return roleSmallMapper.toDto(new ArrayList<>(roleRepository.findByUserId(id))); + public List findByUsersId(Long id) { + return roleRepository.findByUserId(id); } @Override diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java index 82bb4b5..583542f 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java @@ -22,6 +22,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializeConfig; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; @@ -136,7 +137,7 @@ public class UserServiceImpl implements UserService { User user = this.findById(resources.getUser_id()); redisUtils.del("user::username:" + user.getUsername()); // 如果用户被禁用,则清除用户登录信息 - if(!resources.getIs_used()){ + if("0".equals(resources.getIs_used())){ onlineUserService.kickOutForUsername(resources.getUsername()); } resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); @@ -226,7 +227,7 @@ public class UserServiceImpl implements UserService { map.put("用户名", userDTO.getUsername()); map.put("角色", userDTO.getRoles()); map.put("邮箱", userDTO.getEmail()); - map.put("状态", userDTO.getIs_used() ? "启用" : "禁用"); + map.put("状态", "1".equals(userDTO.getIs_used()) ? "启用" : "禁用"); map.put("手机号码", userDTO.getPhone()); map.put("修改密码的时间", userDTO.getPwdResetTime()); map.put("创建日期", userDTO.getCreate_time()); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/sso/wql/SYS_USER.wql b/nladmin-system/nlsso-server/src/main/java/org/nl/sso/wql/SYS_USER.wql index 4e8b04b..4dd34f1 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/sso/wql/SYS_USER.wql +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/sso/wql/SYS_USER.wql @@ -49,11 +49,12 @@ IF 输入.flag = "1" PAGEQUERY SELECT - sys_user.*,GROUP_CONCAT(DISTINCT dept_id),GROUP_CONCAT(DISTINCT role_id) + sys_user.*,GROUP_CONCAT(DISTINCT sys_dept.dept_id) as depts,GROUP_CONCAT(DISTINCT sys_dept.name) as deptnames,GROUP_CONCAT(DISTINCT role_id) as roles FROM sys_user left join sys_user_dept on sys_user.user_id = sys_user_dept.user_id left join sys_users_roles on sys_users_roles.user_id = sys_user.user_id + left join sys_dept on sys_user_dept.dept_id = sys_dept.dept_id WHERE 1=1 OPTION 输入.id <> "" sys_user.id = 输入.id