role, RedisConfig
This commit is contained in:
parent
0c1fe9ce7a
commit
b6ba543fb7
|
|
@ -42,8 +42,8 @@ public class RedisConfig extends CachingConfigurerSupport
|
|||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
// FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||
RedisSerializer<Object> serializer = new GenericJackson2JsonRedisSerializer(OBJECT_MAPPER);
|
||||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||
// RedisSerializer<Object> serializer = new GenericJackson2JsonRedisSerializer(OBJECT_MAPPER);
|
||||
|
||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
|
|
@ -57,16 +57,16 @@ public class RedisConfig extends CachingConfigurerSupport
|
|||
return template;
|
||||
}
|
||||
|
||||
static {
|
||||
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
OBJECT_MAPPER.registerModule(new JavaTimeModule());
|
||||
OBJECT_MAPPER.registerModule((new SimpleModule()).addSerializer(new StdSerializer<NullValue>(NullValue.class) {
|
||||
public void serialize(NullValue value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||
gen.writeStartObject();
|
||||
gen.writeStringField("@class", NullValue.class.getName());
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}));
|
||||
OBJECT_MAPPER.activateDefaultTyping(OBJECT_MAPPER.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
}
|
||||
// static {
|
||||
// OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
// OBJECT_MAPPER.registerModule(new JavaTimeModule());
|
||||
// OBJECT_MAPPER.registerModule((new SimpleModule()).addSerializer(new StdSerializer<NullValue>(NullValue.class) {
|
||||
// public void serialize(NullValue value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||
// gen.writeStartObject();
|
||||
// gen.writeStringField("@class", NullValue.class.getName());
|
||||
// gen.writeEndObject();
|
||||
// }
|
||||
// }));
|
||||
// OBJECT_MAPPER.activateDefaultTyping(OBJECT_MAPPER.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,14 +81,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
role.setRoleKey(str);
|
||||
}
|
||||
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
List<SysRole> roles = roleMapper.selectRoleList(role);
|
||||
for (SysRole r : roles) {
|
||||
List<String> areaIds = roleMapper.getAreaIdsByRoleId(r.getRoleId());
|
||||
List<String> dataIds = roleMapper.getDataIdsByRoleId(r.getRoleId());
|
||||
r.setAreaIds(areaIds.toArray(new String[areaIds.size()]));
|
||||
r.setDataIds(dataIds.toArray(new String[dataIds.size()]));
|
||||
}
|
||||
return roles;
|
||||
return roleMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,7 +162,12 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
@Override
|
||||
public SysRole selectRoleById(Long roleId)
|
||||
{
|
||||
return roleMapper.selectRoleById(roleId);
|
||||
SysRole role = roleMapper.selectRoleById(roleId);
|
||||
List<String> areaIds = roleMapper.getAreaIdsByRoleId(role.getRoleId());
|
||||
List<String> dataIds = roleMapper.getDataIdsByRoleId(role.getRoleId());
|
||||
role.setAreaIds(areaIds.toArray(new String[areaIds.size()]));
|
||||
role.setDataIds(dataIds.toArray(new String[dataIds.size()]));
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -408,12 +406,13 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
int rows = 1;
|
||||
// 新增角色与区域(数据权限)管理
|
||||
List<SysRoleArea> list = new ArrayList<SysRoleArea>();
|
||||
for (String areaId : role.getAreaIds())
|
||||
{
|
||||
SysRoleArea rd = new SysRoleArea();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setAreaId(areaId);
|
||||
list.add(rd);
|
||||
if (role.getAreaIds() != null && role.getAreaIds().length > 0) {
|
||||
for (String areaId : role.getAreaIds()) {
|
||||
SysRoleArea rd = new SysRoleArea();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setAreaId(areaId);
|
||||
list.add(rd);
|
||||
}
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
|
|
@ -432,12 +431,13 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
int rows = 1;
|
||||
// 新增角色与食堂档口(数据权限)管理
|
||||
List<SysRoleCanteen> list = new ArrayList<SysRoleCanteen>();
|
||||
for (String dataId : role.getDataIds())
|
||||
{
|
||||
SysRoleCanteen rd = new SysRoleCanteen();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDataId(dataId);
|
||||
list.add(rd);
|
||||
if (role.getDataIds() != null && role.getDataIds().length > 0) {
|
||||
for (String dataId : role.getDataIds()) {
|
||||
SysRoleCanteen rd = new SysRoleCanteen();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDataId(dataId);
|
||||
list.add(rd);
|
||||
}
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<include refid="com.bonus.system.mapper.DataScopeMapper.dataScopeFilter"/>
|
||||
order by r.role_sort
|
||||
order by r.role_sort, r.role_id
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
|
|
|
|||
Loading…
Reference in New Issue