Three Day
1.缓存(1)账户中心缓存Key(2)图书资源缓存Key(3)精品页缓存key(5)缓存操作类2.常量(1)精品页常量类(2)jwt常量类3.图书相关枚举(1)图书分类枚举类(2)书单列表功能枚举类(3)图书连载状态枚举类4.请求参数封装5.统一返回结果(1)Http状态码封装(2)操作结果封装(3)返回结果工具类6.POJOgithub地址:/Zealon159/light-reading-cloud
该模块存放了一些公共的POJO类、工具类等
1.缓存
(1)账户中心缓存Key
public class RedisAccountKey {/** 图书喜欢数缓存(hash) */public final static String ACCOUNT_CENTER_BOOK_LIKES_COUNT = "account-center:book-likes-count";}
(2)图书资源缓存Key
public class RedisBookKey {/** 图书信息缓存 */public static final String getBookKey(String bookId){return String.format("book-center:detail-%s",bookId);}/** 资源中心图书章节缓存 */public static final String getBookChapterKey(String bookId){return String.format("book-center:chapter-%s",bookId);}/** 资源中心图书章节列表缓存 */public static final String getBookChapterListKey(String bookId){return String.format("book-center:chapter-list-%s",bookId);}/** 资源中心图书章节节点缓存 */public static final String getBookChapterNodeKey(Integer bookId){return String.format("book-center:chapter-node-%s",bookId);}/** 图书资源中心feign-client缓存 */public static final class BookCenter {/** 资源中心图书缓存 */public static final String getFeignClientBookKey(String bookId){return String.format("book-center:feign-client-book-%s",bookId);}}}
(3)精品页缓存key
public class RedisHomepageKey {/*** 主页缓存Key* @param type 类型1.主页 2.男生 3.女生* @return*/public static final String getHomepageKey(Integer type){return String.format("home-page:index-%s", type);}/** 主页Banner缓存Key */public static final String getBannerVoKey(Integer bannerId){return String.format("home-page:banner-vo-%s", bannerId);}/** 主页书单DB缓存Key */public static final String getBooklistDbKey(Integer booklistId){return String.format("home-page:booklist-db-%s", booklistId);}/** 主页书单缓存Key */public static final String getBooklistVoKey(Integer booklistId){return String.format("home-page:booklist-vo-%s", booklistId);}/** 主页书单随机缓存Key */public static final String getBooklistRandomVoKey(Integer booklistId){return String.format("home-page:booklist-random-vo-%s", booklistId);}/** 主页书单图书分页更多 */public static final String getBooklistItemPagingKey(Integer booklistId){return String.format("home-page:booklist-item-paging-%s", booklistId);}}
(4)Redis缓存有效时间工具类
/*** Redis 缓存有效时间(单位:秒)*/public class RedisExpire {// 1分钟public static final long MINUTE = 60;// 2分钟 60*2public static final long MINUTE_TWO = 120;// 3分钟 60*3public static final long MINUTE_THR = 180;// 5分钟 60*5public static final long MINUTE_FIV = 300;// 10分钟 60*10public static final long MINUTE_TEN = 600;// 20分钟public static final long MINUTE_TWENTY = 1200;// 30分钟 60*30public static final long MINUTE_THIRTY = 1800;// 1小时 60*60*1public static final long HOUR = 3600;// 2小时 60*60*2public static final long HOUR_TWO = 7200;// 4小时public static final long HOUR_FOUR = 14400;// 1天 60*60*24public static final long DAY = 86400;// 2天 60*60*24*2public static final long DAY_TWO = 172800;// 1周 60*60*24*7public static final long WEEK = 604800;// 1月 60*60*24*30public static final long MONTH = 2592000;// 1年 60*60*24*365public static final long YEAR = 31536000;}
(5)缓存操作类
/*** cache 操作类* @author zealon*/@Componentpublic class RedisService {/** 日志 */private static final Logger LOGGER = LoggerFactory.getLogger(RedisService.class);/** 默认缓存时间(10分钟) */public static final Long DEFAULT_CACHE_TIME = RedisExpire.MINUTE_TEN;/** 操作字符串 */private ValueOperations<String, String> valueOperations;/** 操作hash */private HashOperations hashOperations;/** 操作list */private ListOperations listOperations;/** 操作set */private SetOperations setOperations;/** 操作有序set */private ZSetOperations zSetOperations;/** Redis模板 */@Autowiredprivate StringRedisTemplate stringRedisTemplate;@Autowiredprivate RedisTemplate redisTemplate;/*** 构造方法初始化操作类*/@PostConstructprivate void inInit() {valueOperations = stringRedisTemplate.opsForValue();hashOperations = redisTemplate.opsForHash();listOperations = stringRedisTemplate.opsForList();setOperations = stringRedisTemplate.opsForSet();zSetOperations = stringRedisTemplate.opsForZSet();}/************************************** 公共方法 *//*** 删除缓存* @param key 缓存key* @return Boolean 成功失败*/public Boolean removeCache(String key) {Long begTime = System.currentTimeMillis();Boolean result = this.removeCacheComm(key);Long endTime = System.currentTimeMillis();LOGGER.info("删除缓存耗时 key={} time={}", key, endTime - begTime);return result;}/*** 根据Key删除缓存* @param key 缓存key* @return Boolean 成功失败*/public Boolean removeCacheComm(String key) {Boolean hasExist = hasKey(key);if (hasExist) {return stringRedisTemplate.delete(key);} else {return true;}}/*** 删除多个key** @param keys 缓存key* @return Long 删除key的数量*/public Long removeList(Set<String> keys) {if (StringUtils.isEmpty(keys)) {return null;}return stringRedisTemplate.delete(keys);}/*** 获取匹配的key** @param keyRegular key正则表达式* @return Set<String> 匹配的可以列表*/public Set<String> getKeyRegualr(String keyRegular) {if (StringUtils.isEmpty(keyRegular)) {return null;}return stringRedisTemplate.keys(keyRegular);}/*** 设置过期时间** @param key 缓存key* @param time 缓存时间*/public void setExpire(final String key, Long time) {stringRedisTemplate.expire(key, time, TimeUnit.SECONDS);}/*** 获取缓存时间剩余时间** @param key 缓存key* @return long 缓存剩余时间*/public Long getExpire(final String key) {return stringRedisTemplate.getExpire(key, TimeUnit.SECONDS);}/*** 判断key是否存在** @param key 缓存key* @return boolean 成功失败*/public Boolean hasKey(String key) {return stringRedisTemplate.hasKey(key);}/************************************** 公共方法 End *//************************************** String处理(实体转化为json字符串) *//*** 从缓存获取值** @param key 缓存key* @param c 参数类型* @param <T> 参数对象* @return T 返回对象*/public <T> T getCache(String key, Class<T> c) {String cache = getCache(key);return JSONObject.parseObject(cache, c);}public <T> List getCacheForList(String key, Class<T> c) {String cache = getCache(key);return JSONObject.parseArray(cache, c);}/*** 从缓存中获取** @param key缓存key* @param typeOff 对象类型* @return Object 返回实体*/public Object getCache(String key, Type typeOff) {return JSONObject.parseObject(getCache(key), typeOff);}/*** 获取缓存信息** @param key 缓存key* @return String*/public String getCache(String key) {return valueOperations.get(key);}/*** 设置缓存值没有设置过期时间** @param key 缓存key* @param value 缓存值*/public void setCache(String key, String value) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) {return;}valueOperations.set(key, value);}/*** 设置缓存过期时间** @param key 缓存KEY* @param value 缓存值*/public void setExpireCacheDefault(final String key, final String value) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) {return;}valueOperations.set(key, value, DEFAULT_CACHE_TIME, TimeUnit.SECONDS);}/*** 设置缓存过期时间** @param key 缓存KEY* @param value 缓存值* @param time 缓存时间*/public void setExpireCache(final String key, final String value, Long time) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value) || StringUtils.isEmpty(time) || time <= 0) {return;}valueOperations.set(key, value, time, TimeUnit.SECONDS);}/************************************** String处理(实体转化为json字符串) End *//************************************** Object处理 *//*** 添加缓存** @param key 缓存KEY* @param obj 缓存对象*/public void setCache(String key, Object obj) {setCache(key, JSONObject.toJSONString(obj));}/*** 设置缓存并添加默认过期时间** @param key 缓存KEY* @param obj 添加的缓存对象*/public void setExpireCacheDefault(final String key, final Object obj) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(obj)) {return;}setExpireCache(key, obj, DEFAULT_CACHE_TIME);}/*** 设置缓存并添加缓存过期时间** @param key 缓存KEY* @param obj 缓存对象* @param time 缓存时间*/public void setExpireCache(final String key, final Object obj, Long time) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(obj) || StringUtils.isEmpty(time)) {return;}this.setExpireCache(key, JSONObject.toJSONString(obj), time);}/************************************** Object处理 End *//************************************** List处理 *//*** 添加缓存** @param key 缓存KEY* @param list 缓存列表值*/public void rightPushAll(String key, List list) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(list)) {return;}List<String> redisList = new ArrayList<>();if (list != null && !list.isEmpty() && list.size() > 0) {for (Object obj : list) {if (obj != null) {redisList.add(JSONObject.toJSONString(obj));}}}listOperations.rightPushAll(key, redisList);}/*** 添加缓存并设置过期时间 有默认值** @param key 缓存KEY* @param list 缓存列表值*/public void rightPushAllExpireDefault(String key, List list) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(list)) {return;}this.rightPushAll(key, list);setExpire(key, DEFAULT_CACHE_TIME);}/*** 添加缓存并设置过期时间** @param key 缓存KEY* @param list 缓存列表* @param time 缓存时间*/public void rightPushAllExpire(String key, List list, Long time) {this.rightPushAll(key, list);setExpire(key, time);}/*** 添加缓存** @param key 缓存KEY* @param list 缓存列表*/public void leftPushAll(String key, List list) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(list)) {return;}List<String> redisList = new ArrayList<>();if (list != null && !list.isEmpty() && list.size() > 0) {for (Object obj : list) {if (obj != null) {redisList.add(JSONObject.toJSONString(obj));}}}listOperations.leftPushAll(key, redisList);}/*** 添加缓存并设置过期时间 有默认值** @param key 缓存KEY* @param list 缓存列表*/public void leftPushAllExpireDefault(String key, List list) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(list)) {return;}this.leftPushAll(key, list);setExpire(key, DEFAULT_CACHE_TIME);}/*** 添加缓存并设置过期时间** @param key 缓存KEY* @param list 缓存列表* @param time 缓存时间*/public void leftPushAllExpire(String key, List list, Long time) {this.leftPushAll(key, list);setExpire(key, time);}/*** 从缓存获取数据** @param key 缓存KEY* @param c 值类型* @param <T> 值对象* @return List<T> 返回对象列表*/public <T> List<T> getRedisList(String key, Class<T> c) {List<String> listStr = listOperations.range(key, 0, -1);if (listStr.isEmpty()) {return null;}List<T> backList = new ArrayList<>();for (String str : listStr) {if (!StringUtils.isEmpty(str)) {backList.add(JSONObject.parseObject(str, c));}}return backList;}/************************************** List处理 End *//************************************** Hash处理 *//*** 获取Hash filed值* @param key* @param field* @param c* @param <T>* @return*/public <T> T getHashVal(String key, String field, Class<T> c){Object val = this.hashOperations.get(key, field);if (val == null) {return null;}return JSONObject.parseObject(val.toString(), c);}public <T> T getHashObject(String key, String field, Class<T> c){Object val = this.hashOperations.get(key, field);if (val == null) {return null;}return (T) val;}public <T> List<T> getHashListVal(String key, String field, Class<T> c){Object val = this.hashOperations.get(key, field);if (val == null) {return null;}return JSONObject.parseArray(val.toString(), c);}public void setHashValExpire(String key, String field, Object val, Long time){this.hashOperations.put(key, field, JSONObject.toJSONString(val));this.setExpire(key, time);}public void setHashValsExpire(String key, HashMap val, Long time){this.hashOperations.putAll(key, val);this.setExpire(key, time);}public boolean hashHasKey(String key, String field){return this.hashOperations.hasKey(key, field);}public void hashIncrement(String key, String field, Integer val){this.hashOperations.increment(key, field, val);}/************************************** Hash处理 End *//************************************** zSet处理 End *//*** 批量保存到有序集合* @param key* @param list*/public void zSetAddExpireDefault(String key, List list) {if (StringUtils.isEmpty(key) || StringUtils.isEmpty(list)) {return;}Double index = 1d;Set<ZSetOperations.TypedTuple<String>> tuples = new HashSet<>();if (!list.isEmpty() && list.size() > 0) {for (Object obj : list) {if (obj != null) {String value = JSONObject.toJSONString(obj);ZSetOperations.TypedTuple<String> typedTuple = new DefaultTypedTuple<>(value, index);tuples.add(typedTuple);index++;}}}zSetOperations.add(key,tuples);setExpire(key, DEFAULT_CACHE_TIME);}/*** 范围查询,返回集合* @param key* @param start* @param end* @param c* @return*/public <T> List<T> zSetRange(String key,long start,long end,Class<T> c){List<T> backList = new ArrayList<>();// 缓存获取数据Set<String> data = zSetOperations.range(key, start, end);if (data == null || data.isEmpty()) {return null;}// 转换为ListIterator<String> iterator = data.iterator();while (iterator.hasNext()){String jsonStr = iterator.next();if (!StringUtils.isEmpty(jsonStr)) {backList.add(JSONObject.parseObject(jsonStr, c));}}return backList;}/*** 获取 zSet 长度* @param key* @return*/public Long zSetGetSize(String key){return zSetOperations.size(key);}/*** 分页获取 zSet 数据集合* @param key* @param c* @param pageNo* @param pageSize* @return*/public <T> List<T> zSetRangeByPage(String key, Class<T> c, Integer pageNo, Integer pageSize) {long start = 0;if (pageNo > 1) {start = (pageNo - 1l) * pageSize;}long end = pageNo * pageSize - 1;return zSetRange(key,start,end,c);}/************************************** zSet处理 End */}
2.常量
(1)精品页常量类
public class CategoryConstant {public static Map<Integer,String> categorys;static {categorys = new HashMap<>();categorys.put(1100, "东方玄幻");categorys.put(1200, "都市小说");categorys.put(1300, "西方玄幻");categorys.put(1400, "武侠仙侠");categorys.put(1500, "历史穿越");categorys.put(1600, "科幻未来");categorys.put(1700, "网游竞技");categorys.put(1800, "悬疑惊悚");categorys.put(2100, "古代言情");categorys.put(2200, "幻想言情");categorys.put(2300, "都市言情");categorys.put(2400, "总裁豪门");categorys.put(2500, "青春校园");categorys.put(2600, "唯美同人");categorys.put(2700, "历史穿越");categorys.put(2800, "唯美同人");categorys.put(3100, "文学小说");categorys.put(3200, "经典名著");}}
(2)jwt常量类
public class JwtConstant {/** JWT秘钥 */public final static String SECRET_KEY = "someday";/** 过期时间天数 */public final static int EXPIRE_DAY = 7;}
3.图书相关枚举
(1)图书分类枚举类
public enum BookCategoryEnum {CATEGORY_1(1,"都市小说"),CATEGORY_2(2,"东方玄幻"),CATEGORY_3(3,"武侠仙侠"),CATEGORY_4(4,"悬疑惊悚"),CATEGORY_5(5,"唯美同人"),CATEGORY_6(6,"网游竞技"),CATEGORY_7(7,"科幻未来"),CATEGORY_8(8,"历史穿越");private Integer value;private String name;BookCategoryEnum(Integer value, String name) {this.value = value;this.name = name;}public Integer getValue() {return value;}public String getName() {return name;}}
(2)书单列表功能枚举类
public enum BooklistMoreTypeEnum {NOTHING(1,"无"),MORE(2,"更多"),EXCHANGE(3,"换一换"),LOADING(4,"加载");private int value;private String name;BooklistMoreTypeEnum(int value, String name) {this.value = value;this.name = name;}public int getValue() {return value;}public String getName() {return name;}}
(3)图书连载状态枚举类
public enum BookSerialStatusEnum {SERIAL(1,"连载"),SUSPEND(2,"暂更"),END(3,"完结");private Integer value;private String name;BookSerialStatusEnum(Integer value, String name) {this.value = value;this.name = name;}public Integer getValue() {return value;}public String getName() {return name;}}
4.请求参数封装
public class RequestParams extends HashMap {private static final Logger LOGGER = LoggerFactory.getLogger(RequestParams.class);/*** 获取整型参数值* @param paramName* @return*/public Integer getIntValue(String paramName){Integer value = 0;Object object = this.get(paramName);if (null == object) {return value;}try{value = Integer.parseInt(this.get(paramName).toString());} catch (Exception ex){value = 0;LOGGER.error("获取参数{}转换整型异常!{}", paramName, ex);}return value;}/*** 获取字符串参数值* @param paramName* @return*/public String getStringValue(String paramName){String value = "";Object object = this.get(paramName);if (null == object) {return value;}return object.toString();}}
5.统一返回结果
(1)Http状态码封装
/*** * http 状态码* ----------------------------------------------------------------------------* 200 OK - [GET]:服务器成功返回用户请求的数据,该操作是幂等的(Idempotent)。* 400 INVALID REQUEST - [POST/PUT/PATCH]:用户发出的请求有错误,服务器没有进行新建或修改数据的操作,该操作是幂等的。* 401 Unauthorized - [*]:表示用户没有权限(令牌、用户名、密码错误)。* 403 Forbidden - [*] 表示用户得到授权(与401错误相对),但是访问是被禁止的。* 404 NOT FOUND - [*]:用户发出的请求针对的是不存在的记录,服务器没有进行操作,该操作是幂等的。* 406 Not Acceptable - [GET]:用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)。* 410 Gone -[GET]:用户请求的资源被永久删除,且不会再得到的。* 422 Unprocesable entity - [POST/PUT/PATCH] 当创建一个对象时,发生一个验证错误。* 500 INTERNAL SERVER ERROR - [*]:服务器发生错误,用户将无法判断发出的请求是否成功。* 600 UN_KNOW_ERROR - 未知错误* ----------------------------------------------------------------------------*/public enum HttpCodeEnum {OK(200,"操作成功"),INVALID_REQUEST(400,"参数错误"),UNAUTHORIZED(401,"没有权限"),FORBIDDEN(403,"禁止访问"),NOT_FOUND(404,"资源不存在"),NOT_ACCEPTABLE(406,"请求的格式不正确"),GONE(410,"数据被删除"),UNPROCESABLE_ENTITY(422,"参数验证错误"),INTERNAL_SERVER_ERROR(500,"服务器发生错误"),UN_KNOW_ERROR(500,"未知错误"),FAIL(501,"操作失败"),MODEL_NOT_EXIST(1000, "模型不存在"),VERIFICATION_FAILED(1001, "业务逻辑验证未通过"),USERNAME_OR_PASSWORD_ERR(2000,"用户未登录或token已失效"),DELETE_DEFAULT_PHOTO_ERR(2001,"默认头像不可删除"),AUTH_EXPIRED(3000,"认证到期"),TOKEN_ERR(3001, "token无效");private final int code;private final String message;HttpCodeEnum(final int code, final String message){this.code=code;this.message=message;}public String getMessage() {return message;}public int getCode() {return code;}}
(2)操作结果封装
public class Result<T> implements Serializable {private static final long serialVersionUID = 1L;private int code;private String msg;private T data;public Result(int code, String msg, T data) {this.code = code;this.msg = msg;this.data = data;}public Result(int code, String msg) {this.code = code;this.msg = msg;}public Result() {}/*** 构建消息内容* @param msg* @return*/public Result buildMessage(String msg){this.setMsg(msg);return this;}/*** 构建消息data的值,key默认为data* @param obj data值* @return*/public Result buildData(T obj){this.setData(obj);return this;}public int getCode() {return code;}public void setCode(int code) {this.code = code;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public T getData() {return data;}public void setData(T data) {this.data = data;}}
(3)返回结果工具类
ResultUtil {/*** 请求成功* @return*/public static Result success() {return new Result(HttpCodeEnum.OK.getCode(),HttpCodeEnum.OK.getMessage());}/*** 请求成功(无消息)* @return*/public static Result successAndNoMsg() {return new Result(HttpCodeEnum.OK.getCode(),"");}/*** 成功请求** @param data* @return*/public static Result success(Object data) {return new Result(HttpCodeEnum.OK.getCode(), HttpCodeEnum.OK.getMessage() , data);}/*** 成功请求(无消息)** @param data* @return*/public static Result successAndNoMsg(Object data) {return new Result(HttpCodeEnum.OK.getCode(), "", data);}/*** 操作失败* @return*/public static Result fail() {return new Result(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMessage());}/*** 操作失败* @return*/public static Result fail(Object data) {return new Result(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMessage() ,data);}/*** 服务器错误* @return*/public static Result error() {return new Result(HttpCodeEnum.INTERNAL_SERVER_ERROR.getCode(),HttpCodeEnum.INTERNAL_SERVER_ERROR.getMessage());}/*** 服务器错误* @param data* @return*/public static Result error(Object data) {return new Result(HttpCodeEnum.INTERNAL_SERVER_ERROR.getCode(),HttpCodeEnum.INTERNAL_SERVER_ERROR.getMessage(), data);}/*** 参数错误* @return*/public static Result paramError() {return new Result(HttpCodeEnum.INVALID_REQUEST.getCode(), HttpCodeEnum.INVALID_REQUEST.getMessage());}/*** 参数错误* @param data* @return*/public static Result paramError(Object data) {return new Result(HttpCodeEnum.INVALID_REQUEST.getCode(), HttpCodeEnum.INVALID_REQUEST.getMessage(), data);}/*** 认证到期* @return*/public static Result authExpired() {return new Result(HttpCodeEnum.AUTH_EXPIRED.getCode(), HttpCodeEnum.AUTH_EXPIRED.getMessage());}/*** 没有权限* @return*/public static Result unAuthorized() {return new Result(HttpCodeEnum.UNAUTHORIZED.getCode(), HttpCodeEnum.UNAUTHORIZED.getMessage());}/*** 没有权限* @param data* @return*/public static Result unAuthorized(Object data) {return new Result(HttpCodeEnum.UNAUTHORIZED.getCode(),HttpCodeEnum.UNAUTHORIZED.getMessage(),data);}/*** 禁止访问* @return*/public static Result forbidden() {return new Result(HttpCodeEnum.FORBIDDEN.getCode(),HttpCodeEnum.FORBIDDEN.getMessage());}/*** 禁止访问* @param data* @return*/public static Result forbidden(Object data) {return new Result(HttpCodeEnum.FORBIDDEN.getCode(),HttpCodeEnum.FORBIDDEN.getMessage(), data);}/*** 资源不存在* @return*/public static Result notFound() {return new Result(HttpCodeEnum.NOT_FOUND.getCode(),HttpCodeEnum.NOT_FOUND.getMessage());}/*** 资源不存在* @param data* @return*/public static Result notFound(Object data) {return new Result(HttpCodeEnum.NOT_FOUND.getCode(),HttpCodeEnum.NOT_FOUND.getMessage(), data);}/*** 请求的格式不正确* @return*/public static Result notAcceptable() {return new Result(HttpCodeEnum.NOT_ACCEPTABLE.getCode(),HttpCodeEnum.NOT_ACCEPTABLE.getMessage());}/*** 请求的格式不正确* @param data* @return*/public static Result notAcceptable(Object data) {return new Result(HttpCodeEnum.NOT_ACCEPTABLE.getCode(),HttpCodeEnum.NOT_ACCEPTABLE.getMessage(), data);}/*** 数据已经被删除* @return*/public static Result gone() {return new Result(HttpCodeEnum.GONE.getCode(),HttpCodeEnum.GONE.getMessage());}/*** 数据已经被删除* @param data* @return*/public static Result gone(Object data) {return new Result(HttpCodeEnum.GONE.getCode(),HttpCodeEnum.GONE.getMessage(), data);}/*** 实体参数校验错误* @return*/public static Result unprocesableEntity() {return new Result(HttpCodeEnum.UNPROCESABLE_ENTITY.getCode(),HttpCodeEnum.UNPROCESABLE_ENTITY.getMessage());}/*** 实体参数校验错误* @param data* @return*/public static Result unprocesableEntity(Object data) {return new Result(HttpCodeEnum.UNPROCESABLE_ENTITY.getCode(),HttpCodeEnum.UNPROCESABLE_ENTITY.getMessage(), data);}/*** 未知错误* @return*/public static Result unKnowError() {return new Result(HttpCodeEnum.UN_KNOW_ERROR.getCode(),HttpCodeEnum.UN_KNOW_ERROR.getMessage());}/*** 未知错误* @param data* @return*/public static Result unKnowError(Object data) {return new Result(HttpCodeEnum.UN_KNOW_ERROR.getCode(),HttpCodeEnum.UN_KNOW_ERROR.getMessage(), data);}/*** 业务逻辑验证未通过* @return*/public static Result verificationFailed() {return new Result(HttpCodeEnum.VERIFICATION_FAILED.getCode(),HttpCodeEnum.VERIFICATION_FAILED.getMessage());}/*** 业务逻辑验证未通过* @param data* @return*/public static Result verificationFailed(Object data) {return new Result(HttpCodeEnum.VERIFICATION_FAILED.getCode(),HttpCodeEnum.VERIFICATION_FAILED.getMessage(), data);}/*** 自定义返回* @param e* @return*/public static Result custom(HttpCodeEnum e) {return new Result(e.getCode(),e.getMessage());}/*** 自定义返回* @param error* @return*/public static Result custom(int code,String error) {return new Result(code,error);}/*** 自定义返回* @param error* @param data* @return*/public static Result custom(int code,String error,Object data) {return new Result(code,error,data);}}
6.POJO
公用的实体类不再多说!!!