├── refer ├── 9部门.png ├── 日志.png ├── 界面.png ├── 登录.png ├── 结构.png ├── 部门.png ├── e_个人日程.png └── e_个人日程2.png ├── src ├── main │ ├── resources │ │ ├── i18n │ │ │ ├── validation.properties │ │ │ ├── validation_zh_CN.properties │ │ │ ├── validation_en_US.properties │ │ │ ├── message.properties │ │ │ ├── message_zh_CN.properties │ │ │ └── message_en_US.properties │ │ ├── static │ │ │ └── assets │ │ │ │ ├── img │ │ │ │ ├── examples │ │ │ │ │ ├── blog.png │ │ │ │ │ ├── grid.png │ │ │ │ │ ├── album.png │ │ │ │ │ ├── cover.png │ │ │ │ │ ├── album@2x.png │ │ │ │ │ ├── blog@2x.png │ │ │ │ │ ├── carousel.png │ │ │ │ │ ├── checkout.png │ │ │ │ │ ├── cover@2x.png │ │ │ │ │ ├── dashboard.png │ │ │ │ │ ├── grid@2x.png │ │ │ │ │ ├── jumbotron.png │ │ │ │ │ ├── navbars.png │ │ │ │ │ ├── offcanvas.png │ │ │ │ │ ├── pricing.png │ │ │ │ │ ├── product.png │ │ │ │ │ ├── sign-in.png │ │ │ │ │ ├── carousel@2x.png │ │ │ │ │ ├── checkout@2x.png │ │ │ │ │ ├── navbars@2x.png │ │ │ │ │ ├── pricing@2x.png │ │ │ │ │ ├── product@2x.png │ │ │ │ │ ├── sign-in@2x.png │ │ │ │ │ ├── dashboard@2x.png │ │ │ │ │ ├── jumbotron@2x.png │ │ │ │ │ ├── navbar-bottom.png │ │ │ │ │ ├── navbar-fixed.png │ │ │ │ │ ├── navbar-static.png │ │ │ │ │ ├── offcanvas@2x.png │ │ │ │ │ ├── sticky-footer.png │ │ │ │ │ ├── floating-labels.png │ │ │ │ │ ├── navbar-bottom@2x.png │ │ │ │ │ ├── navbar-fixed@2x.png │ │ │ │ │ ├── navbar-static@2x.png │ │ │ │ │ ├── starter-template.png │ │ │ │ │ ├── sticky-footer@2x.png │ │ │ │ │ ├── floating-labels@2x.png │ │ │ │ │ ├── starter-template@2x.png │ │ │ │ │ ├── sticky-footer-navbar.png │ │ │ │ │ └── sticky-footer-navbar@2x.png │ │ │ │ ├── bootstrap-themes.png │ │ │ │ ├── bootstrap-themes@2x.png │ │ │ │ ├── brand │ │ │ │ │ ├── bootstrap-social.png │ │ │ │ │ ├── bootstrap-social-logo.png │ │ │ │ │ ├── bootstrap-solid.svg │ │ │ │ │ ├── bootstrap-punchout.svg │ │ │ │ │ └── bootstrap-outline.svg │ │ │ │ └── favicons │ │ │ │ │ ├── favicon-16x16.png │ │ │ │ │ ├── favicon-32x32.png │ │ │ │ │ ├── mstile-144x144.png │ │ │ │ │ ├── mstile-150x150.png │ │ │ │ │ ├── mstile-310x150.png │ │ │ │ │ ├── mstile-310x310.png │ │ │ │ │ ├── mstile-70x70.png │ │ │ │ │ ├── apple-touch-icon.png │ │ │ │ │ ├── android-chrome-192x192.png │ │ │ │ │ ├── android-chrome-512x512.png │ │ │ │ │ ├── browserconfig.xml │ │ │ │ │ └── safari-pinned-tab.svg │ │ │ │ ├── css │ │ │ │ ├── index.css │ │ │ │ ├── error.css │ │ │ │ ├── signin.css │ │ │ │ ├── sidebar.css │ │ │ │ └── project.css │ │ │ │ └── js │ │ │ │ ├── signin.js │ │ │ │ ├── util │ │ │ │ └── common.js │ │ │ │ ├── index.js │ │ │ │ ├── validate │ │ │ │ └── user-validate.js │ │ │ │ └── userInfo.js │ │ ├── templates │ │ │ ├── error │ │ │ │ ├── 5xx.html │ │ │ │ ├── 401.html │ │ │ │ ├── 402.html │ │ │ │ └── 404.html │ │ │ ├── components │ │ │ │ └── sidebar.html │ │ │ └── signin.html │ │ ├── log4j.properties │ │ ├── quartz.properties │ │ ├── application.yml │ │ └── logback-spring.xml │ └── java │ │ └── com │ │ └── nanyin │ │ ├── enumEntity │ │ ├── HttpMsgEnum.java │ │ ├── MessageEnum.java │ │ ├── DeletedStatusEnum.java │ │ └── SystemStatusEnum.java │ │ ├── services │ │ ├── OperateService.java │ │ ├── PermissionService.java │ │ ├── impl │ │ │ ├── OperateServiceImpl.java │ │ │ ├── UnitServiceImpl.java │ │ │ └── PermissionServiceImpl.java │ │ ├── UnitService.java │ │ ├── RoleService.java │ │ ├── LocaleService.java │ │ ├── UserServices.java │ │ └── UploadService.java │ │ ├── config │ │ ├── quartz │ │ │ ├── task │ │ │ │ ├── Task.java │ │ │ │ └── SimpleTask.java │ │ │ ├── JobStatus.java │ │ │ ├── repository │ │ │ │ └── JobEntityRepository.java │ │ │ ├── Job │ │ │ │ └── SimpleJob.java │ │ │ ├── JobEntity.java │ │ │ └── controller │ │ │ │ └── JobController.java │ │ ├── enums │ │ │ ├── TranferDirection.java │ │ │ ├── OperateModuleEnum.java │ │ │ ├── OperationTypeEnum.java │ │ │ ├── ResultMapEnum.java │ │ │ └── ResultCodeEnum.java │ │ ├── exceptions │ │ │ ├── tokenException │ │ │ │ ├── TokenEmptyException.java │ │ │ │ ├── TokenParseException.java │ │ │ │ ├── TokenWrongException.java │ │ │ │ └── TokenExpiredException.java │ │ │ ├── userException │ │ │ │ ├── UserBlockedException.java │ │ │ │ └── UserExistedException.java │ │ │ ├── CheckException.java │ │ │ └── exceptionHandler │ │ │ │ ├── ShiroAuthorizationExceptionHandler.java │ │ │ │ └── FieldValidExceptionHandler.java │ │ ├── log │ │ │ └── Log.java │ │ ├── locale │ │ │ ├── MyCookieResolver.java │ │ │ └── MyLocaleResolver.java │ │ ├── shiro │ │ │ ├── MyPassThruAuthenticationFilter.java │ │ │ └── MySessionManager.java │ │ ├── security │ │ │ ├── handler │ │ │ │ ├── CustomAccessDeniedHandler.java │ │ │ │ ├── CustomAuthenticationEntryPoint.java │ │ │ │ └── CustomLogoutSuccessHandler.java │ │ │ ├── CustomAuthenticatioToken.java │ │ │ ├── CustomAuthenticationProvider.java │ │ │ ├── filter │ │ │ │ └── CustomLogoutFilter.java │ │ │ └── CustomPermissionEvaluator.java │ │ ├── filter │ │ │ └── CORSFilter.java │ │ ├── util │ │ │ ├── HashHelper.java │ │ │ ├── Result.java │ │ │ ├── MDCUtil.java │ │ │ ├── CommonUtils.java │ │ │ └── PageHelper.java │ │ ├── redis │ │ │ ├── FastJson2JsonRedisSerializer.java │ │ │ └── WebRedisConfiguration.java │ │ ├── swagger2 │ │ │ └── Swagger2Config.java │ │ ├── interceptor │ │ │ └── WebTokenInterceptor.java │ │ └── WebMvcConfiguration.java │ │ ├── entity │ │ ├── DTO │ │ │ ├── UserDto.java │ │ │ ├── TranferDto.java │ │ │ ├── OperateLogDto.java │ │ │ ├── UnitDto.java │ │ │ ├── PageQueryParams.java │ │ │ └── NameAndPw.java │ │ ├── Priority.java │ │ ├── HandleStatus.java │ │ ├── Status.java │ │ ├── Sex.java │ │ ├── Task.java │ │ ├── Operate.java │ │ ├── Tickets.java │ │ ├── Paper.java │ │ ├── Permission.java │ │ ├── Person.java │ │ ├── Unit.java │ │ └── Role.java │ │ ├── repository │ │ ├── OperateRepository.java │ │ ├── SexRepository.java │ │ ├── StatusRepository.java │ │ ├── UnitRepository.java │ │ ├── RoleRepository.java │ │ ├── PermissionRepository.java │ │ └── UserRepository.java │ │ ├── WebProjectApplication.java │ │ └── controller │ │ ├── PermissionController.java │ │ ├── LoginController.java │ │ ├── UnitController.java │ │ └── RoleController.java └── test │ └── java │ └── com │ └── nanyin │ ├── WebProjectApplicationTest.java │ ├── controller │ └── UserControllerTest.java │ └── services │ └── impl │ └── UserServicesImplTest.java ├── .idea ├── vcs.xml ├── kotlinc.xml ├── modules.xml ├── libraries │ ├── Maven__junit_junit_4_11.xml │ ├── Maven__log4j_log4j_1_2_17.xml │ ├── Maven__javax_servlet_jstl_1_2.xml │ ├── Maven__org_ehcache_ehcache_3_3_1.xml │ ├── Maven__org_mybatis_mybatis_3_4_1.xml │ ├── Maven__commons_io_commons_io_2_5.xml │ ├── Maven__org_slf4j_slf4j_api_1_7_7.xml │ ├── Maven__com_alibaba_fastjson_1_2_31.xml │ ├── Maven__com_fasterxml_classmate_1_3_1.xml │ ├── Maven__javax_servlet_servlet_api_2_5.xml │ ├── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── Maven__org_apache_shiro_shiro_web_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_core_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_lang_1_4_0.xml │ ├── Maven__org_opensymphony_quartz_quartz_1_6_1.xml │ ├── Maven__org_apache_shiro_shiro_cache_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_event_1_4_0.xml │ ├── Maven__org_aspectj_aspectjweaver_1_8_10.xml │ ├── Maven__org_mybatis_mybatis_spring_1_3_0.xml │ ├── Maven__com_github_jsqlparser_jsqlparser_1_0.xml │ ├── Maven__net_sf_ehcache_ehcache_core_2_6_11.xml │ ├── Maven__org_apache_shiro_shiro_quartz_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_spring_1_4_0.xml │ ├── Maven__org_mybatis_mybatis_ehcache_1_0_0.xml │ ├── Maven__com_github_pagehelper_pagehelper_5_0_3.xml │ ├── Maven__org_apache_shiro_shiro_ehcache_1_4_0.xml │ ├── Maven__com_octo_captcha_jcaptcha_2_0_alpha_1.xml │ ├── Maven__mysql_mysql_connector_java_5_1_38.xml │ ├── Maven__org_apache_commons_commons_dbcp2_2_1_1.xml │ ├── Maven__org_apache_commons_commons_pool2_2_4_2.xml │ ├── Maven__org_apache_shiro_shiro_config_core_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_config_ogdl_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_crypto_core_1_4_0.xml │ ├── Maven__org_apache_shiro_shiro_crypto_hash_1_4_0.xml │ ├── Maven__commons_beanutils_commons_beanutils_1_9_3.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_8_8.xml │ ├── Maven__org_apache_shiro_shiro_crypto_cipher_1_4_0.xml │ ├── Maven__org_springframework_spring_tx_4_3_8_RELEASE.xml │ ├── Maven__commons_fileupload_commons_fileupload_1_3_1.xml │ ├── Maven__org_jboss_logging_jboss_logging_3_3_0_Final.xml │ ├── Maven__javax_validation_validation_api_1_1_0_Final.xml │ ├── Maven__org_springframework_spring_aop_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_web_4_3_8_RELEASE.xml │ ├── Maven__commons_collections_commons_collections_3_2_2.xml │ ├── Maven__org_springframework_spring_core_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_jdbc_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_test_4_3_8_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_8_9.xml │ ├── Maven__org_springframework_spring_beans_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_webmvc_4_3_8_RELEASE.xml │ ├── Maven__org_hibernate_hibernate_validator_5_4_1_Final.xml │ ├── Maven__org_springframework_spring_context_4_3_8_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_9.xml │ ├── Maven__org_springframework_spring_expression_4_3_8_RELEASE.xml │ ├── Maven__javax_servlet_jsp_jstl_javax_servlet_jsp_jstl_api_1_2_1.xml │ ├── Maven__org_springframework_spring_context_support_4_3_8_RELEASE.xml │ └── Maven__com_octo_captcha_jcaptcha_integration_simple_servlet_2_0_alpha_1.xml ├── artifacts │ └── web_ssm_project_war.xml ├── misc.xml ├── compiler.xml └── inspectionProfiles │ └── Project_Default.xml └── README.md /refer/9部门.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/9部门.png -------------------------------------------------------------------------------- /refer/日志.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/日志.png -------------------------------------------------------------------------------- /refer/界面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/界面.png -------------------------------------------------------------------------------- /refer/登录.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/登录.png -------------------------------------------------------------------------------- /refer/结构.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/结构.png -------------------------------------------------------------------------------- /refer/部门.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/部门.png -------------------------------------------------------------------------------- /refer/e_个人日程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/e_个人日程.png -------------------------------------------------------------------------------- /refer/e_个人日程2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/refer/e_个人日程2.png -------------------------------------------------------------------------------- /src/main/resources/i18n/validation.properties: -------------------------------------------------------------------------------- 1 | user_email_format=邮箱格式不正确 2 | user_password_length=密码长度应大于3并且小于64 -------------------------------------------------------------------------------- /src/main/resources/i18n/validation_zh_CN.properties: -------------------------------------------------------------------------------- 1 | user_email_format=邮箱格式不正确 2 | user_password_length=密码长度应大于3并且小于64 -------------------------------------------------------------------------------- /src/main/java/com/nanyin/enumEntity/HttpMsgEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.enumEntity; 2 | 3 | public enum HttpMsgEnum { 4 | SUCCESS,FAIL 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/blog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/blog.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/grid.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/album.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/album.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/cover.png -------------------------------------------------------------------------------- /src/main/resources/i18n/validation_en_US.properties: -------------------------------------------------------------------------------- 1 | user_email_format=E-mail format is incorrect 2 | user_password_length=Password length should be greater than 3 and less than 64 -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/bootstrap-themes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/bootstrap-themes.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/album@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/album@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/blog@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/blog@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/carousel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/carousel.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/checkout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/checkout.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/cover@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/cover@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/dashboard.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/grid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/grid@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/jumbotron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/jumbotron.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbars.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/offcanvas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/offcanvas.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/pricing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/pricing.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/product.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/product.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sign-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sign-in.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/bootstrap-themes@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/bootstrap-themes@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/carousel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/carousel@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/checkout@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/checkout@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbars@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbars@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/pricing@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/pricing@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/product@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/product@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sign-in@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sign-in@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/brand/bootstrap-social.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/brand/bootstrap-social.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/dashboard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/dashboard@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/jumbotron@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/jumbotron@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-bottom.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-fixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-fixed.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-static.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/offcanvas@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/offcanvas@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sticky-footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sticky-footer.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/favicon-16x16.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/favicon-32x32.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/mstile-144x144.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/mstile-150x150.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/mstile-310x150.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/mstile-310x310.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/mstile-70x70.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/floating-labels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/floating-labels.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-bottom@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-bottom@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-fixed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-fixed@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/navbar-static@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/navbar-static@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/starter-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/starter-template.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sticky-footer@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sticky-footer@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/apple-touch-icon.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/brand/bootstrap-social-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/brand/bootstrap-social-logo.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/floating-labels@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/floating-labels@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/starter-template@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/starter-template@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sticky-footer-navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sticky-footer-navbar.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/examples/sticky-footer-navbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/examples/sticky-footer-navbar@2x.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/android-chrome-192x192.png -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanYinIU/ssm-web-project/HEAD/src/main/resources/static/assets/img/favicons/android-chrome-512x512.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/enumEntity/MessageEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.enumEntity; 2 | 3 | public enum MessageEnum { 4 | NO_ACCOUNT,USER_HAS_BEEN_BLOCKED,SYSTEM_ERROR,INCORRECT_LOGIN_INFORMATION 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/OperateService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.nanyin.entity.Operate; 4 | 5 | public interface OperateService { 6 | Operate save(Operate operate); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/css/index.css: -------------------------------------------------------------------------------- 1 | 2 | .feather { 3 | width: 16px; 4 | height: 16px; 5 | vertical-align: text-bottom; 6 | } 7 | 8 | 9 | /* 10 | * Content 11 | */ 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/templates/error/5xx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

5xx 错误

9 | 10 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/task/Task.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz.task; 2 | 3 | /** 4 | * Created by NanYin on 2019/9/19. 5 | */ 6 | public interface Task { 7 | public void execute(String[] args); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/enums/TranferDirection.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.enums; 2 | 3 | public class TranferDirection { 4 | public final static String RIGHT = "right"; 5 | public final static String LEFT = "left"; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/JobStatus.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz; 2 | 3 | /** 4 | * Created by NanYin on 2019/9/18. 5 | * 定时任务的状态 6 | */ 7 | 8 | public enum JobStatus { 9 | OPEN, 10 | CLOSE 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | import com.nanyin.entity.Person; 4 | import com.nanyin.entity.Sex; 5 | 6 | /** 7 | * 包含用户的基本信息 8 | */ 9 | public class UserDto { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/OperateRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Operate; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface OperateRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG, stdout 2 | log4j.logger.org.mybatis=DEBUG 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/tokenException/TokenEmptyException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.tokenException; 2 | 3 | public class TokenEmptyException extends RuntimeException { 4 | public TokenEmptyException() { 5 | super("Token不存在!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/tokenException/TokenParseException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.tokenException; 2 | 3 | public class TokenParseException extends RuntimeException { 4 | public TokenParseException() { 5 | super("Token 解析异常!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/tokenException/TokenWrongException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.tokenException; 2 | 3 | public class TokenWrongException extends RuntimeException { 4 | public TokenWrongException() { 5 | super("用户名或密码错误!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/userException/UserBlockedException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.userException; 2 | 3 | public class UserBlockedException extends RuntimeException { 4 | public UserBlockedException() { 5 | super("用户已经被封锁!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/tokenException/TokenExpiredException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.tokenException; 2 | 3 | public class TokenExpiredException extends RuntimeException { 4 | public TokenExpiredException() { 5 | super("Token已过期!请重新登陆"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/userException/UserExistedException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.userException; 2 | 3 | public class UserExistedException extends RuntimeException{ 4 | public UserExistedException() { 5 | super("用户已存在!请修改用户名,重新提交!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/SexRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Sex; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface SexRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/enums/OperateModuleEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.enums; 2 | /** 3 | * 发生的模块 4 | * @Author nanyin 5 | * @Date 21:57 2019-08-21 6 | **/ 7 | public enum OperateModuleEnum { 8 | /** 9 | * 用户模块 10 | **/ 11 | USER, 12 | /** 13 | * 其他模块 14 | **/ 15 | OTHER 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/task/SimpleTask.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz.task; 2 | 3 | /** 4 | * Created by NanYin on 2019/9/19. 5 | */ 6 | public class SimpleTask implements Task { 7 | @Override 8 | public void execute(String... args) { 9 | System.out.println("simple task,.."); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/TranferDto.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 穿梭框的DTO 7 | */ 8 | @Data 9 | public class TranferDto { 10 | private String direction; 11 | private Integer[] value; 12 | private String standardKey; 13 | private Integer[] movedKeys; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/CheckException.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions; 2 | 3 | /** 4 | * 检查异常 5 | * @Author nanyin 6 | * @Date 13:50 2019-08-20 7 | **/ 8 | public class CheckException extends RuntimeException { 9 | public CheckException(String message) { 10 | super(message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/StatusRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Status; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface StatusRepository extends JpaRepository { 9 | List findAllByIsDeletedOrderByOrd(Boolean isDeleted); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/browserconfig.xml: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | 5 | 6 | 7 | 8 | #563d7c 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/OperateLogDto.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | import com.nanyin.config.enums.OperateModuleEnum; 4 | import com.nanyin.config.enums.OperationTypeEnum; 5 | import lombok.Data; 6 | 7 | @Data 8 | public class OperateLogDto { 9 | private OperationTypeEnum operationTypeEnum; 10 | private String operationName; 11 | private OperateModuleEnum operateModuleEnum; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/UnitDto.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | import com.nanyin.entity.Unit; 4 | import com.nanyin.entity.User; 5 | import lombok.Data; 6 | 7 | import java.util.Set; 8 | 9 | @Data 10 | public class UnitDto { 11 | private Integer id; 12 | private String name; 13 | 14 | private String address; 15 | private String comment; 16 | 17 | Set users; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/enumEntity/DeletedStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.enumEntity; 2 | 3 | public enum DeletedStatusEnum { 4 | 5 | IS_NOT_DELETED(false), 6 | 7 | IS_DELETED(true); 8 | 9 | private DeletedStatusEnum(boolean judge) { 10 | this.judge = judge; 11 | } 12 | 13 | private boolean judge; 14 | 15 | public boolean isJudge() { 16 | return judge; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/repository/JobEntityRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz.repository; 2 | 3 | import com.nanyin.config.quartz.JobEntity; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * Created by NanYin on 2019/9/18. 8 | */ 9 | public interface JobEntityRepository extends JpaRepository { 10 | JobEntity getById(Integer id); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/enums/OperationTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.enums; 2 | 3 | public enum OperationTypeEnum { 4 | 5 | /** 6 | * 增 7 | **/ 8 | ADD, 9 | 10 | /** 11 | * 删 12 | **/ 13 | MODIFY, 14 | 15 | /** 16 | * 改 17 | **/ 18 | DELETE, 19 | /** 20 | * 查 21 | **/ 22 | FIND, 23 | 24 | /** 25 | * 26 | **/ 27 | INIT 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/js/signin.js: -------------------------------------------------------------------------------- 1 | function translates(lang) { 2 | console.log("test"); 3 | $.ajax({ 4 | type: 'post', 5 | url: '/lang', 6 | dataType: 'json', 7 | data: {'lang':lang}, 8 | success: function (res) { 9 | // 成功后刷新页面 10 | window.location.reload(); 11 | }, 12 | error: function (request, status, error) { 13 | 14 | } 15 | }); 16 | } -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/PageQueryParams.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class PageQueryParams { 7 | private String search; 8 | private Integer offset; 9 | private Integer limit; 10 | private String sort; 11 | /** 12 | * 角色ID 13 | */ 14 | private Integer role; 15 | 16 | /** 17 | * 单位id 18 | */ 19 | private Integer unit; 20 | } 21 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__junit_junit_4_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/UnitRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Unit; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface UnitRepository extends JpaRepository,QuerydslPredicateExecutor { 12 | List findAllByParentIsNull(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.nanyin.entity.DTO.PageQueryParams; 4 | import com.nanyin.entity.Permission; 5 | import org.springframework.data.domain.Page; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public interface PermissionService { 11 | Page findPermissions(PageQueryParams pageQueryParams) throws Exception; 12 | 13 | Map> getRolePermission(Integer role) throws Exception; 14 | } 15 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__log4j_log4j_1_2_17.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_jstl_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/artifacts/web_ssm_project_war.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target 4 | 5 | 6 | web-ssm-project 7 | war 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/DTO/NameAndPw.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity.DTO; 2 | 3 | public class NameAndPw { 4 | private String username; 5 | private String password; 6 | 7 | public String getUsername() { 8 | return username; 9 | } 10 | 11 | public void setUsername(String username) { 12 | this.username = username; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/enumEntity/SystemStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.enumEntity; 2 | 3 | public enum SystemStatusEnum { 4 | /* 5 | * 正常状态 为 1 6 | * normal status is 1 7 | **/ 8 | NORMAL(1), 9 | /* 10 | * 暂时被禁止登陆 为2 11 | **/ 12 | BLOCK_FOR_TEMP(2), 13 | /* 14 | * 永久被禁为3 15 | **/ 16 | BLOCK_FORVER(3); 17 | 18 | private Integer id; 19 | 20 | SystemStatusEnum(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public Integer getId() { 25 | return id; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_ehcache_ehcache_3_3_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_3_4_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/Job/SimpleJob.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz.Job; 2 | 3 | import org.quartz.DisallowConcurrentExecution; 4 | import org.quartz.Job; 5 | import org.quartz.JobExecutionContext; 6 | import org.quartz.JobExecutionException; 7 | 8 | /** 9 | * Created by NanYin on 2019/9/18. 10 | */ 11 | @DisallowConcurrentExecution 12 | public class SimpleJob implements Job { 13 | @Override 14 | public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { 15 | System.out.println("开始执行job"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_io_commons_io_2_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_alibaba_fastjson_1_2_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_classmate_1_3_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_servlet_api_2_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/enums/ResultMapEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.enums; 2 | 3 | 4 | import java.util.Collection; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public enum ResultMapEnum { 9 | rows, total; 10 | public static Map generateInstance(Integer total, Collection rows){ 11 | HashMap objectObjectHashMap = new HashMap<>(); 12 | objectObjectHashMap.put(ResultMapEnum.rows,rows); 13 | objectObjectHashMap.put(ResultMapEnum.total,total); 14 | return objectObjectHashMap; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_web_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 9 | 10 | @Component 11 | public interface RoleRepository extends JpaRepository, JpaSpecificationExecutor, QuerydslPredicateExecutor { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_core_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_lang_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_opensymphony_quartz_quartz_1_6_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/PermissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Permission; 4 | import com.nanyin.entity.Role; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 8 | import org.springframework.stereotype.Repository; 9 | 10 | @Repository 11 | public interface PermissionRepository extends JpaRepository, JpaSpecificationExecutor, QuerydslPredicateExecutor { 12 | } 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_cache_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_event_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_spring_1_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_github_jsqlparser_jsqlparser_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/impl/OperateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services.impl; 2 | 3 | import com.nanyin.entity.Operate; 4 | import com.nanyin.repository.OperateRepository; 5 | import com.nanyin.services.OperateService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class OperateServiceImpl implements OperateService { 11 | @Autowired 12 | OperateRepository operateRepository; 13 | 14 | @Override 15 | public Operate save(Operate operate){ 16 | return operateRepository.save(operate); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_sf_ehcache_ehcache_core_2_6_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_quartz_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_spring_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_ehcache_1_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_github_pagehelper_pagehelper_5_0_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_ehcache_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_octo_captcha_jcaptcha_2_0_alpha_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__mysql_mysql_connector_java_5_1_38.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_commons_commons_dbcp2_2_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_commons_commons_pool2_2_4_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/UnitService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.nanyin.entity.DTO.PageQueryParams; 4 | import com.nanyin.entity.Unit; 5 | import org.springframework.data.domain.Page; 6 | 7 | import java.util.List; 8 | 9 | public interface UnitService { 10 | 11 | /** 12 | * 获得所有unit数据 13 | * @return 14 | * @throws Exception 15 | * @param pageQueryParams 16 | */ 17 | Page findUnits(PageQueryParams pageQueryParams) throws Exception; 18 | 19 | /** 20 | * 查找单位树数据 21 | * @return 22 | * @throws Exception 23 | */ 24 | List findUnitTree() throws Exception; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_config_core_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_config_ogdl_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_crypto_core_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_crypto_hash_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_beanutils_commons_beanutils_1_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_crypto_cipher_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_tx_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_aop_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_web_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_collections_commons_collections_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_core_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_jdbc_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_test_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/i18n/message.properties: -------------------------------------------------------------------------------- 1 | simplified_chinese=简体中文 2 | email_address=邮箱地址 3 | password=密码 4 | please_sign_in=请登陆 5 | remember_me=记住我 6 | sign_in=登陆 7 | english=英文 8 | username_or_password_wrong=用户名或密码错误,请重新输入! 9 | user_has_been_blocked=用户已被锁定 10 | sign_out=登出 11 | search=搜索.. 12 | product=项目管理系统 13 | version=2.0 版本 14 | not_selected=未选择.. 15 | project_status=项目状态 16 | project_level=项目等级 17 | project_type=项目类型 18 | system_error=系统异常,请联系管理员 19 | no_account=没有这个用户! 20 | check_error=检查异常 21 | start_log=----------开始属于模块[{2}]的类[{0}]中的方法[{1}]进行日志跟踪,用于[{3}]---------- 22 | after_log=----------结束属于模块[{2}]的类[{0}]中的方法[{1}]进行日志跟踪,用于[{3}],方法耗时[{4}]---------- 23 | search_users=检索用户列表 24 | search_user_info=查询用户id为{0}信息 -------------------------------------------------------------------------------- /src/main/resources/i18n/message_zh_CN.properties: -------------------------------------------------------------------------------- 1 | email_address=邮箱地址 2 | english=英文 3 | password=密码 4 | please_sign_in=请登陆 5 | remember_me=记住我 6 | sign_in=登陆 7 | simplified_chinese=简体中文 8 | username_or_password_wrong=用户名或密码错误,请重新输入! 9 | user_has_been_blocked=用户已被锁定 10 | sign_out=登出 11 | search=搜索.. 12 | product=项目管理系统 13 | version=2.0 版本 14 | not_selected=未选择.. 15 | project_status=项目状态 16 | project_level=项目等级 17 | project_type=项目类型 18 | system_error=系统异常,请联系管理员 19 | no_account=没有这个用户! 20 | check_error=检查异常 21 | start_log=----------开始属于模块[{2}]的类[{0}]中的方法[{1}]进行日志跟踪,用于[{3}]---------- 22 | after_log=----------结束属于模块[{2}]的类[{0}]中的方法[{1}]进行日志跟踪,用于[{3}],方法耗时[{4}]---------- 23 | search_users=检索用户列表 24 | search_user_info=查询用户id为{0}信息 -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_beans_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_hibernate_validator_5_4_1_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_expression_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/WebProjectApplication.java: -------------------------------------------------------------------------------- 1 | package com.nanyin; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.serializer.SerializerFeature; 5 | import com.nanyin.config.util.MDCUtil; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.cache.annotation.EnableCaching; 9 | 10 | 11 | @SpringBootApplication 12 | @EnableCaching 13 | public class WebProjectApplication { 14 | public static void main(String[] args) { 15 | MDCUtil.setUser("ADMIN"); 16 | JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask(); 17 | SpringApplication.run(WebProjectApplication.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_jsp_jstl_javax_servlet_jsp_jstl_api_1_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_support_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Priority.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.Date; 7 | 8 | /** 9 | * 优先级 10 | */ 11 | @Data 12 | @Entity 13 | public class Priority { 14 | @Id 15 | @Column(columnDefinition = "INT(11)") 16 | @GeneratedValue(strategy= GenerationType.IDENTITY) 17 | private Integer id; 18 | @Column(length = 64) 19 | String name; 20 | @Column(length = 1024) 21 | String comment; 22 | @Column(length = 11) 23 | Integer ord; 24 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 25 | Boolean isDeleted; 26 | @Temporal(value=TemporalType.TIMESTAMP) 27 | Date gmtCreate; 28 | @Temporal(value=TemporalType.TIMESTAMP) 29 | Date gmtModify; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/brand/bootstrap-solid.svg: -------------------------------------------------------------------------------- 1 | 2 | Bootstrap 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/brand/bootstrap-punchout.svg: -------------------------------------------------------------------------------- 1 | 2 | Bootstrap 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_octo_captcha_jcaptcha_integration_simple_servlet_2_0_alpha_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/log/Log.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.log; 2 | 3 | import com.nanyin.config.enums.OperateModuleEnum; 4 | import com.nanyin.config.enums.OperationTypeEnum; 5 | 6 | import java.lang.annotation.*; 7 | 8 | /** 9 | * Created by NanYin on 2017-07-16 下午11:09. 10 | * 包名: com.nanyin.common.log 11 | * 类描述: 12 | */ 13 | @Target({ElementType.PARAMETER, ElementType.METHOD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | public @interface Log { 17 | 18 | /** 要执行的操作类型比如:add操作 **/ 19 | OperationTypeEnum operationType() default OperationTypeEnum.FIND; 20 | 21 | /** 要执行的具体操作比如:添加用户 但必须是在message中的属性名称 如add**/ 22 | String operationName() default ""; 23 | 24 | OperateModuleEnum operateModul(); 25 | 26 | /** 27 | * 国际化的参数在参数列表中的顺序,从0开始,如{0,1} 28 | **/ 29 | int[] params() default {}; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/quartz.properties: -------------------------------------------------------------------------------- 1 | org.quartz.scheduler.instanceName=spring-boot-quartz 2 | org.quartz.scheduler.instanceId=AUTO 3 | org.quartz.threadPool.threadCount=5 4 | org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX 5 | org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate 6 | org.quartz.jobStore.misfireThreshold=60000 7 | org.quartz.jobStore.tablePrefix=QRTZ_ 8 | 9 | org.quartz.jobStore.isClustered=true 10 | org.quartz.jobStore.clusterCheckinInterval=20000 11 | 12 | # A different classloader is needed to work with Spring Boot dev mode, 13 | # see https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-known-restart-limitations 14 | # and https://github.com/quartz-scheduler/quartz/issues/221 15 | org.quartz.scheduler.classLoadHelper.class=org.quartz.simpl.ThreadContextClassLoadHelper -------------------------------------------------------------------------------- /src/main/resources/static/assets/css/error.css: -------------------------------------------------------------------------------- 1 | /*html,*/ 2 | /*body {*/ 3 | /*height: 100%;*/ 4 | /*}*/ 5 | 6 | body { 7 | display: -ms-flexbox; 8 | display: flex; 9 | -ms-flex-align: center; 10 | align-items: center; 11 | padding-top: 40px; 12 | padding-bottom: 40px; 13 | background-color: #f5f5f5; 14 | } 15 | .page { 16 | display: -ms-flexbox; 17 | display: flex; 18 | -ms-flex-direction: column; 19 | flex-direction: column; 20 | -ms-flex-pack: center; 21 | justify-content: center; 22 | min-height: 100%; 23 | } 24 | 25 | .page-content { 26 | margin: .75rem 0; 27 | } 28 | 29 | @media (min-width: 768px) { 30 | .page-content { 31 | margin: 1.5rem 0; 32 | } 33 | } 34 | 35 | .display-1 i, 36 | .display-2 i, 37 | .display-3 i, 38 | .display-4 i { 39 | vertical-align: baseline; 40 | font-size: 0.815em; 41 | } -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/HandleStatus.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.Date; 7 | 8 | /** 9 | * 工作处理情况 10 | */ 11 | @Data 12 | @Entity 13 | public class HandleStatus { 14 | 15 | @Id 16 | @Column(columnDefinition = "INT(11)") 17 | @GeneratedValue(strategy= GenerationType.IDENTITY) 18 | private Integer id; 19 | @Column(length = 64) 20 | String name; 21 | @Column(length = 1024) 22 | String comment; 23 | @Column(length = 11) 24 | Integer ord; 25 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 26 | Boolean isDeleted; 27 | @Temporal(value=TemporalType.TIMESTAMP) 28 | Date gmtCreate; 29 | @Temporal(value=TemporalType.TIMESTAMP) 30 | Date gmtModify; 31 | private static final long serialVersionUID = -866998743428907531L; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/js/util/common.js: -------------------------------------------------------------------------------- 1 | $.fn.serializeObject = function() { 2 | var o = {}; 3 | var a = this.serializeArray(); 4 | $.each(a, function() { 5 | var value = this.value; 6 | var paths = this.name.split("."); 7 | var len = paths.length; 8 | var obj = o; 9 | $.each(paths,function(i,e){ 10 | if(i == len-1){ 11 | if (obj[e]) { 12 | if (!obj[e].push) { 13 | obj[e] = [obj[e]]; 14 | } 15 | obj[e].push(value || ''); 16 | } else { 17 | obj[e] = value || ''; 18 | } 19 | }else{ 20 | if(!obj[e]){ 21 | obj[e] = {}; 22 | } 23 | } 24 | obj = o[e]; 25 | }); 26 | }); 27 | return o; 28 | } -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.controller; 2 | 3 | import com.nanyin.config.util.Result; 4 | import com.nanyin.entity.DTO.PageQueryParams; 5 | import com.nanyin.services.PermissionService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @RestController 13 | public class PermissionController { 14 | @Autowired 15 | PermissionService permissionService; 16 | 17 | @GetMapping("/permissions") 18 | public Result permissions(PageQueryParams pageQueryParams) throws Exception{ 19 | return new Result<>(permissionService.findPermissions(pageQueryParams)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/templates/components/sidebar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |
9 | 10 | 23 |
24 | 25 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.nanyin.entity.DTO.TranferDto; 4 | import com.nanyin.entity.Role; 5 | import org.springframework.data.domain.Page; 6 | 7 | public interface RoleService { 8 | Role saveRole(Role role) throws Exception; 9 | 10 | Role getRole(Integer id) throws Exception; 11 | 12 | Role updateRole(Role role) throws Exception; 13 | 14 | void deleteRole(Integer id) throws Exception; 15 | 16 | Page findRoles(String search, Integer offset, Integer limit, String sort) throws Exception; 17 | 18 | /** 19 | * 为角色增加/删除人员 20 | * @param tranferDto 21 | * @throws Exception 22 | */ 23 | void movePersons(TranferDto tranferDto)throws Exception; 24 | 25 | /** 26 | * 为角色增加/删除权限 27 | * @param tranferDto 28 | * @throws Exception 29 | */ 30 | void movePermission(TranferDto tranferDto) throws Exception; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Status.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Entity 11 | @Table(name = "s_user_status") 12 | public class Status implements Serializable{ 13 | 14 | @Id 15 | @Column(columnDefinition = "INT(11)") 16 | @GeneratedValue(strategy= GenerationType.IDENTITY) 17 | private Integer id; 18 | @Column(length = 64) 19 | String name; 20 | @Column(length = 1024) 21 | String comment; 22 | @Column(length = 11) 23 | Integer ord; 24 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 25 | Boolean isDeleted; 26 | @Temporal(value=TemporalType.TIMESTAMP) 27 | Date gmtCreate; 28 | @Temporal(value=TemporalType.TIMESTAMP) 29 | Date gmtModify; 30 | private static final long serialVersionUID = -866998743428907531L; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/LocaleService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.MessageSource; 5 | import org.springframework.context.i18n.LocaleContextHolder; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Locale; 9 | 10 | @Component 11 | public class LocaleService { 12 | 13 | @Autowired 14 | MessageSource messageSource; 15 | 16 | public String getMessage(String code){ 17 | return getMessage(code,null); 18 | } 19 | 20 | public String getMessage(String code,Object...args){ 21 | return getMessage(code, "",args); 22 | } 23 | 24 | public String getMessage(String code,String defaultMessage,Object...args){ 25 | //不依赖request 26 | Locale locale = LocaleContextHolder.getLocale(); 27 | return messageSource.getMessage(code, args, defaultMessage, locale); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Sex.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Entity 11 | @Table(name = "s_user_sex") 12 | public class Sex implements Serializable { 13 | @Id 14 | @Column(columnDefinition = "INT(11)") 15 | @GeneratedValue(strategy= GenerationType.IDENTITY) 16 | private Integer id; 17 | @Column(length = 64) 18 | String name; 19 | @Column(length = 1024) 20 | String comment; 21 | @Column(length = 11) 22 | Integer ord; 23 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 24 | Boolean isDeleted; 25 | @Temporal(value=TemporalType.TIMESTAMP) 26 | Date gmtCreate; 27 | @Temporal(value=TemporalType.TIMESTAMP) 28 | Date gmtModify; 29 | 30 | public Sex() { 31 | } 32 | 33 | private static final long serialVersionUID = -450912372259672214L; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/css/signin.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | } 5 | 6 | body { 7 | display: -ms-flexbox; 8 | display: flex; 9 | -ms-flex-align: center; 10 | align-items: center; 11 | padding-top: 40px; 12 | padding-bottom: 40px; 13 | background-color: #f5f5f5; 14 | } 15 | 16 | .form-signin { 17 | width: 100%; 18 | max-width: 330px; 19 | padding: 15px; 20 | margin: auto; 21 | } 22 | .form-signin .checkbox { 23 | font-weight: 400; 24 | } 25 | .form-signin .form-control { 26 | position: relative; 27 | box-sizing: border-box; 28 | height: auto; 29 | padding: 10px; 30 | font-size: 16px; 31 | } 32 | .form-signin .form-control:focus { 33 | z-index: 2; 34 | } 35 | .form-signin input[type="email"] { 36 | margin-bottom: -1px; 37 | border-bottom-right-radius: 0; 38 | border-bottom-left-radius: 0; 39 | } 40 | .form-signin input[type="password"] { 41 | margin-bottom: 10px; 42 | border-top-left-radius: 0; 43 | border-top-right-radius: 0; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/brand/bootstrap-outline.svg: -------------------------------------------------------------------------------- 1 | 2 | Bootstrap 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/locale/MyCookieResolver.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.locale; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.servlet.i18n.CookieLocaleResolver; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import java.util.Locale; 8 | 9 | @Component 10 | public class MyCookieResolver extends CookieLocaleResolver { 11 | 12 | public static final String DEFAULT_COOKIE_NAME = "MyCookieLocaleResolver.locale"; 13 | 14 | public MyCookieResolver() { 15 | setCookieName(DEFAULT_COOKIE_NAME); 16 | } 17 | 18 | @Override 19 | public void setDefaultLocale(Locale defaultLocale) { 20 | super.setDefaultLocale(Locale.SIMPLIFIED_CHINESE); 21 | } 22 | 23 | @Override 24 | protected Locale getDefaultLocale() { 25 | return Locale.SIMPLIFIED_CHINESE; 26 | } 27 | 28 | @Override 29 | public Locale resolveLocale(HttpServletRequest request) { 30 | return super.resolveLocale(request); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/shiro/MyPassThruAuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.shiro; 2 | 3 | import org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter; 4 | import org.springframework.web.bind.annotation.RequestMethod; 5 | 6 | import javax.servlet.ServletRequest; 7 | import javax.servlet.ServletResponse; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * 过滤 OPTION 请求 13 | */ 14 | public class MyPassThruAuthenticationFilter extends PassThruAuthenticationFilter { 15 | 16 | @Override 17 | public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) 18 | throws Exception { 19 | HttpServletRequest req = (HttpServletRequest) request; 20 | HttpServletResponse res = (HttpServletResponse) response; 21 | if (req.getMethod().equals(RequestMethod.OPTIONS.name())) { 22 | return true; 23 | } 24 | return super.onPreHandle(request, response, mappedValue); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Task.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.Date; 7 | 8 | /** 9 | * 工单下的一页中有多个任务组成 10 | */ 11 | @Data 12 | @Entity 13 | public class Task { 14 | @Id 15 | @Column(columnDefinition = "INT(11)") 16 | @GeneratedValue(strategy= GenerationType.IDENTITY) 17 | private Integer id; 18 | 19 | /** 20 | * Task名称 21 | */ 22 | @Column(length = 2048) 23 | String name; 24 | 25 | /** 26 | * Task内容 27 | */ 28 | @Column(columnDefinition = "TEXT") 29 | String comment; 30 | 31 | @Column(length = 11) 32 | Integer ord; 33 | 34 | @Temporal(value=TemporalType.TIMESTAMP) 35 | Date gmtCreate; 36 | 37 | @Temporal(value=TemporalType.TIMESTAMP) 38 | Date gmtModify; 39 | 40 | @Temporal(value=TemporalType.TIMESTAMP) 41 | Date gmtEnd; 42 | 43 | @OneToOne 44 | @JoinColumn 45 | Priority priority; 46 | 47 | @ManyToOne 48 | @JoinColumn(name = "paper_id") 49 | Paper paper; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.repository; 2 | 3 | import com.nanyin.entity.Role; 4 | import com.nanyin.entity.User; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.List; 11 | 12 | @Component 13 | public interface UserRepository extends JpaRepository, QuerydslPredicateExecutor { 14 | /** 15 | * 根据名称查询用户 16 | * @Author nanyin 17 | * @Date 20:28 2019-07-24 18 | * @param name 19 | * @return com.nanyin.entity.User 20 | **/ 21 | @Query(nativeQuery = true,value = "select u.* from user u where u.name=:name limit 1") 22 | User findUserByName(String name); 23 | 24 | @Override 25 | User saveAndFlush(User user); 26 | 27 | @Query(nativeQuery = true,value = "select u.name from user u where u.id:id limit 1") 28 | String getUserNameById(Integer id); 29 | } 30 | 31 | // 32 | -------------------------------------------------------------------------------- /src/main/resources/i18n/message_en_US.properties: -------------------------------------------------------------------------------- 1 | email_address=Email Address 2 | english=English 3 | password=Password 4 | please_sign_in=Please sign in 5 | remember_me=Remember me 6 | sign_in=Sign in 7 | simplified_chinese=Simplified Chinese 8 | username_or_password_wrong=Username or password is incorrect, please re-enter ! 9 | user_has_been_blocked=User has been locked 10 | sign_out=Sign out 11 | search=Search.. 12 | product=Project Manage System 13 | version=Version 2.0 14 | not_selected=Not selected .. 15 | project_status=Project Status 16 | project_level=Project Level 17 | project_type=Project Type 18 | system_error=The system is abnormal. Please contact the administrator. 19 | no_account=This user does not exist! 20 | check_error=check error 21 | start_log=---------- Start the method [{1}] in class [{0}] belonging to module [{2}] for log tracking, implementing [{3}]---------- 22 | after_log=---------- End the method [{1}] in class [{0}] belonging to module [{2}] for log tracking, implementing [{3}], method takes time [{4}]---------- 23 | search_users=Retrieve user list 24 | search_user_info=Query user id as {0} information -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/handler/CustomAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security.handler; 2 | 3 | import org.springframework.security.access.AccessDeniedException; 4 | import org.springframework.security.web.access.AccessDeniedHandler; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.io.IOException; 10 | 11 | /** 12 | * 处理 AccessDeniedException 13 | */ 14 | public class CustomAccessDeniedHandler implements AccessDeniedHandler { 15 | 16 | @Override 17 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException { 18 | // This is invoked when user tries to access a secured REST resource without the necessary authorization 19 | // We should just send a 403 Forbidden response because there is no 'error' page to redirect to 20 | // Here you can place any message you want 21 | response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/handler/CustomAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security.handler; 2 | 3 | import org.springframework.security.core.AuthenticationException; 4 | import org.springframework.security.web.AuthenticationEntryPoint; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.io.IOException; 10 | 11 | public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { 12 | 13 | @Override 14 | public void commence(HttpServletRequest request, 15 | HttpServletResponse response, 16 | AuthenticationException authException) throws IOException { 17 | // This is invoked when user tries to access a secured REST resource without supplying any credentials 18 | // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to 19 | // Here you can place any message you want 20 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/enums/ResultCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.enums; 2 | 3 | public enum ResultCodeEnum { 4 | /** 5 | * illegal token : code : 50008 6 | */ 7 | ILLEGAL_TOKEN(50008,"illegal token"), 8 | /** 9 | * TOKEN_EXPIRED : code : 50014 10 | */ 11 | TOKEN_EXPIRED(50014,"token expired"), 12 | 13 | /** 14 | * SUCCESS : code : 20000 15 | */ 16 | SUCCESS(20000,"success"), 17 | /** 18 | * FAIL : code : 10000 19 | */ 20 | FAIL(10000,"fail"), 21 | /** 22 | * NO_PERMISSION: code : 10005 23 | */ 24 | NO_PERMISSION(10005,"no permission"), 25 | /** 26 | * WRONG_USERNAME_OR_PASSWORD : code :10006 27 | */ 28 | WRONG_USERNAME_OR_PASSWORD(10006,"wrong username or password"); 29 | 30 | private Integer code; 31 | private String message; 32 | 33 | ResultCodeEnum(Integer code, String message) { 34 | this.code = code; 35 | this.message = message; 36 | } 37 | 38 | public int getCode() { 39 | return code; 40 | } 41 | 42 | public String getMessage() { 43 | return message; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/exceptionHandler/ShiroAuthorizationExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.exceptionHandler; 2 | 3 | import com.nanyin.config.enums.ResultCodeEnum; 4 | import com.nanyin.config.util.Result; 5 | import org.apache.shiro.authz.UnauthenticatedException; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.bind.annotation.RestControllerAdvice; 11 | 12 | @RestControllerAdvice 13 | public class ShiroAuthorizationExceptionHandler { 14 | 15 | private static final Logger logger = LoggerFactory.getLogger(ShiroAuthorizationExceptionHandler.class); 16 | 17 | @ResponseBody 18 | @ExceptionHandler(value = {UnauthenticatedException.class}) 19 | public Result authorizationExceptionHandler(Exception exception) { 20 | Result result = new Result<>(); 21 | logger.error("Occur Exception:"+exception.getClass().getSimpleName()+",Message Show:"+exception.getMessage()); 22 | result.setCode(ResultCodeEnum.NO_PERMISSION); 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/CustomAuthenticatioToken.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security; 2 | 3 | import com.nanyin.config.util.HttpUtils; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.GrantedAuthority; 6 | 7 | import javax.servlet.http.Cookie; 8 | import java.util.Collection; 9 | 10 | /** 11 | * 自定义token,继承自UsernamePasswordAuthenticationToken 12 | */ 13 | public class CustomAuthenticatioToken extends UsernamePasswordAuthenticationToken { 14 | 15 | private String token; 16 | 17 | public String getToken() { 18 | return token; 19 | } 20 | 21 | public CustomAuthenticatioToken(Object principal, Object credentials) { 22 | super(principal, credentials); 23 | } 24 | 25 | public CustomAuthenticatioToken(Object principal, Object credentials, Collection authorities,String token) { 26 | super(principal, credentials, authorities); 27 | this.token = token; 28 | } 29 | 30 | public void setToken(String token){ 31 | this.token = token; 32 | // Cookie tokenCookie = HttpUtils.buildCookie("TokenKey", token); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/js/index.js: -------------------------------------------------------------------------------- 1 | /* globals Chart:false, feather:false */ 2 | 3 | (function () { 4 | 'use strict' 5 | 6 | feather.replace() 7 | 8 | // Graphs 9 | var ctx = document.getElementById('myChart') 10 | // eslint-disable-next-line no-unused-vars 11 | var myChart = new Chart(ctx, { 12 | type: 'line', 13 | data: { 14 | labels: [ 15 | 'Sunday', 16 | 'Monday', 17 | 'Tuesday', 18 | 'Wednesday', 19 | 'Thursday', 20 | 'Friday', 21 | 'Saturday' 22 | ], 23 | datasets: [{ 24 | data: [ 25 | 15339, 26 | 21345, 27 | 18483, 28 | 24003, 29 | 23489, 30 | 24092, 31 | 12034 32 | ], 33 | lineTension: 0, 34 | backgroundColor: 'transparent', 35 | borderColor: '#007bff', 36 | borderWidth: 4, 37 | pointBackgroundColor: '#007bff' 38 | }] 39 | }, 40 | options: { 41 | scales: { 42 | yAxes: [{ 43 | ticks: { 44 | beginAtZero: false 45 | } 46 | }] 47 | }, 48 | legend: { 49 | display: false 50 | } 51 | } 52 | }) 53 | }()) 54 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/filter/CORSFilter.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.filter; 2 | 3 | import org.apache.catalina.filters.CorsFilter; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.cors.CorsConfigurationSource; 7 | 8 | import javax.servlet.*; 9 | import javax.servlet.http.HttpServletResponse; 10 | import java.io.IOException; 11 | 12 | //@Component 13 | public class CORSFilter extends CorsFilter { 14 | 15 | @Override 16 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 17 | HttpServletResponse response = (HttpServletResponse) res; 18 | response.setHeader("Access-Control-Allow-Origin", "*"); 19 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 20 | response.setHeader("Access-Control-Max-Age", "5000"); 21 | response.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 22 | chain.doFilter(req, res); 23 | } 24 | @Override 25 | public void init(FilterConfig filterConfig) {} 26 | @Override 27 | public void destroy() {} 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/JobEntity.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | /** 7 | * Created by NanYin on 2019/9/18. 8 | */ 9 | @Data 10 | @Entity 11 | @Table(name = "job") 12 | public class JobEntity { 13 | 14 | @Id 15 | @Column(columnDefinition = "INT(11)") 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private Integer id; 18 | 19 | @Column(name = "job_name") 20 | private String name; 21 | 22 | @Column(name = "job_group") 23 | private String group; 24 | 25 | @Column(name = "cron") 26 | private String cron; 27 | /* 28 | job的参数,jar包内需要的参数 29 | */ 30 | @Column(name = "parameter") 31 | private String parameter; 32 | 33 | /* 34 | 描述 35 | */ 36 | private String description; 37 | /* 38 | VM参数 39 | */ 40 | @Column(name = "vm_param") 41 | private String vmParam; 42 | /* 43 | 包含jab的jar包路径 44 | */ 45 | @Column(name = "jar_path") 46 | private String jarPath; 47 | /* 48 | job的状态 49 | */ 50 | @Column(length = 32) 51 | @Enumerated(EnumType.STRING) 52 | private JobStatus status; 53 | /* 54 | job的类 55 | */ 56 | private String jobClass; 57 | } 58 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/css/sidebar.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Sidebar 3 | */ 4 | 5 | .sidebar { 6 | position: fixed; 7 | top: 0; 8 | bottom: 0; 9 | left: 0; 10 | z-index: 100; /* Behind the navbar */ 11 | padding: 48px 0 0; /* Height of navbar */ 12 | box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); 13 | } 14 | 15 | .sidebar-sticky { 16 | position: relative; 17 | top: 0; 18 | height: calc(100vh - 48px); 19 | padding-top: .5rem; 20 | overflow-x: hidden; 21 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 22 | } 23 | 24 | @supports ((position: -webkit-sticky) or (position: sticky)) { 25 | .sidebar-sticky { 26 | position: -webkit-sticky; 27 | position: sticky; 28 | } 29 | } 30 | 31 | .sidebar .nav-link { 32 | font-weight: 500; 33 | color: #333; 34 | } 35 | 36 | .sidebar .nav-link .feather { 37 | margin-right: 4px; 38 | color: #999; 39 | } 40 | 41 | .sidebar .nav-link.active { 42 | color: #007bff; 43 | } 44 | 45 | .sidebar .nav-link:hover .feather, 46 | .sidebar .nav-link.active .feather { 47 | color: inherit; 48 | } 49 | 50 | .sidebar-heading { 51 | font-size: .75rem; 52 | text-transform: uppercase; 53 | } 54 | 55 | body { 56 | font-size: .875rem; 57 | } -------------------------------------------------------------------------------- /src/main/resources/templates/error/401.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Bottom navbar example for Bootstrap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

404 NOT FOUND

21 |

地址访问不到

22 | 返回主页 » 23 | RETURN HOME PAGE » 24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Operate.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import com.nanyin.config.enums.OperationTypeEnum; 4 | import lombok.Data; 5 | 6 | import javax.persistence.*; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | @Data 11 | @Entity 12 | @Table(name = "operate" ) 13 | public class Operate implements Serializable { 14 | @Id 15 | @Column(columnDefinition = "INT(11)") 16 | @GeneratedValue(strategy= GenerationType.IDENTITY) 17 | private Integer id; 18 | @Column(length = 64) 19 | String name; 20 | @Column(length = 1024) 21 | String comment; 22 | @Column(length = 11) 23 | Integer ord; 24 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 25 | Boolean isDeleted; 26 | @Temporal(value=TemporalType.TIMESTAMP) 27 | Date gmtCreate; 28 | @Temporal(value=TemporalType.TIMESTAMP) 29 | Date gmtModify; 30 | 31 | private static final long serialVersionUID = -450912372259672214L; 32 | @OneToOne(cascade = CascadeType.MERGE) 33 | @JoinColumn(name="user_id") 34 | private User user; 35 | 36 | @Column(length = 255) 37 | @Enumerated(EnumType.STRING) 38 | private OperationTypeEnum operateType; 39 | 40 | @Column(length=255) 41 | private String ip; 42 | 43 | @Column(length = 255) 44 | private String device; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/img/favicons/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/shiro/MySessionManager.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.shiro; 2 | 3 | import com.nanyin.config.util.CommonUtils; 4 | import org.apache.shiro.web.servlet.ShiroHttpServletRequest; 5 | import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; 6 | import org.apache.shiro.web.util.WebUtils; 7 | 8 | import javax.servlet.ServletRequest; 9 | import javax.servlet.ServletResponse; 10 | import java.io.Serializable; 11 | 12 | public class MySessionManager extends DefaultWebSessionManager { 13 | 14 | private static final String AUTHORIZATION = "Authorization"; 15 | 16 | public MySessionManager() { 17 | super(); 18 | } 19 | 20 | @Override 21 | protected Serializable getSessionId(ServletRequest request, ServletResponse response) { 22 | //前端ajax的headers中必须传入Authorization的值 23 | String id = WebUtils.toHttp(request).getHeader(AUTHORIZATION); 24 | //如果请求头中有 Authorization 则其值为sessionId 25 | if (!CommonUtils.isNull(id)) { 26 | request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, id); 27 | request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE); 28 | return id; 29 | } else { 30 | //否则按默认规则从cookie取sessionId 31 | return super.getSessionId(request, response); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/util/HashHelper.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.util; 2 | 3 | import org.apache.shiro.codec.CodecException; 4 | import org.apache.shiro.crypto.UnknownAlgorithmException; 5 | import org.apache.shiro.crypto.hash.SimpleHash; 6 | 7 | public class HashHelper extends SimpleHash { 8 | public HashHelper(String algorithmName) { 9 | super(algorithmName); 10 | } 11 | 12 | public HashHelper(String algorithmName, Object source) throws CodecException, UnknownAlgorithmException { 13 | super(algorithmName, source); 14 | } 15 | 16 | public HashHelper(String algorithmName, Object source, Object salt) throws CodecException, UnknownAlgorithmException { 17 | super(algorithmName, source, salt); 18 | } 19 | 20 | public HashHelper(String algorithmName, Object source, Object salt, int hashIterations) throws CodecException, UnknownAlgorithmException { 21 | super(algorithmName, source, salt, hashIterations); 22 | } 23 | 24 | @Override 25 | protected byte[] objectToBytes(Object o) { 26 | if(o.getClass().equals(int.class) || o.getClass().equals(Integer.class)){ 27 | Integer result = (int) o; 28 | return new byte[]{result.byteValue()}; 29 | }else{ 30 | String result = (String) o; 31 | return result.getBytes(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Tickets.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.Date; 7 | import java.util.Set; 8 | 9 | /** 10 | * 定义 工单,一个工单是一个工作内容的集合,比如一个项目 11 | */ 12 | @Data 13 | @Entity 14 | public class Tickets { 15 | @Id 16 | @Column(columnDefinition = "INT(11)") 17 | @GeneratedValue(strategy= GenerationType.IDENTITY) 18 | private Integer id; 19 | 20 | /** 21 | * 工单名称 22 | */ 23 | @Column(length = 2048) 24 | String name; 25 | 26 | /** 27 | * 工单内容 28 | */ 29 | @Column(columnDefinition = "TEXT") 30 | String comment; 31 | 32 | @Column(length = 11) 33 | Integer ord; 34 | 35 | @Temporal(value=TemporalType.TIMESTAMP) 36 | Date gmtCreate; 37 | 38 | @Temporal(value=TemporalType.TIMESTAMP) 39 | Date gmtModify; 40 | 41 | @Temporal(value=TemporalType.TIMESTAMP) 42 | Date gmtEnd; 43 | 44 | /** 45 | * 发起人 46 | */ 47 | @OneToOne 48 | @JoinColumn(columnDefinition = "INT(11)") 49 | User sponsor; 50 | 51 | /** 52 | * 工单由页组成 53 | */ 54 | @OneToMany(cascade = CascadeType.ALL,mappedBy = "tickets") 55 | Set papers; 56 | 57 | /** 58 | * 优先级 59 | */ 60 | @OneToOne 61 | @JoinColumn(columnDefinition = "INT(11)") 62 | Priority priority; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Paper.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | import java.util.Date; 7 | import java.util.Set; 8 | 9 | /** 10 | * 工单由 paper 组成,一个工单由若干页 11 | */ 12 | @Data 13 | @Entity 14 | public class Paper { 15 | 16 | @Id 17 | @Column(columnDefinition = "INT(11)") 18 | @GeneratedValue(strategy= GenerationType.IDENTITY) 19 | private Integer id; 20 | 21 | /** 22 | * Paper名称 23 | */ 24 | @Column(length = 2048) 25 | String name; 26 | 27 | /** 28 | * Paper内容 29 | */ 30 | @Column(columnDefinition = "TEXT") 31 | String comment; 32 | 33 | @Column(length = 11) 34 | Integer ord; 35 | 36 | @Temporal(value=TemporalType.TIMESTAMP) 37 | Date gmtCreate; 38 | 39 | @Temporal(value=TemporalType.TIMESTAMP) 40 | Date gmtModify; 41 | 42 | @Temporal(value=TemporalType.TIMESTAMP) 43 | Date gmtEnd; 44 | 45 | /** 46 | * 处理人 47 | */ 48 | @OneToOne 49 | @JoinColumn 50 | User handler; 51 | 52 | /** 53 | * 处理时间 54 | */ 55 | @Temporal(value=TemporalType.TIMESTAMP) 56 | Date gmtHandle; 57 | 58 | /** 59 | * 一个paper由多个task组成 60 | */ 61 | @OneToMany(cascade = CascadeType.ALL,mappedBy = "paper") 62 | Set tasks; 63 | 64 | @ManyToOne 65 | @JoinColumn(name = "ticket_id") 66 | Tickets tickets; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/js/validate/user-validate.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | // validate 3 | $("#add").validate({ 4 | errorClass: "is-invalid", 5 | success: "valid", 6 | ignore: "", 7 | validClass: "is-valid", 8 | errorElement: 'em', 9 | errorPlacement: function(error, element) { 10 | var elem = $(element); 11 | if (elem.hasClass("select2-hidden-accessible")) { 12 | element = elem.next(); 13 | error.insertAfter(element); 14 | } else { 15 | error.insertAfter(element); 16 | } 17 | }, 18 | rules: { 19 | name: "required", 20 | email: { 21 | required: true, 22 | email: true 23 | }, 24 | auths: "required", 25 | status: "required", 26 | sex: "required" 27 | }, 28 | messages: { 29 | name: "名称必填", 30 | email: { 31 | required: "邮箱字段必填", 32 | email: "Your email address must be in the format of name@domain.com" 33 | }, 34 | auths: { 35 | required: "字段必填", 36 | }, 37 | status: { 38 | required: "字段必填", 39 | }, 40 | sex: { 41 | required: "字段必填", 42 | } 43 | }, 44 | }); 45 | 46 | 47 | }) -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/locale/MyLocaleResolver.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.locale; 2 | 3 | import com.nanyin.config.util.MDCUtil; 4 | import org.springframework.web.servlet.LocaleResolver; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.util.Locale; 9 | 10 | 11 | public class MyLocaleResolver implements LocaleResolver { 12 | 13 | @Override 14 | public Locale resolveLocale(HttpServletRequest request) { 15 | // Cookie[] cookies = request.getCookies(); 16 | // String locale = null; 17 | // for (Cookie cookie:cookies 18 | // ) { 19 | // if("locale".equals(cookie.getName())){ 20 | // locale = cookie.getValue(); 21 | // } 22 | // } 23 | // if(locale == null || "".equals(locale)){ 24 | // return Locale.SIMPLIFIED_CHINESE; 25 | // }else { 26 | // CommonUtils.check(locale.split("_").length>1,"check_error","resolveLocale"); 27 | // // 在MDC中存放副本 28 | // Locale locale1 = new Locale(locale.split("_")[0],locale.split("_")[1]); 29 | // MDCUtil.setLocale(locale1); 30 | // return locale1; 31 | // } 32 | Locale locale = MDCUtil.getLocale(); 33 | return locale; 34 | } 35 | 36 | @Override 37 | public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) { 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.google.common.base.Objects; 6 | import lombok.Data; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | import javax.persistence.*; 11 | import java.util.Date; 12 | import java.util.Set; 13 | 14 | @Getter 15 | @Setter 16 | @Entity 17 | @Table(name = "permission") 18 | public class Permission{ 19 | @Id 20 | @Column(columnDefinition = "INT(11)") 21 | @GeneratedValue(strategy= GenerationType.IDENTITY) 22 | private Integer id; 23 | @Column(length = 64) 24 | String name; 25 | @Column(length = 1024) 26 | String comment; 27 | @Column(length = 11) 28 | Integer ord; 29 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4)") 30 | Boolean isDeleted=false; 31 | 32 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 33 | @Temporal(value=TemporalType.TIMESTAMP) 34 | Date gmtCreate; 35 | 36 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 37 | @Temporal(value=TemporalType.TIMESTAMP) 38 | Date gmtModify; 39 | 40 | @JSONField(serialize=false) 41 | @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) 42 | @JoinTable(name = "r_role_permission", 43 | joinColumns = {@JoinColumn(name = "permission_id")}, 44 | inverseJoinColumns = {@JoinColumn(name = "role_id")}) 45 | Set roles; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/handler/CustomLogoutSuccessHandler.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.nanyin.config.enums.ResultCodeEnum; 5 | import com.nanyin.config.util.Result; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.core.context.SecurityContext; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 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 | /** 18 | * 登出后的操作,在配置时需要配置到config中 19 | */ 20 | public class CustomLogoutSuccessHandler implements LogoutSuccessHandler { 21 | @Override 22 | public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { 23 | // 清除 context 信息 24 | SecurityContext context = SecurityContextHolder.getContext(); 25 | context.setAuthentication(null); 26 | SecurityContextHolder.clearContext(); 27 | // 返回内容给前端 28 | PrintWriter writer = response.getWriter(); 29 | Result result = new Result(); 30 | result.setCode(ResultCodeEnum.TOKEN_EXPIRED); 31 | writer.append(JSON.toJSONString(result)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/js/userInfo.js: -------------------------------------------------------------------------------- 1 | // $(document).ready(function () { 2 | // $('select').select2({ 3 | // theme: 'bootstrap4', 4 | // }) 5 | // }) 6 | 7 | function showModifyModal(id) { 8 | $('#modifyModal').modal('show'); 9 | } 10 | 11 | function saveUser(id) { 12 | var flag = $("#add").valid(); 13 | if (!flag) { 14 | //没有通过验证 15 | return; 16 | } 17 | var type = "PUT"; 18 | var url = "/user/user/"+id; 19 | // 数据 20 | var t = $('#modify').serialize(); 21 | 22 | $.ajax({ 23 | type: type, 24 | url: url, 25 | dataType: 'json', 26 | contentType:'application/json', 27 | data: JSON.stringify(t), 28 | success: function (res) { 29 | var data = JSON.parse(res); 30 | if (data.code === 0) { 31 | $("#modifyModal").modal("hide"); 32 | swal({ 33 | title: "Success!", 34 | text: "修改成功!Modifyed successfully!", 35 | type: "success", 36 | confirmButtonClass: "btn-primary", 37 | confirmButtonText: "确认", 38 | }, function () { 39 | 40 | }) 41 | } else { 42 | swal("保存失败,请重试!", "Save failed, please try again!"); 43 | } 44 | }, 45 | error: function (request, status, error) { 46 | swal("请求出错,请重试!", "Request error, please try again!"); 47 | } 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/CustomAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security; 2 | 3 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 4 | import org.springframework.security.authentication.dao.DaoAuthenticationProvider; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 10 | 11 | /** 12 | * 自定义 provider 需要在config中指定provider,实现更复杂的登陆验证和角色认证 13 | */ 14 | public class CustomAuthenticationProvider extends DaoAuthenticationProvider { 15 | 16 | public CustomAuthenticationProvider(UserDetailsService userDetailsService) { 17 | setUserDetailsService(userDetailsService); 18 | setPasswordEncoder(new BCryptPasswordEncoder()); 19 | } 20 | 21 | @Override 22 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 23 | System.out.println("登录认证逻辑"); 24 | return super.authenticate(authentication); 25 | } 26 | 27 | @Override 28 | protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) 29 | throws AuthenticationException { 30 | System.out.println("密码验证逻辑"); 31 | super.additionalAuthenticationChecks(userDetails, authentication); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/UserServices.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.nanyin.entity.Sex; 4 | import com.nanyin.entity.Status; 5 | import com.nanyin.entity.User; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | @Service 13 | public interface UserServices { 14 | 15 | User getUserFromUserName(String name) throws Exception; 16 | 17 | 18 | Page findUsers(Integer offset, Integer limit, String order, String search, Integer status, Integer sex, Integer role) throws Exception; 19 | 20 | String login(String username, String password, Boolean rememberMe) throws Exception; 21 | 22 | User getCurrentUserInfo(String token) throws Exception; 23 | 24 | List getStandardSex() throws Exception; 25 | 26 | List getStandardStatus() throws Exception; 27 | 28 | String logout(String token) throws Exception; 29 | 30 | User saveUser(User user) throws Exception; 31 | 32 | User updateUser(User user) throws Exception; 33 | 34 | void deleteUser(Integer id) throws Exception; 35 | 36 | User findUserByName(String name); 37 | 38 | Map> getRolePerson(Integer role) throws Exception; 39 | 40 | /** 41 | * 返回Page的User数据 42 | * @param id 43 | * @param search 44 | * @param offset 45 | * @param limit 46 | * @param sort 47 | * @return 48 | */ 49 | Page findUnitUsers(Integer id, String search, Integer offset, Integer limit, String sort); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Person.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.*; 5 | import org.hibernate.annotations.Fetch; 6 | import org.hibernate.annotations.FetchMode; 7 | import org.hibernate.annotations.NotFound; 8 | import org.hibernate.annotations.NotFoundAction; 9 | 10 | import javax.persistence.*; 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | import java.util.Set; 14 | 15 | /** 16 | * 作为人员的扩展信息使用 17 | * 如职位、头像、各种联系方式 18 | **/ 19 | @Data 20 | @Entity 21 | @Table(name = "person") 22 | public class Person implements Serializable { 23 | private static final long serialVersionUID = -7783058473676963173L; 24 | @Id 25 | @Column(columnDefinition = "INT(11)") 26 | @GeneratedValue(strategy= GenerationType.IDENTITY ) 27 | private Integer id; 28 | 29 | @Column(length = 64) 30 | private String name; 31 | 32 | /** 33 | * 居住地址 34 | **/ 35 | @Column(length = 512) 36 | private String address; 37 | 38 | /** 39 | * 头像 40 | **/ 41 | @Column(length = 512) 42 | private String avatar; 43 | 44 | /** 45 | * 简介 46 | **/ 47 | @Column(length = 512) 48 | private String introduction; 49 | 50 | /** 51 | * 手机号 52 | **/ 53 | private String telephone; 54 | 55 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4) default 0") 56 | private Boolean isDeleted ; 57 | @Temporal(value=TemporalType.TIMESTAMP) 58 | private Date gmtCreate; 59 | @Temporal(value=TemporalType.TIMESTAMP) 60 | private Date gmtModify; 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/util/Result.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.util; 2 | 3 | import com.nanyin.config.enums.ResultCodeEnum; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.Collection; 8 | import java.util.Map; 9 | 10 | public class Result implements Serializable { 11 | 12 | /** 13 | * 定义返回信息,默认success 14 | */ 15 | private String message = "success"; 16 | 17 | /** 18 | * 定义返回code值,默认 SUCCESS 19 | */ 20 | private int code = ResultCodeEnum.SUCCESS.getCode(); 21 | 22 | /** 23 | * 定义返回数据 24 | */ 25 | private T data; 26 | 27 | 28 | public Result() { 29 | super(); 30 | } 31 | 32 | public String getMessage() { 33 | return message; 34 | } 35 | 36 | public void setMessage(String message) { 37 | this.message = message; 38 | } 39 | 40 | public int getCode() { 41 | return code; 42 | } 43 | 44 | /** 45 | * 使用setCode方法会默认将ResultCodeEnum中的code和message赋予给result 46 | * 如果默认的message不符合情况,可使用setMessage方法再次设置一次message 47 | * @param code 48 | */ 49 | public void setCode(ResultCodeEnum code) { 50 | this.code = code.getCode(); 51 | this.message = code.getMessage(); 52 | } 53 | 54 | public T getData() { 55 | return data; 56 | } 57 | 58 | public void setData(T data) { 59 | this.data = data; 60 | } 61 | 62 | public Result(T data) { 63 | super(); 64 | this.data = data; 65 | } 66 | 67 | public Result(String message, int code, T data) { 68 | this.message = message; 69 | this.code = code; 70 | this.data = data; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Unit.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.google.common.base.Objects; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | import javax.persistence.*; 9 | import java.util.Date; 10 | import java.util.Set; 11 | 12 | /** 13 | * 单位表 14 | * 15 | */ 16 | @Getter 17 | @Setter 18 | @Entity 19 | @Table(name = "unit") 20 | public class Unit { 21 | 22 | @Id 23 | @Column(columnDefinition = "INT(11)") 24 | @GeneratedValue(strategy= GenerationType.IDENTITY) 25 | private Integer id; 26 | 27 | /** 28 | * 名称 29 | */ 30 | @Column(length = 256) 31 | String name; 32 | 33 | /** 34 | * 编号 35 | */ 36 | @Column(length = 256) 37 | String code; 38 | 39 | /** 40 | * 地址 41 | */ 42 | @Column(length = 2048) 43 | String address; 44 | 45 | /** 46 | * 内容 47 | */ 48 | @Column(columnDefinition = "TEXT") 49 | String comment; 50 | 51 | @Column(length = 11) 52 | Integer ord; 53 | 54 | @Temporal(value=TemporalType.TIMESTAMP) 55 | Date gmtCreate; 56 | 57 | @Temporal(value=TemporalType.TIMESTAMP) 58 | Date gmtModify; 59 | 60 | @OneToMany(cascade = CascadeType.ALL,mappedBy = "parent") 61 | Set children; 62 | 63 | @ManyToOne() 64 | @JoinColumn(name = "parent_id") 65 | @JSONField(serialize = false) 66 | Unit parent; 67 | 68 | @OneToMany(cascade = CascadeType.ALL,mappedBy = "unit") 69 | Set users; 70 | 71 | public Unit() { 72 | } 73 | 74 | public Unit(Integer id, String name, Unit parent) { 75 | this.id = id; 76 | this.name = name; 77 | this.parent = parent; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.controller; 2 | 3 | import com.nanyin.config.enums.ResultCodeEnum; 4 | import com.nanyin.config.exceptions.tokenException.TokenWrongException; 5 | import com.nanyin.services.LocaleService; 6 | import com.nanyin.services.RedisService; 7 | import com.nanyin.entity.DTO.NameAndPw; 8 | import com.nanyin.config.util.Result; 9 | import com.nanyin.services.UserServices; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | /** 15 | * Created by NanYin on 2019/9/10. 16 | * 用于登录、登出等操作 17 | * 并非前后端分离项目 18 | */ 19 | @RestController 20 | public class LoginController{ 21 | 22 | 23 | @Autowired 24 | UserServices userServices; 25 | 26 | @Autowired 27 | LocaleService localeService; 28 | 29 | @Autowired 30 | RedisService redisService; 31 | 32 | @CrossOrigin(origins = "*",allowCredentials="true",allowedHeaders = "",methods = {}) 33 | @PostMapping(value = "/login") 34 | public @ResponseBody 35 | Result login(@RequestBody NameAndPw nameAndPw) throws Exception { 36 | // Boolean rememberMe = false; 37 | String data = userServices.login(nameAndPw.getUsername(),nameAndPw.getPassword(),false); 38 | if(data.equals(ResultCodeEnum.WRONG_USERNAME_OR_PASSWORD.toString())){ 39 | throw new TokenWrongException(); 40 | } 41 | return new Result<>(data); 42 | } 43 | 44 | @GetMapping("/logout") 45 | @ApiOperation(value = "登出",notes = "登出") 46 | public Result logout(String token) throws Exception { 47 | String data = userServices.logout(token); 48 | return new Result<>(data); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/filter/CustomLogoutFilter.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security.filter; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | import org.springframework.security.web.authentication.logout.LogoutFilter; 6 | import org.springframework.security.web.authentication.logout.LogoutHandler; 7 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 8 | 9 | import javax.servlet.FilterChain; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.ServletRequest; 12 | import javax.servlet.ServletResponse; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | 17 | /** 18 | * 可自定义LogoutFilter进行登出 19 | */ 20 | public class CustomLogoutFilter extends LogoutFilter { 21 | 22 | LogoutHandler handler; 23 | 24 | public CustomLogoutFilter(LogoutSuccessHandler logoutSuccessHandler, LogoutHandler handlers) { 25 | super(logoutSuccessHandler,handlers); 26 | this.handler = handlers; 27 | setFilterProcessesUrl("/logout"); 28 | } 29 | 30 | @Override 31 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) 32 | throws IOException, ServletException { 33 | HttpServletRequest request = (HttpServletRequest) req; 34 | HttpServletResponse response = (HttpServletResponse) res; 35 | 36 | if (requiresLogout(request, response)) { 37 | Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 38 | this.handler.logout(request, response, auth); 39 | return; 40 | } 41 | 42 | chain.doFilter(request, response); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.google.common.base.Objects; 5 | import lombok.Data; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.apache.shiro.authz.SimpleRole; 9 | 10 | import javax.persistence.*; 11 | import java.util.Collections; 12 | import java.util.Date; 13 | import java.util.List; 14 | import java.util.Set; 15 | 16 | @Entity 17 | @Getter 18 | @Setter 19 | @Table(name = "role") 20 | public class Role { 21 | private static final long serialVersionUID = 8538788781327321942L; 22 | @Id 23 | @Column(columnDefinition = "INT(11)") 24 | @GeneratedValue(strategy= GenerationType.IDENTITY) 25 | private Integer id; 26 | @Column(length = 64) 27 | String name; 28 | 29 | @Column(length = 11) 30 | Integer ord; 31 | @Column(name = "is_deleted",columnDefinition = "TINYINT(4)") 32 | Boolean isDeleted=false; 33 | 34 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 35 | @Temporal(value=TemporalType.TIMESTAMP) 36 | Date gmtCreate; 37 | 38 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 39 | // @Temporal(value=TemporalType.TIMESTAMP) 40 | Date gmtModify; 41 | 42 | @JSONField(serialize = false) 43 | @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) 44 | @JoinTable(name = "r_user_role", 45 | joinColumns = {@JoinColumn(name = "role_id")}, 46 | inverseJoinColumns = {@JoinColumn(name = "user_id")}) 47 | private List users; 48 | 49 | 50 | // @JSONField(serialize = false) 51 | @ManyToMany(mappedBy = "roles",cascade = CascadeType.ALL,fetch = FetchType.EAGER) 52 | private Set permissions; 53 | 54 | public static long getSerialVersionUID() { 55 | return serialVersionUID; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | driver-class-name: com.mysql.jdbc.Driver 4 | druid: 5 | initial-size: 5 6 | max-active: 20 7 | max-wait: 60000 8 | stat-view-servlet: 9 | login-password: admin 10 | login-username: admin 11 | password: 123456 12 | url: jdbc:mysql://127.0.0.1:3306/web?useUnicode=true&characterEncoding=UTF-8&useSSL=false 13 | username: root 14 | jpa: 15 | database-platform: org.hibernate.dialect.MySQL5InnoDBDialect 16 | show-sql: true 17 | hibernate: 18 | ddl-auto: update 19 | properties: 20 | hibernate: 21 | dialect: org.hibernate.dialect.MySQL5InnoDBDialect 22 | # 创建数据库 23 | # hibernate: 24 | # 国际化Resource目录设置 25 | messages: 26 | basename: i18n/message,i18n/validation 27 | # redis配置 28 | redis: 29 | database: 0 30 | host: localhost 31 | port: 6379 32 | timeout: 3600 33 | # 开发时禁用cache 34 | thymeleaf: 35 | cache: false 36 | quartz: 37 | job-store-type: jdbc 38 | #properties: 39 | # org: 40 | # quartz: 41 | # scheduler: 42 | # instanceName: clusteredScheduler 43 | # instanceId: AUTO 44 | server: 45 | port: 8080 46 | servlet: 47 | context-path: "/api/" 48 | session: 49 | store-dir: ./session 50 | persistent: true #重新启动之间持续会话数据 51 | 52 | upload: 53 | qiniu: 54 | ak: hZKOhv9GXfOztS-dX8AFwmmR6g-AbfCxuLO9JZ5x 55 | sk: VcpO6QSNxGInrgyMMr_8_qMI3W8jZZChDw2hCIon 56 | bucket: nanyiniu 57 | domain: http://q61syra66.bkt.clouddn.com/ 58 | 59 | hash: 60 | algorithm: 61 | md5: md5 62 | iterations: 1024 63 | defalutCrdentials: 123456 -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/security/CustomPermissionEvaluator.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.security; 2 | 3 | import org.springframework.security.access.PermissionEvaluator; 4 | import org.springframework.security.core.Authentication; 5 | import org.springframework.security.core.GrantedAuthority; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 自定义 hasPermission 表达式 12 | * 13 | * 注入role时,使用ROLE_开头 14 | * 注入Permission时,需要将 在角色基础上添加 _[permission] 15 | * 如 admin_write 使用hasPermission('admin', 'write') 16 | */ 17 | @Component 18 | public class CustomPermissionEvaluator implements PermissionEvaluator { 19 | 20 | @Override 21 | public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) { 22 | if ((authentication == null) || (targetDomainObject == null) || !(permission instanceof String)){ 23 | return false; 24 | } 25 | String targetType = targetDomainObject.getClass().getSimpleName().toUpperCase(); 26 | 27 | return hasPrivilege(authentication, targetType, permission.toString().toUpperCase()); 28 | } 29 | 30 | @Override 31 | public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) { 32 | if ((authentication == null) || (targetType == null) || !(permission instanceof String)) { 33 | return false; 34 | } 35 | return hasPrivilege(authentication, targetType.toUpperCase(), 36 | permission.toString().toUpperCase()); 37 | } 38 | 39 | private boolean hasPrivilege(Authentication auth, String targetType, String permission) { 40 | for (GrantedAuthority grantedAuth : auth.getAuthorities()) { 41 | if (grantedAuth.getAuthority().startsWith(targetType)) { 42 | if (grantedAuth.getAuthority().contains(permission)) { 43 | return true; 44 | } 45 | } 46 | } 47 | return false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/impl/UnitServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services.impl; 2 | 3 | import com.nanyin.config.util.PageHelper; 4 | import com.nanyin.entity.DTO.PageQueryParams; 5 | import com.nanyin.entity.DTO.UnitDto; 6 | import com.nanyin.entity.QUnit; 7 | import com.nanyin.entity.Unit; 8 | import com.nanyin.repository.UnitRepository; 9 | import com.nanyin.services.UnitService; 10 | import com.querydsl.core.types.ExpressionUtils; 11 | import com.querydsl.core.types.Predicate; 12 | import com.querydsl.jpa.impl.JPAQueryFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.data.domain.Page; 15 | import org.springframework.data.domain.PageRequest; 16 | import org.springframework.stereotype.Service; 17 | 18 | import java.util.List; 19 | 20 | @Service 21 | public class UnitServiceImpl implements UnitService { 22 | 23 | @Autowired 24 | UnitRepository unitRepository; 25 | 26 | @Autowired 27 | JPAQueryFactory jpaQueryFactory; 28 | 29 | @Override 30 | public Page findUnits(PageQueryParams pageQueryParams) throws Exception { 31 | Integer offset = pageQueryParams.getOffset(); 32 | Integer limit = pageQueryParams.getLimit(); 33 | PageRequest pageRequest = PageHelper.generatePageRequest(offset, limit); 34 | String search = pageQueryParams.getSearch(); 35 | Integer unitId = pageQueryParams.getUnit(); 36 | 37 | QUnit unit = QUnit.unit; 38 | Predicate predicate = unit.isNotNull().or(unit.isNull()); 39 | predicate = search == null ? predicate : ExpressionUtils.and(predicate, unit.name.like("%" + search + "%")); 40 | predicate = unitId == null ? 41 | ExpressionUtils.and(predicate, unit.parent.id.isNull()) : 42 | ExpressionUtils.and(predicate, unit.parent.id.eq(unitId).and(unit.id.ne(unitId))); 43 | return unitRepository.findAll(predicate, pageRequest); 44 | } 45 | 46 | @Override 47 | public List findUnitTree() throws Exception { 48 | return unitRepository.findAllByParentIsNull(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/util/MDCUtil.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.util; 2 | 3 | import org.slf4j.MDC; 4 | 5 | import java.util.Locale; 6 | /** 7 | * 使用mdc构建日志,使用ThreadLocal存储国际化信息,防止出现在url上 8 | * @Author nanyin 9 | * @Date 13:38 2019-08-20 10 | **/ 11 | public class MDCUtil { 12 | 13 | private final static ThreadLocal TL_USER = new ThreadLocal(){ 14 | @Override 15 | protected String initialValue() { 16 | return "000000-000-0000000000"; 17 | } 18 | }; 19 | 20 | private final static ThreadLocal TL_LOCALE = new ThreadLocal() { 21 | @Override 22 | protected Locale initialValue() { 23 | // 语言的默认值 24 | return Locale.SIMPLIFIED_CHINESE; 25 | }; 26 | }; 27 | 28 | private final static ThreadLocal TL_REQUEST_ID = new ThreadLocal<>(); 29 | 30 | public static final String KEY_LANG = "lang"; 31 | 32 | public static final String KEY_USER = "username"; 33 | 34 | public static final String KEY_REQUEST_ID = "requestId"; 35 | 36 | public static void setUser(String userid) { 37 | TL_USER.set(userid); 38 | MDC.put(KEY_USER, userid); 39 | } 40 | 41 | public static String getUser() { 42 | return TL_USER.get(); 43 | } 44 | 45 | public static void setLocale(String locale) { 46 | setLocale(new Locale(locale)); 47 | } 48 | 49 | public static void setLocale(Locale locale) { 50 | TL_LOCALE.set(locale); 51 | } 52 | 53 | public static Locale getLocale() { 54 | return TL_LOCALE.get(); 55 | } 56 | 57 | public static void setRequestId(String requestId) { 58 | MDC.put(KEY_REQUEST_ID, requestId); 59 | TL_REQUEST_ID.set(requestId); 60 | } 61 | 62 | public static String getRequestId() { 63 | return TL_REQUEST_ID.get(); 64 | } 65 | 66 | public static void clearAllUserInfo() { 67 | TL_USER.remove(); 68 | TL_LOCALE.remove(); 69 | TL_REQUEST_ID.remove(); 70 | MDC.remove(KEY_USER); 71 | MDC.remove(KEY_REQUEST_ID); 72 | } 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/resources/templates/error/402.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Page 404 - tabler.github.io - a responsive, flat and full featured admin template 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
30 |
402
31 |

Oops.. You just found an error page..

32 |

We are sorry but our service is currently not available…

33 | 34 | RETURN HOME PAGE » 35 | 36 |
37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/templates/error/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Page 404 - tabler.github.io - a responsive, flat and full featured admin template 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
30 |
404
31 |

Oops.. You just found an error page..

32 |

We are sorry but our service is currently not available…

33 | 34 | RETURN HOME PAGE » 35 | 36 |
37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /src/test/java/com/nanyin/WebProjectApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.nanyin; 2 | 3 | import com.nanyin.config.quartz.service.JobService; 4 | import com.nanyin.services.RedisService; 5 | import com.nanyin.services.UserServices; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import java.text.SimpleDateFormat; 13 | import java.util.ArrayList; 14 | import java.util.Calendar; 15 | import java.util.Date; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by NanYin on 2019/9/6. 20 | */ 21 | @RunWith(SpringRunner.class) 22 | @SpringBootTest 23 | public class WebProjectApplicationTest { 24 | 25 | @Test 26 | public void testDate(){ 27 | Date currentDate = new Date(); 28 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); 29 | String endTime = simpleDateFormat.format(currentDate); 30 | Calendar c = Calendar.getInstance(); 31 | c.set(Calendar.DAY_OF_MONTH, 0); 32 | String startTime = simpleDateFormat.format(c.getTime()); 33 | System.out.println(endTime); 34 | System.out.println(startTime); 35 | } 36 | 37 | /** 38 | * 初始化数据 39 | */ 40 | @Test 41 | public void initData(){ 42 | List list = new ArrayList<>(); 43 | list.add(1); 44 | list.add(2); 45 | list.add(3); 46 | list.add(5); 47 | list.forEach(x -> { 48 | System.out.println(x); 49 | }); 50 | } 51 | 52 | @Test 53 | public void testStingFormat(){ 54 | String format = String.format("%s:%s", "x", "y"); 55 | System.out.println(format); 56 | } 57 | 58 | @Autowired 59 | JobService jobService; 60 | @Test 61 | public void TestQuartzJobs(){ 62 | try { 63 | jobService.openAssignJob(2); 64 | 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | @Autowired 70 | RedisService redisService ; 71 | @Autowired 72 | UserServices userServices; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ssm-web-project 2 | 3 | # 项目介绍(正在重构) 4 | 5 | 基于SpringBoot,Spring Data JPA,Shiro开发的前后端分离的拥有权限管理的工作系统.具体模块正在开发中..前端[项目地址](https://github.com/NanYinIU/vue-admin) 6 | 7 | ## 涉及框架 8 | 9 | #### 后端框架: 10 | 11 | 技术 | 名称 | 官网 12 | ---|------|---- 13 | Spring Framework | 容器 | [http://projects.spring.io/spring-framework/](http://projects.spring.io/spring-framework/) 14 | SpringMVC | MVC框架 | [http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc](http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc) 15 | Spring Data JPA | ORM框架 | https://spring.io/projects/spring-data-jpa 16 | Apache Shiro | 安全框架 | [http://shiro.apache.org/](http://shiro.apache.org/) 17 | Maven | 项目构建管理 | [http://maven.apache.org/](http://maven.apache.org/) 18 | Druid | 数据库连接池 | [https://github.com/alibaba/druid](https://github.com/alibaba/druid) 19 | hibernate-validator | 校验框架 | http://hibernate.org/validator 20 | Logback | SpringBoot默认日志框架 | http://logback.qos.ch/ 21 | Swagger2 | 文档管理 | https://swagger.io/ 22 | quartz | 定时任务 | https://qz.com/ 23 | redis | 数据缓存 | https://redis.io/ 24 | 25 | #### 前端技术: 26 | 技术 | 名称 | 官网 27 | ----|------|---- 28 | vue-element-admin | 前端VUE基本框架 | https://github.com/PanJiaChen/vue-element-admin 29 | vue-element | VUE框架 | https://element.eleme.cn/ 30 | 31 | ## 开发环境 32 | 33 | -IDE:intellJ IDEA 34 | -数据库:Mysql 35 | -应用服务器:tomcat 36 | -数据库客户端:TablePlus 37 | -jdk版本:jdk8 38 | 39 | ## 截图 40 | 41 | 42 | 43 | ## 相关内容 44 | 45 | 以下内容是自己在学习过程中的应用和总结,可以参考以下博文,有问题可以及时联系: 46 | 47 | 1. [SpringBoot集成缓存](https://nanyiniu.github.io/2019/08/15/2019-08-15-Spring的缓存/) 48 | 2. [SpringBoot整合JPA与使用](https://nanyiniu.github.io/2020/03/05/SpringBoot整合JPA使用/) 49 | 3. [SpringBoot自定义Starter](https://nanyiniu.github.io/2019/08/13/2019-08-13-SpringBoot的自定义starter开发/) 50 | 4. [使用Thymeleaf继承SpringBoot完成前后端的国际化](https://nanyiniu.github.io/2019/07/15/SpringBoot的WEB开发之国际化/) 51 | 52 | 53 | 54 | ## 其他 55 | 56 | 自己是个小白,欢迎一起交流学习.[我的博客](https://nanyiniu.github.io) 57 | -------------------------------------------------------------------------------- /src/test/java/com/nanyin/controller/UserControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.controller; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.test.web.servlet.MockMvc; 11 | import org.springframework.test.web.servlet.ResultMatcher; 12 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 13 | import org.springframework.web.context.WebApplicationContext; 14 | 15 | import static org.hamcrest.CoreMatchers.containsString; 16 | import static org.junit.Assert.*; 17 | import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; 18 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 20 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 21 | 22 | /** 23 | * 单元测试测试Controller层 24 | */ 25 | @RunWith(SpringRunner.class) 26 | @SpringBootTest 27 | public class UserControllerTest { 28 | 29 | @Autowired 30 | private WebApplicationContext webApplicationContext; 31 | private MockMvc mockMvc; 32 | 33 | @Before 34 | public void setUp() { 35 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); 36 | } 37 | 38 | 39 | @Test 40 | public void userStandardSex() throws Exception{ 41 | String response = mockMvc.perform(get("/user/sex"). 42 | accept(MediaType.APPLICATION_JSON_UTF8_VALUE)). 43 | andExpect(status().isOk()).andDo(print()).andReturn().getResponse().getContentAsString(); 44 | System.out.println(response); 45 | } 46 | 47 | 48 | @Test 49 | public void userStandardStatus() { 50 | } 51 | 52 | @Test 53 | public void userInfo() throws Exception{ 54 | mockMvc.perform(get("/user/info"). 55 | accept(MediaType.APPLICATION_JSON_UTF8_VALUE)). 56 | andExpect(status().isOk()). 57 | andReturn(); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/redis/FastJson2JsonRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.redis; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.parser.ParserConfig; 5 | import com.alibaba.fastjson.serializer.SerializerFeature; 6 | import com.fasterxml.jackson.databind.JavaType; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import com.fasterxml.jackson.databind.type.TypeFactory; 9 | import org.apache.shiro.util.Assert; 10 | import org.springframework.data.redis.serializer.RedisSerializer; 11 | import org.springframework.data.redis.serializer.SerializationException; 12 | 13 | import java.nio.charset.Charset; 14 | 15 | public class FastJson2JsonRedisSerializer implements RedisSerializer { 16 | private ObjectMapper objectMapper = new ObjectMapper(); 17 | 18 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 19 | 20 | private Class clazz; 21 | 22 | static { 23 | ParserConfig.getGlobalInstance().setAutoTypeSupport(true); 24 | //如果遇到反序列化autoType is not support错误,请添加并修改一下包名到bean文件路径 25 | // ParserConfig.getGlobalInstance().addAccept("com.xxxxx.xxx"); 26 | } 27 | public FastJson2JsonRedisSerializer(Class clazz) { 28 | super(); 29 | this.clazz = clazz; 30 | } 31 | 32 | // 序列化 33 | @Override 34 | public byte[] serialize(T t) throws SerializationException { 35 | if (t == null) { 36 | return new byte[0]; 37 | } 38 | return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); 39 | } 40 | 41 | // 反序列化 42 | @Override 43 | public T deserialize(byte[] bytes) throws SerializationException { 44 | if (bytes == null || bytes.length <= 0) { 45 | return null; 46 | } 47 | String str = new String(bytes, DEFAULT_CHARSET); 48 | return JSON.parseObject(str, clazz); 49 | } 50 | 51 | public void setObjectMapper(ObjectMapper objectMapper) { 52 | Assert.notNull(objectMapper, "'objectMapper' must not be null"); 53 | this.objectMapper = objectMapper; 54 | } 55 | 56 | protected JavaType getJavaType(Class clazz) { 57 | return TypeFactory.defaultInstance().constructType(clazz); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/exceptions/exceptionHandler/FieldValidExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.exceptions.exceptionHandler; 2 | 3 | import com.google.common.base.Strings; 4 | import com.nanyin.config.util.Result; 5 | import com.nanyin.config.enums.ResultCodeEnum; 6 | import com.nanyin.services.LocaleService; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.BindException; 11 | import org.springframework.validation.BindingResult; 12 | import org.springframework.web.bind.MethodArgumentNotValidException; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * 统一字段规则的异常处理 17 | **/ 18 | 19 | @RestControllerAdvice 20 | public class FieldValidExceptionHandler { 21 | 22 | @Autowired 23 | LocaleService localeService; 24 | 25 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 26 | /** 27 | * 对hibernate validate进行统一的异常管理 28 | * @Author nanyin 29 | * @Date 20:06 2019-08-07 30 | **/ 31 | @ResponseBody 32 | @ExceptionHandler(value = {BindException.class, MethodArgumentNotValidException.class}) 33 | public Result validationExceptionHandler(Exception exception) { 34 | BindingResult bindResult = null; 35 | if (exception instanceof BindException) { 36 | bindResult = ((BindException) exception).getBindingResult(); 37 | } else if (exception instanceof MethodArgumentNotValidException) { 38 | bindResult = ((MethodArgumentNotValidException) exception).getBindingResult(); 39 | } 40 | String msg; 41 | if (bindResult != null && bindResult.hasErrors()) { 42 | String code = bindResult.getAllErrors().get(0).getDefaultMessage(); 43 | // 把两边的 {} 去掉 44 | if(!Strings.isNullOrEmpty(code) && code.length() > 1){ 45 | code = code.substring(1,code.length()-1); 46 | } 47 | msg =localeService.getMessage(code); 48 | 49 | }else { 50 | msg = "系统繁忙,请稍后重试..."; 51 | } 52 | Result result = new Result<>(); 53 | result.setMessage(msg); 54 | result.setCode(ResultCodeEnum.FAIL); 55 | return result; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/UploadService.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services; 2 | 3 | import com.google.common.io.Files; 4 | import com.google.gson.Gson; 5 | import com.qiniu.common.QiniuException; 6 | import com.qiniu.http.Response; 7 | import com.qiniu.storage.Configuration; 8 | import com.qiniu.storage.Region; 9 | import com.qiniu.storage.UploadManager; 10 | import com.qiniu.storage.model.DefaultPutRet; 11 | import com.qiniu.util.Auth; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * 文件上传至七牛云(头像)工具类 17 | */ 18 | @Component 19 | public class UploadService { 20 | 21 | @Value("${upload.qiniu.ak}") 22 | private String accessKey; 23 | @Value("${upload.qiniu.sk}") 24 | private String secretKey; 25 | @Value("${upload.qiniu.domain}") 26 | private String domain; 27 | @Value("${upload.qiniu.bucket}") 28 | private String bucket; 29 | private static final String DOT = "."; 30 | 31 | /** 32 | * key 可以为空 (null),也可以自定义 33 | * @param filePath 34 | * @param key 35 | * @return 36 | */ 37 | public String uploadFile(String filePath, String key) { 38 | String suffix = Files.getFileExtension(filePath); 39 | //构造一个带指定 Region 对象的配置类 40 | Configuration cfg = new Configuration(Region.region0()); 41 | //...其他参数参考类注释 42 | UploadManager uploadManager = new UploadManager(cfg); 43 | //...生成上传凭证,然后准备上传 44 | Auth auth = Auth.create(accessKey, secretKey); 45 | String upToken = auth.uploadToken(bucket); 46 | try { 47 | Response response = uploadManager.put(filePath, key, upToken); 48 | //解析上传成功的结果 49 | DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); 50 | return domain + putRet.key + DOT + suffix; 51 | // System.out.println(putRet.key); 52 | // System.out.println(putRet.hash); 53 | } catch (QiniuException ex) { 54 | Response r = ex.response; 55 | System.err.println(r.toString()); 56 | try { 57 | System.err.println(r.bodyString()); 58 | } catch (QiniuException ex2) { 59 | //ignore 60 | } 61 | return ""; 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/resources/templates/signin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Signin Template · Bootstrap 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/test/java/com/nanyin/services/impl/UserServicesImplTest.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services.impl; 2 | 3 | import com.nanyin.entity.User; 4 | import com.nanyin.repository.UserRepository; 5 | import com.nanyin.services.UserServices; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.mockito.Mockito; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.boot.test.mock.mockito.MockBean; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | import javax.transaction.Transactional; 16 | import java.util.List; 17 | 18 | import static org.mockito.Mockito.mock; 19 | import static org.mockito.Mockito.when; 20 | 21 | /** 22 | * 测试规范: 23 | * 1.首先对Service进行测试时,应该生成对实现类的Test类,如 userService接口,实现类为userServiceImpl,则应该创建测试类UserServicesImplTest 24 | * 2.应该对类中的所有的public,protect方法全部进行测试 25 | * 3.涉及数据库,中间件等使用mock框架模拟mock掉 26 | * 4.测试方法名称, 原类名Test_测试场景,如:saveUserTest_SuccessWhenCreateNewUser 27 | */ 28 | @RunWith(SpringRunner.class) 29 | @SpringBootTest 30 | public class UserServicesImplTest { 31 | 32 | @MockBean 33 | UserRepository userRepository; 34 | 35 | @Autowired 36 | UserServices userServices; 37 | 38 | @Test 39 | public void login() { 40 | } 41 | 42 | /** 43 | * 使用Mockito测试service 44 | * @throws Exception 45 | */ 46 | @Test 47 | @Transactional // 测试后自动回滚数据,不会影响数据 48 | public void saveUser() throws Exception{ 49 | User user = mock(User.class); 50 | user.setId(1); 51 | user.setName("zhangsan"); 52 | when(userRepository.findUserByName("zhangsan")).thenReturn(user); 53 | User result = userServices.findUserByName("zhangsan"); 54 | 55 | Assert.assertEquals(user.getId(),result.getId()); 56 | } 57 | 58 | @Test 59 | public void simpleTest(){ 60 | 61 | //创建mock对象,参数可以是类,也可以是接口 62 | List list = mock(List.class); 63 | 64 | //设置方法的预期返回值 65 | when(list.get(0)).thenReturn("helloworld"); 66 | 67 | String result = list.get(0); 68 | 69 | //验证方法调用(是否调用了get(0)) 70 | Mockito.verify(list).get(0); 71 | 72 | //junit测试 73 | Assert.assertEquals("helloworld", result); 74 | } 75 | 76 | @Test 77 | public void findUsers() { 78 | } 79 | 80 | @Test 81 | public void findUserByName() { 82 | } 83 | } -------------------------------------------------------------------------------- /src/main/java/com/nanyin/controller/UnitController.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.controller; 2 | 3 | import com.nanyin.config.util.Result; 4 | import com.nanyin.entity.DTO.PageQueryParams; 5 | import com.nanyin.entity.Unit; 6 | import com.nanyin.services.UnitService; 7 | import com.nanyin.services.UserServices; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | /** 12 | * 单位管理 --- 结构: 13 | * 左侧:单位树, 14 | * 右侧上:单位基本信息,添加子单位,添加同级单位 15 | * 右侧下:单位下人员列表 16 | * 17 | */ 18 | @RestController 19 | public class UnitController { 20 | 21 | @Autowired 22 | UnitService unitService; 23 | 24 | @Autowired 25 | UserServices userServices; 26 | 27 | /** 28 | * 获得所有单位列表(树) 29 | * @return 30 | */ 31 | @GetMapping("/units") 32 | public Result findUnitTree() throws Exception{ 33 | return new Result<>(unitService.findUnitTree()); 34 | } 35 | 36 | @GetMapping("/unit/list") 37 | public Result findUnits(PageQueryParams pageQueryParams) throws Exception{ 38 | return new Result<>(unitService.findUnits(pageQueryParams)); 39 | } 40 | 41 | 42 | /** 43 | * 获得单位下人员列表 44 | * @param id 45 | * @param search 46 | * @param offset 47 | * @param limit 48 | * @param sort 49 | * @return 50 | * @throws Exception 51 | */ 52 | @GetMapping("/unit/{id}/users") 53 | public Result findUnitUsers(@PathVariable Integer id,String search, Integer offset, Integer limit, String sort) throws Exception{ 54 | return new Result<>(userServices.findUnitUsers(id,search,offset,limit,sort)); 55 | } 56 | 57 | /** 58 | * 获得特定{id}的单位 59 | * @param id 60 | * @return 61 | * @throws Exception 62 | */ 63 | @GetMapping("/unit/{id}") 64 | public Result findUnit(@PathVariable Integer id) throws Exception{ 65 | return new Result(); 66 | } 67 | 68 | /** 69 | * 添加单位 70 | * @param unit 71 | * @return 72 | * @throws Exception 73 | */ 74 | @PostMapping("/unit") 75 | public Result addUnit(@RequestBody Unit unit) throws Exception{ 76 | return new Result(); 77 | } 78 | 79 | /** 80 | * 修改单位 81 | * @param unit 82 | * @return 83 | * @throws Exception 84 | */ 85 | @PutMapping("/unit") 86 | public Result updateUnit(@RequestBody Unit unit) throws Exception{ 87 | return new Result(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 52 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/util/CommonUtils.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.util; 2 | 3 | import java.util.*; 4 | 5 | import com.google.common.base.Strings; 6 | import com.nanyin.config.exceptions.CheckException; 7 | import org.springframework.context.MessageSource; 8 | import org.springframework.context.NoSuchMessageException; 9 | import org.springframework.data.domain.PageRequest; 10 | import org.springframework.data.domain.Sort; 11 | 12 | import java.text.SimpleDateFormat; 13 | 14 | public class CommonUtils { 15 | 16 | private static MessageSource resources; 17 | 18 | private static Sort sending(String direction, String... propertis) { 19 | return new Sort(Sort.Direction.fromString(direction),propertis); 20 | } 21 | 22 | public static PageRequest pageRequest(Integer offset, Integer limit, String order, String... properties){ 23 | return new PageRequest((offset/limit),limit, CommonUtils.sending(order,properties)); 24 | } 25 | 26 | /** 27 | * 使用 时间戳-随机uuid的方式构造 11位的字符串进行对request的跟踪。 28 | * 应用于多应用,或多动作之间的日志跟踪 29 | **/ 30 | public static String generateRequestUid(){ 31 | Date date = new Date(); 32 | String dateString = new SimpleDateFormat("hhmmss-SSS").format(date); 33 | return dateString+"-"+ UUID.randomUUID().toString().replace("-", "").substring(0,10); 34 | } 35 | 36 | public static void setResources(MessageSource resources) { 37 | CommonUtils.resources = resources; 38 | } 39 | 40 | /** 41 | * 检查条件,如果不符合条件抛出异常 42 | **/ 43 | public static void check(boolean condition, String msgKey, Object... args) { 44 | if (!condition) { 45 | fail(msgKey, args); 46 | } 47 | } 48 | 49 | private static void fail(String msgKey, Object... args) { 50 | Locale locale = MDCUtil.getLocale(); 51 | if(locale==null){ 52 | locale = new Locale("zh_CN"); 53 | } 54 | String msg = ""; 55 | try{ 56 | msg = resources.getMessage(msgKey, args, locale); 57 | }catch (NoSuchMessageException npe){ 58 | msg = msgKey; 59 | } 60 | if("".equals(msg)){ 61 | msg = msgKey; 62 | } 63 | throw new CheckException(msg); 64 | } 65 | 66 | /** 67 | * object 是否为空 68 | **/ 69 | public static boolean isNull(Object o){ 70 | return !Optional.ofNullable(o).isPresent(); 71 | }; 72 | 73 | public static boolean isNotNull(Object o){ 74 | return Optional.ofNullable(o).isPresent(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/quartz/controller/JobController.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.quartz.controller; 2 | 3 | import com.nanyin.config.quartz.Job.DefaultJob; 4 | import com.nanyin.config.quartz.Job.SimpleJob; 5 | import com.nanyin.config.quartz.JobEntity; 6 | import com.nanyin.config.quartz.JobStatus; 7 | import com.nanyin.config.quartz.repository.JobEntityRepository; 8 | import com.nanyin.config.quartz.service.JobService; 9 | import org.quartz.*; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.scheduling.quartz.SchedulerFactoryBean; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.ResponseBody; 18 | 19 | /** 20 | * Created by NanYin on 2019/9/18. 21 | * Job rest get /job/{id} 启动id为{id} 的任务 22 | */ 23 | @Controller 24 | public class JobController { 25 | private Logger logger = LoggerFactory.getLogger(JobController.class); 26 | @Autowired 27 | JobService jobService; 28 | @Autowired 29 | JobEntityRepository jobEntityRepository; 30 | 31 | //根据ID重启某个Job 32 | @GetMapping("/job/{id}") 33 | public @ResponseBody String StartOrStopJob(@PathVariable Integer id,String type) throws SchedulerException { 34 | String result = ""; 35 | try { 36 | if(type.equals("open")){ 37 | result = jobService.openAssignJob(id); 38 | }else if(type.equals("close")){ 39 | result = jobService.closeAssignJob(id); 40 | }else result = "wrong status"; 41 | } catch (Exception e) { 42 | 43 | } 44 | return result; 45 | } 46 | 47 | @GetMapping("/jobs") 48 | public @ResponseBody String StartOrStopJobs(String type) throws SchedulerException { 49 | String result = ""; 50 | try { 51 | if(type.equals("open")){ 52 | jobService.startAllJobs(); 53 | }else if(type.equals("close")){ 54 | jobService.stopAllJobs(); 55 | }else result = "wrong status"; 56 | } catch (Exception e) { 57 | 58 | } 59 | return result; 60 | } 61 | 62 | // 修改和删除定时任务内容,并且默认将修改后的状态置为close,并且关闭定时任务。 63 | 64 | 65 | 66 | @GetMapping("/stopJob/{id}") 67 | public @ResponseBody String stop(@PathVariable Integer id ){ 68 | String result = ""; 69 | try { 70 | result = jobService.closeAssignJob(id); 71 | } catch (Exception e) { 72 | 73 | } 74 | return result; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/swagger2/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.swagger2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.service.ApiInfo; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.ApiSelectorBuilder; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | import static com.google.common.base.Predicates.or; 13 | import static springfox.documentation.builders.PathSelectors.regex; 14 | 15 | /** 16 | * Created by NanYin on 2019/9/9. 17 | * swagger2 配置类,参考springfox例子程序 18 | */ 19 | @EnableSwagger2 20 | @Configuration 21 | public class Swagger2Config { 22 | 23 | @Bean 24 | public Docket userDocket(){ 25 | return new Docket(DocumentationType.SWAGGER_2) 26 | .groupName("user") 27 | .apiInfo(userApiInfo()) 28 | .select() 29 | .paths(or(regex("/user.*"),regex("/user"))) 30 | .build(); 31 | } 32 | 33 | @Bean 34 | public Docket defaultDocket(){ 35 | return new Docket(DocumentationType.SWAGGER_2) 36 | .groupName("login") 37 | .apiInfo(defaultApiInfo()) 38 | .select() 39 | .paths(or(regex("/signin"),(regex("/index")) 40 | ,(regex("/login")),(regex("/logout")) 41 | ,(regex("/lang")))) 42 | .build(); 43 | } 44 | 45 | private ApiInfo userApiInfo(){ 46 | return new ApiInfoBuilder() 47 | .title("About User API") 48 | .description(" 本页包含用户相关api.") 49 | .termsOfServiceUrl("https://github.com/nanyiniu") 50 | .contact("NanYinIU") 51 | .license("Apache License Version 2.0") 52 | .licenseUrl("https://github.com/springfox/springfox/blob/master/LICENSE") 53 | .version("2.0") 54 | .build(); 55 | } 56 | 57 | private ApiInfo defaultApiInfo(){ 58 | return new ApiInfoBuilder() 59 | .title("默认相关 API") 60 | .description(" 本页包含登录,登出,国际化相关api.") 61 | .termsOfServiceUrl("https://github.com/nanyiniu") 62 | .contact("NanYinIU") 63 | .license("Apache License Version 2.0") 64 | .licenseUrl("https://github.com/springfox/springfox/blob/master/LICENSE") 65 | .version("2.0") 66 | .build(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/util/PageHelper.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.util; 2 | 3 | import org.springframework.data.domain.PageRequest; 4 | import org.springframework.data.domain.Sort; 5 | 6 | import javax.validation.constraints.NotNull; 7 | import java.util.List; 8 | 9 | public class PageHelper { 10 | 11 | private static final String DESC = "desc"; 12 | private static final String ASC = "asc"; 13 | /** 14 | * 传入 offset,limit,sort,direct 15 | * @param offset 16 | * @param limit 17 | * @return 18 | */ 19 | public static PageRequest generatePageRequest(Integer offset, Integer limit, String direct,@NotNull List sort){ 20 | offset = initOffset(offset); 21 | limit = initLimit(limit); 22 | Sort initSort = initSort(direct,sort); 23 | return PageRequest.of(offset-1,limit,initSort); 24 | } 25 | 26 | public static PageRequest generatePageRequest(Integer offset, Integer limit, String direct,@NotNull String sort){ 27 | offset = initOffset(offset); 28 | limit = initLimit(limit); 29 | Sort initSort = initSort(direct,sort); 30 | return PageRequest.of(offset-1,limit,initSort); 31 | } 32 | 33 | public static PageRequest generatePageRequest(Integer offset, Integer limit, @NotNull Sort sort){ 34 | offset = initOffset(offset); 35 | limit = initLimit(limit); 36 | return PageRequest.of(offset-1,limit,sort); 37 | } 38 | 39 | private static Sort initSort(String direct,String sort) { 40 | return Sort.by(initDirect(direct),sort); 41 | } 42 | 43 | private static Sort initSort(String direct,List sort) { 44 | return Sort.by(initDirect(direct),(String[]) sort.toArray(new String[sort.size()])); 45 | } 46 | 47 | private static Sort.Direction initDirect(String direct) { 48 | if(DESC.equals(direct)){ 49 | return Sort.Direction.DESC; 50 | } 51 | return Sort.Direction.ASC; 52 | } 53 | 54 | private static Integer initLimit(Integer limit) { 55 | if(limit == null){ 56 | return Integer.MAX_VALUE; 57 | } 58 | return limit; 59 | } 60 | 61 | private static Integer initOffset(Integer offset) { 62 | if(offset == null){ 63 | return 1; 64 | } 65 | return offset; 66 | } 67 | 68 | public static PageRequest generatePageRequest(Integer offset, Integer limit){ 69 | return generatePageRequest(offset,limit,null,"id"); 70 | } 71 | 72 | public static PageRequest generatePageRequest(Integer offset, Integer limit,String sort){ 73 | return generatePageRequest(offset,limit,null,sort); 74 | } 75 | 76 | public static PageRequest generatePageRequest(Integer offset, Integer limit,List sort){ 77 | return generatePageRequest(offset,limit,null,sort); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/resources/static/assets/css/project.css: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 100%; 3 | padding-right: 0.75rem; 4 | padding-left: 0.75rem; 5 | margin-right: auto; 6 | margin-left: auto; 7 | margin-top: 0.25rem; 8 | } 9 | 10 | @media (min-width: 576px) { 11 | .container { 12 | max-width: 540px; 13 | } 14 | } 15 | 16 | @media (min-width: 768px) { 17 | .container { 18 | max-width: 720px; 19 | } 20 | } 21 | 22 | @media (min-width: 992px) { 23 | .container { 24 | max-width: 960px; 25 | } 26 | } 27 | 28 | @media (min-width: 1280px) { 29 | .container { 30 | max-width: 1200px; 31 | } 32 | } 33 | 34 | /*.container-fluid {*/ 35 | /*width: 100%;*/ 36 | /*padding-right: 0.75rem;*/ 37 | /*padding-left: 0.75rem;*/ 38 | /*margin-right: auto;*/ 39 | /*margin-left: auto;*/ 40 | /*}*/ 41 | 42 | 43 | .row { 44 | display: -ms-flexbox; 45 | display: flex; 46 | -ms-flex-wrap: wrap; 47 | flex-wrap: wrap; 48 | margin-right: -0.75rem; 49 | margin-left: -0.75rem; 50 | } 51 | 52 | .card-aside { 53 | -ms-flex-direction: row; 54 | flex-direction: row; 55 | } 56 | 57 | .card-aside-column { 58 | min-width: 5rem; 59 | width: 30%; 60 | -ms-flex: 0 0 30%; 61 | flex: 0 0 30%; 62 | border-top-left-radius: 3px; 63 | border-bottom-left-radius: 3px; 64 | background: no-repeat center/cover; 65 | } 66 | 67 | .card-value { 68 | font-size: 2.5rem; 69 | line-height: 3.4rem; 70 | height: 3.4rem; 71 | display: -ms-flexbox; 72 | display: flex; 73 | -ms-flex-align: center; 74 | align-items: center; 75 | font-weight: 400; 76 | } 77 | 78 | .card-value i { 79 | vertical-align: middle; 80 | } 81 | 82 | .row-cards > .col, 83 | .row-cards > [class*='col-'] { 84 | display: -ms-flexbox; 85 | display: flex; 86 | -ms-flex-direction: column; 87 | flex-direction: column; 88 | 89 | } 90 | 91 | .row-deck > .col, 92 | .row-deck > [class*='col-'] { 93 | display: -ms-flexbox; 94 | display: flex; 95 | -ms-flex-align: stretch; 96 | align-items: stretch; 97 | } 98 | 99 | .row-deck > .col .card, 100 | .row-deck > [class*='col-'] .card { 101 | -ms-flex: 1 1 auto; 102 | flex: 1 1 auto; 103 | } 104 | 105 | 106 | .card { 107 | box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); 108 | position: relative; 109 | margin-bottom: 1.5rem; 110 | width: 100%; 111 | } 112 | 113 | .card .card { 114 | box-shadow: none; 115 | } 116 | 117 | @media print { 118 | .card { 119 | box-shadow: none; 120 | border: none; 121 | } 122 | } 123 | 124 | .card-body { 125 | -ms-flex: 1 1 auto; 126 | flex: 1 1 auto; 127 | margin: 0; 128 | padding: 1.5rem 1.5rem; 129 | position: relative; 130 | } 131 | 132 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/interceptor/WebTokenInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.interceptor; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.google.common.base.Strings; 5 | import com.nanyin.config.enums.ResultCodeEnum; 6 | import com.nanyin.config.util.CommonUtils; 7 | import com.nanyin.config.util.HttpUtils; 8 | import com.nanyin.config.util.MDCUtil; 9 | import com.nanyin.config.util.Result; 10 | import com.nanyin.services.RedisService; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.servlet.HandlerInterceptor; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.io.PrintWriter; 20 | import java.util.Enumeration; 21 | 22 | public class WebTokenInterceptor implements HandlerInterceptor { 23 | 24 | private static final Logger logger = LoggerFactory.getLogger(WebTokenInterceptor.class); 25 | 26 | /* 27 | 使用autowired 需要将 28 | 注册到容器中,也就是在 WebConfiguration 类中声明为 @Bean 29 | */ 30 | @Autowired 31 | RedisService redisService; 32 | /** 33 | * 请求前执行 34 | * @param request 35 | * @param response 36 | * @param handler 37 | * @return 38 | * @throws Exception 39 | */ 40 | @Override 41 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 42 | // 检查token 在缓存中是否存在 43 | String token = HttpUtils.getHeader(request, "X-Token"); 44 | if (!Strings.isNullOrEmpty(token)) { 45 | if (redisService.exists(token)) { 46 | String username = (String) redisService.get(token); 47 | // MDC 用作日志显示 48 | MDCUtil.setUser(username); 49 | String uuid = CommonUtils.generateRequestUid(); 50 | // 从session中获取 username 放到mdc中 51 | MDCUtil.setRequestId(uuid); 52 | // 更新缓存中token的时间 53 | redisService.set(token, username, 3600L); 54 | return true; 55 | } 56 | } 57 | // 否则返回illegal token ,返回前台 58 | PrintWriter writer = response.getWriter(); 59 | Result result = new Result(); 60 | result.setCode(ResultCodeEnum.ILLEGAL_TOKEN); 61 | writer.append(JSON.toJSONString(result)); 62 | return false; 63 | } 64 | 65 | /** 66 | * 请求后执行 67 | * @param request 68 | * @param response 69 | * @param handler 70 | * @param modelAndView 71 | * @throws Exception 72 | */ 73 | @Override 74 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 75 | MDCUtil.clearAllUserInfo(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | ${CONSOLE_LOG_PATTERN} 22 | utf8 23 | 24 | 25 | 26 | 28 | ${LOGS}/spring-boot-logger.log 29 | 31 | %d %p %C{1.} [%t] %m%n 32 | 33 | 34 | 36 | 37 | ${LOGS}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log 38 | 39 | 41 | 10MB 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/services/impl/PermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.services.impl; 2 | 3 | import com.nanyin.config.util.PageHelper; 4 | import com.nanyin.entity.DTO.PageQueryParams; 5 | import com.nanyin.entity.Permission; 6 | import com.nanyin.entity.QPermission; 7 | import com.nanyin.repository.PermissionRepository; 8 | import com.nanyin.services.PermissionService; 9 | import com.querydsl.core.types.ExpressionUtils; 10 | import com.querydsl.core.types.Predicate; 11 | import com.querydsl.jpa.impl.JPAQueryFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.data.domain.Page; 14 | import org.springframework.data.domain.PageRequest; 15 | import org.springframework.data.jpa.domain.Specification; 16 | import org.springframework.stereotype.Service; 17 | 18 | import javax.persistence.criteria.CriteriaBuilder; 19 | import javax.persistence.criteria.CriteriaQuery; 20 | import javax.persistence.criteria.Root; 21 | import java.util.*; 22 | 23 | @Service 24 | public class PermissionServiceImpl implements PermissionService { 25 | 26 | @Autowired 27 | PermissionRepository permissionRepository; 28 | 29 | @Autowired 30 | JPAQueryFactory jpaQueryFactory; 31 | 32 | @Override 33 | public Map> getRolePermission(Integer role) throws Exception { 34 | Map> map = new HashMap<>(); 35 | List permissions = doGetRolePermission(role); 36 | map.put("cur",permissions); 37 | map.put("otr",permissionRepository.findAll()); 38 | return map; 39 | } 40 | 41 | private List doGetRolePermission(Integer role){ 42 | QPermission permission = QPermission.permission; 43 | com.querydsl.core.types.Predicate predicate = permission.isNotNull().or(permission.isNull()); 44 | predicate = role == null ? predicate : ExpressionUtils.and(predicate, permission.roles.any().id.in(role)); 45 | return jpaQueryFactory.selectFrom(permission).where(predicate).fetch(); 46 | } 47 | 48 | @Override 49 | public Page findPermissions(PageQueryParams pageQueryParams) throws Exception { 50 | Integer offset = pageQueryParams.getOffset(); 51 | Integer limit = pageQueryParams.getLimit(); 52 | String search = pageQueryParams.getSearch(); 53 | Integer roleId = pageQueryParams.getRole(); 54 | PageRequest pageRequest = PageHelper.generatePageRequest(offset, limit); 55 | QPermission permission = QPermission.permission; 56 | Predicate predicate = permission.isNotNull().or(permission.isNull()); 57 | predicate = search == null ? predicate : ExpressionUtils.and(predicate,permission.name.like("%"+search+"%")); 58 | predicate = roleId == null ? predicate : ExpressionUtils.and(predicate,permission.roles.any().id.in(roleId)); 59 | return permissionRepository.findAll(predicate,pageRequest); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/WebMvcConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config; 2 | 3 | import com.alibaba.fastjson.support.config.FastJsonConfig; 4 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 5 | import com.nanyin.config.interceptor.WebTokenInterceptor; 6 | import com.nanyin.config.locale.MyCookieResolver; 7 | import com.querydsl.jpa.impl.JPAQueryFactory; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.http.converter.HttpMessageConverter; 11 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 12 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 13 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 14 | import org.springframework.web.servlet.i18n.CookieLocaleResolver; 15 | 16 | import javax.persistence.EntityManager; 17 | import java.nio.charset.Charset; 18 | import java.util.List; 19 | 20 | @Configuration 21 | public class WebMvcConfiguration implements WebMvcConfigurer { 22 | 23 | @Bean 24 | public CookieLocaleResolver localeResolver(){ 25 | return new MyCookieResolver(); 26 | } 27 | 28 | @Bean 29 | public WebTokenInterceptor tokenInterceptor(){ 30 | return new WebTokenInterceptor(); 31 | } 32 | 33 | @Override 34 | public void addCorsMappings(CorsRegistry registry) { 35 | // 允许跨域访问的路径 36 | registry.addMapping("/**") 37 | // 允许跨域访问的源 38 | .allowedOrigins("*") 39 | // 允许请求方法 40 | .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") 41 | // 预检间隔时间 42 | .maxAge(168000) 43 | // 允许头部设置 44 | .allowedHeaders("*") 45 | // 是否发送cookie 46 | .allowCredentials(true); 47 | } 48 | 49 | /** 50 | * 使用 fastjson 配置消息转换器 51 | * @param converters 52 | */ 53 | @Override 54 | public void configureMessageConverters(List> converters) { 55 | FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); 56 | //自定义配置... 57 | FastJsonConfig config = new FastJsonConfig(); 58 | config.setCharset(Charset.forName("utf-8")); 59 | converter.setFastJsonConfig(config); 60 | converters.add(0, converter); 61 | } 62 | 63 | /** 64 | * 添加interceptors 65 | * @param registry 66 | */ 67 | @Override 68 | public void addInterceptors(InterceptorRegistry registry) { 69 | // registry.addInterceptor(logbackInterceptor()); 70 | // 需要实现对token的解析 71 | // registry.addInterceptor(tokenInterceptor()).excludePathPatterns("/user/login"); 72 | } 73 | 74 | 75 | /** 76 | * 注入 jpaQueryFactory 77 | * @param entityManager 78 | * @return 79 | */ 80 | @Bean 81 | public JPAQueryFactory jpaQueryFactory(EntityManager entityManager){ 82 | return new JPAQueryFactory(entityManager); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.controller; 2 | 3 | import com.nanyin.config.util.Result; 4 | import com.nanyin.entity.DTO.TranferDto; 5 | import com.nanyin.entity.Role; 6 | import com.nanyin.services.PermissionService; 7 | import com.nanyin.services.RoleService; 8 | import com.nanyin.services.UserServices; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | @RestController 14 | public class RoleController { 15 | @Autowired 16 | RoleService roleService; 17 | 18 | @Autowired 19 | UserServices userServices; 20 | 21 | @Autowired 22 | PermissionService permissionService; 23 | /** 24 | * 查询角色列表 25 | * @param search 26 | * @param offset 27 | * @param limit 28 | * @param sort 29 | */ 30 | @GetMapping("/roles") 31 | @ApiOperation(value = "获取角色信息列表") 32 | public Result roleLists(String search, Integer offset, Integer limit, String sort) throws Exception{ 33 | return new Result<>(roleService.findRoles(search,offset,limit,sort)); 34 | } 35 | 36 | @PostMapping("/role") 37 | @ApiOperation(value = "添加角色") 38 | public Result saveRole(@RequestBody Role role) throws Exception{ 39 | return new Result<>(roleService.saveRole(role)); 40 | } 41 | 42 | @GetMapping("/role/{id}") 43 | @ApiOperation(value = "根据标识获取角色") 44 | public Result getRole(@PathVariable Integer id) throws Exception{ 45 | return new Result<>(roleService.getRole(id)); 46 | } 47 | 48 | @PutMapping("/role/{id}") 49 | @ApiOperation(value = "更新角色信息") 50 | public Result updateRole(@RequestBody Role role,@PathVariable Integer id) throws Exception{ 51 | return new Result<>(roleService.updateRole(role)); 52 | } 53 | 54 | @DeleteMapping("/role/{id}") 55 | @ApiOperation(value = "删除角色") 56 | public Result deleteRole(@PathVariable Integer id) throws Exception{ 57 | roleService.deleteRole(id); 58 | return new Result<>(); 59 | } 60 | 61 | /** 62 | * 为角色添加/删除人员 63 | * @return 64 | * @throws Exception 65 | */ 66 | @PostMapping("/role/users") 67 | @ApiOperation(value = "为角色添加/删除人员") 68 | public Result movePerson(@RequestBody TranferDto tranferDto) throws Exception{ 69 | roleService.movePersons(tranferDto); 70 | return new Result(); 71 | } 72 | 73 | @GetMapping("/role/users") 74 | public Result getRolePerson(Integer role) throws Exception{ 75 | return new Result<>(userServices.getRolePerson(role)); 76 | } 77 | 78 | @PostMapping("/role/permissions") 79 | public Result movePermission(@RequestBody TranferDto tranferDto) throws Exception{ 80 | roleService.movePermission(tranferDto); 81 | return new Result(); 82 | } 83 | @GetMapping("/role/permissions") 84 | public Result getRolePermission(Integer role) throws Exception{ 85 | return new Result<>(permissionService.getRolePermission(role)); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/nanyin/config/redis/WebRedisConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.nanyin.config.redis; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.PropertyAccessor; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import org.springframework.cache.CacheManager; 7 | import org.springframework.cache.annotation.CachingConfigurerSupport; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.data.redis.cache.RedisCacheConfiguration; 11 | import org.springframework.data.redis.cache.RedisCacheManager; 12 | import org.springframework.data.redis.cache.RedisCacheWriter; 13 | import org.springframework.data.redis.connection.RedisConnectionFactory; 14 | import org.springframework.data.redis.core.RedisTemplate; 15 | import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; 16 | import org.springframework.data.redis.serializer.RedisSerializationContext; 17 | import org.springframework.data.redis.serializer.StringRedisSerializer; 18 | 19 | import java.time.Duration; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | /** 24 | * redis 配置 25 | * redisTemplate 设置序列化策略 26 | * cacheManager 自定义 实现自定义ttl时间 27 | * @Author nanyin 28 | * @Date 22:12 2019-08-19 29 | **/ 30 | @Configuration 31 | public class WebRedisConfiguration extends CachingConfigurerSupport { 32 | 33 | @Bean 34 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { 35 | RedisTemplate template = new RedisTemplate<>(); 36 | template.setConnectionFactory(redisConnectionFactory); 37 | FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); 38 | ObjectMapper mapper = new ObjectMapper(); 39 | mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 40 | mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 41 | serializer.setObjectMapper(mapper); 42 | template.setHashKeySerializer(serializer); 43 | template.setHashValueSerializer(serializer); 44 | template.setDefaultSerializer(serializer); 45 | template.setKeySerializer(new StringRedisSerializer()); 46 | template.setValueSerializer(new StringRedisSerializer()); 47 | template.afterPropertiesSet(); 48 | return template; 49 | } 50 | /** 51 | * 使用 @Cacheable(cacheManager="TtlCacheManager") 激活cacheManager 52 | **/ 53 | @Bean(name = "TtlCacheManager") 54 | public RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) { 55 | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() 56 | .entryTtl(Duration.ofSeconds(30)) 57 | .disableCachingNullValues(); 58 | RedisCacheManager.RedisCacheManagerBuilder builder = 59 | RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory); 60 | return builder.transactionAware().cacheDefaults(config).build(); 61 | } 62 | } 63 | --------------------------------------------------------------------------------