当前位置: 首页 > 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 ResponseVO<T> …

在这里插入图片描述

文章目录

    • 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 ResponseVO<T> {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 RedisUtils<V> {@Resourceprivate RedisTemplate<String, 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((Collection<String>) CollectionUtils.arrayToList(key));}}}
}

在这里插入图片描述

http://www.yidumall.com/news/75896.html

相关文章:

  • 可以做ppt的网站有哪些内容seo入口
  • vs2010 网站开发2023免费b站推广大全
  • 需要个网站目前推广平台都有哪些
  • 怎样自己做网络推广网站搜狗推广助手
  • 政府网站建设(信科网络)河北网站seo策划
  • 网站做系统下载seo入门到精通
  • 如何给网站做2维码百度电脑版官网入口
  • 视频插入网站全网营销老婆第一人
  • 做静态网站有什么用做销售怎样去寻找客户
  • 做钓鱼网站软件下载天津seo代理商
  • 企业网站建设策划书怎么写友情手机站
  • 网站开发北京搜索引擎营销的常见方式
  • 单位做网站的目的营销策划公司的经营范围
  • 可不可以建网站做微商怎么在百度上设置自己的门店
  • 做网站项目前期工作包括哪些如何做地推推广技巧
  • 怎么做本地网站乌海网站seo
  • 黄埔网站建设 信科网络外链群发软件
  • 阿里云上做网站网站收录怎么弄
  • 天津中冀建设集团有限公司网站洛阳seo网络推广
  • 近一周财经新闻热点广州网站设计专注乐云seo
  • 网站优化可以做哪些优化淘宝关键词搜索
  • 返利网站建设江西百度推广开户多少钱
  • 鞍山做网站优化公司seo排名优化技术
  • 网站分析步骤网站收录查询爱站
  • 徐州做网站管理的公司网络舆情处置的五个步骤
  • 企业官方网站需要备案吗软件开发培训学校
  • 传奇手游sf网站汽车网络营销推广方案
  • element ui做的网站优化大师免费下载安装
  • 阿里云服务器添加网站什么是搜索引擎优化seo
  • 株洲做网站多少钱怎么做公众号