| | |
| | | import javax.validation.constraints.*;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.fasterxml.jackson.annotation.JsonProperty;
|
| | | import com.ruoyi.common.core.annotation.Excel;
|
| | | import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.annotation.Excel.Type;
|
| | |
| | | this.avatar = avatar;
|
| | | }
|
| | |
|
| | | @JsonProperty
|
| | | public String getPassword()
|
| | | {
|
| | | return password;
|
| | |
| | | import java.nio.charset.Charset;
|
| | | import org.springframework.data.redis.serializer.RedisSerializer;
|
| | | import org.springframework.data.redis.serializer.SerializationException;
|
| | | import org.springframework.util.Assert;
|
| | | import com.alibaba.fastjson2.JSON;
|
| | | import com.alibaba.fastjson2.JSONReader;
|
| | | import com.alibaba.fastjson2.JSONWriter;
|
| | | import com.fasterxml.jackson.databind.JavaType;
|
| | | import com.fasterxml.jackson.databind.ObjectMapper;
|
| | | import com.fasterxml.jackson.databind.type.TypeFactory;
|
| | |
|
| | | /**
|
| | | * Redis使用FastJson序列化
|
| | |
| | | */
|
| | | public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
| | | {
|
| | | @SuppressWarnings("unused")
|
| | | private ObjectMapper objectMapper = new ObjectMapper();
|
| | |
|
| | | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
| | |
|
| | | private Class<T> clazz;
|
| | |
| | | String str = new String(bytes, DEFAULT_CHARSET);
|
| | |
|
| | | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
| | | }
|
| | |
|
| | | public void setObjectMapper(ObjectMapper objectMapper)
|
| | | {
|
| | | Assert.notNull(objectMapper, "'objectMapper' must not be null");
|
| | | this.objectMapper = objectMapper;
|
| | | }
|
| | |
|
| | | protected JavaType getJavaType(Class<?> clazz)
|
| | | {
|
| | | return TypeFactory.defaultInstance().constructType(clazz);
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.data.redis.serializer.StringRedisSerializer;
|
| | | import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
| | | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
| | | import com.fasterxml.jackson.annotation.PropertyAccessor;
|
| | | import com.fasterxml.jackson.databind.ObjectMapper;
|
| | | import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
| | |
|
| | | /**
|
| | | * redis配置
|
| | |
| | | template.setConnectionFactory(connectionFactory);
|
| | |
|
| | | FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
| | |
|
| | | ObjectMapper mapper = new ObjectMapper();
|
| | | mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
| | | mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
| | | serializer.setObjectMapper(mapper);
|
| | |
|
| | | // 使用StringRedisSerializer来序列化和反序列化redis的key值
|
| | | template.setKeySerializer(new StringRedisSerializer());
|
| | |
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.List;
|
| | | import com.alibaba.fastjson2.JSONArray;
|
| | | import com.ruoyi.common.core.constant.Constants;
|
| | | import com.ruoyi.common.core.utils.SpringUtils;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | |
| | | */
|
| | | public static List<SysDictData> getDictCache(String key)
|
| | | {
|
| | | Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
| | | if (StringUtils.isNotNull(cacheObj))
|
| | | JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
| | | if (StringUtils.isNotNull(arrayCache))
|
| | | {
|
| | | return StringUtils.cast(cacheObj);
|
| | | return arrayCache.toList(SysDictData.class);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | </sql>
|
| | |
|
| | | <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
| | | left join sys_dept d on u.dept_id = d.dept_id
|
| | | where u.del_flag = '0'
|
| | | <if test="userId != null and userId != 0">
|