forked from luyan/epmet-cloud-lingshan
41 changed files with 640 additions and 990 deletions
@ -0,0 +1,28 @@ |
|||||
|
package com.epmet.commons.mybatis.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
@Data |
||||
|
public class GetSQLFilterFormDTO { |
||||
|
|
||||
|
@NotBlank |
||||
|
private String operationKey; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String userId; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String app; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String client; |
||||
|
|
||||
|
private String tableAlias; |
||||
|
|
||||
|
private String gridId; |
||||
|
|
||||
|
private String departmentId; |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.epmet.commons.tools.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
@Data |
||||
|
public class HasSpecifiedPermissionFormDTO { |
||||
|
|
||||
|
@NotBlank |
||||
|
private String operationKey; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String userId; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String app; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String client; |
||||
|
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
@Data |
||||
|
public class GetSQLFilterFormDTO { |
||||
|
|
||||
|
@NotBlank |
||||
|
private String operationKey; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String userId; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String app; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String client; |
||||
|
|
||||
|
private String tableAlias; |
||||
|
|
||||
|
private String gridId; |
||||
|
|
||||
|
private String departmentId; |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
@Data |
||||
|
public class HasSpecifiedPermissionFormDTO { |
||||
|
|
||||
|
@NotBlank |
||||
|
private String operationKey; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String userId; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String app; |
||||
|
|
||||
|
@NotBlank |
||||
|
private String client; |
||||
|
|
||||
|
} |
@ -1,14 +0,0 @@ |
|||||
package com.epmet.dto.result; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
|
|
||||
@Data |
|
||||
public class AccessConfigSettingResultDTO { |
|
||||
|
|
||||
private String settingKey; |
|
||||
private String settingName; |
|
||||
private String roleId; |
|
||||
private Boolean assigned; |
|
||||
private String operationKey; |
|
||||
|
|
||||
} |
|
@ -0,0 +1,15 @@ |
|||||
|
package com.epmet.bean; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.HashSet; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
@Data |
||||
|
public class OpeScopeFilterResultBean { |
||||
|
|
||||
|
private HashSet<String> orgLevelScopes; |
||||
|
private Set<String> switchScopes; |
||||
|
private boolean allScopes; |
||||
|
|
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.epmet.constant; |
||||
|
|
||||
|
/** |
||||
|
* 操作范围系列常量 |
||||
|
*/ |
||||
|
public class OperationScopeConstant { |
||||
|
|
||||
|
/** |
||||
|
* ===================系列=================== |
||||
|
*/ |
||||
|
public static final String SERIES_ORG_LEVEL = "org_level"; |
||||
|
public static final String SERIES_SWITCH = "switch"; |
||||
|
public static final String SERIES_ALL = "all"; |
||||
|
|
||||
|
/** |
||||
|
* ===================范围=================== |
||||
|
*/ |
||||
|
// 无任何范围限制
|
||||
|
public static final String SCOPE_ALL = "all"; |
||||
|
|
||||
|
// 覆盖机构下的所有范围
|
||||
|
public static final String SCOPE_ORG_ALL = "org_all"; |
||||
|
|
||||
|
//"同级组织的下级"
|
||||
|
public static final String SCOPE_ORG_EQUAL_SUB = "org_equal_sub"; |
||||
|
//"同级组织及下级"
|
||||
|
public static final String SCOPE_ORG_EQUAL_AND_SUB = "org_equal_and_sub"; |
||||
|
// 同级组织的上级
|
||||
|
public static final String SCOPE_ORG_EQUAL_SUP = "org_equal_sup"; |
||||
|
// 同级组织及上级
|
||||
|
public static final String SCOPE_ORG_EQUAL_AND_SUP = "org_equal_and_sup"; |
||||
|
//"同级组织"
|
||||
|
public static final String SCOPE_ORG_EQUAL = "org_equal"; |
||||
|
|
||||
|
//"本组织的下级"
|
||||
|
public static final String SCOPE_ORG_CURR_SUB = "org_curr_sub"; |
||||
|
//"本组织及下级"
|
||||
|
public static final String SCOPE_ORG_CURR_AND_SUB = "org_curr_and_sub"; |
||||
|
//"本组织"
|
||||
|
public static final String SCOPE_ORG_CURR = "org_curr"; |
||||
|
|
||||
|
//我创建的
|
||||
|
public static final String SCOPE_I_CREATED = "i_created"; |
||||
|
//网格内
|
||||
|
public static final String SCOPE_IN_GRID = "in_grid"; |
||||
|
// 部门内
|
||||
|
public static final String SCOPE_IN_DEPARTMENT = "in_department"; |
||||
|
} |
@ -1,75 +0,0 @@ |
|||||
/** |
|
||||
* Copyright 2018 人人开源 https://www.renren.io
|
|
||||
* <p> |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* <p> |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* <p> |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.dao; |
|
||||
|
|
||||
import com.epmet.commons.mybatis.dao.BaseDao; |
|
||||
import com.epmet.dto.result.AccessConfigSettingResultDTO; |
|
||||
import com.epmet.dto.result.AccessSettingResultDTO; |
|
||||
import com.epmet.entity.AccessSettingEntity; |
|
||||
import org.apache.ibatis.annotations.Mapper; |
|
||||
import org.apache.ibatis.annotations.Param; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.Set; |
|
||||
|
|
||||
/** |
|
||||
* 权限配置 |
|
||||
* |
|
||||
* @author generator generator@elink-cn.com |
|
||||
* @since v1.0.0 2020-04-29 |
|
||||
*/ |
|
||||
@Mapper |
|
||||
public interface AccessSettingDao extends BaseDao<AccessSettingEntity> { |
|
||||
|
|
||||
/** |
|
||||
* 根据角色查询配置列表 |
|
||||
* @param roleId |
|
||||
* @return |
|
||||
*/ |
|
||||
List<AccessSettingResultDTO> listAccessSettingsByRoleId(@Param("roleId") String roleId, |
|
||||
@Param("operationKey") String operationKey); |
|
||||
|
|
||||
List<AccessConfigSettingResultDTO> listSettingOptionsForAccessConfig(@Param("roleId") String roleId, |
|
||||
@Param("operationKey") String operationKey); |
|
||||
|
|
||||
/** |
|
||||
* 删除 |
|
||||
* @param roleId |
|
||||
* @param operationKey |
|
||||
* @param settingKeys2Delete |
|
||||
* @return |
|
||||
*/ |
|
||||
int delete(@Param("roleId") String roleId, |
|
||||
@Param("operationKey") String operationKey, |
|
||||
@Param("settingKeys2Delete") Set<String> settingKeys2Delete); |
|
||||
|
|
||||
AccessSettingEntity get(@Param("roleId") String roleId, |
|
||||
@Param("operationKey") String operationKey, |
|
||||
@Param("settingKey") String settingKey); |
|
||||
|
|
||||
/** |
|
||||
* 启用 |
|
||||
* @param roleId |
|
||||
* @param operationKey |
|
||||
* @param settingKey |
|
||||
* @return |
|
||||
*/ |
|
||||
int enable(@Param("roleId") String roleId, |
|
||||
@Param("operationKey") String operationKey, |
|
||||
@Param("settingKey") String settingKey); |
|
||||
} |
|
@ -1,33 +0,0 @@ |
|||||
/** |
|
||||
* Copyright 2018 人人开源 https://www.renren.io
|
|
||||
* <p> |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* <p> |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* <p> |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.dao; |
|
||||
|
|
||||
import com.epmet.commons.mybatis.dao.BaseDao; |
|
||||
import com.epmet.entity.AccessSettingOptionsEntity; |
|
||||
import org.apache.ibatis.annotations.Mapper; |
|
||||
|
|
||||
/** |
|
||||
* 权限配置选项 |
|
||||
* |
|
||||
* @author generator generator@elink-cn.com |
|
||||
* @since v1.0.0 2020-04-29 |
|
||||
*/ |
|
||||
@Mapper |
|
||||
public interface AccessSettingOptionsDao extends BaseDao<AccessSettingOptionsEntity> { |
|
||||
|
|
||||
} |
|
@ -1,61 +0,0 @@ |
|||||
/** |
|
||||
* Copyright 2018 人人开源 https://www.renren.io
|
|
||||
* <p> |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* <p> |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* <p> |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.entity; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
|
||||
|
|
||||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
|
|
||||
import java.util.Date; |
|
||||
|
|
||||
/** |
|
||||
* 权限配置 |
|
||||
* |
|
||||
* @author generator generator@elink-cn.com |
|
||||
* @since v1.0.0 2020-04-29 |
|
||||
*/ |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper=false) |
|
||||
@TableName("access_setting") |
|
||||
public class AccessSettingEntity extends BaseEpmetEntity { |
|
||||
|
|
||||
private static final long serialVersionUID = 1L; |
|
||||
|
|
||||
/** |
|
||||
* 角色ID |
|
||||
*/ |
|
||||
private String roleId; |
|
||||
|
|
||||
/** |
|
||||
* 操作key |
|
||||
*/ |
|
||||
private String operationKey; |
|
||||
|
|
||||
/** |
|
||||
* 配置KEY |
|
||||
*/ |
|
||||
private String settingKey; |
|
||||
|
|
||||
/** |
|
||||
* 配置值 |
|
||||
*/ |
|
||||
private String settingValue; |
|
||||
|
|
||||
} |
|
@ -1,56 +0,0 @@ |
|||||
/** |
|
||||
* Copyright 2018 人人开源 https://www.renren.io
|
|
||||
* <p> |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* <p> |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* <p> |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.entity; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
|
||||
|
|
||||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
|
|
||||
import java.util.Date; |
|
||||
|
|
||||
/** |
|
||||
* 权限配置选项 |
|
||||
* |
|
||||
* @author generator generator@elink-cn.com |
|
||||
* @since v1.0.0 2020-04-29 |
|
||||
*/ |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper=false) |
|
||||
@TableName("access_setting_options") |
|
||||
public class AccessSettingOptionsEntity extends BaseEpmetEntity { |
|
||||
|
|
||||
private static final long serialVersionUID = 1L; |
|
||||
|
|
||||
/** |
|
||||
* 配置KEY |
|
||||
*/ |
|
||||
private String settingKey; |
|
||||
|
|
||||
/** |
|
||||
* 配置name |
|
||||
*/ |
|
||||
private String settingName; |
|
||||
|
|
||||
/** |
|
||||
* 简介 |
|
||||
*/ |
|
||||
private String brief; |
|
||||
|
|
||||
} |
|
@ -1,52 +0,0 @@ |
|||||
package com.epmet.redis; |
|
||||
|
|
||||
import com.epmet.commons.tools.redis.RedisKeys; |
|
||||
import com.epmet.commons.tools.redis.RedisUtils; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
import org.springframework.util.CollectionUtils; |
|
||||
|
|
||||
import java.util.HashMap; |
|
||||
import java.util.Map; |
|
||||
import java.util.Set; |
|
||||
|
|
||||
@Component |
|
||||
public class RoleAccessSettingRedis { |
|
||||
|
|
||||
@Autowired |
|
||||
private RedisUtils redisUtils; |
|
||||
|
|
||||
public void set(Map<String, String> settings, String roleId, String operationKey) { |
|
||||
// 转化Map
|
|
||||
HashMap<String, Object> newSettings = new HashMap<>(); |
|
||||
Set<Map.Entry<String, String>> entries = settings.entrySet(); |
|
||||
entries.forEach(entry -> { |
|
||||
newSettings.put(entry.getKey(), entry.getValue()); |
|
||||
}); |
|
||||
|
|
||||
String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId, operationKey); |
|
||||
redisUtils.hMSet(roleAccessSettingKey, newSettings); |
|
||||
} |
|
||||
|
|
||||
public Map<String, String> get(String roleId, String operationKey) { |
|
||||
String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId, operationKey); |
|
||||
Map<String, Object> s = redisUtils.hGetAll(roleAccessSettingKey); |
|
||||
// 转化Map
|
|
||||
if (!CollectionUtils.isEmpty(s)) { |
|
||||
Map<String, String> settings = new HashMap<>(); |
|
||||
s.forEach((s1, o) -> { |
|
||||
if (o != null) { |
|
||||
settings.put(s1, String.valueOf(o)); |
|
||||
} |
|
||||
}); |
|
||||
return settings; |
|
||||
} |
|
||||
|
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public void delete(String roleId, String operationKey) { |
|
||||
redisUtils.delete(RedisKeys.getRoleAccessSettingKey(roleId, operationKey)); |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,80 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||
|
|
||||
<mapper namespace="com.epmet.dao.AccessSettingDao"> |
|
||||
|
|
||||
<resultMap type="com.epmet.entity.AccessSettingEntity" id="accessSettingMap"> |
|
||||
<result property="id" column="ID"/> |
|
||||
<result property="roleId" column="ROLE_ID"/> |
|
||||
<result property="operationKey" column="OPERATION_KEY"/> |
|
||||
<result property="settingKey" column="SETTING_KEY"/> |
|
||||
<result property="settingValue" column="SETTING_VALUE"/> |
|
||||
<result property="delFlag" column="DEL_FLAG"/> |
|
||||
<result property="revision" column="REVISION"/> |
|
||||
<result property="createdBy" column="CREATED_BY"/> |
|
||||
<result property="createdTime" column="CREATED_TIME"/> |
|
||||
<result property="updatedBy" column="UPDATED_BY"/> |
|
||||
<result property="updatedTime" column="UPDATED_TIME"/> |
|
||||
</resultMap> |
|
||||
|
|
||||
<!--根据角色查询配置列表--> |
|
||||
<select id="listAccessSettingsByRoleId" resultType="com.epmet.dto.result.AccessSettingResultDTO"> |
|
||||
SELECT |
|
||||
s.*, |
|
||||
opt.SETTING_NAME |
|
||||
FROM |
|
||||
access_setting s |
|
||||
INNER JOIN access_setting_options opt ON ( s.SETTING_KEY = opt.SETTING_KEY AND opt.DEL_FLAG = 0) |
|
||||
WHERE |
|
||||
s.ROLE_ID = #{roleId} |
|
||||
AND s.DEL_FLAG = 0 |
|
||||
AND s.OPERATION_KEY = #{operationKey} |
|
||||
AND s.DEL_FLAG = 0 |
|
||||
</select> |
|
||||
|
|
||||
<!--权限配置:列出配置项--> |
|
||||
<select id="listSettingOptionsForAccessConfig" |
|
||||
resultType="com.epmet.dto.result.AccessConfigSettingResultDTO"> |
|
||||
SELECT opt.SETTING_KEY, |
|
||||
opt.SETTING_NAME, |
|
||||
s.ROLE_ID, |
|
||||
CASE |
|
||||
WHEN s.ROLE_ID IS NULL THEN FALSE |
|
||||
ELSE TRUE END AS assigned, |
|
||||
s.OPERATION_KEY |
|
||||
FROM access_setting_options opt |
|
||||
LEFT JOIN access_setting s ON (s.DEL_FLAG = 0 AND opt.SETTING_KEY = s.SETTING_KEY AND s.ROLE_ID = #{roleId} |
|
||||
AND s.OPERATION_KEY = #{operationKey}) |
|
||||
WHERE opt.DEL_FLAG = 0 |
|
||||
ORDER BY opt.SETTING_KEY ASC |
|
||||
</select> |
|
||||
|
|
||||
<!--删除--> |
|
||||
<delete id="delete"> |
|
||||
DELETE |
|
||||
FROM access_setting |
|
||||
WHERE ROLE_ID = #{roleId} |
|
||||
AND OPERATION_KEY = #{operationKey} |
|
||||
AND SETTING_KEY IN |
|
||||
<foreach collection="settingKeys2Delete" item="settingKey" open="(" separator="," close=")"> |
|
||||
#{settingKey} |
|
||||
</foreach> |
|
||||
</delete> |
|
||||
|
|
||||
<select id="get" resultType="com.epmet.entity.AccessSettingEntity"> |
|
||||
SELECT s.* |
|
||||
FROM access_setting s |
|
||||
WHERE s.ROLE_ID = #{roleId} |
|
||||
AND s.OPERATION_KEY = #{operationKey} |
|
||||
AND s.SETTING_KEY = #{settingKey} |
|
||||
</select> |
|
||||
|
|
||||
<!--启用--> |
|
||||
<update id="enable"> |
|
||||
UPDATE access_setting s |
|
||||
SET DEL_FLAG = 0 |
|
||||
WHERE s.ROLE_ID = #{roleId} |
|
||||
AND s.OPERATION_KEY = #{operationKey} |
|
||||
AND s.SETTING_KEY = #{settingKey} |
|
||||
</update> |
|
||||
</mapper> |
|
@ -1,20 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||
|
|
||||
<mapper namespace="com.epmet.dao.AccessSettingOptionsDao"> |
|
||||
|
|
||||
<resultMap type="com.epmet.entity.AccessSettingOptionsEntity" id="accessSettingOptionsMap"> |
|
||||
<result property="id" column="ID"/> |
|
||||
<result property="settingKey" column="SETTING_KEY"/> |
|
||||
<result property="settingName" column="SETTING_NAME"/> |
|
||||
<result property="brief" column="BRIEF"/> |
|
||||
<result property="delFlag" column="DEL_FLAG"/> |
|
||||
<result property="revision" column="REVISION"/> |
|
||||
<result property="createdBy" column="CREATED_BY"/> |
|
||||
<result property="createdTime" column="CREATED_TIME"/> |
|
||||
<result property="updatedBy" column="UPDATED_BY"/> |
|
||||
<result property="updatedTime" column="UPDATED_TIME"/> |
|
||||
</resultMap> |
|
||||
|
|
||||
|
|
||||
</mapper> |
|
@ -1,38 +0,0 @@ |
|||||
package com.epmet.test.govaccess; |
|
||||
|
|
||||
import com.epmet.dao.AccessSettingDao; |
|
||||
import com.epmet.dto.result.AccessSettingResultDTO; |
|
||||
import com.epmet.redis.RoleAccessSettingRedis; |
|
||||
import org.junit.Test; |
|
||||
import org.junit.runner.RunWith; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.boot.test.context.SpringBootTest; |
|
||||
import org.springframework.test.context.junit4.SpringRunner; |
|
||||
|
|
||||
import java.util.HashMap; |
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
@RunWith(SpringRunner.class) |
|
||||
@SpringBootTest |
|
||||
public class AccessSettingTest { |
|
||||
|
|
||||
@Autowired |
|
||||
private AccessSettingDao roleAccessSettingDao; |
|
||||
|
|
||||
@Autowired |
|
||||
private RoleAccessSettingRedis roleAccessSettingRedis; |
|
||||
|
|
||||
@Test |
|
||||
public void addAccessSettings2Redis() { |
|
||||
List<AccessSettingResultDTO> settings = roleAccessSettingDao.listAccessSettingsByRoleId("1", "org_staff_list"); |
|
||||
HashMap<String, String> objectObjectHashMap = new HashMap<>(); |
|
||||
settings.forEach(setting -> { |
|
||||
objectObjectHashMap.put(setting.getSettingKey(), setting.getSettingValue()); |
|
||||
}); |
|
||||
roleAccessSettingRedis.set(objectObjectHashMap, "1", "org_staff_list"); |
|
||||
Map<String, String> map = roleAccessSettingRedis.get("1", "org_staff_list"); |
|
||||
System.out.println(map); |
|
||||
} |
|
||||
|
|
||||
} |
|
Loading…
Reference in new issue