add:
1. 增加用户数据权限查询接口 2. 增加数据权限管理接口 3. 用户类增加数据权限列表属性 4. 数据库增加数据权限表和组织机构与数据权限关系表
正在显示
12 个修改的文件
包含
462 行增加
和
3 行删除
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | </parent> | 11 | </parent> |
| 12 | <groupId>com.tianbo</groupId> | 12 | <groupId>com.tianbo</groupId> |
| 13 | <artifactId>warehouse</artifactId> | 13 | <artifactId>warehouse</artifactId> |
| 14 | - <version>4.0Beta-organization-update</version> | 14 | + <version>5.0Beta-DataPermission</version> |
| 15 | <name>usercenter</name> | 15 | <name>usercenter</name> |
| 16 | <description>usercenter for springcloud</description> | 16 | <description>usercenter for springcloud</description> |
| 17 | 17 |
| @@ -4,7 +4,9 @@ import com.github.pagehelper.PageInfo; | @@ -4,7 +4,9 @@ import com.github.pagehelper.PageInfo; | ||
| 4 | import com.tianbo.warehouse.annotation.LogAnnotation; | 4 | import com.tianbo.warehouse.annotation.LogAnnotation; |
| 5 | import com.tianbo.warehouse.controller.response.ResultJson; | 5 | import com.tianbo.warehouse.controller.response.ResultJson; |
| 6 | import com.tianbo.warehouse.model.PERMISSION; | 6 | import com.tianbo.warehouse.model.PERMISSION; |
| 7 | +import com.tianbo.warehouse.model.USERS; | ||
| 7 | import com.tianbo.warehouse.service.PermissionService; | 8 | import com.tianbo.warehouse.service.PermissionService; |
| 9 | +import com.tianbo.warehouse.service.UserService; | ||
| 8 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
| 9 | import org.apache.ibatis.annotations.Param; | 11 | import org.apache.ibatis.annotations.Param; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -23,6 +25,9 @@ public class PermssionController { | @@ -23,6 +25,9 @@ public class PermssionController { | ||
| 23 | @Autowired | 25 | @Autowired |
| 24 | PermissionService permissionService; | 26 | PermissionService permissionService; |
| 25 | 27 | ||
| 28 | + @Autowired | ||
| 29 | + UserService userService; | ||
| 30 | + | ||
| 26 | @GetMapping("/list") | 31 | @GetMapping("/list") |
| 27 | public PageInfo<PERMISSION> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1") | 32 | public PageInfo<PERMISSION> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1") |
| 28 | int pageNum, | 33 | int pageNum, |
| @@ -135,4 +140,14 @@ public class PermssionController { | @@ -135,4 +140,14 @@ public class PermssionController { | ||
| 135 | return new ResultJson("200","success",result); | 140 | return new ResultJson("200","success",result); |
| 136 | 141 | ||
| 137 | } | 142 | } |
| 143 | + | ||
| 144 | + @GetMapping("/getUserPermByToken") | ||
| 145 | + public ResultJson get( | ||
| 146 | + @RequestHeader("Authorization") String token, | ||
| 147 | + @RequestParam(value = "path") String path | ||
| 148 | + ){ | ||
| 149 | + System.out.println("im in"); | ||
| 150 | + USERS userInfo = userService.getUserDataPermissionsByPath(token, path); | ||
| 151 | + return new ResultJson("200","get user data permissions success",userInfo); | ||
| 152 | + } | ||
| 138 | } | 153 | } |
| 1 | +package com.tianbo.warehouse.dao; | ||
| 2 | + | ||
| 3 | +import com.tianbo.warehouse.model.DataPermission; | ||
| 4 | + | ||
| 5 | +public interface DataPermissionDao { | ||
| 6 | + int deleteByPrimaryKey(Integer data_perm_id); | ||
| 7 | + | ||
| 8 | + int insert(DataPermission record); | ||
| 9 | + | ||
| 10 | + int insertSelective(DataPermission record); | ||
| 11 | + | ||
| 12 | + DataPermission selectByPrimaryKey(Integer data_perm_id); | ||
| 13 | + | ||
| 14 | + int updateByPrimaryKeySelective(DataPermission record); | ||
| 15 | + | ||
| 16 | + int updateByPrimaryKey(DataPermission record); | ||
| 17 | +} |
| @@ -24,4 +24,6 @@ public interface USERSMapper { | @@ -24,4 +24,6 @@ public interface USERSMapper { | ||
| 24 | 24 | ||
| 25 | List<USERS> selectAllUser(USERS users); | 25 | List<USERS> selectAllUser(USERS users); |
| 26 | 26 | ||
| 27 | + USERS getUserDataPermissionsByPath(@Param("userId") Integer userId,@Param("path") String path); | ||
| 28 | + | ||
| 27 | } | 29 | } |
| 1 | +package com.tianbo.warehouse.model; | ||
| 2 | + | ||
| 3 | +import java.io.Serializable; | ||
| 4 | +import java.util.Date; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * data_permission | ||
| 9 | + * @author | ||
| 10 | + */ | ||
| 11 | +@Data | ||
| 12 | +public class DataPermission implements Serializable { | ||
| 13 | + private Integer data_perm_id; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 数据权限名称 | ||
| 17 | + */ | ||
| 18 | + private String perm_name; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 数据权限描述 | ||
| 22 | + */ | ||
| 23 | + private String perm_des; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 权限排序 | ||
| 27 | + */ | ||
| 28 | + private Byte perm_sort; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 权限禁用状态 - 0 不禁用 / 1 禁用 | ||
| 32 | + */ | ||
| 33 | + private Boolean perm_status; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 创建时间 | ||
| 37 | + */ | ||
| 38 | + private Date create_time; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 更新时间 | ||
| 42 | + */ | ||
| 43 | + private Date update_time; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 创建人id/名称 | ||
| 47 | + */ | ||
| 48 | + private String create_user; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 条件行冗余,数组转字符串orJson字符串 | ||
| 52 | +可以为* ,代表所有行 | ||
| 53 | + */ | ||
| 54 | + private String row_condition; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 行条件对应的实体类名 | ||
| 58 | + */ | ||
| 59 | + private String row_condition_property; | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 条件列冗余,数组转字符串orJson字符串 | ||
| 63 | +可以为* 代表所有列 | ||
| 64 | + */ | ||
| 65 | + private String cols_list; | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 对应访问权限id | ||
| 69 | + */ | ||
| 70 | + private Integer permission_id; | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 对应接口访问地址 | ||
| 74 | + */ | ||
| 75 | + private String path; | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 接口名称冗余 | ||
| 79 | + */ | ||
| 80 | + private String interface_name; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 涉及微服务名称冗余 | ||
| 84 | + */ | ||
| 85 | + private String service_name; | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 涉及微服务描述 | ||
| 89 | + */ | ||
| 90 | + private String service_name_des; | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 关键字 | ||
| 94 | + */ | ||
| 95 | + private String perm_keyword; | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 权限类别-row:行权限,col:列权限 | ||
| 99 | + */ | ||
| 100 | + private String perm_type; | ||
| 101 | + | ||
| 102 | + private static final long serialVersionUID = 1L; | ||
| 103 | +} |
| @@ -70,6 +70,9 @@ public class USERS implements UserDetails { | @@ -70,6 +70,9 @@ public class USERS implements UserDetails { | ||
| 70 | @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) | 70 | @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) |
| 71 | private List<PERMISSION> permissions; | 71 | private List<PERMISSION> permissions; |
| 72 | 72 | ||
| 73 | + @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) | ||
| 74 | + private List<DataPermission> dataPermissions; | ||
| 75 | + | ||
| 73 | public Integer getUserId() { | 76 | public Integer getUserId() { |
| 74 | return userId; | 77 | return userId; |
| 75 | } | 78 | } |
| @@ -200,6 +203,14 @@ public class USERS implements UserDetails { | @@ -200,6 +203,14 @@ public class USERS implements UserDetails { | ||
| 200 | this.permissions = permissions; | 203 | this.permissions = permissions; |
| 201 | } | 204 | } |
| 202 | 205 | ||
| 206 | + public List<DataPermission> getDataPermissions() { | ||
| 207 | + return dataPermissions; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + public void setDataPermissions(List<DataPermission> dataPermissions) { | ||
| 211 | + this.dataPermissions = dataPermissions; | ||
| 212 | + } | ||
| 213 | + | ||
| 203 | public String getToken() { | 214 | public String getToken() { |
| 204 | return token; | 215 | return token; |
| 205 | } | 216 | } |
| @@ -23,4 +23,6 @@ public interface UserService { | @@ -23,4 +23,6 @@ public interface UserService { | ||
| 23 | ROLE getUserCompany(Integer company_id); | 23 | ROLE getUserCompany(Integer company_id); |
| 24 | 24 | ||
| 25 | USERS selectByUserId(Integer userid); | 25 | USERS selectByUserId(Integer userid); |
| 26 | + | ||
| 27 | + USERS getUserDataPermissionsByPath(String token,String path); | ||
| 26 | } | 28 | } |
| 1 | package com.tianbo.warehouse.service.imp; | 1 | package com.tianbo.warehouse.service.imp; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 3 | import com.github.pagehelper.Page; | 4 | import com.github.pagehelper.Page; |
| 4 | import com.github.pagehelper.PageHelper; | 5 | import com.github.pagehelper.PageHelper; |
| 5 | import com.github.pagehelper.PageInfo; | 6 | import com.github.pagehelper.PageInfo; |
| @@ -14,6 +15,8 @@ import com.tianbo.warehouse.model.USERS; | @@ -14,6 +15,8 @@ import com.tianbo.warehouse.model.USERS; | ||
| 14 | import com.tianbo.warehouse.model.UserRole; | 15 | import com.tianbo.warehouse.model.UserRole; |
| 15 | import com.tianbo.warehouse.service.PermissionService; | 16 | import com.tianbo.warehouse.service.PermissionService; |
| 16 | import com.tianbo.warehouse.service.UserService; | 17 | import com.tianbo.warehouse.service.UserService; |
| 18 | +import com.tianbo.warehouse.util.RedisUtils; | ||
| 19 | +import org.apache.commons.lang.StringUtils; | ||
| 17 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 19 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
| @@ -42,6 +45,9 @@ public class UserServiceImpl implements UserService{ | @@ -42,6 +45,9 @@ public class UserServiceImpl implements UserService{ | ||
| 42 | @Autowired | 45 | @Autowired |
| 43 | private PermissionService permissionService; | 46 | private PermissionService permissionService; |
| 44 | 47 | ||
| 48 | + @Autowired | ||
| 49 | + RedisUtils redisUtils; | ||
| 50 | + | ||
| 45 | @Override | 51 | @Override |
| 46 | public USERS loadByUsername(String username){ | 52 | public USERS loadByUsername(String username){ |
| 47 | List<USERS> userList = usersMapper.selectByUsername(username); | 53 | List<USERS> userList = usersMapper.selectByUsername(username); |
| @@ -188,8 +194,26 @@ public class UserServiceImpl implements UserService{ | @@ -188,8 +194,26 @@ public class UserServiceImpl implements UserService{ | ||
| 188 | } | 194 | } |
| 189 | 195 | ||
| 190 | @Override | 196 | @Override |
| 191 | - public USERS selectByUserId(Integer userid){ | 197 | + public USERS selectByUserId(Integer userid){ |
| 192 | return usersMapper.selectByPrimaryKey(userid); | 198 | return usersMapper.selectByPrimaryKey(userid); |
| 193 | } | 199 | } |
| 194 | 200 | ||
| 201 | + @Override | ||
| 202 | + public USERS getUserDataPermissionsByPath(String token,String path){ | ||
| 203 | + USERS userinfo = new USERS(); | ||
| 204 | + try { | ||
| 205 | + if(token != null && token.startsWith("Bearer ")) { | ||
| 206 | + token = token.substring(7); // 7 是 "Bearer " 的长度 | ||
| 207 | + String userJsonStr = redisUtils.get(token); | ||
| 208 | + if (StringUtils.isNotEmpty(userJsonStr)) { | ||
| 209 | + USERS user = JSONObject.parseObject(userJsonStr, USERS.class); | ||
| 210 | + userinfo = usersMapper.getUserDataPermissionsByPath(user.getUserId(),path); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + }catch (Exception e){ | ||
| 214 | + e.printStackTrace(); | ||
| 215 | + } | ||
| 216 | + return userinfo; | ||
| 217 | + } | ||
| 218 | + | ||
| 195 | } | 219 | } |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="com.tianbo.warehouse.dao.DataPermissionDao"> | ||
| 4 | + <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.DataPermission"> | ||
| 5 | + <id column="data_perm_id" jdbcType="INTEGER" property="data_perm_id" /> | ||
| 6 | + <result column="perm_name" jdbcType="VARCHAR" property="perm_name" /> | ||
| 7 | + <result column="perm_des" jdbcType="VARCHAR" property="perm_des" /> | ||
| 8 | + <result column="perm_sort" jdbcType="TINYINT" property="perm_sort" /> | ||
| 9 | + <result column="perm_status" jdbcType="BOOLEAN" property="perm_status" /> | ||
| 10 | + <result column="create_time" jdbcType="TIMESTAMP" property="create_time" /> | ||
| 11 | + <result column="update_time" jdbcType="TIMESTAMP" property="update_time" /> | ||
| 12 | + <result column="create_user" jdbcType="VARCHAR" property="create_user" /> | ||
| 13 | + <result column="row_condition" jdbcType="VARCHAR" property="row_condition" /> | ||
| 14 | + <result column="row_condition_property" jdbcType="VARCHAR" property="row_condition_property" /> | ||
| 15 | + <result column="cols_list" jdbcType="VARCHAR" property="cols_list" /> | ||
| 16 | + <result column="permission_id" jdbcType="INTEGER" property="permission_id" /> | ||
| 17 | + <result column="path" jdbcType="VARCHAR" property="path" /> | ||
| 18 | + <result column="interface_name" jdbcType="VARCHAR" property="interface_name" /> | ||
| 19 | + <result column="service_name" jdbcType="VARCHAR" property="service_name" /> | ||
| 20 | + <result column="service_name_des" jdbcType="VARCHAR" property="service_name_des" /> | ||
| 21 | + <result column="perm_keyword" jdbcType="VARCHAR" property="perm_keyword" /> | ||
| 22 | + <result column="perm_type" jdbcType="VARCHAR" property="perm_type" /> | ||
| 23 | + </resultMap> | ||
| 24 | + <sql id="Base_Column_List"> | ||
| 25 | + data_perm_id, perm_name, perm_des, perm_sort, perm_status, create_time, update_time, | ||
| 26 | + create_user, row_condition, row_condition_property, cols_list, permission_id, `path`, | ||
| 27 | + interface_name, service_name, service_name_des, perm_keyword, perm_type | ||
| 28 | + </sql> | ||
| 29 | + <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | ||
| 30 | + select | ||
| 31 | + <include refid="Base_Column_List" /> | ||
| 32 | + from data_permission | ||
| 33 | + where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | ||
| 34 | + </select> | ||
| 35 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | ||
| 36 | + delete from data_permission | ||
| 37 | + where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | ||
| 38 | + </delete> | ||
| 39 | + <insert id="insert" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> | ||
| 40 | + insert into data_permission (perm_name, perm_des, perm_sort, | ||
| 41 | + perm_status, create_time, update_time, | ||
| 42 | + create_user, row_condition, row_condition_property, | ||
| 43 | + cols_list, permission_id, `path`, | ||
| 44 | + interface_name, service_name, service_name_des, | ||
| 45 | + perm_keyword, perm_type) | ||
| 46 | + values (#{perm_name,jdbcType=VARCHAR}, #{perm_des,jdbcType=VARCHAR}, #{perm_sort,jdbcType=TINYINT}, | ||
| 47 | + #{perm_status,jdbcType=BOOLEAN}, #{create_time,jdbcType=TIMESTAMP}, #{update_time,jdbcType=TIMESTAMP}, | ||
| 48 | + #{create_user,jdbcType=VARCHAR}, #{row_condition,jdbcType=VARCHAR}, #{row_condition_property,jdbcType=VARCHAR}, | ||
| 49 | + #{cols_list,jdbcType=VARCHAR}, #{permission_id,jdbcType=INTEGER}, #{path,jdbcType=VARCHAR}, | ||
| 50 | + #{interface_name,jdbcType=VARCHAR}, #{service_name,jdbcType=VARCHAR}, #{service_name_des,jdbcType=VARCHAR}, | ||
| 51 | + #{perm_keyword,jdbcType=VARCHAR}, #{perm_type,jdbcType=VARCHAR}) | ||
| 52 | + </insert> | ||
| 53 | + <insert id="insertSelective" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> | ||
| 54 | + insert into data_permission | ||
| 55 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 56 | + <if test="perm_name != null"> | ||
| 57 | + perm_name, | ||
| 58 | + </if> | ||
| 59 | + <if test="perm_des != null"> | ||
| 60 | + perm_des, | ||
| 61 | + </if> | ||
| 62 | + <if test="perm_sort != null"> | ||
| 63 | + perm_sort, | ||
| 64 | + </if> | ||
| 65 | + <if test="perm_status != null"> | ||
| 66 | + perm_status, | ||
| 67 | + </if> | ||
| 68 | + <if test="create_time != null"> | ||
| 69 | + create_time, | ||
| 70 | + </if> | ||
| 71 | + <if test="update_time != null"> | ||
| 72 | + update_time, | ||
| 73 | + </if> | ||
| 74 | + <if test="create_user != null"> | ||
| 75 | + create_user, | ||
| 76 | + </if> | ||
| 77 | + <if test="row_condition != null"> | ||
| 78 | + row_condition, | ||
| 79 | + </if> | ||
| 80 | + <if test="row_condition_property != null"> | ||
| 81 | + row_condition_property, | ||
| 82 | + </if> | ||
| 83 | + <if test="cols_list != null"> | ||
| 84 | + cols_list, | ||
| 85 | + </if> | ||
| 86 | + <if test="permission_id != null"> | ||
| 87 | + permission_id, | ||
| 88 | + </if> | ||
| 89 | + <if test="path != null"> | ||
| 90 | + `path`, | ||
| 91 | + </if> | ||
| 92 | + <if test="interface_name != null"> | ||
| 93 | + interface_name, | ||
| 94 | + </if> | ||
| 95 | + <if test="service_name != null"> | ||
| 96 | + service_name, | ||
| 97 | + </if> | ||
| 98 | + <if test="service_name_des != null"> | ||
| 99 | + service_name_des, | ||
| 100 | + </if> | ||
| 101 | + <if test="perm_keyword != null"> | ||
| 102 | + perm_keyword, | ||
| 103 | + </if> | ||
| 104 | + <if test="perm_type != null"> | ||
| 105 | + perm_type, | ||
| 106 | + </if> | ||
| 107 | + </trim> | ||
| 108 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 109 | + <if test="perm_name != null"> | ||
| 110 | + #{perm_name,jdbcType=VARCHAR}, | ||
| 111 | + </if> | ||
| 112 | + <if test="perm_des != null"> | ||
| 113 | + #{perm_des,jdbcType=VARCHAR}, | ||
| 114 | + </if> | ||
| 115 | + <if test="perm_sort != null"> | ||
| 116 | + #{perm_sort,jdbcType=TINYINT}, | ||
| 117 | + </if> | ||
| 118 | + <if test="perm_status != null"> | ||
| 119 | + #{perm_status,jdbcType=BOOLEAN}, | ||
| 120 | + </if> | ||
| 121 | + <if test="create_time != null"> | ||
| 122 | + #{create_time,jdbcType=TIMESTAMP}, | ||
| 123 | + </if> | ||
| 124 | + <if test="update_time != null"> | ||
| 125 | + #{update_time,jdbcType=TIMESTAMP}, | ||
| 126 | + </if> | ||
| 127 | + <if test="create_user != null"> | ||
| 128 | + #{create_user,jdbcType=VARCHAR}, | ||
| 129 | + </if> | ||
| 130 | + <if test="row_condition != null"> | ||
| 131 | + #{row_condition,jdbcType=VARCHAR}, | ||
| 132 | + </if> | ||
| 133 | + <if test="row_condition_property != null"> | ||
| 134 | + #{row_condition_property,jdbcType=VARCHAR}, | ||
| 135 | + </if> | ||
| 136 | + <if test="cols_list != null"> | ||
| 137 | + #{cols_list,jdbcType=VARCHAR}, | ||
| 138 | + </if> | ||
| 139 | + <if test="permission_id != null"> | ||
| 140 | + #{permission_id,jdbcType=INTEGER}, | ||
| 141 | + </if> | ||
| 142 | + <if test="path != null"> | ||
| 143 | + #{path,jdbcType=VARCHAR}, | ||
| 144 | + </if> | ||
| 145 | + <if test="interface_name != null"> | ||
| 146 | + #{interface_name,jdbcType=VARCHAR}, | ||
| 147 | + </if> | ||
| 148 | + <if test="service_name != null"> | ||
| 149 | + #{service_name,jdbcType=VARCHAR}, | ||
| 150 | + </if> | ||
| 151 | + <if test="service_name_des != null"> | ||
| 152 | + #{service_name_des,jdbcType=VARCHAR}, | ||
| 153 | + </if> | ||
| 154 | + <if test="perm_keyword != null"> | ||
| 155 | + #{perm_keyword,jdbcType=VARCHAR}, | ||
| 156 | + </if> | ||
| 157 | + <if test="perm_type != null"> | ||
| 158 | + #{perm_type,jdbcType=VARCHAR}, | ||
| 159 | + </if> | ||
| 160 | + </trim> | ||
| 161 | + </insert> | ||
| 162 | + <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.DataPermission"> | ||
| 163 | + update data_permission | ||
| 164 | + <set> | ||
| 165 | + <if test="perm_name != null"> | ||
| 166 | + perm_name = #{perm_name,jdbcType=VARCHAR}, | ||
| 167 | + </if> | ||
| 168 | + <if test="perm_des != null"> | ||
| 169 | + perm_des = #{perm_des,jdbcType=VARCHAR}, | ||
| 170 | + </if> | ||
| 171 | + <if test="perm_sort != null"> | ||
| 172 | + perm_sort = #{perm_sort,jdbcType=TINYINT}, | ||
| 173 | + </if> | ||
| 174 | + <if test="perm_status != null"> | ||
| 175 | + perm_status = #{perm_status,jdbcType=BOOLEAN}, | ||
| 176 | + </if> | ||
| 177 | + <if test="create_time != null"> | ||
| 178 | + create_time = #{create_time,jdbcType=TIMESTAMP}, | ||
| 179 | + </if> | ||
| 180 | + <if test="update_time != null"> | ||
| 181 | + update_time = #{update_time,jdbcType=TIMESTAMP}, | ||
| 182 | + </if> | ||
| 183 | + <if test="create_user != null"> | ||
| 184 | + create_user = #{create_user,jdbcType=VARCHAR}, | ||
| 185 | + </if> | ||
| 186 | + <if test="row_condition != null"> | ||
| 187 | + row_condition = #{row_condition,jdbcType=VARCHAR}, | ||
| 188 | + </if> | ||
| 189 | + <if test="row_condition_property != null"> | ||
| 190 | + row_condition_property = #{row_condition_property,jdbcType=VARCHAR}, | ||
| 191 | + </if> | ||
| 192 | + <if test="cols_list != null"> | ||
| 193 | + cols_list = #{cols_list,jdbcType=VARCHAR}, | ||
| 194 | + </if> | ||
| 195 | + <if test="permission_id != null"> | ||
| 196 | + permission_id = #{permission_id,jdbcType=INTEGER}, | ||
| 197 | + </if> | ||
| 198 | + <if test="path != null"> | ||
| 199 | + `path` = #{path,jdbcType=VARCHAR}, | ||
| 200 | + </if> | ||
| 201 | + <if test="interface_name != null"> | ||
| 202 | + interface_name = #{interface_name,jdbcType=VARCHAR}, | ||
| 203 | + </if> | ||
| 204 | + <if test="service_name != null"> | ||
| 205 | + service_name = #{service_name,jdbcType=VARCHAR}, | ||
| 206 | + </if> | ||
| 207 | + <if test="service_name_des != null"> | ||
| 208 | + service_name_des = #{service_name_des,jdbcType=VARCHAR}, | ||
| 209 | + </if> | ||
| 210 | + <if test="perm_keyword != null"> | ||
| 211 | + perm_keyword = #{perm_keyword,jdbcType=VARCHAR}, | ||
| 212 | + </if> | ||
| 213 | + <if test="perm_type != null"> | ||
| 214 | + perm_type = #{perm_type,jdbcType=VARCHAR}, | ||
| 215 | + </if> | ||
| 216 | + </set> | ||
| 217 | + where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | ||
| 218 | + </update> | ||
| 219 | + <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.DataPermission"> | ||
| 220 | + update data_permission | ||
| 221 | + set perm_name = #{perm_name,jdbcType=VARCHAR}, | ||
| 222 | + perm_des = #{perm_des,jdbcType=VARCHAR}, | ||
| 223 | + perm_sort = #{perm_sort,jdbcType=TINYINT}, | ||
| 224 | + perm_status = #{perm_status,jdbcType=BOOLEAN}, | ||
| 225 | + create_time = #{create_time,jdbcType=TIMESTAMP}, | ||
| 226 | + update_time = #{update_time,jdbcType=TIMESTAMP}, | ||
| 227 | + create_user = #{create_user,jdbcType=VARCHAR}, | ||
| 228 | + row_condition = #{row_condition,jdbcType=VARCHAR}, | ||
| 229 | + row_condition_property = #{row_condition_property,jdbcType=VARCHAR}, | ||
| 230 | + cols_list = #{cols_list,jdbcType=VARCHAR}, | ||
| 231 | + permission_id = #{permission_id,jdbcType=INTEGER}, | ||
| 232 | + `path` = #{path,jdbcType=VARCHAR}, | ||
| 233 | + interface_name = #{interface_name,jdbcType=VARCHAR}, | ||
| 234 | + service_name = #{service_name,jdbcType=VARCHAR}, | ||
| 235 | + service_name_des = #{service_name_des,jdbcType=VARCHAR}, | ||
| 236 | + perm_keyword = #{perm_keyword,jdbcType=VARCHAR}, | ||
| 237 | + perm_type = #{perm_type,jdbcType=VARCHAR} | ||
| 238 | + where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | ||
| 239 | + </update> | ||
| 240 | +</mapper> |
| @@ -76,6 +76,30 @@ | @@ -76,6 +76,30 @@ | ||
| 76 | <result column="component" property="component" jdbcType="VARCHAR" /> | 76 | <result column="component" property="component" jdbcType="VARCHAR" /> |
| 77 | </collection> | 77 | </collection> |
| 78 | </resultMap> | 78 | </resultMap> |
| 79 | + | ||
| 80 | + <resultMap id="DataPermissionResultMap" type="com.tianbo.warehouse.model.USERS" extends="BaseResultMap"> | ||
| 81 | + <result column="role_id" property="companyId" jdbcType="INTEGER" /> | ||
| 82 | + <result column="role_name" property="companyName" jdbcType="VARCHAR" /> | ||
| 83 | + <collection property="dataPermissions" javaType="java.util.ArrayList" ofType="com.tianbo.warehouse.model.DataPermission"> | ||
| 84 | + <id column="data_perm_id" jdbcType="INTEGER" property="data_perm_id" /> | ||
| 85 | + <result column="perm_name" jdbcType="VARCHAR" property="perm_name" /> | ||
| 86 | + <result column="perm_des" jdbcType="VARCHAR" property="perm_des" /> | ||
| 87 | + <result column="perm_sort" jdbcType="TINYINT" property="perm_sort" /> | ||
| 88 | + <result column="perm_status" jdbcType="BOOLEAN" property="perm_status" /> | ||
| 89 | + <result column="row_condition" jdbcType="VARCHAR" property="row_condition" /> | ||
| 90 | + <result column="row_condition_property" jdbcType="VARCHAR" property="row_condition_property" /> | ||
| 91 | + <result column="cols_list" jdbcType="VARCHAR" property="cols_list" /> | ||
| 92 | + <result column="permission_id" jdbcType="INTEGER" property="permission_id" /> | ||
| 93 | + <result column="path" jdbcType="VARCHAR" property="path" /> | ||
| 94 | + <result column="perm_type" jdbcType="VARCHAR" property="perm_type" /> | ||
| 95 | + </collection> | ||
| 96 | + </resultMap> | ||
| 97 | + <sql id="Data_Perm_List"> | ||
| 98 | + u.user_id,u.username,r.role_name,r.role_id,dp.data_perm_id,dp.perm_name,dp.perm_des, | ||
| 99 | + dp.perm_sort,dp.perm_status,dp.row_condition,dp.row_condition_property,dp.cols_list, | ||
| 100 | + dp.path,dp.perm_type | ||
| 101 | + </sql> | ||
| 102 | + | ||
| 79 | <sql id="Base_Column_List" > | 103 | <sql id="Base_Column_List" > |
| 80 | user_id, username, password, birthday, sex, address, state, mobilePhone, creatTime, | 104 | user_id, username, password, birthday, sex, address, state, mobilePhone, creatTime, |
| 81 | updateTime, userFace, realName, email, age,company_id | 105 | updateTime, userFace, realName, email, age,company_id |
| @@ -327,4 +351,18 @@ | @@ -327,4 +351,18 @@ | ||
| 327 | age = #{age,jdbcType=INTEGER} | 351 | age = #{age,jdbcType=INTEGER} |
| 328 | where user_id = #{userId,jdbcType=INTEGER} | 352 | where user_id = #{userId,jdbcType=INTEGER} |
| 329 | </update> | 353 | </update> |
| 354 | + | ||
| 355 | + <select id="getUserDataPermissionsByPath" resultMap="DataPermissionResultMap" > | ||
| 356 | + select | ||
| 357 | + <include refid="Data_Perm_List" /> | ||
| 358 | + from | ||
| 359 | + users u | ||
| 360 | + LEFT JOIN user_role ur ON u.user_id = ur.user_id | ||
| 361 | + LEFT JOIN role r ON ur.role_id = r.role_id | ||
| 362 | + LEFT JOIN role_data_permission rdp ON r.role_id = rdp.role_id | ||
| 363 | + LEFT JOIN data_permission dp ON rdp.permission_id = dp.data_perm_id | ||
| 364 | + where u.user_id = #{userId,jdbcType=INTEGER} | ||
| 365 | + and path = #{path,jdbcType=VARCHAR} | ||
| 366 | + and dp.perm_status = 0 | ||
| 367 | + </select> | ||
| 330 | </mapper> | 368 | </mapper> |
-
请 注册 或 登录 后发表评论