当前位置: 首页 > news >正文

实验室网站制作邯郸市网络建站

实验室网站制作,邯郸市网络建站,十堰哪里有做网站的,谷歌的网站打不开文章目录 4.1后端统一设计思想4.1.1后端统一返回格式对象4.1.2后端统一响应状态码4.1.3后端统一异常处理类4.1.4StringUtils类4.1.5 RedisUtils类 4.1后端统一设计思想 4.1.1后端统一返回格式对象 com.easypan.entity.vo.ResponseVO Data public class ResponseVOT … 文章目录 4.1后端统一设计思想4.1.1后端统一返回格式对象4.1.2后端统一响应状态码4.1.3后端统一异常处理类4.1.4StringUtils类4.1.5 RedisUtils类 4.1后端统一设计思想 4.1.1后端统一返回格式对象 com.easypan.entity.vo.ResponseVO Data public class ResponseVOT {private String status;private Integer code; //响应状态码private String info; //响应消息private T data; //响应数据 }4.1.2后端统一响应状态码 com.easypan.entity.enums.ResponseCodeEnum public enum ResponseCodeEnum {CODE_200(200, 请求成功),CODE_404(404, 请求地址不存在),CODE_600(600, 请求参数错误),CODE_601(601, 信息已经存在),CODE_500(500, 服务器返回错误请联系管理员),CODE_901(901, 登录超时请重新登录),CODE_902(902, 分享连接不存在或者已失效),CODE_903(903, 分享验证失效请重新验证),CODE_904(904, 网盘空间不足请扩容);private Integer code; //状态码private String msg; //状态码对应的信息ResponseCodeEnum(Integer code, String msg) {this.code code;this.msg msg;}public Integer getCode() {return code;}public String getMsg() {return msg;} }4.1.3后端统一异常处理类 com.easypan.exception.BusinessException Data AllArgsConstructor public class BusinessException extends RuntimeException {private ResponseCodeEnum codeEnum; //后端统一响应状态码private Integer code; //自定义code值private String message; //自定义消息public BusinessException(String message, Throwable e) {super(message, e);this.message message;}public BusinessException(String message) {super(message);this.message message;}public BusinessException(Throwable e) {super(e);}/*** Description 根据指定codeEnum创建Exception对象*/public BusinessException(ResponseCodeEnum codeEnum) {super(codeEnum.getMsg());this.codeEnum codeEnum;this.code codeEnum.getCode();this.message codeEnum.getMsg();}/*** Description: 自定义code、message来创建Exception对象*/public BusinessException(Integer code, String message) {super(message);this.code code;this.message message;}/*** 重写fillInStackTrace 业务异常不需要堆栈信息提高效率.*/Overridepublic Throwable fillInStackTrace() {return this;}}4.1.4StringUtils类 com.easypan.utils.StringUtils public class StringUtils {public static String encodeByMD5(String originString) {return StringUtils.isEmpty(originString) ? null : DigestUtils.md5Hex(originString);}public static boolean isEmpty(String str) {if (null str || .equals(str) || null.equals(str) || \u0000.equals(str)) {return true;} else if (.equals(str.trim())) {return true;}return false;}public static String getFileSuffix(String fileName) {Integer index fileName.lastIndexOf(.);if (index -1) {return ;}String suffix fileName.substring(index);return suffix;}public static String getFileNameNoSuffix(String fileName) {Integer index fileName.lastIndexOf(.);if (index -1) {return fileName;}fileName fileName.substring(0, index);return fileName;}public static String rename(String fileName) {String fileNameReal getFileNameNoSuffix(fileName);String suffix getFileSuffix(fileName);return fileNameReal _ getRandomString(Constants.LENGTH_5) suffix;}public static final String getRandomString(Integer count) {return RandomStringUtils.random(count, true, true);}public static final String getRandomNumber(Integer count) {return RandomStringUtils.random(count, false, true);}public static String escapeTitle(String content) {if (isEmpty(content)) {return content;}content content.replace(, lt;);return content;}public static String escapeHtml(String content) {if (isEmpty(content)) {return content;}content content.replace(, lt;);content content.replace( , nbsp;);content content.replace(\n, br);return content;}public static boolean pathIsOk(String path) {if (StringUtils.isEmpty(path)) {return true;}if (path.contains(../) || path.contains(..\\)) {return false;}return true;} }4.1.5 RedisUtils类 com.easypan.utils.RedisUtils Slf4j Component(redisUtils) public class RedisUtilsV {Resourceprivate RedisTemplateString, V redisTemplate;/*** 普通缓存放入* param key 键* param value 值* return true成功 false失败*/public boolean set(String key, V value) {try {redisTemplate.opsForValue().set(key, value);return true;} catch (Exception e) {log.error(设置redisKey:{},value:{}失败, key, value);return false;}}/*** 普通缓存放入并设置时间** param key 键* param value 值* param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期* return true成功 false 失败*/public boolean setex(String key, V value, long time) {try {if (time 0) {redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);} else {set(key, value);}return true;} catch (Exception e) {log.error(设置redisKey:{},value:{}失败, key, value);return false;}}//获取指定key的value值public V get(String key) {return key null ? null : redisTemplate.opsForValue().get(key);}/*** 删除缓存key 可以传一个值 或多个*/public void delete(String... key) {if (key ! null key.length 0) {if (key.length 1) {redisTemplate.delete(key[0]);} else {redisTemplate.delete((CollectionString) CollectionUtils.arrayToList(key));}}} }
http://www.hkea.cn/news/14427534/

相关文章:

  • 免费网站在线制作南京学习网站建设
  • 门户网站管理流程免费微信小程序商城官网
  • 库尔勒网站建设哪家好医院导航网站怎么做
  • 广州比较有名的网站建设公司网络规划设计师教程第二版 pdf下载地址
  • 济南网站建设是什么意思网站建设 体会
  • 全国二级建造师查询网站seo美式
  • 个人免费网站wordpress环境文件包
  • 模板网站制作logo设计培训
  • 《网站建设与维护》讲义网站搜索建设
  • 庆阳网站设计公司wordpress 不更新
  • 手机网站大全推荐北京做兼职的网站
  • 漳州微信网站开发自己做网站怎么连接外网
  • 上海网站建设咨询报价官方网站建设银行年利息是多少
  • 网站制作流程有哪些360免费自助建站
  • 重庆做营销型网站公司怎么做优惠券网站
  • 中国建设网站的公司南昌简单做网站
  • 简述建设一个商务网站的过程百度站长平台闭站保护
  • 建设部国家标准网站网站的标题优化怎么做
  • 女生自己做网站小程序制作工具
  • 建设项目验收 网站用网站ip做代理服务器
  • 网站做板块地图的办法网站推广的四个阶段包括
  • 网站建设与百度推广怎么在百度发帖
  • 网站推广公司哪家好刚做的网站为什么搜索不到
  • 临沂门户网站制作石家庄网页开发建设
  • 湖南星大建设集团有限公司网站开发公司财务管理制度
  • 有做全棉坯布的网站吗怎样修改wordpress模板
  • 做网站用哪个版本的eclipse软件商城app下载
  • 如何在eclipse上做网站途牛企业网站建设方案
  • 建旅游网站费用明细潮流资讯类网站建设策划
  • 网站什么做南昌网站建设哪家好