fast-family-mvc
介绍:
fast-family-mvc是fast-family框架其中的一个模块,此模块主要是对传统的springmvc进行增强,让其开发人员更加轻松便捷的写代码,达到开箱即用的效果。而且可以通过fast-family-generator配套的代码生成器快速生成。
主要功能:
- 传统controller,service,mapper,entity,dto等基类
- 分布式主键ID生成器
- swagger2增强(基于简单yml配置即可)
- tomcat优雅停机
- 全局异常处理器
- 请求响应日志打印
使用示例:
-
controller等基类示例
controller:
@RestController@RequestMapping("/user")@Slf4j@Api(tags = "用户信息接口")public class SysUserController extends GenericController
{ @Autowired private SysUserService sysUserService;
@Override public GenericServicegetService() { return this.sysUserService; }
}
/**
- <p>
- 描述: 用户信息业务接口
- <p>
*
- @created 2018-10-06 14:17:30
*/
public interface SysUserService extends GenericService<SysUser,Long>{}
@Service
@Slf4j public class SysUserServiceImpl extends GenericServiceImpl<SysUser,Long> implements SysUserService{@Autowired private SysUserMapper sysuserMapper; @Override public GenericMappergetMapper() { return sysuserMapper; }
}
mapper:
/**
- <p>
- 描述: 用户信息Mapper接口
- <p>
*
- @created 2018-10-06 14:17:30
*/
public interface SysUserMapper extends GenericMapper<SysUser,Long> {}
entity:
/**
- <p>
- 描述: 用户信息实体
- <p>
- @created 2018-10-06 14:17:30
*/
@Builder @Data @AllArgsConstructor @NoArgsConstructor @Entity @Table(name = "sys_user") @ApiModel(value = "用户信息实体") public class SysUser extends GenericEntity<Long> {@Column(name = "user_name") @ApiModelProperty(required = true, dataType = "String", name = "用户名") private String userName; @Column(name = "password") @ApiModelProperty(required = true, dataType = "String", name = "密码") private String password;
}
dto:
/**
- <p>
- 描述: 用户信息Dto实体
- <p>
*
- @created 2018-10-06 14:17:30
*/
public class SysUserDTO extends AbstractPersistableBusinessObjectAdapter<SysUser>{public SysUserDTO(ClasspersistableEntityClass) { super(persistableEntityClass); } @Override protected void customizeConvert(SysUser sysuser) { } @Override protected void customizeFill(SysUser sysuser) { }
}
- swagger2示例
fast:
family: swagger2: restapi: back-package: com.fast.family.mvc.example apiinfo: version: 1.0 title: fast-family-swagger构建restful api description: 欢迎关注fast-family快速开发框架 terms-of-service-url: https://github.com/fast-family/fast-family-master contact-email: 616394599@qq.com contact-name: 张顺
- 请求响应日志示例 @Bean public Filter logFilter(){ return new AccessLogFilter(); }**使用效果:** 继承controller基类效果图![file](http://springforall.ufile.ucloud.com.cn/static/img/9327888e7378ed24bee02892108085181538833) swagger效果图![file](http://springforall.ufile.ucloud.com.cn/static/img/ebdb28bd5bc57e00b77f6287b6511e671538833) 请求响应日志效果图![file](http://springforall.ufile.ucloud.com.cn/static/img/4ea6ae23fe6551bed869e33900b4f4eb1538833)**最后:** 如果您对此框架感兴趣或者想获取最新进度信息可以加qq群:390295286 github地址:https://github.com/fast-family/fast-family-master 欢迎star fork github example地址: https://github.com/fast-family/fast-family-example