mirror of https://gitee.com/stylefeng/guns
【7.3.0】重新整理注释
parent
b989a82dca
commit
ea389df554
|
@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
|||
* SpringBoot方式启动类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/1 17:50
|
||||
* @since 2020/12/1 17:50
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication(scanBasePackages = {"cn.stylefeng"}, exclude = {FlywayAutoConfiguration.class, GunsDataSourceAutoConfiguration.class})
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
|||
* Web程序启动类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/1 17:50
|
||||
* @since 2020/12/1 17:50
|
||||
*/
|
||||
public class GunsServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
* 配置mapper包扫描
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/13 16:11
|
||||
* @since 2020/12/13 16:11
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = {"cn.stylefeng.**.mapper"})
|
||||
|
|
|
@ -20,7 +20,7 @@ import javax.annotation.Resource;
|
|||
* spring mvc的配置
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/11 10:23
|
||||
* @since 2020/4/11 10:23
|
||||
*/
|
||||
@Configuration
|
||||
@Import({cn.hutool.extra.spring.SpringUtil.class, CorsFilterConfiguration.class})
|
||||
|
@ -36,7 +36,7 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
* 重写系统的默认错误提示
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 15:36
|
||||
* @since 2020/12/16 15:36
|
||||
*/
|
||||
@Bean
|
||||
public CustomErrorAttributes gunsErrorAttributes() {
|
||||
|
@ -47,7 +47,7 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
* json自定义序列化工具,long转string
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/13 17:16
|
||||
* @since 2020/12/13 17:16
|
||||
*/
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
|
@ -61,7 +61,7 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
* 配置项目拦截器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/18 9:43
|
||||
* @since 2020/12/18 9:43
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
@ -73,7 +73,7 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
* 静态资源映射
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/16 21:45
|
||||
* @since 2021/1/16 21:45
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import cn.stylefeng.guns.GunsApplication;
|
|||
* 项目的常量
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:28
|
||||
* @since 2020/12/16 14:28
|
||||
*/
|
||||
public interface ProjectConstants {
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||
* 将系统管理未知错误异常,输出格式重写为我们熟悉的响应格式
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:36
|
||||
* @since 2020/12/16 14:36
|
||||
*/
|
||||
public class CustomErrorAttributes extends DefaultErrorAttributes {
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import static cn.stylefeng.guns.core.consts.ProjectConstants.ROOT_PACKAGE_NAME;
|
|||
* 全局异常处理器,拦截控制器层的异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:20
|
||||
* @since 2020/12/16 14:20
|
||||
*/
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
|
@ -57,7 +57,7 @@ public class GlobalExceptionHandler {
|
|||
* 请求参数缺失异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:20
|
||||
* @since 2020/12/16 14:20
|
||||
*/
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
@ResponseBody
|
||||
|
@ -72,7 +72,7 @@ public class GlobalExceptionHandler {
|
|||
* HttpMessageConverter转化异常,一般为json解析异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:21
|
||||
* @since 2020/12/16 14:21
|
||||
*/
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
@ResponseBody
|
||||
|
@ -86,7 +86,7 @@ public class GlobalExceptionHandler {
|
|||
* 拦截不支持媒体类型异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:26
|
||||
* @since 2020/12/16 14:26
|
||||
*/
|
||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||
@ResponseBody
|
||||
|
@ -100,7 +100,7 @@ public class GlobalExceptionHandler {
|
|||
* 不受支持的http method
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:56
|
||||
* @since 2020/12/16 14:56
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
@ResponseBody
|
||||
|
@ -114,7 +114,7 @@ public class GlobalExceptionHandler {
|
|||
* 404找不到资源
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:58
|
||||
* @since 2020/12/16 14:58
|
||||
*/
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
@ResponseBody
|
||||
|
@ -127,7 +127,7 @@ public class GlobalExceptionHandler {
|
|||
* 请求参数校验失败,拦截 @Valid 校验失败的情况
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:59
|
||||
* @since 2020/12/16 14:59
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseBody
|
||||
|
@ -143,7 +143,7 @@ public class GlobalExceptionHandler {
|
|||
* 两个注解 @Valid 和 @Validated 区别是后者可以加分组校验,前者没有分组校验
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 15:08
|
||||
* @since 2020/12/16 15:08
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
@ResponseBody
|
||||
|
@ -157,7 +157,7 @@ public class GlobalExceptionHandler {
|
|||
* 拦截 @TableUniqueValue 里抛出的异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/26 14:05
|
||||
* @since 2020/12/26 14:05
|
||||
*/
|
||||
@ExceptionHandler(ValidationException.class)
|
||||
@ResponseBody
|
||||
|
@ -180,7 +180,7 @@ public class GlobalExceptionHandler {
|
|||
* 如果用户登录过期,不是ajax请求,则直接跳转到登录页面,并提示会话超时
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 15:11
|
||||
* @since 2020/12/16 15:11
|
||||
*/
|
||||
@ExceptionHandler(AuthException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
@ -221,7 +221,7 @@ public class GlobalExceptionHandler {
|
|||
* 拦截业务代码抛出的异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 15:11
|
||||
* @since 2020/12/16 15:11
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
@ -237,7 +237,7 @@ public class GlobalExceptionHandler {
|
|||
* 用在demo模式,拦截DemoException
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2020/5/5 15:19
|
||||
* @since 2020/5/5 15:19
|
||||
*/
|
||||
@ExceptionHandler(MyBatisSystemException.class)
|
||||
@ResponseBody
|
||||
|
@ -257,7 +257,7 @@ public class GlobalExceptionHandler {
|
|||
* 拦截未知的运行时异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 15:12
|
||||
* @since 2020/12/16 15:12
|
||||
*/
|
||||
@ExceptionHandler(Throwable.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
@ -271,7 +271,7 @@ public class GlobalExceptionHandler {
|
|||
* 渲染异常json
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/5/5 16:22
|
||||
* @since 2020/5/5 16:22
|
||||
*/
|
||||
private ErrorResponseData<?> renderJson(String code, String message) {
|
||||
return renderJson(code, message, null);
|
||||
|
@ -281,7 +281,7 @@ public class GlobalExceptionHandler {
|
|||
* 渲染异常json
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/5/5 16:22
|
||||
* @since 2020/5/5 16:22
|
||||
*/
|
||||
private ErrorResponseData<?> renderJson(AbstractExceptionEnum exception, Object... params) {
|
||||
return renderJson(exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params), null);
|
||||
|
@ -291,7 +291,7 @@ public class GlobalExceptionHandler {
|
|||
* 渲染异常json
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/5/5 16:22
|
||||
* @since 2020/5/5 16:22
|
||||
*/
|
||||
private ErrorResponseData<?> renderJson(AbstractExceptionEnum abstractExceptionEnum) {
|
||||
return renderJson(abstractExceptionEnum.getErrorCode(), abstractExceptionEnum.getUserTip(), null);
|
||||
|
@ -301,7 +301,7 @@ public class GlobalExceptionHandler {
|
|||
* 渲染异常json
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/5/5 16:22
|
||||
* @since 2020/5/5 16:22
|
||||
*/
|
||||
private ErrorResponseData<?> renderJson(Throwable throwable) {
|
||||
return renderJson(DefaultBusinessExceptionEnum.SYSTEM_RUNTIME_ERROR.getErrorCode(), DefaultBusinessExceptionEnum.SYSTEM_RUNTIME_ERROR.getUserTip(), throwable);
|
||||
|
@ -313,7 +313,7 @@ public class GlobalExceptionHandler {
|
|||
* 根据异常枚举和Throwable异常响应,异常信息响应堆栈第一行
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2020/5/5 16:22
|
||||
* @since 2020/5/5 16:22
|
||||
*/
|
||||
private ErrorResponseData<?> renderJson(String code, String message, Throwable throwable) {
|
||||
if (ObjectUtil.isNotNull(throwable)) {
|
||||
|
@ -331,7 +331,7 @@ public class GlobalExceptionHandler {
|
|||
* 多个信息,拼接成用逗号分隔的形式
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2020/5/5 16:50
|
||||
* @since 2020/5/5 16:50
|
||||
*/
|
||||
private String getArgNotValidMessage(BindingResult bindingResult) {
|
||||
if (bindingResult == null) {
|
||||
|
@ -357,7 +357,7 @@ public class GlobalExceptionHandler {
|
|||
* 第二种,如果是前后端分离项目,则渲染Json结果
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/5/18 10:48
|
||||
* @since 2021/5/18 10:48
|
||||
*/
|
||||
private String renderLoginResult(HttpServletResponse response, AuthException authException, Model model) {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import static cn.stylefeng.guns.core.consts.ProjectConstants.PROJECT_MODULE_NAME
|
|||
* 业务异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/16 14:26
|
||||
* @since 2020/12/16 14:26
|
||||
*/
|
||||
public class BusinessException extends ServiceException {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* 鉴权的过滤器,用来鉴权token
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/15 22:45
|
||||
* @since 2020/12/15 22:45
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
|
|
|
@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* 权限校验的过滤器,用来校验用户有没有访问接口的权限
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/15 22:46
|
||||
* @since 2020/12/15 22:46
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
|
|
|
@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* 基础的Filter,一般用在权限过滤
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/15 22:50
|
||||
* @since 2020/12/15 22:50
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class BaseSecurityInterceptor implements HandlerInterceptor {
|
||||
|
@ -99,7 +99,7 @@ public abstract class BaseSecurityInterceptor implements HandlerInterceptor {
|
|||
* 过滤器的具体业务执行逻辑
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/15 22:52
|
||||
* @since 2020/12/15 22:52
|
||||
*/
|
||||
public abstract void filterAction(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, ResourceDefinition resourceDefinition, String token);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import javax.annotation.Resource;
|
|||
* 示例控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/24 10:57
|
||||
* @since 2021/1/24 10:57
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "示例")
|
||||
|
@ -29,7 +29,7 @@ public class DemoController {
|
|||
* 示例方法
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/24 10:59
|
||||
* @since 2021/1/24 10:59
|
||||
*/
|
||||
@GetResource(name = "示例方法", path = "/json/success")
|
||||
public ResponseData<?> renderSuccess() {
|
||||
|
@ -44,7 +44,7 @@ public class DemoController {
|
|||
* </p>
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/24 10:59
|
||||
* @since 2021/1/24 10:59
|
||||
*/
|
||||
@PostResource(name = "示例加密方法", path = "/encode", requiredPermission = false, requiredLogin = false, requiredEncryption = true)
|
||||
public ResponseData<Dict> encode(@RequestBody Dict dict) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
|
|||
* 示例服务
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/24 10:58
|
||||
* @since 2021/1/24 10:58
|
||||
*/
|
||||
@Service
|
||||
public class DemoService {
|
||||
|
@ -15,7 +15,7 @@ public class DemoService {
|
|||
* demo方法
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/24 10:58
|
||||
* @since 2021/1/24 10:58
|
||||
*/
|
||||
public void demoService(){
|
||||
System.out.println("这是一个demo方法");
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.annotation.Resource;
|
|||
* 测试多数据源
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2018/7/20 23:39
|
||||
* @since 2018/7/20 23:39
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "测试多数据源")
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.annotation.Resource;
|
|||
* 测试单数据源回滚
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2018/7/20 23:39
|
||||
* @since 2018/7/20 23:39
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "测试单数据源")
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
|||
* 创建一个用于测试数据源的用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/23 23:29
|
||||
* @since 2021/1/23 23:29
|
||||
*/
|
||||
public class NormalUserFactory {
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class NormalUserFactory {
|
|||
* 创建一个用于测试数据源的用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/23 23:29
|
||||
* @since 2021/1/23 23:29
|
||||
*/
|
||||
public static SysUser createAnUser() {
|
||||
SysUser user = new SysUser();
|
||||
|
|
|
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
|||
* Guns数据库操作
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/23 23:29
|
||||
* @since 2021/1/23 23:29
|
||||
*/
|
||||
@Service
|
||||
public class GunsDbService extends ServiceImpl<SysUserMapper, SysUser> {
|
||||
|
|
|
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
|||
* 其他数据库操作
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/23 23:30
|
||||
* @since 2021/1/23 23:30
|
||||
*/
|
||||
@Service
|
||||
public class OtherDbService extends ServiceImpl<SysUserMapper, SysUser> {
|
||||
|
|
|
@ -10,7 +10,7 @@ import javax.annotation.Resource;
|
|||
* 测试多数据源操作
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/23 23:30
|
||||
* @since 2021/1/23 23:30
|
||||
*/
|
||||
@Service
|
||||
public class TranTestService {
|
||||
|
|
Loading…
Reference in New Issue