├── .gitignore ├── LICENSE ├── README.md ├── ffast-admin ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── ffast │ │ │ └── web │ │ │ ├── WebApplication.java │ │ │ ├── config │ │ │ ├── InterceptorConfig.java │ │ │ ├── MybatisPlusConfig.java │ │ │ └── RedisConfig.java │ │ │ ├── controller │ │ │ ├── TestController.java │ │ │ ├── sys │ │ │ │ ├── AttachController.java │ │ │ │ ├── AuthController.java │ │ │ │ ├── DictController.java │ │ │ │ ├── DictTypeController.java │ │ │ │ ├── LogController.java │ │ │ │ ├── ResController.java │ │ │ │ ├── RestfulController.java │ │ │ │ ├── RoleController.java │ │ │ │ ├── RoleResController.java │ │ │ │ ├── ScheduleJobController.java │ │ │ │ ├── ScheduleJobLogController.java │ │ │ │ └── UserController.java │ │ │ └── work │ │ │ │ └── BacklogController.java │ │ │ ├── dao │ │ │ ├── mapper │ │ │ │ ├── AttachMapper.xml │ │ │ │ ├── BacklogMapper.xml │ │ │ │ ├── DictMapper.xml │ │ │ │ ├── DictTypeMapper.xml │ │ │ │ ├── LogMapper.xml │ │ │ │ ├── ResMapper.xml │ │ │ │ ├── RoleMapper.xml │ │ │ │ ├── RoleResMapper.xml │ │ │ │ ├── ScheduleJobLogMapper.xml │ │ │ │ ├── ScheduleJobMapper.xml │ │ │ │ ├── UserMapper.xml │ │ │ │ └── UserRoleMapper.xml │ │ │ ├── sys │ │ │ │ ├── AttachMapper.java │ │ │ │ ├── DictMapper.java │ │ │ │ ├── DictTypeMapper.java │ │ │ │ ├── LogMapper.java │ │ │ │ ├── ResMapper.java │ │ │ │ ├── RoleMapper.java │ │ │ │ ├── RoleResMapper.java │ │ │ │ ├── ScheduleJobLogMapper.java │ │ │ │ ├── ScheduleJobMapper.java │ │ │ │ ├── UserMapper.java │ │ │ │ └── UserRoleMapper.java │ │ │ └── work │ │ │ │ └── BacklogMapper.java │ │ │ ├── entity │ │ │ ├── sys │ │ │ │ ├── Attach.java │ │ │ │ ├── Dict.java │ │ │ │ ├── DictType.java │ │ │ │ ├── Log.java │ │ │ │ ├── Res.java │ │ │ │ ├── Role.java │ │ │ │ ├── RoleRes.java │ │ │ │ ├── ScheduleJob.java │ │ │ │ ├── ScheduleJobLog.java │ │ │ │ ├── User.java │ │ │ │ └── UserRole.java │ │ │ └── work │ │ │ │ └── Backlog.java │ │ │ ├── interceptor │ │ │ └── AuthInterceptor.java │ │ │ ├── schedule │ │ │ ├── ScheduleQuartzJob.java │ │ │ ├── ScheduleRunnable.java │ │ │ └── ScheduleUtils.java │ │ │ ├── service │ │ │ ├── impl │ │ │ │ ├── sys │ │ │ │ │ ├── AttachServiceImpl.java │ │ │ │ │ ├── AuthServiceImpl.java │ │ │ │ │ ├── DictServiceImpl.java │ │ │ │ │ ├── DictTypeServiceImpl.java │ │ │ │ │ ├── LogServiceImpl.java │ │ │ │ │ ├── ResServiceImpl.java │ │ │ │ │ ├── RoleResServiceImpl.java │ │ │ │ │ ├── RoleServiceImpl.java │ │ │ │ │ ├── ScheduleJobLogServiceImpl.java │ │ │ │ │ ├── ScheduleJobServiceImpl.java │ │ │ │ │ ├── UserRoleServiceImpl.java │ │ │ │ │ └── UserServiceImpl.java │ │ │ │ └── work │ │ │ │ │ └── BacklogServiceImpl.java │ │ │ ├── sys │ │ │ │ ├── IAttachService.java │ │ │ │ ├── IDictService.java │ │ │ │ ├── IDictTypeService.java │ │ │ │ ├── ILogService.java │ │ │ │ ├── IResService.java │ │ │ │ ├── IRoleResService.java │ │ │ │ ├── IRoleService.java │ │ │ │ ├── IUserRoleService.java │ │ │ │ ├── IUserService.java │ │ │ │ ├── ScheduleJobLogService.java │ │ │ │ └── ScheduleJobService.java │ │ │ └── work │ │ │ │ └── IBacklogService.java │ │ │ └── vo │ │ │ ├── Operator.java │ │ │ └── RoleMenuPerms.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application-test.yml │ │ ├── application.yml │ │ ├── db │ │ └── migration │ │ │ ├── V1_0_1__init.sql │ │ │ ├── V1_0_2__backlog.sql │ │ │ └── V1_0_3__schedule.sql │ │ ├── dev │ │ └── logback.xml │ │ ├── prod │ │ └── logback.xml │ │ └── test │ │ └── logback.xml │ └── test │ └── java │ └── WebApplicationTests.java ├── ffast-core ├── pom.xml └── src │ └── main │ ├── java │ └── cn │ │ └── ffast │ │ └── core │ │ ├── annotations │ │ ├── CrudConfig.java │ │ ├── Log.java │ │ ├── Logined.java │ │ └── Permission.java │ │ ├── aop │ │ ├── LogAspect.java │ │ └── LogPoint.java │ │ ├── auth │ │ ├── JwtUtils.java │ │ ├── OperatorBase.java │ │ └── OperatorUtils.java │ │ ├── constant │ │ ├── ResultCode.java │ │ └── ScheduleStatus.java │ │ ├── filter │ │ └── CrossFilter.java │ │ ├── handler │ │ ├── BaseEntityHandler.java │ │ └── GlobalExceptionHandler.java │ │ ├── interceptor │ │ └── BaseAuthInterceptor.java │ │ ├── redis │ │ ├── GenericMsgpackRedisSerializer.java │ │ ├── RedisCacheUtils.java │ │ └── RedisSerializerType.java │ │ ├── service │ │ └── CaptchaService.java │ │ ├── support │ │ ├── BaseController.java │ │ ├── BaseCrudController.java │ │ ├── BaseEntity.java │ │ ├── BaseService.java │ │ ├── CrudServiceImpl.java │ │ ├── IAuthService.java │ │ └── ICrudService.java │ │ ├── utils │ │ ├── AnnotationUtils.java │ │ ├── CaptchaUtils.java │ │ ├── CodeUtil.java │ │ ├── CollectionUtils.java │ │ ├── DateUtil.java │ │ ├── FStringUtil.java │ │ ├── FileUtil.java │ │ ├── GzipUtils.java │ │ ├── HttpServletUtils.java │ │ ├── IpUtils.java │ │ ├── Md5Utils.java │ │ ├── PasswordUtil.java │ │ ├── ReflectionUtils.java │ │ ├── SpringContextUtils.java │ │ └── Underline2Camel.java │ │ └── vo │ │ ├── Menu.java │ │ ├── ServiceResult.java │ │ ├── ServiceRowsResult.java │ │ └── Tree.java │ └── resources │ └── font │ └── WellrockSlabBold.ttf ├── ffast-generator ├── pom.xml └── src │ ├── main │ └── java │ │ └── cn │ │ └── ffast │ │ └── generator │ │ ├── controller │ │ └── TableController.java │ │ ├── dao │ │ └── TableDao.java │ │ └── entity │ │ ├── Column.java │ │ └── Table.java │ └── test │ ├── java │ └── MpGenerator.java │ └── resources │ └── templates │ ├── controller.java.vm │ ├── entity.java.vm │ ├── mapper.java.vm │ ├── mapper.xml.vm │ ├── service.java.vm │ ├── serviceImpl.java.vm │ └── vue.vm ├── ffast-parent └── pom.xml └── ffast.iml /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | /.idea/ 3 | /ffast-core/target/ 4 | /ffast-admin/target/ 5 | /ffast-generator/target/ 6 | .mvn 7 | /*.iml 8 | *.iml 9 | /ffast-generator/*.iml 10 | /ffast-admin/*.iml 11 | /ffast-parent/*.iml 12 | /ffast.iml 13 | /ffast-admin/ffast-admin.iml 14 | /ffast-core/ffast-core.iml 15 | /ffast-generator/ffast-generator.iml 16 | /ffast-admin/src/main/resources/application-private.yml 17 | /ffast-admin/src/main/resources/application-private-dev.yml 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-present Ffast 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ffast-admin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | cn.ffast 7 | ffast-admin 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | ffast-admin 12 | ffast project for Spring Boot 13 | 14 | 15 | ffast-parent 16 | cn.ffast 17 | 1.0-SNAPSHOT 18 | ../ffast-parent/pom.xml 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-test 26 | test 27 | 28 | 29 | 30 | com.alibaba 31 | druid-spring-boot-starter 32 | ${druid.version} 33 | 34 | 35 | 36 | cn.ffast 37 | ffast-core 38 | 1.0-SNAPSHOT 39 | 40 | 41 | 42 | cn.ffast 43 | ffast-generator 44 | 1.0-SNAPSHOT 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-cache 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-devtools 55 | true 56 | 57 | 58 | 59 | org.flywaydb 60 | flyway-core 61 | 62 | 63 | 64 | org.quartz-scheduler 65 | quartz 66 | ${quartz.version} 67 | 68 | 69 | com.mchange 70 | c3p0 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | ffast 80 | 81 | 82 | org.springframework.boot 83 | spring-boot-maven-plugin 84 | 85 | true 86 | 87 | 88 | 89 | 90 | 91 | 92 | src/main/java 93 | 94 | **/*.xml 95 | 96 | true 97 | 98 | 99 | src/main/resources 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/WebApplication.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @SpringBootApplication 10 | @ComponentScan(basePackages ={"cn.ffast.*"}) 11 | @MapperScan(basePackages="cn.ffast.**.dao.**") 12 | /** 13 | * sprint boot 启动入口 14 | * idea的话请把项目添加为maven项目即可启动 15 | */ 16 | public class WebApplication { 17 | public static void main(String[] args) { 18 | SpringApplication.run(WebApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/config/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.config; 2 | 3 | import cn.ffast.web.interceptor.AuthInterceptor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | @Configuration 10 | public class InterceptorConfig implements WebMvcConfigurer { 11 | 12 | @Bean 13 | public AuthInterceptor authInterceptor() { 14 | return new AuthInterceptor(); 15 | } 16 | 17 | @Override 18 | public void addInterceptors(InterceptorRegistry registry) { 19 | registry.addInterceptor(authInterceptor()).addPathPatterns("/api/**"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.config; 2 | 3 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | 9 | @EnableTransactionManagement 10 | @Configuration 11 | @MapperScan(basePackages={"cn.ffast.**.dao.**"}) 12 | public class MybatisPlusConfig { 13 | 14 | /** 15 | * 分页插件 16 | */ 17 | @Bean 18 | public PaginationInterceptor paginationInterceptor() { 19 | return new PaginationInterceptor(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller; 2 | 3 | import cn.ffast.core.annotations.Logined; 4 | import cn.ffast.core.auth.OperatorBase; 5 | import cn.ffast.core.redis.RedisCacheUtils; 6 | import cn.ffast.core.auth.OperatorUtils; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import javax.annotation.Resource; 12 | 13 | @RestController 14 | public class TestController { 15 | @Resource 16 | RedisCacheUtils redisCacheUtils; 17 | @Resource 18 | OperatorUtils operatorUtils; 19 | 20 | @GetMapping("/test") 21 | @Logined 22 | public Object test() { 23 | return operatorUtils.getUser(OperatorBase.class); 24 | } 25 | 26 | @GetMapping("/test2") 27 | public Object test2() { 28 | return "test2"; 29 | } 30 | 31 | @GetMapping("/test3") 32 | public Object test4() { 33 | return 1/0; 34 | } 35 | 36 | 37 | // @GetMapping("/getCache") 38 | // public Object getCache() { 39 | // List result = redisCacheUtils.getCacheObject("list_cache", new ArrayList>(0).getClass()); 40 | // return result; 41 | // } 42 | // 43 | // @GetMapping("/setCache") 44 | // public Object setCache() { 45 | // List list = new ArrayList<>(); 46 | // for (int i = 0; i < 100; i++) { 47 | // Map map = new HashMap(); 48 | // map.put("id", i); 49 | // map.put("name", "index=" + i); 50 | // list.add(map); 51 | // } 52 | // return redisCacheUtils.setCacheObject("list_cache", list, RedisSerializerType.Msgpack); 53 | // } 54 | // 55 | // @GetMapping("/testCache") 56 | // public Object testCache() { 57 | // List list = new ArrayList<>(); 58 | // for (int i = 0; i < 10000; i++) { 59 | // Map map = new HashMap(); 60 | // map.put("id", i); 61 | // map.put("name", "index=" + i); 62 | // map.put("sex", "man"); 63 | // map.put("abc", "cvb"); 64 | // list.add(map); 65 | // } 66 | // redisCacheUtils.setCacheObject("list_cache2", list, RedisSerializerType.FastJSON); 67 | // 68 | // 69 | // redisCacheUtils.setCacheObject("list_cache2", list, RedisSerializerType.FastJSON); 70 | // redisCacheUtils.getCacheObject("list_cache2", new ArrayList>(0).getClass(), RedisSerializerType.FastJSON); 71 | // 72 | // redisCacheUtils.setCacheObject("list_cache3", list, RedisSerializerType.JackJson); 73 | // redisCacheUtils.getCacheObject("list_cache3", new ArrayList>(0).getClass(), RedisSerializerType.JackJson); 74 | // 75 | // redisCacheUtils.setCacheObject("list_cache1", list, RedisSerializerType.Msgpack); 76 | // redisCacheUtils.getCacheObject("list_cache1", new ArrayList>(0).getClass(), RedisSerializerType.Msgpack); 77 | // 78 | // return null; 79 | // } 80 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/AttachController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.Log; 4 | import cn.ffast.core.annotations.Logined; 5 | import cn.ffast.core.annotations.Permission; 6 | import cn.ffast.core.vo.ServiceResult; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import javax.annotation.Resource; 12 | import javax.servlet.ServletOutputStream; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import cn.ffast.web.entity.sys.Attach; 16 | import cn.ffast.web.service.sys.IAttachService; 17 | import cn.ffast.core.support.BaseCrudController; 18 | import org.springframework.web.bind.annotation.RequestMethod; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | import org.springframework.web.multipart.MultipartFile; 21 | 22 | 23 | import java.io.*; 24 | 25 | /** 26 | * @description: 系统_附件数据接口 27 | * @copyright: 28 | * @createTime: 2017-09-27 15:47:59 29 | * @author: dzy 30 | * @version: 1.0 31 | */ 32 | @Controller 33 | @RequestMapping("/api/sys/attach") 34 | @Logined 35 | @Permission(value = "attach") 36 | @Log("附件管理") 37 | public class AttachController extends BaseCrudController { 38 | 39 | private static Logger logger = LoggerFactory.getLogger(AttachController.class); 40 | 41 | @Resource 42 | private IAttachService service; 43 | 44 | @Override 45 | protected IAttachService getService() { 46 | return this.service; 47 | } 48 | 49 | @Override 50 | protected Logger getLogger() { 51 | return logger; 52 | } 53 | 54 | 55 | /** 56 | * 获得图片 57 | * @param attachId 58 | * @param response 59 | */ 60 | @RequestMapping(value = "/getImg", method = RequestMethod.GET ) 61 | public void getImg(Long id, HttpServletResponse response) { 62 | File file = service.getAttach(id); 63 | if (file != null) { 64 | try { 65 | ServletOutputStream outputStream = response.getOutputStream(); 66 | InputStream in = new FileInputStream(file.getPath()); 67 | BufferedOutputStream bout = new BufferedOutputStream(outputStream); 68 | byte[] b = new byte[(int)file.length()]; 69 | int len = in.read(b); 70 | while (len > 0) { 71 | bout.write(b, 0, len); 72 | len = in.read(b); 73 | } 74 | bout.close(); 75 | in.close(); 76 | outputStream.flush(); 77 | } catch (FileNotFoundException e) { 78 | e.printStackTrace(); 79 | } catch (IOException e) { 80 | e.printStackTrace(); 81 | } 82 | } 83 | } 84 | 85 | @RequestMapping(value = "/uploadImg", method = RequestMethod.POST) 86 | @ResponseBody 87 | public Object uploadImg(MultipartFile file, HttpServletRequest request) { 88 | return service.uploadImg("ffast", file); 89 | } 90 | 91 | /** 92 | * 删除垃圾文件 93 | * @return 94 | */ 95 | @RequestMapping(value = "/deleteRubbish", method = RequestMethod.POST) 96 | @ResponseBody 97 | public Object deleteRubish(){ 98 | ServiceResult result = new ServiceResult(false); 99 | result = service.deleteRubbish(); 100 | return result; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/AuthController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.Logined; 4 | import cn.ffast.core.annotations.Permission; 5 | import cn.ffast.core.auth.OperatorUtils; 6 | import cn.ffast.core.support.BaseController; 7 | import cn.ffast.core.support.IAuthService; 8 | import cn.ffast.core.service.CaptchaService; 9 | import cn.ffast.core.vo.ServiceResult; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.annotation.Resource; 18 | import javax.servlet.http.HttpServletResponse; 19 | 20 | /** 21 | * @description: 用户登录 22 | * @copyright: 23 | * @createTime: 2017/9/5 15:17 24 | * @author:dzy 25 | * @version:1.0 26 | */ 27 | @Controller 28 | @RequestMapping("/api/auth") 29 | public class AuthController extends BaseController { 30 | private static Logger logger = LoggerFactory.getLogger(AuthController.class); 31 | 32 | @Resource 33 | private CaptchaService captchaService; 34 | 35 | @Resource 36 | IAuthService authService; 37 | 38 | /*** 39 | * 用户登录 40 | * @return 41 | */ 42 | @RequestMapping(value = "/login") 43 | @ResponseBody 44 | public ServiceResult login(String username, String password, String captcha) { 45 | return authService.login(username, password, captcha, true); 46 | } 47 | 48 | 49 | /** 50 | * 是否登录 51 | * 52 | * @return 53 | */ 54 | @RequestMapping(value = "/isLogined") 55 | @ResponseBody 56 | @Logined 57 | public ServiceResult isLogined() { 58 | return new ServiceResult(true); 59 | } 60 | 61 | 62 | /** 63 | * 退出登录 64 | * 65 | * @return 66 | */ 67 | @RequestMapping(value = "/logout") 68 | @ResponseBody 69 | public ServiceResult logout() { 70 | return authService.logout(getRequest().getHeader("token")); 71 | } 72 | 73 | /** 74 | * 验证码获取 75 | * 76 | * @return 77 | */ 78 | @RequestMapping(value = "/captcha") 79 | public void captcha(HttpServletResponse response) { 80 | captchaService.buildCaptcha(response); 81 | } 82 | 83 | /** 84 | * 获得菜单权限 85 | * 86 | * @param roleName 指定登录角色名的菜单权限(为空则默认角色) 87 | * @return 88 | */ 89 | @RequestMapping(value = "/getMenuPerms") 90 | @ResponseBody 91 | public ServiceResult roleMenuPerms(String roleName) { 92 | return authService.getMenuPermsByRoleName(roleName); 93 | } 94 | 95 | 96 | @Override 97 | protected Logger getLogger() { 98 | return logger; 99 | } 100 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/DictController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.CrudConfig; 4 | import cn.ffast.core.annotations.Log; 5 | import cn.ffast.core.annotations.Logined; 6 | import cn.ffast.core.annotations.Permission; 7 | import cn.ffast.core.vo.ServiceResult; 8 | import cn.ffast.web.entity.sys.Dict; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import javax.annotation.Resource; 15 | 16 | import cn.ffast.web.service.sys.IDictService; 17 | 18 | import cn.ffast.core.support.BaseCrudController; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | 21 | /** 22 | * @description: 字典数据接口 23 | * @copyright: 24 | * @createTime: 2017-09-13 09:14:49 25 | * @author: dzy 26 | * @version: 1.0 27 | */ 28 | @Logined 29 | @Controller 30 | @RequestMapping("/api/sys/dict") 31 | @Permission(value = "dict") 32 | @Log("字典") 33 | public class DictController extends BaseCrudController { 34 | 35 | private static Logger logger = LoggerFactory.getLogger(DictController.class); 36 | 37 | @Resource 38 | private IDictService service; 39 | 40 | @Override 41 | protected IDictService getService() { 42 | return this.service; 43 | } 44 | 45 | @Override 46 | protected Logger getLogger() { 47 | return logger; 48 | } 49 | 50 | 51 | /** 52 | * 获得字典 53 | * 54 | * @param type 55 | * @param isName 56 | * @return 57 | */ 58 | @ResponseBody 59 | @RequestMapping(value = "/get") 60 | public ServiceResult getDict(String type, Boolean isName) { 61 | return getService().getDict(type, isName); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/DictTypeController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.CrudConfig; 4 | import cn.ffast.core.annotations.Log; 5 | import cn.ffast.core.annotations.Logined; 6 | import cn.ffast.core.annotations.Permission; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import javax.annotation.Resource; 12 | import cn.ffast.web.entity.sys.DictType; 13 | import cn.ffast.web.service.sys.IDictTypeService; 14 | 15 | import cn.ffast.core.support.BaseCrudController; 16 | 17 | /** 18 | * @description: 基础字典类型数据接口 19 | * @copyright: 20 | * @createTime: 2017-09-13 09:14:49 21 | * @author: dzy 22 | * @version: 1.0 23 | */ 24 | @Controller 25 | @RequestMapping("/api/sys/dictType") 26 | @Logined 27 | @Permission(value = "dict") 28 | @Log("字典分类") 29 | public class DictTypeController extends BaseCrudController { 30 | 31 | private static Logger logger = LoggerFactory.getLogger(DictTypeController.class); 32 | 33 | @Resource 34 | private IDictTypeService service; 35 | 36 | @Override 37 | protected IDictTypeService getService() { 38 | return this.service; 39 | } 40 | 41 | @Override 42 | protected Logger getLogger() { 43 | return logger; 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/LogController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.Logined; 4 | import cn.ffast.core.annotations.Permission; 5 | import cn.ffast.web.entity.sys.Log; 6 | import cn.ffast.web.service.sys.ILogService; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.slf4j.Logger; 11 | import javax.annotation.Resource; 12 | 13 | import cn.ffast.core.support.BaseCrudController; 14 | 15 | /** 16 | * @description: 操作日志表数据接口 17 | * @copyright: 18 | * @createTime: 2017-11-14 14:48:11 19 | * @author: dzy 20 | * @version: 1.0 21 | */ 22 | @Controller 23 | @RequestMapping("/api/sys/log") 24 | @Logined 25 | @Permission(value = "sysLog") 26 | public class LogController extends BaseCrudController { 27 | 28 | private static Logger logger = LoggerFactory.getLogger(ResController.class); 29 | 30 | @Resource 31 | private ILogService service; 32 | 33 | @Override 34 | protected ILogService getService() { 35 | return this.service; 36 | } 37 | 38 | @Override 39 | protected Logger getLogger() { 40 | return logger; 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/ResController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.CrudConfig; 4 | import cn.ffast.core.annotations.Log; 5 | import cn.ffast.core.annotations.Logined; 6 | import cn.ffast.core.annotations.Permission; 7 | import cn.ffast.core.vo.ServiceResult; 8 | import cn.ffast.web.entity.sys.Res; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import javax.annotation.Resource; 15 | 16 | import cn.ffast.web.service.sys.IResService; 17 | import cn.ffast.core.support.BaseCrudController; 18 | 19 | /** 20 | * @description: 系统_资源数据接口 21 | * @copyright: 22 | * @createTime: 2017-09-13 09:14:49 23 | * @author: dzy 24 | * @version: 1.0 25 | */ 26 | @Controller 27 | @RequestMapping("/api/sys/res") 28 | @CrudConfig(updateAllColumn = true, retrievePermission = "") 29 | @Permission(value = "res") 30 | @Logined 31 | @Log("菜单权限") 32 | public class ResController extends BaseCrudController { 33 | 34 | private static Logger logger = LoggerFactory.getLogger(ResController.class); 35 | 36 | @Resource 37 | private IResService service; 38 | 39 | @Override 40 | protected IResService getService() { 41 | return this.service; 42 | } 43 | 44 | @Override 45 | protected Logger getLogger() { 46 | return logger; 47 | } 48 | 49 | 50 | @Override 51 | protected ServiceResult createBefore(Res m) { 52 | // Demo限制 可以删除 53 | return new ServiceResult(false).setMessage("暂时关闭该功能!"); 54 | } 55 | 56 | @Override 57 | protected ServiceResult deleteBefore(String ids) { 58 | // Demo限制 可以删除 59 | return new ServiceResult(false).setMessage("暂时关闭该功能!"); 60 | } 61 | 62 | @Override 63 | protected ServiceResult updateBefore(Res m) { 64 | // Demo限制 可以删除 65 | return new ServiceResult(false).setMessage("暂时关闭该功能!"); 66 | } 67 | 68 | @Override 69 | protected void createAfter(Res m, ServiceResult result) { 70 | if ("true".equals(getRequestParamString("addBaseCrud")) && m.getResType() == 1) { 71 | service.addBaseCrud(m); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/RestfulController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | 4 | import cn.ffast.core.annotations.Logined; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import org.springframework.web.method.HandlerMethod; 8 | import org.springframework.web.servlet.mvc.method.RequestMappingInfo; 9 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; 10 | import javax.annotation.Resource; 11 | import java.util.*; 12 | 13 | import static java.awt.SystemColor.info; 14 | 15 | /** 16 | * @description: 接口列表 17 | * @copyright: 18 | * @createTime: 2017/11/10 10:34 19 | * @author:dzy 20 | * @version:1.0 21 | */ 22 | @RestController 23 | @RequestMapping("/api/restful") 24 | @Logined 25 | public class RestfulController { 26 | @Resource 27 | private RequestMappingHandlerMapping handlerMapping; 28 | 29 | /** 30 | * 获得所有api接口 31 | * @return 32 | */ 33 | @RequestMapping("/list") 34 | public Object list() { 35 | Map map = this.handlerMapping.getHandlerMethods(); 36 | List result = new ArrayList<>(); 37 | Iterator> iterator = map.entrySet().iterator(); 38 | while (iterator.hasNext()) { 39 | Map.Entry entry = (Map.Entry) iterator.next(); 40 | RequestMappingInfo requestMappingInfo = ((RequestMappingInfo) entry.getKey()); 41 | Map obj = new HashMap(); 42 | for (String url : requestMappingInfo.getPatternsCondition().getPatterns()) { 43 | obj.put("url", url); 44 | } 45 | HandlerMethod method = map.get(requestMappingInfo); 46 | // RequestMapping requestMapping = method.getMethodAnnotation(RequestMapping.class); 47 | result.add(obj); 48 | } 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/RoleController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | 4 | import cn.ffast.core.annotations.CrudConfig; 5 | import cn.ffast.core.annotations.Log; 6 | import cn.ffast.core.annotations.Logined; 7 | import cn.ffast.core.annotations.Permission; 8 | import cn.ffast.core.vo.ServiceResult; 9 | import cn.ffast.web.entity.sys.Role; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | import javax.annotation.Resource; 16 | 17 | import cn.ffast.web.service.sys.IRoleService; 18 | import cn.ffast.core.support.BaseCrudController; 19 | 20 | 21 | /** 22 | * @description: 系统_角色数据接口 23 | * @copyright: 24 | * @createTime: 2017-09-13 09:14:49 25 | * @author: dzy 26 | * @version: 1.0 27 | */ 28 | @Controller 29 | @RequestMapping("/api/sys/role") 30 | @Logined 31 | @Permission(value = "role") 32 | @Log("角色管理") 33 | public class RoleController extends BaseCrudController { 34 | 35 | private static Logger logger = LoggerFactory.getLogger(RoleController.class); 36 | 37 | @Resource 38 | private IRoleService service; 39 | 40 | @Override 41 | protected IRoleService getService() { 42 | return this.service; 43 | } 44 | 45 | @Override 46 | protected Logger getLogger() { 47 | return logger; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/RoleResController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | 4 | import cn.ffast.core.annotations.Log; 5 | import cn.ffast.core.annotations.Logined; 6 | import cn.ffast.core.annotations.Permission; 7 | import cn.ffast.core.auth.OperatorUtils; 8 | import cn.ffast.web.service.sys.IResService; 9 | import cn.ffast.core.vo.ServiceResult; 10 | import cn.ffast.web.entity.sys.RoleRes; 11 | import cn.ffast.core.vo.ServiceRowsResult; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | 17 | import javax.annotation.Resource; 18 | 19 | import cn.ffast.web.service.sys.IRoleResService; 20 | 21 | import cn.ffast.core.support.BaseCrudController; 22 | import org.springframework.web.bind.annotation.ResponseBody; 23 | 24 | /** 25 | * @description: 系统_角色资源数据接口 26 | * @copyright: 27 | * @createTime: 2017-09-13 09:14:49 28 | * @author: dzy 29 | * @version: 1.0 30 | */ 31 | @Controller 32 | @RequestMapping("/api/sys/roleRes") 33 | @Logined 34 | @Permission(value = "roleRes") 35 | @Log("角色资源") 36 | public class RoleResController extends BaseCrudController { 37 | 38 | private static Logger logger = LoggerFactory.getLogger(RoleResController.class); 39 | 40 | @Resource 41 | private IRoleResService service; 42 | @Resource 43 | private IResService resService; 44 | 45 | @Override 46 | protected IRoleResService getService() { 47 | return this.service; 48 | } 49 | 50 | @Override 51 | protected Logger getLogger() { 52 | return logger; 53 | } 54 | 55 | @Resource 56 | private OperatorUtils operatorUtils; 57 | 58 | /** 59 | * 保存角色资源菜单 60 | * 61 | * @param ids 62 | * @param roleId 63 | * @return 64 | */ 65 | @ResponseBody 66 | @RequestMapping(value = "/saveRes") 67 | public ServiceResult saveRes(String ids, Long roleId) { 68 | // Demo限制(可以删除):不允许修改超级管理员账户 69 | if (roleId.intValue() == 1) { 70 | return new ServiceResult(false).setMessage("不能修改超级管理员账户"); 71 | } 72 | return service.saveRes(ids, roleId); 73 | } 74 | 75 | /** 76 | * 获得所有资源菜单与角色所拥有的资源列表 77 | * 78 | * @param roleId 79 | * @return 80 | */ 81 | @ResponseBody 82 | @RequestMapping(value = "/getRoleRes") 83 | public ServiceResult getRoleResIds(Long roleId) { 84 | ServiceRowsResult result = new ServiceRowsResult(false); 85 | result.addData("rows", resService.selectList(null, new String[]{"id", "name", "parent_id", "res_type"})); 86 | result.addData("selected", service.getRoleResIds(roleId)); 87 | result.setSuccess(true); 88 | return result; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/ScheduleJobController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.sys; 2 | 3 | import cn.ffast.core.annotations.Log; 4 | import cn.ffast.core.annotations.Permission; 5 | import cn.ffast.core.support.BaseCrudController; 6 | import cn.ffast.core.vo.ServiceResult; 7 | import cn.ffast.web.entity.sys.ScheduleJob; 8 | import cn.ffast.web.service.sys.ScheduleJobService; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.web.bind.annotation.*; 12 | import javax.annotation.Resource; 13 | /** 14 | * @description: 定时任务 15 | * @copyright: 16 | * @createTime: 2018/6/29 15:23 17 | * @author:dzy 18 | * @version:1.0 19 | */ 20 | @RestController 21 | @RequestMapping("/api/sys/schedule") 22 | @Permission("schedule") 23 | public class ScheduleJobController extends BaseCrudController { 24 | private static Logger logger = LoggerFactory.getLogger(ScheduleJobController.class); 25 | @Resource 26 | private ScheduleJobService service; 27 | 28 | /** 29 | * 定时任务信息 30 | */ 31 | @GetMapping("/info/{id}") 32 | @Permission("info") 33 | public ServiceResult info(@PathVariable("id") Long id) { 34 | ScheduleJob schedule = service.selectById(id); 35 | return new ServiceResult(true).addData("obj", schedule); 36 | } 37 | 38 | 39 | /** 40 | * 立即执行任务 41 | */ 42 | @Log("立即执行任务") 43 | @PostMapping("/run") 44 | @Permission("run") 45 | public ServiceResult ServiceResultun(Long[] ids) { 46 | service.run(ids); 47 | return new ServiceResult(true); 48 | } 49 | 50 | /** 51 | * 暂停定时任务 52 | */ 53 | @Log("暂停定时任务") 54 | @PostMapping("/pause") 55 | @Permission("pause") 56 | public ServiceResult pause(Long[] ids) { 57 | service.pause(ids); 58 | return new ServiceResult(true); 59 | } 60 | 61 | /** 62 | * 恢复定时任务 63 | */ 64 | @Log("恢复定时任务") 65 | @PostMapping("/resume") 66 | @Permission("resume") 67 | public ServiceResult ServiceResultesume(Long[] ids) { 68 | service.resume(ids); 69 | return new ServiceResult(true); 70 | } 71 | 72 | @Override 73 | protected ScheduleJobService getService() { 74 | return service; 75 | } 76 | 77 | @Override 78 | protected Logger getLogger() { 79 | return logger; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/sys/ScheduleJobLogController.java: -------------------------------------------------------------------------------- 1 | 2 | package cn.ffast.web.controller.sys; 3 | 4 | import cn.ffast.core.annotations.CrudConfig; 5 | import cn.ffast.core.support.BaseCrudController; 6 | import cn.ffast.core.vo.ServiceResult; 7 | 8 | import cn.ffast.web.entity.sys.ScheduleJobLog; 9 | import cn.ffast.web.service.sys.ScheduleJobLogService; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.web.bind.annotation.*; 13 | import javax.annotation.Resource; 14 | 15 | /** 16 | * @description: 定时任务日志 17 | * @copyright: 18 | * @createTime: 2018/6/29 15:23 19 | * @author:dzy 20 | * @version:1.0 21 | */ 22 | @RestController 23 | @RequestMapping("/api/sys/scheduleLog") 24 | @CrudConfig(isAsc = false) 25 | public class ScheduleJobLogController extends BaseCrudController { 26 | private static Logger logger = LoggerFactory.getLogger(ScheduleJobLogController.class); 27 | @Resource 28 | private ScheduleJobLogService scheduleJobLogService; 29 | 30 | 31 | /** 32 | * 定时任务日志信息 33 | */ 34 | @GetMapping("/info/{id}") 35 | public ServiceResult info(@PathVariable("id") Long id) { 36 | ScheduleJobLog log = scheduleJobLogService.selectById(id); 37 | 38 | return new ServiceResult(true).addData("obj", log); 39 | } 40 | 41 | @Override 42 | protected ScheduleJobLogService getService() { 43 | return scheduleJobLogService; 44 | } 45 | 46 | @Override 47 | protected Logger getLogger() { 48 | return logger; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/controller/work/BacklogController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.controller.work; 2 | 3 | 4 | import cn.ffast.core.annotations.CrudConfig; 5 | import cn.ffast.core.annotations.Logined; 6 | import cn.ffast.core.support.BaseCrudController; 7 | import cn.ffast.web.entity.work.Backlog; 8 | import cn.ffast.web.service.work.IBacklogService; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import javax.annotation.Resource; 15 | 16 | /** 17 | * @description: 待办事项数据接口 18 | * @copyright: 19 | * @createTime: 2018-06-09 11:20:16 20 | * @author: dzy 21 | * @version: 1.0 22 | */ 23 | @Controller 24 | @RequestMapping("/api/work/backlog") 25 | @CrudConfig(sortField = "start_time",isAsc = true) 26 | @Logined 27 | public class BacklogController extends BaseCrudController { 28 | 29 | private static Logger logger = LoggerFactory.getLogger(BacklogController.class); 30 | 31 | @Resource 32 | private IBacklogService service; 33 | 34 | @Override 35 | protected IBacklogService getService() { 36 | return this.service; 37 | } 38 | 39 | @Override 40 | protected Logger getLogger() { 41 | return logger; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/DictMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | select a.id,a.name 21 | FROM t_sys_dict a 22 | LEFT JOIN t_sys_dict_type b ON a.dict_type_id=b.id 23 | 24 | 25 | AND b.identity =#{identity} 26 | 27 | 28 | AND b.name = #{name} 29 | 30 | 31 | ORDER BY a.weight 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/DictTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/LogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | a.id,a.content, a.operation, a.create_time AS createTime, a.creator_id AS creatorId 18 | 19 | 20 | 21 | select b.name AS creatorName, 22 | 23 | from t_sys_log a left join t_sys_user b on b.id=a.creator_id 24 | 25 | 26 | AND a.id = #{id} 27 | 28 | 29 | AND a.creator_id = #{creatorId} 30 | 31 | 32 | AND cast(a.create_time as date) = #{createTime} 33 | 34 | 35 | AND a.content like '%${content}%' 36 | 37 | 38 | AND a.operation = #{operation} 39 | 40 | 41 | AND b.name like '%${creatorName}%' 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/ResMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/RoleResMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | select a.id,a.name,a.url,a.parent_id,a.icon,a.res_type,a.identity 13 | from t_sys_res a 14 | LEFT JOIN t_sys_role_res b ON b.res_id=a.id 15 | 16 | 17 | a.res_type=#{resType} 18 | 19 | 20 | and b.role_id in(${roleIds}) 21 | 22 | 23 | GROUP BY a.id 24 | ORDER BY a.weight 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/ScheduleJobLogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/ScheduleJobMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | select a.id,a.username,a.name,a.status,a.email,a.tel,a.is_lock,a.lock_time,a.login_count,a.login_failure_count, 28 | a.login_ip,a.login_time,a.creator_id,a.create_time,a.last_modify_time,a.last_modifier_id, 29 | (select group_concat(role_id) from t_sys_user_role where user_id=a.id) as roleId 30 | from t_sys_user a 31 | left join t_sys_user_role b on a.id=b.user_id 32 | 33 | 34 | AND b.role_id in (${roleId}) 35 | 36 | 37 | AND a.username like '%${username}%' 38 | 39 | 40 | AND a.name like '%${name}%' 41 | 42 | 43 | AND a.email like '%${email}%' 44 | 45 | 46 | AND a.tel like '%${tel}%' 47 | 48 | 49 | AND a.status = #{status} 50 | 51 | 52 | AND a.is_lock = #{isLock} 53 | 54 | 55 | AND a.login_ip = #{loginIp} 56 | 57 | 58 | AND a.creator_id = #{creatorId} 59 | 60 | 61 | AND a.login_time = #{loginTime} 62 | 63 | 64 | 65 | 66 | GROUP BY a.id 67 | 68 | 69 | 70 | 71 | UPDATE t_sys_user 72 | 73 | login_count = (case #{bool} when true then ifnull(login_count,0) + 1 else login_count end), 74 | login_time = (case #{bool} when true then now() else login_time end), 75 | login_failure_count = (case #{bool} when false then ifnull(login_failure_count,0) + 1 else 76 | login_failure_count end) 77 | 78 | WHERE username = #{username} 79 | 80 | 81 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/mapper/UserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | SELECT b.id,b.name,b.role,b.description,b.main 15 | FROM t_sys_user_role a 16 | LEFT JOIN t_sys_role b on a.role_id=b.id 17 | WHERE a.user_id=#{userId} 18 | 19 | AND a.role_id=#(roleId) 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/AttachMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Attach; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @description: 系统_附件Mapper接口 12 | * @copyright: 13 | * @createTime: 2017-09-27 15:47:59 14 | * @author: dzy 15 | * @version: 1.0 16 | */ 17 | public interface AttachMapper extends BaseMapper { 18 | /** 19 | * 分页查询 20 | * @param page 21 | * @param attach 22 | * @return 23 | */ 24 | List listByPage(Pagination page, Attach attach); 25 | 26 | 27 | /** 28 | * 更新引用计数 29 | * @param ids 30 | * @param addValue 31 | */ 32 | void updateCount(@Param("ids") String ids, @Param("addValue") Integer addValue); 33 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/DictMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Dict; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @description: 字典Mapper接口 11 | * @copyright: 12 | * @createTime: 2017-09-12 17:18:46 13 | * @author: dzy 14 | * @version: 1.0 15 | */ 16 | public interface DictMapper extends BaseMapper { 17 | /** 18 | * 分页查询 19 | * @param identity 20 | * @param name 21 | * @return 22 | */ 23 | List listDict(@Param("identity") String identity, @Param("name") Long name); 24 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/DictTypeMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.DictType; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | 6 | /** 7 | * @description: 基础字典类型Mapper接口 8 | * @copyright: 9 | * @createTime: 2017-09-12 17:18:46 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface DictTypeMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/LogMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Log; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @description: 操作日志表Mapper接口 11 | * @copyright: 12 | * @createTime: 2017-11-14 14:48:11 13 | * @author: dzy 14 | * @version: 1.0 15 | */ 16 | public interface LogMapper extends BaseMapper { 17 | /** 18 | * 分页查询 19 | * @param page 20 | * @param log 21 | * @return 22 | */ 23 | List listByPage(Pagination page, Log log); 24 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/ResMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Res; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | 6 | /** 7 | * @description: 系统_资源Mapper接口 8 | * @copyright: 9 | * @createTime: 2017年08月31日 09:49:42 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface ResMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Role; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | 6 | /** 7 | * @description: 系统_角色Mapper接口 8 | * @copyright: 9 | * @createTime: 2017年08月31日 09:49:42 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface RoleMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/RoleResMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Res; 4 | import cn.ffast.web.entity.sys.RoleRes; 5 | import com.baomidou.mybatisplus.mapper.BaseMapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @description: 系统_角色资源Mapper接口 12 | * @copyright: 13 | * @createTime: 2017年08月31日 09:49:42 14 | * @author: dzy 15 | * @version: 1.0 16 | */ 17 | public interface RoleResMapper extends BaseMapper { 18 | /** 19 | * 根据角色id获得资源列表 20 | * @param roleId 21 | * @param resType 22 | * @return 23 | */ 24 | List listByRoleId(@Param("roleIds") String roleIds, @Param("resType") Integer resType); 25 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/ScheduleJobLogMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.ScheduleJobLog; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | /** 9 | * @description: 定时任务日志 10 | * @copyright: 11 | * @createTime: 2017年08月31日 09:49:42 12 | * @author: dzy 13 | * @version: 1.0 14 | */ 15 | public interface ScheduleJobLogMapper extends BaseMapper { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/ScheduleJobMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.ScheduleJob; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @description: 定时任务 12 | * @copyright: 13 | * @createTime: 2017年08月31日 09:49:42 14 | * @author: dzy 15 | * @version: 1.0 16 | */ 17 | 18 | public interface ScheduleJobMapper extends BaseMapper { 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/UserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.User; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @description: 系统_用户Mapper接口 13 | * @copyright: 14 | * @createTime: 2017年08月31日 09:49:42 15 | * @author: dzy 16 | * @version: 1.0 17 | */ 18 | 19 | public interface UserMapper extends BaseMapper { 20 | /** 21 | * 分页查询 22 | * @param page 23 | * @param user 24 | * @return 25 | */ 26 | List listByPage(Pagination page, User user); 27 | 28 | /** 29 | * 根据登录结果更新登录次数时间信息 30 | * ct 31 | */ 32 | void updateLoginResult(@Param("username") String username, @Param("bool") Boolean bool); 33 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/sys/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.sys; 2 | 3 | import cn.ffast.web.entity.sys.Role; 4 | import cn.ffast.web.entity.sys.UserRole; 5 | import com.baomidou.mybatisplus.mapper.BaseMapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @description: 系统_用户角色Mapper接口 12 | * @copyright: 13 | * @createTime: 2017年08月31日 09:49:42 14 | * @author: dzy 15 | * @version: 1.0 16 | */ 17 | public interface UserRoleMapper extends BaseMapper { 18 | /** 19 | * 根据用户id获得角色列表 20 | * @param userId 21 | * @param roleId 22 | * @return 23 | */ 24 | List listByUserId(@Param("userId") Long userId, @Param("roleId") Long roleId); 25 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/dao/work/BacklogMapper.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.dao.work; 2 | 3 | 4 | import cn.ffast.web.entity.work.Backlog; 5 | import com.baomidou.mybatisplus.mapper.BaseMapper; 6 | 7 | /** 8 | * @description: 待办事项Mapper接口 9 | * @copyright: 10 | * @createTime: 2018-06-09 11:20:16 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | public interface BacklogMapper extends BaseMapper { 15 | 16 | } -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/Attach.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import cn.ffast.core.support.BaseEntity; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | 7 | /** 8 | * @description: 系统_附件 9 | * @copyright: 10 | * @createTime: 2017-09-27 15:47:59 11 | * @author: lxb 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_attach") 15 | public class Attach extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 路径 21 | */ 22 | private String path; 23 | /** 24 | * 文件大小 25 | */ 26 | private Long size; 27 | /** 28 | * 文件后缀 29 | */ 30 | private String extention; 31 | /** 32 | * 引用计数 33 | */ 34 | private Integer count; 35 | /** 36 | * 创建人 37 | */ 38 | @TableField(exist=false) 39 | private String creatorName; 40 | /** 41 | * 判断文件是否存在 42 | */ 43 | @TableField(exist=false) 44 | private String exist; 45 | 46 | public String getPath() { 47 | return path; 48 | } 49 | 50 | public void setPath(String path) { 51 | this.path = path; 52 | } 53 | 54 | public Long getSize() { 55 | return size; 56 | } 57 | 58 | public void setSize(Long size) { 59 | this.size = size; 60 | } 61 | 62 | public String getExtention() { 63 | return extention; 64 | } 65 | 66 | public void setExtention(String extention) { 67 | this.extention = extention; 68 | } 69 | 70 | public String getCreatorName() {return creatorName;} 71 | 72 | public void setCreatorName(String creatorName) {this.creatorName = creatorName;} 73 | 74 | public String getExist() {return exist;} 75 | 76 | public void setExist(String exist) {this.exist = exist;} 77 | 78 | public Integer getCount() { 79 | return count; 80 | } 81 | 82 | public void setCount(Integer count) { 83 | this.count = count; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/Dict.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 字典 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_dict") 15 | public class Dict extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 类型ID 21 | */ 22 | @TableField("dict_type_id") 23 | private Long dictTypeId; 24 | 25 | /** 26 | * 父类ID 27 | */ 28 | @TableField("parent_id") 29 | private Long parentId; 30 | 31 | /** 32 | * 编号 33 | */ 34 | private String code; 35 | /** 36 | * 是否系统内置【是1、否0】 37 | */ 38 | @TableField("is_sys") 39 | private Integer isSys; 40 | /** 41 | * 排序 42 | */ 43 | private Integer weight; 44 | 45 | 46 | /** 47 | * 备注 48 | */ 49 | private String note; 50 | 51 | public Long getDictTypeId() { 52 | return dictTypeId; 53 | } 54 | 55 | public void setDictTypeId(Long dictTypeId) { 56 | this.dictTypeId = dictTypeId; 57 | } 58 | 59 | public String getCode() { 60 | return code; 61 | } 62 | 63 | public void setCode(String code) { 64 | this.code = code; 65 | } 66 | 67 | public Integer getIsSys() { 68 | return isSys; 69 | } 70 | 71 | public void setIsSys(Integer isSys) { 72 | this.isSys = isSys; 73 | } 74 | 75 | 76 | public Integer getWeight() { 77 | return weight; 78 | } 79 | 80 | public void setWeight(Integer weight) { 81 | this.weight = weight; 82 | } 83 | 84 | public Long getParentId() { 85 | return parentId; 86 | } 87 | 88 | public void setParentId(Long parentId) { 89 | this.parentId = parentId; 90 | } 91 | 92 | public String getNote() { 93 | return note; 94 | } 95 | 96 | public void setNote(String note) { 97 | this.note = note; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/DictType.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 基础字典类型 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_dict_type") 15 | public class DictType extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 字典标识符 21 | */ 22 | private String identity; 23 | /** 24 | * 编号 25 | */ 26 | private String code; 27 | /** 28 | * 父类ID 29 | */ 30 | @TableField("parent_id") 31 | private Long parentId; 32 | /** 33 | * 排序 34 | */ 35 | private Integer weight; 36 | 37 | public String getIdentity() { 38 | return identity; 39 | } 40 | 41 | public void setIdentity(String identity) { 42 | this.identity = identity; 43 | } 44 | 45 | public String getCode() { 46 | return code; 47 | } 48 | 49 | public void setCode(String code) { 50 | this.code = code; 51 | } 52 | 53 | public Integer getWeight() { 54 | return weight; 55 | } 56 | 57 | public void setWeight(Integer weight) { 58 | this.weight = weight; 59 | } 60 | 61 | public Long getParentId() { 62 | return parentId; 63 | } 64 | 65 | public void setParentId(Long parentId) { 66 | this.parentId = parentId; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/Log.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import cn.ffast.core.support.BaseEntity; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | 7 | /** 8 | * @description: 操作日志表 9 | * @copyright: 10 | * @createTime: 2017-11-14 14:48:11 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_log") 15 | public class Log extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 日志内容 21 | */ 22 | private String content; 23 | /** 24 | * 用户操作 25 | */ 26 | private String operation; 27 | 28 | /** 29 | * 操作人姓名 30 | */ 31 | @TableField(exist=false) 32 | private String creatorName; 33 | 34 | public String getContent() { 35 | return content; 36 | } 37 | 38 | public void setContent(String content) { 39 | this.content = content; 40 | } 41 | 42 | public String getOperation() { 43 | return operation; 44 | } 45 | 46 | public void setOperation(String operation) { 47 | this.operation = operation; 48 | } 49 | 50 | public String getCreatorName() {return creatorName;} 51 | 52 | public void setCreatorName(String creatorName) {this.creatorName = creatorName;} 53 | } 54 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/Res.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 系统_资源 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_res") 15 | public class Res extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 资源标识符 21 | */ 22 | private String identity; 23 | /** 24 | * 菜单url 25 | */ 26 | private String url; 27 | /** 28 | * 父资源 29 | */ 30 | @TableField("parent_id") 31 | private Long parentId; 32 | /** 33 | * 父路径 34 | */ 35 | @TableField("parent_ids") 36 | private String parentIds; 37 | /** 38 | * 菜单权重 39 | */ 40 | private Integer weight; 41 | /** 42 | * 菜单图标 43 | */ 44 | private String icon; 45 | /** 46 | * 资源类型(1=显示2禁止0=隐藏) 47 | */ 48 | private Integer status; 49 | /** 50 | * 资源类型(1=菜单2=权限) 51 | */ 52 | @TableField("res_type") 53 | private Integer resType; 54 | 55 | public String getIdentity() { 56 | return identity; 57 | } 58 | 59 | public void setIdentity(String identity) { 60 | this.identity = identity; 61 | } 62 | 63 | public String getUrl() { 64 | return url; 65 | } 66 | 67 | public void setUrl(String url) { 68 | this.url = url; 69 | } 70 | 71 | public Long getParentId() { 72 | return parentId; 73 | } 74 | 75 | public void setParentId(Long parentId) { 76 | this.parentId = parentId; 77 | } 78 | 79 | public String getParentIds() { 80 | return parentIds; 81 | } 82 | 83 | public void setParentIds(String parentIds) { 84 | this.parentIds = parentIds; 85 | } 86 | 87 | public Integer getWeight() { 88 | return weight; 89 | } 90 | 91 | public void setWeight(Integer weight) { 92 | this.weight = weight; 93 | } 94 | 95 | public String getIcon() { 96 | return icon; 97 | } 98 | 99 | public void setIcon(String icon) { 100 | this.icon = icon; 101 | } 102 | 103 | public Integer getStatus() { 104 | return status; 105 | } 106 | 107 | public void setStatus(Integer status) { 108 | this.status = status; 109 | } 110 | 111 | public Integer getResType() { 112 | return resType; 113 | } 114 | 115 | public void setResType(Integer resType) { 116 | this.resType = resType; 117 | } 118 | 119 | 120 | } 121 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/Role.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 系统_角色 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_role") 15 | public class Role extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 角色标识 21 | */ 22 | private String role; 23 | /** 24 | * 角色描述 25 | */ 26 | private String description; 27 | /** 28 | * 角色状态 29 | */ 30 | private Integer status; 31 | /** 32 | * 是否内置 33 | */ 34 | @TableField("is_sys") 35 | private Integer isSys; 36 | 37 | private String main; 38 | 39 | public String getRole() { 40 | return role; 41 | } 42 | 43 | public void setRole(String role) { 44 | this.role = role; 45 | } 46 | 47 | public String getDescription() { 48 | return description; 49 | } 50 | 51 | public void setDescription(String description) { 52 | this.description = description; 53 | } 54 | 55 | public Integer getStatus() { 56 | return status; 57 | } 58 | 59 | public void setStatus(Integer status) { 60 | this.status = status; 61 | } 62 | 63 | public Integer getIsSys() { 64 | return isSys; 65 | } 66 | 67 | public void setIsSys(Integer isSys) { 68 | this.isSys = isSys; 69 | } 70 | 71 | public String getMain() { 72 | return main; 73 | } 74 | 75 | public void setMain(String main) { 76 | this.main = main; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/RoleRes.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 系统_角色资源 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_role_res") 15 | public class RoleRes extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | @TableField("role_id") 20 | private Long roleId; 21 | @TableField("res_id") 22 | private Long resId; 23 | 24 | /** 25 | * 资源标识符 26 | */ 27 | @TableField(exist = true) 28 | private String identity; 29 | 30 | public Long getRoleId() { 31 | return roleId; 32 | } 33 | 34 | public void setRoleId(Long roleId) { 35 | this.roleId = roleId; 36 | } 37 | 38 | public Long getResId() { 39 | return resId; 40 | } 41 | 42 | public void setResId(Long resId) { 43 | this.resId = resId; 44 | } 45 | 46 | public String getIdentity() { 47 | return identity; 48 | } 49 | 50 | public void setIdentity(String identity) { 51 | this.identity = identity; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/ScheduleJob.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import cn.ffast.core.support.BaseEntity; 4 | import com.baomidou.mybatisplus.annotations.TableId; 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | import java.util.Date; 10 | /** 11 | * @description: 定时任务 12 | * @copyright: 13 | * @createTime: 2018/6/29 15:23 14 | * @author:dzy 15 | * @version:1.0 16 | */ 17 | @TableName("t_schedule_job") 18 | public class ScheduleJob extends BaseEntity { 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * 任务调度参数key 23 | */ 24 | public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY"; 25 | 26 | 27 | /** 28 | * spring bean名称 29 | */ 30 | @NotBlank(message="bean名称不能为空") 31 | private String beanName; 32 | 33 | /** 34 | * 方法名 35 | */ 36 | @NotBlank(message="方法名称不能为空") 37 | private String methodName; 38 | 39 | /** 40 | * 参数 41 | */ 42 | private String params; 43 | 44 | /** 45 | * cron表达式 46 | */ 47 | @NotBlank(message="cron表达式不能为空") 48 | private String cronExpression; 49 | 50 | /** 51 | * 任务状态 52 | */ 53 | private Integer status; 54 | 55 | /** 56 | * 备注 57 | */ 58 | private String note; 59 | 60 | 61 | 62 | 63 | 64 | public String getBeanName() { 65 | return beanName; 66 | } 67 | 68 | public void setBeanName(String beanName) { 69 | this.beanName = beanName; 70 | } 71 | 72 | public String getMethodName() { 73 | return methodName; 74 | } 75 | 76 | public void setMethodName(String methodName) { 77 | this.methodName = methodName; 78 | } 79 | 80 | public String getParams() { 81 | return params; 82 | } 83 | 84 | public void setParams(String params) { 85 | this.params = params; 86 | } 87 | 88 | 89 | 90 | /** 91 | * 设置:任务状态 92 | * @param status 任务状态 93 | */ 94 | public void setStatus(Integer status) { 95 | this.status = status; 96 | } 97 | 98 | /** 99 | * 获取:任务状态 100 | * @return String 101 | */ 102 | public Integer getStatus() { 103 | return status; 104 | } 105 | 106 | /** 107 | * 设置:cron表达式 108 | * @param cronExpression cron表达式 109 | */ 110 | public void setCronExpression(String cronExpression) { 111 | this.cronExpression = cronExpression; 112 | } 113 | 114 | /** 115 | * 获取:cron表达式 116 | * @return String 117 | */ 118 | public String getCronExpression() { 119 | return cronExpression; 120 | } 121 | 122 | 123 | public String getNote() { 124 | return note; 125 | } 126 | 127 | public void setNote(String note) { 128 | this.note = note; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/ScheduleJobLog.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import cn.ffast.core.support.BaseEntity; 4 | import com.baomidou.mybatisplus.annotations.TableId; 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | /** 10 | * @description: 定时任务日志实体类 11 | * @copyright: 12 | * @createTime: 2018/6/29 15:23 13 | * @author:dzy 14 | * @version:1.0 15 | */ 16 | @TableName("t_schedule_job_log") 17 | public class ScheduleJobLog extends BaseEntity { 18 | private static final long serialVersionUID = 1L; 19 | 20 | 21 | /** 22 | * 任务id 23 | */ 24 | private Long jobId; 25 | 26 | /** 27 | * spring bean名称 28 | */ 29 | private String beanName; 30 | 31 | /** 32 | * 方法名 33 | */ 34 | private String methodName; 35 | 36 | /** 37 | * 参数 38 | */ 39 | private String params; 40 | 41 | /** 42 | * 任务状态 0:成功 1:失败 43 | */ 44 | private Integer status; 45 | 46 | /** 47 | * 失败信息 48 | */ 49 | private String error; 50 | 51 | /** 52 | * 耗时(单位:毫秒) 53 | */ 54 | private Integer times; 55 | 56 | 57 | 58 | 59 | 60 | 61 | public Long getJobId() { 62 | return jobId; 63 | } 64 | 65 | public void setJobId(Long jobId) { 66 | this.jobId = jobId; 67 | } 68 | 69 | public String getBeanName() { 70 | return beanName; 71 | } 72 | 73 | public void setBeanName(String beanName) { 74 | this.beanName = beanName; 75 | } 76 | 77 | public String getMethodName() { 78 | return methodName; 79 | } 80 | 81 | public void setMethodName(String methodName) { 82 | this.methodName = methodName; 83 | } 84 | 85 | public String getParams() { 86 | return params; 87 | } 88 | 89 | public void setParams(String params) { 90 | this.params = params; 91 | } 92 | 93 | public Integer getStatus() { 94 | return status; 95 | } 96 | 97 | public void setStatus(Integer status) { 98 | this.status = status; 99 | } 100 | 101 | public String getError() { 102 | return error; 103 | } 104 | 105 | public void setError(String error) { 106 | this.error = error; 107 | } 108 | 109 | public Integer getTimes() { 110 | return times; 111 | } 112 | 113 | public void setTimes(Integer times) { 114 | this.times = times; 115 | } 116 | 117 | 118 | 119 | 120 | } 121 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/User.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import java.util.Date; 5 | 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import cn.ffast.core.support.BaseEntity; 8 | 9 | /** 10 | * @description: 系统_用户 11 | * @copyright: 12 | * @createTime: 2017-09-13 09:14:49 13 | * @author: dzy 14 | * @version: 1.0 15 | */ 16 | @TableName(value="t_sys_user") 17 | public class User extends BaseEntity { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * 用户名 23 | */ 24 | private String username; 25 | /** 26 | * 用户状态【1启用、0禁用】 27 | */ 28 | private Integer status; 29 | /** 30 | * 密码 31 | */ 32 | private String pwd; 33 | /** 34 | * 邮箱 35 | */ 36 | private String email; 37 | /** 38 | * 手机号码 39 | */ 40 | private String tel; 41 | /** 42 | * 是否锁定【1是、0否】 43 | */ 44 | @TableField("is_lock") 45 | private Integer isLock; 46 | /** 47 | * 锁定时间 48 | */ 49 | @TableField("lock_time") 50 | private Date lockTime; 51 | /** 52 | * 登录次数 53 | */ 54 | @TableField("login_count") 55 | private Long loginCount; 56 | /** 57 | * 失败次数 58 | */ 59 | @TableField("login_failure_count") 60 | private Long loginFailureCount; 61 | /** 62 | * 登录Ip 63 | */ 64 | @TableField("login_ip") 65 | private String loginIp; 66 | /** 67 | * 登录时间 68 | */ 69 | @TableField("login_time") 70 | private String loginTime; 71 | 72 | /** 73 | * 密码盐 74 | */ 75 | @TableField("salt") 76 | private String salt; 77 | 78 | @TableField(exist = false) 79 | private String roleId; 80 | 81 | 82 | 83 | public String getUsername() { 84 | return username; 85 | } 86 | 87 | public void setUsername(String username) { 88 | this.username = username; 89 | } 90 | 91 | public Integer getStatus() { 92 | return status; 93 | } 94 | 95 | public void setStatus(Integer status) { 96 | this.status = status; 97 | } 98 | 99 | public String getPwd() { 100 | return pwd; 101 | } 102 | 103 | public void setPwd(String pwd) { 104 | this.pwd = pwd; 105 | } 106 | 107 | public String getEmail() { 108 | return email; 109 | } 110 | 111 | public void setEmail(String email) { 112 | this.email = email; 113 | } 114 | 115 | public String getTel() { 116 | return tel; 117 | } 118 | 119 | public void setTel(String tel) { 120 | this.tel = tel; 121 | } 122 | 123 | public Integer getIsLock() { 124 | return isLock; 125 | } 126 | 127 | public void setIsLock(Integer isLock) { 128 | this.isLock = isLock; 129 | } 130 | 131 | public Date getLockTime() { 132 | return lockTime; 133 | } 134 | 135 | public void setLockTime(Date lockTime) { 136 | this.lockTime = lockTime; 137 | } 138 | 139 | public Long getLoginCount() { 140 | return loginCount; 141 | } 142 | 143 | public void setLoginCount(Long loginCount) { 144 | this.loginCount = loginCount; 145 | } 146 | 147 | public Long getLoginFailureCount() { 148 | return loginFailureCount; 149 | } 150 | 151 | public void setLoginFailureCount(Long loginFailureCount) { 152 | this.loginFailureCount = loginFailureCount; 153 | } 154 | 155 | public String getLoginIp() { 156 | return loginIp; 157 | } 158 | 159 | public void setLoginIp(String loginIp) { 160 | this.loginIp = loginIp; 161 | } 162 | 163 | public String getLoginTime() { 164 | return loginTime; 165 | } 166 | 167 | public void setLoginTime(String loginTime) { 168 | this.loginTime = loginTime; 169 | } 170 | 171 | public String getRoleId() { 172 | return roleId; 173 | } 174 | 175 | public void setRoleId(String roleId) { 176 | this.roleId = roleId; 177 | } 178 | 179 | public String getSalt() { 180 | return salt; 181 | } 182 | 183 | public void setSalt(String salt) { 184 | this.salt = salt; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/entity/sys/UserRole.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.entity.sys; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import cn.ffast.core.support.BaseEntity; 6 | 7 | /** 8 | * @description: 系统_用户角色 9 | * @copyright: 10 | * @createTime: 2017-09-13 09:14:49 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | @TableName(value="t_sys_user_role") 15 | public class UserRole extends BaseEntity { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 角色id 21 | */ 22 | @TableField("role_id") 23 | private Long roleId; 24 | /** 25 | * 用户id 26 | */ 27 | @TableField("user_id") 28 | private Long userId; 29 | 30 | public Long getRoleId() { 31 | return roleId; 32 | } 33 | 34 | public void setRoleId(Long roleId) { 35 | this.roleId = roleId; 36 | } 37 | 38 | public Long getUserId() { 39 | return userId; 40 | } 41 | 42 | public void setUserId(Long userId) { 43 | this.userId = userId; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/interceptor/AuthInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.interceptor; 2 | 3 | 4 | 5 | import cn.ffast.core.interceptor.BaseAuthInterceptor; 6 | import cn.ffast.web.dao.sys.RoleResMapper; 7 | import cn.ffast.web.service.sys.IResService; 8 | import cn.ffast.web.service.sys.IRoleResService; 9 | import cn.ffast.web.vo.Operator; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | 14 | import javax.annotation.Resource; 15 | import java.util.Set; 16 | 17 | /** 18 | * @description: 登录拦截器 19 | * @copyright: 20 | * @createTime: 2017/9/5 17:56 21 | * @author:dzy 22 | * @version:1.0 23 | */ 24 | public class AuthInterceptor extends BaseAuthInterceptor { 25 | private static Logger logger = LoggerFactory.getLogger(AuthInterceptor.class); 26 | 27 | @Resource 28 | IRoleResService roleResService; 29 | 30 | @Override 31 | protected Set getRolePerms(Long roleId) { 32 | return roleResService.getRoleResIdentitys(roleId); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/schedule/ScheduleQuartzJob.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package cn.ffast.web.schedule; 4 | 5 | 6 | import cn.ffast.core.utils.SpringContextUtils; 7 | import cn.ffast.web.entity.sys.ScheduleJob; 8 | import cn.ffast.web.entity.sys.ScheduleJobLog; 9 | import cn.ffast.web.service.sys.ScheduleJobLogService; 10 | import org.apache.commons.lang.StringUtils; 11 | import org.quartz.JobExecutionContext; 12 | import org.quartz.JobExecutionException; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.scheduling.quartz.QuartzJobBean; 16 | 17 | import java.util.concurrent.ExecutorService; 18 | import java.util.concurrent.Executors; 19 | import java.util.concurrent.Future; 20 | 21 | 22 | /** 23 | * @description: 定时任务 24 | * @copyright: 25 | * @createTime: 2018/6/29 15:23 26 | * @author:dzy 27 | * @version:1.0 28 | */ 29 | public class ScheduleQuartzJob extends QuartzJobBean { 30 | private Logger logger = LoggerFactory.getLogger(getClass()); 31 | private ExecutorService service = Executors.newSingleThreadExecutor(); 32 | 33 | @Override 34 | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { 35 | ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap() 36 | .get(ScheduleJob.JOB_PARAM_KEY); 37 | 38 | //获取spring bean 39 | ScheduleJobLogService scheduleJobLogService = (ScheduleJobLogService) SpringContextUtils.getBean("scheduleJobLogServiceImpl"); 40 | 41 | //数据库保存执行记录 42 | ScheduleJobLog log = new ScheduleJobLog(); 43 | log.setJobId(scheduleJob.getId()); 44 | log.setBeanName(scheduleJob.getBeanName()); 45 | log.setMethodName(scheduleJob.getMethodName()); 46 | log.setParams(scheduleJob.getParams()); 47 | log.setName(scheduleJob.getName()); 48 | 49 | //任务开始时间 50 | long startTime = System.currentTimeMillis(); 51 | 52 | try { 53 | //执行任务 54 | logger.info("任务准备执行,任务ID:" + scheduleJob.getId()); 55 | ScheduleRunnable task = new ScheduleRunnable(scheduleJob.getBeanName(), 56 | scheduleJob.getMethodName(), scheduleJob.getParams()); 57 | Future> future = service.submit(task); 58 | 59 | future.get(); 60 | 61 | //任务执行总时长 62 | long times = System.currentTimeMillis() - startTime; 63 | log.setTimes((int) times); 64 | //任务状态 1:成功 0:失败 65 | log.setStatus(1); 66 | 67 | logger.info("任务执行完毕,任务ID:" + scheduleJob.getId() + " 总共耗时:" + times + "毫秒"); 68 | } catch (Exception e) { 69 | logger.error("任务执行失败,任务ID:" + scheduleJob.getId(), e); 70 | 71 | //任务执行总时长 72 | long times = System.currentTimeMillis() - startTime; 73 | log.setTimes((int) times); 74 | 75 | //任务状态 1:成功 0:失败 76 | log.setStatus(0); 77 | log.setError(StringUtils.substring(e.toString(), 0, 2000)); 78 | } finally { 79 | //由于有人添加1秒一次的任务导致日志数量飙升,演示版本,关闭定时任务日志插入 80 | //scheduleJobLogService.insert(log); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/schedule/ScheduleRunnable.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.schedule; 2 | 3 | 4 | import cn.ffast.core.utils.SpringContextUtils; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.springframework.util.ReflectionUtils; 7 | 8 | import java.lang.reflect.Method; 9 | 10 | /** 11 | * @description: 执行定时任务 12 | * @copyright: 13 | * @createTime: 2018/6/29 15:23 14 | * @author:dzy 15 | * @version:1.0 16 | */ 17 | public class ScheduleRunnable implements Runnable { 18 | private Object target; 19 | private Method method; 20 | private String params; 21 | 22 | public ScheduleRunnable(String beanName, String methodName, String params) throws NoSuchMethodException, SecurityException { 23 | this.target = SpringContextUtils.getBean(beanName); 24 | this.params = params; 25 | 26 | if (StringUtils.isNotBlank(params)) { 27 | this.method = target.getClass().getDeclaredMethod(methodName, String.class); 28 | } else { 29 | this.method = target.getClass().getDeclaredMethod(methodName); 30 | } 31 | } 32 | 33 | @Override 34 | public void run() { 35 | try { 36 | ReflectionUtils.makeAccessible(method); 37 | if (StringUtils.isNotBlank(params)) { 38 | method.invoke(target, params); 39 | } else { 40 | method.invoke(target); 41 | } 42 | } catch (Exception e) { 43 | // 执行定时任务失败 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/DictServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | import cn.ffast.core.support.CrudServiceImpl; 4 | import cn.ffast.web.dao.sys.DictMapper; 5 | import cn.ffast.web.entity.sys.Dict; 6 | import cn.ffast.web.service.sys.IDictService; 7 | import cn.ffast.core.vo.ServiceResult; 8 | import cn.ffast.core.vo.ServiceRowsResult; 9 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 10 | import org.springframework.cache.annotation.Cacheable; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @description: 字典服务实现类 17 | * @copyright: 18 | * @createTime: 2017-09-12 17:18:46 19 | * @author: dzy 20 | * @version: 1.0 21 | */ 22 | @Service 23 | public class DictServiceImpl extends CrudServiceImpl implements IDictService { 24 | 25 | 26 | @Override 27 | protected ServiceRowsResult listBefore(Dict m, EntityWrapper ew) { 28 | ew.like("name", m.getName()); 29 | ew.like("code", m.getCode()); 30 | m.setName(null); 31 | m.setCode(null); 32 | return null; 33 | } 34 | 35 | 36 | @Cacheable(value = "sys", key = "'dict_type_'+(#isName!=null && #isName?'name_':'')+#type") 37 | @Override 38 | public ServiceResult getDict(String type, Boolean isName) { 39 | ServiceRowsResult result = new ServiceRowsResult(false); 40 | List list = null; 41 | if (isName != null && isName) { 42 | list = baseMapper.listDict(null, new Long(type)); 43 | } else { 44 | list = baseMapper.listDict(type, null); 45 | } 46 | result.setPage(list); 47 | result.setSuccess(true); 48 | clearCache(); 49 | return result; 50 | } 51 | 52 | /** 53 | * 清除缓存 54 | */ 55 | private void clearCache(){ 56 | redisCacheUtils.clear("sys::dict_*"); 57 | } 58 | 59 | @Override 60 | protected ServiceResult createAfter(Dict m) { 61 | clearCache(); 62 | return null; 63 | } 64 | 65 | @Override 66 | protected ServiceResult deleteAfter(String ids) { 67 | clearCache(); 68 | return null; 69 | } 70 | 71 | @Override 72 | protected ServiceResult updateAfter(Dict m, Dict oldM) { 73 | clearCache(); 74 | return null; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/DictTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | import cn.ffast.core.support.CrudServiceImpl; 4 | import cn.ffast.web.dao.sys.DictTypeMapper; 5 | import cn.ffast.web.entity.sys.DictType; 6 | import cn.ffast.web.service.sys.IDictTypeService; 7 | import cn.ffast.core.vo.ServiceResult; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * @description: 基础字典类型服务实现类 13 | * @copyright: 14 | * @createTime: 2017-09-12 17:18:46 15 | * @author: dzy 16 | * @version: 1.0 17 | */ 18 | @Service 19 | public class DictTypeServiceImpl extends CrudServiceImpl implements IDictTypeService { 20 | 21 | @Override 22 | protected ServiceResult createBefore(DictType m) { 23 | ServiceResult result = new ServiceResult(); 24 | EntityWrapper ew = new EntityWrapper(); 25 | ew.eq("identity", m.getIdentity()); 26 | if (selectCount(ew) > 0) { 27 | result.setMessage("标识重复,请重新输入"); 28 | return result; 29 | } 30 | EntityWrapper ew1 = new EntityWrapper(); 31 | ew1.eq("name", m.getName()); 32 | if (selectCount(ew1) > 0) { 33 | result.setMessage("分类名重复,请重新输入"); 34 | return result; 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/LogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | import cn.ffast.core.aop.LogPoint; 4 | import cn.ffast.core.support.CrudServiceImpl; 5 | import cn.ffast.core.utils.IpUtils; 6 | import cn.ffast.web.entity.sys.Log; 7 | import cn.ffast.web.dao.sys.LogMapper; 8 | import cn.ffast.web.service.sys.ILogService; 9 | import cn.ffast.core.vo.ServiceRowsResult; 10 | import com.baomidou.mybatisplus.plugins.Page; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.aspectj.lang.ProceedingJoinPoint; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import java.util.Enumeration; 17 | 18 | /** 19 | * @description: 操作日志表服务实现类 20 | * @copyright: 21 | * @createTime: 2017-11-14 14:48:11 22 | * @author: dzy 23 | * @version: 1.0 24 | */ 25 | @Service 26 | public class LogServiceImpl extends CrudServiceImpl implements ILogService, LogPoint { 27 | private static final String LOG_CONTENT = "[类名]:%s,[方法]:%s,[参数]:%s,[IP]:%s"; 28 | 29 | @Override 30 | public void saveLog(ProceedingJoinPoint joinPoint, String methodName, String operate) { 31 | /** 32 | * 日志入库 33 | */ 34 | Log log = new Log(); 35 | log.setCreatorId(getLoginUserId()); 36 | log.setContent(operateContent(joinPoint, methodName, getRequest())); 37 | log.setOperation(operate); 38 | baseMapper.insert(log); 39 | } 40 | 41 | /** 42 | * 拼接操作内容 43 | * @param joinPoint 44 | * @param methodName 45 | * @param request 46 | * @return 47 | */ 48 | public String operateContent(ProceedingJoinPoint joinPoint, String methodName, HttpServletRequest request) { 49 | String className = joinPoint.getTarget().getClass().getName(); 50 | Object[] params = joinPoint.getArgs(); 51 | StringBuffer bf = new StringBuffer(); 52 | if (params != null && params.length > 0) { 53 | Enumeration paraNames = request.getParameterNames(); 54 | while (paraNames.hasMoreElements()) { 55 | String key = paraNames.nextElement(); 56 | bf.append(key).append("="); 57 | bf.append(request.getParameter(key)).append("&"); 58 | } 59 | if (StringUtils.isBlank(bf.toString())) { 60 | bf.append(request.getQueryString()); 61 | } 62 | } 63 | return String.format(LOG_CONTENT, className, methodName, bf.toString(), IpUtils.getIpAddr(request)); 64 | } 65 | 66 | @Override 67 | public ServiceRowsResult findListByPage(Log m, Page page, String[] properties) { 68 | ServiceRowsResult result = new ServiceRowsResult(false); 69 | page.setRecords(baseMapper.listByPage(page, m)); 70 | result.setPage(page.getRecords(), page.getTotal()); 71 | result.setSuccess(true); 72 | return result; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | 4 | import cn.ffast.core.support.CrudServiceImpl; 5 | import cn.ffast.web.dao.sys.RoleMapper; 6 | import cn.ffast.web.dao.sys.UserRoleMapper; 7 | import cn.ffast.web.entity.sys.Role; 8 | import cn.ffast.web.entity.sys.UserRole; 9 | import cn.ffast.web.service.sys.IRoleService; 10 | import cn.ffast.core.vo.ServiceResult; 11 | import cn.ffast.core.vo.ServiceRowsResult; 12 | import cn.ffast.web.service.sys.IUserRoleService; 13 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 14 | import org.springframework.stereotype.Service; 15 | 16 | import javax.annotation.Resource; 17 | import java.util.List; 18 | 19 | /** 20 | * @description: 系统_角色服务实现类 21 | * @copyright: 22 | * @createTime: 2017-09-12 17:18:46 23 | * @author: dzy 24 | * @version: 1.0 25 | */ 26 | @Service 27 | public class RoleServiceImpl extends CrudServiceImpl implements IRoleService { 28 | 29 | @Resource 30 | UserRoleMapper userRoleMapper; 31 | 32 | 33 | @Override 34 | protected ServiceRowsResult listBefore(Role m, EntityWrapper ew) { 35 | if (m.getName() != null) { 36 | ew.like("name", m.getName()); 37 | m.setName(null); 38 | } 39 | if (m.getDescription() != null) { 40 | ew.like("description", m.getDescription()); 41 | m.setDescription(null); 42 | } 43 | if (m.getStatus() != null) { 44 | ew.eq("status", m.getStatus()); 45 | m.setStatus(null); 46 | } 47 | return null; 48 | } 49 | 50 | @Override 51 | protected ServiceResult createBefore(Role m) { 52 | ServiceResult result = new ServiceResult(); 53 | EntityWrapper ew = new EntityWrapper(); 54 | ew.eq("name", m.getName()); 55 | if (selectCount(ew) > 0) { 56 | result.setMessage("该角色已存在"); 57 | return result; 58 | } else { 59 | return null; 60 | } 61 | } 62 | 63 | @Override 64 | protected ServiceResult deleteBefore(String ids, EntityWrapper ew) { 65 | EntityWrapper selectEw = new EntityWrapper(); 66 | selectEw.in("id", ids); 67 | List roles = baseMapper.selectList(selectEw); 68 | for (Role role : roles) { 69 | if (new Integer(1).equals(role.getIsSys())) { 70 | return new ServiceResult(false).setMessage("无法删除系统角色:" + role.getName()); 71 | } 72 | } 73 | return null; 74 | } 75 | 76 | @Override 77 | protected ServiceResult deleteAfter(String ids) { 78 | // 删除账号角色 79 | EntityWrapper deleteEw = new EntityWrapper(); 80 | deleteEw.in("role_id", ids); 81 | userRoleMapper.delete(deleteEw); 82 | return null; 83 | } 84 | 85 | 86 | @Override 87 | protected ServiceResult updateBefore(Role m, Role oldM) { 88 | if (Integer.valueOf(1).equals(oldM.getIsSys())) { 89 | return new ServiceResult(false).setMessage("不能修改系统角色"); 90 | } 91 | return null; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/ScheduleJobLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package cn.ffast.web.service.impl.sys; 4 | 5 | import cn.ffast.core.support.CrudServiceImpl; 6 | 7 | import cn.ffast.web.dao.sys.ScheduleJobLogMapper; 8 | 9 | import cn.ffast.web.entity.sys.ScheduleJobLog; 10 | import cn.ffast.web.service.sys.ScheduleJobLogService; 11 | 12 | import org.springframework.stereotype.Service; 13 | 14 | 15 | @Service 16 | public class ScheduleJobLogServiceImpl extends CrudServiceImpl implements ScheduleJobLogService { 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/ScheduleJobServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | import cn.ffast.core.support.CrudServiceImpl; 4 | import cn.ffast.core.vo.ServiceResult; 5 | import cn.ffast.web.dao.sys.ScheduleJobMapper; 6 | import cn.ffast.web.entity.sys.ScheduleJob; 7 | import cn.ffast.core.constant.ScheduleStatus; 8 | import cn.ffast.web.schedule.ScheduleUtils; 9 | import cn.ffast.web.service.sys.ScheduleJobService; 10 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 11 | import org.quartz.CronTrigger; 12 | import org.quartz.Scheduler; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.annotation.PostConstruct; 16 | import javax.annotation.Resource; 17 | import java.util.*; 18 | 19 | @Service("scheduleJobService") 20 | public class ScheduleJobServiceImpl extends CrudServiceImpl implements ScheduleJobService { 21 | @Resource 22 | private Scheduler scheduler; 23 | 24 | /** 25 | * 项目启动时,初始化定时器 26 | */ 27 | @PostConstruct 28 | public void init() { 29 | try { 30 | List scheduleJobList = this.selectList(null); 31 | for (ScheduleJob scheduleJob : scheduleJobList) { 32 | CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getId()); 33 | //如果不存在,则创建 34 | if (cronTrigger == null) { 35 | ScheduleUtils.createScheduleJob(scheduler, scheduleJob); 36 | } else { 37 | ScheduleUtils.updateScheduleJob(scheduler, scheduleJob); 38 | } 39 | } 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | 44 | } 45 | 46 | 47 | @Override 48 | public void run(Long[] jobIds) { 49 | for (Long jobId : jobIds) { 50 | ScheduleUtils.run(scheduler, this.selectById(jobId)); 51 | } 52 | } 53 | 54 | @Override 55 | public void pause(Long[] jobIds) { 56 | for (Long jobId : jobIds) { 57 | ScheduleUtils.pauseJob(scheduler, jobId); 58 | } 59 | updateStatus(jobIds, ScheduleStatus.PAUSE.getValue()); 60 | } 61 | 62 | private void updateStatus(Long[] jobIds, int value) { 63 | EntityWrapper ew = new EntityWrapper(); 64 | ScheduleJob scheduleJob = new ScheduleJob(); 65 | scheduleJob.setStatus(value); 66 | ew.in("id", jobIds); 67 | baseMapper.update(scheduleJob, ew); 68 | } 69 | 70 | @Override 71 | public void resume(Long[] jobIds) { 72 | for (Long jobId : jobIds) { 73 | ScheduleUtils.resumeJob(scheduler, jobId); 74 | } 75 | updateStatus(jobIds, ScheduleStatus.NORMAL.getValue()); 76 | } 77 | 78 | @Override 79 | protected ServiceResult updateAfter(ScheduleJob m, ScheduleJob oldM) { 80 | createOrUpdateStatus(m); 81 | oldM.setBeanName(m.getBeanName()); 82 | oldM.setStatus(m.getStatus()); 83 | oldM.setCronExpression(m.getCronExpression()); 84 | oldM.setMethodName(m.getMethodName()); 85 | oldM.setParams(m.getParams()); 86 | ScheduleUtils.updateScheduleJob(scheduler, oldM); 87 | return null; 88 | } 89 | 90 | private void createOrUpdateStatus(ScheduleJob m) { 91 | if (m.getStatus() != null) { 92 | if (ScheduleStatus.NORMAL.getValue() == m.getStatus().intValue()) { 93 | ScheduleUtils.resumeJob(scheduler, m.getId()); 94 | } else if (ScheduleStatus.PAUSE.getValue() == m.getStatus().intValue()) { 95 | ScheduleUtils.pauseJob(scheduler, m.getId()); 96 | } 97 | } 98 | } 99 | 100 | 101 | @Override 102 | protected ServiceResult createAfter(ScheduleJob m) { 103 | ScheduleUtils.createScheduleJob(scheduler, m); 104 | createOrUpdateStatus(m); 105 | return null; 106 | } 107 | 108 | 109 | public void Test() { 110 | System.out.println("ScheduleJobServiceImpl test"); 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/sys/UserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.sys; 2 | 3 | import cn.ffast.core.support.CrudServiceImpl; 4 | import cn.ffast.web.entity.sys.Role; 5 | import cn.ffast.web.entity.sys.UserRole; 6 | import cn.ffast.web.dao.sys.UserRoleMapper; 7 | import cn.ffast.web.service.sys.IUserRoleService; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | /** 14 | * @description: 系统_用户角色服务实现类 15 | * @copyright: 16 | * @createTime: 2017年08月31日 09:49:42 17 | * @author: dzy 18 | * @version: 1.0 19 | */ 20 | @Service 21 | public class UserRoleServiceImpl extends CrudServiceImpl implements IUserRoleService { 22 | 23 | @Resource 24 | UserRoleMapper userRoleMapper; 25 | 26 | @Override 27 | public List listByUserId(Long userId,Long roleId) { 28 | return userRoleMapper.listByUserId(userId,roleId); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/impl/work/BacklogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.impl.work; 2 | 3 | 4 | import cn.ffast.core.support.CrudServiceImpl; 5 | import cn.ffast.core.vo.ServiceResult; 6 | import cn.ffast.core.vo.ServiceRowsResult; 7 | import cn.ffast.web.dao.work.BacklogMapper; 8 | import cn.ffast.web.entity.work.Backlog; 9 | 10 | import cn.ffast.web.service.work.IBacklogService; 11 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 12 | import org.apache.commons.lang.StringUtils; 13 | import org.springframework.stereotype.Service; 14 | 15 | /** 16 | * @description: 待办事项服务实现类 17 | * @copyright: 18 | * @createTime: 2018-06-09 11:20:16 19 | * @author: dzy 20 | * @version: 1.0 21 | */ 22 | @Service 23 | public class BacklogServiceImpl extends CrudServiceImpl implements IBacklogService { 24 | 25 | @Override 26 | protected ServiceResult createBefore(Backlog m) { 27 | m.setUserIds(getLoginUserId().toString()); 28 | return null; 29 | } 30 | 31 | 32 | @Override 33 | protected ServiceRowsResult listBefore(Backlog m, EntityWrapper ew) { 34 | m.setUserIds(getLoginUserId().toString()); 35 | if (StringUtils.isNotBlank(m.getAfterDate())) { 36 | ew.where("unix_timestamp(start_time) >= unix_timestamp({0})", m.getAfterDate()); 37 | m.setAfterDate(null); 38 | } 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IAttachService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Attach; 5 | import cn.ffast.core.vo.ServiceResult; 6 | import cn.ffast.core.vo.ServiceRowsResult; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * @description: 系统_附件服务类 13 | * @copyright: 14 | * @createTime: 2017-09-27 15:47:59 15 | * @author: lxb 16 | * @version: 1.0 17 | */ 18 | public interface IAttachService extends ICrudService { 19 | /** 20 | * 获得附件文件对象 21 | * @param attachId 22 | * @return 23 | */ 24 | File getAttach(Long attachId); 25 | 26 | /** 27 | * 上传图片 28 | * @param resource 29 | * @param file 30 | * @return 31 | */ 32 | ServiceResult uploadImg(String resource,MultipartFile file); 33 | 34 | /** 35 | * 上传文件 36 | * @param resource 37 | * @param file 38 | * @return 39 | */ 40 | ServiceResult upload(String resource, MultipartFile file); 41 | 42 | /** 43 | * 删除垃圾文件 44 | */ 45 | ServiceRowsResult deleteRubbish(); 46 | 47 | /** 48 | * 增加引用计数 49 | * @param ids 50 | */ 51 | void addCount(String ids); 52 | 53 | 54 | /** 55 | * 减去引用计数 56 | * @param ids 57 | */ 58 | void subtractCount(String ids); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IDictService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Dict; 5 | import cn.ffast.core.vo.ServiceResult; 6 | 7 | /** 8 | * @description: 字典服务类 9 | * @copyright: 10 | * @createTime: 2017-09-12 17:18:46 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | public interface IDictService extends ICrudService { 15 | /** 16 | * 根据字典分类获得字典 17 | * @param type 分类 18 | * @param isName 是否为字典分类名称 19 | * @return 20 | */ 21 | ServiceResult getDict(String type,Boolean isName); 22 | } 23 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IDictTypeService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.DictType; 5 | 6 | /** 7 | * @description: 基础字典类型服务类 8 | * @copyright: 9 | * @createTime: 2017-09-12 17:18:46 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface IDictTypeService extends ICrudService { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/ILogService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Log; 5 | 6 | /** 7 | * @description: 操作日志表服务类 8 | * @copyright: 9 | * @createTime: 2017-11-14 14:48:11 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface ILogService extends ICrudService { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IResService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | 4 | import cn.ffast.core.support.ICrudService; 5 | import cn.ffast.web.entity.sys.Res; 6 | 7 | import java.util.HashMap; 8 | 9 | 10 | /** 11 | * @description: 系统_资源服务类 12 | * @copyright: 13 | * @createTime: 2017年08月31日 09:49:42 14 | * @author: dzy 15 | * @version: 1.0 16 | */ 17 | public interface IResService extends ICrudService { 18 | 19 | /** 20 | * 添加增删改查权限 21 | * 22 | * @param m 23 | * @return 24 | */ 25 | boolean addBaseCrud(Res m); 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IRoleResService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Res; 5 | import cn.ffast.web.entity.sys.RoleRes; 6 | import cn.ffast.web.vo.RoleMenuPerms; 7 | import cn.ffast.core.vo.ServiceResult; 8 | 9 | import java.util.HashSet; 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | /** 14 | * @description: 系统_角色资源服务类 15 | * @copyright: 16 | * @createTime: 2017年08月31日 09:49:42 17 | * @author: dzy 18 | * @version: 1.0 19 | */ 20 | public interface IRoleResService extends ICrudService { 21 | /** 22 | * 根据角色ID获得菜单或权限列表 23 | * @param roleId 24 | * @return 25 | */ 26 | List getRoleResList(Long roleId,Integer resType); 27 | 28 | /** 29 | * 根据角色ID获得菜单或权限列表 30 | * @param roleIds 31 | * @param resType 32 | * @return 33 | */ 34 | List getRoleResList(String roleIds, Integer resType); 35 | /** 36 | * 根据角色ID获得菜单列表 37 | * @param roleId 38 | * @return 39 | */ 40 | List getRoleMenuList(Long roleId); 41 | /** 42 | * 根据角色ID获得权限集合 43 | * @param roleId 44 | * @return 45 | */ 46 | HashSet getRolePermissionList(Long roleId); 47 | 48 | /** 49 | * 根据角色id获得权限集合和菜单列表 50 | * @param roleId 51 | * @param permissionList 52 | * @param menuList 53 | */ 54 | RoleMenuPerms getRoleMenuAndPerms(String roleIds); 55 | 56 | /** 57 | * 保存角色资源 58 | * @param ids 59 | * @param roleId 60 | * @return 61 | */ 62 | ServiceResult saveRes(String ids,Long roleId); 63 | 64 | /** 65 | * 获得角色资源列表 66 | * @param roleId 67 | * @return 68 | */ 69 | List getRoleResIds(Long roleId); 70 | 71 | /** 72 | * 获得角色资源列表 73 | * @param roleId 74 | * @return 75 | */ 76 | Set getRoleResIdentitys(Long roleId); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IRoleService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Role; 5 | 6 | /** 7 | * @description: 系统_角色服务类 8 | * @copyright: 9 | * @createTime: 2017-09-12 17:18:46 10 | * @author: dzy 11 | * @version: 1.0 12 | */ 13 | public interface IRoleService extends ICrudService { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IUserRoleService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.Role; 5 | import cn.ffast.web.entity.sys.UserRole; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @description: 系统_用户角色服务类 11 | * @copyright: 12 | * @createTime: 2017年08月31日 09:49:42 13 | * @author: dzy 14 | * @version: 1.0 15 | */ 16 | public interface IUserRoleService extends ICrudService { 17 | List listByUserId(Long userId,Long roleId); 18 | } 19 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.User; 5 | import cn.ffast.core.vo.ServiceResult; 6 | 7 | 8 | /** 9 | * @description: 系统_用户服务类 10 | * @copyright: 11 | * @createTime: 2017年08月31日 09:49:42 12 | * @author: dzy 13 | * @version: 1.0 14 | */ 15 | public interface IUserService extends ICrudService { 16 | /** 17 | * 根据username取得用户对象 18 | */ 19 | User getUserByUserName(String username) ; 20 | /** 21 | * 验证用户 22 | */ 23 | User verifyUser(String username,String password) ; 24 | /** 25 | * 重置密码 26 | */ 27 | ServiceResult reseting(Long ids); 28 | 29 | /** 30 | * 修改密码 31 | */ 32 | ServiceResult respwd(Long userId, String pwd, String newpwd, String newpwd2); 33 | 34 | /** 35 | * 根据登录结果更新登录次数时间信息 36 | */ 37 | void updateLoginResult(String username, Boolean bool); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/ScheduleJobLogService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.ScheduleJobLog; 5 | 6 | 7 | import java.util.Map; 8 | /** 9 | * @description: 定时任务日志Service 10 | * @copyright: 11 | * @createTime: 2018/6/29 15:23 12 | * @author:dzy 13 | * @version:1.0 14 | */ 15 | public interface ScheduleJobLogService extends ICrudService { 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/sys/ScheduleJobService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.sys; 2 | 3 | import cn.ffast.core.support.ICrudService; 4 | import cn.ffast.web.entity.sys.ScheduleJob; 5 | 6 | 7 | import java.util.Map; 8 | /** 9 | * @description: 定时任务Service 10 | * @copyright: 11 | * @createTime: 2018/6/29 15:23 12 | * @author:dzy 13 | * @version:1.0 14 | */ 15 | public interface ScheduleJobService extends ICrudService { 16 | 17 | 18 | /** 19 | * 立即执行 20 | */ 21 | void run(Long[] jobIds); 22 | 23 | /** 24 | * 暂停运行 25 | */ 26 | void pause(Long[] jobIds); 27 | 28 | /** 29 | * 恢复运行 30 | */ 31 | void resume(Long[] jobIds); 32 | } 33 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/service/work/IBacklogService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.service.work; 2 | 3 | 4 | import cn.ffast.core.support.ICrudService; 5 | import cn.ffast.web.entity.work.Backlog; 6 | 7 | /** 8 | * @description: 待办事项服务类 9 | * @copyright: 10 | * @createTime: 2018-06-09 11:20:16 11 | * @author: dzy 12 | * @version: 1.0 13 | */ 14 | public interface IBacklogService extends ICrudService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/vo/Operator.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.vo; 2 | 3 | import cn.ffast.core.auth.OperatorBase; 4 | 5 | public class Operator extends OperatorBase { 6 | private Long sortId; 7 | 8 | public Long getSortId() { 9 | return sortId; 10 | } 11 | 12 | public void setSortId(Long sortId) { 13 | this.sortId = sortId; 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /ffast-admin/src/main/java/cn/ffast/web/vo/RoleMenuPerms.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.web.vo; 2 | 3 | import cn.ffast.core.vo.Menu; 4 | import java.util.HashSet; 5 | import java.util.List; 6 | 7 | /** 8 | * @description: 角色菜单权限 9 | * @copyright: 10 | * @createTime: 2017/11/14 9:28 11 | * @author:dzy 12 | * @version:1.0 13 | */ 14 | 15 | public class RoleMenuPerms { 16 | private HashSet permsList; 17 | private List menuList; 18 | 19 | public HashSet getPermsList() { 20 | return permsList; 21 | } 22 | 23 | public void setPermsList(HashSet permsList) { 24 | this.permsList = permsList; 25 | } 26 | 27 | public List getMenuList() { 28 | return menuList; 29 | } 30 | 31 | public void setMenuList(List menuList) { 32 | this.menuList = menuList; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | #servlet: 4 | #contextPath: /api/ 5 | spring: 6 | devtools: 7 | restart: 8 | enabled: true 9 | datasource: 10 | driver-class-name: com.mysql.jdbc.Driver 11 | username: root 12 | password: root 13 | url: jdbc:mysql://localhost:3306/ffast?useUnicode=true&characterEncoding=utf-8&useSSL=false 14 | druid: 15 | initialSize: 1 16 | maxActive: 10 17 | minIdle: 1 18 | maxWait: 60000 19 | jpa: 20 | show-sql: true 21 | jackson: 22 | default-property-inclusion: non_null 23 | redis: 24 | 25 | enabled: true 26 | host: 127.0.0.1 27 | port: 6379 28 | #password: 123465 29 | #过期时间(秒) 30 | expirationSecond: 0 31 | #序列号方式 默认0 0:"FastJSON",1:"JackJson",2:"Msgpack" 32 | serializerType: 2 33 | 34 | mybatis-plus: 35 | global-config: 36 | #刷新mapper 调试神器 37 | refresh-mapper: true 38 | 39 | #日志配置 40 | logging: 41 | config: classpath:dev/logback.xml 42 | 43 | auth: 44 | pwdDefault: '123456' 45 | #是否开启验证码 46 | captchaEnable: true 47 | #0使用jwt 1使用redis 48 | type: 1 49 | #过期时间(秒) 50 | expirationSecond: 86400 51 | jwt: 52 | secret: 'ggs6fad5as6d5sa#dddfg2ddd$fdd$d@dd' 53 | 54 | 55 | #上传配置 56 | upload: 57 | filesBasePath: 'files/' 58 | uploadUrl: 'http://127.0.1.1:8030/' 59 | 60 | 61 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | #servlet: 4 | #contextPath: /api/ 5 | spring: 6 | datasource: 7 | driver-class-name: com.mysql.jdbc.Driver 8 | username: root 9 | password: root 10 | url: jdbc:mysql://localhost:3306/ffast?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 | druid: 12 | initialSize: 1 13 | maxActive: 10 14 | minIdle: 1 15 | maxWait: 60000 16 | jpa: 17 | show-sql: true 18 | jackson: 19 | default-property-inclusion: non_null 20 | redis: 21 | enabled: true 22 | host: 127.0.0.1 23 | port: 6379 24 | #password: 123456 25 | #过期时间(秒) 26 | expirationSecond: 1800 27 | #序列号方式 默认0 0:"FastJSON",1:"JackJson",2:"Msgpack" 28 | serializerType: 2 29 | 30 | 31 | #日志配置 32 | logging: 33 | config: classpath:prod/logback.xml 34 | 35 | auth: 36 | pwdDefault: '123456' 37 | #是否开启验证码 38 | captchaEnable: true 39 | #0使用jwt 1使用redis 40 | type: 1 41 | #过期时间(秒) 42 | expirationSecond: 86400 43 | jwt: 44 | secret: 'fGSASD6fad5as6d5sa#ddd42ddd$fdd$d@dd' 45 | 46 | 47 | #上传配置 48 | upload: 49 | filesBasePath: '/data/wwwroot/default/files/' 50 | uploadUrl: 'http://39.107.104.190/files' 51 | 52 | 53 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | #servlet: 4 | #contextPath: /api/ 5 | spring: 6 | datasource: 7 | driver-class-name: com.mysql.jdbc.Driver 8 | username: root 9 | password: root 10 | url: jdbc:mysql://localhost:3306/ffast?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 | druid: 12 | initialSize: 1 13 | maxActive: 10 14 | minIdle: 1 15 | maxWait: 60000 16 | jpa: 17 | show-sql: true 18 | jackson: 19 | default-property-inclusion: non_null 20 | redis: 21 | enabled: true 22 | host: 127.0.0.1 23 | port: 6379 24 | #password: 123465 25 | #过期时间(秒) 26 | expirationSecond: 1800 27 | #序列号方式 默认0 0:"FastJSON",1:"JackJson",2:"Msgpack" 28 | serializerType: 2 29 | 30 | 31 | #日志配置 32 | logging: 33 | config: classpath:test/logback.xml 34 | 35 | auth: 36 | pwdDefault: '123456' 37 | #是否开启验证码 38 | captchaEnable: true 39 | #0使用jwt 1使用redis 40 | type: 1 41 | #过期时间(秒) 42 | expirationSecond: 86400 43 | jwt: 44 | secret: 'fs6fad5as6d5sa#ddd42ddd$fdd$d@dd' 45 | 46 | 47 | #上传配置 48 | upload: 49 | filesBasePath: 'files/' 50 | uploadUrl: 'http://127.0.1.1:8030/' 51 | 52 | 53 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | flyway: 5 | enabled: true 6 | baselineOnMigrate: true 7 | table: t_flyway_schema 8 | 9 | 10 | mybatis-plus: 11 | # 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml 12 | # 如果是放在resource目录 classpath:/mapper/*Mapper.xml 13 | mapper-locations: classpath:/cn/ffast/web/dao/mapper/*.xml 14 | #实体扫描,多个package用逗号或者分号分隔 15 | typeAliasesPackage: cn.ffast.web.entity.* 16 | global-config: 17 | #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; 18 | id-type: 0 19 | #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" 20 | field-strategy: 2 21 | #驼峰下划线转换 22 | db-column-underline: true 23 | #数据库大写下划线转换 24 | #capital-mode: true 25 | # Sequence序列接口实现类配置 26 | key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator 27 | #逻辑删除配置(下面3个配置) 28 | logic-delete-value: 1 29 | logic-not-delete-value: 0 30 | sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector 31 | #自定义填充策略接口实现 32 | meta-object-handler: cn.ffast.core.handler.BaseEntityHandler 33 | configuration: 34 | #配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId) 35 | map-underscore-to-camel-case: true 36 | cache-enabled: false 37 | #配置JdbcTypeForNull, oracle数据库必须配置 38 | jdbc-type-for-null: 'null' -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/db/migration/V1_0_2__backlog.sql: -------------------------------------------------------------------------------- 1 | -- ---------------------------- 2 | -- Table structure for t_work_backlog 3 | -- ---------------------------- 4 | DROP TABLE IF EXISTS `t_work_backlog`; 5 | CREATE TABLE `t_work_backlog` ( 6 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 7 | `name` varchar(50) DEFAULT NULL COMMENT '名称', 8 | `content` varchar(2000) DEFAULT NULL COMMENT '内容', 9 | `pictures` varchar(100) DEFAULT NULL COMMENT '图片', 10 | `start_time` varchar(20) DEFAULT NULL COMMENT '待办开始时间', 11 | `finish_time` varchar(20) DEFAULT NULL COMMENT '待办完成时间', 12 | `from_module` tinyint(4) DEFAULT NULL COMMENT '来源模块', 13 | `from_id` bigint(20) DEFAULT NULL COMMENT '来源id', 14 | `priority` tinyint(4) DEFAULT '0' COMMENT '优先级(0=一般1=重要)', 15 | `user_ids` varchar(100) DEFAULT NULL COMMENT '待办用户', 16 | `status` tinyint(4) DEFAULT '0' COMMENT '状态(0=未完成1=已完成)', 17 | `inform_days` int(11) DEFAULT NULL COMMENT '提前多少天提醒', 18 | `inform_enable` tinyint(4) DEFAULT '1' COMMENT '开启提醒', 19 | `inform_type` varchar(20) DEFAULT NULL COMMENT '通知渠道', 20 | `inform_status` tinyint(4) DEFAULT NULL COMMENT '通知状态(0=未通知1=已通知2=已提前通知)', 21 | `note` varchar(50) DEFAULT NULL COMMENT '备注', 22 | `creator_id` bigint(20) DEFAULT NULL COMMENT '创建人', 23 | `create_time` varchar(20) DEFAULT NULL COMMENT '创建时间', 24 | `last_modifier_id` bigint(20) DEFAULT NULL COMMENT '最后修改人', 25 | `last_modify_time` varchar(20) DEFAULT NULL COMMENT '最后修改时间', 26 | PRIMARY KEY (`id`) 27 | ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='待办事项'; 28 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/db/migration/V1_0_3__schedule.sql: -------------------------------------------------------------------------------- 1 | SET FOREIGN_KEY_CHECKS=0; 2 | 3 | -- ---------------------------- 4 | -- Table structure for t_schedule_job 5 | -- ---------------------------- 6 | DROP TABLE IF EXISTS `t_schedule_job`; 7 | CREATE TABLE `t_schedule_job` ( 8 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务id', 9 | `name` varchar(200) DEFAULT NULL COMMENT '任务名称', 10 | `bean_name` varchar(200) DEFAULT NULL COMMENT 'spring bean名称', 11 | `method_name` varchar(100) DEFAULT NULL COMMENT '方法名', 12 | `params` varchar(2000) DEFAULT NULL COMMENT '参数', 13 | `cron_expression` varchar(100) DEFAULT NULL COMMENT 'cron表达式', 14 | `status` tinyint(4) DEFAULT NULL COMMENT '任务状态 1:正常 0:暂停', 15 | `note` varchar(255) DEFAULT NULL COMMENT '备注', 16 | `creator_id` bigint(20) DEFAULT NULL COMMENT '创建人', 17 | `create_time` varchar(20) DEFAULT NULL COMMENT '创建时间', 18 | `last_modifier_id` bigint(20) DEFAULT NULL COMMENT '最后修改人', 19 | `last_modify_time` varchar(20) DEFAULT NULL COMMENT '最后修改时间', 20 | PRIMARY KEY (`id`) 21 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='定时任务'; 22 | 23 | -- ---------------------------- 24 | -- Table structure for t_schedule_job_log 25 | -- ---------------------------- 26 | DROP TABLE IF EXISTS `t_schedule_job_log`; 27 | CREATE TABLE `t_schedule_job_log` ( 28 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务日志id', 29 | `job_id` bigint(20) NOT NULL COMMENT '任务id', 30 | `name` varchar(200) DEFAULT NULL COMMENT '任务名称', 31 | `bean_name` varchar(200) DEFAULT NULL COMMENT 'spring bean名称', 32 | `method_name` varchar(100) DEFAULT NULL COMMENT '方法名', 33 | `params` varchar(2000) DEFAULT NULL COMMENT '参数', 34 | `status` tinyint(4) NOT NULL COMMENT '任务状态 1:成功 0:失败', 35 | `error` varchar(2000) DEFAULT NULL COMMENT '失败信息', 36 | `times` int(11) NOT NULL COMMENT '耗时(单位:毫秒)', 37 | `creator_id` bigint(20) DEFAULT NULL COMMENT '创建人', 38 | `create_time` varchar(20) DEFAULT NULL COMMENT '创建时间', 39 | `last_modifier_id` bigint(20) DEFAULT NULL COMMENT '最后修改人', 40 | `last_modify_time` varchar(20) DEFAULT NULL COMMENT '最后修改时间', 41 | PRIMARY KEY (`id`) 42 | ) ENGINE=MyISAM AUTO_INCREMENT=302 DEFAULT CHARSET=utf8 COMMENT='定时任务日志'; 43 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/dev/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 8 | 9 | UTF-8 10 | 11 | 12 | 13 | 14 | D:/logs_files/ffast/ffast.log 15 | 16 | 17 | D:/logs_files/ffast/ffast.%d{yyyy-MM-dd}.log 18 | 19 | 20 | 10 21 | 22 | 23 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 24 | UTF-8 25 | GBK 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/prod/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 8 | UTF-8 9 | UTF-8 10 | 11 | 12 | 13 | 14 | /data/wwwlogs/ffast/ffast.log 15 | 16 | 17 | /data/wwwlogs/ffast/ffast.%d{yyyy-MM-dd}.log 18 | 19 | 20 | 10 21 | 22 | 23 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 24 | UTF-8 25 | UTF-8 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ffast-admin/src/main/resources/test/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 8 | 9 | GBK 10 | 11 | 12 | 13 | 14 | /logs_files/ffast/ffast.log 15 | 16 | 17 | /logs_files/ffast/ffast.%d{yyyy-MM-dd}.log 18 | 19 | 20 | 10 21 | 22 | 23 | %d{yyyy-MM-dd HH:mm:ss} %level %c:%L - %msg%n 24 | UTF-8 25 | GBK 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ffast-admin/src/test/java/WebApplicationTests.java: -------------------------------------------------------------------------------- 1 | 2 | import cn.ffast.web.WebApplication; 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | // @RunWith(SpringRunner.class) 9 | // @SpringBootTest(classes = WebApplication.class) 10 | public class WebApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/annotations/CrudConfig.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.annotations; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @description: 基础增删改配置项 7 | * @copyright: 8 | * @createTime: 2017/11/14 14:12 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | @Target(ElementType.TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface CrudConfig { 16 | 17 | /** 18 | * 是否更新所有字段 19 | */ 20 | boolean updateAllColumn() default false; 21 | 22 | /** 23 | * 查询字段 24 | */ 25 | String[] properties() default {}; 26 | 27 | /** 28 | * 简单的查询字段 29 | */ 30 | String[] simpleProperties() default {}; 31 | 32 | /** 33 | * 默认排序字段 34 | */ 35 | String sortField() default "id"; 36 | 37 | /** 38 | * 默认是否升序 39 | */ 40 | boolean isAsc() default true; 41 | 42 | /** 43 | * 增加接口权限名 44 | */ 45 | String createPermission() default "create"; 46 | /** 47 | * 查询接口权限名 48 | */ 49 | String retrievePermission() default "list"; 50 | /** 51 | * 更新接口权限名 52 | */ 53 | String updatePermission() default "update"; 54 | /** 55 | * 删除接口权限名 56 | */ 57 | String deletePermission() default "delete"; 58 | /** 59 | * 更新排除字段 60 | */ 61 | String[] updateIgnoreProperties() default {}; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/annotations/Log.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.annotations; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @description: 操作日志注解 7 | * @copyright: 8 | * @createTime: 2017/11/14 14:12 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | @Target({ElementType.TYPE,ElementType.METHOD}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface Log { 16 | 17 | /** 18 | * 操作描述 19 | */ 20 | String value() default ""; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/annotations/Logined.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020, hubin (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package cn.ffast.core.annotations; 17 | 18 | import java.lang.annotation.*; 19 | 20 | /** 21 | * @description: 登录验证 22 | * @copyright: 23 | * @createTime: 2017/11/14 14:12 24 | * @author:dzy 25 | * @version:1.0 26 | */ 27 | @Target({ElementType.METHOD, ElementType.TYPE}) 28 | @Inherited 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Documented 31 | public @interface Logined { 32 | /** 33 | * 是否对自己生效(false只对基类生效) 34 | * @return 35 | */ 36 | boolean notEffectSelf() default false; 37 | } 38 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/annotations/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020, hubin (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package cn.ffast.core.annotations; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | 25 | 26 | /** 27 | * @description: 权限注解 28 | * @copyright: 29 | * @createTime: 2017/11/14 14:12 30 | * @author:dzy 31 | * @version:1.0 32 | */ 33 | @Target({ElementType.METHOD, ElementType.TYPE}) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | public @interface Permission { 37 | 38 | /** 39 | * 权限内容 40 | */ 41 | String value() default ""; 42 | 43 | /** 44 | * 是否是独立的 45 | * true 不和类注解的权限名组合 46 | * false 没有类注解权限则无效 47 | */ 48 | boolean alone() default false; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/aop/LogAspect.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.aop; 2 | 3 | import cn.ffast.core.annotations.Log; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.Signature; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.reflect.MethodSignature; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.annotation.Resource; 12 | import java.lang.reflect.Method; 13 | 14 | /** 15 | * @description: 日志Aop 16 | * @copyright: 17 | * @createTime: 2017/11/14 14:13 18 | * @author:dzy 19 | * @version:1.0 20 | */ 21 | @Aspect 22 | @Component 23 | public class LogAspect { 24 | 25 | /** 26 | * 日志切入点 27 | */ 28 | @Resource 29 | private LogPoint logPoint; 30 | 31 | /** 32 | * 保存系统操作日志 33 | * 34 | * @param joinPoint 连接点 35 | * @return 方法执行结果 36 | * @throws Throwable 调用出错 37 | */ 38 | @Around(value = "@annotation(cn.ffast.core.annotations.Log)") 39 | public Object saveLog(ProceedingJoinPoint joinPoint) throws Throwable { 40 | /** 41 | * 解析Log注解 42 | */ 43 | Method currentMethod = currentMethod(joinPoint); 44 | Log log = currentMethod.getAnnotation(Log.class); 45 | Log classLog = joinPoint.getTarget().getClass().getAnnotation(Log.class); 46 | /** 47 | * 日志入库 48 | */ 49 | String logStr = null; 50 | if (classLog != null) { 51 | logStr = classLog.value() + "-" + log.value(); 52 | } else { 53 | logStr = log.value(); 54 | } 55 | if (log != null && logPoint != null) { 56 | logPoint.saveLog(joinPoint, currentMethod.getName(), logStr); 57 | } 58 | 59 | /** 60 | * 方法执行 61 | */ 62 | return joinPoint.proceed(); 63 | } 64 | 65 | /** 66 | * 获取当前执行的方法 67 | * 68 | * @param joinPoint 连接点 69 | * @return 方法 70 | */ 71 | private Method currentMethod(ProceedingJoinPoint joinPoint) throws NoSuchMethodException { 72 | Signature sig = joinPoint.getSignature(); 73 | MethodSignature msig = null; 74 | if (!(sig instanceof MethodSignature)) { 75 | throw new IllegalArgumentException("该注解只能用于方法"); 76 | } 77 | msig = (MethodSignature) sig; 78 | Object target = joinPoint.getTarget(); 79 | Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); 80 | return currentMethod; 81 | } 82 | 83 | public LogPoint getLogPoint() { 84 | return logPoint; 85 | } 86 | 87 | public void setLogPoint(LogPoint logPoint) { 88 | this.logPoint = logPoint; 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/aop/LogPoint.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.aop; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | 5 | /** 6 | * @description: 7 | * @copyright: 8 | * @createTime: 2017/11/14 14:55 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | public interface LogPoint { 13 | /** 14 | * 保存日志 15 | * @param joinPoint 16 | * @param methodName 17 | * @param operate 18 | */ 19 | void saveLog(ProceedingJoinPoint joinPoint, String methodName, String operate); 20 | } 21 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/auth/JwtUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.auth; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.auth0.jwt.JWTSigner; 7 | import com.auth0.jwt.JWTVerifier; 8 | import com.auth0.jwt.internal.com.fasterxml.jackson.databind.ObjectMapper; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | public class JwtUtils { 13 | private static Logger logger = LoggerFactory.getLogger(JwtUtils.class); 14 | private static final String SECRET_PREIFX = "@@@FFFFFFFFAAAASSSSTTTT%%%%"; 15 | private static final String EXP = "exp"; 16 | private static final String PAYLOAD = "payload"; 17 | 18 | /** 19 | * get jwt String of object 20 | * 21 | * @param object the POJO object 22 | * @param maxAge the milliseconds of life time 23 | * @return the jwt token 24 | */ 25 | public static String sign(T object, long maxAge, String secret) { 26 | try { 27 | final JWTSigner signer = new JWTSigner(SECRET_PREIFX + secret); 28 | final Map claims = new HashMap(); 29 | ObjectMapper mapper = new ObjectMapper(); 30 | String jsonString = mapper.writeValueAsString(object); 31 | claims.put(PAYLOAD, jsonString); 32 | claims.put(EXP, System.currentTimeMillis() + (maxAge * 1000)); 33 | return signer.sign(claims); 34 | } catch (Exception e) { 35 | return null; 36 | } 37 | } 38 | 39 | /** 40 | * get the object of jwt if not expired 41 | * 42 | * @param jwt 43 | * @return POJO object 44 | */ 45 | public static T unsign(String jwt, Class classT, String secret) { 46 | final JWTVerifier verifier = new JWTVerifier(SECRET_PREIFX + secret); 47 | try { 48 | final Map claims = verifier.verify(jwt); 49 | if (claims.containsKey(EXP) && claims.containsKey(PAYLOAD)) { 50 | long exp = (Long) claims.get(EXP); 51 | long currentTimeMillis = System.currentTimeMillis(); 52 | if (exp > currentTimeMillis) { 53 | String json = (String) claims.get(PAYLOAD); 54 | ObjectMapper objectMapper = new ObjectMapper(); 55 | return objectMapper.readValue(json, classT); 56 | } 57 | } 58 | return null; 59 | } catch (Exception e) { 60 | logger.error(e.getMessage()); 61 | return null; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/auth/OperatorBase.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.auth; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | /** 7 | * @description: 当前登录用户基础类 8 | * @copyright: 9 | * @createTime: 2017/8/31 9:02 10 | * @author:dzy 11 | * @version:1.0 12 | */ 13 | public class OperatorBase { 14 | //当前登录用户名 15 | protected String userName; 16 | //当前登录用户id 17 | protected Long userId; 18 | 19 | protected String token; 20 | //当前登录账号姓名 21 | protected String name; 22 | /** 23 | * 拥有的角色id 24 | */ 25 | protected Set hasRoleId; 26 | 27 | 28 | public String getUserName() { 29 | return userName; 30 | } 31 | 32 | public void setUserName(String userName) { 33 | this.userName = userName; 34 | } 35 | 36 | public Long getUserId() { 37 | return userId; 38 | } 39 | 40 | public void setUserId(Long userId) { 41 | this.userId = userId; 42 | } 43 | 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getToken() { 54 | return token; 55 | } 56 | 57 | public void setToken(String token) { 58 | this.token = token; 59 | } 60 | 61 | public Set getHasRoleId() { 62 | return hasRoleId; 63 | } 64 | 65 | public void setHasRoleId(Set hasRoleId) { 66 | this.hasRoleId = hasRoleId; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/constant/ResultCode.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.constant; 2 | 3 | /** 4 | * @author daizhiyi 5 | * @version 1.0 6 | * @Description: 结果返回code 7 | * @date 2017年3月24日 8 | */ 9 | public enum ResultCode { 10 | /** 11 | * 成功返回 12 | */ 13 | SUCCESS(200, "成功"), 14 | /** 15 | * 未登录系统 16 | */ 17 | NOTLOGIN(1000, "未登录系统!"), 18 | /** 19 | * 操作失败 20 | */ 21 | ERROR(1001, "操作失败!"), 22 | /** 23 | * 权限不足 24 | */ 25 | PERMISSION_DENIED(1002, "权限不足"), 26 | /** 27 | * 不存在 28 | */ 29 | INEXISTENCE(1003, "不存在"), 30 | /** 31 | * 存在 32 | */ 33 | EXIST(1004, "存在"), 34 | /** 35 | * 参数为空 36 | */ 37 | PARAMNULL(1005, "参数为空"), 38 | /** 39 | * 服务内部错误 40 | */ 41 | SERVICE_ERROR(500, "服务内部错误"); 42 | 43 | private int code; 44 | private String message; 45 | 46 | ResultCode(int code, String message) { 47 | this.code = code; 48 | this.message = message; 49 | } 50 | 51 | public String getMessage() { 52 | return message; 53 | } 54 | 55 | public void setMessage(String message) { 56 | this.message = message; 57 | } 58 | 59 | public int getCode() { 60 | return code; 61 | } 62 | 63 | public void setCode(int code) { 64 | this.code = code; 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/constant/ScheduleStatus.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.constant; 2 | 3 | public enum ScheduleStatus { 4 | /** 5 | * 正常 6 | */ 7 | NORMAL(1), 8 | /** 9 | * 暂停 10 | */ 11 | PAUSE(0); 12 | 13 | private int value; 14 | 15 | ScheduleStatus(int value) { 16 | this.value = value; 17 | } 18 | 19 | public int getValue() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/filter/CrossFilter.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.filter; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import javax.servlet.*; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | /** 11 | * 跨域设置 12 | */ 13 | @Component 14 | public class CrossFilter implements Filter { 15 | @Override 16 | public void init(FilterConfig filterConfig) throws ServletException { 17 | 18 | } 19 | 20 | @Override 21 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 22 | HttpServletResponse response = (HttpServletResponse) servletResponse; 23 | HttpServletRequest reqs = (HttpServletRequest) servletRequest; 24 | response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); 25 | response.setHeader("Access-Control-Allow-Credentials", "true"); 26 | response.setHeader("Access-Control-Allow-Methods", "*"); 27 | response.setHeader("Access-Control-Max-Age", "3600"); 28 | response.setHeader("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Authorization"); 29 | filterChain.doFilter(servletRequest, servletResponse); 30 | } 31 | 32 | @Override 33 | public void destroy() { 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/handler/BaseEntityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.handler; 2 | 3 | 4 | import cn.ffast.core.utils.DateUtil; 5 | import com.baomidou.mybatisplus.mapper.MetaObjectHandler; 6 | import org.apache.ibatis.reflection.MetaObject; 7 | 8 | /** 9 | * @description: mybatis plus公共字段填充处理器 10 | * @copyright: 11 | * @createTime: 2017/7/17 10:58 12 | * @author:dzy 13 | * @version:1.0 14 | */ 15 | 16 | public class BaseEntityHandler extends MetaObjectHandler { 17 | 18 | /** 19 | * 测试 user 表 name 字段为空自动填充 20 | */ 21 | @Override 22 | public void insertFill(MetaObject metaObject) { 23 | // 更多查看源码测试用例 24 | //System.out.println("insert fill"); 25 | //mybatis-plus版本2.0.9+ 26 | setFieldValByName("createTime", DateUtil.getNowTimestampStr(), metaObject); 27 | setFieldValByName("lastModifyTime", DateUtil.getNowTimestampStr(), metaObject); 28 | } 29 | 30 | @Override 31 | public void updateFill(MetaObject metaObject) { 32 | //更新填充 33 | //System.out.println("update fill"); 34 | //mybatis-plus版本2.0.9+ 35 | setFieldValByName("lastModifyTime", DateUtil.getNowTimestampStr(), metaObject); 36 | } 37 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.handler; 2 | 3 | import cn.ffast.core.constant.ResultCode; 4 | import cn.ffast.core.vo.ServiceResult; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | 11 | /** 12 | * 全局异常处理 13 | */ 14 | @RestControllerAdvice 15 | public class GlobalExceptionHandler { 16 | private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); 17 | 18 | @ExceptionHandler({Exception.class, NullPointerException.class}) 19 | @ResponseBody 20 | public ServiceResult handleException(Exception e) { 21 | ServiceResult result = new ServiceResult(ResultCode.SERVICE_ERROR.getCode(), ResultCode.SERVICE_ERROR.getMessage()); 22 | if (e != null) { 23 | result.addData("error", e.getMessage()); 24 | e.printStackTrace(); 25 | } else { 26 | logger.error("exception is null"); 27 | } 28 | return result; 29 | } 30 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/redis/GenericMsgpackRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.redis; 2 | 3 | import com.fasterxml.jackson.annotation.JsonTypeInfo.As; 4 | import com.fasterxml.jackson.core.JsonGenerator; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.fasterxml.jackson.databind.SerializerProvider; 8 | import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; 9 | import com.fasterxml.jackson.databind.module.SimpleModule; 10 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 11 | 12 | import java.io.IOException; 13 | 14 | import org.msgpack.core.annotations.Nullable; 15 | import org.msgpack.jackson.dataformat.MessagePackFactory; 16 | import org.springframework.cache.support.NullValue; 17 | import org.springframework.data.redis.serializer.RedisSerializer; 18 | import org.springframework.data.redis.serializer.SerializationException; 19 | import org.springframework.util.Assert; 20 | import org.springframework.util.StringUtils; 21 | 22 | public class GenericMsgpackRedisSerializer implements RedisSerializer { 23 | static final byte[] EMPTY_ARRAY = new byte[0]; 24 | private final ObjectMapper mapper; 25 | 26 | 27 | public GenericMsgpackRedisSerializer() { 28 | this.mapper = new ObjectMapper(new MessagePackFactory()); 29 | this.mapper.registerModule((new SimpleModule()).addSerializer(new GenericMsgpackRedisSerializer.NullValueSerializer(null))); 30 | this.mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY); 31 | } 32 | 33 | @Override 34 | public byte[] serialize(@Nullable Object source) throws SerializationException { 35 | if (source == null) { 36 | return EMPTY_ARRAY; 37 | } else { 38 | try { 39 | return this.mapper.writeValueAsBytes(source); 40 | } catch (JsonProcessingException var3) { 41 | throw new SerializationException("Could not write JSON: " + var3.getMessage(), var3); 42 | } 43 | } 44 | } 45 | 46 | @Override 47 | public Object deserialize(@Nullable byte[] source) throws SerializationException { 48 | return this.deserialize(source, Object.class); 49 | } 50 | 51 | @Nullable 52 | public T deserialize(@Nullable byte[] source, Class type) throws SerializationException { 53 | Assert.notNull(type, "Deserialization type must not be null! Pleaes provide Object.class to make use of Jackson2 default typing."); 54 | if (source == null || source.length == 0) { 55 | return null; 56 | } else { 57 | try { 58 | return this.mapper.readValue(source, type); 59 | } catch (Exception var4) { 60 | throw new SerializationException("Could not read JSON: " + var4.getMessage(), var4); 61 | } 62 | } 63 | } 64 | 65 | private class NullValueSerializer extends StdSerializer { 66 | private static final long serialVersionUID = 2199052150128658111L; 67 | private final String classIdentifier; 68 | 69 | NullValueSerializer(@Nullable String classIdentifier) { 70 | super(NullValue.class); 71 | this.classIdentifier = StringUtils.hasText(classIdentifier) ? classIdentifier : "@class"; 72 | } 73 | 74 | @Override 75 | public void serialize(NullValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 76 | jgen.writeStartObject(); 77 | jgen.writeStringField(this.classIdentifier, NullValue.class.getName()); 78 | jgen.writeEndObject(); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/redis/RedisSerializerType.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.redis; 2 | 3 | public enum RedisSerializerType { 4 | FastJSON(0, "FastJSON"), 5 | JackJson(1, "JackJson"), 6 | Msgpack(2, "Msgpack"); 7 | private String name; 8 | private int type; 9 | 10 | RedisSerializerType(int type, String name) { 11 | this.type = type; 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public int getType() { 24 | return type; 25 | } 26 | 27 | public void setType(int type) { 28 | this.type = type; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/service/CaptchaService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.service; 2 | 3 | 4 | import cn.ffast.core.redis.RedisCacheUtils; 5 | import cn.ffast.core.utils.CaptchaUtils; 6 | import cn.ffast.core.utils.HttpServletUtils; 7 | import cn.ffast.core.utils.Md5Utils; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | import javax.imageio.ImageIO; 13 | import javax.servlet.ServletOutputStream; 14 | import javax.servlet.http.Cookie; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | 19 | /** 20 | * @author dzy 21 | * @Description: 验证码Service实现 22 | * @Copyright: 23 | * @Created 24 | * @vesion 1.0 25 | */ 26 | @Service 27 | public class CaptchaService { 28 | private final static String CAPTCHA_KEY = "captcha:"; 29 | 30 | @Resource 31 | RedisCacheUtils redisCacheUtils; 32 | 33 | 34 | public void buildCaptcha() { 35 | buildCaptcha(HttpServletUtils.getResponse()); 36 | } 37 | 38 | 39 | public void buildCaptcha(HttpServletResponse response) { 40 | CaptchaUtils.Captcha captcha = CaptchaUtils.createCaptcha(120, 30); 41 | String captchaId = Md5Utils.hash(Md5Utils.getUUID()); 42 | response.setContentType("image/jpeg"); 43 | response.setHeader("Pragma", "no-cache"); 44 | response.setHeader("Cache-Control", "no-cache"); 45 | response.setDateHeader("Expires", 0); 46 | Cookie cookie = new Cookie("captchaId", captchaId); 47 | cookie.setMaxAge(1800); 48 | response.addCookie(cookie); 49 | 50 | redisCacheUtils.setCacheObject(CAPTCHA_KEY + captchaId, captcha.getCode(),300); 51 | try { 52 | ServletOutputStream outputStream = response.getOutputStream(); 53 | ImageIO.write(captcha.getImage(), "jpg", outputStream); 54 | } catch (IOException e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | 59 | 60 | public boolean valid(String code) { 61 | return valid(HttpServletUtils.getRequest(), code); 62 | } 63 | 64 | 65 | public boolean valid(HttpServletRequest request, String code) { 66 | Cookie[] cookies = request.getCookies(); 67 | if (cookies != null) { 68 | for (int i = 0; i < cookies.length; i++) { 69 | Cookie cookie = cookies[i]; 70 | if (cookie.getName().equals("captchaId")) { 71 | String key = CAPTCHA_KEY + cookie.getValue(); 72 | String captcha = redisCacheUtils.getCacheObject(key, String.class); 73 | redisCacheUtils.delete(CAPTCHA_KEY + cookie.getValue()); 74 | if (StringUtils.isNotEmpty(captcha) && StringUtils.isNotEmpty(code) && 75 | code.toLowerCase().equals(captcha.toLowerCase())) { 76 | return true; 77 | } 78 | 79 | } 80 | } 81 | } 82 | return false; 83 | } 84 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 3 | * Created by dzy on 2017/4/14. 4 | */ 5 | package cn.ffast.core.support; 6 | 7 | 8 | 9 | import cn.ffast.core.auth.OperatorBase; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.web.context.request.RequestContextHolder; 13 | import org.springframework.web.context.request.ServletRequestAttributes; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import javax.servlet.http.HttpSession; 17 | import java.util.Enumeration; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | 22 | public abstract class BaseController { 23 | private static Logger logger = LoggerFactory.getLogger(BaseController.class); 24 | 25 | protected HttpServletRequest getRequest() { 26 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); 27 | } 28 | 29 | protected HttpServletResponse getResponse() { 30 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse(); 31 | } 32 | 33 | protected void setAttribute(String key, Object data){ 34 | getHttpSession().setAttribute(key,data); 35 | } 36 | 37 | protected HttpSession getHttpSession(){ 38 | return getRequest().getSession(); 39 | } 40 | 41 | protected Object getAttribute(String var1){ 42 | return getHttpSession().getAttribute(var1); 43 | } 44 | 45 | 46 | 47 | /** 48 | * 获取所有请求参数 49 | * 50 | * @return 返回所有请求参数 51 | */ 52 | protected Map getAllParam() { 53 | Map params = new HashMap<>(); 54 | HttpServletRequest request = getRequest(); 55 | Enumeration enu = request.getParameterNames(); 56 | while (enu.hasMoreElements()) { 57 | String paraName = (String) enu.nextElement(); 58 | String val = request.getParameter(paraName); 59 | params.put(paraName, val); 60 | } 61 | return params; 62 | } 63 | 64 | /** 65 | * 获取请求参数 66 | * 67 | * @return 返回所有请求参数 68 | */ 69 | protected Object getRequestParam(String key) { 70 | HttpServletRequest request = getRequest(); 71 | if (request != null) { 72 | return request.getParameter(key); 73 | } 74 | return null; 75 | } 76 | 77 | /** 78 | * 获得请求参数返回指定的强制转换对象 79 | * @param key 80 | * @param clazz 81 | * @param 82 | * @return 83 | */ 84 | protected T getRequestParam(String key, Class clazz) { 85 | Object obj = getRequestParam(key); 86 | if (obj != null) { 87 | return (T) obj; 88 | } 89 | return null; 90 | } 91 | 92 | /** 93 | * 获得请求参数返回字符串 94 | * @param key 95 | * @return 96 | */ 97 | protected String getRequestParamString(String key) { 98 | Object obj = getRequestParam(key); 99 | if (obj != null) { 100 | return obj.toString(); 101 | } 102 | return null; 103 | } 104 | 105 | /** 106 | * 获取后台管理登录信息 107 | * 108 | * @return 109 | */ 110 | protected OperatorBase getLoginUser() { 111 | Object obj = getAttribute("loginUser"); 112 | if (obj != null) { 113 | return (OperatorBase) (obj); 114 | } 115 | return null; 116 | } 117 | 118 | /** 119 | * 获取后台管理登录用户id 120 | * 121 | * @return 122 | */ 123 | protected Long getLoginUserId() { 124 | OperatorBase operator = getLoginUser(); 125 | if (operator != null) { 126 | return operator.getUserId(); 127 | } 128 | return null; 129 | } 130 | 131 | 132 | /** 133 | * 获取后台管理登录信息 134 | * @return 135 | */ 136 | protected T getLoginUser(Class clazz) { 137 | return (T) (getAttribute("loginUser")); 138 | } 139 | 140 | /** 141 | * 获得日志对象,供子类重写 142 | * @return 143 | */ 144 | protected abstract Logger getLogger(); 145 | 146 | } 147 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.enums.FieldFill; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * @description: 实体基类 13 | * @copyright: 14 | * @createTime: 2017年9月12日下午5:27:50 15 | * @author:dzy 16 | * @version:1.0 17 | */ 18 | public class BaseEntity extends Model implements Serializable { 19 | 20 | @TableField(exist = false) 21 | private static final long serialVersionUID = -34115333603863619L; 22 | /** 23 | * 主键Id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | protected Long id; 27 | /** 28 | * name 29 | */ 30 | @TableId(value = "name") 31 | protected String name; 32 | /** 33 | * 创建人 34 | */ 35 | @TableField("creator_id") 36 | private Long creatorId; 37 | /** 38 | * 创建时间 39 | */ 40 | @TableField(value = "create_time", fill = FieldFill.INSERT) 41 | private String createTime; 42 | /** 43 | * 最后修改时间 44 | */ 45 | @TableField(value = "last_modify_time", fill = FieldFill.INSERT_UPDATE, update = "now()") 46 | private String lastModifyTime; 47 | /** 48 | * 最后修改人 49 | */ 50 | @TableField("last_modifier_id") 51 | private Long lastModifierId; 52 | 53 | 54 | public Long getId() { 55 | return id; 56 | } 57 | 58 | public void setId(Long id) { 59 | this.id = id; 60 | } 61 | 62 | public String getCreateTime() { 63 | return createTime; 64 | } 65 | 66 | public void setCreateTime(String createTime) { 67 | this.createTime = createTime; 68 | } 69 | 70 | public Long getCreatorId() { 71 | return creatorId; 72 | } 73 | 74 | public void setCreatorId(Long creatorId) { 75 | this.creatorId = creatorId; 76 | } 77 | 78 | public String getLastModifyTime() { 79 | return lastModifyTime; 80 | } 81 | 82 | public void setLastModifyTime(String lastModifyTime) { 83 | this.lastModifyTime = lastModifyTime; 84 | } 85 | 86 | public Long getLastModifierId() { 87 | return lastModifierId; 88 | } 89 | 90 | public void setLastModifierId(Long lastModifierId) { 91 | this.lastModifierId = lastModifierId; 92 | } 93 | 94 | public String getName() { 95 | return name; 96 | } 97 | 98 | public void setName(String name) { 99 | this.name = name; 100 | } 101 | 102 | @Override 103 | protected Serializable pkVal() { 104 | return this.id; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import cn.ffast.core.auth.OperatorBase; 4 | import cn.ffast.core.utils.HttpServletUtils; 5 | import com.baomidou.mybatisplus.mapper.BaseMapper; 6 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 7 | import com.baomidou.mybatisplus.toolkit.ReflectionKit; 8 | import org.springframework.web.context.request.RequestContextHolder; 9 | import org.springframework.web.context.request.ServletRequestAttributes; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.util.Enumeration; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * @description: 20 | * @copyright: 21 | * @createTime: 2017/10/28 23:20 22 | * @author:dzy 23 | * @version:1.0 24 | */ 25 | public class BaseService, T extends BaseEntity> extends ServiceImpl { 26 | protected HttpServletRequest getRequest() { 27 | return HttpServletUtils.getRequest(); 28 | } 29 | 30 | protected HttpServletResponse getResponse() { 31 | return HttpServletUtils.getResponse(); 32 | } 33 | 34 | 35 | /** 36 | * 获取所有请求参数 37 | * 38 | * @return 返回所有请求参数 39 | */ 40 | protected Map getAllParam() { 41 | return HttpServletUtils.getAllParam(); 42 | } 43 | 44 | /** 45 | * 获取请求参数 46 | * 47 | * @return 返回所有请求参数 48 | */ 49 | protected Object getRequestParam(String key) { 50 | HttpServletRequest request = getRequest(); 51 | if (request != null) { 52 | return request.getParameter(key); 53 | } 54 | return null; 55 | } 56 | 57 | /** 58 | * 获得请求参数返回指定的强制转换对象 59 | * @param key 60 | * @param clazz 61 | * @param 62 | * @return 63 | */ 64 | protected T getRequestParam(String key, Class clazz) { 65 | Object obj = getRequestParam(key); 66 | if (obj != null) { 67 | return (T) obj; 68 | } 69 | return null; 70 | } 71 | 72 | /** 73 | * 获得请求参数返回字符串 74 | * @param key 75 | * @return 76 | */ 77 | protected String getRequestParamString(String key) { 78 | Object obj = getRequestParam(key); 79 | if (obj != null) { 80 | return obj.toString(); 81 | } 82 | return null; 83 | } 84 | 85 | /** 86 | * 获取后台管理登录信息 87 | * 88 | * @return 89 | */ 90 | protected OperatorBase getLoginUser() { 91 | Object obj = HttpServletUtils.getRequestAttribute("loginUser"); 92 | if (obj != null) { 93 | return (OperatorBase) (obj); 94 | } 95 | return null; 96 | } 97 | 98 | /** 99 | * 获取后台管理登录用户id 100 | * 101 | * @return 102 | */ 103 | protected Long getLoginUserId() { 104 | OperatorBase operator = getLoginUser(); 105 | if (operator != null) { 106 | return operator.getUserId(); 107 | } 108 | return null; 109 | } 110 | 111 | @Override 112 | protected Class currentModelClass() { 113 | return ReflectionKit.getSuperClassGenricType(this.getClass(), 1); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/IAuthService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | 4 | import cn.ffast.core.vo.ServiceResult; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | public interface IAuthService { 9 | /** 10 | * 登录接口 11 | * @param username 账户 12 | * @param password 密码 13 | * @param captcha 验证码 14 | * @param getMenuPerms 同时获得菜单权限 15 | * @return 16 | */ 17 | ServiceResult login(String username, String password, String captcha, boolean getMenuPerms); 18 | 19 | /** 20 | * 退出登录 21 | * 22 | * @param token 23 | * @return 24 | */ 25 | ServiceResult logout(String token); 26 | 27 | /** 28 | * 获取当前登录账户角色菜单权限 29 | * @param roleName 30 | * @return 31 | */ 32 | ServiceResult getMenuPermsByRoleName(String roleName); 33 | } 34 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/ICrudService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import cn.ffast.core.vo.ServiceRowsResult; 4 | import cn.ffast.core.vo.ServiceResult; 5 | import com.baomidou.mybatisplus.plugins.Page; 6 | import com.baomidou.mybatisplus.service.IService; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @description: 基础增删改查 12 | * @copyright: 13 | * @createTime: 2017/9/5 9:39 14 | * @author:dzy 15 | * @version:1.0 16 | */ 17 | public interface ICrudService extends IService { 18 | /** 19 | * @description: 插入对象 20 | * @createTime: 2017-9-5 10:00 21 | * @author: dzy 22 | * @param m 实体类 23 | * @return 24 | */ 25 | ServiceResult create(T m); 26 | /** 27 | * @description: 更新对象 28 | * @createTime: 2017-9-5 10:00 29 | * @author: dzy 30 | * @param m 实体类 31 | * @param updateAllColumn 是否更新所有字段 32 | * @param ignoreProperties 更新排除字段 33 | * @return 34 | */ 35 | ServiceResult update(T m, boolean updateAllColumn,String[] ignoreProperties); 36 | /** 37 | * @description: 批量删除 38 | * @createTime: 2017-9-5 10:00 39 | * @author: dzy 40 | * @param ids 41 | * @return 42 | */ 43 | ServiceResult mulDelete(String ids); 44 | /** 45 | * @description: 根据Id删除对象 46 | * @createTime: 2017-9-5 10:00 47 | * @author: dzy 48 | * @param id 49 | * @return 50 | */ 51 | ServiceResult delById(ID id); 52 | /** 53 | * @description: 删除支持批量 54 | * @createTime: 2017-9-5 10:00 55 | * @author: dzy 56 | * @param ids 57 | * @return 58 | */ 59 | ServiceResult delete(String ids); 60 | /** 61 | * @description: 根据Id发现对象 62 | * @createTime: 2017-9-5 10:00 63 | * @author: dzy 64 | * @param id 65 | * @return 66 | */ 67 | T findById(ID id); 68 | /** 69 | * @description: 分页查询 70 | * @createTime: 2017-9-5 10:00 71 | * @author: dzy 72 | * @param m 73 | * @param page 74 | */ 75 | ServiceRowsResult findListByPage(T m, Page page); 76 | /** 77 | * @description: 分页查询 78 | * @createTime: 2017-9-5 10:00 79 | * @author: dzy 80 | * @param m 81 | * @param page 82 | */ 83 | ServiceRowsResult findListByPage(T m, Page page,String[] properties); 84 | /** 85 | * @description: 查询 86 | * @createTime: 2017-9-5 10:00 87 | * @author: dzy 88 | * @param m 89 | * @param properties 查询字段 90 | * @return 91 | */ 92 | ServiceRowsResult list(T m,String[] properties); 93 | /** 94 | * @description: 查询 95 | * @createTime: 2017-9-5 10:00 96 | * @author: dzy 97 | * @param m 98 | * @param properties 查询字段 99 | * @return 100 | */ 101 | List selectList(T m,String[] properties); 102 | 103 | } 104 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/AnnotationUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.reflect.Field; 5 | import java.lang.reflect.InvocationHandler; 6 | import java.lang.reflect.Proxy; 7 | import java.util.Map; 8 | 9 | public class AnnotationUtils { 10 | 11 | public static void setAnnotationValue(Annotation annotationClass, String key, Object value) { 12 | if(annotationClass==null){} 13 | try { 14 | //获取这个代理实例所持有的 InvocationHandler 15 | InvocationHandler h = Proxy.getInvocationHandler(annotationClass); 16 | // 获取 AnnotationInvocationHandler 的 memberValues 字段 17 | Field hField = null; 18 | hField = h.getClass().getDeclaredField("memberValues"); 19 | // 因为这个字段事 private final 修饰,所以要打开权限 20 | hField.setAccessible(true); 21 | Map memberValues = null; 22 | memberValues = (Map) hField.get(h); 23 | // 修改 权限注解value 属性值 24 | memberValues.put(key, value); 25 | } catch (IllegalAccessException e) { 26 | e.printStackTrace(); 27 | } catch (NoSuchFieldException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/CodeUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.codec.binary.Hex; 4 | import org.apache.commons.lang3.RandomStringUtils; 5 | 6 | import java.security.MessageDigest; 7 | 8 | public class CodeUtil { 9 | public static final String KEY_SHA = "SHA"; 10 | public static final String KEY_MD5 = "MD5"; 11 | 12 | /** 13 | * MAC算法可选以下多种算法 14 | * 15 | * 16 | * HmacMD5 17 | * HmacSHA1 18 | * HmacSHA256 19 | * HmacSHA384 20 | * HmacSHA512 21 | * 22 | */ 23 | public static final String KEY_MAC = "HmacMD5"; 24 | 25 | /** 26 | * MD5加密 27 | * 28 | * @param data 29 | * @return 30 | * @throws Exception 31 | */ 32 | public static byte[] encryptMD5(byte[] data) throws Exception { 33 | MessageDigest md5 = MessageDigest.getInstance(KEY_MD5); 34 | md5.update(data); 35 | return md5.digest(); 36 | 37 | } 38 | 39 | /** 40 | * SHA加密 41 | * 42 | * @param data 43 | * @return 44 | * @throws Exception 45 | */ 46 | public static byte[] encryptSHA(byte[] data) throws Exception { 47 | MessageDigest sha = MessageDigest.getInstance(KEY_SHA); 48 | sha.update(data); 49 | return sha.digest(); 50 | } 51 | 52 | public static byte[] hex2byte(String str) { 53 | if (str == null) { 54 | return null; 55 | } 56 | str = str.trim(); 57 | int len = str.length(); 58 | if (len == 0 || len % 2 == 1) { 59 | return null; 60 | } 61 | 62 | byte[] b = new byte[len / 2]; 63 | try { 64 | for (int i = 0; i < str.length(); i += 2) { 65 | b[i / 2] = (byte) Integer.decode( 66 | "0x" + str.substring(i, i + 2)).intValue(); 67 | } 68 | return b; 69 | } catch (Exception e) { 70 | return null; 71 | } 72 | } 73 | 74 | public static void main(String[] args) throws Exception { 75 | int no = (int) (40 * Math.random() + 10); 76 | String str = RandomStringUtils.randomAlphanumeric(no); 77 | System.out.println(str); 78 | System.out.println(Hex.encodeHexString(encryptMD5("a123456".getBytes()))); 79 | System.out.println(Hex.encodeHexString(encryptSHA(("a123456" + str).getBytes()))); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.util.Collection; 4 | import java.util.Iterator; 5 | 6 | 7 | public class CollectionUtils { 8 | 9 | public static String arraryToString(Collection collection) { 10 | Iterator it = collection.iterator(); 11 | if (!it.hasNext()) { 12 | return ""; 13 | } 14 | StringBuilder sb = new StringBuilder(); 15 | for (; ; ) { 16 | E e = it.next(); 17 | sb.append(e == collection ? "(this Collection)" : e); 18 | if (!it.hasNext()) { 19 | return sb.toString(); 20 | } 21 | sb.append(','); 22 | } 23 | } 24 | 25 | public static boolean isEmpty(Collection> coll) { 26 | return coll == null || coll.isEmpty(); 27 | } 28 | 29 | public static boolean isNotEmpty(Collection> coll) { 30 | return !isEmpty(coll); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/FStringUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.util.*; 7 | 8 | public class FStringUtil { 9 | 10 | /** 11 | * 将字符串source根据separator分割成字符串数组 12 | * 13 | * @param source 14 | * @param separator 15 | * @return 16 | */ 17 | public static List listSplit(String source, String separator) { 18 | if (source == null) { 19 | return null; 20 | } 21 | int i = 0; 22 | List list = new ArrayList<>(StringUtils.countMatches(source, separator) + 1); 23 | while (source.length() > 0) { 24 | String value = StringUtils.substringBefore(source, separator); 25 | if (!StringUtils.isEmpty(value)) { 26 | list.add(value); 27 | } 28 | 29 | source = StringUtils.substringAfter(source, separator); 30 | } 31 | return list; 32 | } 33 | 34 | /** 35 | * 将字符串source根据separator分割成字符串数组 36 | * 37 | * @param source 38 | * @param separator 39 | * @return 40 | */ 41 | public static String[] split(String source, String separator) { 42 | String[] distArray = {}; 43 | if (source == null) { 44 | return null; 45 | } 46 | int i = 0; 47 | distArray = new String[StringUtils.countMatches(source, separator) + 1]; 48 | while (source.length() > 0) { 49 | String value = StringUtils.substringBefore(source, separator); 50 | distArray[i++] = StringUtils.isEmpty(value) ? null : value; 51 | source = StringUtils.substringAfter(source, separator); 52 | } 53 | if (distArray[distArray.length - 1] == null) {// 排除最后一个分隔符后放空 54 | distArray[distArray.length - 1] = null; 55 | } 56 | return distArray; 57 | } 58 | 59 | /** 60 | * 判断str最后一个字符是否包含str2是的话删除 61 | * @param str 62 | * @param str2 63 | * @return 64 | */ 65 | public static String removeLast(String str, String str2) { 66 | if (StringUtils.isEmpty(str) || StringUtils.isEmpty(str2)) { 67 | return null; 68 | } 69 | if (str2.equals(str.substring(str.length() - 1))) { 70 | str = str.substring(0, str.length() - 1); 71 | } 72 | return str; 73 | } 74 | 75 | /** 76 | * 将字符串source根据全局变量GobelConstants.SPLIT_SEPARATOR分割成字符串数组 77 | * 78 | * @param source 79 | * @return 80 | */ 81 | public static String[] split(String source) { 82 | return split(source, ","); 83 | } 84 | 85 | 86 | public static void main(String[] args) { 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/FileUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.io.FileUtils; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.io.*; 7 | 8 | /** 9 | * 文件处理类 10 | */ 11 | public class FileUtil { 12 | 13 | /** 14 | * 下载文件 15 | * @param response 16 | * @param filePath 17 | * @param fileName 18 | */ 19 | public static void downloadFile(HttpServletResponse response, 20 | String filePath, String fileName) { 21 | 22 | InputStream is = null; 23 | OutputStream os = null; 24 | BufferedOutputStream bos = null; 25 | File file = new File(filePath); 26 | 27 | try { 28 | if(file.exists()){ 29 | response.setContentType("APPLICATION/OCTET-STREAM;charset=UTF-8"); 30 | fileName = fileName.replace(",", ","); 31 | String formatFileName = java.net.URLEncoder.encode(fileName, "UTF-8"); 32 | response.setHeader("Content-Disposition", "attachment; filename="+ formatFileName); 33 | is = new BufferedInputStream(new FileInputStream(file)); 34 | os = response.getOutputStream(); 35 | bos = new BufferedOutputStream(os); 36 | 37 | byte[] buffer = new byte[1024]; 38 | 39 | int len = 0; 40 | 41 | while (-1 != (len = is.read(buffer))) { 42 | bos.write(buffer, 0, len); 43 | 44 | } 45 | bos.flush(); 46 | } 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } finally { 50 | try { 51 | if (bos != null) { 52 | bos.close(); 53 | } 54 | if (os != null) { 55 | os.close(); 56 | } 57 | if (is != null) { 58 | is.close(); 59 | } 60 | 61 | } catch (IOException e) { 62 | e.printStackTrace(); 63 | } 64 | 65 | } 66 | } 67 | 68 | public static void deleteFile(String filePath){ 69 | File file = new File(filePath); 70 | if(file.exists()){ 71 | FileUtils.deleteQuietly(file); 72 | } 73 | } 74 | public static void saveFileNew(InputStream source, File dest) { 75 | InputStream is = null; 76 | OutputStream os = null; 77 | try { 78 | is = new BufferedInputStream(source); 79 | 80 | os = new BufferedOutputStream(new FileOutputStream(dest)); 81 | 82 | int len = 0; 83 | 84 | byte[] buffer = new byte[1024]; 85 | 86 | while (-1 != (len = is.read(buffer))) { 87 | os.write(buffer, 0, len); 88 | 89 | } 90 | os.flush(); 91 | } catch (IOException e) { 92 | e.printStackTrace(); 93 | throw new RuntimeException(); 94 | } finally { 95 | try { 96 | if (os != null) { 97 | os.close(); 98 | } 99 | if (is != null) { 100 | is.close(); 101 | } 102 | } catch (IOException e) { 103 | e.printStackTrace(); 104 | } 105 | } 106 | } 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/GzipUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | import java.io.ByteArrayInputStream; 3 | import java.io.ByteArrayOutputStream; 4 | import java.util.zip.GZIPInputStream; 5 | import java.util.zip.GZIPOutputStream; 6 | 7 | /** 8 | * Gzip压缩解压工具类 9 | */ 10 | 11 | public class GzipUtils { 12 | /** 13 | * 压缩 14 | * @param data 15 | * @return 16 | * @throws Exception 17 | */ 18 | public static byte[] gzip(byte[] data) throws Exception { 19 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 20 | GZIPOutputStream gzip = new GZIPOutputStream(bos); 21 | gzip.write(data); 22 | gzip.finish(); 23 | gzip.close(); 24 | byte[] ret = bos.toByteArray(); 25 | bos.close(); 26 | return ret; 27 | } 28 | 29 | /** 30 | * 解压 31 | * @param data 32 | * @return 33 | * @throws Exception 34 | */ 35 | public static byte[] ungzip(byte[] data) throws Exception { 36 | ByteArrayInputStream bis = new ByteArrayInputStream(data); 37 | GZIPInputStream gzip = new GZIPInputStream(bis); 38 | byte[] buf = new byte[1024]; 39 | int num = -1; 40 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 41 | while ((num = gzip.read(buf, 0, buf.length)) != -1) { 42 | bos.write(buf, 0, num); 43 | } 44 | gzip.close(); 45 | bis.close(); 46 | byte[] ret = bos.toByteArray(); 47 | bos.flush(); 48 | bos.close(); 49 | return ret; 50 | } 51 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/HttpServletUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.springframework.web.context.request.RequestContextHolder; 4 | import org.springframework.web.context.request.ServletRequestAttributes; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import javax.servlet.http.HttpSession; 9 | import java.util.Enumeration; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | public class HttpServletUtils { 14 | 15 | public static HttpServletRequest getRequest() { 16 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); 17 | } 18 | 19 | public static HttpServletResponse getResponse() { 20 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse(); 21 | } 22 | 23 | public static void setAttribute(String key, Object data) { 24 | getHttpSession().setAttribute(key, data); 25 | } 26 | 27 | public static HttpSession getHttpSession() { 28 | return getRequest().getSession(); 29 | } 30 | 31 | public static Object getSessionAttribute(String var1) { 32 | return getHttpSession().getAttribute(var1); 33 | } 34 | 35 | public static Object getRequestAttribute(String var1) { 36 | return getRequest().getAttribute(var1); 37 | } 38 | 39 | 40 | /** 41 | * 获取所有请求参数 42 | * 43 | * @return 返回所有请求参数 44 | */ 45 | public static Map getAllParam() { 46 | Map params = new HashMap<>(); 47 | HttpServletRequest request = getRequest(); 48 | Enumeration enu = request.getParameterNames(); 49 | while (enu.hasMoreElements()) { 50 | String paraName = (String) enu.nextElement(); 51 | String val = request.getParameter(paraName); 52 | params.put(paraName, val); 53 | } 54 | return params; 55 | } 56 | 57 | /** 58 | * 获取请求参数 59 | * 60 | * @return 返回所有请求参数 61 | */ 62 | public static Object getRequestParam(String key) { 63 | HttpServletRequest request = getRequest(); 64 | if (request != null) { 65 | return request.getParameter(key); 66 | } 67 | return null; 68 | } 69 | 70 | /** 71 | * 获得请求参数返回指定的强制转换对象 72 | * @param key 73 | * @param clazz 74 | * @param 75 | * @return 76 | */ 77 | public static T getRequestParam(String key, Class clazz) { 78 | Object obj = getRequestParam(key); 79 | if (obj != null) { 80 | return (T) obj; 81 | } 82 | return null; 83 | } 84 | 85 | /** 86 | * 获得请求参数返回字符串 87 | * @param key 88 | * @return 89 | */ 90 | public static String getRequestParamString(String key) { 91 | Object obj = getRequestParam(key); 92 | if (obj != null) { 93 | return obj.toString(); 94 | } 95 | return null; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * Ip工具类 7 | */ 8 | public class IpUtils { 9 | private IpUtils() { 10 | } 11 | 12 | /** 13 | * 取得ip地址 14 | * @param request 15 | * @return 16 | */ 17 | public static String getIpAddr(HttpServletRequest request) { 18 | if (request == null) { 19 | return "unknown"; 20 | } 21 | String ip = request.getHeader("x-forwarded-for"); 22 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 23 | ip = request.getHeader("Proxy-Client-IP"); 24 | } 25 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 26 | ip = request.getHeader("X-Forwarded-For"); 27 | } 28 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 29 | ip = request.getHeader("WL-Proxy-Client-IP"); 30 | } 31 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 32 | ip = request.getHeader("X-Real-IP"); 33 | } 34 | 35 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 36 | ip = request.getRemoteAddr(); 37 | } 38 | return ip; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/Md5Utils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.security.MessageDigest; 7 | import java.util.UUID; 8 | 9 | public class Md5Utils { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class); 12 | 13 | 14 | public static String getUUID() { 15 | return UUID.randomUUID().toString().replace("-", "").toUpperCase(); 16 | } 17 | 18 | private static byte[] md5(String s) { 19 | MessageDigest algorithm; 20 | try { 21 | algorithm = MessageDigest.getInstance("MD5"); 22 | algorithm.reset(); 23 | algorithm.update(s.getBytes("UTF-8")); 24 | byte[] messageDigest = algorithm.digest(); 25 | return messageDigest; 26 | } catch (Exception e) { 27 | LOGGER.error("MD5 Error...", e); 28 | } 29 | return null; 30 | } 31 | 32 | private static final String toHex(byte[] hash) { 33 | if (hash == null) { 34 | return null; 35 | } 36 | StringBuffer buf = new StringBuffer(hash.length * 2); 37 | int i; 38 | 39 | for (i = 0; i < hash.length; i++) { 40 | if ((hash[i] & 0xff) < 0x10) { 41 | buf.append("0"); 42 | } 43 | buf.append(Long.toString(hash[i] & 0xff, 16)); 44 | } 45 | return buf.toString(); 46 | } 47 | 48 | public static String hash(String s) { 49 | try { 50 | return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); 51 | } catch (Exception e) { 52 | LOGGER.error("not supported charset...{}", e); 53 | return s; 54 | } 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/PasswordUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.codec.binary.Hex; 4 | import org.apache.commons.lang3.RandomStringUtils; 5 | 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * 密码工具类 11 | */ 12 | public class PasswordUtil { 13 | /** 14 | * 取得随机字符串 15 | * @param from 16 | * @param distance 17 | * @return 18 | */ 19 | public static String getRandom(int from,int distance){ 20 | int no =(int) (distance* Math.random() +from ); 21 | return RandomStringUtils.randomAlphanumeric(no).toLowerCase(); 22 | } 23 | 24 | /** 25 | * 取得用户密码 26 | * @param prefix 27 | * @param pwd 28 | * @param suffix 29 | * @return 30 | */ 31 | public static String getPwd(String prefix,String pwd,String suffix){ 32 | try { 33 | String md5PWD = Hex.encodeHexString(CodeUtil.encryptMD5(pwd.getBytes())); 34 | String str = prefix+md5PWD+suffix; 35 | return Hex.encodeHexString(CodeUtil.encryptSHA(str.getBytes())); 36 | } catch (Exception e) { 37 | new RuntimeException(e.getMessage()); 38 | } 39 | return null; 40 | } 41 | 42 | /** 43 | * @description: 取得用户密码 44 | * @createTime: 2017年6月2日 下午6:38:03 45 | * @author: lys 46 | * @param prefix 47 | * @param pwd 48 | * @param suffix 49 | * @return 50 | */ 51 | public static String getPwd(String prefix,String pwd){ 52 | return getPwd(prefix,pwd,""); 53 | } 54 | 55 | 56 | /** 57 | * 密码验证:不能全是数字或全是字母,长度>6 58 | */ 59 | public static Boolean valdateUsepwd(String usepwd) { 60 | String pwdPattern = "(?!^\\d+$)(?!^[a-zA-Z]+$).{6,}"; 61 | Pattern pattern = Pattern.compile(pwdPattern); 62 | Matcher matcher = pattern.matcher(usepwd); 63 | return matcher.matches(); 64 | } 65 | 66 | 67 | public static void main(String[] args) { 68 | 69 | System.out.println(PasswordUtil.getPwd("sfff","123456")); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.lang3.ArrayUtils; 4 | 5 | import java.lang.reflect.Field; 6 | import java.lang.reflect.Method; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | public class ReflectionUtils { 12 | 13 | public static void reflectClassValueToNull(Object model, String[] fieldNames) throws Exception { 14 | if (ArrayUtils.isEmpty(fieldNames)) { 15 | return; 16 | } 17 | List fieldArray = Arrays.asList(fieldNames); 18 | // 获取此类的所有父类 19 | List> listSuperClass = new ArrayList<>(10); 20 | Class> superClass = model.getClass().getSuperclass(); 21 | while (superClass != null) { 22 | if (superClass.getName().equals("java.lang.Object")) { 23 | break; 24 | } 25 | listSuperClass.add(superClass); 26 | superClass = superClass.getSuperclass(); 27 | } 28 | // 遍历处理所有父类的字段 29 | for (Class> clazz : listSuperClass) { 30 | Field[] fields = clazz.getDeclaredFields(); 31 | for (int i = 0; i < fields.length; i++) { 32 | String name = fields[i].getName(); 33 | if (fieldArray.contains(name)) { 34 | Class type = fields[i].getType(); 35 | Method method = clazz.getMethod("set" + name.replaceFirst(name.substring(0, 1), 36 | name.substring(0, 1).toUpperCase()), type); 37 | method.invoke(model, new Object[]{null}); 38 | } 39 | 40 | } 41 | } 42 | // 处理此类自己的字段 43 | Field[] fields = model.getClass().getDeclaredFields(); 44 | for (int i = 0; i < fields.length; i++) { 45 | String name = fields[i].getName(); 46 | if (fieldArray.contains(name)) { 47 | Class type = fields[i].getType(); 48 | // 获取属性的set方法 49 | Method method = model.getClass().getMethod("set" + name.replaceFirst(name.substring(0, 1), 50 | name.substring(0, 1).toUpperCase()), type); 51 | // 将值设为null 52 | method.invoke(model, new Object[]{null}); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/SpringContextUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | 9 | /** 10 | * @description: Spring Context 工具类 11 | * @copyright: 12 | * @createTime: 2018/6/29 15:23 13 | * @author:dzy 14 | * @version:1.0 15 | */ 16 | @Component 17 | public class SpringContextUtils implements ApplicationContextAware { 18 | public static ApplicationContext applicationContext; 19 | 20 | @Override 21 | public void setApplicationContext(ApplicationContext applicationContext) 22 | throws BeansException { 23 | SpringContextUtils.applicationContext = applicationContext; 24 | } 25 | 26 | public static Object getBean(String name) { 27 | return applicationContext.getBean(name); 28 | } 29 | 30 | public static T getBean(String name, Class requiredType) { 31 | return applicationContext.getBean(name, requiredType); 32 | } 33 | 34 | public static boolean containsBean(String name) { 35 | return applicationContext.containsBean(name); 36 | } 37 | 38 | public static boolean isSingleton(String name) { 39 | return applicationContext.isSingleton(name); 40 | } 41 | 42 | public static Class extends Object> getType(String name) { 43 | return applicationContext.getType(name); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/Underline2Camel.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | /** 6 | * @description: 7 | * @copyright: 8 | * @createTime: 2017/12/11 14:49 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | public class Underline2Camel { 13 | /** 14 | * 下划线转驼峰法 15 | * @param line 源字符串 16 | * @param smallCamel 大小驼峰,是否为小驼峰 17 | * @return 转换后的字符串 18 | */ 19 | public static String underline2Camel(String line,boolean smallCamel){ 20 | if(line==null||"".equals(line)){ 21 | return ""; 22 | } 23 | StringBuffer sb=new StringBuffer(); 24 | Pattern pattern=Pattern.compile("([A-Za-z\\d]+)(_)?"); 25 | Matcher matcher=pattern.matcher(line); 26 | while(matcher.find()){ 27 | String word=matcher.group(); 28 | sb.append(smallCamel&&matcher.start()==0?Character.toLowerCase(word.charAt(0)):Character.toUpperCase(word.charAt(0))); 29 | int index=word.lastIndexOf('_'); 30 | if(index>0){ 31 | sb.append(word.substring(1, index).toLowerCase()); 32 | }else{ 33 | sb.append(word.substring(1).toLowerCase()); 34 | } 35 | } 36 | return sb.toString(); 37 | } 38 | /** 39 | * 驼峰法转下划线 40 | * @param line 源字符串 41 | * @return 转换后的字符串 42 | */ 43 | public static String camel2Underline(String line){ 44 | if(line==null||"".equals(line)){ 45 | return ""; 46 | } 47 | line=String.valueOf(line.charAt(0)).toUpperCase().concat(line.substring(1)); 48 | StringBuffer sb=new StringBuffer(); 49 | Pattern pattern=Pattern.compile("[A-Z]([a-z\\d]+)?"); 50 | Matcher matcher=pattern.matcher(line); 51 | while(matcher.find()){ 52 | String word=matcher.group(); 53 | sb.append(word.toUpperCase()); 54 | sb.append(matcher.end()==line.length()?"":"_"); 55 | } 56 | return sb.toString(); 57 | } 58 | public static void main(String[] args) { 59 | String line="I_HAVE_AN_IPANG3_PIG"; 60 | String camel=underline2Camel(line,true); 61 | System.out.println(camel); 62 | System.out.println(camel2Underline(camel)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/Menu.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | 4 | /** 5 | * @description: 6 | * @copyright: 7 | * @createTime: 2017/8/31 17:23 8 | * @author:dzy 9 | * @version:1.0 10 | */ 11 | 12 | public class Menu { 13 | private Long id; 14 | /* 15 | 菜单名 16 | */ 17 | private String name; 18 | /* 19 | 菜单图标 20 | */ 21 | private String icon; 22 | /* 23 | 访问路径 24 | */ 25 | private String url; 26 | /* 27 | 组件名 28 | */ 29 | private String component; 30 | /** 31 | * 父id 32 | */ 33 | private Long parentId; 34 | 35 | 36 | public Long getId() { 37 | return id; 38 | } 39 | 40 | public void setId(Long id) { 41 | this.id = id; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | public String getIcon() { 53 | return icon; 54 | } 55 | 56 | public void setIcon(String icon) { 57 | this.icon = icon; 58 | } 59 | 60 | public String getUrl() { 61 | return url; 62 | } 63 | 64 | public void setUrl(String url) { 65 | this.url = url; 66 | } 67 | 68 | public String getComponent() { 69 | return component; 70 | } 71 | 72 | public void setComponent(String component) { 73 | this.component = component; 74 | } 75 | 76 | public Long getParentId() { 77 | return parentId; 78 | } 79 | 80 | public void setParentId(Long parentId) { 81 | this.parentId = parentId; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/ServiceResult.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | 5 | import java.io.Serializable; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * service层执行的结果 11 | */ 12 | public class ServiceResult implements Serializable { 13 | private static final long serialVersionUID = 1L; 14 | /** 15 | * 返回的信息 16 | */ 17 | protected String message; 18 | /** 19 | * 执行是否成功 20 | */ 21 | protected Boolean success; 22 | 23 | protected Integer errNo; 24 | 25 | protected Map data = new HashMap(); 26 | 27 | public ServiceResult() { 28 | } 29 | 30 | public ServiceResult(Boolean success) { 31 | this.success = success; 32 | } 33 | 34 | public ServiceResult(Integer errNo, String message) { 35 | this.errNo = errNo; 36 | this.message = message; 37 | this.success = false; 38 | } 39 | 40 | public String toJSON() { 41 | JSONObject result = new JSONObject(); 42 | result.put("message", message); 43 | result.put("success", success); 44 | result.put("data", data); 45 | result.put("errNo", errNo); 46 | return result.toString(); 47 | } 48 | 49 | /** 50 | * 添加数据 51 | * 52 | * @param key 53 | * @param value 54 | */ 55 | public ServiceResult addData(String key, Object value) { 56 | data.put(key, value); 57 | return this; 58 | } 59 | 60 | public ServiceResult setMessage(String message) { 61 | this.message = message; 62 | return this; 63 | } 64 | 65 | public String getMessage() { 66 | return this.message; 67 | } 68 | 69 | public Boolean getSuccess() { 70 | return success; 71 | } 72 | 73 | public ServiceResult setSuccess(Boolean success) { 74 | this.success = success; 75 | return this; 76 | } 77 | 78 | public Integer getErrNo() { 79 | return errNo; 80 | } 81 | 82 | public ServiceResult setErrNo(Integer errNo) { 83 | this.errNo = errNo; 84 | return this; 85 | } 86 | 87 | public Map getData() { 88 | return data; 89 | } 90 | 91 | public ServiceResult setData(Map data) { 92 | this.data = data; 93 | return this; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/ServiceRowsResult.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @Description: 分页结果 7 | * @author dzy 8 | * @vesion 1.0 9 | */ 10 | public class ServiceRowsResult extends ServiceResult { 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ServiceRowsResult(){} 14 | 15 | public ServiceRowsResult(Boolean success){ 16 | this.success=success; 17 | } 18 | 19 | public void setPage(List rows, Long total){ 20 | addData("rows",rows); 21 | addData("total",total); 22 | } 23 | 24 | public void setPage(List rows){ 25 | addData("rows",rows); 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/Tree.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * @description: 树 8 | * @copyright: 9 | * @createTime: 2017/12/8 14:15 10 | * @author:dzy 11 | * @version:1.0 12 | */ 13 | public class Tree { 14 | private Long parentId; 15 | private Long id; 16 | private String name; 17 | private String title; 18 | private List children; 19 | private String type; 20 | 21 | public Long getParentId() { 22 | return parentId; 23 | } 24 | 25 | public void setParentId(Long parentId) { 26 | this.parentId = parentId; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public List getChildren() { 46 | return children; 47 | } 48 | 49 | public void setChildren(List children) { 50 | this.children = children; 51 | } 52 | 53 | public String getTitle() { 54 | return title; 55 | } 56 | 57 | public void setTitle(String title) { 58 | this.title = title; 59 | } 60 | 61 | public String getType() { 62 | return type; 63 | } 64 | 65 | public void setType(String type) { 66 | this.type = type; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ffast-core/src/main/resources/font/WellrockSlabBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhiYiDai/Ffast-Java/fc5b0d76bb6f2258ab1464805223084cee01079b/ffast-core/src/main/resources/font/WellrockSlabBold.ttf -------------------------------------------------------------------------------- /ffast-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ffast-parent 7 | cn.ffast 8 | 1.0-SNAPSHOT 9 | ../ffast-parent/pom.xml 10 | 11 | cn.ffast 12 | 1.0-SNAPSHOT 13 | 4.0.0 14 | jar 15 | ffast-generator 16 | 17 | 18 | 19 | cn.ffast 20 | ffast-core 21 | 1.0-SNAPSHOT 22 | 23 | 24 | 25 | 26 | org.apache.velocity 27 | velocity 28 | 1.7 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/controller/TableController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.controller; 2 | 3 | 4 | import cn.ffast.core.vo.ServiceRowsResult; 5 | import cn.ffast.generator.dao.TableDao; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import javax.annotation.Resource; 9 | 10 | @RestController 11 | @RequestMapping("/api/generator/table") 12 | public class TableController { 13 | 14 | @Resource 15 | TableDao tableDao; 16 | 17 | 18 | @RequestMapping("/list") 19 | public ServiceRowsResult list(String id) { 20 | ServiceRowsResult result = new ServiceRowsResult(true); 21 | result.setPage(tableDao.listTable()); 22 | return result; 23 | } 24 | @RequestMapping("/columns") 25 | public ServiceRowsResult info(String tableName) { 26 | ServiceRowsResult result = new ServiceRowsResult(true); 27 | result.setPage(tableDao.listTableColumn(tableName)); 28 | return result; 29 | } 30 | } -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/dao/TableDao.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.dao; 2 | 3 | import cn.ffast.generator.entity.Column; 4 | import cn.ffast.generator.entity.Table; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Select; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | @Mapper 12 | public interface TableDao { 13 | 14 | @Select("select * from information_schema.TABLES where TABLE_SCHEMA=(select database())") 15 | List listTable(); 16 | 17 | @Select("select * from information_schema.COLUMNS where TABLE_SCHEMA = (select database()) and TABLE_NAME=#{tableName}") 18 | List listTableColumn(String tableName); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/entity/Column.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.entity; 2 | 3 | public class Column { 4 | private String columnName; 5 | private String dataType; 6 | private String columnComment; 7 | private String isNullable; 8 | private Integer ordinalPosition; 9 | private String extra; 10 | private Integer characterMaximumLength; 11 | private String columnDefault; 12 | 13 | public String getColumnName() { 14 | return columnName; 15 | } 16 | 17 | public void setColumnName(String columnName) { 18 | this.columnName = columnName; 19 | } 20 | 21 | public String getDataType() { 22 | return dataType; 23 | } 24 | 25 | public void setDataType(String dataType) { 26 | this.dataType = dataType; 27 | } 28 | 29 | public String getColumnComment() { 30 | return columnComment; 31 | } 32 | 33 | public void setColumnComment(String columnComment) { 34 | this.columnComment = columnComment; 35 | } 36 | 37 | public String getIsNullable() { 38 | return isNullable; 39 | } 40 | 41 | public void setIsNullable(String isNullable) { 42 | this.isNullable = isNullable; 43 | } 44 | 45 | public Integer getOrdinalPosition() { 46 | return ordinalPosition; 47 | } 48 | 49 | public void setOrdinalPosition(Integer ordinalPosition) { 50 | this.ordinalPosition = ordinalPosition; 51 | } 52 | 53 | public String getExtra() { 54 | return extra; 55 | } 56 | 57 | public void setExtra(String extra) { 58 | this.extra = extra; 59 | } 60 | 61 | public Integer getCharacterMaximumLength() { 62 | return characterMaximumLength; 63 | } 64 | 65 | public void setCharacterMaximumLength(Integer characterMaximumLength) { 66 | this.characterMaximumLength = characterMaximumLength; 67 | } 68 | 69 | public String getColumnDefault() { 70 | return columnDefault; 71 | } 72 | 73 | public void setColumnDefault(String columnDefault) { 74 | this.columnDefault = columnDefault; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/entity/Table.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.entity; 2 | 3 | public class Table { 4 | private String tableName; 5 | private String tableComment; 6 | 7 | public String getTableName() { 8 | return tableName; 9 | } 10 | 11 | public void setTableName(String tableName) { 12 | this.tableName = tableName; 13 | } 14 | 15 | public String getTableComment() { 16 | return tableComment; 17 | } 18 | 19 | public void setTableComment(String tableComment) { 20 | this.tableComment = tableComment; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/controller.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Controller}; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import javax.annotation.Resource; 8 | import ${package.Entity}.${entity}; 9 | import ${package.Service}.${table.serviceName}; 10 | 11 | #if(${superControllerClassPackage}) 12 | import ${superControllerClassPackage}; 13 | #end 14 | 15 | /** 16 | * @description: $!{table.comment}数据接口 17 | * @copyright: ${copyright} (c)${cfg.year} 18 | * @createTime: ${cfg.createTime} 19 | * @author: ${author} 20 | * @version: ${cfg.version} 21 | */ 22 | @Controller 23 | @RequestMapping("/${cfg.apiPrefix}/${cfg.resPrefix}#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}") 24 | #if(${superControllerClass}) 25 | public class ${table.controllerName} extends ${superControllerClass}<${entity},${table.serviceName},Long> { 26 | 27 | private static Logger logger = LoggerFactory.getLogger(${table.controllerName}.class); 28 | 29 | @Resource 30 | private ${table.serviceName} service; 31 | 32 | @Override 33 | protected ${table.serviceName} getService() { 34 | return this.service; 35 | } 36 | 37 | @Override 38 | protected Logger getLogger() { 39 | return logger; 40 | } 41 | 42 | 43 | #else 44 | public class ${table.controllerName} { 45 | #end 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/entity.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Entity}; 2 | 3 | #foreach($pkg in ${table.importPackages}) 4 | import ${pkg}; 5 | #end 6 | 7 | /** 8 | * @description: $!{table.comment} 9 | * @copyright: ${copyright} (c)${cfg.year} 10 | * @createTime: ${cfg.createTime} 11 | * @author: ${author} 12 | * @version: ${cfg.version} 13 | */ 14 | #if(${table.convert}) 15 | @TableName(value="${table.name}",resultMap="BaseResultMap") 16 | #end 17 | #if(${superEntityClass}) 18 | public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end { 19 | #elseif(${activeRecord}) 20 | public class ${entity} extends Model<${entity}> { 21 | #else 22 | public class ${entity} implements Serializable { 23 | #end 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | #foreach($field in ${table.fields}) 28 | #if(${field.keyFlag}) 29 | #set($keyPropertyName=${field.propertyName}) 30 | #end 31 | #if("$!field.comment" != "") 32 | /** 33 | * ${field.comment} 34 | */ 35 | #end 36 | #if(${field.keyFlag}) 37 | #if(${field.keyIdentityFlag}) 38 | @TableId(value="${field.name}", type= IdType.AUTO) 39 | #elseif(${field.convert}) 40 | @TableId("${field.name}") 41 | #end 42 | #elseif(${field.fill}) 43 | #if(${field.convert}) 44 | @TableField(value = "${field.name}", fill = FieldFill.${field.fill}) 45 | #else 46 | @TableField(fill = FieldFill.${field.fill}) 47 | #end 48 | #elseif(${field.convert}) 49 | @TableField("${field.name}") 50 | #end 51 | #if(${logicDeleteFieldName}==${field.name}) 52 | @TableLogic 53 | #end 54 | private ${field.propertyType} ${field.propertyName}; 55 | #end 56 | #foreach($field in ${table.fields}) 57 | #if(${field.propertyType.equals("Boolean")}) 58 | #set($getprefix="is") 59 | #else 60 | #set($getprefix="get") 61 | #end 62 | 63 | public ${field.propertyType} ${getprefix}${field.capitalName}() { 64 | return ${field.propertyName}; 65 | } 66 | 67 | #if(${entityBuilderModel}) 68 | public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { 69 | #else 70 | public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { 71 | #end 72 | this.${field.propertyName} = ${field.propertyName}; 73 | #if(${entityBuilderModel}) 74 | return this; 75 | #end 76 | } 77 | #end 78 | 79 | #if(${entityColumnConstant}) 80 | #foreach($field in ${table.fields}) 81 | public static final String ${field.name.toUpperCase()} = "${field.name}"; 82 | 83 | #end 84 | #end 85 | 86 | } 87 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/mapper.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Mapper}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${superMapperClassPackage}; 5 | 6 | /** 7 | * @description: $!{table.comment}Mapper接口 8 | * @copyright: ${copyright} (c)${cfg.year} 9 | * @createTime: ${cfg.createTime} 10 | * @author: ${author} 11 | * @version: ${cfg.version} 12 | */ 13 | public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { 14 | 15 | } -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/mapper.xml.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #if(${enableCache}) 6 | 7 | 8 | 9 | #end 10 | #if(${baseResultMap}) 11 | 12 | 13 | #foreach($field in ${table.fields}) 14 | #if(${field.keyFlag})##生成主键排在第一位 15 | 16 | #end 17 | #end 18 | #foreach($field in ${table.commonFields})##生成公共字段 19 | 20 | #end 21 | #foreach($field in ${table.fields}) 22 | #if(!${field.keyFlag})##生成普通字段 23 | 24 | #end 25 | #end 26 | 27 | #end 28 | #if(${baseColumnList}) 29 | 30 | 31 | ${table.fieldNames} 32 | 33 | 34 | 35 | 36 | #foreach($field in ${table.commonFields})##生成字段 37 | #if(${field.propertyType.equals("String")}) 38 | 39 | #else 40 | 41 | #end 42 | AND ${field.name} = #{m.${field.propertyName}} 43 | 44 | #end 45 | #foreach($field in ${table.fields})##生成字段 46 | #if(${field.propertyType.equals("String")}) 47 | 48 | #else 49 | 50 | #end 51 | AND ${field.name} = #{m.${field.propertyName}} 52 | 53 | #end 54 | 55 | ORDER BY id ASC 56 | 57 | 58 | 59 | 76 | 77 | #end 78 | 79 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/service.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Service}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${superServiceClassPackage}; 5 | 6 | /** 7 | * @description: $!{table.comment}服务类 8 | * @copyright: ${copyright} (c)${cfg.year} 9 | * @createTime: ${cfg.createTime} 10 | * @author: ${author} 11 | * @version: ${cfg.version} 12 | */ 13 | public interface ${table.serviceName} extends ${superServiceClass}<${entity},Long> { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/serviceImpl.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.ServiceImpl}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${package.Mapper}.${table.mapperName}; 5 | import ${package.Service}.${table.serviceName}; 6 | import ${superServiceImplClassPackage}; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @description: $!{table.comment}服务实现类 11 | * @copyright: ${copyright} (c)${cfg.year} 12 | * @createTime: ${cfg.createTime} 13 | * @author: ${author} 14 | * @version: ${cfg.version} 15 | */ 16 | @Service 17 | public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName},${entity},Long> implements ${table.serviceName} { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/vue.vm: -------------------------------------------------------------------------------- 1 | #set($url="/${cfg.resPrefix}#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/") 2 | 4 | 5 | 6 | 7 | 8 | 9 | 88 | --------------------------------------------------------------------------------
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package cn.ffast.core.annotations; 17 | 18 | import java.lang.annotation.*; 19 | 20 | /** 21 | * @description: 登录验证 22 | * @copyright: 23 | * @createTime: 2017/11/14 14:12 24 | * @author:dzy 25 | * @version:1.0 26 | */ 27 | @Target({ElementType.METHOD, ElementType.TYPE}) 28 | @Inherited 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Documented 31 | public @interface Logined { 32 | /** 33 | * 是否对自己生效(false只对基类生效) 34 | * @return 35 | */ 36 | boolean notEffectSelf() default false; 37 | } 38 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/annotations/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2020, hubin (jobob@qq.com). 3 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package cn.ffast.core.annotations; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | 25 | 26 | /** 27 | * @description: 权限注解 28 | * @copyright: 29 | * @createTime: 2017/11/14 14:12 30 | * @author:dzy 31 | * @version:1.0 32 | */ 33 | @Target({ElementType.METHOD, ElementType.TYPE}) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | public @interface Permission { 37 | 38 | /** 39 | * 权限内容 40 | */ 41 | String value() default ""; 42 | 43 | /** 44 | * 是否是独立的 45 | * true 不和类注解的权限名组合 46 | * false 没有类注解权限则无效 47 | */ 48 | boolean alone() default false; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/aop/LogAspect.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.aop; 2 | 3 | import cn.ffast.core.annotations.Log; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.Signature; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.reflect.MethodSignature; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.annotation.Resource; 12 | import java.lang.reflect.Method; 13 | 14 | /** 15 | * @description: 日志Aop 16 | * @copyright: 17 | * @createTime: 2017/11/14 14:13 18 | * @author:dzy 19 | * @version:1.0 20 | */ 21 | @Aspect 22 | @Component 23 | public class LogAspect { 24 | 25 | /** 26 | * 日志切入点 27 | */ 28 | @Resource 29 | private LogPoint logPoint; 30 | 31 | /** 32 | * 保存系统操作日志 33 | * 34 | * @param joinPoint 连接点 35 | * @return 方法执行结果 36 | * @throws Throwable 调用出错 37 | */ 38 | @Around(value = "@annotation(cn.ffast.core.annotations.Log)") 39 | public Object saveLog(ProceedingJoinPoint joinPoint) throws Throwable { 40 | /** 41 | * 解析Log注解 42 | */ 43 | Method currentMethod = currentMethod(joinPoint); 44 | Log log = currentMethod.getAnnotation(Log.class); 45 | Log classLog = joinPoint.getTarget().getClass().getAnnotation(Log.class); 46 | /** 47 | * 日志入库 48 | */ 49 | String logStr = null; 50 | if (classLog != null) { 51 | logStr = classLog.value() + "-" + log.value(); 52 | } else { 53 | logStr = log.value(); 54 | } 55 | if (log != null && logPoint != null) { 56 | logPoint.saveLog(joinPoint, currentMethod.getName(), logStr); 57 | } 58 | 59 | /** 60 | * 方法执行 61 | */ 62 | return joinPoint.proceed(); 63 | } 64 | 65 | /** 66 | * 获取当前执行的方法 67 | * 68 | * @param joinPoint 连接点 69 | * @return 方法 70 | */ 71 | private Method currentMethod(ProceedingJoinPoint joinPoint) throws NoSuchMethodException { 72 | Signature sig = joinPoint.getSignature(); 73 | MethodSignature msig = null; 74 | if (!(sig instanceof MethodSignature)) { 75 | throw new IllegalArgumentException("该注解只能用于方法"); 76 | } 77 | msig = (MethodSignature) sig; 78 | Object target = joinPoint.getTarget(); 79 | Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); 80 | return currentMethod; 81 | } 82 | 83 | public LogPoint getLogPoint() { 84 | return logPoint; 85 | } 86 | 87 | public void setLogPoint(LogPoint logPoint) { 88 | this.logPoint = logPoint; 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/aop/LogPoint.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.aop; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | 5 | /** 6 | * @description: 7 | * @copyright: 8 | * @createTime: 2017/11/14 14:55 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | public interface LogPoint { 13 | /** 14 | * 保存日志 15 | * @param joinPoint 16 | * @param methodName 17 | * @param operate 18 | */ 19 | void saveLog(ProceedingJoinPoint joinPoint, String methodName, String operate); 20 | } 21 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/auth/JwtUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.auth; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.auth0.jwt.JWTSigner; 7 | import com.auth0.jwt.JWTVerifier; 8 | import com.auth0.jwt.internal.com.fasterxml.jackson.databind.ObjectMapper; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | public class JwtUtils { 13 | private static Logger logger = LoggerFactory.getLogger(JwtUtils.class); 14 | private static final String SECRET_PREIFX = "@@@FFFFFFFFAAAASSSSTTTT%%%%"; 15 | private static final String EXP = "exp"; 16 | private static final String PAYLOAD = "payload"; 17 | 18 | /** 19 | * get jwt String of object 20 | * 21 | * @param object the POJO object 22 | * @param maxAge the milliseconds of life time 23 | * @return the jwt token 24 | */ 25 | public static String sign(T object, long maxAge, String secret) { 26 | try { 27 | final JWTSigner signer = new JWTSigner(SECRET_PREIFX + secret); 28 | final Map claims = new HashMap(); 29 | ObjectMapper mapper = new ObjectMapper(); 30 | String jsonString = mapper.writeValueAsString(object); 31 | claims.put(PAYLOAD, jsonString); 32 | claims.put(EXP, System.currentTimeMillis() + (maxAge * 1000)); 33 | return signer.sign(claims); 34 | } catch (Exception e) { 35 | return null; 36 | } 37 | } 38 | 39 | /** 40 | * get the object of jwt if not expired 41 | * 42 | * @param jwt 43 | * @return POJO object 44 | */ 45 | public static T unsign(String jwt, Class classT, String secret) { 46 | final JWTVerifier verifier = new JWTVerifier(SECRET_PREIFX + secret); 47 | try { 48 | final Map claims = verifier.verify(jwt); 49 | if (claims.containsKey(EXP) && claims.containsKey(PAYLOAD)) { 50 | long exp = (Long) claims.get(EXP); 51 | long currentTimeMillis = System.currentTimeMillis(); 52 | if (exp > currentTimeMillis) { 53 | String json = (String) claims.get(PAYLOAD); 54 | ObjectMapper objectMapper = new ObjectMapper(); 55 | return objectMapper.readValue(json, classT); 56 | } 57 | } 58 | return null; 59 | } catch (Exception e) { 60 | logger.error(e.getMessage()); 61 | return null; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/auth/OperatorBase.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.auth; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | /** 7 | * @description: 当前登录用户基础类 8 | * @copyright: 9 | * @createTime: 2017/8/31 9:02 10 | * @author:dzy 11 | * @version:1.0 12 | */ 13 | public class OperatorBase { 14 | //当前登录用户名 15 | protected String userName; 16 | //当前登录用户id 17 | protected Long userId; 18 | 19 | protected String token; 20 | //当前登录账号姓名 21 | protected String name; 22 | /** 23 | * 拥有的角色id 24 | */ 25 | protected Set hasRoleId; 26 | 27 | 28 | public String getUserName() { 29 | return userName; 30 | } 31 | 32 | public void setUserName(String userName) { 33 | this.userName = userName; 34 | } 35 | 36 | public Long getUserId() { 37 | return userId; 38 | } 39 | 40 | public void setUserId(Long userId) { 41 | this.userId = userId; 42 | } 43 | 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getToken() { 54 | return token; 55 | } 56 | 57 | public void setToken(String token) { 58 | this.token = token; 59 | } 60 | 61 | public Set getHasRoleId() { 62 | return hasRoleId; 63 | } 64 | 65 | public void setHasRoleId(Set hasRoleId) { 66 | this.hasRoleId = hasRoleId; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/constant/ResultCode.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.constant; 2 | 3 | /** 4 | * @author daizhiyi 5 | * @version 1.0 6 | * @Description: 结果返回code 7 | * @date 2017年3月24日 8 | */ 9 | public enum ResultCode { 10 | /** 11 | * 成功返回 12 | */ 13 | SUCCESS(200, "成功"), 14 | /** 15 | * 未登录系统 16 | */ 17 | NOTLOGIN(1000, "未登录系统!"), 18 | /** 19 | * 操作失败 20 | */ 21 | ERROR(1001, "操作失败!"), 22 | /** 23 | * 权限不足 24 | */ 25 | PERMISSION_DENIED(1002, "权限不足"), 26 | /** 27 | * 不存在 28 | */ 29 | INEXISTENCE(1003, "不存在"), 30 | /** 31 | * 存在 32 | */ 33 | EXIST(1004, "存在"), 34 | /** 35 | * 参数为空 36 | */ 37 | PARAMNULL(1005, "参数为空"), 38 | /** 39 | * 服务内部错误 40 | */ 41 | SERVICE_ERROR(500, "服务内部错误"); 42 | 43 | private int code; 44 | private String message; 45 | 46 | ResultCode(int code, String message) { 47 | this.code = code; 48 | this.message = message; 49 | } 50 | 51 | public String getMessage() { 52 | return message; 53 | } 54 | 55 | public void setMessage(String message) { 56 | this.message = message; 57 | } 58 | 59 | public int getCode() { 60 | return code; 61 | } 62 | 63 | public void setCode(int code) { 64 | this.code = code; 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/constant/ScheduleStatus.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.constant; 2 | 3 | public enum ScheduleStatus { 4 | /** 5 | * 正常 6 | */ 7 | NORMAL(1), 8 | /** 9 | * 暂停 10 | */ 11 | PAUSE(0); 12 | 13 | private int value; 14 | 15 | ScheduleStatus(int value) { 16 | this.value = value; 17 | } 18 | 19 | public int getValue() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/filter/CrossFilter.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.filter; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import javax.servlet.*; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | /** 11 | * 跨域设置 12 | */ 13 | @Component 14 | public class CrossFilter implements Filter { 15 | @Override 16 | public void init(FilterConfig filterConfig) throws ServletException { 17 | 18 | } 19 | 20 | @Override 21 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 22 | HttpServletResponse response = (HttpServletResponse) servletResponse; 23 | HttpServletRequest reqs = (HttpServletRequest) servletRequest; 24 | response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); 25 | response.setHeader("Access-Control-Allow-Credentials", "true"); 26 | response.setHeader("Access-Control-Allow-Methods", "*"); 27 | response.setHeader("Access-Control-Max-Age", "3600"); 28 | response.setHeader("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Authorization"); 29 | filterChain.doFilter(servletRequest, servletResponse); 30 | } 31 | 32 | @Override 33 | public void destroy() { 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/handler/BaseEntityHandler.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.handler; 2 | 3 | 4 | import cn.ffast.core.utils.DateUtil; 5 | import com.baomidou.mybatisplus.mapper.MetaObjectHandler; 6 | import org.apache.ibatis.reflection.MetaObject; 7 | 8 | /** 9 | * @description: mybatis plus公共字段填充处理器 10 | * @copyright: 11 | * @createTime: 2017/7/17 10:58 12 | * @author:dzy 13 | * @version:1.0 14 | */ 15 | 16 | public class BaseEntityHandler extends MetaObjectHandler { 17 | 18 | /** 19 | * 测试 user 表 name 字段为空自动填充 20 | */ 21 | @Override 22 | public void insertFill(MetaObject metaObject) { 23 | // 更多查看源码测试用例 24 | //System.out.println("insert fill"); 25 | //mybatis-plus版本2.0.9+ 26 | setFieldValByName("createTime", DateUtil.getNowTimestampStr(), metaObject); 27 | setFieldValByName("lastModifyTime", DateUtil.getNowTimestampStr(), metaObject); 28 | } 29 | 30 | @Override 31 | public void updateFill(MetaObject metaObject) { 32 | //更新填充 33 | //System.out.println("update fill"); 34 | //mybatis-plus版本2.0.9+ 35 | setFieldValByName("lastModifyTime", DateUtil.getNowTimestampStr(), metaObject); 36 | } 37 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.handler; 2 | 3 | import cn.ffast.core.constant.ResultCode; 4 | import cn.ffast.core.vo.ServiceResult; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | 11 | /** 12 | * 全局异常处理 13 | */ 14 | @RestControllerAdvice 15 | public class GlobalExceptionHandler { 16 | private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); 17 | 18 | @ExceptionHandler({Exception.class, NullPointerException.class}) 19 | @ResponseBody 20 | public ServiceResult handleException(Exception e) { 21 | ServiceResult result = new ServiceResult(ResultCode.SERVICE_ERROR.getCode(), ResultCode.SERVICE_ERROR.getMessage()); 22 | if (e != null) { 23 | result.addData("error", e.getMessage()); 24 | e.printStackTrace(); 25 | } else { 26 | logger.error("exception is null"); 27 | } 28 | return result; 29 | } 30 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/redis/GenericMsgpackRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.redis; 2 | 3 | import com.fasterxml.jackson.annotation.JsonTypeInfo.As; 4 | import com.fasterxml.jackson.core.JsonGenerator; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.fasterxml.jackson.databind.SerializerProvider; 8 | import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; 9 | import com.fasterxml.jackson.databind.module.SimpleModule; 10 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 11 | 12 | import java.io.IOException; 13 | 14 | import org.msgpack.core.annotations.Nullable; 15 | import org.msgpack.jackson.dataformat.MessagePackFactory; 16 | import org.springframework.cache.support.NullValue; 17 | import org.springframework.data.redis.serializer.RedisSerializer; 18 | import org.springframework.data.redis.serializer.SerializationException; 19 | import org.springframework.util.Assert; 20 | import org.springframework.util.StringUtils; 21 | 22 | public class GenericMsgpackRedisSerializer implements RedisSerializer { 23 | static final byte[] EMPTY_ARRAY = new byte[0]; 24 | private final ObjectMapper mapper; 25 | 26 | 27 | public GenericMsgpackRedisSerializer() { 28 | this.mapper = new ObjectMapper(new MessagePackFactory()); 29 | this.mapper.registerModule((new SimpleModule()).addSerializer(new GenericMsgpackRedisSerializer.NullValueSerializer(null))); 30 | this.mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY); 31 | } 32 | 33 | @Override 34 | public byte[] serialize(@Nullable Object source) throws SerializationException { 35 | if (source == null) { 36 | return EMPTY_ARRAY; 37 | } else { 38 | try { 39 | return this.mapper.writeValueAsBytes(source); 40 | } catch (JsonProcessingException var3) { 41 | throw new SerializationException("Could not write JSON: " + var3.getMessage(), var3); 42 | } 43 | } 44 | } 45 | 46 | @Override 47 | public Object deserialize(@Nullable byte[] source) throws SerializationException { 48 | return this.deserialize(source, Object.class); 49 | } 50 | 51 | @Nullable 52 | public T deserialize(@Nullable byte[] source, Class type) throws SerializationException { 53 | Assert.notNull(type, "Deserialization type must not be null! Pleaes provide Object.class to make use of Jackson2 default typing."); 54 | if (source == null || source.length == 0) { 55 | return null; 56 | } else { 57 | try { 58 | return this.mapper.readValue(source, type); 59 | } catch (Exception var4) { 60 | throw new SerializationException("Could not read JSON: " + var4.getMessage(), var4); 61 | } 62 | } 63 | } 64 | 65 | private class NullValueSerializer extends StdSerializer { 66 | private static final long serialVersionUID = 2199052150128658111L; 67 | private final String classIdentifier; 68 | 69 | NullValueSerializer(@Nullable String classIdentifier) { 70 | super(NullValue.class); 71 | this.classIdentifier = StringUtils.hasText(classIdentifier) ? classIdentifier : "@class"; 72 | } 73 | 74 | @Override 75 | public void serialize(NullValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException { 76 | jgen.writeStartObject(); 77 | jgen.writeStringField(this.classIdentifier, NullValue.class.getName()); 78 | jgen.writeEndObject(); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/redis/RedisSerializerType.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.redis; 2 | 3 | public enum RedisSerializerType { 4 | FastJSON(0, "FastJSON"), 5 | JackJson(1, "JackJson"), 6 | Msgpack(2, "Msgpack"); 7 | private String name; 8 | private int type; 9 | 10 | RedisSerializerType(int type, String name) { 11 | this.type = type; 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public int getType() { 24 | return type; 25 | } 26 | 27 | public void setType(int type) { 28 | this.type = type; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/service/CaptchaService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.service; 2 | 3 | 4 | import cn.ffast.core.redis.RedisCacheUtils; 5 | import cn.ffast.core.utils.CaptchaUtils; 6 | import cn.ffast.core.utils.HttpServletUtils; 7 | import cn.ffast.core.utils.Md5Utils; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | import javax.imageio.ImageIO; 13 | import javax.servlet.ServletOutputStream; 14 | import javax.servlet.http.Cookie; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | 19 | /** 20 | * @author dzy 21 | * @Description: 验证码Service实现 22 | * @Copyright: 23 | * @Created 24 | * @vesion 1.0 25 | */ 26 | @Service 27 | public class CaptchaService { 28 | private final static String CAPTCHA_KEY = "captcha:"; 29 | 30 | @Resource 31 | RedisCacheUtils redisCacheUtils; 32 | 33 | 34 | public void buildCaptcha() { 35 | buildCaptcha(HttpServletUtils.getResponse()); 36 | } 37 | 38 | 39 | public void buildCaptcha(HttpServletResponse response) { 40 | CaptchaUtils.Captcha captcha = CaptchaUtils.createCaptcha(120, 30); 41 | String captchaId = Md5Utils.hash(Md5Utils.getUUID()); 42 | response.setContentType("image/jpeg"); 43 | response.setHeader("Pragma", "no-cache"); 44 | response.setHeader("Cache-Control", "no-cache"); 45 | response.setDateHeader("Expires", 0); 46 | Cookie cookie = new Cookie("captchaId", captchaId); 47 | cookie.setMaxAge(1800); 48 | response.addCookie(cookie); 49 | 50 | redisCacheUtils.setCacheObject(CAPTCHA_KEY + captchaId, captcha.getCode(),300); 51 | try { 52 | ServletOutputStream outputStream = response.getOutputStream(); 53 | ImageIO.write(captcha.getImage(), "jpg", outputStream); 54 | } catch (IOException e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | 59 | 60 | public boolean valid(String code) { 61 | return valid(HttpServletUtils.getRequest(), code); 62 | } 63 | 64 | 65 | public boolean valid(HttpServletRequest request, String code) { 66 | Cookie[] cookies = request.getCookies(); 67 | if (cookies != null) { 68 | for (int i = 0; i < cookies.length; i++) { 69 | Cookie cookie = cookies[i]; 70 | if (cookie.getName().equals("captchaId")) { 71 | String key = CAPTCHA_KEY + cookie.getValue(); 72 | String captcha = redisCacheUtils.getCacheObject(key, String.class); 73 | redisCacheUtils.delete(CAPTCHA_KEY + cookie.getValue()); 74 | if (StringUtils.isNotEmpty(captcha) && StringUtils.isNotEmpty(code) && 75 | code.toLowerCase().equals(captcha.toLowerCase())) { 76 | return true; 77 | } 78 | 79 | } 80 | } 81 | } 82 | return false; 83 | } 84 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 3 | * Created by dzy on 2017/4/14. 4 | */ 5 | package cn.ffast.core.support; 6 | 7 | 8 | 9 | import cn.ffast.core.auth.OperatorBase; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.web.context.request.RequestContextHolder; 13 | import org.springframework.web.context.request.ServletRequestAttributes; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import javax.servlet.http.HttpSession; 17 | import java.util.Enumeration; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | 22 | public abstract class BaseController { 23 | private static Logger logger = LoggerFactory.getLogger(BaseController.class); 24 | 25 | protected HttpServletRequest getRequest() { 26 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); 27 | } 28 | 29 | protected HttpServletResponse getResponse() { 30 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse(); 31 | } 32 | 33 | protected void setAttribute(String key, Object data){ 34 | getHttpSession().setAttribute(key,data); 35 | } 36 | 37 | protected HttpSession getHttpSession(){ 38 | return getRequest().getSession(); 39 | } 40 | 41 | protected Object getAttribute(String var1){ 42 | return getHttpSession().getAttribute(var1); 43 | } 44 | 45 | 46 | 47 | /** 48 | * 获取所有请求参数 49 | * 50 | * @return 返回所有请求参数 51 | */ 52 | protected Map getAllParam() { 53 | Map params = new HashMap<>(); 54 | HttpServletRequest request = getRequest(); 55 | Enumeration enu = request.getParameterNames(); 56 | while (enu.hasMoreElements()) { 57 | String paraName = (String) enu.nextElement(); 58 | String val = request.getParameter(paraName); 59 | params.put(paraName, val); 60 | } 61 | return params; 62 | } 63 | 64 | /** 65 | * 获取请求参数 66 | * 67 | * @return 返回所有请求参数 68 | */ 69 | protected Object getRequestParam(String key) { 70 | HttpServletRequest request = getRequest(); 71 | if (request != null) { 72 | return request.getParameter(key); 73 | } 74 | return null; 75 | } 76 | 77 | /** 78 | * 获得请求参数返回指定的强制转换对象 79 | * @param key 80 | * @param clazz 81 | * @param 82 | * @return 83 | */ 84 | protected T getRequestParam(String key, Class clazz) { 85 | Object obj = getRequestParam(key); 86 | if (obj != null) { 87 | return (T) obj; 88 | } 89 | return null; 90 | } 91 | 92 | /** 93 | * 获得请求参数返回字符串 94 | * @param key 95 | * @return 96 | */ 97 | protected String getRequestParamString(String key) { 98 | Object obj = getRequestParam(key); 99 | if (obj != null) { 100 | return obj.toString(); 101 | } 102 | return null; 103 | } 104 | 105 | /** 106 | * 获取后台管理登录信息 107 | * 108 | * @return 109 | */ 110 | protected OperatorBase getLoginUser() { 111 | Object obj = getAttribute("loginUser"); 112 | if (obj != null) { 113 | return (OperatorBase) (obj); 114 | } 115 | return null; 116 | } 117 | 118 | /** 119 | * 获取后台管理登录用户id 120 | * 121 | * @return 122 | */ 123 | protected Long getLoginUserId() { 124 | OperatorBase operator = getLoginUser(); 125 | if (operator != null) { 126 | return operator.getUserId(); 127 | } 128 | return null; 129 | } 130 | 131 | 132 | /** 133 | * 获取后台管理登录信息 134 | * @return 135 | */ 136 | protected T getLoginUser(Class clazz) { 137 | return (T) (getAttribute("loginUser")); 138 | } 139 | 140 | /** 141 | * 获得日志对象,供子类重写 142 | * @return 143 | */ 144 | protected abstract Logger getLogger(); 145 | 146 | } 147 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.enums.FieldFill; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * @description: 实体基类 13 | * @copyright: 14 | * @createTime: 2017年9月12日下午5:27:50 15 | * @author:dzy 16 | * @version:1.0 17 | */ 18 | public class BaseEntity extends Model implements Serializable { 19 | 20 | @TableField(exist = false) 21 | private static final long serialVersionUID = -34115333603863619L; 22 | /** 23 | * 主键Id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | protected Long id; 27 | /** 28 | * name 29 | */ 30 | @TableId(value = "name") 31 | protected String name; 32 | /** 33 | * 创建人 34 | */ 35 | @TableField("creator_id") 36 | private Long creatorId; 37 | /** 38 | * 创建时间 39 | */ 40 | @TableField(value = "create_time", fill = FieldFill.INSERT) 41 | private String createTime; 42 | /** 43 | * 最后修改时间 44 | */ 45 | @TableField(value = "last_modify_time", fill = FieldFill.INSERT_UPDATE, update = "now()") 46 | private String lastModifyTime; 47 | /** 48 | * 最后修改人 49 | */ 50 | @TableField("last_modifier_id") 51 | private Long lastModifierId; 52 | 53 | 54 | public Long getId() { 55 | return id; 56 | } 57 | 58 | public void setId(Long id) { 59 | this.id = id; 60 | } 61 | 62 | public String getCreateTime() { 63 | return createTime; 64 | } 65 | 66 | public void setCreateTime(String createTime) { 67 | this.createTime = createTime; 68 | } 69 | 70 | public Long getCreatorId() { 71 | return creatorId; 72 | } 73 | 74 | public void setCreatorId(Long creatorId) { 75 | this.creatorId = creatorId; 76 | } 77 | 78 | public String getLastModifyTime() { 79 | return lastModifyTime; 80 | } 81 | 82 | public void setLastModifyTime(String lastModifyTime) { 83 | this.lastModifyTime = lastModifyTime; 84 | } 85 | 86 | public Long getLastModifierId() { 87 | return lastModifierId; 88 | } 89 | 90 | public void setLastModifierId(Long lastModifierId) { 91 | this.lastModifierId = lastModifierId; 92 | } 93 | 94 | public String getName() { 95 | return name; 96 | } 97 | 98 | public void setName(String name) { 99 | this.name = name; 100 | } 101 | 102 | @Override 103 | protected Serializable pkVal() { 104 | return this.id; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/BaseService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import cn.ffast.core.auth.OperatorBase; 4 | import cn.ffast.core.utils.HttpServletUtils; 5 | import com.baomidou.mybatisplus.mapper.BaseMapper; 6 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 7 | import com.baomidou.mybatisplus.toolkit.ReflectionKit; 8 | import org.springframework.web.context.request.RequestContextHolder; 9 | import org.springframework.web.context.request.ServletRequestAttributes; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.util.Enumeration; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * @description: 20 | * @copyright: 21 | * @createTime: 2017/10/28 23:20 22 | * @author:dzy 23 | * @version:1.0 24 | */ 25 | public class BaseService, T extends BaseEntity> extends ServiceImpl { 26 | protected HttpServletRequest getRequest() { 27 | return HttpServletUtils.getRequest(); 28 | } 29 | 30 | protected HttpServletResponse getResponse() { 31 | return HttpServletUtils.getResponse(); 32 | } 33 | 34 | 35 | /** 36 | * 获取所有请求参数 37 | * 38 | * @return 返回所有请求参数 39 | */ 40 | protected Map getAllParam() { 41 | return HttpServletUtils.getAllParam(); 42 | } 43 | 44 | /** 45 | * 获取请求参数 46 | * 47 | * @return 返回所有请求参数 48 | */ 49 | protected Object getRequestParam(String key) { 50 | HttpServletRequest request = getRequest(); 51 | if (request != null) { 52 | return request.getParameter(key); 53 | } 54 | return null; 55 | } 56 | 57 | /** 58 | * 获得请求参数返回指定的强制转换对象 59 | * @param key 60 | * @param clazz 61 | * @param 62 | * @return 63 | */ 64 | protected T getRequestParam(String key, Class clazz) { 65 | Object obj = getRequestParam(key); 66 | if (obj != null) { 67 | return (T) obj; 68 | } 69 | return null; 70 | } 71 | 72 | /** 73 | * 获得请求参数返回字符串 74 | * @param key 75 | * @return 76 | */ 77 | protected String getRequestParamString(String key) { 78 | Object obj = getRequestParam(key); 79 | if (obj != null) { 80 | return obj.toString(); 81 | } 82 | return null; 83 | } 84 | 85 | /** 86 | * 获取后台管理登录信息 87 | * 88 | * @return 89 | */ 90 | protected OperatorBase getLoginUser() { 91 | Object obj = HttpServletUtils.getRequestAttribute("loginUser"); 92 | if (obj != null) { 93 | return (OperatorBase) (obj); 94 | } 95 | return null; 96 | } 97 | 98 | /** 99 | * 获取后台管理登录用户id 100 | * 101 | * @return 102 | */ 103 | protected Long getLoginUserId() { 104 | OperatorBase operator = getLoginUser(); 105 | if (operator != null) { 106 | return operator.getUserId(); 107 | } 108 | return null; 109 | } 110 | 111 | @Override 112 | protected Class currentModelClass() { 113 | return ReflectionKit.getSuperClassGenricType(this.getClass(), 1); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/IAuthService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | 4 | import cn.ffast.core.vo.ServiceResult; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | public interface IAuthService { 9 | /** 10 | * 登录接口 11 | * @param username 账户 12 | * @param password 密码 13 | * @param captcha 验证码 14 | * @param getMenuPerms 同时获得菜单权限 15 | * @return 16 | */ 17 | ServiceResult login(String username, String password, String captcha, boolean getMenuPerms); 18 | 19 | /** 20 | * 退出登录 21 | * 22 | * @param token 23 | * @return 24 | */ 25 | ServiceResult logout(String token); 26 | 27 | /** 28 | * 获取当前登录账户角色菜单权限 29 | * @param roleName 30 | * @return 31 | */ 32 | ServiceResult getMenuPermsByRoleName(String roleName); 33 | } 34 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/support/ICrudService.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.support; 2 | 3 | import cn.ffast.core.vo.ServiceRowsResult; 4 | import cn.ffast.core.vo.ServiceResult; 5 | import com.baomidou.mybatisplus.plugins.Page; 6 | import com.baomidou.mybatisplus.service.IService; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @description: 基础增删改查 12 | * @copyright: 13 | * @createTime: 2017/9/5 9:39 14 | * @author:dzy 15 | * @version:1.0 16 | */ 17 | public interface ICrudService extends IService { 18 | /** 19 | * @description: 插入对象 20 | * @createTime: 2017-9-5 10:00 21 | * @author: dzy 22 | * @param m 实体类 23 | * @return 24 | */ 25 | ServiceResult create(T m); 26 | /** 27 | * @description: 更新对象 28 | * @createTime: 2017-9-5 10:00 29 | * @author: dzy 30 | * @param m 实体类 31 | * @param updateAllColumn 是否更新所有字段 32 | * @param ignoreProperties 更新排除字段 33 | * @return 34 | */ 35 | ServiceResult update(T m, boolean updateAllColumn,String[] ignoreProperties); 36 | /** 37 | * @description: 批量删除 38 | * @createTime: 2017-9-5 10:00 39 | * @author: dzy 40 | * @param ids 41 | * @return 42 | */ 43 | ServiceResult mulDelete(String ids); 44 | /** 45 | * @description: 根据Id删除对象 46 | * @createTime: 2017-9-5 10:00 47 | * @author: dzy 48 | * @param id 49 | * @return 50 | */ 51 | ServiceResult delById(ID id); 52 | /** 53 | * @description: 删除支持批量 54 | * @createTime: 2017-9-5 10:00 55 | * @author: dzy 56 | * @param ids 57 | * @return 58 | */ 59 | ServiceResult delete(String ids); 60 | /** 61 | * @description: 根据Id发现对象 62 | * @createTime: 2017-9-5 10:00 63 | * @author: dzy 64 | * @param id 65 | * @return 66 | */ 67 | T findById(ID id); 68 | /** 69 | * @description: 分页查询 70 | * @createTime: 2017-9-5 10:00 71 | * @author: dzy 72 | * @param m 73 | * @param page 74 | */ 75 | ServiceRowsResult findListByPage(T m, Page page); 76 | /** 77 | * @description: 分页查询 78 | * @createTime: 2017-9-5 10:00 79 | * @author: dzy 80 | * @param m 81 | * @param page 82 | */ 83 | ServiceRowsResult findListByPage(T m, Page page,String[] properties); 84 | /** 85 | * @description: 查询 86 | * @createTime: 2017-9-5 10:00 87 | * @author: dzy 88 | * @param m 89 | * @param properties 查询字段 90 | * @return 91 | */ 92 | ServiceRowsResult list(T m,String[] properties); 93 | /** 94 | * @description: 查询 95 | * @createTime: 2017-9-5 10:00 96 | * @author: dzy 97 | * @param m 98 | * @param properties 查询字段 99 | * @return 100 | */ 101 | List selectList(T m,String[] properties); 102 | 103 | } 104 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/AnnotationUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.reflect.Field; 5 | import java.lang.reflect.InvocationHandler; 6 | import java.lang.reflect.Proxy; 7 | import java.util.Map; 8 | 9 | public class AnnotationUtils { 10 | 11 | public static void setAnnotationValue(Annotation annotationClass, String key, Object value) { 12 | if(annotationClass==null){} 13 | try { 14 | //获取这个代理实例所持有的 InvocationHandler 15 | InvocationHandler h = Proxy.getInvocationHandler(annotationClass); 16 | // 获取 AnnotationInvocationHandler 的 memberValues 字段 17 | Field hField = null; 18 | hField = h.getClass().getDeclaredField("memberValues"); 19 | // 因为这个字段事 private final 修饰,所以要打开权限 20 | hField.setAccessible(true); 21 | Map memberValues = null; 22 | memberValues = (Map) hField.get(h); 23 | // 修改 权限注解value 属性值 24 | memberValues.put(key, value); 25 | } catch (IllegalAccessException e) { 26 | e.printStackTrace(); 27 | } catch (NoSuchFieldException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/CodeUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.codec.binary.Hex; 4 | import org.apache.commons.lang3.RandomStringUtils; 5 | 6 | import java.security.MessageDigest; 7 | 8 | public class CodeUtil { 9 | public static final String KEY_SHA = "SHA"; 10 | public static final String KEY_MD5 = "MD5"; 11 | 12 | /** 13 | * MAC算法可选以下多种算法 14 | * 15 | * 16 | * HmacMD5 17 | * HmacSHA1 18 | * HmacSHA256 19 | * HmacSHA384 20 | * HmacSHA512 21 | * 22 | */ 23 | public static final String KEY_MAC = "HmacMD5"; 24 | 25 | /** 26 | * MD5加密 27 | * 28 | * @param data 29 | * @return 30 | * @throws Exception 31 | */ 32 | public static byte[] encryptMD5(byte[] data) throws Exception { 33 | MessageDigest md5 = MessageDigest.getInstance(KEY_MD5); 34 | md5.update(data); 35 | return md5.digest(); 36 | 37 | } 38 | 39 | /** 40 | * SHA加密 41 | * 42 | * @param data 43 | * @return 44 | * @throws Exception 45 | */ 46 | public static byte[] encryptSHA(byte[] data) throws Exception { 47 | MessageDigest sha = MessageDigest.getInstance(KEY_SHA); 48 | sha.update(data); 49 | return sha.digest(); 50 | } 51 | 52 | public static byte[] hex2byte(String str) { 53 | if (str == null) { 54 | return null; 55 | } 56 | str = str.trim(); 57 | int len = str.length(); 58 | if (len == 0 || len % 2 == 1) { 59 | return null; 60 | } 61 | 62 | byte[] b = new byte[len / 2]; 63 | try { 64 | for (int i = 0; i < str.length(); i += 2) { 65 | b[i / 2] = (byte) Integer.decode( 66 | "0x" + str.substring(i, i + 2)).intValue(); 67 | } 68 | return b; 69 | } catch (Exception e) { 70 | return null; 71 | } 72 | } 73 | 74 | public static void main(String[] args) throws Exception { 75 | int no = (int) (40 * Math.random() + 10); 76 | String str = RandomStringUtils.randomAlphanumeric(no); 77 | System.out.println(str); 78 | System.out.println(Hex.encodeHexString(encryptMD5("a123456".getBytes()))); 79 | System.out.println(Hex.encodeHexString(encryptSHA(("a123456" + str).getBytes()))); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.util.Collection; 4 | import java.util.Iterator; 5 | 6 | 7 | public class CollectionUtils { 8 | 9 | public static String arraryToString(Collection collection) { 10 | Iterator it = collection.iterator(); 11 | if (!it.hasNext()) { 12 | return ""; 13 | } 14 | StringBuilder sb = new StringBuilder(); 15 | for (; ; ) { 16 | E e = it.next(); 17 | sb.append(e == collection ? "(this Collection)" : e); 18 | if (!it.hasNext()) { 19 | return sb.toString(); 20 | } 21 | sb.append(','); 22 | } 23 | } 24 | 25 | public static boolean isEmpty(Collection> coll) { 26 | return coll == null || coll.isEmpty(); 27 | } 28 | 29 | public static boolean isNotEmpty(Collection> coll) { 30 | return !isEmpty(coll); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/FStringUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.util.*; 7 | 8 | public class FStringUtil { 9 | 10 | /** 11 | * 将字符串source根据separator分割成字符串数组 12 | * 13 | * @param source 14 | * @param separator 15 | * @return 16 | */ 17 | public static List listSplit(String source, String separator) { 18 | if (source == null) { 19 | return null; 20 | } 21 | int i = 0; 22 | List list = new ArrayList<>(StringUtils.countMatches(source, separator) + 1); 23 | while (source.length() > 0) { 24 | String value = StringUtils.substringBefore(source, separator); 25 | if (!StringUtils.isEmpty(value)) { 26 | list.add(value); 27 | } 28 | 29 | source = StringUtils.substringAfter(source, separator); 30 | } 31 | return list; 32 | } 33 | 34 | /** 35 | * 将字符串source根据separator分割成字符串数组 36 | * 37 | * @param source 38 | * @param separator 39 | * @return 40 | */ 41 | public static String[] split(String source, String separator) { 42 | String[] distArray = {}; 43 | if (source == null) { 44 | return null; 45 | } 46 | int i = 0; 47 | distArray = new String[StringUtils.countMatches(source, separator) + 1]; 48 | while (source.length() > 0) { 49 | String value = StringUtils.substringBefore(source, separator); 50 | distArray[i++] = StringUtils.isEmpty(value) ? null : value; 51 | source = StringUtils.substringAfter(source, separator); 52 | } 53 | if (distArray[distArray.length - 1] == null) {// 排除最后一个分隔符后放空 54 | distArray[distArray.length - 1] = null; 55 | } 56 | return distArray; 57 | } 58 | 59 | /** 60 | * 判断str最后一个字符是否包含str2是的话删除 61 | * @param str 62 | * @param str2 63 | * @return 64 | */ 65 | public static String removeLast(String str, String str2) { 66 | if (StringUtils.isEmpty(str) || StringUtils.isEmpty(str2)) { 67 | return null; 68 | } 69 | if (str2.equals(str.substring(str.length() - 1))) { 70 | str = str.substring(0, str.length() - 1); 71 | } 72 | return str; 73 | } 74 | 75 | /** 76 | * 将字符串source根据全局变量GobelConstants.SPLIT_SEPARATOR分割成字符串数组 77 | * 78 | * @param source 79 | * @return 80 | */ 81 | public static String[] split(String source) { 82 | return split(source, ","); 83 | } 84 | 85 | 86 | public static void main(String[] args) { 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/FileUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.io.FileUtils; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.io.*; 7 | 8 | /** 9 | * 文件处理类 10 | */ 11 | public class FileUtil { 12 | 13 | /** 14 | * 下载文件 15 | * @param response 16 | * @param filePath 17 | * @param fileName 18 | */ 19 | public static void downloadFile(HttpServletResponse response, 20 | String filePath, String fileName) { 21 | 22 | InputStream is = null; 23 | OutputStream os = null; 24 | BufferedOutputStream bos = null; 25 | File file = new File(filePath); 26 | 27 | try { 28 | if(file.exists()){ 29 | response.setContentType("APPLICATION/OCTET-STREAM;charset=UTF-8"); 30 | fileName = fileName.replace(",", ","); 31 | String formatFileName = java.net.URLEncoder.encode(fileName, "UTF-8"); 32 | response.setHeader("Content-Disposition", "attachment; filename="+ formatFileName); 33 | is = new BufferedInputStream(new FileInputStream(file)); 34 | os = response.getOutputStream(); 35 | bos = new BufferedOutputStream(os); 36 | 37 | byte[] buffer = new byte[1024]; 38 | 39 | int len = 0; 40 | 41 | while (-1 != (len = is.read(buffer))) { 42 | bos.write(buffer, 0, len); 43 | 44 | } 45 | bos.flush(); 46 | } 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } finally { 50 | try { 51 | if (bos != null) { 52 | bos.close(); 53 | } 54 | if (os != null) { 55 | os.close(); 56 | } 57 | if (is != null) { 58 | is.close(); 59 | } 60 | 61 | } catch (IOException e) { 62 | e.printStackTrace(); 63 | } 64 | 65 | } 66 | } 67 | 68 | public static void deleteFile(String filePath){ 69 | File file = new File(filePath); 70 | if(file.exists()){ 71 | FileUtils.deleteQuietly(file); 72 | } 73 | } 74 | public static void saveFileNew(InputStream source, File dest) { 75 | InputStream is = null; 76 | OutputStream os = null; 77 | try { 78 | is = new BufferedInputStream(source); 79 | 80 | os = new BufferedOutputStream(new FileOutputStream(dest)); 81 | 82 | int len = 0; 83 | 84 | byte[] buffer = new byte[1024]; 85 | 86 | while (-1 != (len = is.read(buffer))) { 87 | os.write(buffer, 0, len); 88 | 89 | } 90 | os.flush(); 91 | } catch (IOException e) { 92 | e.printStackTrace(); 93 | throw new RuntimeException(); 94 | } finally { 95 | try { 96 | if (os != null) { 97 | os.close(); 98 | } 99 | if (is != null) { 100 | is.close(); 101 | } 102 | } catch (IOException e) { 103 | e.printStackTrace(); 104 | } 105 | } 106 | } 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/GzipUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | import java.io.ByteArrayInputStream; 3 | import java.io.ByteArrayOutputStream; 4 | import java.util.zip.GZIPInputStream; 5 | import java.util.zip.GZIPOutputStream; 6 | 7 | /** 8 | * Gzip压缩解压工具类 9 | */ 10 | 11 | public class GzipUtils { 12 | /** 13 | * 压缩 14 | * @param data 15 | * @return 16 | * @throws Exception 17 | */ 18 | public static byte[] gzip(byte[] data) throws Exception { 19 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 20 | GZIPOutputStream gzip = new GZIPOutputStream(bos); 21 | gzip.write(data); 22 | gzip.finish(); 23 | gzip.close(); 24 | byte[] ret = bos.toByteArray(); 25 | bos.close(); 26 | return ret; 27 | } 28 | 29 | /** 30 | * 解压 31 | * @param data 32 | * @return 33 | * @throws Exception 34 | */ 35 | public static byte[] ungzip(byte[] data) throws Exception { 36 | ByteArrayInputStream bis = new ByteArrayInputStream(data); 37 | GZIPInputStream gzip = new GZIPInputStream(bis); 38 | byte[] buf = new byte[1024]; 39 | int num = -1; 40 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 41 | while ((num = gzip.read(buf, 0, buf.length)) != -1) { 42 | bos.write(buf, 0, num); 43 | } 44 | gzip.close(); 45 | bis.close(); 46 | byte[] ret = bos.toByteArray(); 47 | bos.flush(); 48 | bos.close(); 49 | return ret; 50 | } 51 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/HttpServletUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.springframework.web.context.request.RequestContextHolder; 4 | import org.springframework.web.context.request.ServletRequestAttributes; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import javax.servlet.http.HttpSession; 9 | import java.util.Enumeration; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | public class HttpServletUtils { 14 | 15 | public static HttpServletRequest getRequest() { 16 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); 17 | } 18 | 19 | public static HttpServletResponse getResponse() { 20 | return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse(); 21 | } 22 | 23 | public static void setAttribute(String key, Object data) { 24 | getHttpSession().setAttribute(key, data); 25 | } 26 | 27 | public static HttpSession getHttpSession() { 28 | return getRequest().getSession(); 29 | } 30 | 31 | public static Object getSessionAttribute(String var1) { 32 | return getHttpSession().getAttribute(var1); 33 | } 34 | 35 | public static Object getRequestAttribute(String var1) { 36 | return getRequest().getAttribute(var1); 37 | } 38 | 39 | 40 | /** 41 | * 获取所有请求参数 42 | * 43 | * @return 返回所有请求参数 44 | */ 45 | public static Map getAllParam() { 46 | Map params = new HashMap<>(); 47 | HttpServletRequest request = getRequest(); 48 | Enumeration enu = request.getParameterNames(); 49 | while (enu.hasMoreElements()) { 50 | String paraName = (String) enu.nextElement(); 51 | String val = request.getParameter(paraName); 52 | params.put(paraName, val); 53 | } 54 | return params; 55 | } 56 | 57 | /** 58 | * 获取请求参数 59 | * 60 | * @return 返回所有请求参数 61 | */ 62 | public static Object getRequestParam(String key) { 63 | HttpServletRequest request = getRequest(); 64 | if (request != null) { 65 | return request.getParameter(key); 66 | } 67 | return null; 68 | } 69 | 70 | /** 71 | * 获得请求参数返回指定的强制转换对象 72 | * @param key 73 | * @param clazz 74 | * @param 75 | * @return 76 | */ 77 | public static T getRequestParam(String key, Class clazz) { 78 | Object obj = getRequestParam(key); 79 | if (obj != null) { 80 | return (T) obj; 81 | } 82 | return null; 83 | } 84 | 85 | /** 86 | * 获得请求参数返回字符串 87 | * @param key 88 | * @return 89 | */ 90 | public static String getRequestParamString(String key) { 91 | Object obj = getRequestParam(key); 92 | if (obj != null) { 93 | return obj.toString(); 94 | } 95 | return null; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * Ip工具类 7 | */ 8 | public class IpUtils { 9 | private IpUtils() { 10 | } 11 | 12 | /** 13 | * 取得ip地址 14 | * @param request 15 | * @return 16 | */ 17 | public static String getIpAddr(HttpServletRequest request) { 18 | if (request == null) { 19 | return "unknown"; 20 | } 21 | String ip = request.getHeader("x-forwarded-for"); 22 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 23 | ip = request.getHeader("Proxy-Client-IP"); 24 | } 25 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 26 | ip = request.getHeader("X-Forwarded-For"); 27 | } 28 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 29 | ip = request.getHeader("WL-Proxy-Client-IP"); 30 | } 31 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 32 | ip = request.getHeader("X-Real-IP"); 33 | } 34 | 35 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 36 | ip = request.getRemoteAddr(); 37 | } 38 | return ip; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/Md5Utils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.security.MessageDigest; 7 | import java.util.UUID; 8 | 9 | public class Md5Utils { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class); 12 | 13 | 14 | public static String getUUID() { 15 | return UUID.randomUUID().toString().replace("-", "").toUpperCase(); 16 | } 17 | 18 | private static byte[] md5(String s) { 19 | MessageDigest algorithm; 20 | try { 21 | algorithm = MessageDigest.getInstance("MD5"); 22 | algorithm.reset(); 23 | algorithm.update(s.getBytes("UTF-8")); 24 | byte[] messageDigest = algorithm.digest(); 25 | return messageDigest; 26 | } catch (Exception e) { 27 | LOGGER.error("MD5 Error...", e); 28 | } 29 | return null; 30 | } 31 | 32 | private static final String toHex(byte[] hash) { 33 | if (hash == null) { 34 | return null; 35 | } 36 | StringBuffer buf = new StringBuffer(hash.length * 2); 37 | int i; 38 | 39 | for (i = 0; i < hash.length; i++) { 40 | if ((hash[i] & 0xff) < 0x10) { 41 | buf.append("0"); 42 | } 43 | buf.append(Long.toString(hash[i] & 0xff, 16)); 44 | } 45 | return buf.toString(); 46 | } 47 | 48 | public static String hash(String s) { 49 | try { 50 | return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); 51 | } catch (Exception e) { 52 | LOGGER.error("not supported charset...{}", e); 53 | return s; 54 | } 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/PasswordUtil.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.codec.binary.Hex; 4 | import org.apache.commons.lang3.RandomStringUtils; 5 | 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * 密码工具类 11 | */ 12 | public class PasswordUtil { 13 | /** 14 | * 取得随机字符串 15 | * @param from 16 | * @param distance 17 | * @return 18 | */ 19 | public static String getRandom(int from,int distance){ 20 | int no =(int) (distance* Math.random() +from ); 21 | return RandomStringUtils.randomAlphanumeric(no).toLowerCase(); 22 | } 23 | 24 | /** 25 | * 取得用户密码 26 | * @param prefix 27 | * @param pwd 28 | * @param suffix 29 | * @return 30 | */ 31 | public static String getPwd(String prefix,String pwd,String suffix){ 32 | try { 33 | String md5PWD = Hex.encodeHexString(CodeUtil.encryptMD5(pwd.getBytes())); 34 | String str = prefix+md5PWD+suffix; 35 | return Hex.encodeHexString(CodeUtil.encryptSHA(str.getBytes())); 36 | } catch (Exception e) { 37 | new RuntimeException(e.getMessage()); 38 | } 39 | return null; 40 | } 41 | 42 | /** 43 | * @description: 取得用户密码 44 | * @createTime: 2017年6月2日 下午6:38:03 45 | * @author: lys 46 | * @param prefix 47 | * @param pwd 48 | * @param suffix 49 | * @return 50 | */ 51 | public static String getPwd(String prefix,String pwd){ 52 | return getPwd(prefix,pwd,""); 53 | } 54 | 55 | 56 | /** 57 | * 密码验证:不能全是数字或全是字母,长度>6 58 | */ 59 | public static Boolean valdateUsepwd(String usepwd) { 60 | String pwdPattern = "(?!^\\d+$)(?!^[a-zA-Z]+$).{6,}"; 61 | Pattern pattern = Pattern.compile(pwdPattern); 62 | Matcher matcher = pattern.matcher(usepwd); 63 | return matcher.matches(); 64 | } 65 | 66 | 67 | public static void main(String[] args) { 68 | 69 | System.out.println(PasswordUtil.getPwd("sfff","123456")); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.apache.commons.lang3.ArrayUtils; 4 | 5 | import java.lang.reflect.Field; 6 | import java.lang.reflect.Method; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | public class ReflectionUtils { 12 | 13 | public static void reflectClassValueToNull(Object model, String[] fieldNames) throws Exception { 14 | if (ArrayUtils.isEmpty(fieldNames)) { 15 | return; 16 | } 17 | List fieldArray = Arrays.asList(fieldNames); 18 | // 获取此类的所有父类 19 | List> listSuperClass = new ArrayList<>(10); 20 | Class> superClass = model.getClass().getSuperclass(); 21 | while (superClass != null) { 22 | if (superClass.getName().equals("java.lang.Object")) { 23 | break; 24 | } 25 | listSuperClass.add(superClass); 26 | superClass = superClass.getSuperclass(); 27 | } 28 | // 遍历处理所有父类的字段 29 | for (Class> clazz : listSuperClass) { 30 | Field[] fields = clazz.getDeclaredFields(); 31 | for (int i = 0; i < fields.length; i++) { 32 | String name = fields[i].getName(); 33 | if (fieldArray.contains(name)) { 34 | Class type = fields[i].getType(); 35 | Method method = clazz.getMethod("set" + name.replaceFirst(name.substring(0, 1), 36 | name.substring(0, 1).toUpperCase()), type); 37 | method.invoke(model, new Object[]{null}); 38 | } 39 | 40 | } 41 | } 42 | // 处理此类自己的字段 43 | Field[] fields = model.getClass().getDeclaredFields(); 44 | for (int i = 0; i < fields.length; i++) { 45 | String name = fields[i].getName(); 46 | if (fieldArray.contains(name)) { 47 | Class type = fields[i].getType(); 48 | // 获取属性的set方法 49 | Method method = model.getClass().getMethod("set" + name.replaceFirst(name.substring(0, 1), 50 | name.substring(0, 1).toUpperCase()), type); 51 | // 将值设为null 52 | method.invoke(model, new Object[]{null}); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/SpringContextUtils.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | 9 | /** 10 | * @description: Spring Context 工具类 11 | * @copyright: 12 | * @createTime: 2018/6/29 15:23 13 | * @author:dzy 14 | * @version:1.0 15 | */ 16 | @Component 17 | public class SpringContextUtils implements ApplicationContextAware { 18 | public static ApplicationContext applicationContext; 19 | 20 | @Override 21 | public void setApplicationContext(ApplicationContext applicationContext) 22 | throws BeansException { 23 | SpringContextUtils.applicationContext = applicationContext; 24 | } 25 | 26 | public static Object getBean(String name) { 27 | return applicationContext.getBean(name); 28 | } 29 | 30 | public static T getBean(String name, Class requiredType) { 31 | return applicationContext.getBean(name, requiredType); 32 | } 33 | 34 | public static boolean containsBean(String name) { 35 | return applicationContext.containsBean(name); 36 | } 37 | 38 | public static boolean isSingleton(String name) { 39 | return applicationContext.isSingleton(name); 40 | } 41 | 42 | public static Class extends Object> getType(String name) { 43 | return applicationContext.getType(name); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/utils/Underline2Camel.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | /** 6 | * @description: 7 | * @copyright: 8 | * @createTime: 2017/12/11 14:49 9 | * @author:dzy 10 | * @version:1.0 11 | */ 12 | public class Underline2Camel { 13 | /** 14 | * 下划线转驼峰法 15 | * @param line 源字符串 16 | * @param smallCamel 大小驼峰,是否为小驼峰 17 | * @return 转换后的字符串 18 | */ 19 | public static String underline2Camel(String line,boolean smallCamel){ 20 | if(line==null||"".equals(line)){ 21 | return ""; 22 | } 23 | StringBuffer sb=new StringBuffer(); 24 | Pattern pattern=Pattern.compile("([A-Za-z\\d]+)(_)?"); 25 | Matcher matcher=pattern.matcher(line); 26 | while(matcher.find()){ 27 | String word=matcher.group(); 28 | sb.append(smallCamel&&matcher.start()==0?Character.toLowerCase(word.charAt(0)):Character.toUpperCase(word.charAt(0))); 29 | int index=word.lastIndexOf('_'); 30 | if(index>0){ 31 | sb.append(word.substring(1, index).toLowerCase()); 32 | }else{ 33 | sb.append(word.substring(1).toLowerCase()); 34 | } 35 | } 36 | return sb.toString(); 37 | } 38 | /** 39 | * 驼峰法转下划线 40 | * @param line 源字符串 41 | * @return 转换后的字符串 42 | */ 43 | public static String camel2Underline(String line){ 44 | if(line==null||"".equals(line)){ 45 | return ""; 46 | } 47 | line=String.valueOf(line.charAt(0)).toUpperCase().concat(line.substring(1)); 48 | StringBuffer sb=new StringBuffer(); 49 | Pattern pattern=Pattern.compile("[A-Z]([a-z\\d]+)?"); 50 | Matcher matcher=pattern.matcher(line); 51 | while(matcher.find()){ 52 | String word=matcher.group(); 53 | sb.append(word.toUpperCase()); 54 | sb.append(matcher.end()==line.length()?"":"_"); 55 | } 56 | return sb.toString(); 57 | } 58 | public static void main(String[] args) { 59 | String line="I_HAVE_AN_IPANG3_PIG"; 60 | String camel=underline2Camel(line,true); 61 | System.out.println(camel); 62 | System.out.println(camel2Underline(camel)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/Menu.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | 4 | /** 5 | * @description: 6 | * @copyright: 7 | * @createTime: 2017/8/31 17:23 8 | * @author:dzy 9 | * @version:1.0 10 | */ 11 | 12 | public class Menu { 13 | private Long id; 14 | /* 15 | 菜单名 16 | */ 17 | private String name; 18 | /* 19 | 菜单图标 20 | */ 21 | private String icon; 22 | /* 23 | 访问路径 24 | */ 25 | private String url; 26 | /* 27 | 组件名 28 | */ 29 | private String component; 30 | /** 31 | * 父id 32 | */ 33 | private Long parentId; 34 | 35 | 36 | public Long getId() { 37 | return id; 38 | } 39 | 40 | public void setId(Long id) { 41 | this.id = id; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | public String getIcon() { 53 | return icon; 54 | } 55 | 56 | public void setIcon(String icon) { 57 | this.icon = icon; 58 | } 59 | 60 | public String getUrl() { 61 | return url; 62 | } 63 | 64 | public void setUrl(String url) { 65 | this.url = url; 66 | } 67 | 68 | public String getComponent() { 69 | return component; 70 | } 71 | 72 | public void setComponent(String component) { 73 | this.component = component; 74 | } 75 | 76 | public Long getParentId() { 77 | return parentId; 78 | } 79 | 80 | public void setParentId(Long parentId) { 81 | this.parentId = parentId; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/ServiceResult.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | 5 | import java.io.Serializable; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * service层执行的结果 11 | */ 12 | public class ServiceResult implements Serializable { 13 | private static final long serialVersionUID = 1L; 14 | /** 15 | * 返回的信息 16 | */ 17 | protected String message; 18 | /** 19 | * 执行是否成功 20 | */ 21 | protected Boolean success; 22 | 23 | protected Integer errNo; 24 | 25 | protected Map data = new HashMap(); 26 | 27 | public ServiceResult() { 28 | } 29 | 30 | public ServiceResult(Boolean success) { 31 | this.success = success; 32 | } 33 | 34 | public ServiceResult(Integer errNo, String message) { 35 | this.errNo = errNo; 36 | this.message = message; 37 | this.success = false; 38 | } 39 | 40 | public String toJSON() { 41 | JSONObject result = new JSONObject(); 42 | result.put("message", message); 43 | result.put("success", success); 44 | result.put("data", data); 45 | result.put("errNo", errNo); 46 | return result.toString(); 47 | } 48 | 49 | /** 50 | * 添加数据 51 | * 52 | * @param key 53 | * @param value 54 | */ 55 | public ServiceResult addData(String key, Object value) { 56 | data.put(key, value); 57 | return this; 58 | } 59 | 60 | public ServiceResult setMessage(String message) { 61 | this.message = message; 62 | return this; 63 | } 64 | 65 | public String getMessage() { 66 | return this.message; 67 | } 68 | 69 | public Boolean getSuccess() { 70 | return success; 71 | } 72 | 73 | public ServiceResult setSuccess(Boolean success) { 74 | this.success = success; 75 | return this; 76 | } 77 | 78 | public Integer getErrNo() { 79 | return errNo; 80 | } 81 | 82 | public ServiceResult setErrNo(Integer errNo) { 83 | this.errNo = errNo; 84 | return this; 85 | } 86 | 87 | public Map getData() { 88 | return data; 89 | } 90 | 91 | public ServiceResult setData(Map data) { 92 | this.data = data; 93 | return this; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/ServiceRowsResult.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @Description: 分页结果 7 | * @author dzy 8 | * @vesion 1.0 9 | */ 10 | public class ServiceRowsResult extends ServiceResult { 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ServiceRowsResult(){} 14 | 15 | public ServiceRowsResult(Boolean success){ 16 | this.success=success; 17 | } 18 | 19 | public void setPage(List rows, Long total){ 20 | addData("rows",rows); 21 | addData("total",total); 22 | } 23 | 24 | public void setPage(List rows){ 25 | addData("rows",rows); 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /ffast-core/src/main/java/cn/ffast/core/vo/Tree.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.core.vo; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * @description: 树 8 | * @copyright: 9 | * @createTime: 2017/12/8 14:15 10 | * @author:dzy 11 | * @version:1.0 12 | */ 13 | public class Tree { 14 | private Long parentId; 15 | private Long id; 16 | private String name; 17 | private String title; 18 | private List children; 19 | private String type; 20 | 21 | public Long getParentId() { 22 | return parentId; 23 | } 24 | 25 | public void setParentId(Long parentId) { 26 | this.parentId = parentId; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public List getChildren() { 46 | return children; 47 | } 48 | 49 | public void setChildren(List children) { 50 | this.children = children; 51 | } 52 | 53 | public String getTitle() { 54 | return title; 55 | } 56 | 57 | public void setTitle(String title) { 58 | this.title = title; 59 | } 60 | 61 | public String getType() { 62 | return type; 63 | } 64 | 65 | public void setType(String type) { 66 | this.type = type; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ffast-core/src/main/resources/font/WellrockSlabBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhiYiDai/Ffast-Java/fc5b0d76bb6f2258ab1464805223084cee01079b/ffast-core/src/main/resources/font/WellrockSlabBold.ttf -------------------------------------------------------------------------------- /ffast-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ffast-parent 7 | cn.ffast 8 | 1.0-SNAPSHOT 9 | ../ffast-parent/pom.xml 10 | 11 | cn.ffast 12 | 1.0-SNAPSHOT 13 | 4.0.0 14 | jar 15 | ffast-generator 16 | 17 | 18 | 19 | cn.ffast 20 | ffast-core 21 | 1.0-SNAPSHOT 22 | 23 | 24 | 25 | 26 | org.apache.velocity 27 | velocity 28 | 1.7 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/controller/TableController.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.controller; 2 | 3 | 4 | import cn.ffast.core.vo.ServiceRowsResult; 5 | import cn.ffast.generator.dao.TableDao; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import javax.annotation.Resource; 9 | 10 | @RestController 11 | @RequestMapping("/api/generator/table") 12 | public class TableController { 13 | 14 | @Resource 15 | TableDao tableDao; 16 | 17 | 18 | @RequestMapping("/list") 19 | public ServiceRowsResult list(String id) { 20 | ServiceRowsResult result = new ServiceRowsResult(true); 21 | result.setPage(tableDao.listTable()); 22 | return result; 23 | } 24 | @RequestMapping("/columns") 25 | public ServiceRowsResult info(String tableName) { 26 | ServiceRowsResult result = new ServiceRowsResult(true); 27 | result.setPage(tableDao.listTableColumn(tableName)); 28 | return result; 29 | } 30 | } -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/dao/TableDao.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.dao; 2 | 3 | import cn.ffast.generator.entity.Column; 4 | import cn.ffast.generator.entity.Table; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Select; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | @Mapper 12 | public interface TableDao { 13 | 14 | @Select("select * from information_schema.TABLES where TABLE_SCHEMA=(select database())") 15 | List listTable(); 16 | 17 | @Select("select * from information_schema.COLUMNS where TABLE_SCHEMA = (select database()) and TABLE_NAME=#{tableName}") 18 | List listTableColumn(String tableName); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/entity/Column.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.entity; 2 | 3 | public class Column { 4 | private String columnName; 5 | private String dataType; 6 | private String columnComment; 7 | private String isNullable; 8 | private Integer ordinalPosition; 9 | private String extra; 10 | private Integer characterMaximumLength; 11 | private String columnDefault; 12 | 13 | public String getColumnName() { 14 | return columnName; 15 | } 16 | 17 | public void setColumnName(String columnName) { 18 | this.columnName = columnName; 19 | } 20 | 21 | public String getDataType() { 22 | return dataType; 23 | } 24 | 25 | public void setDataType(String dataType) { 26 | this.dataType = dataType; 27 | } 28 | 29 | public String getColumnComment() { 30 | return columnComment; 31 | } 32 | 33 | public void setColumnComment(String columnComment) { 34 | this.columnComment = columnComment; 35 | } 36 | 37 | public String getIsNullable() { 38 | return isNullable; 39 | } 40 | 41 | public void setIsNullable(String isNullable) { 42 | this.isNullable = isNullable; 43 | } 44 | 45 | public Integer getOrdinalPosition() { 46 | return ordinalPosition; 47 | } 48 | 49 | public void setOrdinalPosition(Integer ordinalPosition) { 50 | this.ordinalPosition = ordinalPosition; 51 | } 52 | 53 | public String getExtra() { 54 | return extra; 55 | } 56 | 57 | public void setExtra(String extra) { 58 | this.extra = extra; 59 | } 60 | 61 | public Integer getCharacterMaximumLength() { 62 | return characterMaximumLength; 63 | } 64 | 65 | public void setCharacterMaximumLength(Integer characterMaximumLength) { 66 | this.characterMaximumLength = characterMaximumLength; 67 | } 68 | 69 | public String getColumnDefault() { 70 | return columnDefault; 71 | } 72 | 73 | public void setColumnDefault(String columnDefault) { 74 | this.columnDefault = columnDefault; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ffast-generator/src/main/java/cn/ffast/generator/entity/Table.java: -------------------------------------------------------------------------------- 1 | package cn.ffast.generator.entity; 2 | 3 | public class Table { 4 | private String tableName; 5 | private String tableComment; 6 | 7 | public String getTableName() { 8 | return tableName; 9 | } 10 | 11 | public void setTableName(String tableName) { 12 | this.tableName = tableName; 13 | } 14 | 15 | public String getTableComment() { 16 | return tableComment; 17 | } 18 | 19 | public void setTableComment(String tableComment) { 20 | this.tableComment = tableComment; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/controller.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Controller}; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import javax.annotation.Resource; 8 | import ${package.Entity}.${entity}; 9 | import ${package.Service}.${table.serviceName}; 10 | 11 | #if(${superControllerClassPackage}) 12 | import ${superControllerClassPackage}; 13 | #end 14 | 15 | /** 16 | * @description: $!{table.comment}数据接口 17 | * @copyright: ${copyright} (c)${cfg.year} 18 | * @createTime: ${cfg.createTime} 19 | * @author: ${author} 20 | * @version: ${cfg.version} 21 | */ 22 | @Controller 23 | @RequestMapping("/${cfg.apiPrefix}/${cfg.resPrefix}#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}") 24 | #if(${superControllerClass}) 25 | public class ${table.controllerName} extends ${superControllerClass}<${entity},${table.serviceName},Long> { 26 | 27 | private static Logger logger = LoggerFactory.getLogger(${table.controllerName}.class); 28 | 29 | @Resource 30 | private ${table.serviceName} service; 31 | 32 | @Override 33 | protected ${table.serviceName} getService() { 34 | return this.service; 35 | } 36 | 37 | @Override 38 | protected Logger getLogger() { 39 | return logger; 40 | } 41 | 42 | 43 | #else 44 | public class ${table.controllerName} { 45 | #end 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/entity.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Entity}; 2 | 3 | #foreach($pkg in ${table.importPackages}) 4 | import ${pkg}; 5 | #end 6 | 7 | /** 8 | * @description: $!{table.comment} 9 | * @copyright: ${copyright} (c)${cfg.year} 10 | * @createTime: ${cfg.createTime} 11 | * @author: ${author} 12 | * @version: ${cfg.version} 13 | */ 14 | #if(${table.convert}) 15 | @TableName(value="${table.name}",resultMap="BaseResultMap") 16 | #end 17 | #if(${superEntityClass}) 18 | public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end { 19 | #elseif(${activeRecord}) 20 | public class ${entity} extends Model<${entity}> { 21 | #else 22 | public class ${entity} implements Serializable { 23 | #end 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | #foreach($field in ${table.fields}) 28 | #if(${field.keyFlag}) 29 | #set($keyPropertyName=${field.propertyName}) 30 | #end 31 | #if("$!field.comment" != "") 32 | /** 33 | * ${field.comment} 34 | */ 35 | #end 36 | #if(${field.keyFlag}) 37 | #if(${field.keyIdentityFlag}) 38 | @TableId(value="${field.name}", type= IdType.AUTO) 39 | #elseif(${field.convert}) 40 | @TableId("${field.name}") 41 | #end 42 | #elseif(${field.fill}) 43 | #if(${field.convert}) 44 | @TableField(value = "${field.name}", fill = FieldFill.${field.fill}) 45 | #else 46 | @TableField(fill = FieldFill.${field.fill}) 47 | #end 48 | #elseif(${field.convert}) 49 | @TableField("${field.name}") 50 | #end 51 | #if(${logicDeleteFieldName}==${field.name}) 52 | @TableLogic 53 | #end 54 | private ${field.propertyType} ${field.propertyName}; 55 | #end 56 | #foreach($field in ${table.fields}) 57 | #if(${field.propertyType.equals("Boolean")}) 58 | #set($getprefix="is") 59 | #else 60 | #set($getprefix="get") 61 | #end 62 | 63 | public ${field.propertyType} ${getprefix}${field.capitalName}() { 64 | return ${field.propertyName}; 65 | } 66 | 67 | #if(${entityBuilderModel}) 68 | public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) { 69 | #else 70 | public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { 71 | #end 72 | this.${field.propertyName} = ${field.propertyName}; 73 | #if(${entityBuilderModel}) 74 | return this; 75 | #end 76 | } 77 | #end 78 | 79 | #if(${entityColumnConstant}) 80 | #foreach($field in ${table.fields}) 81 | public static final String ${field.name.toUpperCase()} = "${field.name}"; 82 | 83 | #end 84 | #end 85 | 86 | } 87 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/mapper.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Mapper}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${superMapperClassPackage}; 5 | 6 | /** 7 | * @description: $!{table.comment}Mapper接口 8 | * @copyright: ${copyright} (c)${cfg.year} 9 | * @createTime: ${cfg.createTime} 10 | * @author: ${author} 11 | * @version: ${cfg.version} 12 | */ 13 | public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { 14 | 15 | } -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/mapper.xml.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #if(${enableCache}) 6 | 7 | 8 | 9 | #end 10 | #if(${baseResultMap}) 11 | 12 | 13 | #foreach($field in ${table.fields}) 14 | #if(${field.keyFlag})##生成主键排在第一位 15 | 16 | #end 17 | #end 18 | #foreach($field in ${table.commonFields})##生成公共字段 19 | 20 | #end 21 | #foreach($field in ${table.fields}) 22 | #if(!${field.keyFlag})##生成普通字段 23 | 24 | #end 25 | #end 26 | 27 | #end 28 | #if(${baseColumnList}) 29 | 30 | 31 | ${table.fieldNames} 32 | 33 | 34 | 35 | 36 | #foreach($field in ${table.commonFields})##生成字段 37 | #if(${field.propertyType.equals("String")}) 38 | 39 | #else 40 | 41 | #end 42 | AND ${field.name} = #{m.${field.propertyName}} 43 | 44 | #end 45 | #foreach($field in ${table.fields})##生成字段 46 | #if(${field.propertyType.equals("String")}) 47 | 48 | #else 49 | 50 | #end 51 | AND ${field.name} = #{m.${field.propertyName}} 52 | 53 | #end 54 | 55 | ORDER BY id ASC 56 | 57 | 58 | 59 | 76 | 77 | #end 78 | 79 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/service.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.Service}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${superServiceClassPackage}; 5 | 6 | /** 7 | * @description: $!{table.comment}服务类 8 | * @copyright: ${copyright} (c)${cfg.year} 9 | * @createTime: ${cfg.createTime} 10 | * @author: ${author} 11 | * @version: ${cfg.version} 12 | */ 13 | public interface ${table.serviceName} extends ${superServiceClass}<${entity},Long> { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/serviceImpl.java.vm: -------------------------------------------------------------------------------- 1 | package ${package.ServiceImpl}; 2 | 3 | import ${package.Entity}.${entity}; 4 | import ${package.Mapper}.${table.mapperName}; 5 | import ${package.Service}.${table.serviceName}; 6 | import ${superServiceImplClassPackage}; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @description: $!{table.comment}服务实现类 11 | * @copyright: ${copyright} (c)${cfg.year} 12 | * @createTime: ${cfg.createTime} 13 | * @author: ${author} 14 | * @version: ${cfg.version} 15 | */ 16 | @Service 17 | public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName},${entity},Long> implements ${table.serviceName} { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ffast-generator/src/test/resources/templates/vue.vm: -------------------------------------------------------------------------------- 1 | #set($url="/${cfg.resPrefix}#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/") 2 | 4 | 5 | 6 | 7 | 8 | 9 | 88 | --------------------------------------------------------------------------------
15 | *
16 | * HmacMD5 17 | * HmacSHA1 18 | * HmacSHA256 19 | * HmacSHA384 20 | * HmacSHA512 21 | *