mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 18:46:36 +08:00
commit:同步1.4版本
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.orange.demo.upmsinterface.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.upmsinterface.constant.SysMenuType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@@ -30,12 +30,6 @@ public class SysUserVo {
|
||||
@ApiModelProperty(value = "登录用户名")
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* 用户密码。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户显示名称。
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.orange.demo.common.core.util.RsaUtil;
|
||||
import com.orange.demo.common.redis.cache.SessionCacheHelper;
|
||||
import com.orange.demo.upmsinterface.constant.SysUserStatus;
|
||||
import com.orange.demo.upmsinterface.constant.SysUserType;
|
||||
import com.orange.demo.upmsservice.config.ApplicationConfig;
|
||||
import com.orange.demo.upmsservice.model.SysMenu;
|
||||
import com.orange.demo.upmsservice.model.SysUser;
|
||||
import com.orange.demo.upmsservice.service.*;
|
||||
@@ -46,12 +45,12 @@ public class LoginController {
|
||||
@Autowired
|
||||
private SysPermCodeService sysPermCodeService;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
private SysPermWhitelistService sysPermWhitelistService;
|
||||
@Autowired
|
||||
private ApplicationConfig appConfig;
|
||||
@Autowired
|
||||
private SessionCacheHelper cacheHelper;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@@ -76,11 +75,14 @@ public class LoginController {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysUser user = sysUserService.getSysUserByLoginName(loginName);
|
||||
if (user == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
||||
}
|
||||
password = URLDecoder.decode(password, StandardCharsets.UTF_8.name());
|
||||
// NOTE: 第一次使用时,请务必阅读ApplicationConstant.PRIVATE_KEY的代码注释。
|
||||
// 执行RsaUtil工具类中的main函数,可以生成新的公钥和私钥。
|
||||
password = RsaUtil.decrypt(password, ApplicationConstant.PRIVATE_KEY);
|
||||
if (user == null || !passwordEncoder.matches(password, user.getPassword())) {
|
||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
||||
}
|
||||
String errorMessage;
|
||||
@@ -120,19 +122,17 @@ public class LoginController {
|
||||
JSONObject jsonData = new JSONObject();
|
||||
jsonData.put("showName", tokenData.getShowName());
|
||||
jsonData.put("isAdmin", tokenData.getIsAdmin());
|
||||
List<SysMenu> menuList;
|
||||
Collection<SysMenu> menuList;
|
||||
Collection<String> permCodeList;
|
||||
if (tokenData.getIsAdmin()) {
|
||||
menuList = sysMenuService.getAllMenuList();
|
||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
||||
} else {
|
||||
menuList = sysMenuService.getMenuListByUserId(tokenData.getUserId());
|
||||
List<String> permCodeList = sysPermCodeService.getPermCodeListByUserId(tokenData.getUserId());
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
// 将白名单url列表合并到当前用户的权限资源列表中,便于网关一并处理。
|
||||
Set<String> permSet = sysUserService.getSysPermSetByUserId(tokenData.getUserId());
|
||||
permSet.addAll(sysPermWhitelistService.getWhitelistPermList());
|
||||
jsonData.put("permSet", permSet);
|
||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(tokenData.getUserId());
|
||||
}
|
||||
jsonData.put("menuList", menuList);
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
return ResponseResult.success(jsonData);
|
||||
}
|
||||
/**
|
||||
@@ -177,19 +177,21 @@ public class LoginController {
|
||||
jsonData.put(TokenData.REQUEST_ATTRIBUTE_NAME, tokenData);
|
||||
jsonData.put("showName", user.getShowName());
|
||||
jsonData.put("isAdmin", isAdmin);
|
||||
List<SysMenu> menuList;
|
||||
Collection<SysMenu> menuList;
|
||||
Collection<String> permCodeList;
|
||||
if (isAdmin) {
|
||||
menuList = sysMenuService.getAllMenuList();
|
||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
||||
} else {
|
||||
menuList = sysMenuService.getMenuListByUserId(user.getUserId());
|
||||
List<String> permCodeList = sysPermCodeService.getPermCodeListByUserId(user.getUserId());
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
menuList = sysMenuService.getMenuListByUserId(tokenData.getUserId());
|
||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(user.getUserId());
|
||||
// 将白名单url列表合并到当前用户的权限资源列表中,便于网关一并处理。
|
||||
Set<String> permSet = sysUserService.getSysPermSetByUserId(user.getUserId());
|
||||
permSet.addAll(sysPermWhitelistService.getWhitelistPermList());
|
||||
jsonData.put("permSet", permSet);
|
||||
Collection<String> permList = sysPermService.getPermListByUserId(user.getUserId());
|
||||
permList.addAll(sysPermWhitelistService.getWhitelistPermList());
|
||||
jsonData.put("permSet", permList);
|
||||
}
|
||||
jsonData.put("menuList", menuList);
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
return jsonData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ public class SysMenuController {
|
||||
*
|
||||
* @return 应答结果对象,包含全部菜单数据列表。
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<List<SysMenuVo>> list() {
|
||||
List<SysMenu> sysMenuList = sysMenuService.getAllListByOrder("menuType", "showOrder");
|
||||
Collection<SysMenu> sysMenuList = sysMenuService.getAllListByOrder("showOrder");
|
||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(sysMenuList, SysMenuVo.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class SysPermModuleController {
|
||||
*
|
||||
* @return 应答结果对象,包含权限资源模块列表。
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<List<SysPermModuleVo>> list() {
|
||||
List<SysPermModule> permModuleList = sysPermModuleService.getAllListByOrder("showOrder");
|
||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(permModuleList, SysPermModuleVo.class));
|
||||
@@ -133,7 +133,7 @@ public class SysPermModuleController {
|
||||
*
|
||||
* @return 应答结果对象,包含树状列表,
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
@PostMapping("/listAll")
|
||||
public ResponseResult<List<Map<String, Object>>> listAll() {
|
||||
List<SysPermModule> sysPermModuleList = sysPermModuleService.getPermModuleAndPermList();
|
||||
List<Map<String, Object>> resultList = new LinkedList<>();
|
||||
|
||||
@@ -292,7 +292,7 @@ public class SysRoleController {
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface SysPermMapper extends BaseDaoMapper<SysPerm> {
|
||||
* @param userId 用户Id。
|
||||
* @return 该用户的权限标识列表。
|
||||
*/
|
||||
List<SysPerm> getPermListByUserId(@Param("userId") Long userId);
|
||||
List<String> getPermListByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
||||
@@ -51,5 +51,5 @@ public interface SysPermMapper extends BaseDaoMapper<SysPerm> {
|
||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
List<Map<String, Object>> getSysMenuListWithDetail(
|
||||
@Param("permId") Long permId, @Param("menuName") String menuName);
|
||||
@Param("permId") Long permId, @Param("menuName") String menuName);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<select id="getMenuListByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
DISTINCT m.*
|
||||
m.*
|
||||
FROM
|
||||
zz_sys_user_role ur,
|
||||
zz_sys_role_menu rm,
|
||||
@@ -83,5 +83,5 @@
|
||||
</where>
|
||||
ORDER BY
|
||||
u.user_id, r.role_id
|
||||
</select>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.upmsservice.dao.SysMenuPermCodeMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.upmsservice.model.SysMenuPermCode">
|
||||
<result column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
||||
<result column="perm_code_id" jdbcType="BIGINT" property="permCodeId"/>
|
||||
<id column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
||||
<id column="perm_code_id" jdbcType="BIGINT" property="permCodeId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<select id="getPermCodeListByUserId" resultType="java.lang.String">
|
||||
SELECT
|
||||
DISTINCT pc.perm_code
|
||||
pc.perm_code
|
||||
FROM
|
||||
zz_sys_user_role ur,
|
||||
zz_sys_role_menu rm,
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getPermListByUserId" resultMap="BaseResultMap">
|
||||
<select id="getPermListByUserId" resultType="java.lang.String">
|
||||
SELECT
|
||||
p.*
|
||||
p.url
|
||||
FROM
|
||||
zz_sys_user_role ur,
|
||||
zz_sys_role_menu rm,
|
||||
@@ -128,5 +128,5 @@
|
||||
</where>
|
||||
ORDER BY
|
||||
m.menu_id, pc.perm_code_id
|
||||
</select>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.upmsservice.dao.SysPermModuleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.upmsservice.model.SysPermModule">
|
||||
<result column="module_id" jdbcType="BIGINT" property="moduleId"/>
|
||||
<id column="module_id" jdbcType="BIGINT" property="moduleId"/>
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
||||
<result column="module_name" jdbcType="VARCHAR" property="moduleName"/>
|
||||
<result column="module_type" jdbcType="INTEGER" property="moduleType"/>
|
||||
@@ -34,9 +34,8 @@
|
||||
FROM
|
||||
zz_sys_perm_module pm
|
||||
LEFT JOIN
|
||||
zz_sys_perm p ON pm.module_id = p.module_id
|
||||
zz_sys_perm p ON pm.module_id = p.module_id AND p.deleted_flag = ${@com.orange.demo.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
<where>
|
||||
AND p.deleted_flag = ${@com.orange.demo.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
AND pm.deleted_flag = ${@com.orange.demo.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
</where>
|
||||
ORDER BY
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
AND zz_sys_user.create_time <= #{sysUserFilter.createTimeEnd}
|
||||
</if>
|
||||
</if>
|
||||
AND zz_sys_user.deleted_flag = ${@com.orange.demo.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
</sql>
|
||||
|
||||
<select id="getSysUserList" resultMap="BaseResultMap" parameterType="com.orange.demo.upmsservice.model.SysUser">
|
||||
@@ -101,7 +100,7 @@
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
||||
<select id="getSysPermListWithDetail" resultType="map">
|
||||
SELECT
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.upmsinterface.vo.SysMenuVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -20,8 +21,9 @@ import java.util.*;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_menu")
|
||||
public class SysMenu {
|
||||
public class SysMenu extends BaseModel {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
@@ -65,34 +67,9 @@ public class SysMenu {
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
@@ -15,8 +16,9 @@ import java.util.*;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_perm")
|
||||
public class SysPerm {
|
||||
public class SysPerm extends BaseModel {
|
||||
|
||||
/**
|
||||
* 权限Id。
|
||||
@@ -48,34 +50,9 @@ public class SysPerm {
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.upmsinterface.vo.SysPermCodeVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -20,8 +21,9 @@ import java.util.*;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_perm_code")
|
||||
public class SysPermCode {
|
||||
public class SysPermCode extends BaseModel {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
@@ -60,34 +62,9 @@ public class SysPermCode {
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
@@ -14,8 +15,9 @@ import java.util.*;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_perm_module")
|
||||
public class SysPermModule {
|
||||
public class SysPermModule extends BaseModel {
|
||||
|
||||
/**
|
||||
* 权限模块Id。
|
||||
@@ -48,34 +50,9 @@ public class SysPermModule {
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.upmsinterface.vo.SysRoleVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -20,8 +21,9 @@ import java.util.*;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_role")
|
||||
public class SysRole {
|
||||
public class SysRole extends BaseModel {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
@@ -36,34 +38,9 @@ public class SysRole {
|
||||
@Column(name = "role_name")
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.orange.demo.upmsservice.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.upmsinterface.constant.SysUserType;
|
||||
import com.orange.demo.upmsinterface.constant.SysUserStatus;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.model.BaseModel;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.upmsinterface.vo.SysUserVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,8 +24,9 @@ import java.util.List;
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "zz_sys_user")
|
||||
public class SysUser {
|
||||
public class SysUser extends BaseModel {
|
||||
|
||||
/**
|
||||
* 用户Id。
|
||||
@@ -72,35 +73,10 @@ public class SysUser {
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@DeletedFlagColumn
|
||||
@Column(name = "deleted_flag")
|
||||
private Integer deletedFlag;
|
||||
|
||||
/**
|
||||
* 创建用户Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
|
||||
@@ -46,15 +46,15 @@ public interface SysMenuService extends IBaseService<SysMenu, Long> {
|
||||
*
|
||||
* @return 全部菜单列表。
|
||||
*/
|
||||
List<SysMenu> getAllMenuList();
|
||||
Collection<SysMenu> getAllMenuList();
|
||||
|
||||
/**
|
||||
* 获取指定用户Id的菜单列表。
|
||||
* 获取指定用户Id的菜单列表,已去重。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的菜单列表。
|
||||
*/
|
||||
List<SysMenu> getMenuListByUserId(Long userId);
|
||||
Collection<SysMenu> getMenuListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 判断当前菜单是否存在子菜单。
|
||||
|
||||
@@ -15,12 +15,19 @@ import java.util.*;
|
||||
public interface SysPermCodeService extends IBaseService<SysPermCode, Long> {
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限字列表。
|
||||
* 获取指定用户的权限字列表,已去重。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的权限字列表。
|
||||
*/
|
||||
List<String> getPermCodeListByUserId(Long userId);
|
||||
Collection<String> getPermCodeListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取所有权限字数据列表,已去重。
|
||||
*
|
||||
* @return 全部权限字列表。
|
||||
*/
|
||||
Collection<String> getAllPermCodeList();
|
||||
|
||||
/**
|
||||
* 保存新增的权限字对象。
|
||||
|
||||
@@ -48,12 +48,12 @@ public interface SysPermService extends IBaseService<SysPerm, Long> {
|
||||
List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter);
|
||||
|
||||
/**
|
||||
* 获取与指定用户关联的权限资源列表。
|
||||
* 获取与指定用户关联的权限资源列表,已去重。
|
||||
*
|
||||
* @param userId 关联的用户主键Id。
|
||||
* @return 与指定用户Id关联的权限资源列表。
|
||||
* @return 与指定用户Id关联的权限资源URL列表。
|
||||
*/
|
||||
List<SysPerm> getPermListByUserId(Long userId);
|
||||
Collection<String> getPermListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 验证权限资源对象关联的数据是否都合法。
|
||||
|
||||
@@ -104,14 +104,6 @@ public interface SysUserService extends IBaseService<SysUser, Long> {
|
||||
<M> List<SysUser> getSysUserListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, SysUser filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限集合。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户权限集合。
|
||||
*/
|
||||
Set<String> getSysPermSetByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取指定角色的用户列表。
|
||||
*
|
||||
|
||||
@@ -10,12 +10,13 @@ import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upmsinterface.constant.SysMenuType;
|
||||
import com.orange.demo.upmsservice.service.SysMenuService;
|
||||
import com.orange.demo.upmsservice.service.SysPermCodeService;
|
||||
import com.orange.demo.upmsservice.dao.SysMenuMapper;
|
||||
import com.orange.demo.upmsservice.dao.SysMenuPermCodeMapper;
|
||||
import com.orange.demo.upmsservice.dao.SysRoleMenuMapper;
|
||||
import com.orange.demo.upmsservice.dao.SysMenuMapper;
|
||||
import com.orange.demo.upmsservice.model.SysMenu;
|
||||
import com.orange.demo.upmsservice.model.SysMenuPermCode;
|
||||
import com.orange.demo.upmsservice.model.SysRoleMenu;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -66,8 +67,8 @@ public class SysMenuServiceImpl extends BaseService<SysMenu, Long> implements Sy
|
||||
@Override
|
||||
public SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet) {
|
||||
sysMenu.setMenuId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(sysMenu);
|
||||
sysMenu.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.fillCommonsForInsert(sysMenu);
|
||||
sysMenuMapper.insert(sysMenu);
|
||||
if (permCodeIdSet != null) {
|
||||
List<SysMenuPermCode> sysMenuPermCodeList = new LinkedList<>();
|
||||
@@ -142,9 +143,9 @@ public class SysMenuServiceImpl extends BaseService<SysMenu, Long> implements Sy
|
||||
* @return 全部菜单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> getAllMenuList() {
|
||||
public Collection<SysMenu> getAllMenuList() {
|
||||
Example e = new Example(SysMenu.class);
|
||||
e.orderBy("menuType").orderBy("showOrder");
|
||||
e.orderBy("showOrder");
|
||||
Example.Criteria c = e.createCriteria();
|
||||
c.andIn("menuType", Arrays.asList(SysMenuType.TYPE_MENU, SysMenuType.TYPE_DIRECTORY));
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
@@ -152,14 +153,19 @@ public class SysMenuServiceImpl extends BaseService<SysMenu, Long> implements Sy
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户Id的菜单列表。
|
||||
* 获取指定用户Id的菜单列表,已去重。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的菜单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> getMenuListByUserId(Long userId) {
|
||||
return sysMenuMapper.getMenuListByUserId(userId);
|
||||
public Collection<SysMenu> getMenuListByUserId(Long userId) {
|
||||
List<SysMenu> menuList = sysMenuMapper.getMenuListByUserId(userId);
|
||||
LinkedHashMap<Long, SysMenu> menuMap = new LinkedHashMap<>();
|
||||
for (SysMenu menu : menuList) {
|
||||
menuMap.put(menu.getMenuId(), menu);
|
||||
}
|
||||
return menuMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,14 +54,26 @@ public class SysPermCodeServiceImpl extends BaseService<SysPermCode, Long> imple
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限字列表。
|
||||
* 获取指定用户的权限字列表,已去重。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的权限字列表。
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermCodeListByUserId(Long userId) {
|
||||
return sysPermCodeMapper.getPermCodeListByUserId(userId);
|
||||
public Collection<String> getPermCodeListByUserId(Long userId) {
|
||||
List<String> permCodeList = sysPermCodeMapper.getPermCodeListByUserId(userId);
|
||||
return new HashSet<>(permCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有权限字数据列表,已去重。
|
||||
*
|
||||
* @return 全部权限字列表。
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> getAllPermCodeList() {
|
||||
List<SysPermCode> permCodeList = this.getAllList();
|
||||
return permCodeList.stream().map(SysPermCode::getPermCode).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,8 +87,8 @@ public class SysPermCodeServiceImpl extends BaseService<SysPermCode, Long> imple
|
||||
@Override
|
||||
public SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet) {
|
||||
sysPermCode.setPermCodeId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(sysPermCode);
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.fillCommonsForInsert(sysPermCode);
|
||||
sysPermCodeMapper.insert(sysPermCode);
|
||||
if (permIdSet != null) {
|
||||
List<SysPermCodePerm> sysPermCodePermList = new LinkedList<>();
|
||||
@@ -102,9 +114,9 @@ public class SysPermCodeServiceImpl extends BaseService<SysPermCode, Long> imple
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet) {
|
||||
MyModelUtil.fillCommonsForUpdate(sysPermCode, originalSysPermCode);
|
||||
sysPermCode.setParentId(originalSysPermCode.getParentId());
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.fillCommonsForUpdate(sysPermCode, originalSysPermCode);
|
||||
if (sysPermCodeMapper.updateByPrimaryKey(sysPermCode) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限资源数据服务类。
|
||||
@@ -124,14 +123,15 @@ public class SysPermServiceImpl extends BaseService<SysPerm, Long> implements Sy
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取与指定用户关联的权限资源列表。
|
||||
* 获取与指定用户关联的权限资源列表,已去重。
|
||||
*
|
||||
* @param userId 关联的用户主键Id。
|
||||
* @return 与指定用户Id关联的权限资源列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysPerm> getPermListByUserId(Long userId) {
|
||||
return sysPermMapper.getPermListByUserId(userId);
|
||||
public Collection<String> getPermListByUserId(Long userId) {
|
||||
List<String> urlList = sysPermMapper.getPermListByUserId(userId);
|
||||
return new HashSet<>(urlList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.orange.demo.upmsservice.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
@@ -64,8 +64,8 @@ public class SysRoleServiceImpl extends BaseService<SysRole, Long> implements Sy
|
||||
@Override
|
||||
public SysRole saveNew(SysRole role, Set<Long> menuIdSet) {
|
||||
role.setRoleId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(role);
|
||||
role.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.fillCommonsForInsert(role);
|
||||
sysRoleMapper.insert(role);
|
||||
if (menuIdSet != null) {
|
||||
List<SysRoleMenu> roleMenuList = new LinkedList<>();
|
||||
@@ -91,8 +91,8 @@ public class SysRoleServiceImpl extends BaseService<SysRole, Long> implements Sy
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysRole role, SysRole originalRole, Set<Long> menuIdSet) {
|
||||
MyModelUtil.fillCommonsForUpdate(role, originalRole);
|
||||
role.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.fillCommonsForUpdate(role, originalRole);
|
||||
if (sysRoleMapper.updateByPrimaryKey(role) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ public class SysUserServiceImpl extends BaseService<SysUser, Long> implements Sy
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@@ -62,11 +60,10 @@ public class SysUserServiceImpl extends BaseService<SysUser, Long> implements Sy
|
||||
*/
|
||||
@Override
|
||||
public SysUser getSysUserByLoginName(String loginName) {
|
||||
Example e = new Example(SysUser.class);
|
||||
Example.Criteria c = e.createCriteria();
|
||||
c.andEqualTo("loginName", loginName);
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
return sysUserMapper.selectOneByExample(e);
|
||||
SysUser filter = new SysUser();
|
||||
filter.setLoginName(loginName);
|
||||
filter.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
return sysUserMapper.selectOne(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,18 +234,6 @@ public class SysUserServiceImpl extends BaseService<SysUser, Long> implements Sy
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限集合。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户权限集合。
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSysPermSetByUserId(Long userId) {
|
||||
List<SysPerm> permList = sysPermService.getPermListByUserId(userId);
|
||||
return permList.stream().map(SysPerm::getUrl).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定角色的用户列表。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user