本文总结苍穹外卖项目中可复用的通用设计
sky-common

constant存放常量类,包括消息常量,状态常量
context是上下文对象,封装了threadlocal
package com.sky.context;
public class BaseContext {
public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
public static void setCurrentId(Long id) {
threadLocal.set(id);
}
public static Long getCurrentId() {
return threadLocal.get();
}
public static void removeCurrentId() {
threadLocal.remove();
}
}
enumeration存放枚举类
exception存放自定义异常类,用于抛出自定义异常
/**
* 业务异常
*/
public class BaseException extends RuntimeException {
public BaseException() {
}
public BaseException(String msg) {
super(msg);
}
}
/**
* 账号被锁定异常
*/
public class AccountLockedException extends BaseException {
public AccountLockedException() {
}
public AccountLockedException(String msg) {
super(msg);
}
}
properties用于配置工具类的属性,@ConfigurationProperties(prefix = “sky.alioss”)读取application.yml中以sky.alioss为前缀的具体值
@Component
@ConfigurationProperties<

最低0.47元/天 解锁文章
1882

被折叠的 条评论
为什么被折叠?



