├── .gitignore ├── README.md ├── pom.xml ├── zero-business ├── logs │ └── zero-center ├── pom.xml └── src │ ├── main │ ├── java │ │ └── space │ │ │ └── zero │ │ │ └── business │ │ │ ├── ZeroApplication.java │ │ │ ├── configure │ │ │ ├── DruidConfigurer.java │ │ │ ├── MybatisConfigurer.java │ │ │ ├── SpringContextCommon.java │ │ │ ├── SpringContextSecurity.java │ │ │ ├── SpringContextSpringSession.java │ │ │ ├── WebMvcConfigurer.java │ │ │ ├── ZeroSecurityInitializer.java │ │ │ ├── ZeroSessionInitializer.java │ │ │ ├── interceptor │ │ │ │ └── LoggerInterceptor.java │ │ │ └── override │ │ │ │ └── PackagesSqlSessionFactoryBean.java │ │ │ └── module │ │ │ ├── base │ │ │ ├── dao │ │ │ │ ├── BaseOrganizationMapper.java │ │ │ │ └── SysLogMapper.java │ │ │ ├── model │ │ │ │ ├── BaseOrganization.java │ │ │ │ └── SysLog.java │ │ │ ├── param │ │ │ │ └── response │ │ │ │ │ └── BaseOrganizationTree.java │ │ │ ├── service │ │ │ │ ├── BaseOrganizationService.java │ │ │ │ ├── SysLogService.java │ │ │ │ └── impl │ │ │ │ │ ├── BaseOrganizationServiceImpl.java │ │ │ │ │ └── SysLogServiceImpl.java │ │ │ └── web │ │ │ │ ├── BaseOrganizationController.java │ │ │ │ └── SysLogController.java │ │ │ ├── common │ │ │ └── web │ │ │ │ ├── DashboardController.java │ │ │ │ ├── DocumentationController.java │ │ │ │ ├── IconController.java │ │ │ │ ├── IndexController.java │ │ │ │ └── LogoutController.java │ │ │ ├── official │ │ │ └── website │ │ │ │ ├── base │ │ │ │ ├── WebsiteDeleteFlagService.java │ │ │ │ └── WebsiteEntity.java │ │ │ │ ├── dao │ │ │ │ ├── OfficialWebsiteAboutUsMapper.java │ │ │ │ ├── OfficialWebsiteBaseInfoMapper.java │ │ │ │ ├── OfficialWebsiteCarouselMapper.java │ │ │ │ ├── OfficialWebsiteClassMateMapper.java │ │ │ │ ├── OfficialWebsiteContactUsMapper.java │ │ │ │ ├── OfficialWebsiteCustomerCaseMapper.java │ │ │ │ ├── OfficialWebsiteDigitizationMapper.java │ │ │ │ ├── OfficialWebsiteFirstScreenMapper.java │ │ │ │ ├── OfficialWebsiteHistoryMapper.java │ │ │ │ ├── OfficialWebsiteNewsMapper.java │ │ │ │ ├── OfficialWebsiteProductMapper.java │ │ │ │ ├── OfficialWebsiteRecruitMapper.java │ │ │ │ └── OfficialWebsiteSolutionMapper.java │ │ │ │ ├── model │ │ │ │ ├── OfficialWebsiteAboutUs.java │ │ │ │ ├── OfficialWebsiteBaseInfo.java │ │ │ │ ├── OfficialWebsiteCarousel.java │ │ │ │ ├── OfficialWebsiteClassMate.java │ │ │ │ ├── OfficialWebsiteContactUs.java │ │ │ │ ├── OfficialWebsiteCustomerCase.java │ │ │ │ ├── OfficialWebsiteDigitization.java │ │ │ │ ├── OfficialWebsiteFirstScreen.java │ │ │ │ ├── OfficialWebsiteHistory.java │ │ │ │ ├── OfficialWebsiteNews.java │ │ │ │ ├── OfficialWebsiteProduct.java │ │ │ │ ├── OfficialWebsiteRecruit.java │ │ │ │ └── OfficialWebsiteSolution.java │ │ │ │ ├── param │ │ │ │ ├── request │ │ │ │ │ ├── ClazzListRequest.java │ │ │ │ │ └── CondRequest.java │ │ │ │ └── response │ │ │ │ │ ├── ClazzListResponse.java │ │ │ │ │ └── NewsDetailResponse.java │ │ │ │ ├── service │ │ │ │ ├── OfficialWebsiteAboutUsService.java │ │ │ │ ├── OfficialWebsiteBaseInfoService.java │ │ │ │ ├── OfficialWebsiteCarouselService.java │ │ │ │ ├── OfficialWebsiteClassMateService.java │ │ │ │ ├── OfficialWebsiteContactUsService.java │ │ │ │ ├── OfficialWebsiteCustomerCaseService.java │ │ │ │ ├── OfficialWebsiteDigitizationService.java │ │ │ │ ├── OfficialWebsiteFirstScreenService.java │ │ │ │ ├── OfficialWebsiteHistoryService.java │ │ │ │ ├── OfficialWebsiteNewsService.java │ │ │ │ ├── OfficialWebsiteProductService.java │ │ │ │ ├── OfficialWebsiteRecruitService.java │ │ │ │ ├── OfficialWebsiteSolutionService.java │ │ │ │ └── impl │ │ │ │ │ ├── OfficialWebsiteAboutUsServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteBaseInfoServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteCarouselServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteClassMateServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteContactUsServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteCustomerCaseServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteDigitizationServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteFirstScreenServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteHistoryServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteNewsServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteProductServiceImpl.java │ │ │ │ │ ├── OfficialWebsiteRecruitServiceImpl.java │ │ │ │ │ └── OfficialWebsiteSolutionServiceImpl.java │ │ │ │ └── web │ │ │ │ ├── OfficialWebsiteAboutUsController.java │ │ │ │ ├── OfficialWebsiteBaseInfoController.java │ │ │ │ ├── OfficialWebsiteCarouselController.java │ │ │ │ ├── OfficialWebsiteClassMateController.java │ │ │ │ ├── OfficialWebsiteContactUsController.java │ │ │ │ ├── OfficialWebsiteCustomerCaseController.java │ │ │ │ ├── OfficialWebsiteDigitizationController.java │ │ │ │ ├── OfficialWebsiteFirstScreenController.java │ │ │ │ ├── OfficialWebsiteHistoryController.java │ │ │ │ ├── OfficialWebsiteNewsController.java │ │ │ │ ├── OfficialWebsiteProductController.java │ │ │ │ ├── OfficialWebsiteRecruitController.java │ │ │ │ ├── OfficialWebsiteSolutionController.java │ │ │ │ └── api │ │ │ │ └── OfficialWebsiteController.java │ │ │ └── sys │ │ │ ├── dao │ │ │ ├── SysMenuMapper.java │ │ │ ├── SysRoleMapper.java │ │ │ ├── SysRoleMenuMapper.java │ │ │ ├── SysUserMapper.java │ │ │ └── SysUserRoleMapper.java │ │ │ ├── model │ │ │ ├── SysMenu.java │ │ │ ├── SysRole.java │ │ │ ├── SysRoleMenu.java │ │ │ ├── SysUser.java │ │ │ ├── SysUserDetails.java │ │ │ └── SysUserRole.java │ │ │ ├── param │ │ │ ├── request │ │ │ │ ├── CondRequest.java │ │ │ │ ├── RoleAuthListRequest.java │ │ │ │ ├── RoleAuthRequest.java │ │ │ │ ├── SysUserListRequest.java │ │ │ │ └── UserRoleListRequest.java │ │ │ └── response │ │ │ │ ├── RoleListResponse.java │ │ │ │ ├── RouterTree.java │ │ │ │ └── SysMenuTree.java │ │ │ ├── security │ │ │ ├── AntPathRequestMatcher.java │ │ │ ├── ContentTypeAntPathRequestMatcher.java │ │ │ ├── DefaultAuthenticationProcessingFilter.java │ │ │ ├── RestAuthenticationExceptionFilter.java │ │ │ ├── RestAuthenticationProcessingFilter.java │ │ │ ├── SysAccessDecisionManager.java │ │ │ ├── SysAccessDeniedHandler.java │ │ │ ├── SysAuthenticationFailureHandler.java │ │ │ ├── SysAuthenticationSuccessHandler.java │ │ │ ├── SysSecurityFilter.java │ │ │ └── SysSecurityMetadataSource.java │ │ │ ├── service │ │ │ ├── SysMenuService.java │ │ │ ├── SysRoleMenuService.java │ │ │ ├── SysRoleService.java │ │ │ ├── SysUserRoleService.java │ │ │ ├── SysUserService.java │ │ │ └── impl │ │ │ │ ├── SysMenuServiceImpl.java │ │ │ │ ├── SysRoleMenuServiceImpl.java │ │ │ │ ├── SysRoleServiceImpl.java │ │ │ │ ├── SysUserRoleServiceImpl.java │ │ │ │ └── SysUserServiceImpl.java │ │ │ └── web │ │ │ ├── SysMenuController.java │ │ │ ├── SysRoleController.java │ │ │ ├── SysRoleMenuController.java │ │ │ ├── SysUserController.java │ │ │ └── SysUserRoleController.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application-test.yml │ │ ├── application.yml │ │ ├── banner.txt │ │ ├── config │ │ ├── logback-spring.xml │ │ └── mybatis-config.xml │ │ └── mapper │ │ ├── base │ │ └── BaseOrganizationMapper.xml │ │ ├── official │ │ └── website │ │ │ ├── OfficialWebsiteAboutUsMapper.xml │ │ │ ├── OfficialWebsiteBaseInfoMapper.xml │ │ │ ├── OfficialWebsiteCarouselMapper.xml │ │ │ ├── OfficialWebsiteClassMateMapper.xml │ │ │ ├── OfficialWebsiteContactUsMapper.xml │ │ │ ├── OfficialWebsiteCustomerCaseMapper.xml │ │ │ ├── OfficialWebsiteDigitizationMapper.xml │ │ │ ├── OfficialWebsiteFirstScreenMapper.xml │ │ │ ├── OfficialWebsiteHistoryMapper.xml │ │ │ ├── OfficialWebsiteNewsMapper.xml │ │ │ ├── OfficialWebsiteProductMapper.xml │ │ │ ├── OfficialWebsiteRecruitMapper.xml │ │ │ └── OfficialWebsiteSolutionMapper.xml │ │ └── sys │ │ ├── BaseOrganizationMapper.xml │ │ ├── SysLogMapper.xml │ │ ├── SysMenuMapper.xml │ │ ├── SysRoleMapper.xml │ │ ├── SysRoleMenuMapper.xml │ │ ├── SysUserMapper.xml │ │ ├── SysUserRoleMapper.xml │ │ └── UserMapper.xml │ └── test │ └── java │ └── space │ └── zero │ └── business │ ├── Main.java │ └── Tester.java ├── zero-common ├── pom.xml └── src │ ├── main │ ├── java │ │ └── space │ │ │ └── zero │ │ │ └── common │ │ │ ├── jsonLib │ │ │ ├── annotation │ │ │ │ └── JsonBeanRequestParam.java │ │ │ ├── dataBind │ │ │ │ └── NullableJsonNodeParser.java │ │ │ ├── dateFormat │ │ │ │ └── StandardDateFormat.java │ │ │ ├── mapper │ │ │ │ └── JsonMapper.java │ │ │ ├── module │ │ │ │ └── DateModule.java │ │ │ ├── resolver │ │ │ │ └── JsonBeanArgumentResolver.java │ │ │ └── serialize │ │ │ │ ├── DateDeserializer.java │ │ │ │ └── DateSerializer.java │ │ │ ├── keyGenerator │ │ │ ├── KeyGenerator.java │ │ │ ├── TimeFormatKeyGenerator.java │ │ │ └── TimeHexKeyGenerator.java │ │ │ ├── mail │ │ │ ├── MailContentTypeEnum.java │ │ │ ├── MailEntity.java │ │ │ └── MailSender.java │ │ │ └── utils │ │ │ ├── DateUtils.java │ │ │ ├── FileUploadEnum.java │ │ │ ├── FileUploadUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── HttpUtils.java │ │ │ ├── IpUtils.java │ │ │ ├── MIMEType.java │ │ │ ├── MimeUtils.java │ │ │ ├── PropertiesUtils.java │ │ │ ├── ReflectionUtils.java │ │ │ └── StringUtils.java │ └── resources │ │ └── mail.properties │ └── test │ └── java │ └── space │ └── zero │ └── common │ └── Test.java ├── zero-core ├── pom.xml └── src │ ├── main │ └── java │ │ └── space │ │ └── zero │ │ └── core │ │ ├── constant │ │ └── Constant.java │ │ ├── exception │ │ └── ServiceException.java │ │ ├── mapper │ │ └── Mapper.java │ │ ├── model │ │ └── BaseEntity.java │ │ ├── result │ │ ├── Result.java │ │ ├── ResultCode.java │ │ └── ResultGenerator.java │ │ └── service │ │ ├── AbstractDeleteFlagService.java │ │ ├── AbstractService.java │ │ └── Service.java │ └── test │ ├── java │ ├── CodeGenerator.java │ └── space │ │ └── zero │ │ └── core │ │ └── Test.java │ └── resources │ ├── demo-user.sql │ └── generator │ └── template │ ├── controller-restful.ftl │ ├── controller.ftl │ ├── mapper.ftl │ ├── service-impl.ftl │ └── service.ftl ├── zero-cron ├── pom.xml └── src │ └── main │ └── java │ └── space │ └── zero │ └── cron │ ├── configure │ └── ScheduleConfig.java │ └── task │ └── CronDemo.java └── zero.sql /.gitignore: -------------------------------------------------------------------------------- 1 | *.java.hsp 2 | *.sonarj 3 | *.sw* 4 | .DS_Store 5 | .settings 6 | .springBeans 7 | bin 8 | build.sh 9 | integration-repo 10 | ivy-cache 11 | jxl.log 12 | jmx.log 13 | derby.log 14 | spring-test/test-output/ 15 | .gradle 16 | argfile* 17 | activemq-data/ 18 | 19 | classes/ 20 | /build 21 | buildSrc/build 22 | /spring-*/build 23 | /src/asciidoc/build 24 | target/ 25 | 26 | # Eclipse artifacts, including WTP generated manifests 27 | .classpath 28 | .project 29 | spring-*/src/main/java/META-INF/MANIFEST.MF 30 | 31 | # IDEA artifacts and output dirs 32 | *.iml 33 | *.ipr 34 | *.iws 35 | .idea 36 | out 37 | test-output 38 | atlassian-ide-plugin.xml 39 | .gradletasknamecache 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 基于Spring Boot + Spring Security开发信息管理平台 2 | ## 一. 项目简介 3 | ### 1. 项目简介 4 |     本项目采用**Restful API** 设计,即前后端分离,这也是当前比较流行的做法,在项目开发过程中,事先约定好API接口以及对应数据格式,使前后端之间可以最大限度减少对方的"依赖",提高开发效率. 5 |     后端是基于**Spring Boot**框架搭建的信息管理系统,并整合**Spring Security**进行授权认证管理,数据访问层则采用**Mybatis**进行持久化,该项目使用**maven**进行项目工程管理. 6 |     前端方面采用的**vue.js** + **Element UI**框架,由于本人主要做后端开发,在前端方面能力较渣,所以前端直接使用了由[花裤衩][1]开发的模板,在此基础上结合自己项目的业务进行修改,这位大大还写了一个非常详细的[文档][2],非常值得学习. 7 | 8 | ## 二. 环境 9 | ###1. 开发工具 10 | * 操作系统: Deepin 11 | * IDE: IntelliJ IDEA / WebStorm 12 | > **Deepin** 深度操作系统是基于Ubuntu开发一款国产Linux操作系统,底层是Linux系统,同时基于DeepinWine技术,可以运行大量的Windows平台软件,像微信、QQ、TIM等都可以运行,这是其他Linux操作系统所没有的,界面也非常好看,用起来还是很顺心的,本项目是在Deepin系统上开发的. 13 | > **IntelliJ IDEA** 个人角色比eclipse好用,比较坑的是这东西很占内存 14 | 15 | ###2. 开发环境 16 | * Java 17 | * Mysql 18 | * maven 19 | * node.js 20 | * redis 21 | 22 | 23 | [1]: https://github.com/PanJiaChen/vue-element-admin 24 | [2]: https://panjiachen.github.io/vue-element-admin-site/#/ 25 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | space.non-zero 8 | non-zero 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | 13 | 1.8 14 | 1.8 15 | UTF-8 16 | 17 | 18 | UTF-8 19 | UTF-8 20 | 1.8 21 | 22 | space.zero.business.ZeroApplication 23 | 24 | 2.8.6 25 | 3.3.2 26 | 2.4 27 | 1.9 28 | 1.3.1 29 | 1.9.1 30 | 2.2 31 | 3.3 32 | 1.1 33 | 4.5 34 | 21.0 35 | 1.7.22 36 | 1.8.2 37 | 4.3.1.Final 38 | 1.4.7 39 | 40 | 1.5.1.RELEASE 41 | 42 | 43 | 44 | 45 | zero-core 46 | zero-common 47 | zero-business 48 | zero-cron 49 | 50 | 51 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/ZeroApplication.java: -------------------------------------------------------------------------------- 1 | package space.zero.business; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.scheduling.annotation.EnableScheduling; 7 | import org.springframework.web.cors.CorsConfiguration; 8 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 9 | import org.springframework.web.filter.CorsFilter; 10 | 11 | @SpringBootApplication 12 | //@EnableScheduling 13 | public class ZeroApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(ZeroApplication.class, args); 16 | } 17 | 18 | private CorsConfiguration buildConfig() { 19 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 20 | corsConfiguration.addAllowedOrigin("*"); 21 | corsConfiguration.addAllowedHeader("*"); 22 | corsConfiguration.addAllowedMethod("*"); 23 | return corsConfiguration; 24 | } 25 | 26 | /** 27 | * 跨域过滤器 28 | * @return 29 | */ 30 | @Bean 31 | public CorsFilter corsFilter() { 32 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 33 | source.registerCorsConfiguration("/**", buildConfig()); // 4 34 | return new CorsFilter(source); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/DruidConfigurer.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import com.alibaba.druid.support.http.StatViewServlet; 4 | import com.alibaba.druid.support.http.WebStatFilter; 5 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 6 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Configuration 11 | public class DruidConfigurer { 12 | @Bean 13 | public ServletRegistrationBean statViewServlet(){ 14 | ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); 15 | servletRegistrationBean.addInitParameter("allow", "127.0.0.1"); 16 | // servletRegistrationBean.addInitParameter("deny", "192.168.0.1"); 17 | // servletRegistrationBean.addInitParameter("loginUsername", "druid"); 18 | // servletRegistrationBean.addInitParameter("loginPassword", "123456"); 19 | servletRegistrationBean.addInitParameter("resetEnable", "false"); 20 | return servletRegistrationBean; 21 | } 22 | 23 | @Bean 24 | public FilterRegistrationBean statFilter(){ 25 | FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); 26 | filterRegistrationBean.addUrlPatterns("/*"); 27 | filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.jpeg,*.css,*.ico,*.vue,/druid/*"); 28 | return filterRegistrationBean; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/MybatisConfigurer.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import org.apache.ibatis.plugin.Interceptor; 5 | import org.apache.ibatis.session.SqlSessionFactory; 6 | import org.mybatis.spring.SqlSessionFactoryBean; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.core.io.ClassPathResource; 10 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 11 | import org.springframework.core.io.support.ResourcePatternResolver; 12 | import space.zero.business.configure.override.PackagesSqlSessionFactoryBean; 13 | import tk.mybatis.spring.mapper.MapperScannerConfigurer; 14 | 15 | import javax.sql.DataSource; 16 | import java.util.Properties; 17 | 18 | import static space.zero.core.constant.Constant.*; 19 | 20 | 21 | /** 22 | * Mybatis & Mapper & PageHelper 配置 23 | */ 24 | @Configuration 25 | public class MybatisConfigurer { 26 | 27 | @Bean 28 | public SqlSessionFactory sqlSessionFactoryBean(DataSource dataSource) throws Exception { 29 | //use log4j 30 | org.apache.ibatis.logging.LogFactory.useLog4JLogging(); 31 | //此处使用重写的sqlSessionFactoryBean 32 | SqlSessionFactoryBean factory = new PackagesSqlSessionFactoryBean(); 33 | factory.setDataSource(dataSource); 34 | //使用通配符扫描space.zero.business下的model 35 | factory.setTypeAliasesPackage("space.zero.business.**.model"); 36 | 37 | //配置分页插件,详情请查阅官方文档 38 | //Java配置方式,也可在xml文件中配置 39 | PageHelper pageHelper = new PageHelper(); 40 | Properties properties = new Properties(); 41 | properties.setProperty("pageSizeZero", "true");//分页尺寸为0时查询所有纪录不再执行分页 42 | properties.setProperty("reasonable", "true");//页码<=0 查询第一页,页码>=总页数查询最后一页 43 | properties.setProperty("supportMethodsArguments", "true");//支持通过 Mapper 接口参数来传递分页参数 44 | pageHelper.setProperties(properties); 45 | 46 | //添加插件 47 | factory.setPlugins(new Interceptor[]{pageHelper}); 48 | 49 | //添加XML目录 50 | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); 51 | //此时添加xml文件配置方式 52 | factory.setMapperLocations(resolver.getResources("classpath:mapper/*.xml")); 53 | factory.setConfigLocation(new ClassPathResource("config/mybatis-config.xml")); 54 | return factory.getObject(); 55 | } 56 | 57 | @Bean 58 | public MapperScannerConfigurer mapperScannerConfigurer() { 59 | MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); 60 | mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactoryBean"); 61 | mapperScannerConfigurer.setBasePackage("space.zero.business.**.dao"); 62 | 63 | //配置通用Mapper,详情请查阅官方文档 64 | Properties properties = new Properties(); 65 | properties.setProperty("mappers", MAPPER_INTERFACE_REFERENCE); 66 | properties.setProperty("notEmpty", "false");//insert、update是否判断字符串类型!='' 即 test="str != null"表达式内是否追加 and str != '' 67 | properties.setProperty("IDENTITY", "MYSQL"); 68 | properties.setProperty("ORDER","BEFORE"); 69 | mapperScannerConfigurer.setProperties(properties); 70 | 71 | return mapperScannerConfigurer; 72 | } 73 | 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/SpringContextCommon.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.annotation.SchedulingConfigurer; 6 | import space.zero.common.keyGenerator.KeyGenerator; 7 | import space.zero.common.keyGenerator.TimeFormatKeyGenerator; 8 | import space.zero.common.mail.MailSender; 9 | import space.zero.cron.configure.ScheduleConfig; 10 | import space.zero.cron.task.CronDemo; 11 | 12 | /** 13 | * Created by PG_shen 14 | * Date : 3/14/18 15 | * Time : 8:23 PM 16 | * 该配置类主要用于将其他模块的引入Spring boot 扫描范围,从而注入到spring boot的bean管理中 17 | * 除普通bean外,配置类也可以引入 18 | */ 19 | @Configuration 20 | public class SpringContextCommon { 21 | 22 | @Bean 23 | public KeyGenerator stringKeyGenerator(){ 24 | return new TimeFormatKeyGenerator(); 25 | } 26 | 27 | @Bean 28 | public MailSender mailSender(){ 29 | return new MailSender(); 30 | } 31 | 32 | // @Bean 33 | // public CronDemo cronDemo(){ 34 | // return new CronDemo(); 35 | // } 36 | // 37 | // @Bean 38 | // public ScheduleConfig scheduleConfig(){ 39 | // return new ScheduleConfig(); 40 | // } 41 | } 42 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/SpringContextSpringSession.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import org.springframework.context.EnvironmentAware; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.core.env.Environment; 7 | import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; 8 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 9 | import org.springframework.session.web.http.HeaderHttpSessionStrategy; 10 | import org.springframework.session.web.http.HttpSessionStrategy; 11 | 12 | /** 13 | * Created by PG_shen 14 | * Date : 3/9/18 15 | * Time : 10:25 AM 16 | * 启用RedisHttpSession功能 17 | */ 18 | @Configuration 19 | @EnableRedisHttpSession(maxInactiveIntervalInSeconds=1800,redisNamespace="fire-safety") 20 | public class SpringContextSpringSession implements EnvironmentAware { 21 | 22 | private Environment env; 23 | 24 | @Bean 25 | public LettuceConnectionFactory connectionFactory() { 26 | return new LettuceConnectionFactory(); 27 | } 28 | 29 | @Bean 30 | public HttpSessionStrategy httpSessionStrategy() { 31 | HeaderHttpSessionStrategy headerHttpSessionStrategy = new HeaderHttpSessionStrategy(); // <3> 32 | headerHttpSessionStrategy.setHeaderName(env.getProperty("app.session.headerTokenName")); 33 | return headerHttpSessionStrategy; 34 | } 35 | 36 | @Override 37 | public void setEnvironment(Environment environment) { 38 | this.env=environment; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/ZeroSecurityInitializer.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/8/18 8 | * Time : 5:06 PM 9 | * 主要用于在没有使用spring-mvc情况下,注册过滤器,传递SecurityConfig类到父类中,确保配置信息被加在 10 | */ 11 | public class ZeroSecurityInitializer extends AbstractSecurityWebApplicationInitializer { 12 | 13 | /** 14 | * 传递SecurityConfig类到父类中 15 | */ 16 | public ZeroSecurityInitializer() { 17 | super(SpringContextSecurity.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/ZeroSessionInitializer.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure; 2 | 3 | import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/9/18 8 | * Time : 10:24 AM 9 | */ 10 | public class ZeroSessionInitializer extends AbstractHttpSessionApplicationInitializer { 11 | 12 | public ZeroSessionInitializer() { 13 | super(SpringContextSpringSession.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/configure/override/PackagesSqlSessionFactoryBean.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.configure.override; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.mybatis.spring.SqlSessionFactoryBean; 5 | import org.springframework.core.io.Resource; 6 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 7 | import org.springframework.core.io.support.ResourcePatternResolver; 8 | import org.springframework.core.type.classreading.CachingMetadataReaderFactory; 9 | import org.springframework.core.type.classreading.MetadataReader; 10 | import org.springframework.core.type.classreading.MetadataReaderFactory; 11 | import org.springframework.util.ClassUtils; 12 | 13 | import java.io.IOException; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 重写SqlSessionFactoryBean中的setTypeAliasesPackage方法,使typeAliasesPackag支持通配符扫描model 19 | */ 20 | public class PackagesSqlSessionFactoryBean extends SqlSessionFactoryBean { 21 | 22 | static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; 23 | 24 | @Override 25 | public void setTypeAliasesPackage(String typeAliasesPackage) { 26 | ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); 27 | MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); 28 | typeAliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + 29 | ClassUtils.convertClassNameToResourcePath(typeAliasesPackage) + "/" + DEFAULT_RESOURCE_PATTERN; 30 | 31 | //将加载多个绝对匹配的所有Resource 32 | //将首先通过ClassLoader.getResource("META-INF")加载非模式路径部分 33 | //然后进行遍历模式匹配 34 | try { 35 | List result = new ArrayList(); 36 | Resource[] resources = resolver.getResources(typeAliasesPackage); 37 | if(resources != null && resources.length > 0){ 38 | MetadataReader metadataReader = null; 39 | for(Resource resource : resources){ 40 | if(resource.isReadable()){ 41 | metadataReader = metadataReaderFactory.getMetadataReader(resource); 42 | try { 43 | result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName()); 44 | } catch (ClassNotFoundException e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | } 49 | } 50 | if(result.size() > 0) { 51 | super.setTypeAliasesPackage(StringUtils.join(result.toArray(), ",")); 52 | }else{ 53 | // logger.warn("参数typeAliasesPackage:"+typeAliasesPackage+",未找到任何包"); 54 | } 55 | //logger.info("d"); 56 | } catch (IOException e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/dao/BaseOrganizationMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.base.model.BaseOrganization; 5 | import space.zero.core.mapper.Mapper; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/17. 12 | */ 13 | public interface BaseOrganizationMapper extends Mapper { 14 | @Select("select * from base_organization where is_delete = 0 and parent_id = 0") // 公司节点的parent_id为0 15 | List findAllOrganization(); 16 | 17 | @Select("select * from base_organization where is_delete=0 and parent_id=#{parentID}") 18 | List findByParentID(String parentId); 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/dao/SysLogMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.dao; 2 | 3 | import space.zero.business.module.base.model.SysLog; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/08/19. 9 | */ 10 | public interface SysLogMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/param/response/BaseOrganizationTree.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.param.response; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/17/18 8 | * Time : 5:09 PM 9 | */ 10 | public class BaseOrganizationTree { 11 | 12 | private String id; 13 | 14 | private String parentId; 15 | 16 | private String name; 17 | 18 | private String email; 19 | 20 | private String remark; 21 | 22 | private String postCode; 23 | 24 | private String type; 25 | 26 | private String tel; 27 | 28 | private String description; 29 | 30 | private List children; 31 | 32 | public BaseOrganizationTree(){} 33 | 34 | public BaseOrganizationTree(String id, String parentId, String name, String email, String remark, String postCode, String type, String tel, String description) { 35 | this.id = id; 36 | this.parentId = parentId; 37 | this.name = name; 38 | this.email = email; 39 | this.remark = remark; 40 | this.postCode = postCode; 41 | this.type = type; 42 | this.tel = tel; 43 | this.description = description; 44 | } 45 | 46 | public String getId() { 47 | return id; 48 | } 49 | 50 | public void setId(String id) { 51 | this.id = id; 52 | } 53 | 54 | public String getParentId() { 55 | return parentId; 56 | } 57 | 58 | public void setParentId(String parentId) { 59 | this.parentId = parentId; 60 | } 61 | 62 | public String getName() { 63 | return name; 64 | } 65 | 66 | public void setName(String name) { 67 | this.name = name; 68 | } 69 | 70 | public String getEmail() { 71 | return email; 72 | } 73 | 74 | public void setEmail(String email) { 75 | this.email = email; 76 | } 77 | 78 | public String getRemark() { 79 | return remark; 80 | } 81 | 82 | public void setRemark(String remark) { 83 | this.remark = remark; 84 | } 85 | 86 | public String getPostCode() { 87 | return postCode; 88 | } 89 | 90 | public void setPostCode(String postCode) { 91 | this.postCode = postCode; 92 | } 93 | 94 | public String getType() { 95 | return type; 96 | } 97 | 98 | public void setType(String type) { 99 | this.type = type; 100 | } 101 | 102 | public String getTel() { 103 | return tel; 104 | } 105 | 106 | public void setTel(String tel) { 107 | this.tel = tel; 108 | } 109 | 110 | public String getDescription() { 111 | return description; 112 | } 113 | 114 | public void setDescription(String description) { 115 | this.description = description; 116 | } 117 | 118 | public List getChildren() { 119 | return children; 120 | } 121 | 122 | public void setChildren(List children) { 123 | this.children = children; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/service/BaseOrganizationService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.service; 2 | 3 | import space.zero.business.module.base.model.BaseOrganization; 4 | import space.zero.business.module.base.param.response.BaseOrganizationTree; 5 | import space.zero.core.service.Service; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/17. 12 | */ 13 | public interface BaseOrganizationService extends Service { 14 | BaseOrganizationTree getOrgTree(); 15 | List getChildren(String parentId); 16 | } 17 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/service/SysLogService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.service; 2 | 3 | import space.zero.business.module.base.model.SysLog; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/08/19. 9 | */ 10 | public interface SysLogService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/service/impl/SysLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import space.zero.business.module.base.dao.SysLogMapper; 5 | import space.zero.business.module.base.model.SysLog; 6 | import space.zero.business.module.base.service.SysLogService; 7 | import space.zero.common.keyGenerator.KeyGenerator; 8 | import space.zero.common.utils.StringUtils; 9 | import space.zero.core.service.AbstractDeleteFlagService; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.sql.Timestamp; 15 | import java.util.Date; 16 | 17 | 18 | /** 19 | * Created by PG_shen on 2018/08/19. 20 | */ 21 | @Service 22 | @Transactional 23 | public class SysLogServiceImpl extends AbstractDeleteFlagService implements SysLogService { 24 | @Resource 25 | private SysLogMapper sysLogMapper; 26 | 27 | @Autowired 28 | private KeyGenerator keyGenerator; 29 | 30 | @Override 31 | public boolean preInsert(SysLog data) { 32 | if (StringUtils.isBlank(data.getId())) { 33 | data.setId(keyGenerator.getNext()); 34 | } 35 | data.setCreatedTime(new Timestamp(new Date().getTime())); 36 | return super.preInsert(data); 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/web/BaseOrganizationController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.web; 2 | 3 | import space.zero.business.module.base.param.response.BaseOrganizationTree; 4 | import space.zero.business.module.sys.param.request.CondRequest; 5 | import space.zero.core.result.Result; 6 | import space.zero.core.result.ResultGenerator; 7 | import space.zero.business.module.base.model.BaseOrganization; 8 | import space.zero.business.module.base.service.BaseOrganizationService; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by PG_shen on 2018/03/17. 18 | */ 19 | @RestController 20 | @RequestMapping("/base/org") 21 | public class BaseOrganizationController { 22 | @Resource 23 | private BaseOrganizationService baseOrganizationService; 24 | 25 | @PostMapping 26 | public Result add(@RequestBody BaseOrganization baseOrganization) { 27 | if (null != baseOrganization){ 28 | if (baseOrganization.getParentId().equals("")){ 29 | baseOrganization.setParentId("0"); 30 | } 31 | BaseOrganization tmp = baseOrganizationService.save(baseOrganization); 32 | return ResultGenerator.genSuccessResult("operation succeeded"); 33 | }else { 34 | return ResultGenerator.genSuccessResult("operation fail"); 35 | } 36 | } 37 | 38 | @DeleteMapping("/{id}") 39 | public Result delete(@PathVariable String id) { 40 | baseOrganizationService.deleteById(id); 41 | return ResultGenerator.genSuccessResult(); 42 | } 43 | 44 | @PutMapping 45 | public Result update(@RequestBody BaseOrganization baseOrganization) { 46 | BaseOrganization tmp = baseOrganizationService.update(baseOrganization); 47 | return ResultGenerator.genSuccessResult(tmp); 48 | } 49 | 50 | @GetMapping("/{id}") 51 | public Result detail(@PathVariable String id) { 52 | BaseOrganization baseOrganization = baseOrganizationService.findById(id); 53 | return ResultGenerator.genSuccessResult(baseOrganization); 54 | } 55 | 56 | @PostMapping("list") 57 | public Result list(@RequestBody CondRequest condRequest) { 58 | PageHelper.startPage(condRequest.getPage(), condRequest.getSize(), condRequest.getOrder()); 59 | List list = baseOrganizationService.findBy(condRequest.getCond()); 60 | PageInfo pageInfo = new PageInfo(list); 61 | pageInfo.setOrderBy(condRequest.getOrder()); 62 | return ResultGenerator.genSuccessResult(pageInfo); 63 | } 64 | 65 | @PostMapping("tree") 66 | public Result getOrgTree(){ 67 | BaseOrganizationTree organizationTree = baseOrganizationService.getOrgTree(); 68 | return ResultGenerator.genSuccessResult(organizationTree.getChildren()); 69 | } 70 | 71 | @GetMapping("/page") 72 | public Result page(){ 73 | return ResultGenerator.genSuccessResult(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/base/web/SysLogController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.base.web; 2 | 3 | import space.zero.business.module.base.model.SysLog; 4 | import space.zero.core.result.Result; 5 | import space.zero.core.result.ResultGenerator; 6 | import space.zero.business.module.base.service.SysLogService; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by PG_shen on 2018/08/19. 16 | */ 17 | @RestController 18 | @RequestMapping("/sys/log") 19 | public class SysLogController { 20 | @Resource 21 | private SysLogService sysLogService; 22 | 23 | @PostMapping 24 | public Result add(@RequestBody SysLog sysLog) { 25 | SysLog tmp = sysLogService.save(sysLog); 26 | return ResultGenerator.genSuccessResult(tmp); 27 | } 28 | 29 | @DeleteMapping("/{id}") 30 | public Result delete(@PathVariable String id) { 31 | sysLogService.deleteById(id); 32 | return ResultGenerator.genSuccessResult(); 33 | } 34 | 35 | @PutMapping 36 | public Result update(@RequestBody SysLog sysLog) { 37 | SysLog tmp = sysLogService.update(sysLog); 38 | return ResultGenerator.genSuccessResult(tmp); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public Result detail(@PathVariable String id) { 43 | SysLog sysLog = sysLogService.findById(id); 44 | return ResultGenerator.genSuccessResult(sysLog); 45 | } 46 | 47 | @GetMapping 48 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 49 | PageHelper.startPage(page, size); 50 | List list = sysLogService.findAll(); 51 | PageInfo pageInfo = new PageInfo(list); 52 | return ResultGenerator.genSuccessResult(pageInfo); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/common/web/DashboardController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.common.web; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import space.zero.core.result.Result; 7 | import space.zero.core.result.ResultGenerator; 8 | 9 | /** 10 | * Created by PG_shen 11 | * Date : 3/22/18 12 | * Time : 11:18 AM 13 | */ 14 | @RestController 15 | @RequestMapping("/dashboard") 16 | public class DashboardController { 17 | @GetMapping("/page") 18 | public Result page(){ 19 | return ResultGenerator.genSuccessResult(); 20 | } 21 | } -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/common/web/DocumentationController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.common.web; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import space.zero.core.result.Result; 7 | import space.zero.core.result.ResultGenerator; 8 | 9 | /** 10 | * Created by PG_shen 11 | * Date : 3/22/18 12 | * Time : 11:18 AM 13 | */ 14 | @RestController 15 | @RequestMapping("/documentation") 16 | public class DocumentationController { 17 | @GetMapping("/page") 18 | public Result page(){ 19 | return ResultGenerator.genSuccessResult(); 20 | } 21 | } -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/common/web/IconController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.common.web; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import space.zero.core.result.Result; 7 | import space.zero.core.result.ResultGenerator; 8 | 9 | /** 10 | * Created by PG_shen 11 | * Date : 3/22/18 12 | * Time : 11:19 AM 13 | */ 14 | @RestController 15 | @RequestMapping("/icons") 16 | public class IconController { 17 | @GetMapping("/page") 18 | public Result page(){ 19 | return ResultGenerator.genSuccessResult(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/common/web/IndexController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.common.web; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | /** 7 | * Created by IntelliJ IDEA 8 | * User: pipix 9 | * Date: 10/12/18 10 | * TIME: 2:25 PM 11 | */ 12 | @Controller 13 | public class IndexController { 14 | // @GetMapping({"/", "/index", "/index.html", "/login"}) 15 | // public String index(){ 16 | // return "index"; 17 | // } 18 | } 19 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/common/web/LogoutController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.common.web; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import space.zero.core.result.Result; 9 | import space.zero.core.result.ResultGenerator; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | /** 15 | * Created by PG_shen 16 | * Date : 3/22/18 17 | * Time : 2:34 PM 18 | */ 19 | @RestController 20 | public class LogoutController { 21 | // @GetMapping("/logout") 22 | // public Result logout (HttpServletRequest request, HttpServletResponse response) { 23 | // Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 24 | // if (auth != null){ 25 | // new SecurityContextLogoutHandler().logout(request, response, auth); 26 | // } 27 | // return ResultGenerator.genSuccessResult(); 28 | // } 29 | } 30 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/base/WebsiteDeleteFlagService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.base; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | import space.zero.business.module.sys.model.SysUserDetails; 6 | import space.zero.common.keyGenerator.KeyGenerator; 7 | import space.zero.core.service.AbstractDeleteFlagService; 8 | 9 | import java.sql.Timestamp; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by IntelliJ IDEA 14 | * User: pipix 15 | * Date: 10/4/18 16 | * TIME: 4:19 PM 17 | */ 18 | public abstract class WebsiteDeleteFlagService extends AbstractDeleteFlagService { 19 | 20 | @Autowired 21 | private KeyGenerator keyGenerator; 22 | 23 | @Override 24 | public boolean preInsert(T data) { 25 | data.setId(keyGenerator.getNext()); 26 | SysUserDetails sysUserDetails = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 27 | data.setUpdateUser(sysUserDetails.getUser().getName()); 28 | data.setCreatedTime(new Timestamp(new Date().getTime())); 29 | return super.preInsert(data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/base/WebsiteEntity.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.base; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.codehaus.jackson.map.Serializers; 5 | import space.zero.core.model.BaseEntity; 6 | 7 | import javax.persistence.Transient; 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by IntelliJ IDEA 12 | * User: pipix 13 | * Date: 10/4/18 14 | * TIME: 4:32 PM 15 | */ 16 | public class WebsiteEntity extends BaseEntity { 17 | @Transient 18 | @JsonIgnore 19 | private String id; 20 | @Transient 21 | @JsonIgnore 22 | private Date createdTime; 23 | @Transient 24 | @JsonIgnore 25 | private String updateUser; 26 | 27 | @Override 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | @Override 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | public Date getCreatedTime() { 38 | return createdTime; 39 | } 40 | 41 | public void setCreatedTime(Date createdTime) { 42 | this.createdTime = createdTime; 43 | } 44 | 45 | public String getUpdateUser() { 46 | return updateUser; 47 | } 48 | 49 | public void setUpdateUser(String updateUser) { 50 | this.updateUser = updateUser; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteAboutUsMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteAboutUs; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteAboutUsMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteBaseInfoMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import org.apache.ibatis.annotations.Update; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteBaseInfo; 6 | import space.zero.core.mapper.Mapper; 7 | 8 | 9 | /** 10 | * Created by PG_shen on 2018/09/26. 11 | */ 12 | public interface OfficialWebsiteBaseInfoMapper extends Mapper { 13 | @Select("select * from official_website_base_info where is_enable = 1 order by update_time desc limit 1") 14 | OfficialWebsiteBaseInfo fetchInfo(); 15 | 16 | @Update("update official_website_base_info set is_enable = 0 where is_enable=1") 17 | void setAllDisable(); 18 | } 19 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteCarouselMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteCarousel; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteCarouselMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteClassMateMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteClassMate; 5 | import space.zero.business.module.official.website.param.response.ClazzListResponse; 6 | import space.zero.core.mapper.Mapper; 7 | 8 | import java.util.List; 9 | 10 | 11 | /** 12 | * Created by PG_shen on 2018/10/04. 13 | */ 14 | public interface OfficialWebsiteClassMateMapper extends Mapper { 15 | @Select("select id, clazz_value from official_website_class_mate where is_delete=0 and clazz_name = #{clazzName}") 16 | List findClazz(String clazzName); 17 | } 18 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteContactUsMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteContactUs; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteContactUsMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteCustomerCaseMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteCustomerCase; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteCustomerCaseMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteDigitizationMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteDigitization; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteDigitizationMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteFirstScreenMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteFirstScreen; 5 | import space.zero.core.mapper.Mapper; 6 | 7 | 8 | /** 9 | * Created by PG_shen on 2018/09/26. 10 | */ 11 | public interface OfficialWebsiteFirstScreenMapper extends Mapper { 12 | @Select("select * from official_website_first_screen where is_enable = 1 and is_delete = 0 and first_screen_class = #{firstScreenClazz} order by update_time desc limit 1") 13 | OfficialWebsiteFirstScreen fetchFirstScreen(String firstScreenClazz); 14 | } 15 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteHistoryMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteHistory; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteHistoryMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteNewsMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.apache.ibatis.annotations.Select; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteNews; 6 | import space.zero.core.mapper.Mapper; 7 | 8 | 9 | /** 10 | * Created by PG_shen on 2018/09/26. 11 | */ 12 | public interface OfficialWebsiteNewsMapper extends Mapper { 13 | @Select("select * from official_website_news where release_time > (select release_time from official_website_news where id = #{id}) and news_class = #{newsClass} and IS_DELETE=0 and status=1 order by release_time limit 1") 14 | OfficialWebsiteNews getNextNews(@Param("id")String id, @Param("newsClass")String newsClass); 15 | 16 | 17 | @Select("select * from official_website_news where release_time < (select release_time from official_website_news where id = #{id}) and news_class = #{newsClass} and IS_DELETE=0 and status=1 order by release_time desc limit 1") 18 | OfficialWebsiteNews getPreviousNews(@Param("id")String id, @Param("newsClass")String newsClass); 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteProductMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteProduct; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteProductMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteRecruitMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteRecruit; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteRecruitMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/dao/OfficialWebsiteSolutionMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.dao; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteSolution; 4 | import space.zero.core.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteSolutionMapper extends Mapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/param/request/ClazzListRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.param.request; 2 | 3 | /** 4 | * Created by IntelliJ IDEA 5 | * User: pipix 6 | * Date: 10/5/18 7 | * TIME: 1:17 AM 8 | */ 9 | public class ClazzListRequest { 10 | private String clazzName; 11 | 12 | public String getClazzName() { 13 | return clazzName; 14 | } 15 | 16 | public void setClazzName(String clazzName) { 17 | this.clazzName = clazzName; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/param/request/CondRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.param.request; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by IntelliJ IDEA 7 | * User: pipix 8 | * Date: 10/3/18 9 | * TIME: 10:59 PM 10 | */ 11 | public class CondRequest { 12 | //页码 13 | private Integer page; 14 | //页大小 15 | private Integer size; 16 | //排序字段 17 | private String order; 18 | private Map cond; 19 | 20 | public Integer getPage() { 21 | return page; 22 | } 23 | 24 | public void setPage(Integer page) { 25 | this.page = page; 26 | } 27 | 28 | public Integer getSize() { 29 | return size; 30 | } 31 | 32 | public void setSize(Integer size) { 33 | this.size = size; 34 | } 35 | 36 | public String getOrder() { 37 | return order; 38 | } 39 | 40 | public void setOrder(String order) { 41 | this.order = order; 42 | } 43 | 44 | public Map getCond() { 45 | return cond; 46 | } 47 | 48 | public void setCond(Map cond) { 49 | this.cond = cond; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/param/response/ClazzListResponse.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.param.response; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by IntelliJ IDEA 9 | * User: pipix 10 | * Date: 10/5/18 11 | * TIME: 1:03 AM 12 | */ 13 | public class ClazzListResponse implements Serializable { 14 | @JsonProperty("value") 15 | private String id; 16 | 17 | @JsonProperty("label") 18 | private String clazzValue; 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | public String getClazzValue() { 29 | return clazzValue; 30 | } 31 | 32 | public void setClazzValue(String clazzValue) { 33 | this.clazzValue = clazzValue; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/param/response/NewsDetailResponse.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.param.response; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteNews; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Created by IntelliJ IDEA 10 | * User: pipix 11 | * Date: 10/17/18 12 | * TIME: 6:14 PM 13 | */ 14 | public class NewsDetailResponse implements Serializable { 15 | @JsonProperty("news") 16 | private OfficialWebsiteNews news; 17 | 18 | // 下一篇文章 19 | @JsonProperty("next") 20 | private OfficialWebsiteNews next; 21 | 22 | // 上一篇文章 23 | @JsonProperty("previous") 24 | private OfficialWebsiteNews previous; 25 | 26 | public OfficialWebsiteNews getNews() { 27 | return news; 28 | } 29 | 30 | public void setNews(OfficialWebsiteNews news) { 31 | this.news = news; 32 | } 33 | 34 | public OfficialWebsiteNews getNext() { 35 | return next; 36 | } 37 | 38 | public void setNext(OfficialWebsiteNews next) { 39 | this.next = next; 40 | } 41 | 42 | public OfficialWebsiteNews getPrevious() { 43 | return previous; 44 | } 45 | 46 | public void setPrevious(OfficialWebsiteNews previous) { 47 | this.previous = previous; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteAboutUsService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteAboutUs; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteAboutUsService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteBaseInfoService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteBaseInfo; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteBaseInfoService extends Service { 11 | OfficialWebsiteBaseInfo fetchInfo(); 12 | 13 | OfficialWebsiteBaseInfo updateInfo(OfficialWebsiteBaseInfo baseInfo); 14 | } 15 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteCarouselService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteCarousel; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteCarouselService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteClassMateService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteClassMate; 4 | import space.zero.business.module.official.website.param.response.ClazzListResponse; 5 | import space.zero.core.service.Service; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/10/04. 12 | */ 13 | public interface OfficialWebsiteClassMateService extends Service { 14 | List findClazz(String clazzName); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteContactUsService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteContactUs; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteContactUsService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteCustomerCaseService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteCustomerCase; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteCustomerCaseService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteDigitizationService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteDigitization; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteDigitizationService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteFirstScreenService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteFirstScreen; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteFirstScreenService extends Service { 11 | OfficialWebsiteFirstScreen fetchFirstScreen(String clazz); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteHistoryService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteHistory; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteHistoryService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteNewsService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteNews; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteNewsService extends Service { 11 | 12 | OfficialWebsiteNews getNextNews(String id, String newsClazz); 13 | 14 | OfficialWebsiteNews getPreviousNews(String id, String newsClazz); 15 | } 16 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteProductService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteProduct; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteProductService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteRecruitService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteRecruit; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteRecruitService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/OfficialWebsiteSolutionService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service; 2 | 3 | import space.zero.business.module.official.website.model.OfficialWebsiteSolution; 4 | import space.zero.core.service.Service; 5 | 6 | 7 | /** 8 | * Created by PG_shen on 2018/09/26. 9 | */ 10 | public interface OfficialWebsiteSolutionService extends Service { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteAboutUsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteAboutUsMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteAboutUs; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteAboutUsService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteAboutUsServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteAboutUsService { 19 | @Resource 20 | private OfficialWebsiteAboutUsMapper officialWebsiteAboutUsMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteBaseInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 5 | import space.zero.business.module.official.website.dao.OfficialWebsiteBaseInfoMapper; 6 | import space.zero.business.module.official.website.model.OfficialWebsiteBaseInfo; 7 | import space.zero.business.module.official.website.service.OfficialWebsiteBaseInfoService; 8 | import space.zero.common.keyGenerator.KeyGenerator; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import javax.annotation.Resource; 13 | import java.sql.Timestamp; 14 | import java.util.Date; 15 | 16 | 17 | /** 18 | * Created by PG_shen on 2018/09/26. 19 | */ 20 | @Service 21 | @Transactional 22 | public class OfficialWebsiteBaseInfoServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteBaseInfoService { 23 | @Resource 24 | private OfficialWebsiteBaseInfoMapper officialWebsiteBaseInfoMapper; 25 | 26 | @Autowired 27 | private KeyGenerator keyGenerator; 28 | 29 | 30 | @Override 31 | public OfficialWebsiteBaseInfo fetchInfo() { 32 | return officialWebsiteBaseInfoMapper.fetchInfo(); 33 | } 34 | 35 | @Override 36 | public OfficialWebsiteBaseInfo updateInfo(OfficialWebsiteBaseInfo baseInfo) { 37 | officialWebsiteBaseInfoMapper.setAllDisable(); 38 | return super.save(baseInfo); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteCarouselServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteCarousel; 5 | import space.zero.business.module.official.website.service.OfficialWebsiteCarouselService; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | 10 | 11 | /** 12 | * Created by PG_shen on 2018/09/26. 13 | */ 14 | @Service 15 | @Transactional 16 | public class OfficialWebsiteCarouselServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteCarouselService { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteClassMateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteClassMateMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteClassMate; 6 | import space.zero.business.module.official.website.param.response.ClazzListResponse; 7 | import space.zero.business.module.official.website.service.OfficialWebsiteClassMateService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * Created by PG_shen on 2018/10/04. 17 | */ 18 | @Service 19 | @Transactional 20 | public class OfficialWebsiteClassMateServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteClassMateService { 21 | @Resource 22 | private OfficialWebsiteClassMateMapper officialWebsiteClassMateMapper; 23 | 24 | @Override 25 | public List findClazz(String clazzName) { 26 | return officialWebsiteClassMateMapper.findClazz(clazzName); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteContactUsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteContactUsMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteContactUs; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteContactUsService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteContactUsServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteContactUsService { 19 | @Resource 20 | private OfficialWebsiteContactUsMapper officialWebsiteContactUsMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteCustomerCaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteCustomerCaseMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteCustomerCase; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteCustomerCaseService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteCustomerCaseServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteCustomerCaseService { 19 | @Resource 20 | private OfficialWebsiteCustomerCaseMapper officialWebsiteCustomerCaseMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteDigitizationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.dao.OfficialWebsiteDigitizationMapper; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteDigitization; 5 | import space.zero.business.module.official.website.service.OfficialWebsiteDigitizationService; 6 | import space.zero.core.service.AbstractDeleteFlagService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteDigitizationServiceImpl extends AbstractDeleteFlagService implements OfficialWebsiteDigitizationService { 19 | @Resource 20 | private OfficialWebsiteDigitizationMapper officialWebsiteDigitizationMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteFirstScreenServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteFirstScreenMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteFirstScreen; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteFirstScreenService; 7 | import space.zero.core.service.AbstractDeleteFlagService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import javax.annotation.Resource; 12 | 13 | 14 | /** 15 | * Created by PG_shen on 2018/09/26. 16 | */ 17 | @Service 18 | @Transactional 19 | public class OfficialWebsiteFirstScreenServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteFirstScreenService { 20 | @Resource 21 | private OfficialWebsiteFirstScreenMapper officialWebsiteFirstScreenMapper; 22 | 23 | @Override 24 | public OfficialWebsiteFirstScreen fetchFirstScreen(String clazz) { 25 | return officialWebsiteFirstScreenMapper.fetchFirstScreen(clazz); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteHistoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.dao.OfficialWebsiteHistoryMapper; 4 | import space.zero.business.module.official.website.model.OfficialWebsiteHistory; 5 | import space.zero.business.module.official.website.service.OfficialWebsiteHistoryService; 6 | import space.zero.core.service.AbstractDeleteFlagService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteHistoryServiceImpl extends AbstractDeleteFlagService implements OfficialWebsiteHistoryService { 19 | @Resource 20 | private OfficialWebsiteHistoryMapper officialWebsiteHistoryMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteNewsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteNewsMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteNews; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteNewsService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteNewsServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteNewsService { 19 | @Resource 20 | private OfficialWebsiteNewsMapper officialWebsiteNewsMapper; 21 | 22 | @Override 23 | public OfficialWebsiteNews getNextNews(String id, String newsClazz) { 24 | return officialWebsiteNewsMapper.getNextNews(id, newsClazz); 25 | } 26 | 27 | @Override 28 | public OfficialWebsiteNews getPreviousNews(String id, String newsClazz) { 29 | return officialWebsiteNewsMapper.getPreviousNews(id, newsClazz); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteProductMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteProduct; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteProductService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteProductServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteProductService { 19 | @Resource 20 | private OfficialWebsiteProductMapper officialWebsiteProductMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteRecruitServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteRecruitMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteRecruit; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteRecruitService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteRecruitServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteRecruitService { 19 | @Resource 20 | private OfficialWebsiteRecruitMapper officialWebsiteRecruitMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/service/impl/OfficialWebsiteSolutionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.service.impl; 2 | 3 | import space.zero.business.module.official.website.base.WebsiteDeleteFlagService; 4 | import space.zero.business.module.official.website.dao.OfficialWebsiteSolutionMapper; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteSolution; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteSolutionService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/09/26. 15 | */ 16 | @Service 17 | @Transactional 18 | public class OfficialWebsiteSolutionServiceImpl extends WebsiteDeleteFlagService implements OfficialWebsiteSolutionService { 19 | @Resource 20 | private OfficialWebsiteSolutionMapper officialWebsiteSolutionMapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/web/OfficialWebsiteBaseInfoController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.web; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.multipart.MultipartFile; 5 | import space.zero.common.utils.FileUploadEnum; 6 | import space.zero.common.utils.FileUploadUtils; 7 | import space.zero.core.result.Result; 8 | import space.zero.core.result.ResultGenerator; 9 | import space.zero.business.module.official.website.model.OfficialWebsiteBaseInfo; 10 | import space.zero.business.module.official.website.service.OfficialWebsiteBaseInfoService; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.io.IOException; 15 | 16 | /** 17 | * Created by PG_shen on 2018/09/26. 18 | */ 19 | @RestController 20 | @RequestMapping("/official/website/base/info") 21 | public class OfficialWebsiteBaseInfoController { 22 | @Resource 23 | private OfficialWebsiteBaseInfoService officialWebsiteBaseInfoService; 24 | @Value("${website.global.host}") 25 | private String host; 26 | 27 | @PutMapping 28 | public Result update(@RequestBody OfficialWebsiteBaseInfo officialWebsiteBaseInfo) { 29 | officialWebsiteBaseInfo.setLogoUrl(officialWebsiteBaseInfo.getLogoUrl().replace(host,"")); 30 | officialWebsiteBaseInfo.setQrCodeUrl(officialWebsiteBaseInfo.getQrCodeUrl().replace(host,"")); 31 | OfficialWebsiteBaseInfo baseInfo = officialWebsiteBaseInfoService.updateInfo(officialWebsiteBaseInfo); 32 | officialWebsiteBaseInfo.setLogoUrl(host+ officialWebsiteBaseInfo.getLogoUrl()); 33 | officialWebsiteBaseInfo.setQrCodeUrl(host + officialWebsiteBaseInfo.getQrCodeUrl()); 34 | return ResultGenerator.genSuccessResult(baseInfo); 35 | } 36 | 37 | @GetMapping 38 | public Result detail() { 39 | OfficialWebsiteBaseInfo officialWebsiteBaseInfo = officialWebsiteBaseInfoService.fetchInfo(); 40 | officialWebsiteBaseInfo.setLogoUrl(host+ officialWebsiteBaseInfo.getLogoUrl()); 41 | officialWebsiteBaseInfo.setQrCodeUrl(host + officialWebsiteBaseInfo.getQrCodeUrl()); 42 | return ResultGenerator.genSuccessResult(officialWebsiteBaseInfo); 43 | } 44 | 45 | /** 46 | * 文件上传 47 | * @param file 48 | * @return 49 | */ 50 | @PostMapping("/upload") 51 | public Result upload(@RequestParam("avatar") MultipartFile file){ 52 | FileUploadUtils fileUploadUtils = new FileUploadUtils(); 53 | String filePath = null; 54 | try { 55 | filePath = host + fileUploadUtils.uploadFile(file, FileUploadEnum.AVATAR); 56 | } catch (IOException e) { 57 | e.printStackTrace(); 58 | return ResultGenerator.genFailResult("fail"); 59 | } 60 | return ResultGenerator.genSuccessResult(filePath, "success"); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/web/OfficialWebsiteClassMateController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.web; 2 | 3 | import space.zero.business.module.official.website.param.request.ClazzListRequest; 4 | import space.zero.business.module.official.website.param.request.CondRequest; 5 | import space.zero.core.result.Result; 6 | import space.zero.core.result.ResultGenerator; 7 | import space.zero.business.module.official.website.model.OfficialWebsiteClassMate; 8 | import space.zero.business.module.official.website.service.OfficialWebsiteClassMateService; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | import static space.zero.core.constant.Constant.ENABLE_FLAG_FALSE; 17 | import static space.zero.core.constant.Constant.ENABLE_FLAG_TRUE; 18 | 19 | /** 20 | * Created by PG_shen on 2018/10/04. 21 | */ 22 | @RestController 23 | @RequestMapping("/official/website/class/mate") 24 | public class OfficialWebsiteClassMateController { 25 | @Resource 26 | private OfficialWebsiteClassMateService officialWebsiteClassMateService; 27 | 28 | @PostMapping 29 | public Result add(@RequestBody OfficialWebsiteClassMate officialWebsiteClassMate) { 30 | OfficialWebsiteClassMate tmp = officialWebsiteClassMateService.save(officialWebsiteClassMate); 31 | return ResultGenerator.genSuccessResult(tmp); 32 | } 33 | 34 | @DeleteMapping("/{id}") 35 | public Result delete(@PathVariable String id) { 36 | officialWebsiteClassMateService.deleteById(id); 37 | return ResultGenerator.genSuccessResult(); 38 | } 39 | 40 | @PutMapping 41 | public Result update(@RequestBody OfficialWebsiteClassMate officialWebsiteClassMate) { 42 | OfficialWebsiteClassMate tmp = officialWebsiteClassMateService.update(officialWebsiteClassMate); 43 | return ResultGenerator.genSuccessResult(tmp); 44 | } 45 | 46 | @GetMapping("/{id}") 47 | public Result detail(@PathVariable String id) { 48 | OfficialWebsiteClassMate officialWebsiteClassMate = officialWebsiteClassMateService.findById(id); 49 | return ResultGenerator.genSuccessResult(officialWebsiteClassMate); 50 | } 51 | 52 | @PostMapping("/list") 53 | public Result list(@RequestBody CondRequest condRequest) { 54 | PageHelper.startPage(condRequest.getPage(), condRequest.getSize(), condRequest.getOrder()); 55 | List list = officialWebsiteClassMateService.findBy(condRequest.getCond()); 56 | PageInfo pageInfo = new PageInfo(list); 57 | return ResultGenerator.genSuccessResult(pageInfo); 58 | } 59 | 60 | @PostMapping("/clazzlist") 61 | public Result clazzList(@RequestBody ClazzListRequest clazzListRequest){ 62 | return ResultGenerator.genSuccessResult(officialWebsiteClassMateService.findClazz(clazzListRequest.getClazzName())); 63 | } 64 | 65 | @PostMapping("/checkout/{id}") 66 | public Result checkoutStatus(@PathVariable String id){ 67 | OfficialWebsiteClassMate classMate = officialWebsiteClassMateService.findById(id); 68 | if ("1".equals(classMate.getIsEnable())){ 69 | classMate.setIsEnable(ENABLE_FLAG_FALSE); 70 | }else if ("0".equals(classMate.getIsEnable())){ 71 | classMate.setIsEnable(ENABLE_FLAG_TRUE); 72 | } 73 | officialWebsiteClassMateService.update(classMate); 74 | return ResultGenerator.genSuccessResult(classMate); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/web/OfficialWebsiteDigitizationController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.web; 2 | 3 | import space.zero.core.result.Result; 4 | import space.zero.core.result.ResultGenerator; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteDigitization; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteDigitizationService; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by PG_shen on 2018/09/26. 16 | */ 17 | @RestController 18 | @RequestMapping("/official/website/digitization") 19 | public class OfficialWebsiteDigitizationController { 20 | @Resource 21 | private OfficialWebsiteDigitizationService officialWebsiteDigitizationService; 22 | 23 | @PostMapping 24 | public Result add(@RequestBody OfficialWebsiteDigitization officialWebsiteDigitization) { 25 | OfficialWebsiteDigitization tmp = officialWebsiteDigitizationService.save(officialWebsiteDigitization); 26 | return ResultGenerator.genSuccessResult(tmp); 27 | } 28 | 29 | @DeleteMapping("/{id}") 30 | public Result delete(@PathVariable String id) { 31 | officialWebsiteDigitizationService.deleteById(id); 32 | return ResultGenerator.genSuccessResult(); 33 | } 34 | 35 | @PutMapping 36 | public Result update(@RequestBody OfficialWebsiteDigitization officialWebsiteDigitization) { 37 | OfficialWebsiteDigitization tmp = officialWebsiteDigitizationService.update(officialWebsiteDigitization); 38 | return ResultGenerator.genSuccessResult(tmp); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public Result detail(@PathVariable String id) { 43 | OfficialWebsiteDigitization officialWebsiteDigitization = officialWebsiteDigitizationService.findById(id); 44 | return ResultGenerator.genSuccessResult(officialWebsiteDigitization); 45 | } 46 | 47 | @GetMapping 48 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 49 | PageHelper.startPage(page, size); 50 | List list = officialWebsiteDigitizationService.findAll(); 51 | PageInfo pageInfo = new PageInfo(list); 52 | return ResultGenerator.genSuccessResult(pageInfo); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/web/OfficialWebsiteHistoryController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.web; 2 | 3 | import space.zero.core.result.Result; 4 | import space.zero.core.result.ResultGenerator; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteHistory; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteHistoryService; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by PG_shen on 2018/09/26. 16 | */ 17 | @RestController 18 | @RequestMapping("/official/website/history") 19 | public class OfficialWebsiteHistoryController { 20 | @Resource 21 | private OfficialWebsiteHistoryService officialWebsiteHistoryService; 22 | 23 | @PostMapping 24 | public Result add(@RequestBody OfficialWebsiteHistory officialWebsiteHistory) { 25 | OfficialWebsiteHistory tmp = officialWebsiteHistoryService.save(officialWebsiteHistory); 26 | return ResultGenerator.genSuccessResult(tmp); 27 | } 28 | 29 | @DeleteMapping("/{id}") 30 | public Result delete(@PathVariable String id) { 31 | officialWebsiteHistoryService.deleteById(id); 32 | return ResultGenerator.genSuccessResult(); 33 | } 34 | 35 | @PutMapping 36 | public Result update(@RequestBody OfficialWebsiteHistory officialWebsiteHistory) { 37 | OfficialWebsiteHistory tmp = officialWebsiteHistoryService.update(officialWebsiteHistory); 38 | return ResultGenerator.genSuccessResult(tmp); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public Result detail(@PathVariable String id) { 43 | OfficialWebsiteHistory officialWebsiteHistory = officialWebsiteHistoryService.findById(id); 44 | return ResultGenerator.genSuccessResult(officialWebsiteHistory); 45 | } 46 | 47 | @GetMapping 48 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 49 | PageHelper.startPage(page, size); 50 | List list = officialWebsiteHistoryService.findAll(); 51 | PageInfo pageInfo = new PageInfo(list); 52 | return ResultGenerator.genSuccessResult(pageInfo); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/official/website/web/OfficialWebsiteRecruitController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.official.website.web; 2 | 3 | import space.zero.core.result.Result; 4 | import space.zero.core.result.ResultGenerator; 5 | import space.zero.business.module.official.website.model.OfficialWebsiteRecruit; 6 | import space.zero.business.module.official.website.service.OfficialWebsiteRecruitService; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by PG_shen on 2018/09/26. 16 | */ 17 | @RestController 18 | @RequestMapping("/official/website/recruit") 19 | public class OfficialWebsiteRecruitController { 20 | @Resource 21 | private OfficialWebsiteRecruitService officialWebsiteRecruitService; 22 | 23 | @PostMapping 24 | public Result add(@RequestBody OfficialWebsiteRecruit officialWebsiteRecruit) { 25 | OfficialWebsiteRecruit tmp = officialWebsiteRecruitService.save(officialWebsiteRecruit); 26 | return ResultGenerator.genSuccessResult(tmp); 27 | } 28 | 29 | @DeleteMapping("/{id}") 30 | public Result delete(@PathVariable String id) { 31 | officialWebsiteRecruitService.deleteById(id); 32 | return ResultGenerator.genSuccessResult(); 33 | } 34 | 35 | @PutMapping 36 | public Result update(@RequestBody OfficialWebsiteRecruit officialWebsiteRecruit) { 37 | OfficialWebsiteRecruit tmp = officialWebsiteRecruitService.update(officialWebsiteRecruit); 38 | return ResultGenerator.genSuccessResult(tmp); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public Result detail(@PathVariable String id) { 43 | OfficialWebsiteRecruit officialWebsiteRecruit = officialWebsiteRecruitService.findById(id); 44 | return ResultGenerator.genSuccessResult(officialWebsiteRecruit); 45 | } 46 | 47 | @GetMapping 48 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 49 | PageHelper.startPage(page, size); 50 | List list = officialWebsiteRecruitService.findAll(); 51 | PageInfo pageInfo = new PageInfo(list); 52 | return ResultGenerator.genSuccessResult(pageInfo); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/dao/SysMenuMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.sys.model.SysMenu; 5 | import space.zero.core.mapper.Mapper; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/08. 12 | */ 13 | public interface SysMenuMapper extends Mapper { 14 | @Select("select * from sys_menu where is_delete = 0 and parent_id = #{parentId}") 15 | List findByParentId(String parentId); 16 | 17 | @Select("select * from sys_menu where is_delete = 0 and id = 0") 18 | SysMenu findRoot(); 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/dao/SysRoleMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.sys.model.SysRole; 5 | import space.zero.business.module.sys.param.response.RoleListResponse; 6 | import space.zero.core.mapper.Mapper; 7 | 8 | import java.util.List; 9 | 10 | 11 | /** 12 | * Created by PG_shen on 2018/03/08. 13 | */ 14 | public interface SysRoleMapper extends Mapper { 15 | @Select("select id,name from sys_role where is_delete=0") 16 | List findRoleListForAuth(); 17 | } 18 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/dao/SysRoleMenuMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Component; 6 | import space.zero.business.module.sys.model.SysRoleMenu; 7 | import space.zero.core.mapper.Mapper; 8 | 9 | import java.util.List; 10 | 11 | 12 | /** 13 | * Created by PG_shen on 2018/03/08. 14 | */ 15 | @Component 16 | public interface SysRoleMenuMapper extends Mapper { 17 | @Select("select distinct m.PERM from sys_role_menu r_m, sys_menu m, sys_role r where r_m.MENU_ID=m.ID and r_m.ROLE_ID=r.ID and r_m.IS_DELETE=0 and r.NAME=#{role}") 18 | List getPermsByRole(String role); 19 | 20 | @Select("select distinct m.PERM from sys_role_menu r_m, sys_menu m, sys_role r where r_m.MENU_ID=m.ID and r_m.ROLE_ID=r.ID and r_m.IS_DELETE=0 and r.ID=#{roleId}") 21 | List getPermsByRoleId(String roleId); 22 | 23 | @Select("select MENU_ID from sys_role_menu where IS_DELETE=0 and role_id=#{roleId}") 24 | List findAuthByRoleId(String roleId); 25 | 26 | //只查找菜单,不需请求跟按钮 27 | @Select("select r_m.MENU_ID from sys_role_menu r_m, sys_menu m where r_m.MENU_ID=m.ID and r_m.IS_DELETE=0 and m.type=0 and r_m.role_id=#{roleId}") 28 | List findMenuByRoleId(String roleId); 29 | 30 | //根据菜单ID查找该菜单下的权限按钮 31 | @Select("select distinct m.PERM from sys_role_menu r_m, sys_menu m where r_m.MENU_ID=m.ID and r_m.IS_DELETE=0 and m.type=2 and r_m.role_id=${roleId} and m.parent_id=${parentId}") 32 | List findButtonByParentId(@Param("roleId") String roleId, @Param("parentId") String parentId); 33 | } 34 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/dao/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.dao; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.sys.model.SysUser; 5 | import space.zero.core.mapper.Mapper; 6 | 7 | 8 | /** 9 | * Created by PG_shen on 2018/03/08. 10 | */ 11 | public interface SysUserMapper extends Mapper { 12 | } 13 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/dao/SysUserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.dao; 2 | 3 | import org.apache.ibatis.annotations.Delete; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Component; 6 | import space.zero.business.module.sys.model.SysRole; 7 | import space.zero.business.module.sys.model.SysUserRole; 8 | import space.zero.core.mapper.Mapper; 9 | 10 | import java.util.List; 11 | 12 | 13 | /** 14 | * Created by PG_shen on 2018/03/08. 15 | */ 16 | @Component 17 | public interface SysUserRoleMapper extends Mapper { 18 | @Select("select r.* from sys_role r, sys_user u, sys_user_role u_r where r.id = u_r.ROLE_ID and u_r.USER_ID = u.ID and u_r.IS_DELETE = 0 and u.ID = #{userId}") 19 | List findSysRolesByUserId(String userId); 20 | 21 | @Select("select ROLE_ID from sys_user_role where IS_DELETE=0 and user_id=#{userID}") 22 | List findRolesByUserId(String userId); 23 | 24 | @Select("select r.`NAME` from sys_role r, sys_user u, sys_user_role u_r WHERE u.ID = u_r.USER_ID AND r.ID = u_r.ROLE_ID AND u_r.IS_DELETE=0 AND u.LOGIN_NAME = #{username}") 25 | List getSysRolesByUsername(String username); 26 | 27 | @Delete("update sys_user_role set IS_DELETE=1 where user_id=#{userId}") 28 | void deleteByUserId(String userId); 29 | } 30 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/model/SysRoleMenu.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import space.zero.core.model.BaseEntity; 5 | 6 | import java.util.Date; 7 | import javax.persistence.*; 8 | 9 | @Table(name = "sys_role_menu") 10 | public class SysRoleMenu extends BaseEntity { 11 | /** 12 | * 角色菜单ID 13 | */ 14 | @Id 15 | @Column(name = "ID") 16 | private String id; 17 | 18 | /** 19 | * 角色id(外键) 20 | */ 21 | @Column(name = "ROLE_ID") 22 | private String roleId; 23 | 24 | /** 25 | * 菜单id(外键) 26 | */ 27 | @Column(name = "MENU_ID") 28 | private String menuId; 29 | 30 | /** 31 | * 是否删除标志(所有记录都是假删除) 32 | */ 33 | @JsonIgnore 34 | @Column(name = "IS_DELETE") 35 | private transient String isDelete; 36 | 37 | @Column(name = "CREATED_TIME") 38 | private Date createdTime; 39 | 40 | @Column(name = "UPDATE_TIME") 41 | private Date updateTime; 42 | 43 | /** 44 | * 获取角色菜单ID 45 | * 46 | * @return ID - 角色菜单ID 47 | */ 48 | public String getId() { 49 | return id; 50 | } 51 | 52 | /** 53 | * 设置角色菜单ID 54 | * 55 | * @param id 角色菜单ID 56 | */ 57 | public void setId(String id) { 58 | this.id = id; 59 | } 60 | 61 | /** 62 | * 获取角色id(外键) 63 | * 64 | * @return ROLE_ID - 角色id(外键) 65 | */ 66 | public String getRoleId() { 67 | return roleId; 68 | } 69 | 70 | /** 71 | * 设置角色id(外键) 72 | * 73 | * @param roleId 角色id(外键) 74 | */ 75 | public void setRoleId(String roleId) { 76 | this.roleId = roleId; 77 | } 78 | 79 | /** 80 | * 获取菜单id(外键) 81 | * 82 | * @return MENU_ID - 菜单id(外键) 83 | */ 84 | public String getMenuId() { 85 | return menuId; 86 | } 87 | 88 | /** 89 | * 设置菜单id(外键) 90 | * 91 | * @param menuId 菜单id(外键) 92 | */ 93 | public void setMenuId(String menuId) { 94 | this.menuId = menuId; 95 | } 96 | 97 | /** 98 | * 获取是否删除标志(所有记录都是假删除) 99 | * 100 | * @return IS_DELETE - 是否删除标志(所有记录都是假删除) 101 | */ 102 | public String getIsDelete() { 103 | return isDelete; 104 | } 105 | 106 | /** 107 | * 设置是否删除标志(所有记录都是假删除) 108 | * 109 | * @param isDelete 是否删除标志(所有记录都是假删除) 110 | */ 111 | public void setIsDelete(String isDelete) { 112 | this.isDelete = isDelete; 113 | } 114 | 115 | /** 116 | * @return CREATED_TIME 117 | */ 118 | public Date getCreatedTime() { 119 | return createdTime; 120 | } 121 | 122 | /** 123 | * @param createdTime 124 | */ 125 | public void setCreatedTime(Date createdTime) { 126 | this.createdTime = createdTime; 127 | } 128 | 129 | /** 130 | * @return UPDATE_TIME 131 | */ 132 | public Date getUpdateTime() { 133 | return updateTime; 134 | } 135 | 136 | /** 137 | * @param updateTime 138 | */ 139 | public void setUpdateTime(Date updateTime) { 140 | this.updateTime = updateTime; 141 | } 142 | } -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/model/SysUserDetails.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.model; 2 | 3 | import org.springframework.security.core.GrantedAuthority; 4 | import org.springframework.security.core.userdetails.UserDetails; 5 | 6 | import java.util.Collection; 7 | 8 | import static space.zero.core.constant.Constant.ENABLE_FLAG_TRUE; 9 | 10 | /** 11 | * Created by PG_shen 12 | * Date : 3/8/18 13 | * Time : 1:03 PM 14 | */ 15 | public class SysUserDetails implements UserDetails{ 16 | private static final long serialVersionUID = 1L; 17 | 18 | private SysUser user; 19 | 20 | public SysUserDetails(SysUser user) { 21 | this.user = user; 22 | } 23 | 24 | @Override 25 | public Collection getAuthorities() { 26 | return user.getPerms(); 27 | } 28 | 29 | @Override 30 | public String getPassword() { 31 | return user.getPassword(); 32 | } 33 | 34 | @Override 35 | public String getUsername() { 36 | return user.getLoginName(); 37 | } 38 | 39 | @Override 40 | public boolean isAccountNonExpired() { 41 | return true; 42 | } 43 | 44 | @Override 45 | public boolean isAccountNonLocked() { 46 | return true; 47 | } 48 | 49 | @Override 50 | public boolean isCredentialsNonExpired() { 51 | return true; 52 | } 53 | 54 | @Override 55 | public boolean isEnabled() { 56 | return ENABLE_FLAG_TRUE.equals(user.getIsEnable()); 57 | } 58 | 59 | public SysUser getUser() { 60 | return user; 61 | } 62 | 63 | public void setUser(SysUser user) { 64 | this.user = user; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/model/SysUserRole.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import space.zero.core.model.BaseEntity; 5 | 6 | import java.util.Date; 7 | import javax.persistence.*; 8 | 9 | @Table(name = "sys_user_role") 10 | public class SysUserRole extends BaseEntity { 11 | /** 12 | * 主键 13 | */ 14 | @Id 15 | @Column(name = "ID") 16 | private String id; 17 | 18 | /** 19 | * 用户id 20 | */ 21 | @Column(name = "USER_ID") 22 | private String userId; 23 | 24 | /** 25 | * 角色id 26 | */ 27 | @Column(name = "ROLE_ID") 28 | private String roleId; 29 | 30 | @Column(name = "CREATED_TIME") 31 | private Date createdTime; 32 | 33 | @Column(name = "UPDATE_TIME") 34 | private Date updateTime; 35 | 36 | /** 37 | * 假删除 38 | */ 39 | @JsonIgnore 40 | @Column(name = "IS_DELETE") 41 | private transient String isDelete; 42 | 43 | /** 44 | * 获取主键 45 | * 46 | * @return ID - 主键 47 | */ 48 | public String getId() { 49 | return id; 50 | } 51 | 52 | /** 53 | * 设置主键 54 | * 55 | * @param id 主键 56 | */ 57 | public void setId(String id) { 58 | this.id = id; 59 | } 60 | 61 | /** 62 | * 获取用户id 63 | * 64 | * @return USER_ID - 用户id 65 | */ 66 | public String getUserId() { 67 | return userId; 68 | } 69 | 70 | /** 71 | * 设置用户id 72 | * 73 | * @param userId 用户id 74 | */ 75 | public void setUserId(String userId) { 76 | this.userId = userId; 77 | } 78 | 79 | /** 80 | * 获取角色id 81 | * 82 | * @return ROLE_ID - 角色id 83 | */ 84 | public String getRoleId() { 85 | return roleId; 86 | } 87 | 88 | /** 89 | * 设置角色id 90 | * 91 | * @param roleId 角色id 92 | */ 93 | public void setRoleId(String roleId) { 94 | this.roleId = roleId; 95 | } 96 | 97 | /** 98 | * @return CREATED_TIME 99 | */ 100 | public Date getCreatedTime() { 101 | return createdTime; 102 | } 103 | 104 | /** 105 | * @param createdTime 106 | */ 107 | public void setCreatedTime(Date createdTime) { 108 | this.createdTime = createdTime; 109 | } 110 | 111 | /** 112 | * @return UPDATE_TIME 113 | */ 114 | public Date getUpdateTime() { 115 | return updateTime; 116 | } 117 | 118 | /** 119 | * @param updateTime 120 | */ 121 | public void setUpdateTime(Date updateTime) { 122 | this.updateTime = updateTime; 123 | } 124 | 125 | /** 126 | * 获取假删除 127 | * 128 | * @return IS_DELETE - 假删除 129 | */ 130 | public String getIsDelete() { 131 | return isDelete; 132 | } 133 | 134 | /** 135 | * 设置假删除 136 | * 137 | * @param isDelete 假删除 138 | */ 139 | public void setIsDelete(String isDelete) { 140 | this.isDelete = isDelete; 141 | } 142 | } -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/request/CondRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.request; 2 | 3 | import space.zero.core.model.BaseEntity; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by PG_shen 9 | * Date : 3/14/18 10 | * Time : 9:59 AM 11 | */ 12 | public class CondRequest { 13 | //页码 14 | private Integer page; 15 | //页大小 16 | private Integer size; 17 | //排序字段 18 | private String order; 19 | private Map cond; 20 | 21 | public Integer getPage() { 22 | return page; 23 | } 24 | 25 | public void setPage(Integer page) { 26 | this.page = page; 27 | } 28 | 29 | public Integer getSize() { 30 | return size; 31 | } 32 | 33 | public void setSize(Integer size) { 34 | this.size = size; 35 | } 36 | 37 | public String getOrder() { 38 | return order; 39 | } 40 | 41 | public void setOrder(String order) { 42 | this.order = order; 43 | } 44 | 45 | public Map getCond() { 46 | return cond; 47 | } 48 | 49 | public void setCond(Map cond) { 50 | this.cond = cond; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/request/RoleAuthListRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.request; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/8/18 6 | * Time : 4:17 PM 7 | */ 8 | public class RoleAuthListRequest { 9 | 10 | private String roleId; 11 | 12 | public String getRoleId() { 13 | return roleId; 14 | } 15 | 16 | public void setRoleId(String roleId) { 17 | this.roleId = roleId; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/request/RoleAuthRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.request; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/8/18 8 | * Time : 4:15 PM 9 | * 角色授权请求参数 10 | */ 11 | public class RoleAuthRequest { 12 | private String id; 13 | 14 | private List menus; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public List getMenus() { 25 | return menus; 26 | } 27 | 28 | public void setMenus(List menus) { 29 | this.menus = menus; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/request/SysUserListRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.request; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/8/18 6 | * Time : 4:33 PM 7 | */ 8 | public class SysUserListRequest { 9 | private String nameLike; 10 | 11 | public String getNameLike() { 12 | return nameLike; 13 | } 14 | 15 | public void setNameLike(String nameLike) { 16 | this.nameLike = nameLike; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/request/UserRoleListRequest.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.request; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/8/18 6 | * Time : 4:32 PM 7 | */ 8 | public class UserRoleListRequest { 9 | private String userId; 10 | 11 | public String getUserId() { 12 | return userId; 13 | } 14 | 15 | public void setUserId(String userId) { 16 | this.userId = userId; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/response/RoleListResponse.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.response; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by PG_shen 9 | * Date : 3/8/18 10 | * Time : 2:29 PM 11 | */ 12 | public class RoleListResponse implements Serializable{ 13 | @JsonProperty("value") 14 | private String id; 15 | 16 | @JsonProperty("label") 17 | private String name; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/param/response/RouterTree.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.param.response; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/16/18 8 | * Time : 2:26 PM 9 | */ 10 | public class RouterTree { 11 | private String id; 12 | 13 | private String name; 14 | 15 | private String title; 16 | 17 | private String icon; 18 | 19 | private String path; 20 | 21 | private Integer orderNum; 22 | 23 | private String hidden; 24 | 25 | private String alwaysShow; 26 | 27 | private String component; 28 | 29 | private String redirect; 30 | 31 | private String url; 32 | 33 | private String btn; 34 | 35 | private List children; 36 | 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | public void setId(String id) { 42 | this.id = id; 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 getTitle() { 54 | return title; 55 | } 56 | 57 | public void setTitle(String title) { 58 | this.title = title; 59 | } 60 | 61 | public String getIcon() { 62 | return icon; 63 | } 64 | 65 | public void setIcon(String icon) { 66 | this.icon = icon; 67 | } 68 | 69 | public String getPath() { 70 | return path; 71 | } 72 | 73 | public void setPath(String path) { 74 | this.path = path; 75 | } 76 | 77 | public Integer getOrderNum() { 78 | return orderNum; 79 | } 80 | 81 | public void setOrderNum(Integer orderNum) { 82 | this.orderNum = orderNum; 83 | } 84 | 85 | public String getHidden() { 86 | return hidden; 87 | } 88 | 89 | public void setHidden(String hidden) { 90 | this.hidden = hidden; 91 | } 92 | 93 | public String getAlwaysShow() { 94 | return alwaysShow; 95 | } 96 | 97 | public void setAlwaysShow(String alwaysShow) { 98 | this.alwaysShow = alwaysShow; 99 | } 100 | 101 | public String getComponent() { 102 | return component; 103 | } 104 | 105 | public void setComponent(String component) { 106 | this.component = component; 107 | } 108 | 109 | public String getRedirect() { 110 | return redirect; 111 | } 112 | 113 | public void setRedirect(String redirect) { 114 | this.redirect = redirect; 115 | } 116 | 117 | public String getUrl() { 118 | return url; 119 | } 120 | 121 | public void setUrl(String url) { 122 | this.url = url; 123 | } 124 | 125 | public String getBtn() { 126 | return btn; 127 | } 128 | 129 | public void setBtn(String btn) { 130 | this.btn = btn; 131 | } 132 | 133 | public List getChildren() { 134 | return children; 135 | } 136 | 137 | public void setChildren(List children) { 138 | this.children = children; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/ContentTypeAntPathRequestMatcher.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import space.zero.common.utils.StringUtils; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | /** 8 | * Created by PG_shen 9 | * Date : 3/8/18 10 | * Time : 4:44 PM 11 | * Content-type 过滤,进行rest api过滤 12 | */ 13 | public class ContentTypeAntPathRequestMatcher extends AntPathRequestMatcher { 14 | private String contentType; 15 | 16 | public ContentTypeAntPathRequestMatcher(String pattern, String httpMethod,String contentType) { 17 | super(pattern, httpMethod); 18 | this.contentType=contentType; 19 | } 20 | 21 | @Override 22 | public boolean matches(HttpServletRequest request) { 23 | if(StringUtils.isBlank(request.getContentType())){ 24 | return false; 25 | } 26 | return super.matches(request)&& request.getContentType().contains(contentType); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/RestAuthenticationExceptionFilter.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.filter.GenericFilterBean; 6 | 7 | import javax.servlet.FilterChain; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.ServletRequest; 10 | import javax.servlet.ServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Created by PG_shen 15 | * Date : 3/8/18 16 | * Time : 4:47 PM 17 | */ 18 | public class RestAuthenticationExceptionFilter extends GenericFilterBean { 19 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 20 | 21 | public RestAuthenticationExceptionFilter() { 22 | } 23 | 24 | @Override 25 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { 26 | try { 27 | chain.doFilter(request, response); 28 | 29 | logger.debug("Chain processed normally"); 30 | } catch (Exception e) { 31 | throw e; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/SysAccessDecisionManager.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.security.access.AccessDecisionManager; 6 | import org.springframework.security.access.AccessDeniedException; 7 | import org.springframework.security.access.ConfigAttribute; 8 | import org.springframework.security.authentication.InsufficientAuthenticationException; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.GrantedAuthority; 11 | import space.zero.common.utils.StringUtils; 12 | 13 | import java.util.Collection; 14 | import java.util.Iterator; 15 | 16 | /** 17 | * Created by jiabinl on 2017-3-23. 18 | */ 19 | public class SysAccessDecisionManager implements AccessDecisionManager { 20 | private static final Logger logger = LoggerFactory.getLogger(SysAccessDecisionManager.class); 21 | 22 | /*** 23 | * 决策当前的访问是否能通过权限验证 24 | * 25 | * @param authentication 包含了当前的用户信息,包括拥有的权限 26 | * @param object FilterInvocation对象,可以得到request等web资源 27 | * @param configAttributes 本次访问需要的权限 28 | * @throws AccessDeniedException 拒绝访问异常 29 | * @throws InsufficientAuthenticationException 30 | */ 31 | @Override 32 | public void decide(Authentication authentication, Object object, Collection configAttributes) throws AccessDeniedException, InsufficientAuthenticationException { 33 | logger.debug("------------------------- decide now -------------------------"); 34 | 35 | if (authentication == null) { 36 | throw new AccessDeniedException("当前访问没有权限"); 37 | } 38 | 39 | Iterator iterator = configAttributes.iterator(); 40 | while (iterator.hasNext()) { 41 | ConfigAttribute configAttribute = iterator.next(); 42 | String needPerm = configAttribute.getAttribute(); 43 | Collection authorities = authentication.getAuthorities(); 44 | for (GrantedAuthority authority : authorities) { 45 | if (StringUtils.equals(authority.getAuthority(), needPerm)) { 46 | return; 47 | } 48 | } 49 | } 50 | 51 | throw new AccessDeniedException("当前访问没有权限"); 52 | } 53 | 54 | @Override 55 | public boolean supports(ConfigAttribute attribute) { 56 | return true; 57 | } 58 | 59 | @Override 60 | public boolean supports(Class clazz) { 61 | return true; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/SysAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import org.springframework.security.access.AccessDeniedException; 4 | import org.springframework.security.web.access.AccessDeniedHandler; 5 | import space.zero.core.result.Result; 6 | import space.zero.core.result.ResultGenerator; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | public class SysAccessDeniedHandler implements AccessDeniedHandler { 15 | @Override 16 | public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException { 17 | httpServletResponse.setContentType("application/json;charset=utf-8"); 18 | httpServletResponse.setCharacterEncoding("UTF-8"); 19 | PrintWriter out = httpServletResponse.getWriter(); 20 | String path = httpServletRequest.getRequestURI(); 21 | Result result; 22 | //区分页面还是接口 23 | if (path.endsWith("page")) { 24 | result = ResultGenerator.genForbiddenPageResult("您当前没有权限访问该页面,请联系管理员!"); 25 | }else { 26 | result = ResultGenerator.genForbiddenInterfaceResult("","您当前没有权限访问该数据,请联系管理员!"); 27 | } 28 | out.write(result.toString()); 29 | out.flush(); 30 | out.close(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/SysAuthenticationFailureHandler.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import org.springframework.security.authentication.BadCredentialsException; 4 | import org.springframework.security.authentication.DisabledException; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 8 | import space.zero.core.result.Result; 9 | import space.zero.core.result.ResultGenerator; 10 | 11 | import javax.servlet.ServletException; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | import java.io.PrintWriter; 16 | 17 | public class SysAuthenticationFailureHandler implements AuthenticationFailureHandler { 18 | @Override 19 | public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { 20 | httpServletResponse.setContentType("application/json;charset=utf-8"); 21 | httpServletResponse.setCharacterEncoding("UTF-8"); 22 | PrintWriter out = httpServletResponse.getWriter(); 23 | String message; 24 | if (e instanceof UsernameNotFoundException || e instanceof BadCredentialsException) { 25 | message = "用户名或密码输入错误,登录失败!"; 26 | } else if (e instanceof DisabledException) { 27 | message = "账户被禁用,登录失败,请联系管理员!"; 28 | } else { 29 | message = "登录失败!"; 30 | } 31 | Result result = ResultGenerator.genFailResult(message); 32 | out.write(result.toString()); 33 | out.flush(); 34 | out.close(); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/SysAuthenticationSuccessHandler.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 5 | import space.zero.common.jsonLib.mapper.JsonMapper; 6 | import space.zero.common.utils.MIMEType; 7 | import space.zero.core.result.Result; 8 | import space.zero.core.result.ResultGenerator; 9 | 10 | import javax.servlet.ServletException; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | import java.io.PrintWriter; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | public class SysAuthenticationSuccessHandler implements AuthenticationSuccessHandler { 19 | @Override 20 | public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { 21 | httpServletResponse.setCharacterEncoding("UTF-8"); 22 | httpServletResponse.setContentType(MIMEType.APPLICATION_JSON + ";charset=utf8"); 23 | PrintWriter out = httpServletResponse.getWriter(); 24 | Map map = new HashMap(); 25 | map.put("token", httpServletRequest.getSession().getId()); 26 | String message = "认证成功,欢迎登录!"; 27 | out.write(JsonMapper.toJsonString(ResultGenerator.genSuccessResult(map, message))); 28 | out.flush(); 29 | out.close(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/security/SysSecurityFilter.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.security; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/8/18 6 | * Time : 4:50 PM 7 | */ 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.access.SecurityMetadataSource; 11 | import org.springframework.security.access.intercept.AbstractSecurityInterceptor; 12 | import org.springframework.security.access.intercept.InterceptorStatusToken; 13 | import org.springframework.security.web.FilterInvocation; 14 | 15 | import javax.servlet.*; 16 | import java.io.IOException; 17 | 18 | public class SysSecurityFilter extends AbstractSecurityInterceptor implements Filter { 19 | 20 | @Autowired 21 | private SysSecurityMetadataSource sysSecurityMetadataSource; 22 | 23 | public SysSecurityFilter(SysSecurityMetadataSource sysSecurityMetadataSource) { 24 | this.sysSecurityMetadataSource = sysSecurityMetadataSource; 25 | } 26 | 27 | 28 | @Autowired 29 | public void setSysAccessDecisionManager(SysAccessDecisionManager sysAccessDecisionManager) { 30 | super.setAccessDecisionManager(sysAccessDecisionManager); 31 | } 32 | 33 | 34 | @Override 35 | public void init(FilterConfig filterConfig) throws ServletException { 36 | 37 | } 38 | 39 | @Override 40 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { 41 | 42 | FilterInvocation fi = new FilterInvocation(request, response, chain); 43 | invoke(fi); 44 | } 45 | 46 | 47 | public void invoke(FilterInvocation fi) throws IOException, ServletException { 48 | //fi里面有一个被拦截的url 49 | //里面调用MyInvocationSecurityMetadataSource的getAttributes(Object object)这个方法获取fi对应的所有权限 50 | //再调用MyAccessDecisionManager的decide方法来校验用户的权限是否足够 51 | InterceptorStatusToken token = super.beforeInvocation(fi); 52 | try { 53 | //执行下一个拦截器 54 | fi.getChain().doFilter(fi.getRequest(), fi.getResponse()); 55 | } finally { 56 | super.afterInvocation(token, null); 57 | } 58 | } 59 | 60 | @Override 61 | public void destroy() { 62 | 63 | } 64 | 65 | @Override 66 | public Class getSecureObjectClass() { 67 | return FilterInvocation.class; 68 | } 69 | 70 | @Override 71 | public SecurityMetadataSource obtainSecurityMetadataSource() { 72 | return this.sysSecurityMetadataSource; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/SysMenuService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service; 2 | 3 | import space.zero.business.module.sys.model.SysMenu; 4 | import space.zero.business.module.sys.param.response.RouterTree; 5 | import space.zero.business.module.sys.param.response.SysMenuTree; 6 | import space.zero.core.service.Service; 7 | 8 | import java.util.List; 9 | 10 | 11 | /** 12 | * Created by PG_shen on 2018/03/08. 13 | */ 14 | public interface SysMenuService extends Service { 15 | List getChildren(String parentId); 16 | 17 | SysMenuTree getSysMenuTree(); 18 | 19 | List getMenuByRoles(List roleIds); 20 | 21 | String getButtonByRolesAndParentId(List roleIds, String parentId); 22 | } 23 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/SysRoleMenuService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service; 2 | 3 | import org.apache.ibatis.annotations.Select; 4 | import space.zero.business.module.sys.model.SysRoleMenu; 5 | import space.zero.core.service.Service; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/08. 12 | */ 13 | public interface SysRoleMenuService extends Service { 14 | List findAllByRoleId(String roleId); 15 | 16 | List findAuthList(String roleID); 17 | 18 | List findMenuList(String roleId); 19 | 20 | List findButtonList(String roleId, String parentId); 21 | 22 | List getPermsByRoles(); 23 | } 24 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/SysRoleService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service; 2 | 3 | import space.zero.business.module.sys.model.SysRole; 4 | import space.zero.business.module.sys.param.response.RoleListResponse; 5 | import space.zero.core.service.Service; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/08. 12 | */ 13 | public interface SysRoleService extends Service { 14 | 15 | boolean roleAuth(String roleId, List menus); 16 | 17 | List findAuthList(String roleID); 18 | 19 | List findRoleListForAuth(); 20 | } 21 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/SysUserRoleService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service; 2 | 3 | import space.zero.business.module.sys.model.SysRole; 4 | import space.zero.business.module.sys.model.SysUserRole; 5 | import space.zero.core.service.Service; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Created by PG_shen on 2018/03/08. 12 | */ 13 | public interface SysUserRoleService extends Service { 14 | void addRoles(String userId, List roleIds); 15 | 16 | List getRolesByUserId(String userId); 17 | 18 | List getRoleByUserId(String userId); 19 | 20 | void deleteAllRolesByUserId(String userId); 21 | 22 | void updateRoles(String userId, List roleIds); 23 | } 24 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service; 2 | 3 | import org.springframework.security.core.userdetails.UserDetails; 4 | import org.springframework.security.core.userdetails.UserDetailsService; 5 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 6 | import space.zero.business.module.sys.model.SysUser; 7 | import space.zero.core.service.Service; 8 | 9 | import java.util.List; 10 | 11 | 12 | /** 13 | * Created by PG_shen on 2018/03/08. 14 | */ 15 | public interface SysUserService extends Service,UserDetailsService { 16 | UserDetails loadUserByUsername(String username) throws UsernameNotFoundException; 17 | SysUser save(SysUser data); 18 | SysUser update(SysUser data); 19 | List findUserRoleList(String userID); 20 | } 21 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/impl/SysRoleMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | import space.zero.business.module.sys.dao.SysRoleMenuMapper; 6 | import space.zero.business.module.sys.model.SysRoleMenu; 7 | import space.zero.business.module.sys.model.SysUserDetails; 8 | import space.zero.business.module.sys.service.SysRoleMenuService; 9 | import space.zero.business.module.sys.service.SysUserRoleService; 10 | import space.zero.common.keyGenerator.KeyGenerator; 11 | import space.zero.common.utils.StringUtils; 12 | import space.zero.core.service.AbstractDeleteFlagService; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import javax.annotation.Resource; 17 | import java.sql.Timestamp; 18 | import java.util.*; 19 | 20 | 21 | /** 22 | * Created by PG_shen on 2018/03/08. 23 | */ 24 | @Service 25 | @Transactional 26 | public class SysRoleMenuServiceImpl extends AbstractDeleteFlagService implements SysRoleMenuService { 27 | @Resource 28 | private SysRoleMenuMapper sysRoleMenuMapper; 29 | @Autowired 30 | private SysUserRoleService sysUserRoleService; 31 | @Autowired 32 | private KeyGenerator keyGenerator; 33 | 34 | public List findAllByRoleId(String roleId){ 35 | if (!StringUtils.isBlank(roleId) && !StringUtils.isEmpty(roleId)) { 36 | // return sysRoleMenuMapper.findAllByRoleId(roleId); 37 | return super.findBy("roleId",roleId); 38 | } 39 | 40 | return null; 41 | } 42 | 43 | public List findAuthList(String roleId){ 44 | return sysRoleMenuMapper.findAuthByRoleId(roleId); 45 | } 46 | 47 | public List findMenuList(String roleId){ 48 | List menuList = sysRoleMenuMapper.findMenuByRoleId(roleId); 49 | return menuList; 50 | } 51 | 52 | public List findButtonList(String roleId, String parentId){ 53 | return sysRoleMenuMapper.findButtonByParentId(roleId, parentId); 54 | } 55 | 56 | /** 57 | * 获取当前用户的权限列表 58 | * @return perms 59 | */ 60 | @Override 61 | public List getPermsByRoles() { 62 | SysUserDetails sysUserDetails = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 63 | List roles = sysUserRoleService.getRoleByUserId(sysUserDetails.getUser().getId()); 64 | Set tmp = new HashSet<>(); 65 | for (String roleId : roles) { 66 | List permsList = sysRoleMenuMapper.getPermsByRoleId(roleId); 67 | if (permsList.size() > 0) { 68 | tmp.addAll(new HashSet<>(permsList)); 69 | } 70 | } 71 | List perms; 72 | if (tmp.size() > 0) { 73 | perms = new ArrayList<>(tmp); 74 | }else { 75 | perms = new ArrayList<>(); 76 | } 77 | return perms; 78 | } 79 | 80 | @Override 81 | public boolean preInsert(SysRoleMenu data) { 82 | if (StringUtils.isBlank(data.getId())) { 83 | data.setId(keyGenerator.getNext()); 84 | } 85 | data.setCreatedTime(new Timestamp(new Date().getTime())); 86 | return super.preInsert(data); 87 | } 88 | 89 | @Override 90 | public boolean preUpdate(SysRoleMenu data){ 91 | SysRoleMenu sysRole = findById(data.getId()); 92 | data.setCreatedTime(sysRole.getCreatedTime()); 93 | return super.preUpdate(data); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/service/impl/SysUserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import space.zero.business.module.sys.dao.SysUserRoleMapper; 5 | import space.zero.business.module.sys.model.SysRole; 6 | import space.zero.business.module.sys.model.SysUserRole; 7 | import space.zero.business.module.sys.service.SysUserRoleService; 8 | import space.zero.common.keyGenerator.KeyGenerator; 9 | import space.zero.common.utils.StringUtils; 10 | import space.zero.core.service.AbstractDeleteFlagService; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import javax.annotation.Resource; 15 | import java.sql.Timestamp; 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | 20 | /** 21 | * Created by PG_shen on 2018/03/08. 22 | */ 23 | @Service 24 | @Transactional 25 | public class SysUserRoleServiceImpl extends AbstractDeleteFlagService implements SysUserRoleService { 26 | @Resource 27 | private SysUserRoleMapper sysUserRoleMapper; 28 | @Autowired 29 | private KeyGenerator keyGenerator; 30 | 31 | /** 32 | * 给用户分配角色 33 | * @param userId 34 | * @param roleIds 35 | */ 36 | @Transactional 37 | public void addRoles(String userId, List roleIds) { 38 | if (roleIds != null && roleIds.size()>0){ 39 | for(String tmp : roleIds) { 40 | SysUserRole userRole = new SysUserRole(); 41 | userRole.setUserId(userId); 42 | userRole.setRoleId(tmp); 43 | userRole.setCreatedTime(new Timestamp(new Date().getTime())); 44 | userRole.setUpdateTime(new Timestamp(new Date().getTime())); 45 | userRole.setIsDelete("0"); 46 | this.save(userRole); 47 | } 48 | } 49 | } 50 | 51 | public List getRolesByUserId(String userId) { 52 | return sysUserRoleMapper.findSysRolesByUserId(userId); 53 | } 54 | 55 | public List getRoleByUserId(String userId){ 56 | return sysUserRoleMapper.findRolesByUserId(userId); 57 | } 58 | 59 | public void deleteAllRolesByUserId(String userId) { 60 | sysUserRoleMapper.deleteByUserId(userId); 61 | } 62 | 63 | /** 64 | * 更新用户角色 65 | * @param userId 66 | * @param roleIds 67 | */ 68 | @Transactional 69 | public void updateRoles(String userId, List roleIds) { 70 | deleteAllRolesByUserId(userId); 71 | addRoles(userId, roleIds); 72 | } 73 | 74 | @Override 75 | public boolean preInsert(SysUserRole data) { 76 | if (StringUtils.isBlank(data.getId())) { 77 | data.setId(keyGenerator.getNext()); 78 | } 79 | data.setCreatedTime(new Timestamp(new Date().getTime())); 80 | return super.preInsert(data); 81 | } 82 | 83 | @Override 84 | public boolean preUpdate(SysUserRole data){ 85 | SysUserRole sysRole = findById(data.getId()); 86 | data.setCreatedTime(sysRole.getCreatedTime()); 87 | return super.preUpdate(data); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /zero-business/src/main/java/space/zero/business/module/sys/web/SysUserRoleController.java: -------------------------------------------------------------------------------- 1 | package space.zero.business.module.sys.web; 2 | 3 | import space.zero.business.module.sys.model.SysMenu; 4 | import space.zero.business.module.sys.param.request.CondRequest; 5 | import space.zero.core.result.Result; 6 | import space.zero.core.result.ResultGenerator; 7 | import space.zero.business.module.sys.model.SysUserRole; 8 | import space.zero.business.module.sys.service.SysUserRoleService; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by PG_shen on 2018/03/08. 18 | */ 19 | @RestController 20 | @RequestMapping("/sys/user/role") 21 | public class SysUserRoleController { 22 | @Resource 23 | private SysUserRoleService sysUserRoleService; 24 | 25 | @PostMapping 26 | public Result add(@RequestBody SysUserRole sysUserRole) { 27 | SysUserRole tmp = sysUserRoleService.save(sysUserRole); 28 | return ResultGenerator.genSuccessResult(tmp); 29 | } 30 | 31 | @DeleteMapping("/{id}") 32 | public Result delete(@PathVariable String id) { 33 | sysUserRoleService.deleteById(id); 34 | return ResultGenerator.genSuccessResult(); 35 | } 36 | 37 | @PutMapping 38 | public Result update(@RequestBody SysUserRole sysUserRole) { 39 | SysUserRole tmp = sysUserRoleService.update(sysUserRole); 40 | return ResultGenerator.genSuccessResult(tmp); 41 | } 42 | 43 | @GetMapping("/{id}") 44 | public Result detail(@PathVariable String id) { 45 | SysUserRole sysUserRole = sysUserRoleService.findById(id); 46 | return ResultGenerator.genSuccessResult(sysUserRole); 47 | } 48 | 49 | // @GetMapping 50 | // public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 51 | // PageHelper.startPage(page, size); 52 | // List list = sysUserRoleService.findAll(); 53 | // PageInfo pageInfo = new PageInfo(list); 54 | // return ResultGenerator.genSuccessResult(pageInfo); 55 | // } 56 | 57 | @PostMapping("/list") 58 | public Result list(@RequestBody CondRequest condRequest){ 59 | PageHelper.startPage(condRequest.getPage(), condRequest.getSize(), condRequest.getOrder()); 60 | List list = sysUserRoleService.findBy(condRequest.getCond()); 61 | PageInfo pageInfo = new PageInfo(list); 62 | pageInfo.setOrderBy(condRequest.getOrder()); 63 | return ResultGenerator.genSuccessResult(pageInfo); 64 | } 65 | 66 | @GetMapping("/page") 67 | public Result page(){ 68 | return ResultGenerator.genSuccessResult(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | # 数据源 3 | datasource: 4 | url: jdbc:mysql://localhost:3306/zero?useUnicode=true&characterEncoding=utf8&useSSL=false 5 | username: root 6 | password: Pass1108! 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | driver-class-name: com.mysql.jdbc.Driver 9 | druid: 10 | filters: stat,wall,log4j 11 | max-active: 20 12 | initial-size: 1 13 | max-wait: 60000 14 | pool-prepared-statements: true 15 | max-pool-prepared-statement-per-connection-size: 20 16 | connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 17 | min-idle: 1 18 | time-between-eviction-runs-millis: 60000 19 | min-evictable-idle-time-millis: 300000 20 | validation-query: select 1 from dual 21 | test-while-idle: true 22 | test-on-borrow: false 23 | test-on-return: false 24 | http: 25 | multipart: 26 | max-file-size: 1Mb 27 | 28 | server: 29 | port: 8088 30 | 31 | website: 32 | global: 33 | upload: 34 | location: /home/pipix/zero/upload/ 35 | # host: http://111.230.146.130:8088/ 36 | host: http://127.0.0.1:8088/ -------------------------------------------------------------------------------- /zero-business/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PGshen/non-zero/ff4873c64a73bada06f080555ab74383b325c5d9/zero-business/src/main/resources/application-prod.yml -------------------------------------------------------------------------------- /zero-business/src/main/resources/application-test.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PGshen/non-zero/ff4873c64a73bada06f080555ab74383b325c5d9/zero-business/src/main/resources/application-test.yml -------------------------------------------------------------------------------- /zero-business/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | mvc: 5 | # 404 交给异常处理器处理 6 | throw-exception-if-no-handler-found: true 7 | # 静态资源配置,目前写在WebMvcConfigurer.java 8 | # static-path-pattern: /** 9 | resources: 10 | add-mappings: false 11 | # 静态资源配置,目前写在WebMvcConfigurer.java 12 | # static-locations: file:${} 13 | http: 14 | # 编码 15 | encoding: 16 | force: true 17 | charset: UTF-8 18 | enabled: true 19 | 20 | # 服务 21 | server: 22 | tomcat: 23 | uri-encoding: UTF-8 24 | # session超时 25 | session: 26 | timeout: 3600000 27 | 28 | # 日志 29 | logging: 30 | config: classpath:config/logback-spring.xml 31 | 32 | # 自定义配置 33 | app: 34 | global: 35 | charset: UTF-8 36 | session: 37 | headerTokenName: x-auth-token -------------------------------------------------------------------------------- /zero-business/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ __ __ __ __ 2 | |__| |__ | | / \ | | / \ |__) | | \ 3 | | | |___ |___ |___ \__/ . |/\| \__/ | \ |___ |__/ 4 | ' -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/base/BaseOrganizationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteAboutUsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteBaseInfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteCarouselMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteClassMateMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteContactUsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteCustomerCaseMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteDigitizationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteFirstScreenMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteHistoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteNewsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteRecruitMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/official/website/OfficialWebsiteSolutionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/BaseOrganizationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysLogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysMenuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysRoleMenuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/SysUserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /zero-business/src/main/resources/mapper/sys/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /zero-business/src/test/java/space/zero/business/Main.java: -------------------------------------------------------------------------------- 1 | package space.zero.business; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by PG_shen 7 | * Date : 3/10/18 8 | * Time : 8:16 PM 9 | */ 10 | public class Main { 11 | public static void main(String[] args) { 12 | Scanner sc = new Scanner(System.in); 13 | int number = sc.nextInt(); 14 | int count = count(number); 15 | System.out.println(count); 16 | } 17 | public static boolean isPrimeNumber(int N){ 18 | if( N < 2 ) return false; 19 | 20 | for( int i = 2 ; i*i <= N; i++){ 21 | 22 | if( N % i == 0) return false; 23 | 24 | } 25 | return true; 26 | } 27 | 28 | public static int count(int N){ 29 | int count = 0; 30 | for (int i = 2; i < N; i++){ 31 | if (isPrimeNumber(i)){ 32 | for (int j = 2; j < N ; j++){ 33 | //避免重复 34 | if(j==i || (N-i-j ==i) || (N-i-j ==j)) 35 | continue; 36 | if (isPrimeNumber(j) && isPrimeNumber(N - i - j)){ 37 | count++; 38 | } 39 | } 40 | } 41 | } 42 | return count; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zero-business/src/test/java/space/zero/business/Tester.java: -------------------------------------------------------------------------------- 1 | package space.zero.business; 2 | 3 | 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.annotation.Rollback; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import org.springframework.transaction.annotation.Transactional; 9 | import space.zero.business.ZeroApplication; 10 | 11 | /** 12 | * 单元测试继承该类即可 13 | */ 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest(classes = ZeroApplication.class) 16 | @Transactional 17 | @Rollback 18 | public abstract class Tester {} 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/annotation/JsonBeanRequestParam.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 用于标注使用JSONlib转换的实体类参数
7 | * 用法 :methodName(@JsonBeanRequestParam BeanClass data,...) 8 | * 9 | * @author jiabin 10 | * 11 | */ 12 | @Target({ ElementType.PARAMETER }) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface JsonBeanRequestParam { 16 | /** 17 | * classMap 属性索引列表,必须和 classList的class 位置对应 18 | * @return 19 | */ 20 | String[] classKeys() default {}; 21 | 22 | /** 23 | * classMap 属性对应实体类,必须和classKeys的key 位置对应 24 | * @return 25 | */ 26 | Class[] classList() default {}; 27 | } 28 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/dataBind/NullableJsonNodeParser.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.dataBind; 2 | 3 | import com.fasterxml.jackson.databind.JsonNode; 4 | 5 | public class NullableJsonNodeParser{ 6 | 7 | public static JsonNode getJsonNode(String key, JsonNode jsonNode){ 8 | String[] keys = splitKeys(key); 9 | JsonNode temp=jsonNode; 10 | for(String keyItem:keys){ 11 | temp=temp.get(keyItem); 12 | if(temp==null){ 13 | break; 14 | } 15 | } 16 | return temp; 17 | } 18 | 19 | public static String getString(String key, JsonNode jsonNode){ 20 | String[] keys = splitKeys(key); 21 | JsonNode temp=jsonNode; 22 | for(String keyItem:keys){ 23 | temp=temp.get(keyItem); 24 | if(temp==null){ 25 | break; 26 | } 27 | } 28 | 29 | return temp!=null?temp.asText():null; 30 | } 31 | 32 | public static Double getDouble(String key,JsonNode jsonNode){ 33 | String[] keys = splitKeys(key); 34 | JsonNode temp=jsonNode; 35 | for(String keyItem:keys){ 36 | temp=temp.get(keyItem); 37 | if(temp==null){ 38 | break; 39 | } 40 | } 41 | return temp!=null?temp.asDouble():null; 42 | } 43 | 44 | protected static String[] splitKeys(String key){ 45 | if(key.contains(".")){ 46 | return key.split("\\."); 47 | }else{ 48 | return new String[]{key}; 49 | } 50 | 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/dateFormat/StandardDateFormat.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.dateFormat; 2 | 3 | import java.text.ParsePosition; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * 用于转换 'yyyy-MM-dd hh:mm:ss'格玩玩玩式 9 | * @author jiabin 10 | * 11 | */ 12 | public class StandardDateFormat extends SimpleDateFormat { 13 | private static final long serialVersionUID = 1L; 14 | public final static String FORMAT_DEFAULT="yyyy-MM-dd HH:mm:ss"; 15 | 16 | public StandardDateFormat(){ 17 | super(FORMAT_DEFAULT); 18 | } 19 | 20 | 21 | @Override 22 | public Date parse(String source, ParsePosition pos) { 23 | // TODO Auto-generated method stub 24 | if (source!=null&&source.trim().length() == 10) { 25 | source+=" 00:00:00"; 26 | } 27 | return super.parse(source, pos); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/module/DateModule.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.module; 2 | 3 | import com.fasterxml.jackson.databind.module.SimpleModule; 4 | import space.zero.common.jsonLib.serialize.DateDeserializer; 5 | import space.zero.common.jsonLib.serialize.DateSerializer; 6 | 7 | import java.util.Date; 8 | 9 | public class DateModule extends SimpleModule { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public DateModule() { 14 | super(); 15 | addSerializer(Date.class, new DateSerializer()); 16 | addDeserializer(Date.class, new DateDeserializer()); 17 | } 18 | } -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/resolver/JsonBeanArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.resolver; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.core.MethodParameter; 6 | import org.springframework.web.bind.support.WebDataBinderFactory; 7 | import org.springframework.web.context.request.NativeWebRequest; 8 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 9 | import org.springframework.web.method.support.ModelAndViewContainer; 10 | import space.zero.common.jsonLib.annotation.JsonBeanRequestParam; 11 | import space.zero.common.jsonLib.mapper.JsonMapper; 12 | 13 | import java.lang.reflect.ParameterizedType; 14 | import java.lang.reflect.Type; 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | 21 | public class JsonBeanArgumentResolver implements HandlerMethodArgumentResolver { 22 | private Logger logger = LoggerFactory.getLogger(getClass()); 23 | 24 | @Override 25 | public boolean supportsParameter(MethodParameter parameter) { 26 | // TODO Auto-generated method stub 27 | if(parameter.hasParameterAnnotation(JsonBeanRequestParam.class)){ 28 | return true; 29 | } 30 | return false; 31 | } 32 | 33 | @Override 34 | public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, 35 | NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 36 | // TODO Auto-generated method stub 37 | Class entityClass = parameter.getParameterType(); 38 | JsonBeanRequestParam jsonAnno = parameter.getParameterAnnotation(JsonBeanRequestParam.class); 39 | 40 | String[] classKeys=jsonAnno.classKeys(); 41 | Class[] classList = jsonAnno.classList(); 42 | Map classMap=new HashMap(); 43 | 44 | for(int i=0;i { 15 | 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | public DateDeserializer() { 20 | super(Date.class); 21 | // TODO Auto-generated constructor stub 22 | } 23 | 24 | 25 | @Override 26 | public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { 27 | // TODO Auto-generated method stub 28 | 29 | JsonToken currentToken = p.getCurrentToken(); 30 | if (currentToken == JsonToken.VALUE_STRING) { 31 | String dateAsString = p.getText().trim(); 32 | StandardDateFormat sdf = new StandardDateFormat(); 33 | try { 34 | return sdf.parse(dateAsString); 35 | } catch (ParseException e) { 36 | // TODO Auto-generated catch block 37 | e.printStackTrace(); 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/jsonLib/serialize/DateSerializer.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.jsonLib.serialize; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerationException; 4 | import com.fasterxml.jackson.core.JsonGenerator; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; 7 | 8 | import java.io.IOException; 9 | import java.text.SimpleDateFormat; 10 | import java.util.Date; 11 | 12 | public class DateSerializer extends StdScalarSerializer { 13 | 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | 18 | public DateSerializer() { 19 | super(Date.class); 20 | // TODO Auto-generated constructor stub 21 | } 22 | 23 | @Override 24 | public void serialize(Date date, 25 | JsonGenerator jsonGenerator, 26 | SerializerProvider provider) throws IOException, JsonGenerationException { 27 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 28 | jsonGenerator.writeString(sdf.format(date)); 29 | } 30 | } -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/keyGenerator/KeyGenerator.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.keyGenerator; 2 | 3 | public interface KeyGenerator { 4 | T getNext(String type); 5 | T getNext(); 6 | } 7 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/keyGenerator/TimeFormatKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.keyGenerator; 2 | 3 | import space.zero.common.utils.DateUtils; 4 | 5 | import java.security.SecureRandom; 6 | import java.util.Date; 7 | import java.util.Random; 8 | 9 | 10 | 11 | public class TimeFormatKeyGenerator implements KeyGenerator{ 12 | protected Random random; 13 | 14 | public TimeFormatKeyGenerator(){ 15 | random=new SecureRandom(); 16 | random.setSeed((new Date()).getTime()); 17 | } 18 | 19 | 20 | @Override 21 | public String getNext(String type) { 22 | // TODO Auto-generated method stub 23 | return type+":"+getTimeString()+getRandomNumber(); 24 | } 25 | 26 | @Override 27 | public String getNext() { 28 | // TODO Auto-generated method stub 29 | return getTimeString()+getRandomNumber(); 30 | } 31 | 32 | protected String getTimeString(){ 33 | return DateUtils.formatDate(new Date(), "yyyyMMddHHmmssSSS"); 34 | } 35 | 36 | protected String getRandomNumber(){ 37 | return String.format("%02d",random.nextInt(100))+String.format("%02d",random.nextInt(100)); 38 | } 39 | public static void main(String[] args) { 40 | TimeFormatKeyGenerator ss=new TimeFormatKeyGenerator(); 41 | for(int i =0;i<10;i++){ 42 | System.out.println(ss.getNext()); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/keyGenerator/TimeHexKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.keyGenerator; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.security.SecureRandom; 5 | import java.util.Date; 6 | import java.util.Random; 7 | 8 | public class TimeHexKeyGenerator implements KeyGenerator{ 9 | protected String pid; 10 | protected Random random; 11 | 12 | public TimeHexKeyGenerator(){ 13 | initPidStr(); 14 | random=new SecureRandom(); 15 | random.setSeed((new Date()).getTime()); 16 | } 17 | 18 | protected void initPidStr(){ 19 | pid = ManagementFactory.getRuntimeMXBean().getName(); 20 | int indexOf = pid.indexOf('@'); 21 | if (indexOf > 0) 22 | { 23 | pid = pid.substring(0, indexOf); 24 | } 25 | pid=Long.toHexString(Long.valueOf(pid)); 26 | while(pid.length()<4){ 27 | pid=0+pid; 28 | } 29 | } 30 | 31 | @Override 32 | public String getNext(String type) { 33 | // TODO Auto-generated method stub 34 | return getTimeString()+getPid()+getThreadId()+getRandomNumber(); 35 | } 36 | 37 | @Override 38 | public String getNext() { 39 | // TODO Auto-generated method stub 40 | return getTimeString()+getPid()+getThreadId()+getRandomNumber(); 41 | } 42 | 43 | protected String getTimeString(){ 44 | Long now = (new Date()).getTime(); 45 | return Long.toHexString(now).toUpperCase(); 46 | } 47 | 48 | protected String getThreadId(){ 49 | return String.format("%04d", Thread.currentThread().getId()); 50 | } 51 | 52 | protected String getPid(){ 53 | return pid; 54 | } 55 | 56 | protected String getRandomNumber(){ 57 | return String.format("%02d",random.nextInt(100))+String.format("%03d",random.nextInt(1000)); 58 | } 59 | 60 | public static void main(String[] args) { 61 | TimeHexKeyGenerator ss=new TimeHexKeyGenerator(); 62 | for(int i =0;i<10;i++){ 63 | System.out.println(ss.getNext()); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/mail/MailContentTypeEnum.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.mail; 2 | 3 | /** 4 | * Created by IntelliJ IDEA 5 | * User: pipix 6 | * Date: 8/19/18 7 | * TIME: 11:26 AM 8 | */ 9 | public enum MailContentTypeEnum { 10 | HTML("text/html;charset=UTF-8"), 11 | TEXT("text"); 12 | 13 | private String type; 14 | 15 | MailContentTypeEnum(String type){ 16 | this.type = type; 17 | } 18 | 19 | public String getType(){ 20 | return type; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/mail/MailEntity.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.mail; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Created by IntelliJ IDEA 9 | * User: pipix 10 | * Date: 8/19/18 11 | * TIME: 11:18 AM 12 | */ 13 | public class MailEntity implements Serializable { 14 | // 邮件服务器 15 | private String smtpService; 16 | // 邮件服务器端口 17 | private String smtpPort; 18 | // 发送邮箱 19 | private String mailAddress; 20 | // 发送邮箱密码 21 | private String mailStmpPassword; 22 | // 邮件标题 23 | private String title; 24 | // 邮件内容 25 | private String content; 26 | // 邮件类型 27 | private String contentType; 28 | // 收件邮箱列表 29 | private List targetMailAddress = new ArrayList<>(); 30 | 31 | public String getSmtpService() { 32 | return smtpService; 33 | } 34 | 35 | public void setSmtpService(String smtpService) { 36 | this.smtpService = smtpService; 37 | } 38 | 39 | public String getSmtpPort() { 40 | return smtpPort; 41 | } 42 | 43 | public void setSmtpPort(String smtpPort) { 44 | this.smtpPort = smtpPort; 45 | } 46 | 47 | public String getMailAddress() { 48 | return mailAddress; 49 | } 50 | 51 | public void setMailAddress(String mailAddress) { 52 | this.mailAddress = mailAddress; 53 | } 54 | 55 | public String getMailStmpPassword() { 56 | return mailStmpPassword; 57 | } 58 | 59 | public void setMailStmpPassword(String mailStmpPassword) { 60 | this.mailStmpPassword = mailStmpPassword; 61 | } 62 | 63 | public String getTitle() { 64 | return title; 65 | } 66 | 67 | public void setTitle(String title) { 68 | this.title = title; 69 | } 70 | 71 | public String getContent() { 72 | return content; 73 | } 74 | 75 | public void setContent(String content) { 76 | this.content = content; 77 | } 78 | 79 | public String getContentType() { 80 | return contentType; 81 | } 82 | 83 | public void setContentType(String contentType) { 84 | this.contentType = contentType; 85 | } 86 | 87 | public List gettargetMailAddress() { 88 | return targetMailAddress; 89 | } 90 | 91 | public void settargetMailAddress(List targetMailAddress) { 92 | this.targetMailAddress = targetMailAddress; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/utils/FileUploadEnum.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.utils; 2 | 3 | /** 4 | * Created by PG_shen on 9/27/18 5 | */ 6 | public enum FileUploadEnum { 7 | AVATAR, 8 | FILE, 9 | CAROUSEL, 10 | FIRSTSCREEN, 11 | NEWS, 12 | PRODUCT, 13 | SOLUTION, 14 | CUSTOMERCASE, 15 | CONTACTUS, 16 | ABOUTUS 17 | } -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import java.io.BufferedReader; 5 | import java.io.InputStreamReader; 6 | import java.net.HttpURLConnection; 7 | import java.net.URL; 8 | import java.util.regex.Matcher; 9 | import java.util.regex.Pattern; 10 | 11 | public class IpUtils { 12 | 13 | 14 | /** 15 | * 获得用户远程地址 16 | */ 17 | public static String getRemoteAddr(HttpServletRequest request){ 18 | String remoteAddr = request.getHeader("X-Real-IP"); 19 | if (StringUtils.isNotBlank(remoteAddr)) { 20 | remoteAddr = request.getHeader("X-Forwarded-For"); 21 | }else if (StringUtils.isNotBlank(remoteAddr)) { 22 | remoteAddr = request.getHeader("Proxy-Client-IP"); 23 | }else if (StringUtils.isNotBlank(remoteAddr)) { 24 | remoteAddr = request.getHeader("WL-Proxy-Client-IP"); 25 | } 26 | return remoteAddr != null ? remoteAddr : request.getRemoteAddr(); 27 | } 28 | 29 | /** 30 | * 获取请求类型(是否ajax) 31 | * @param request 32 | * @return 33 | */ 34 | public static String getRequestType(HttpServletRequest request){ 35 | if (request.getHeader("x-requested-with") != null 36 | && request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) { 37 | return "Ajax"; 38 | }else{ 39 | return "SyncRequest"; 40 | } 41 | } 42 | 43 | /** 44 | * 获取主机外网IP 45 | * 这获取方法有些鸡肋啊,哈哈哈... 46 | * @return 47 | */ 48 | public static String getV4IP() { 49 | String ip = ""; 50 | String chinaz = "http://ip.chinaz.com/"; 51 | 52 | String inputLine = ""; 53 | String read = ""; 54 | try { 55 | URL url = new URL(chinaz); 56 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); 57 | BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); 58 | while ((read = in.readLine()) != null) { 59 | inputLine += read; 60 | } 61 | 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | 66 | Pattern p = Pattern.compile("\\
(.*?)\\<\\/dd>"); 67 | Matcher m = p.matcher(inputLine); 68 | if(m.find()){ 69 | String ipstr = m.group(1); 70 | System.out.println(ipstr); 71 | } 72 | return ip; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/utils/MIMEType.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.utils; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/8/18 6 | * Time : 4:53 PM 7 | */ 8 | public class MIMEType { 9 | public static final String APPLICATION_JSON="application/json"; 10 | public static final String MULTIPART_FORM_DATA="multipart/form-data"; 11 | } 12 | -------------------------------------------------------------------------------- /zero-common/src/main/java/space/zero/common/utils/PropertiesUtils.java: -------------------------------------------------------------------------------- 1 | package space.zero.common.utils; 2 | 3 | import java.util.Locale; 4 | import java.util.ResourceBundle; 5 | 6 | /** 7 | * Created by IntelliJ IDEA 8 | * User: pipix 9 | * Date: 8/19/18 10 | * TIME: 11:30 AM 11 | */ 12 | public class PropertiesUtils { 13 | private final ResourceBundle resourceBundle; 14 | private final String fileName; 15 | 16 | public PropertiesUtils(String fileName){ 17 | this.fileName = fileName; 18 | Locale locale = new Locale("zh", "CN"); 19 | this.resourceBundle = ResourceBundle.getBundle(this.fileName, locale); 20 | } 21 | 22 | public String getValue(String key){ 23 | String value = this.resourceBundle.getString(key); 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /zero-common/src/main/resources/mail.properties: -------------------------------------------------------------------------------- 1 | #邮箱服务器地址 2 | mail.smtp.service = smtp.126.com 3 | #发送邮箱 4 | mail.address = email@126.com 5 | #发送邮箱的授权码,非密码,需开启第三方客户端登录 6 | mail.password = pass 7 | #显示在邮箱的发送人名称,直接使用中文会有乱码,先转成ascii 8 | mail.nickName = JavaMail\u4e2d\u6587\u6d4b\u8bd5 9 | #收件邮箱,多个邮箱用逗号分割 10 | mail.target.address = email1@qq.com,email2@126.com,email3@gmail.com -------------------------------------------------------------------------------- /zero-common/src/test/java/space/zero/common/Test.java: -------------------------------------------------------------------------------- 1 | package space.zero.common; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/17/18 6 | * Time : 1:38 PM 7 | */ 8 | public class Test { 9 | } 10 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/constant/Constant.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.constant; 2 | 3 | /** 4 | * 项目常量 5 | */ 6 | public final class Constant { 7 | public static final String BASE_PACKAGE = "space.zero.business.module.official.website";//项目基础包名称,根据自己公司的项目修改 8 | public static final String CORE_PACKAGE = "space.zero.core"; 9 | 10 | public static final String MODEL_PACKAGE = BASE_PACKAGE + ".model";//Model所在包 11 | public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".dao";//Mapper所在包 12 | public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".service";//Service所在包 13 | public static final String SERVICE_IMPL_PACKAGE = SERVICE_PACKAGE + ".impl";//ServiceImpl所在包 14 | public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".web";//Controller所在包 15 | 16 | public static final String MAPPER_INTERFACE_REFERENCE = CORE_PACKAGE + ".mapper.Mapper";//Mapper插件基础接口的完全限定名 17 | 18 | public static final String DELETE_FLAG_FALSE = "0"; 19 | public static final String DELETE_FLAG_TRUE = "1"; 20 | 21 | public static final String ENABLE_FLAG_FALSE = "0"; 22 | public static final String ENABLE_FLAG_TRUE = "1"; 23 | 24 | public static final String WEBSITE_NEWS_STATUS_DELETED = "2"; 25 | public static final String WEBSITE_NEWS_STATUS_PUBLISHED = "1"; 26 | public static final String WEBSITE_NEWS_STATUS_DRAFT = "0"; 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/exception/ServiceException.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.exception; 2 | 3 | /** 4 | * 服务(业务)异常如“ 账号或密码错误 ”,该异常只做INFO级别的日志记录 @see WebMvcConfigurer 5 | */ 6 | public class ServiceException extends RuntimeException { 7 | public ServiceException() { 8 | } 9 | 10 | public ServiceException(String message) { 11 | super(message); 12 | } 13 | 14 | public ServiceException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/mapper/Mapper.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.mapper; 2 | 3 | import tk.mybatis.mapper.common.BaseMapper; 4 | import tk.mybatis.mapper.common.ConditionMapper; 5 | import tk.mybatis.mapper.common.IdsMapper; 6 | import tk.mybatis.mapper.common.special.InsertListMapper; 7 | 8 | /** 9 | * 定制版MyBatis Mapper插件接口,如需其他接口参考官方文档自行添加。 10 | */ 11 | public interface Mapper 12 | extends 13 | BaseMapper, 14 | ConditionMapper, 15 | IdsMapper, 16 | InsertListMapper { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/model/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import javax.persistence.Transient; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | public class BaseEntity implements Serializable { 10 | public static final long serialVersionUID = 1L; 11 | @Transient 12 | @JsonIgnore 13 | protected transient String id; 14 | @Transient 15 | @JsonIgnore 16 | protected transient String isDelete; 17 | @Transient 18 | @JsonIgnore 19 | protected transient String isEnable; 20 | @Transient 21 | @JsonIgnore 22 | protected transient Date updateTime; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getIsDelete() { 33 | return isDelete; 34 | } 35 | 36 | public void setIsDelete(String isDelete) { 37 | this.isDelete = isDelete; 38 | } 39 | 40 | public String getIsEnable() { 41 | return isEnable; 42 | } 43 | 44 | public void setIsEnable(String isEnable) { 45 | this.isEnable = isEnable; 46 | } 47 | 48 | public Date getUpdateTime() { 49 | return updateTime; 50 | } 51 | 52 | public void setUpdateTime(Date updateTime) { 53 | this.updateTime = updateTime; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/result/Result.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.result; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | 6 | /** 7 | * 统一API响应结果封装 8 | */ 9 | public class Result { 10 | private int status; 11 | private int code; 12 | private String message; 13 | private Object data; 14 | private Long timestamp; 15 | 16 | // public Result(){} 17 | 18 | // public Result(){ 19 | // this.timestamp = new Date().getTime(); 20 | // } 21 | 22 | public Result setCode(ResultCode resultCode) { 23 | this.code = resultCode.code(); 24 | return this; 25 | } 26 | 27 | public int getStatus() { 28 | return status; 29 | } 30 | 31 | public Result setStatus(int status) { 32 | this.status = status; 33 | return this; 34 | } 35 | 36 | public int getCode() { 37 | return code; 38 | } 39 | 40 | public String getMessage() { 41 | return message; 42 | } 43 | 44 | public Result setMessage(String message) { 45 | this.message = message; 46 | return this; 47 | } 48 | 49 | public Object getData() { 50 | return data; 51 | } 52 | 53 | public Result setData(Object data) { 54 | this.data = data; 55 | return this; 56 | } 57 | 58 | public Long getTimestamp(){ 59 | return timestamp; 60 | } 61 | 62 | public Result setTimestamp(Long timestamp) { 63 | this.timestamp = timestamp; 64 | return this; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return JSON.toJSONString(this); 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/result/ResultCode.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.result; 2 | 3 | /** 4 | * 响应码枚举,参考HTTP状态码的语义 5 | */ 6 | public enum ResultCode { 7 | SUCCESS(20000),//成功 8 | FAIL(40000),//失败 9 | UNAUTHORIZED(40001),//未认证(签名错误) 10 | NOT_FOUND(40004),//接口不存在 11 | FORBIDDEN_INTERFACE(40003), 12 | FORBIDDEN_PAGE(40013), 13 | INTERNAL_SERVER_ERROR(50000);//服务器内部错误 14 | 15 | private final int code; 16 | 17 | ResultCode(int code) { 18 | this.code = code; 19 | } 20 | 21 | public int code() { 22 | return code; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/result/ResultGenerator.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.result; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * 响应结果生成工具 7 | */ 8 | public class ResultGenerator { 9 | private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS"; 10 | 11 | public static Result genSuccessResult() { 12 | return new Result() 13 | .setStatus(1) 14 | .setCode(ResultCode.SUCCESS) 15 | .setMessage(DEFAULT_SUCCESS_MESSAGE) 16 | .setTimestamp(new Date().getTime()); 17 | } 18 | 19 | public static Result genSuccessResult(Object data) { 20 | return new Result() 21 | .setStatus(1) 22 | .setCode(ResultCode.SUCCESS) 23 | .setMessage(DEFAULT_SUCCESS_MESSAGE) 24 | .setData(data) 25 | .setTimestamp(new Date().getTime()); 26 | } 27 | 28 | public static Result genSuccessResult(String message) { 29 | return new Result() 30 | .setStatus(1) 31 | .setCode(ResultCode.SUCCESS) 32 | .setMessage(message) 33 | .setTimestamp(new Date().getTime()); 34 | } 35 | 36 | public static Result genSuccessResult(Object data, String message){ 37 | return new Result() 38 | .setStatus(1) 39 | .setCode(ResultCode.SUCCESS) 40 | .setMessage(message) 41 | .setData(data) 42 | .setTimestamp(new Date().getTime()); 43 | } 44 | 45 | public static Result genFailResult(String message) { 46 | return new Result() 47 | .setCode(ResultCode.FAIL) 48 | .setMessage(message) 49 | .setTimestamp(new Date().getTime()); 50 | } 51 | 52 | public static Result genForbiddenInterfaceResult(Object data, String message){ 53 | return new Result() 54 | .setCode(ResultCode.FORBIDDEN_INTERFACE) 55 | .setData(data) 56 | .setMessage(message) 57 | .setTimestamp(new Date().getTime()); 58 | } 59 | 60 | public static Result genForbiddenPageResult(String message){ 61 | return new Result() 62 | .setCode(ResultCode.FORBIDDEN_PAGE) 63 | .setMessage(message) 64 | .setTimestamp(new Date().getTime()); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /zero-core/src/main/java/space/zero/core/service/Service.java: -------------------------------------------------------------------------------- 1 | package space.zero.core.service; 2 | 3 | import org.apache.ibatis.exceptions.TooManyResultsException; 4 | import tk.mybatis.mapper.entity.Condition; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * Service 层 基础接口,其他Service 接口 请继承该接口 11 | */ 12 | public interface Service { 13 | T save(T model);//持久化 14 | List save(List models);//批量持久化 15 | void deleteById(String id);//通过主鍵刪除 16 | void deleteByIds(String ids);//批量刪除 eg:ids -> “1,2,3,4” 17 | T update(T model);//更新 18 | T findById(String id);//通过ID查找 19 | List findBy(String fieldName, Object value); //通过Model中某个成员变量名称(非数据表中column的名称)查找 20 | List findBy(Map cond);//通过map 21 | // List findBy(T cond); 22 | List findByIds(String ids);//通过多个ID查找//eg:ids -> “1,2,3,4” 23 | List findByCondition(Condition condition);//根据条件查找 24 | List findAll();//获取所有 25 | /** 26 | * 根据主键获取数据回调,该方法返回false则不进行查询直接返回null 27 | * @param id 28 | * @return 29 | */ 30 | boolean preGet(Object id); 31 | 32 | void afterGet(T data); 33 | 34 | boolean preInsert(T data); 35 | 36 | void afterInsert(T data); 37 | 38 | boolean preUpdate(T data); 39 | 40 | void afterUpdate(T data); 41 | 42 | boolean preDelete(Object id); 43 | 44 | void afterDelete(Object id); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /zero-core/src/test/java/space/zero/core/Test.java: -------------------------------------------------------------------------------- 1 | package space.zero.core; 2 | 3 | /** 4 | * Created by PG_shen 5 | * Date : 3/17/18 6 | * Time : 1:39 PM 7 | */ 8 | public class Test { 9 | } 10 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/demo-user.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : Localhost 5 | Source Server Version : 50713 6 | Source Host : localhost:3306 7 | Source Database : test 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50713 11 | File Encoding : 65001 12 | 13 | Date: 2017-06-23 14:25:27 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | USE test; 19 | -- ---------------------------- 20 | -- Table structure for user 21 | -- ---------------------------- 22 | DROP TABLE IF EXISTS `user`; 23 | CREATE TABLE `user` ( 24 | `id` int(11) NOT NULL AUTO_INCREMENT, 25 | `username` varchar(255) NOT NULL, 26 | `password` varchar(255) NOT NULL, 27 | `nick_name` varchar(255) DEFAULT NULL, 28 | `sex` int(1) DEFAULT NULL, 29 | `register_date` datetime NOT NULL, 30 | `is_delete` INT(1) DEFAULT 0, 31 | `is_enable` INT(1) DEFAULT 1, 32 | `update_time` datetime, 33 | PRIMARY KEY (`id`) 34 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of user 38 | -- ---------------------------- 39 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('1', '89921218@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆', '1', '2017-06-23 14:24:23'); 40 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('2', '2@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-2', '1', '2017-06-23 14:24:23'); 41 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('3', '3@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-3', '1', '2017-06-23 14:24:23'); 42 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('4', '4@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-4', '1', '2017-06-23 14:24:23'); 43 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('5', '5@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-5', '1', '2017-06-23 14:24:23'); 44 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('6', '6@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-6', '1', '2017-06-23 14:24:23'); 45 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('7', '7@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-7', '1', '2017-06-23 14:24:23'); 46 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('8', '8@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-8', '1', '2017-06-23 14:24:23'); 47 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('9', '9@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-9', '1', '2017-06-23 14:24:23'); 48 | INSERT INTO `user`(id, username, password, nick_name, sex, register_date) VALUES ('10', '10@qq.com', '1ee04e0b1cb5af7367c80c22e42efd8b', '土豆-10', '1', '2017-06-23 14:24:23'); 49 | SET FOREIGN_KEY_CHECKS=1; 50 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/generator/template/controller-restful.ftl: -------------------------------------------------------------------------------- 1 | package ${basePackage}.web; 2 | 3 | import ${corePackage}.result.Result; 4 | import ${corePackage}.result.ResultGenerator; 5 | import ${basePackage}.model.${modelNameUpperCamel}; 6 | import ${basePackage}.service.${modelNameUpperCamel}Service; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by ${author} on ${date}. 16 | */ 17 | @RestController 18 | @RequestMapping("${baseRequestMapping}") 19 | public class ${modelNameUpperCamel}Controller { 20 | @Resource 21 | private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service; 22 | 23 | @PostMapping 24 | public Result add(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}) { 25 | ${modelNameUpperCamel} tmp = ${modelNameLowerCamel}Service.save(${modelNameLowerCamel}); 26 | return ResultGenerator.genSuccessResult(tmp); 27 | } 28 | 29 | @DeleteMapping("/{id}") 30 | public Result delete(@PathVariable String id) { 31 | ${modelNameLowerCamel}Service.deleteById(id); 32 | return ResultGenerator.genSuccessResult(); 33 | } 34 | 35 | @PutMapping 36 | public Result update(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}) { 37 | ${modelNameUpperCamel} tmp = ${modelNameLowerCamel}Service.update(${modelNameLowerCamel}); 38 | return ResultGenerator.genSuccessResult(tmp); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public Result detail(@PathVariable String id) { 43 | ${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.findById(id); 44 | return ResultGenerator.genSuccessResult(${modelNameLowerCamel}); 45 | } 46 | 47 | @GetMapping 48 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 49 | PageHelper.startPage(page, size); 50 | List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findAll(); 51 | PageInfo pageInfo = new PageInfo(list); 52 | return ResultGenerator.genSuccessResult(pageInfo); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/generator/template/controller.ftl: -------------------------------------------------------------------------------- 1 | package ${basePackage}.web; 2 | import ${corePackage}.result.Result; 3 | import ${corePackage}.result.ResultGenerator; 4 | import ${basePackage}.model.${modelNameUpperCamel}; 5 | import ${basePackage}.service.${modelNameUpperCamel}Service; 6 | import com.github.pagehelper.PageHelper; 7 | import com.github.pagehelper.PageInfo; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ${author} on ${date}. 18 | */ 19 | @RestController 20 | @RequestMapping("${baseRequestMapping}") 21 | public class ${modelNameUpperCamel}Controller { 22 | @Resource 23 | private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service; 24 | 25 | @PostMapping("/add") 26 | public Result add(${modelNameUpperCamel} ${modelNameLowerCamel}) { 27 | ${modelNameUpperCamel} tmp = ${modelNameLowerCamel}Service.save(${modelNameLowerCamel}); 28 | return ResultGenerator.genSuccessResult(tmp); 29 | } 30 | 31 | @PostMapping("/delete") 32 | public Result delete(@RequestParam Integer id) { 33 | ${modelNameLowerCamel}Service.deleteById(id); 34 | return ResultGenerator.genSuccessResult(); 35 | } 36 | 37 | @PostMapping("/update") 38 | public Result update(${modelNameUpperCamel} ${modelNameLowerCamel}) { 39 | ${modelNameUpperCamel} tmp = ${modelNameLowerCamel}Service.update(${modelNameLowerCamel}); 40 | return ResultGenerator.genSuccessResult(tmp); 41 | } 42 | 43 | @PostMapping("/detail") 44 | public Result detail(@RequestParam Integer id) { 45 | ${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.findById(id); 46 | return ResultGenerator.genSuccessResult(${modelNameLowerCamel}); 47 | } 48 | 49 | @PostMapping("/list") 50 | public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) { 51 | PageHelper.startPage(page, size); 52 | List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findAll(); 53 | PageInfo pageInfo = new PageInfo(list); 54 | return ResultGenerator.genSuccessResult(pageInfo); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/generator/template/mapper.ftl: -------------------------------------------------------------------------------- 1 | package ${basePackage}.dao; 2 | 3 | import ${basePackage}.model.${modelNameUpperCamel}; 4 | import ${corePackage}.mapper.Mapper; 5 | 6 | 7 | /** 8 | * Created by ${author} on ${date}. 9 | */ 10 | public interface ${modelNameUpperCamel}Mapper extends Mapper<${modelNameUpperCamel}> { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/generator/template/service-impl.ftl: -------------------------------------------------------------------------------- 1 | package ${basePackage}.service.impl; 2 | 3 | import ${basePackage}.dao.${modelNameUpperCamel}Mapper; 4 | import ${basePackage}.model.${modelNameUpperCamel}; 5 | import ${basePackage}.service.${modelNameUpperCamel}Service; 6 | import ${corePackage}.service.AbstractDeleteFlagService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | /** 14 | * Created by ${author} on ${date}. 15 | */ 16 | @Service 17 | @Transactional 18 | public class ${modelNameUpperCamel}ServiceImpl extends AbstractDeleteFlagService<${modelNameUpperCamel}> implements ${modelNameUpperCamel}Service { 19 | @Resource 20 | private ${modelNameUpperCamel}Mapper ${modelNameLowerCamel}Mapper; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zero-core/src/test/resources/generator/template/service.ftl: -------------------------------------------------------------------------------- 1 | package ${basePackage}.service; 2 | 3 | import ${basePackage}.model.${modelNameUpperCamel}; 4 | import ${corePackage}.service.Service; 5 | 6 | 7 | /** 8 | * Created by ${author} on ${date}. 9 | */ 10 | public interface ${modelNameUpperCamel}Service extends Service<${modelNameUpperCamel}> { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /zero-cron/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | non-zero 7 | space.non-zero 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | zero-cron 13 | jar 14 | 15 | 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-dependencies 21 | ${spring.boot.version} 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | space.non-zero 30 | zero-core 31 | 1.0-SNAPSHOT 32 | 33 | 34 | space.non-zero 35 | zero-common 36 | 0.0.1-SNAPSHOT 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /zero-cron/src/main/java/space/zero/cron/configure/ScheduleConfig.java: -------------------------------------------------------------------------------- 1 | package space.zero.cron.configure; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.scheduling.annotation.SchedulingConfigurer; 5 | import org.springframework.scheduling.config.ScheduledTaskRegistrar; 6 | 7 | import java.util.concurrent.Executors; 8 | 9 | /** 10 | * 配置多线程执行定时任务 11 | */ 12 | @Configuration 13 | public class ScheduleConfig implements SchedulingConfigurer { 14 | @Override 15 | public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { 16 | scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(10)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /zero-cron/src/main/java/space/zero/cron/task/CronDemo.java: -------------------------------------------------------------------------------- 1 | package space.zero.cron.task; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import space.zero.common.utils.ReflectionUtils; 7 | 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | 11 | /** 12 | * 定时任务示例 13 | * 在Application开启定时调度@EnableScheduling 14 | */ 15 | public class CronDemo { 16 | 17 | Logger logger = LoggerFactory.getLogger(CronDemo.class); 18 | 19 | // 定时执行,固定时间点 20 | @Scheduled(cron = "0 0/1 * * * ?") 21 | public void taskTwo(){ 22 | logger.info("Task two -- now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 23 | } 24 | 25 | // 等待前一次任务执行完成之后 26 | // fixedDelay = 5000表示当前方法执行完毕5000ms后,Spring scheduling会再次调用该方法 27 | @Scheduled(fixedDelay = 5000) 28 | public void testFixDelay() { 29 | logger.info("Task Three -- now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 30 | } 31 | 32 | // 不等待前一次方法执行完成 33 | // fixedRate = 5000表示当前方法开始执行5000ms后,Spring scheduling会再次调用该方法 34 | @Scheduled(fixedRate = 5000) 35 | public void testFixedRate() { 36 | logger.info("Task Four -- now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 37 | } 38 | 39 | // 第一次执行任务延迟时间 40 | // initialDelay = 1000表示延迟1000ms执行第一次任务 41 | @Scheduled(initialDelay = 1000, fixedRate = 5000) 42 | public void testInitialDelay() { 43 | logger.info("Task Five -- now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 44 | } 45 | } 46 | --------------------------------------------------------------------------------