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

实验室网站制作软件开发技术培训课程

实验室网站制作,软件开发技术培训课程,photoshop 做网站,番禺网站开发哪家好文章目录 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.dnsts.com.cn/news/102785.html

相关文章:

  • 龙江做网站网站建设 王卫洲
  • 网站项目建设合同龙华城市建设局网站
  • 一台vps主机可以建设多少个网站手机网站制作费用
  • 网站搭建功能需求wordpress密码登录插件
  • 电子元器件网站怎么做电脑系统做的好的网站
  • 做一个网站做少多少钱湖南省建设厅气源适配性目录2022
  • 用来做网站的软件上海网站建设电
  • 网站无障碍建设标准网站推荐货源
  • 微网站怎么注册wordpress插件h5
  • 企业网站建设存在的不足与困难文章wordpress
  • 网站地图如何更新给女朋友做情侣网站的程序员
  • 使用cms快速搭建商业网站注册小公司
  • 可视化建站源码wordpress多个菜单menu
  • 哈尔滨专业网站建设哪个好蓝色系网站首页
  • ps做的网站怎么到网站上预览济南seo网站推广公司
  • dede更新网站阿里云 wordpress 500
  • 医学院英文网站建设方案局域网内的网站建设
  • 西双网站建设南海佛山网站建设
  • h5开发和前端开发区别东莞seo网站推广
  • 中国商标网商标查询网巩义网站优化培训
  • 皮具网站建设策划书施工企业管理杂志官网
  • 烟台城乡建设局网站网站建设颜色注意事项
  • 网站样式下载百度排名 网站标题
  • 网站建设怎么选公司我做微信淘宝客网站有哪些
  • 广州建设工程造价管理站深圳工作服制作
  • 小企业网站建设哪些好办郑州哪个公司专业做网站
  • 建筑学网站推荐wordpress系统付费
  • 网站制作公司怎样帮客户做优化免费网站建设行情
  • 手机 网站 翻页 外部网站建设视频教程推荐
  • 广州 天河网站设计百度关键词seo公司