├── .editorconfig ├── .gitignore ├── .gitlab-ci.yml ├── Procfile ├── README.md ├── app.json ├── pom.xml ├── zeus-common ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── zeus │ │ │ ├── bean │ │ │ ├── Database.java │ │ │ ├── FastDfs.java │ │ │ ├── Menu.java │ │ │ ├── MenuMeta.java │ │ │ ├── RedisTable.java │ │ │ ├── RespBean.java │ │ │ ├── Role.java │ │ │ ├── User.java │ │ │ ├── UserBase.java │ │ │ └── UserExample.java │ │ │ ├── common │ │ │ └── fastdfs │ │ │ │ ├── ClientGlobal.java │ │ │ │ ├── DownloadCallback.java │ │ │ │ ├── DownloadStream.java │ │ │ │ ├── FileInfo.java │ │ │ │ ├── ProtoCommon.java │ │ │ │ ├── ProtoStructDecoder.java │ │ │ │ ├── ServerInfo.java │ │ │ │ ├── StorageClient.java │ │ │ │ ├── StorageClient1.java │ │ │ │ ├── StorageServer.java │ │ │ │ ├── StructBase.java │ │ │ │ ├── StructGroupStat.java │ │ │ │ ├── StructStorageStat.java │ │ │ │ ├── TrackerClient.java │ │ │ │ ├── TrackerGroup.java │ │ │ │ ├── TrackerServer.java │ │ │ │ ├── UploadCallback.java │ │ │ │ ├── UploadStream.java │ │ │ │ └── common │ │ │ │ ├── Base64.java │ │ │ │ ├── IniFileReader.java │ │ │ │ ├── MyException.java │ │ │ │ └── NameValuePair.java │ │ │ ├── dto │ │ │ ├── MenuUpdateForm.java │ │ │ ├── PassWordResetResource.java │ │ │ ├── SysLogSearchForm.java │ │ │ ├── UserInfoUpdateForm.java │ │ │ └── UserRegister.java │ │ │ └── entity │ │ │ ├── Menu.java │ │ │ ├── MenuExample.java │ │ │ ├── MenuRole.java │ │ │ ├── MenuRoleExample.java │ │ │ ├── Role.java │ │ │ ├── RoleExample.java │ │ │ ├── SysLog.java │ │ │ ├── SysLogExample.java │ │ │ ├── SysSchool.java │ │ │ ├── SysSchoolExample.java │ │ │ ├── SysSystem.java │ │ │ ├── SysSystemExample.java │ │ │ ├── University.java │ │ │ ├── UserRole.java │ │ │ └── UserRoleExample.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── zeus │ └── DemoApplicationTests.java └── zeus-web ├── .gitignore ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── zeus │ │ ├── ValidateCodeBeanConfig.java │ │ ├── ZeusDmsApplication.java │ │ ├── common │ │ ├── CustomAuthenticationFailureHandler.java │ │ ├── CustomUserTypeAuthenticationFilter.java │ │ ├── DateConverter.java │ │ ├── GlobalAuthenticationConfigurerAdapter.java │ │ ├── LogTrackInterceptor.java │ │ ├── LoginFailedEventListener.java │ │ ├── ResponseCode.java │ │ ├── RestUsernamePasswordAuthenticationProvider.java │ │ ├── SecurityConstants.java │ │ ├── SecurityCoreConfig.java │ │ ├── ServerResponse.java │ │ ├── SmsCodeAuthenticationFilter.java │ │ ├── SmsCodeAuthenticationProvider.java │ │ ├── SmsCodeAuthenticationSecurityConfig.java │ │ ├── SmsCodeAuthenticationToken.java │ │ ├── UserTypeEnum.java │ │ ├── UserUtils.java │ │ ├── fw │ │ │ ├── LogType.java │ │ │ ├── SystemLogAspect.java │ │ │ └── annotation │ │ │ │ └── SystemLog.java │ │ ├── util │ │ │ ├── DBUtil.java │ │ │ ├── DMSConstant.java │ │ │ ├── IpInfoUtil.java │ │ │ ├── RedisPersistence.java │ │ │ ├── RedisTool.java │ │ │ └── WindowsUtils.java │ │ └── validator │ │ │ ├── AbstractValidateCodeProcessor.java │ │ │ ├── DefaultSmsCodeSender.java │ │ │ ├── ImageCode.java │ │ │ ├── ImageCodeGenerator.java │ │ │ ├── ImageCodeProcessor.java │ │ │ ├── ImageCodeProperties.java │ │ │ ├── SecurityProperties.java │ │ │ ├── SessionProperties.java │ │ │ ├── SessionValidateCodeRepository.java │ │ │ ├── SmsCodeGenerator.java │ │ │ ├── SmsCodeProcessor.java │ │ │ ├── SmsCodeProperties.java │ │ │ ├── SmsCodeSender.java │ │ │ ├── ValidateCode.java │ │ │ ├── ValidateCodeException.java │ │ │ ├── ValidateCodeFilter.java │ │ │ ├── ValidateCodeGenerator.java │ │ │ ├── ValidateCodeProcessor.java │ │ │ ├── ValidateCodeProcessorHolder.java │ │ │ ├── ValidateCodeProperties.java │ │ │ ├── ValidateCodeRepository.java │ │ │ ├── ValidateCodeSecurityConfig.java │ │ │ └── ValidateCodeType.java │ │ ├── config │ │ ├── AuthenticationAccessDeniedHandler.java │ │ ├── CrossOriginConfig.java │ │ ├── CustomMetadataSource.java │ │ ├── DataSourceContextHolder.java │ │ ├── DruidConfig.java │ │ ├── DynamicDataSource.java │ │ ├── SwaggerConfig.java │ │ ├── UrlAccessDecisionManager.java │ │ ├── WebMvcConfig.java │ │ └── WebSecurityConfig.java │ │ ├── controller │ │ ├── ConfigController.java │ │ ├── RegLoginController.java │ │ ├── ValidateCodeController.java │ │ └── system │ │ │ ├── SystemBasicController.java │ │ │ ├── SystemController.java │ │ │ └── SystemUserController.java │ │ ├── dmsMapper │ │ ├── CommonMapper.java │ │ ├── MenuMapper.java │ │ ├── MenuRoleMapper.java │ │ ├── RoleMapper.java │ │ ├── SysLogMapper.java │ │ ├── SysSchoolMapper.java │ │ ├── SysSystemMapper.java │ │ ├── UniversityMapper.java │ │ ├── UserAndRoleMapper.java │ │ └── UserMapper.java │ │ ├── exception │ │ └── CustomExceptionResolver.java │ │ └── service │ │ ├── MenuRoleService.java │ │ ├── MenuService.java │ │ ├── PlansService.java │ │ ├── RestAuthentication.java │ │ ├── RoleService.java │ │ ├── SecurityMobileUserDetailService.java │ │ ├── SecurityUserDetailService.java │ │ ├── SysLogService.java │ │ ├── SystemUserService.java │ │ ├── SystemUserServiceImpl.java │ │ ├── UniversityService.java │ │ ├── UserAndRoleService.java │ │ ├── UserDetailService.java │ │ └── UserService.java └── resources │ ├── application.properties │ ├── generatorConfig.xml │ ├── logback.xml │ ├── mybatis-config.xml │ ├── mybatis │ └── dmsMapper │ │ ├── CommonMapper.xml │ │ ├── MenuMapper.xml │ │ ├── MenuRoleMapper.xml │ │ ├── RoleMapper.xml │ │ ├── SysLogMapper.xml │ │ ├── SysSchoolMapper.xml │ │ ├── SysSystemMapper.xml │ │ ├── UniversityMapper.xml │ │ ├── UserAndRoleMapper.xml │ │ └── UserMapper.xml │ ├── static │ ├── index.html │ └── static │ │ ├── css │ │ ├── app.1545ffdb37777a2fb1106c25b78d4d61.css │ │ └── app.1545ffdb37777a2fb1106c25b78d4d61.css.map │ │ ├── explode.mp3 │ │ ├── fonts │ │ ├── element-icons.6f0a763.ttf │ │ ├── fontawesome-webfont.674f50d.eot │ │ ├── fontawesome-webfont.af7ae50.woff2 │ │ ├── fontawesome-webfont.b06871f.ttf │ │ └── fontawesome-webfont.fee66e7.woff │ │ ├── img │ │ ├── 2.jpg │ │ ├── bannerleft.452a4c3.gif │ │ ├── bannerleft.gif │ │ ├── fontawesome-webfont.912ec66.svg │ │ └── middle.jpg │ │ ├── js │ │ ├── 0.5d64514a0153b5316003.js │ │ ├── 0.5d64514a0153b5316003.js.map │ │ ├── 1.0a747a176cdcce7fe266.js │ │ ├── 1.0a747a176cdcce7fe266.js.map │ │ ├── 2.6ea732522ba2996fb7f1.js │ │ ├── 2.6ea732522ba2996fb7f1.js.map │ │ ├── 3.3f065b72e30767825c71.js │ │ ├── 3.3f065b72e30767825c71.js.map │ │ ├── 4.a2b4ca3dadf891da28be.js │ │ ├── 4.a2b4ca3dadf891da28be.js.map │ │ ├── 5.39da4507370887090357.js │ │ ├── 5.39da4507370887090357.js.map │ │ ├── 6.b7efcdad30ebadf048c3.js │ │ ├── 6.b7efcdad30ebadf048c3.js.map │ │ ├── 9.05ef753874e99791daa4.js │ │ ├── 9.05ef753874e99791daa4.js.map │ │ ├── app.9b4d211b6f3fc84de052.js │ │ ├── app.9b4d211b6f3fc84de052.js.map │ │ ├── manifest.a3151baa22459846f487.js │ │ ├── manifest.a3151baa22459846f487.js.map │ │ ├── vendor.d2220c3eed214296227f.js │ │ └── vendor.d2220c3eed214296227f.js.map │ │ ├── test.js │ │ └── tinymce4.7.5 │ │ ├── langs │ │ └── zh_CN.js │ │ ├── plugins │ │ ├── codesample │ │ │ └── css │ │ │ │ └── prism.css │ │ ├── emoticons │ │ │ └── img │ │ │ │ ├── smiley-cool.gif │ │ │ │ ├── smiley-cry.gif │ │ │ │ ├── smiley-embarassed.gif │ │ │ │ ├── smiley-foot-in-mouth.gif │ │ │ │ ├── smiley-frown.gif │ │ │ │ ├── smiley-innocent.gif │ │ │ │ ├── smiley-kiss.gif │ │ │ │ ├── smiley-laughing.gif │ │ │ │ ├── smiley-money-mouth.gif │ │ │ │ ├── smiley-sealed.gif │ │ │ │ ├── smiley-smile.gif │ │ │ │ ├── smiley-surprised.gif │ │ │ │ ├── smiley-tongue-out.gif │ │ │ │ ├── smiley-undecided.gif │ │ │ │ ├── smiley-wink.gif │ │ │ │ └── smiley-yell.gif │ │ └── visualblocks │ │ │ └── css │ │ │ └── visualblocks.css │ │ ├── skins │ │ └── lightgray │ │ │ ├── content.inline.min.css │ │ │ ├── content.min.css │ │ │ ├── fonts │ │ │ ├── tinymce-mobile.woff │ │ │ ├── tinymce-small.eot │ │ │ ├── tinymce-small.svg │ │ │ ├── tinymce-small.ttf │ │ │ ├── tinymce-small.woff │ │ │ ├── tinymce.eot │ │ │ ├── tinymce.svg │ │ │ ├── tinymce.ttf │ │ │ └── tinymce.woff │ │ │ ├── img │ │ │ ├── anchor.gif │ │ │ ├── loader.gif │ │ │ ├── object.gif │ │ │ └── trans.gif │ │ │ ├── skin.min.css │ │ │ └── skin.min.css.map │ │ └── tinymce.min.js │ └── zeus.sql └── test └── java └── org └── zeus └── DemoApplicationTests.java /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{xml,js,jsx,json}] 4 | indent_style = space 5 | indent_size = 2 6 | 7 | [*.java] 8 | indent_style = space 9 | indent_size = 4 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - echo "install dpl deploy tool" 3 | 4 | stages: 5 | - deploy 6 | 7 | deploy to production: 8 | stage: deploy 9 | environment: production 10 | tags: 11 | - heroku 12 | only: 13 | - master 14 | script: 15 | - dpl --provider=heroku --app=ifw-demo2 --api-key=$HEROKU_API_KEY 16 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: java -jar zeus-web/target/zeus-web-0.0.1-SNAPSHOT.jar 2 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Start on Heroku: Java", 3 | "description": "Midsummer based on springboot", 4 | "keywords": [ 5 | "business intelligence", 6 | "framework" 7 | ], 8 | "website": "http://www.aichaellee.com/", 9 | "repository": "https://github.com/AichaelLee/springboot.git", 10 | "logo": "https://avatars3.githubusercontent.com/u/10520629?v=3&s=200", 11 | "success_url": "/", 12 | "env": { 13 | }, 14 | "addons": ["heroku-postgresql","Papertrail","Pushwoosh","SendGrid"] 15 | } 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.zeus 7 | zeus-parent 8 | 0.0.1-SNAPSHOT 9 | zeus-web 10 | pom 11 | web Spring Boot 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 2.0.4.RELEASE 17 | 18 | 19 | 20 | zeus-common 21 | zeus-web 22 | 23 | 24 | 25 | 1.8 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-security 32 | true 33 | 34 | 35 | org.springframework.social 36 | spring-social-config 37 | 1.1.6.RELEASE 38 | 39 | 40 | org.springframework.social 41 | spring-social-core 42 | 1.1.6.RELEASE 43 | 44 | 45 | org.springframework.social 46 | spring-social-security 47 | 1.1.6.RELEASE 48 | 49 | 50 | org.springframework.social 51 | spring-social-web 52 | 1.1.6.RELEASE 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-data-jpa 57 | 58 | 59 | 60 | commons-io 61 | commons-io 62 | 2.6 63 | 64 | 65 | org.apache.commons 66 | commons-lang3 67 | 3.5 68 | 69 | 70 | ch.qos.logback 71 | logback-classic 72 | ${logback.version} 73 | 74 | 75 | 76 | io.springfox 77 | springfox-swagger2 78 | 2.8.0 79 | 80 | 81 | io.springfox 82 | springfox-swagger-ui 83 | 2.8.0 84 | 85 | 86 | org.codehaus.groovy 87 | groovy-all 88 | 2.4.13 89 | 90 | 91 | 92 | 93 | 94 | 95 | org.apache.maven.plugins 96 | maven-compiler-plugin 97 | 98 | 1.8 99 | 1.8 100 | UTF-8 101 | 102 | 103 | 104 | org.apache.maven.plugins 105 | maven-surefire-plugin 106 | 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /zeus-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /zeus-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.zeus 7 | zeus-parent 8 | 0.0.1-SNAPSHOT 9 | 10 | 11 | org.zeus 12 | zeus-common 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | 34 | 35 | 36 | org.projectlombok 37 | lombok 38 | 1.14.8 39 | 40 | 41 | com.github.tobato 42 | fastdfs-client 43 | 1.25.3-RELEASE 44 | 45 | 46 | com.fasterxml.jackson.core 47 | jackson-databind 48 | 2.9.6 49 | 50 | 51 | 52 | 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-compiler-plugin 57 | 58 | 1.8 59 | 1.8 60 | UTF-8 61 | 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-surefire-plugin 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/Database.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | 4 | public class Database { 5 | 6 | private String newSchoolNum; 7 | 8 | private String oldSchoolNum; 9 | 10 | private String oldServerIp; 11 | 12 | private String delSameDb; 13 | 14 | private String dbName; 15 | 16 | private String port = "3306"; 17 | 18 | private String MysqlUser; 19 | 20 | private String MysqlPassowrd; 21 | 22 | 23 | public String getMysqlUser() { 24 | return MysqlUser; 25 | } 26 | 27 | public void setMysqlUser(String mysqlUser) { 28 | MysqlUser = mysqlUser; 29 | } 30 | 31 | public String getMysqlPassowrd() { 32 | return MysqlPassowrd; 33 | } 34 | 35 | public void setMysqlPassowrd(String mysqlPassowrd) { 36 | MysqlPassowrd = mysqlPassowrd; 37 | } 38 | 39 | public String getPort() { 40 | return port; 41 | } 42 | 43 | public void setPort(String port) { 44 | this.port = port; 45 | } 46 | 47 | public String getDbName() { 48 | return dbName; 49 | } 50 | 51 | public void setDbName(String dbName) { 52 | this.dbName = dbName; 53 | } 54 | 55 | public String getNewSchoolNum() { 56 | return newSchoolNum; 57 | } 58 | 59 | public void setNewSchoolNum(String newSchoolNum) { 60 | this.newSchoolNum = newSchoolNum; 61 | } 62 | 63 | public String getOldSchoolNum() { 64 | return oldSchoolNum; 65 | } 66 | 67 | public void setOldSchoolNum(String oldSchoolNum) { 68 | this.oldSchoolNum = oldSchoolNum; 69 | } 70 | 71 | public String getOldServerIp() { 72 | return oldServerIp; 73 | } 74 | 75 | public void setOldServerIp(String oldServerIp) { 76 | this.oldServerIp = oldServerIp; 77 | } 78 | 79 | public String getDelSameDb() { 80 | return delSameDb; 81 | } 82 | 83 | public void setDelSameDb(String delSameDb) { 84 | this.delSameDb = delSameDb; 85 | } 86 | 87 | 88 | 89 | public Database() { 90 | // TODO Auto-generated constructor stub 91 | } 92 | 93 | 94 | 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/FastDfs.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.io.Serializable; 10 | 11 | @Entity 12 | @Table(name="FASTDFS") 13 | @Data 14 | public class FastDfs implements Serializable{ 15 | 16 | /** 17 | * 18 | */ 19 | private static final long serialVersionUID = 1L; 20 | 21 | @Id 22 | String filename; 23 | String groupname; 24 | String extension; 25 | } 26 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/Menu.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by lizhizhong on 2018/11/26. 12 | */ 13 | @Data 14 | public class Menu implements Serializable { 15 | private Long id; 16 | private String url; 17 | private String path; 18 | private Object component; 19 | private String name; 20 | private String iconCls; 21 | private Long parentId; 22 | private List roles; 23 | private List children; 24 | private MenuMeta meta; 25 | 26 | 27 | @JsonIgnore 28 | public String getUrl() { 29 | return url; 30 | } 31 | 32 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 33 | public Object getComponent() { 34 | return component; 35 | } 36 | 37 | /** 38 | * todo 因为要自定义菜单名称等,前台部分此时需要parentId这个字段, 39 | * 但是以前没有考虑进去,现在把jsonIgnore注释取消掉,目前想不出来可能会造成的问题 40 | * 后续如果出现bug再进行分析原因 41 | * @data 20190108 42 | * @return 43 | */ 44 | // @JsonIgnore 45 | // public Long getParentId() { 46 | // return parentId; 47 | // } 48 | 49 | @JsonIgnore 50 | public List getRoles() { 51 | return roles; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/MenuMeta.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by lizhizhong on 2017/11/26. 9 | */ 10 | @Data 11 | public class MenuMeta implements Serializable { 12 | 13 | private boolean keepAlive; 14 | private boolean requireAuth; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/RedisTable.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author: lizhizhong 9 | * CreatedDate: 2018/12/6. 10 | */ 11 | @Data 12 | public class RedisTable { 13 | //保存redis的主键ID 14 | private Long redisId; 15 | //redis的类型如:set/list/hash/sortedset/string 16 | private String redisType; 17 | //保存redis时使用的key 18 | private String redisKey; 19 | //此属性主要用于hash数据结构时,保存member的 20 | private String objectName; 21 | //存储的redis的值 22 | private String redisValue; 23 | //保存Token时,为区分拼接的字符串 24 | private String keyToken; 25 | //此属性为sortedset数据结构时,保存的score值 26 | private String score; 27 | //创建时间 28 | private Date createTime; 29 | //更新时间 30 | private Date updateTime; 31 | //redis的IP地址 当然此处也可以存储mac地址 32 | private String macIp; 33 | //redis使用的端口号 34 | private String port; 35 | //应用区分码 36 | private String appCode; 37 | //备注 38 | private String remark; 39 | //是否修改。此属性可以用于增量备份时,即在每个redis存储时可以更具key多存储一个属性isModify。 如果有修改,则置为 Y,否则为N. 40 | private String isModify; 41 | 42 | 43 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/RespBean.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | 5 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) 6 | public class RespBean { 7 | private Integer status; 8 | private String msg; 9 | private Object obj; 10 | 11 | private RespBean() { 12 | } 13 | 14 | public static RespBean build() { 15 | return new RespBean(); 16 | } 17 | 18 | public static RespBean ok(String msg, Object obj) { 19 | return new RespBean(200, msg, obj); 20 | } 21 | 22 | public static RespBean ok(String msg) { 23 | return new RespBean(200, msg, null); 24 | } 25 | 26 | public static RespBean error(String msg, Object obj) { 27 | return new RespBean(500, msg, obj); 28 | } 29 | 30 | public static RespBean error(String msg) { 31 | return new RespBean(500, msg, null); 32 | } 33 | 34 | private RespBean(Integer status, String msg, Object obj) { 35 | this.status = status; 36 | this.msg = msg; 37 | this.obj = obj; 38 | } 39 | 40 | public Integer getStatus() { 41 | 42 | return status; 43 | } 44 | 45 | public RespBean setStatus(Integer status) { 46 | this.status = status; 47 | return this; 48 | } 49 | 50 | public String getMsg() { 51 | return msg; 52 | } 53 | 54 | public RespBean setMsg(String msg) { 55 | this.msg = msg; 56 | return this; 57 | } 58 | 59 | public Object getObj() { 60 | return obj; 61 | } 62 | 63 | public RespBean setObj(Object obj) { 64 | this.obj = obj; 65 | return this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/Role.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by lizhizhong on 2018/11/26. 9 | */ 10 | @Data 11 | public class Role implements Serializable { 12 | private Long id; 13 | private String name; 14 | private String nameZh; 15 | } 16 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/User.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.Data; 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | 10 | import java.io.Serializable; 11 | import java.util.ArrayList; 12 | import java.util.Collection; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | @Data 17 | @JsonInclude(JsonInclude.Include.NON_NULL) 18 | public class User extends UserBase implements UserDetails, Serializable { 19 | private Long id; 20 | 21 | private String username; 22 | 23 | private String name; 24 | 25 | private String email; 26 | 27 | private String password; 28 | 29 | private String lastLogin; 30 | 31 | private String createdTime; 32 | 33 | private String accountStatus; 34 | 35 | private String photo; 36 | 37 | private String deletedflag; 38 | 39 | private Integer mobile; 40 | 41 | private Date updateTime; 42 | private List roles; 43 | 44 | private static final long serialVersionUID = 1L; 45 | 46 | @JsonIgnore 47 | @Override 48 | public Collection getAuthorities() { 49 | List authorities = new ArrayList<>(); 50 | for (Role role : roles) { 51 | authorities.add(new SimpleGrantedAuthority(role.getName())); 52 | } 53 | // authorities.add(new SimpleGrantedAuthority("ROLE_dean")); 54 | return authorities; 55 | } 56 | 57 | @JsonIgnore 58 | @Override 59 | public boolean isEnabled() { 60 | return true; 61 | } 62 | 63 | @JsonIgnore 64 | @Override 65 | public String getUsername() { 66 | return name; 67 | } 68 | 69 | 70 | @JsonIgnore 71 | @Override 72 | public String getPassword() { 73 | return password; 74 | } 75 | 76 | @Override 77 | public boolean isAccountNonExpired() { 78 | return true; 79 | } 80 | 81 | @Override 82 | public boolean isAccountNonLocked() { 83 | return true; 84 | } 85 | 86 | @Override 87 | public boolean isCredentialsNonExpired() { 88 | return true; 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/bean/UserBase.java: -------------------------------------------------------------------------------- 1 | package org.zeus.bean; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: lizhizhong 9 | * CreatedDate: 2018/12/3. 10 | */ 11 | @Data 12 | public class UserBase { 13 | public Long id; 14 | public List roles; 15 | } 16 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/DownloadCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | /** 12 | * Download file callback interface 13 | * 14 | * @author Happy Fish / YuQing 15 | * @version Version 1.4 16 | */ 17 | public interface DownloadCallback { 18 | /** 19 | * recv file content callback function, may be called more than once when the file downloaded 20 | * 21 | * @param file_size file size 22 | * @param data data buff 23 | * @param bytes data bytes 24 | * @return 0 success, return none zero(errno) if fail 25 | */ 26 | public int recv(long file_size, byte[] data, int bytes); 27 | } 28 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/DownloadStream.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.fastdfs; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | /** 7 | * Download file by stream (download callback class) 8 | * 9 | * @author zhouzezhong & Happy Fish / YuQing 10 | * @version Version 1.11 11 | */ 12 | public class DownloadStream implements DownloadCallback { 13 | private OutputStream out; 14 | private long currentBytes = 0; 15 | 16 | public DownloadStream(OutputStream out) { 17 | super(); 18 | this.out = out; 19 | } 20 | 21 | /** 22 | * recv file content callback function, may be called more than once when the file downloaded 23 | * 24 | * @param fileSize file size 25 | * @param data data buff 26 | * @param bytes data bytes 27 | * @return 0 success, return none zero(errno) if fail 28 | */ 29 | public int recv(long fileSize, byte[] data, int bytes) { 30 | try { 31 | out.write(data, 0, bytes); 32 | } catch (IOException ex) { 33 | ex.printStackTrace(); 34 | return -1; 35 | } 36 | 37 | currentBytes += bytes; 38 | if (this.currentBytes == fileSize) { 39 | this.currentBytes = 0; 40 | } 41 | 42 | return 0; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/FileInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | 14 | /** 15 | * Server Info 16 | * 17 | * @author Happy Fish / YuQing 18 | * @version Version 1.23 19 | */ 20 | public class FileInfo { 21 | protected String source_ip_addr; 22 | protected long file_size; 23 | protected Date create_timestamp; 24 | protected int crc32; 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param file_size the file size 30 | * @param create_timestamp create timestamp in seconds 31 | * @param crc32 the crc32 signature 32 | * @param source_ip_addr the source storage ip address 33 | */ 34 | public FileInfo(long file_size, int create_timestamp, int crc32, String source_ip_addr) { 35 | this.file_size = file_size; 36 | this.create_timestamp = new Date(create_timestamp * 1000L); 37 | this.crc32 = crc32; 38 | this.source_ip_addr = source_ip_addr; 39 | } 40 | 41 | /** 42 | * get the source ip address of the file uploaded to 43 | * 44 | * @return the source ip address of the file uploaded to 45 | */ 46 | public String getSourceIpAddr() { 47 | return this.source_ip_addr; 48 | } 49 | 50 | /** 51 | * set the source ip address of the file uploaded to 52 | * 53 | * @param source_ip_addr the source ip address 54 | */ 55 | public void setSourceIpAddr(String source_ip_addr) { 56 | this.source_ip_addr = source_ip_addr; 57 | } 58 | 59 | /** 60 | * get the file size 61 | * 62 | * @return the file size 63 | */ 64 | public long getFileSize() { 65 | return this.file_size; 66 | } 67 | 68 | /** 69 | * set the file size 70 | * 71 | * @param file_size the file size 72 | */ 73 | public void setFileSize(long file_size) { 74 | this.file_size = file_size; 75 | } 76 | 77 | /** 78 | * get the create timestamp of the file 79 | * 80 | * @return the create timestamp of the file 81 | */ 82 | public Date getCreateTimestamp() { 83 | return this.create_timestamp; 84 | } 85 | 86 | /** 87 | * set the create timestamp of the file 88 | * 89 | * @param create_timestamp create timestamp in seconds 90 | */ 91 | public void setCreateTimestamp(int create_timestamp) { 92 | this.create_timestamp = new Date(create_timestamp * 1000L); 93 | } 94 | 95 | /** 96 | * get the file CRC32 signature 97 | * 98 | * @return the file CRC32 signature 99 | */ 100 | public long getCrc32() { 101 | return this.crc32; 102 | } 103 | 104 | /** 105 | * set the create timestamp of the file 106 | * 107 | * @param crc32 the crc32 signature 108 | */ 109 | public void setCrc32(int crc32) { 110 | this.crc32 = crc32; 111 | } 112 | 113 | /** 114 | * to string 115 | * 116 | * @return string 117 | */ 118 | public String toString() { 119 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 120 | return "source_ip_addr = " + this.source_ip_addr + ", " + 121 | "file_size = " + this.file_size + ", " + 122 | "create_timestamp = " + df.format(this.create_timestamp) + ", " + 123 | "crc32 = " + this.crc32; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/ProtoStructDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.lang.reflect.Array; 13 | 14 | /** 15 | * C struct body decoder 16 | * 17 | * @author Happy Fish / YuQing 18 | * @version Version 1.17 19 | */ 20 | public class ProtoStructDecoder { 21 | /** 22 | * Constructor 23 | */ 24 | public ProtoStructDecoder() { 25 | } 26 | 27 | /** 28 | * decode byte buffer 29 | */ 30 | public T[] decode(byte[] bs, Class clazz, int fieldsTotalSize) throws Exception { 31 | if (bs.length % fieldsTotalSize != 0) { 32 | throw new IOException("byte array length: " + bs.length + " is invalid!"); 33 | } 34 | 35 | int count = bs.length / fieldsTotalSize; 36 | int offset; 37 | T[] results = (T[]) Array.newInstance(clazz, count); 38 | 39 | offset = 0; 40 | for (int i = 0; i < results.length; i++) { 41 | results[i] = clazz.newInstance(); 42 | results[i].setFields(bs, offset); 43 | offset += fieldsTotalSize; 44 | } 45 | 46 | return results; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/ServerInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.net.InetSocketAddress; 13 | import java.net.Socket; 14 | 15 | /** 16 | * Server Info 17 | * 18 | * @author Happy Fish / YuQing 19 | * @version Version 1.7 20 | */ 21 | public class ServerInfo { 22 | protected String ip_addr; 23 | protected int port; 24 | 25 | /** 26 | * Constructor 27 | * 28 | * @param ip_addr address of the server 29 | * @param port the port of the server 30 | */ 31 | public ServerInfo(String ip_addr, int port) { 32 | this.ip_addr = ip_addr; 33 | this.port = port; 34 | } 35 | 36 | /** 37 | * return the ip address 38 | * 39 | * @return the ip address 40 | */ 41 | public String getIpAddr() { 42 | return this.ip_addr; 43 | } 44 | 45 | /** 46 | * return the port of the server 47 | * 48 | * @return the port of the server 49 | */ 50 | public int getPort() { 51 | return this.port; 52 | } 53 | 54 | /** 55 | * connect to server 56 | * 57 | * @return connected Socket object 58 | */ 59 | public Socket connect() throws IOException { 60 | Socket sock = new Socket(); 61 | sock.setReuseAddress(true); 62 | sock.setSoTimeout(ClientGlobal.g_network_timeout); 63 | sock.connect(new InetSocketAddress(this.ip_addr, this.port), ClientGlobal.g_connect_timeout); 64 | return sock; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/StorageServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.net.InetSocketAddress; 13 | 14 | /** 15 | * Storage Server Info 16 | * 17 | * @author Happy Fish / YuQing 18 | * @version Version 1.11 19 | */ 20 | public class StorageServer extends TrackerServer { 21 | protected int store_path_index = 0; 22 | 23 | /** 24 | * Constructor 25 | * 26 | * @param ip_addr the ip address of storage server 27 | * @param port the port of storage server 28 | * @param store_path the store path index on the storage server 29 | */ 30 | public StorageServer(String ip_addr, int port, int store_path) throws IOException { 31 | super(ClientGlobal.getSocket(ip_addr, port), new InetSocketAddress(ip_addr, port)); 32 | this.store_path_index = store_path; 33 | } 34 | 35 | /** 36 | * Constructor 37 | * 38 | * @param ip_addr the ip address of storage server 39 | * @param port the port of storage server 40 | * @param store_path the store path index on the storage server 41 | */ 42 | public StorageServer(String ip_addr, int port, byte store_path) throws IOException { 43 | super(ClientGlobal.getSocket(ip_addr, port), new InetSocketAddress(ip_addr, port)); 44 | if (store_path < 0) { 45 | this.store_path_index = 256 + store_path; 46 | } else { 47 | this.store_path_index = store_path; 48 | } 49 | } 50 | 51 | /** 52 | * @return the store path index on the storage server 53 | */ 54 | public int getStorePathIndex() { 55 | return this.store_path_index; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/StructBase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.UnsupportedEncodingException; 12 | import java.util.Date; 13 | 14 | /** 15 | * C struct body decoder 16 | * 17 | * @author Happy Fish / YuQing 18 | * @version Version 1.17 19 | */ 20 | public abstract class StructBase { 21 | /** 22 | * set fields 23 | * 24 | * @param bs byte array 25 | * @param offset start offset 26 | */ 27 | public abstract void setFields(byte[] bs, int offset); 28 | 29 | protected String stringValue(byte[] bs, int offset, FieldInfo filedInfo) { 30 | try { 31 | return (new String(bs, offset + filedInfo.offset, filedInfo.size, ClientGlobal.g_charset)).trim(); 32 | } catch (UnsupportedEncodingException ex) { 33 | ex.printStackTrace(); 34 | return null; 35 | } 36 | } 37 | 38 | protected long longValue(byte[] bs, int offset, FieldInfo filedInfo) { 39 | return ProtoCommon.buff2long(bs, offset + filedInfo.offset); 40 | } 41 | 42 | protected int intValue(byte[] bs, int offset, FieldInfo filedInfo) { 43 | return (int) ProtoCommon.buff2long(bs, offset + filedInfo.offset); 44 | } 45 | 46 | protected int int32Value(byte[] bs, int offset, FieldInfo filedInfo) { 47 | return ProtoCommon.buff2int(bs, offset + filedInfo.offset); 48 | } 49 | 50 | protected byte byteValue(byte[] bs, int offset, FieldInfo filedInfo) { 51 | return bs[offset + filedInfo.offset]; 52 | } 53 | 54 | protected boolean booleanValue(byte[] bs, int offset, FieldInfo filedInfo) { 55 | return bs[offset + filedInfo.offset] != 0; 56 | } 57 | 58 | protected Date dateValue(byte[] bs, int offset, FieldInfo filedInfo) { 59 | return new Date(ProtoCommon.buff2long(bs, offset + filedInfo.offset) * 1000); 60 | } 61 | 62 | protected static class FieldInfo { 63 | protected String name; 64 | protected int offset; 65 | protected int size; 66 | 67 | public FieldInfo(String name, int offset, int size) { 68 | this.name = name; 69 | this.offset = offset; 70 | this.size = size; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/TrackerGroup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.net.InetSocketAddress; 13 | import java.net.Socket; 14 | 15 | /** 16 | * Tracker server group 17 | * 18 | * @author Happy Fish / YuQing 19 | * @version Version 1.17 20 | */ 21 | public class TrackerGroup { 22 | public int tracker_server_index; 23 | public InetSocketAddress[] tracker_servers; 24 | protected Integer lock; 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param tracker_servers tracker servers 30 | */ 31 | public TrackerGroup(InetSocketAddress[] tracker_servers) { 32 | this.tracker_servers = tracker_servers; 33 | this.lock = new Integer(0); 34 | this.tracker_server_index = 0; 35 | } 36 | 37 | /** 38 | * return connected tracker server 39 | * 40 | * @return connected tracker server, null for fail 41 | */ 42 | public TrackerServer getConnection(int serverIndex) throws IOException { 43 | Socket sock = new Socket(); 44 | sock.setReuseAddress(true); 45 | sock.setSoTimeout(ClientGlobal.g_network_timeout); 46 | sock.connect(this.tracker_servers[serverIndex], ClientGlobal.g_connect_timeout); 47 | return new TrackerServer(sock, this.tracker_servers[serverIndex]); 48 | } 49 | 50 | /** 51 | * return connected tracker server 52 | * 53 | * @return connected tracker server, null for fail 54 | */ 55 | public TrackerServer getConnection() throws IOException { 56 | int current_index; 57 | 58 | synchronized (this.lock) { 59 | this.tracker_server_index++; 60 | if (this.tracker_server_index >= this.tracker_servers.length) { 61 | this.tracker_server_index = 0; 62 | } 63 | 64 | current_index = this.tracker_server_index; 65 | } 66 | 67 | try { 68 | return this.getConnection(current_index); 69 | } catch (IOException ex) { 70 | System.err.println("connect to server " + this.tracker_servers[current_index].getAddress().getHostAddress() + ":" + this.tracker_servers[current_index].getPort() + " fail"); 71 | ex.printStackTrace(System.err); 72 | } 73 | 74 | for (int i = 0; i < this.tracker_servers.length; i++) { 75 | if (i == current_index) { 76 | continue; 77 | } 78 | 79 | try { 80 | TrackerServer trackerServer = this.getConnection(i); 81 | 82 | synchronized (this.lock) { 83 | if (this.tracker_server_index == current_index) { 84 | this.tracker_server_index = i; 85 | } 86 | } 87 | 88 | return trackerServer; 89 | } catch (IOException ex) { 90 | System.err.println("connect to server " + this.tracker_servers[i].getAddress().getHostAddress() + ":" + this.tracker_servers[i].getPort() + " fail"); 91 | ex.printStackTrace(System.err); 92 | } 93 | } 94 | 95 | return null; 96 | } 97 | 98 | public Object clone() { 99 | InetSocketAddress[] trackerServers = new InetSocketAddress[this.tracker_servers.length]; 100 | for (int i = 0; i < trackerServers.length; i++) { 101 | trackerServers[i] = new InetSocketAddress(this.tracker_servers[i].getAddress().getHostAddress(), this.tracker_servers[i].getPort()); 102 | } 103 | 104 | return new TrackerGroup(trackerServers); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/TrackerServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.OutputStream; 14 | import java.net.InetSocketAddress; 15 | import java.net.Socket; 16 | 17 | /** 18 | * Tracker Server Info 19 | * 20 | * @author Happy Fish / YuQing 21 | * @version Version 1.11 22 | */ 23 | public class TrackerServer { 24 | protected Socket sock; 25 | protected InetSocketAddress inetSockAddr; 26 | 27 | /** 28 | * Constructor 29 | * 30 | * @param sock Socket of server 31 | * @param inetSockAddr the server info 32 | */ 33 | public TrackerServer(Socket sock, InetSocketAddress inetSockAddr) { 34 | this.sock = sock; 35 | this.inetSockAddr = inetSockAddr; 36 | } 37 | 38 | /** 39 | * get the connected socket 40 | * 41 | * @return the socket 42 | */ 43 | public Socket getSocket() throws IOException { 44 | if (this.sock == null) { 45 | this.sock = ClientGlobal.getSocket(this.inetSockAddr); 46 | } 47 | 48 | return this.sock; 49 | } 50 | 51 | /** 52 | * get the server info 53 | * 54 | * @return the server info 55 | */ 56 | public InetSocketAddress getInetSocketAddress() { 57 | return this.inetSockAddr; 58 | } 59 | 60 | public OutputStream getOutputStream() throws IOException { 61 | return this.sock.getOutputStream(); 62 | } 63 | 64 | public InputStream getInputStream() throws IOException { 65 | return this.sock.getInputStream(); 66 | } 67 | 68 | public void close() throws IOException { 69 | if (this.sock != null) { 70 | try { 71 | ProtoCommon.closeSocket(this.sock); 72 | } finally { 73 | this.sock = null; 74 | } 75 | } 76 | } 77 | 78 | protected void finalize() throws Throwable { 79 | this.close(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/UploadCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | *

4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs; 10 | 11 | import java.io.IOException; 12 | import java.io.OutputStream; 13 | 14 | /** 15 | * upload file callback interface 16 | * 17 | * @author Happy Fish / YuQing 18 | * @version Version 1.0 19 | */ 20 | public interface UploadCallback { 21 | /** 22 | * send file content callback function, be called only once when the file uploaded 23 | * 24 | * @param out output stream for writing file content 25 | * @return 0 success, return none zero(errno) if fail 26 | */ 27 | public int send(OutputStream out) throws IOException; 28 | } 29 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/UploadStream.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.fastdfs; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | 7 | /** 8 | * Upload file by stream 9 | * 10 | * @author zhouzezhong & Happy Fish / YuQing 11 | * @version Version 1.11 12 | */ 13 | public class UploadStream implements UploadCallback { 14 | private InputStream inputStream; //input stream for reading 15 | private long fileSize = 0; //size of the uploaded file 16 | 17 | /** 18 | * constructor 19 | * 20 | * @param inputStream input stream for uploading 21 | * @param fileSize size of uploaded file 22 | */ 23 | public UploadStream(InputStream inputStream, long fileSize) { 24 | super(); 25 | this.inputStream = inputStream; 26 | this.fileSize = fileSize; 27 | } 28 | 29 | /** 30 | * send file content callback function, be called only once when the file uploaded 31 | * 32 | * @param out output stream for writing file content 33 | * @return 0 success, return none zero(errno) if fail 34 | */ 35 | public int send(OutputStream out) throws IOException { 36 | long remainBytes = fileSize; 37 | byte[] buff = new byte[256 * 1024]; 38 | int bytes; 39 | while (remainBytes > 0) { 40 | try { 41 | if ((bytes = inputStream.read(buff, 0, remainBytes > buff.length ? buff.length : (int) remainBytes)) < 0) { 42 | return -1; 43 | } 44 | } catch (IOException ex) { 45 | ex.printStackTrace(); 46 | return -1; 47 | } 48 | 49 | out.write(buff, 0, bytes); 50 | remainBytes -= bytes; 51 | } 52 | 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/common/MyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | * 4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs.common; 10 | 11 | /** 12 | * My Exception 13 | * 14 | * @author Happy Fish / YuQing 15 | * @version Version 1.0 16 | */ 17 | public class MyException extends Exception { 18 | public MyException() { 19 | } 20 | 21 | public MyException(String message) { 22 | super(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/common/fastdfs/common/NameValuePair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Happy Fish / YuQing 3 | * 4 | * FastDFS Java Client may be copied only under the terms of the GNU Lesser 5 | * General Public License (LGPL). 6 | * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. 7 | */ 8 | 9 | package org.zeus.common.fastdfs.common; 10 | 11 | /** 12 | * name(key) and value pair model 13 | * 14 | * @author Happy Fish / YuQing 15 | * @version Version 1.0 16 | */ 17 | public class NameValuePair { 18 | protected String name; 19 | protected String value; 20 | 21 | public NameValuePair() { 22 | } 23 | 24 | public NameValuePair(String name) { 25 | this.name = name; 26 | } 27 | 28 | public NameValuePair(String name, String value) { 29 | this.name = name; 30 | this.value = value; 31 | } 32 | 33 | public String getName() { 34 | return this.name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public String getValue() { 42 | return this.value; 43 | } 44 | 45 | public void setValue(String value) { 46 | this.value = value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/dto/MenuUpdateForm.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dto; 2 | 3 | 4 | 5 | import lombok.Data; 6 | import lombok.Setter; 7 | 8 | 9 | /** 10 | * Created by lizhizhong on 2018/11/26. 11 | */ 12 | @Data 13 | @Setter 14 | public class MenuUpdateForm{ 15 | private Long id; 16 | private String path; 17 | private String component; 18 | private String name; 19 | private String iconCls; 20 | private Long parentId; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/dto/PassWordResetResource.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dto; 2 | 3 | import lombok.Data; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import javax.validation.constraints.AssertTrue; 7 | import javax.validation.constraints.Size; 8 | @Data 9 | public class PassWordResetResource { 10 | public interface PasswordChk { 11 | 12 | } 13 | @Size(min=3,groups = PasswordChk.class) 14 | private String password; 15 | 16 | @Size(min=3,groups = PasswordChk.class) 17 | private String password2; 18 | 19 | @AssertTrue(message = "密码输入不一致,请重新输入",groups = PasswordChk.class) 20 | private boolean isValid(){ 21 | return StringUtils.equals(password,password2); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/dto/SysLogSearchForm.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dto; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | @Data 9 | public class SysLogSearchForm { 10 | 11 | @ApiModelProperty("日志类型") 12 | private String logType; 13 | 14 | @ApiModelProperty("操作人") 15 | private String operator; 16 | 17 | @ApiModelProperty("操作人角色") 18 | private String operatorRole; 19 | 20 | @ApiModelProperty("开始操作时间") 21 | private Date startTime; 22 | 23 | @ApiModelProperty("结束操作时间") 24 | private Date endTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/dto/UserInfoUpdateForm.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dto; 2 | import io.swagger.annotations.ApiModelProperty; 3 | import lombok.Data; 4 | import org.apache.commons.lang3.StringUtils; 5 | import springfox.documentation.annotations.ApiIgnore; 6 | 7 | @Data 8 | public class UserInfoUpdateForm { 9 | 10 | private Integer schoolNum; 11 | private Long id; 12 | 13 | @ApiModelProperty("本人姓名") 14 | private String teacherName; 15 | 16 | @ApiModelProperty("本人学位") 17 | private String academicDegree; 18 | 19 | @ApiModelProperty("毕业学校") 20 | private String graduatedUniversity; 21 | 22 | @ApiModelProperty("职称") 23 | private String title; 24 | 25 | public boolean isEmpty(){ 26 | if(StringUtils.isEmpty(this.getTeacherName()) 27 | &&StringUtils.isEmpty(this.getGraduatedUniversity()) 28 | &&StringUtils.isEmpty(this.getAcademicDegree()) 29 | && StringUtils.isEmpty(this.getTitle())){ 30 | return true; 31 | }else{ 32 | return false; 33 | } 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/dto/UserRegister.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dto; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author: lizhizhong 8 | * CreatedDate: 2018/12/31. 9 | */ 10 | @Data 11 | public class UserRegister { 12 | 13 | 14 | @ApiModelProperty(value="登录名",required=true) 15 | private String username; 16 | 17 | @ApiModelProperty(value="密码",required=true) 18 | private String password; 19 | 20 | @ApiModelProperty(value="用户姓名",required=true) 21 | private String teacherName; 22 | 23 | // @ApiModelProperty(value="角色id",required=true) 24 | // private Integer roleId; 25 | } 26 | -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/Menu.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Menu implements Serializable { 6 | private Integer id; 7 | 8 | private String url; 9 | 10 | private String path; 11 | 12 | private String component; 13 | 14 | private String name; 15 | 16 | private String iconcls; 17 | 18 | private Boolean keepalive; 19 | 20 | private Boolean requireauth; 21 | 22 | private Integer parentid; 23 | 24 | private Boolean enabled; 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getUrl() { 37 | return url; 38 | } 39 | 40 | public void setUrl(String url) { 41 | this.url = url == null ? null : url.trim(); 42 | } 43 | 44 | public String getPath() { 45 | return path; 46 | } 47 | 48 | public void setPath(String path) { 49 | this.path = path == null ? null : path.trim(); 50 | } 51 | 52 | public String getComponent() { 53 | return component; 54 | } 55 | 56 | public void setComponent(String component) { 57 | this.component = component == null ? null : component.trim(); 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | public void setName(String name) { 65 | this.name = name == null ? null : name.trim(); 66 | } 67 | 68 | public String getIconcls() { 69 | return iconcls; 70 | } 71 | 72 | public void setIconcls(String iconcls) { 73 | this.iconcls = iconcls == null ? null : iconcls.trim(); 74 | } 75 | 76 | public Boolean getKeepalive() { 77 | return keepalive; 78 | } 79 | 80 | public void setKeepalive(Boolean keepalive) { 81 | this.keepalive = keepalive; 82 | } 83 | 84 | public Boolean getRequireauth() { 85 | return requireauth; 86 | } 87 | 88 | public void setRequireauth(Boolean requireauth) { 89 | this.requireauth = requireauth; 90 | } 91 | 92 | public Integer getParentid() { 93 | return parentid; 94 | } 95 | 96 | public void setParentid(Integer parentid) { 97 | this.parentid = parentid; 98 | } 99 | 100 | public Boolean getEnabled() { 101 | return enabled; 102 | } 103 | 104 | public void setEnabled(Boolean enabled) { 105 | this.enabled = enabled; 106 | } 107 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/MenuRole.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class MenuRole implements Serializable { 6 | private Integer id; 7 | 8 | private Integer mid; 9 | 10 | private Integer rid; 11 | 12 | private String usertype; 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public Integer getMid() { 25 | return mid; 26 | } 27 | 28 | public void setMid(Integer mid) { 29 | this.mid = mid; 30 | } 31 | 32 | public Integer getRid() { 33 | return rid; 34 | } 35 | 36 | public void setRid(Integer rid) { 37 | this.rid = rid; 38 | } 39 | 40 | public String getUsertype() { 41 | return usertype; 42 | } 43 | 44 | public void setUsertype(String usertype) { 45 | this.usertype = usertype == null ? null : usertype.trim(); 46 | } 47 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/Role.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Role implements Serializable { 6 | private Integer id; 7 | 8 | private String name; 9 | 10 | private String namezh; 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name == null ? null : name.trim(); 28 | } 29 | 30 | public String getNamezh() { 31 | return namezh; 32 | } 33 | 34 | public void setNamezh(String namezh) { 35 | this.namezh = namezh == null ? null : namezh.trim(); 36 | } 37 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/SysLog.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | @Data 9 | public class SysLog implements Serializable { 10 | private Integer logId; 11 | 12 | private String logType; 13 | 14 | private String logContent; 15 | 16 | private Date operationTime; 17 | 18 | private String operator; 19 | 20 | private String sysType; 21 | 22 | private String operatorRole; 23 | 24 | private String ipAddress; 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/SysSchool.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class SysSchool implements Serializable { 6 | private Integer id; 7 | 8 | private Integer schoolId; 9 | 10 | private String schoolName; 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public Integer getSchoolId() { 23 | return schoolId; 24 | } 25 | 26 | public void setSchoolId(Integer schoolId) { 27 | this.schoolId = schoolId; 28 | } 29 | 30 | public String getSchoolName() { 31 | return schoolName; 32 | } 33 | 34 | public void setSchoolName(String schoolName) { 35 | this.schoolName = schoolName == null ? null : schoolName.trim(); 36 | } 37 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/SysSystem.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class SysSystem implements Serializable { 6 | private Integer id; 7 | 8 | private Integer systemId; 9 | 10 | private String systemName; 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public Integer getSystemId() { 23 | return systemId; 24 | } 25 | 26 | public void setSystemId(Integer systemId) { 27 | this.systemId = systemId; 28 | } 29 | 30 | public String getSystemName() { 31 | return systemName; 32 | } 33 | 34 | public void setSystemName(String systemName) { 35 | this.systemName = systemName == null ? null : systemName.trim(); 36 | } 37 | } -------------------------------------------------------------------------------- /zeus-common/src/main/java/org/zeus/entity/UserRole.java: -------------------------------------------------------------------------------- 1 | package org.zeus.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class UserRole implements Serializable { 6 | private Integer id; 7 | 8 | private Integer userid; 9 | 10 | private Integer rid; 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public Integer getUserid() { 23 | return userid; 24 | } 25 | 26 | public void setUserid(Integer userid) { 27 | this.userid = userid; 28 | } 29 | 30 | public Integer getRid() { 31 | return rid; 32 | } 33 | 34 | public void setRid(Integer rid) { 35 | this.rid = rid; 36 | } 37 | } -------------------------------------------------------------------------------- /zeus-common/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-common/src/main/resources/application.properties -------------------------------------------------------------------------------- /zeus-common/src/test/java/org/zeus/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.zeus; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /zeus-web/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/ValidateCodeBeanConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.zeus.common.validator.*; 7 | 8 | /** 9 | * @author: lizhizhong 10 | * CreatedDate: 2019/1/14. 11 | */ 12 | //@Configuration 13 | public class ValidateCodeBeanConfig { 14 | 15 | @Autowired 16 | private SecurityProperties securityProperties; 17 | 18 | /** 19 | * 图片验证码图片生成器 20 | * @return 21 | */ 22 | @Bean 23 | @ConditionalOnMissingBean(name = "imageValidateCodeGenerator") 24 | public ValidateCodeGenerator imageValidateCodeGenerator() { 25 | ImageCodeGenerator codeGenerator = new ImageCodeGenerator(); 26 | codeGenerator.setSecurityProperties(securityProperties); 27 | return codeGenerator; 28 | } 29 | 30 | /** 31 | * 短信验证码发送器 32 | * @return 33 | */ 34 | @Bean 35 | @ConditionalOnMissingBean(SmsCodeSender.class) 36 | public SmsCodeSender smsCodeSender() { 37 | return new DefaultSmsCodeSender(); 38 | } 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/ZeusDmsApplication.java: -------------------------------------------------------------------------------- 1 | package org.zeus; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.session.data.redis.config.ConfigureRedisAction; 10 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 11 | 12 | /** 13 | * 2.0的start中默认也有一个spring-boot-autoconfigure-2.0..RELEASE.jar, 14 | * 如果还引用了activiti的activiti-spring-boot-starter-rest-api.jar包, 15 | * 需要将两个包中的 SecurityAutoConfiguration.class 都排除, 16 | */ 17 | @SpringBootApplication 18 | @MapperScan({"org.zeus.dmsMapper"}) 19 | @ComponentScan({"org.zeus.controller","org.zeus.common","org.zeus.config","org.zeus.service"}) 20 | //@EnableCaching 21 | //@EnableRedisHttpSession 22 | public class ZeusDmsApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(ZeusDmsApplication.class, args); 26 | } 27 | 28 | /** 29 | * 这段配置是当程序运行在云端的redis的时候,为了安全,云厂商会关闭config 30 | * 命令,所以在这设置一下,如果是本地部署redis的话,这段配置可以去掉 31 | * @return 32 | */ 33 | @Bean 34 | public ConfigureRedisAction configureRedisAction() { 35 | return ConfigureRedisAction.NO_OP; 36 | } 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/CustomAuthenticationFailureHandler.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.authentication.*; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 8 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 9 | import org.springframework.stereotype.Component; 10 | import org.zeus.bean.RespBean; 11 | import org.zeus.common.fw.LogType; 12 | import org.zeus.dmsMapper.SysLogMapper; 13 | import org.zeus.entity.SysLog; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | import java.io.PrintWriter; 19 | import java.util.Date; 20 | 21 | /** 22 | * @author: lizhizhong 23 | * CreatedDate: 2019/1/14. 24 | */ 25 | @Component 26 | public class CustomAuthenticationFailureHandler implements AuthenticationFailureHandler { 27 | 28 | @Autowired 29 | SysLogMapper sysLogMapper; 30 | @Override 31 | public void onAuthenticationFailure(HttpServletRequest req, 32 | HttpServletResponse resp, 33 | AuthenticationException e) throws IOException { 34 | resp.setContentType("application/json;charset=utf-8"); 35 | RespBean respBean = null; 36 | String reson = null; 37 | if (e instanceof BadCredentialsException || 38 | e instanceof UsernameNotFoundException) { 39 | reson="账户名或者密码输入错误!"; 40 | respBean = RespBean.error(reson); 41 | } else if (e instanceof LockedException) { 42 | reson="账户被锁定,请联系管理员!"; 43 | respBean = RespBean.error("账户被锁定,请联系管理员!"); 44 | } else if (e instanceof CredentialsExpiredException) { 45 | reson="密码过期,请联系管理员!"; 46 | respBean = RespBean.error("密码过期,请联系管理员!"); 47 | } else if (e instanceof AccountExpiredException) { 48 | reson="账户过期,请联系管理员!"; 49 | respBean = RespBean.error("账户过期,请联系管理员!"); 50 | } else if (e instanceof DisabledException) { 51 | reson="账户被禁用,请联系管理员!"; 52 | respBean = RespBean.error("账户被禁用,请联系管理员!"); 53 | } else { 54 | reson="其他原因!"; 55 | respBean = RespBean.error("其他原因!"); 56 | } 57 | // 数据库中插入操作记录 58 | SysLog sysLog = new SysLog(); 59 | sysLog.setOperatorRole("未知"); 60 | sysLog.setLogType(LogType.LOGIN.getDesc()); 61 | sysLog.setOperator((String)req.getSession().getAttribute("SPRING_SECURITY_LAST_USERNAME")); 62 | sysLog.setLogContent(String.format("用户登录失败,失败原因%s",reson)); 63 | sysLog.setOperationTime(new Date()); 64 | sysLogMapper.insert(sysLog); 65 | resp.setStatus(401); 66 | ObjectMapper om = new ObjectMapper(); 67 | PrintWriter out = resp.getWriter(); 68 | out.write(om.writeValueAsString(respBean)); 69 | out.flush(); 70 | out.close(); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/CustomUserTypeAuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.security.authentication.AuthenticationServiceException; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | /** 13 | * 添加自定义的登录时额外字段的验证过滤器 14 | * @author: lizhizhong 15 | * CreatedDate: 2018/11/30. 16 | */ 17 | public class CustomUserTypeAuthenticationFilter extends UsernamePasswordAuthenticationFilter { 18 | 19 | public static final String SPRING_SECURITY_FORM_DOMAIN_KEY = "userType"; 20 | 21 | /** 22 | * 23 | * @param request 24 | * @param response 25 | * @return Authentication 对象 26 | * @throws AuthenticationException 27 | */ 28 | @Override 29 | public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) 30 | throws AuthenticationException { 31 | 32 | if (!request.getMethod() 33 | .equals("POST")) { 34 | throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); 35 | } 36 | 37 | UsernamePasswordAuthenticationToken authRequest = getAuthRequest(request); 38 | setDetails(request, authRequest); 39 | return this.getAuthenticationManager() 40 | .authenticate(authRequest); 41 | } 42 | 43 | private UsernamePasswordAuthenticationToken getAuthRequest(HttpServletRequest request) { 44 | String username = obtainUsername(request); 45 | String password = obtainPassword(request); 46 | String userType = obtainUserType(request); 47 | 48 | if (username == null) { 49 | username = ""; 50 | } 51 | if (password == null) { 52 | password = ""; 53 | } 54 | if (userType == null) { 55 | userType = ""; 56 | } 57 | 58 | String usernameAndType = String.format("%s%s%s", username.trim(), 59 | String.valueOf(Character.LINE_SEPARATOR), userType); 60 | 61 | return new UsernamePasswordAuthenticationToken(usernameAndType, password); 62 | } 63 | 64 | /** 65 | * 得到用户类型userType 以在UserDetailServices中进行登录验证 66 | * @param request 67 | * @return 用户类型 68 | */ 69 | private String obtainUserType(HttpServletRequest request) { 70 | return request.getParameter(SPRING_SECURITY_FORM_DOMAIN_KEY); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/DateConverter.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.core.convert.converter.Converter; 4 | 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by lizhizhong on 2018/11/26 11 | */ 12 | public class DateConverter implements Converter { 13 | private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 14 | @Override 15 | public Date convert(String s) { 16 | if ("".equals(s) || s == null) { 17 | return null; 18 | } 19 | try { 20 | return simpleDateFormat.parse(s); 21 | } catch (ParseException e) { 22 | e.printStackTrace(); 23 | } 24 | return null; 25 | } 26 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/GlobalAuthenticationConfigurerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * @author: lizhizhong 7 | * CreatedDate: 2018/12/14. 8 | */ 9 | @Component 10 | public class GlobalAuthenticationConfigurerAdapter extends org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter { 11 | } 12 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/LogTrackInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.slf4j.MDC; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.servlet.HandlerInterceptor; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import javax.servlet.http.HttpSession; 12 | import java.security.Principal; 13 | 14 | /** 15 | * @author: lizhizhong 16 | * CreatedDate: 2018/12/1. 17 | */ 18 | @Component 19 | @Slf4j 20 | public class LogTrackInterceptor implements HandlerInterceptor { 21 | 22 | private static final String USER_ID = "userId"; 23 | 24 | private static final String SESSION_ID = "sessionId"; 25 | 26 | private static final String ANONYMOUS = "匿名用户"; 27 | 28 | @Override 29 | public boolean preHandle(HttpServletRequest request, HttpServletResponse httpServletResponse, Object o) throws Exception { 30 | 31 | String xForwardedForHeader = request.getHeader("X-Forwarded-For"); 32 | String remoteIp = request.getRemoteAddr(); 33 | 34 | if(log.isDebugEnabled()){ 35 | log.debug("client ip:{}, X-Forwarded-For:{}", remoteIp, xForwardedForHeader); 36 | } 37 | 38 | Principal auth = request.getUserPrincipal(); 39 | String userId = ""; 40 | if (auth != null) { 41 | userId = auth.getName(); 42 | } else { 43 | userId = ANONYMOUS; 44 | } 45 | MDC.put(USER_ID, userId); 46 | 47 | HttpSession session = request.getSession(false); 48 | if (session != null) { 49 | MDC.put(SESSION_ID, session.getId()); 50 | } 51 | 52 | return true; 53 | } 54 | 55 | @Override 56 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 57 | 58 | if(log.isDebugEnabled()){ 59 | log.debug("清除用户ID和SessionID"); 60 | } 61 | 62 | MDC.remove(USER_ID); 63 | MDC.remove(SESSION_ID); 64 | } 65 | 66 | @Override 67 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/LoginFailedEventListener.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.ApplicationListener; 5 | import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Slf4j 10 | public class LoginFailedEventListener implements ApplicationListener { 11 | @Override 12 | public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) { 13 | String username= event.getAuthentication().getName(); 14 | log.info("{}登录失败!",username); 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | /** 4 | * @author lizhizhong 5 | * 自定义响应码 6 | */ 7 | public enum ResponseCode { 8 | 9 | /**成功*/ 10 | SUCCESS(0,"SUCCESS"), 11 | 12 | /**失败*/ 13 | ERROR(1,"ERROR"), 14 | 15 | /**需要登录*/ 16 | NEED_LOGIN(10,"NEED_LOGIN"), 17 | 18 | /**非法的参数*/ 19 | ILLEGAL_ARGUMENT(2,"ILLEGAL_ARGUMENT"); 20 | 21 | private final int code; 22 | private final String desc; 23 | 24 | 25 | ResponseCode(int code, String desc){ 26 | this.code = code; 27 | this.desc = desc; 28 | } 29 | 30 | public int getCode(){ 31 | return code; 32 | } 33 | public String getDesc(){ 34 | return desc; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/RestUsernamePasswordAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 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 | 9 | /** 10 | * 11 | * @author: lizhizhong 12 | * CreatedDate: 2018/11/28. 13 | */ 14 | public class RestUsernamePasswordAuthenticationProvider extends DaoAuthenticationProvider { 15 | 16 | @Override 17 | protected void additionalAuthenticationChecks(UserDetails userDetails, 18 | UsernamePasswordAuthenticationToken authentication) 19 | throws AuthenticationException { 20 | 21 | super.additionalAuthenticationChecks(userDetails, authentication); 22 | 23 | } 24 | 25 | @Override 26 | protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, 27 | UserDetails user) { 28 | 29 | UsernamePasswordAuthenticationToken s = (UsernamePasswordAuthenticationToken) super.createSuccessAuthentication( 30 | principal, authentication, user); 31 | 32 | UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication; 33 | UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken( 34 | principal, token.getCredentials(), s.getAuthorities()); 35 | result.setDetails(token.getDetails()); 36 | 37 | return result; 38 | } 39 | 40 | @Override 41 | public boolean supports(Class authentication) { 42 | return UsernamePasswordAuthenticationToken.class 43 | .isAssignableFrom(authentication); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/SecurityConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common; 5 | 6 | /** 7 | * @author zhailiang 8 | * 9 | */ 10 | public interface SecurityConstants { 11 | 12 | /** 13 | * 默认的处理验证码的url前缀 14 | */ 15 | String DEFAULT_VALIDATE_CODE_URL_PREFIX = "/code"; 16 | /** 17 | * 当请求需要身份认证时,默认跳转的url 18 | * 19 | * @see SecurityController 20 | */ 21 | String DEFAULT_UNAUTHENTICATION_URL = "/authentication/require"; 22 | /** 23 | * 默认的用户名密码登录请求处理url 24 | */ 25 | String DEFAULT_SIGN_IN_PROCESSING_URL_FORM = "/authentication/form"; 26 | /** 27 | * 默认的手机验证码登录请求处理url 28 | */ 29 | String DEFAULT_SIGN_IN_PROCESSING_URL_MOBILE = "/authentication/mobile"; 30 | /** 31 | * 默认的OPENID登录请求处理url 32 | */ 33 | String DEFAULT_SIGN_IN_PROCESSING_URL_OPENID = "/authentication/openid"; 34 | /** 35 | * 默认登录页面 36 | * 37 | */ 38 | String DEFAULT_SIGN_IN_PAGE_URL = "/imooc-signIn.html"; 39 | /** 40 | * 验证图片验证码时,http请求中默认的携带图片验证码信息的参数的名称 41 | */ 42 | String DEFAULT_PARAMETER_NAME_CODE_IMAGE = "imageCode"; 43 | /** 44 | * 验证短信验证码时,http请求中默认的携带短信验证码信息的参数的名称 45 | */ 46 | String DEFAULT_PARAMETER_NAME_CODE_SMS = "smsCode"; 47 | /** 48 | * 发送短信验证码 或 验证短信验证码时,传递手机号的参数的名称 49 | */ 50 | String DEFAULT_PARAMETER_NAME_MOBILE = "mobile"; 51 | /** 52 | * openid参数名 53 | */ 54 | String DEFAULT_PARAMETER_NAME_OPENID = "openId"; 55 | /** 56 | * providerId参数名 57 | */ 58 | String DEFAULT_PARAMETER_NAME_PROVIDERID = "providerId"; 59 | /** 60 | * session失效默认的跳转地址 61 | */ 62 | String DEFAULT_SESSION_INVALID_URL = "/imooc-session-invalid.html"; 63 | /** 64 | * 获取第三方用户信息的url 65 | */ 66 | String DEFAULT_SOCIAL_USER_INFO_URL = "/social/user"; 67 | } 68 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/SecurityCoreConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.zeus.common.validator.SecurityProperties; 6 | 7 | /** 8 | * @author: lizhizhong 9 | * CreatedDate: 2019/1/14. 10 | */ 11 | @Configuration 12 | @EnableConfigurationProperties(SecurityProperties.class) 13 | public class SecurityCoreConfig { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/ServerResponse.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 服务响应对象封装 11 | * @author aichaellee 12 | */ 13 | //保证序列化json的时候,如果是null的对象,key也会消失*/ 14 | //@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) 15 | @JsonInclude(JsonInclude.Include.NON_NULL) 16 | public class ServerResponse implements Serializable { 17 | 18 | private int status; 19 | private String msg; 20 | private T data; 21 | 22 | private ServerResponse(int status){ 23 | this.status = status; 24 | } 25 | private ServerResponse(int status, T data){ 26 | this.status = status; 27 | this.data = data; 28 | } 29 | 30 | private ServerResponse(int status, String msg, T data){ 31 | this.status = status; 32 | this.msg = msg; 33 | this.data = data; 34 | } 35 | 36 | private ServerResponse(int status, String msg){ 37 | this.status = status; 38 | this.msg = msg; 39 | } 40 | 41 | @JsonIgnore 42 | // 使之不在json序列化结果当中 43 | public boolean isSuccess(){ 44 | return this.status == ResponseCode.SUCCESS.getCode(); 45 | } 46 | 47 | public int getStatus(){ 48 | return status; 49 | } 50 | public T getData(){ 51 | return data; 52 | } 53 | public String getMsg(){ 54 | return msg; 55 | } 56 | 57 | 58 | public static ServerResponse createBySuccess(){ 59 | return new ServerResponse(ResponseCode.SUCCESS.getCode()); 60 | } 61 | 62 | public static ServerResponse createBySuccess(String msg){ 63 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg); 64 | } 65 | 66 | public static ServerResponse createBySuccess(T data){ 67 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),data); 68 | } 69 | 70 | public static ServerResponse createBySuccess(String msg,T data){ 71 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg,data); 72 | } 73 | 74 | 75 | public static ServerResponse createByError(){ 76 | return new ServerResponse(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc()); 77 | } 78 | 79 | 80 | public static ServerResponse createByError(String errorMessage){ 81 | return new ServerResponse(ResponseCode.ERROR.getCode(),errorMessage); 82 | } 83 | 84 | public static ServerResponse createByErrorCodeMessage(int errorCode,String errorMessage){ 85 | return new ServerResponse(errorCode,errorMessage); 86 | } 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | } 101 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/SmsCodeAuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.security.authentication.AuthenticationServiceException; 4 | import org.springframework.security.core.Authentication; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; 7 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 8 | import org.springframework.util.Assert; 9 | 10 | import javax.servlet.ServletException; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | public class SmsCodeAuthenticationFilter extends AbstractAuthenticationProcessingFilter { 16 | /** 17 | * request中必须含有mobile参数 18 | */ 19 | private String mobileParameter = SecurityConstants.DEFAULT_PARAMETER_NAME_MOBILE; 20 | /** 21 | * post请求 22 | */ 23 | private boolean postOnly = true; 24 | 25 | protected SmsCodeAuthenticationFilter() { 26 | /** 27 | * 处理的手机验证码登录请求处理url 28 | */ 29 | super(new AntPathRequestMatcher(SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_MOBILE, "POST")); 30 | } 31 | 32 | @Override 33 | public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { 34 | //判断是是不是post请求 35 | if (postOnly && !request.getMethod().equals("POST")) { 36 | throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); 37 | } 38 | //从请求中获取手机号码 39 | String mobile = obtainMobile(request); 40 | 41 | if (mobile == null) { 42 | mobile = ""; 43 | } 44 | 45 | mobile = mobile.trim(); 46 | //创建SmsCodeAuthenticationToken(未认证) 47 | SmsCodeAuthenticationToken authRequest = new SmsCodeAuthenticationToken(mobile); 48 | 49 | //设置用户信息 50 | setDetails(request, authRequest); 51 | //返回Authentication实例 52 | return this.getAuthenticationManager().authenticate(authRequest); 53 | } 54 | 55 | /** 56 | * 获取手机号 57 | */ 58 | protected String obtainMobile(HttpServletRequest request) { 59 | return request.getParameter(mobileParameter); 60 | } 61 | 62 | protected void setDetails(HttpServletRequest request, SmsCodeAuthenticationToken authRequest) { 63 | authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); 64 | } 65 | 66 | public void setMobileParameter(String usernameParameter) { 67 | Assert.hasText(usernameParameter, "Username parameter must not be empty or null"); 68 | this.mobileParameter = usernameParameter; 69 | } 70 | 71 | public void setPostOnly(boolean postOnly) { 72 | this.postOnly = postOnly; 73 | } 74 | 75 | public final String getMobileParameter() { 76 | return mobileParameter; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/SmsCodeAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.security.authentication.AuthenticationProvider; 4 | import org.springframework.security.authentication.InternalAuthenticationServiceException; 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.zeus.service.SecurityMobileUserDetailService; 10 | 11 | public class SmsCodeAuthenticationProvider implements AuthenticationProvider { 12 | private SecurityMobileUserDetailService userDetailsService; 13 | 14 | @Override 15 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 16 | SmsCodeAuthenticationToken authenticationToken = (SmsCodeAuthenticationToken) authentication; 17 | //调用自定义的userDetailsService认证 18 | UserDetails user = userDetailsService.loadUserByUsername((String) authenticationToken.getPrincipal()); 19 | 20 | if (user == null) { 21 | throw new InternalAuthenticationServiceException("无法获取用户信息"); 22 | } 23 | //如果user不为空重新构建SmsCodeAuthenticationToken(已认证) 24 | SmsCodeAuthenticationToken authenticationResult = new SmsCodeAuthenticationToken(user, user.getAuthorities()); 25 | 26 | authenticationResult.setDetails(authenticationToken.getDetails()); 27 | 28 | return authenticationResult; 29 | } 30 | 31 | /** 32 | * 只有Authentication为SmsCodeAuthenticationToken使用此Provider认证 33 | * @param authentication 34 | * @return 35 | */ 36 | @Override 37 | public boolean supports(Class authentication) { 38 | return SmsCodeAuthenticationToken.class.isAssignableFrom(authentication); 39 | } 40 | 41 | public UserDetailsService getUserDetailsService() { 42 | return userDetailsService; 43 | } 44 | 45 | public void setUserDetailsService(SecurityMobileUserDetailService userDetailsService) { 46 | this.userDetailsService = userDetailsService; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/SmsCodeAuthenticationToken.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | import org.springframework.security.authentication.AbstractAuthenticationToken; 4 | import org.springframework.security.core.GrantedAuthority; 5 | 6 | import java.util.Collection; 7 | 8 | public class SmsCodeAuthenticationToken extends AbstractAuthenticationToken { 9 | private static final long serialVersionUID = 2383092775910246006L; 10 | 11 | /** 12 | * 手机号 13 | */ 14 | private final Object principal; 15 | 16 | /** 17 | * SmsCodeAuthenticationFilter中构建的未认证的Authentication 18 | * @param mobile 19 | */ 20 | public SmsCodeAuthenticationToken(String mobile) { 21 | super(null); 22 | this.principal = mobile; 23 | setAuthenticated(false); 24 | } 25 | 26 | /** 27 | * SmsCodeAuthenticationProvider中构建已认证的Authentication 28 | * @param principal 29 | * @param authorities 30 | */ 31 | public SmsCodeAuthenticationToken(Object principal, 32 | Collection authorities) { 33 | super(authorities); 34 | this.principal = principal; 35 | super.setAuthenticated(true); // must use super, as we override 36 | } 37 | 38 | @Override 39 | public Object getCredentials() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public Object getPrincipal() { 45 | return this.principal; 46 | } 47 | 48 | /** 49 | * @param isAuthenticated 50 | * @throws IllegalArgumentException 51 | */ 52 | public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { 53 | if (isAuthenticated) { 54 | throw new IllegalArgumentException( 55 | "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); 56 | } 57 | 58 | super.setAuthenticated(false); 59 | } 60 | 61 | @Override 62 | public void eraseCredentials() { 63 | super.eraseCredentials(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/UserTypeEnum.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | 3 | /** 4 | * @author: lizhizhong 5 | * CreatedDate: 2018/12/1. 6 | */ 7 | public enum UserTypeEnum { 8 | 9 | /** 10 | * 学生 11 | */ 12 | STUDENT("学生","3"), 13 | 14 | /** 15 | * 管理员 16 | */ 17 | ADMIN("管理员","1"), 18 | 19 | /** 20 | * 教师 21 | */ 22 | TEACHER("教师","2"); 23 | 24 | private String userTypeZh; 25 | private String userType; 26 | 27 | 28 | UserTypeEnum(String userTypename,String userType){ 29 | this.userTypeZh = userTypename; 30 | this.userType = userType; 31 | 32 | } 33 | 34 | public String getUserType(){ 35 | return this.userType; 36 | } 37 | 38 | /** 39 | * 40 | * @param userType 41 | * @return 用户类型的中文名称 42 | */ 43 | public static String getUserTypeZh(String userType){ 44 | 45 | for(UserTypeEnum value:UserTypeEnum.values()){ 46 | if(value.getUserType().equals(userType)){ 47 | return value.userTypeZh; 48 | } 49 | 50 | } 51 | return null; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/UserUtils.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common; 2 | import org.springframework.security.core.context.SecurityContextHolder; 3 | import org.zeus.bean.User; 4 | 5 | /** 6 | * 得到当前用户信息 7 | * @author: lizhizhong 8 | * CreatedDate: 2018/11/28. 9 | */ 10 | public class UserUtils { 11 | public static User getCurrentUser() { 12 | 13 | return (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/fw/LogType.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.fw; 2 | 3 | /** 4 | * 日志类型 5 | * @author: lizhizhong 6 | * CreatedDate: 2018/12/04. 7 | */ 8 | 9 | public enum LogType { 10 | 11 | /** 12 | * 默认0操作 13 | */ 14 | OPERATION(0,"流程操作"), 15 | 16 | /** 17 | * 1登录 18 | */ 19 | LOGIN(1,"登录操作"), 20 | 21 | /** 22 | * 2 删除 23 | */ 24 | DELETE(2,"删除操作"), 25 | 26 | /** 27 | * 3 更改 28 | */ 29 | UPDATE(3,"更改操作"), 30 | 31 | /** 32 | * 审核 33 | */ 34 | AUDITING(4,"审核操作"), 35 | 36 | /** 37 | * 检测 38 | */ 39 | DETECTION(5,"检测操作"), 40 | 41 | /** 42 | * 课题相似性 43 | */ 44 | TOPIC_SIMILARITY(6,"相关性操作"); 45 | 46 | private int code; 47 | private String desc; 48 | 49 | LogType(int code,String desc){ 50 | this.code = code; 51 | this.desc = desc; 52 | } 53 | 54 | public String getDesc(){ 55 | return this.desc; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/fw/annotation/SystemLog.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.fw.annotation; 2 | 3 | 4 | import org.zeus.common.fw.LogType; 5 | 6 | import java.lang.annotation.*; 7 | 8 | /** 9 | * 方法级别的系统日志 10 | * @author lizhizhong 11 | * @date 2018-12-04 12 | */ 13 | @Target({ElementType.PARAMETER, ElementType.METHOD})//作用于参数或方法上 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | public @interface SystemLog { 17 | 18 | /** 19 | * 日志名称 20 | * @return 21 | */ 22 | String description() default ""; 23 | 24 | /** 25 | * 日志类型 26 | * @return 27 | */ 28 | LogType type() default LogType.OPERATION; 29 | } 30 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/util/DBUtil.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.util; 2 | 3 | 4 | import java.util.Map; 5 | 6 | import com.alibaba.druid.pool.DruidDataSource; 7 | 8 | import org.zeus.config.DataSourceContextHolder; 9 | import org.zeus.config.DynamicDataSource; 10 | import org.zeus.entity.University; 11 | 12 | public class DBUtil { 13 | 14 | public static void addOrChangeDataSource(University user){ 15 | 16 | /** 17 | * 创建动态数据源 18 | */ 19 | Map dataSourceMap = DynamicDataSource.getInstance().getDataSourceMap(); 20 | if(!dataSourceMap.containsKey(user.getDbip())&&!"".equals(user.getDbip())&&null != user.getDbip()){ 21 | DruidDataSource dynamicDataSource = new DruidDataSource(); 22 | dynamicDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); 23 | dynamicDataSource.setUrl("jdbc:mysql://"+user.getDbip()+"" 24 | + ":3306/"+user.getDbname()+"?characterEncoding=utf-8&serverTimezone=GMT%2B8" 25 | + "&&useSSL=false" 26 | ); 27 | dynamicDataSource.setUsername(user.getSchoolName()); 28 | dynamicDataSource.setPassword(user.getDbPassword()); 29 | dataSourceMap.put(user.getDbip(), dynamicDataSource); 30 | DynamicDataSource.getInstance().setTargetDataSources(dataSourceMap); 31 | /** 32 | * 切换为动态数据源实例,打印学生信息 33 | */ 34 | DataSourceContextHolder.setDBType(user.getDbip()); 35 | }else{ 36 | /** 37 | * 切换为动态数据源实例,打印学生信息 38 | */ 39 | DataSourceContextHolder.setDBType(user.getDbip()); 40 | } 41 | 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/util/DMSConstant.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.util; 2 | 3 | 4 | public class DMSConstant { 5 | 6 | public static final String AES_KEY = "wdoj223ind2j3ndhr4ij99rmfdualspx9"; 7 | 8 | /** 9 | * 复制库的命名初始格式 10 | */ 11 | public static final String DB_NAME_MASTER_START = "master_"; 12 | public static final String DB_NAME_MASTER_END = "_db"; 13 | 14 | 15 | 16 | public static final String ENCRYPT_AES_TYPE = "AES"; 17 | public static final String ENCRYPT_SHA1PRNG = "SHA1PRNG"; 18 | public static final String SESSION_KEY_USERNAME = "userName" ; 19 | public static final String SESSION_KEY_USERINFO = "userInfo" ; 20 | public static final String MD5 = "MD5"; 21 | public static final int PASSWORD_BEGIN = 3; 22 | public static final int PASSWORD_LANG = 31; 23 | 24 | public static final String LOGIN_CHECK_IMG_CODE = "imageCode"; 25 | public static final String RETURN_SUCCESS = "isSuccess"; 26 | public static final String RETURN_MESSAGE = "message"; 27 | /** 28 | * sql 常量 29 | */ 30 | public static final String SQL_SELECT_STR = "SELECT "; 31 | public static final String SQL_FROM_STR = "FROM "; 32 | public static final String SQL_ODER_STR = "ODER BY "; 33 | public static final String SQL_WHERE_STR = "WHERE "; 34 | public static final String SQL_AND_STR = "AND "; 35 | public static final String SQL_LIKE_STR ="LIKE "; 36 | public static final String SQL_LIMIT_STR = "LIMIT "; 37 | public static final String SQL_ASC_STR = "ASC "; 38 | public static final String SQL_DESC_STR= "DESC "; 39 | public static final String SQL_UPDATE_STR = "UPDATE "; 40 | public static final String SQL_INSERT_STR = "INSERT "; 41 | public static final String SQL_SET_STR = "SET "; 42 | public static final String SQL_ = ""; 43 | public static final String SQL_1 = ""; 44 | public static final String SQL_2 = ""; 45 | 46 | 47 | public static final String SQL_USER_NAME = "username"; 48 | } 49 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/util/IpInfoUtil.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.util; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import java.net.InetAddress; 9 | import java.net.UnknownHostException; 10 | 11 | 12 | /** 13 | * @author aichaellee 14 | */ 15 | @Slf4j 16 | @Component 17 | public class IpInfoUtil { 18 | 19 | 20 | /** 21 | * 获取客户端IP地址 22 | * @param request 请求 23 | * @return 24 | */ 25 | public String getIpAddr(HttpServletRequest request) { 26 | 27 | String ip = request.getHeader("x-forwarded-for"); 28 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 29 | ip = request.getHeader("Proxy-Client-IP"); 30 | } 31 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 32 | ip = request.getHeader("WL-Proxy-Client-IP"); 33 | } 34 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 35 | ip = request.getRemoteAddr(); 36 | if (ip.equals("127.0.0.1")) { 37 | //根据网卡取本机配置的IP 38 | InetAddress inet = null; 39 | try { 40 | inet = InetAddress.getLocalHost(); 41 | } catch (UnknownHostException e) { 42 | e.printStackTrace(); 43 | } 44 | ip = inet.getHostAddress(); 45 | } 46 | } 47 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 48 | if (ip != null && ip.length() > 15) { 49 | if (ip.indexOf(",") > 0) { 50 | ip = ip.substring(0, ip.indexOf(",")); 51 | } 52 | } 53 | if("0:0:0:0:0:0:0:1".equals(ip)){ 54 | ip="127.0.0.1"; 55 | } 56 | return ip; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/util/RedisTool.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.util; 2 | 3 | import redis.clients.jedis.Jedis; 4 | 5 | import java.util.Collections; 6 | 7 | /** 8 | * @author: lizhizhong 9 | * CreatedDate: 2018/12/6. 10 | */ 11 | public class RedisTool { 12 | 13 | private static final String LOCK_SUCCESS = "OK"; 14 | private static final String SET_IF_NOT_EXIST = "NX"; 15 | private static final String SET_WITH_EXPIRE_TIME = "PX"; 16 | 17 | private static final Long RELEASE_SUCCESS = 1L; 18 | 19 | /** 20 | * 尝试获取分布式锁 21 | * @param jedis Redis客户端 22 | * @param lockKey 锁 23 | * @param requestId 请求标识 24 | * @param expireTime 超期时间 25 | * @return 是否获取成功 26 | */ 27 | public static boolean tryGetDistributedLock(Jedis jedis, String lockKey, String requestId, int expireTime) { 28 | 29 | String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, expireTime); 30 | 31 | if (LOCK_SUCCESS.equals(result)) { 32 | return true; 33 | } 34 | return false; 35 | 36 | } 37 | 38 | /** 39 | * 释放分布式锁 40 | * @param jedis Redis客户端 41 | * @param lockKey 锁 42 | * @param requestId 请求标识 43 | * @return 是否释放成功 44 | */ 45 | public static boolean releaseDistributedLock(Jedis jedis, String lockKey, String requestId) { 46 | 47 | String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; 48 | Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(requestId)); 49 | 50 | if (RELEASE_SUCCESS.equals(result)) { 51 | return true; 52 | } 53 | return false; 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/util/WindowsUtils.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.util; 2 | 3 | 4 | import java.io.BufferedReader; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.io.InputStreamReader; 8 | import java.nio.charset.Charset; 9 | 10 | import ch.ethz.ssh2.Connection; 11 | import ch.ethz.ssh2.Session; 12 | 13 | /** 14 | * windows\ssh2 执行命令工具类 15 | * @author to 16 | * 17 | */ 18 | public class WindowsUtils { 19 | 20 | private Connection conn; 21 | private String ipAddr; 22 | private String charset = Charset.defaultCharset().toString(); 23 | private String userName; 24 | private String password; 25 | 26 | public WindowsUtils(String ipAddr, String userName, String password, 27 | String charset) { 28 | this.ipAddr = ipAddr; 29 | this.userName = userName; 30 | this.password = password; 31 | if (charset != null) { 32 | this.charset = charset; 33 | } 34 | } 35 | 36 | /** 37 | * 直接执行服务器命令 38 | * 命令示例 :"cmd /c mysqldump -h 127.0.0.1 testdata -uroot -proot --add-drop-table | mysql -h 192.168.100.66 testdata -uroot -proot" 39 | * @param strCMD 40 | * @return 41 | */ 42 | public static boolean execCMD(String strCMD){ 43 | boolean flag=false; 44 | Runtime rt = Runtime.getRuntime(); 45 | try { 46 | Process p = rt.exec(strCMD); 47 | BufferedReader bufferedReader = new BufferedReader( 48 | new InputStreamReader(p.getInputStream())); 49 | String output = null; 50 | while ((output = bufferedReader.readLine()) != null){ 51 | System.out.println(output); 52 | } 53 | if(p.waitFor()>0){ 54 | flag =true; 55 | }else{ 56 | flag=false; 57 | } 58 | 59 | } catch (IOException e) { 60 | // TODO Auto-generated catch block 61 | e.printStackTrace(); 62 | flag=false; 63 | } catch (InterruptedException e) { 64 | // TODO Auto-generated catch block 65 | e.printStackTrace(); 66 | flag=false; 67 | } 68 | return flag; 69 | } 70 | /** 71 | * 直接执行服务器命令 72 | * 命令示例 :"cmd /c mysqldump -h 127.0.0.1 testdata -uroot -proot --add-drop-table | mysql -h 192.168.100.66 testdata -uroot -proot" 73 | * @param strCMD 74 | * @return 75 | */ 76 | public static Process execCMD(String[] strCMD){ 77 | 78 | Runtime rt = Runtime.getRuntime(); 79 | try { 80 | Process p = rt.exec(strCMD); 81 | return p; 82 | } catch (IOException e) { 83 | // TODO Auto-generated catch block 84 | e.printStackTrace(); 85 | } 86 | return null; 87 | } 88 | 89 | 90 | public boolean login() throws IOException { 91 | conn = new Connection(ipAddr); 92 | conn.connect(); // 连接 93 | return conn.authenticateWithPassword(userName, password); // 认证 94 | } 95 | 96 | /** 97 | * ssh连接执行命令,需要初始化对象。 98 | * @param cmds 99 | * @return 100 | */ 101 | public String execSSH(String cmds) { 102 | InputStream in = null; 103 | String result = ""; 104 | try { 105 | if (this.login()) { 106 | Session session = conn.openSession(); // 打开一个会话 107 | session.execCommand(cmds); 108 | 109 | in = session.getStdout(); 110 | result = this.processStdout(in, this.charset); 111 | session.close(); 112 | conn.close(); 113 | } 114 | } catch (IOException e1) { 115 | e1.printStackTrace(); 116 | } 117 | return result; 118 | } 119 | 120 | public String processStdout(InputStream in, String charset) { 121 | 122 | byte[] buf = new byte[1024]; 123 | StringBuffer sb = new StringBuffer(); 124 | try { 125 | while (in.read(buf) != -1) { 126 | sb.append(new String(buf, charset)); 127 | } 128 | } catch (IOException e) { 129 | e.printStackTrace(); 130 | } 131 | return sb.toString(); 132 | } 133 | 134 | 135 | 136 | } 137 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/AbstractValidateCodeProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.ServletRequestBindingException; 10 | import org.springframework.web.bind.ServletRequestUtils; 11 | import org.springframework.web.context.request.ServletWebRequest; 12 | 13 | import java.util.Map; 14 | 15 | /** 16 | * 抽象的图片验证码处理器 17 | * @author lizhizhong 18 | * 19 | */ 20 | public abstract class AbstractValidateCodeProcessor implements ValidateCodeProcessor { 21 | 22 | /** 23 | * 收集系统中所有的 {@link ValidateCodeGenerator} 接口的实现。 24 | */ 25 | @Autowired 26 | private Map validateCodeGenerators; 27 | 28 | @Autowired 29 | private ValidateCodeRepository validateCodeRepository; 30 | 31 | 32 | 33 | @Override 34 | public void create(ServletWebRequest request) throws Exception { 35 | C validateCode = generate(request); 36 | save(request, validateCode); 37 | send(request, validateCode); 38 | } 39 | 40 | /** 41 | * 生成校验码 42 | * 43 | * @param request 44 | * @return 45 | */ 46 | @SuppressWarnings("unchecked") 47 | private C generate(ServletWebRequest request) { 48 | String type = getValidateCodeType(request).toString().toLowerCase(); 49 | String generatorName = type + ValidateCodeGenerator.class.getSimpleName(); 50 | ValidateCodeGenerator validateCodeGenerator = validateCodeGenerators.get(generatorName); 51 | if (validateCodeGenerator == null) { 52 | throw new ValidateCodeException("验证码生成器" + generatorName + "不存在"); 53 | } 54 | return (C) validateCodeGenerator.generate(request); 55 | } 56 | 57 | /** 58 | * 保存校验码 59 | * 60 | * @param request 61 | * @param validateCode 62 | */ 63 | private void save(ServletWebRequest request, C validateCode) { 64 | ValidateCode code = new ValidateCode(validateCode.getCode(), validateCode.getExpireTime()); 65 | validateCodeRepository.save(request, code, getValidateCodeType(request)); 66 | } 67 | 68 | /** 69 | * 发送校验码,由子类实现 70 | * 71 | * @param request 72 | * @param validateCode 73 | * @throws Exception 74 | */ 75 | protected abstract void send(ServletWebRequest request, C validateCode) throws Exception; 76 | 77 | /** 78 | * 根据请求的url获取校验码的类型 79 | * 80 | * @param request 81 | * @return 82 | */ 83 | private ValidateCodeType getValidateCodeType(ServletWebRequest request) { 84 | String type = StringUtils.substringBefore(getClass().getSimpleName(), "CodeProcessor"); 85 | return ValidateCodeType.valueOf(type.toUpperCase()); 86 | } 87 | 88 | @SuppressWarnings("unchecked") 89 | @Override 90 | public void validate(ServletWebRequest request) { 91 | 92 | ValidateCodeType codeType = getValidateCodeType(request); 93 | 94 | C codeInSession = (C) validateCodeRepository.get(request, codeType); 95 | 96 | String codeInRequest; 97 | try { 98 | codeInRequest = ServletRequestUtils.getStringParameter(request.getRequest(), 99 | codeType.getParamNameOnValidate()); 100 | } catch (ServletRequestBindingException e) { 101 | throw new ValidateCodeException("获取验证码的值失败"); 102 | } 103 | 104 | if (StringUtils.isBlank(codeInRequest)) { 105 | throw new ValidateCodeException(codeType + "验证码的值不能为空"); 106 | } 107 | 108 | if (codeInSession == null) { 109 | throw new ValidateCodeException(codeType + "验证码不存在"); 110 | } 111 | 112 | if (codeInSession.isExpried()) { 113 | validateCodeRepository.remove(request, codeType); 114 | throw new ValidateCodeException(codeType + "验证码已过期"); 115 | } 116 | 117 | if (!StringUtils.equals(codeInSession.getCode(), codeInRequest)) { 118 | throw new ValidateCodeException(codeType + "验证码不匹配"); 119 | } 120 | 121 | validateCodeRepository.remove(request, codeType); 122 | 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/DefaultSmsCodeSender.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * 默认的短信验证码发送器 12 | * 13 | * @author lizhizhong 14 | * 15 | */ 16 | @Component("smsCodeSender") 17 | public class DefaultSmsCodeSender implements SmsCodeSender { 18 | 19 | private Logger logger = LoggerFactory.getLogger(getClass()); 20 | 21 | /** 22 | * 发送手机验证码的默认实现,后续决定使用哪一个短信平台之后重新实现该接口就可以了 23 | * @param mobile 24 | * @param code 25 | */ 26 | @Override 27 | public void send(String mobile, String code) { 28 | logger.warn("todo:请配置真实的短信验证码发送器(SmsCodeSender)"); 29 | logger.info("向手机 {} 发送短信验证码 {} 成功",mobile,code); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ImageCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import java.awt.image.BufferedImage; 7 | import java.time.LocalDateTime; 8 | 9 | 10 | /** 11 | * 图片验证码 12 | * @author lizhizhong 13 | * 14 | */ 15 | public class ImageCode extends ValidateCode { 16 | 17 | /** 18 | * 19 | */ 20 | private static final long serialVersionUID = -6020470039852318468L; 21 | 22 | private BufferedImage image; 23 | 24 | public ImageCode(BufferedImage image, String code, int expireIn){ 25 | super(code, expireIn); 26 | this.image = image; 27 | } 28 | 29 | public ImageCode(BufferedImage image, String code, LocalDateTime expireTime){ 30 | super(code, expireTime); 31 | this.image = image; 32 | } 33 | 34 | public BufferedImage getImage() { 35 | return image; 36 | } 37 | 38 | public void setImage(BufferedImage image) { 39 | this.image = image; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ImageCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.bind.ServletRequestUtils; 9 | import org.springframework.web.context.request.ServletWebRequest; 10 | 11 | import java.awt.*; 12 | import java.awt.image.BufferedImage; 13 | import java.util.Random; 14 | 15 | /** 16 | * 默认的图片验证码生成器 17 | * @author lizhizhong 18 | * 19 | */ 20 | @Component("imageValidateCodeGenerator") 21 | public class ImageCodeGenerator implements ValidateCodeGenerator { 22 | 23 | /** 24 | * 系统配置 25 | */ 26 | @Autowired 27 | private SecurityProperties securityProperties; 28 | 29 | /** 30 | * 生成图片验证码 31 | * @param request 32 | * @return 33 | */ 34 | @Override 35 | public ImageCode generate(ServletWebRequest request) { 36 | int width = ServletRequestUtils.getIntParameter(request.getRequest(), "width", 37 | securityProperties.getCode().getImage().getWidth()); 38 | int height = ServletRequestUtils.getIntParameter(request.getRequest(), "height", 39 | securityProperties.getCode().getImage().getHeight()); 40 | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 41 | 42 | Graphics g = image.getGraphics(); 43 | 44 | Random random = new Random(); 45 | 46 | g.setColor(getRandColor(200, 250)); 47 | g.fillRect(0, 0, width, height); 48 | g.setFont(new Font("Times New Roman", Font.ITALIC, 20)); 49 | g.setColor(getRandColor(160, 200)); 50 | for (int i = 0; i < 155; i++) { 51 | int x = random.nextInt(width); 52 | int y = random.nextInt(height); 53 | int xl = random.nextInt(12); 54 | int yl = random.nextInt(12); 55 | g.drawLine(x, y, x + xl, y + yl); 56 | } 57 | 58 | String sRand = ""; 59 | for (int i = 0; i < securityProperties.getCode().getImage().getLength(); i++) { 60 | String rand = String.valueOf(random.nextInt(10)); 61 | sRand += rand; 62 | g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); 63 | g.drawString(rand, 13 * i + 6, 16); 64 | } 65 | 66 | g.dispose(); 67 | 68 | return new ImageCode(image, sRand, securityProperties.getCode().getImage().getExpireIn()); 69 | } 70 | 71 | /** 72 | * 生成随机背景条纹 73 | * 74 | * @param fc 75 | * @param bc 76 | * @return 77 | */ 78 | private Color getRandColor(int fc, int bc) { 79 | Random random = new Random(); 80 | if (fc > 255) { 81 | fc = 255; 82 | } 83 | if (bc > 255) { 84 | bc = 255; 85 | } 86 | int r = fc + random.nextInt(bc - fc); 87 | int g = fc + random.nextInt(bc - fc); 88 | int b = fc + random.nextInt(bc - fc); 89 | return new Color(r, g, b); 90 | } 91 | 92 | public SecurityProperties getSecurityProperties() { 93 | return securityProperties; 94 | } 95 | 96 | public void setSecurityProperties(SecurityProperties securityProperties) { 97 | this.securityProperties = securityProperties; 98 | } 99 | 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ImageCodeProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.context.request.ServletWebRequest; 8 | 9 | import javax.imageio.ImageIO; 10 | 11 | /** 12 | * 图片验证码处理器 13 | * 14 | * @author lizhizhong 15 | * 16 | */ 17 | @Component("imageValidateCodeProcessor") 18 | public class ImageCodeProcessor extends AbstractValidateCodeProcessor { 19 | 20 | /** 21 | * 发送图形验证码,将其写到响应中 22 | */ 23 | @Override 24 | protected void send(ServletWebRequest request, ImageCode imageCode) throws Exception { 25 | ImageIO.write(imageCode.getImage(), "JPEG", request.getResponse().getOutputStream()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ImageCodeProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import lombok.Data; 7 | 8 | /** 9 | * 图片验证码配置项 10 | * 11 | * @author lizhizhong 12 | * 13 | */ 14 | @Data 15 | public class ImageCodeProperties extends SmsCodeProperties { 16 | 17 | public ImageCodeProperties() { 18 | setLength(4); 19 | } 20 | 21 | /** 22 | * 图片宽 23 | */ 24 | private int width = 67; 25 | /** 26 | * 图片高 27 | */ 28 | private int height = 23; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SecurityProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | 8 | /** 9 | * 验证码属性的配置项 10 | * @author lizhizhong 11 | * 12 | */ 13 | @ConfigurationProperties(prefix = "imooc.security") 14 | public class SecurityProperties { 15 | 16 | /** 17 | * 验证码配置 18 | */ 19 | private ValidateCodeProperties code = new ValidateCodeProperties(); 20 | 21 | public ValidateCodeProperties getCode() { 22 | return code; 23 | } 24 | 25 | public void setCode(ValidateCodeProperties code) { 26 | this.code = code; 27 | } 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SessionProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.zeus.common.SecurityConstants; 7 | 8 | /** 9 | * session管理相关配置项 10 | * 11 | * @author lizhizhong 12 | * 13 | */ 14 | public class SessionProperties { 15 | 16 | /** 17 | * 同一个用户在系统中的最大session数,默认1 18 | */ 19 | private int maximumSessions = 3; 20 | /** 21 | * 达到最大session时是否阻止新的登录请求,默认为false,不阻止,新的登录会将老的登录失效掉 22 | */ 23 | private boolean maxSessionsPreventsLogin; 24 | /** 25 | * session失效时跳转的地址 26 | */ 27 | private String sessionInvalidUrl = SecurityConstants.DEFAULT_SESSION_INVALID_URL; 28 | 29 | public int getMaximumSessions() { 30 | return maximumSessions; 31 | } 32 | 33 | public void setMaximumSessions(int maximumSessions) { 34 | this.maximumSessions = maximumSessions; 35 | } 36 | 37 | public boolean isMaxSessionsPreventsLogin() { 38 | return maxSessionsPreventsLogin; 39 | } 40 | 41 | public void setMaxSessionsPreventsLogin(boolean maxSessionsPreventsLogin) { 42 | this.maxSessionsPreventsLogin = maxSessionsPreventsLogin; 43 | } 44 | 45 | public String getSessionInvalidUrl() { 46 | return sessionInvalidUrl; 47 | } 48 | 49 | public void setSessionInvalidUrl(String sessionInvalidUrl) { 50 | this.sessionInvalidUrl = sessionInvalidUrl; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SessionValidateCodeRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.social.connect.web.HttpSessionSessionStrategy; 7 | import org.springframework.social.connect.web.SessionStrategy; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.context.request.ServletWebRequest; 10 | 11 | /** 12 | * 基于session的验证码存取器 13 | * 如果后续需要把验证码放到redis里面,重新实现validateCodeRepository就ok了 14 | * 15 | * @author lizhizhong 16 | * 17 | */ 18 | @Component 19 | public class SessionValidateCodeRepository implements ValidateCodeRepository { 20 | 21 | /** 22 | * 验证码放入session时的前缀 23 | */ 24 | String SESSION_KEY_PREFIX = "SESSION_KEY_FOR_CODE_"; 25 | 26 | /** 27 | * 操作session的工具类 28 | */ 29 | private SessionStrategy sessionStrategy = new HttpSessionSessionStrategy(); 30 | 31 | /** 32 | * 把验证码存储到session 33 | * @param request 34 | * @param code 35 | * @param validateCodeType 36 | */ 37 | @Override 38 | public void save(ServletWebRequest request, ValidateCode code, ValidateCodeType validateCodeType) { 39 | sessionStrategy.setAttribute(request, getSessionKey(request, validateCodeType), code); 40 | } 41 | 42 | /** 43 | * 构建验证码放入session时的key 44 | * 45 | * @param request 46 | * @return 47 | */ 48 | private String getSessionKey(ServletWebRequest request, ValidateCodeType validateCodeType) { 49 | return SESSION_KEY_PREFIX + validateCodeType.toString().toUpperCase(); 50 | } 51 | 52 | /** 53 | * 获取验证码 54 | * @param request 55 | * @param validateCodeType 56 | * @return 57 | */ 58 | @Override 59 | public ValidateCode get(ServletWebRequest request, ValidateCodeType validateCodeType) { 60 | return (ValidateCode) sessionStrategy.getAttribute(request, getSessionKey(request, validateCodeType)); 61 | } 62 | 63 | /** 64 | * 移除验证码 65 | * @param request 66 | * @param codeType 67 | */ 68 | @Override 69 | public void remove(ServletWebRequest request, ValidateCodeType codeType) { 70 | sessionStrategy.removeAttribute(request, getSessionKey(request, codeType)); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SmsCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.apache.commons.lang3.RandomStringUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.context.request.ServletWebRequest; 10 | 11 | /** 12 | * 短信验证码生成器 13 | * 14 | * @author zhailiang 15 | * 16 | */ 17 | @Component("smsValidateCodeGenerator") 18 | public class SmsCodeGenerator implements ValidateCodeGenerator { 19 | 20 | @Autowired 21 | private SecurityProperties securityProperties; 22 | 23 | /* 24 | * (non-Javadoc) 25 | * 26 | * @see 27 | * com.imooc.security.core.validate.code.ValidateCodeGenerator#generate(org. 28 | * springframework.web.context.request.ServletWebRequest) 29 | */ 30 | @Override 31 | public ValidateCode generate(ServletWebRequest request) { 32 | String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength()); 33 | return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn()); 34 | } 35 | 36 | public SecurityProperties getSecurityProperties() { 37 | return securityProperties; 38 | } 39 | 40 | public void setSecurityProperties(SecurityProperties securityProperties) { 41 | this.securityProperties = securityProperties; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SmsCodeProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.bind.ServletRequestUtils; 9 | import org.springframework.web.context.request.ServletWebRequest; 10 | import org.zeus.common.SecurityConstants; 11 | 12 | /** 13 | * 短信验证码处理器 14 | * 15 | * @author zhailiang 16 | * 17 | */ 18 | @Component("smsValidateCodeProcessor") 19 | public class SmsCodeProcessor extends AbstractValidateCodeProcessor { 20 | 21 | /** 22 | * 短信验证码发送器 23 | */ 24 | @Autowired 25 | private SmsCodeSender smsCodeSender; 26 | 27 | @Override 28 | protected void send(ServletWebRequest request, ValidateCode validateCode) throws Exception { 29 | String paramName = SecurityConstants.DEFAULT_PARAMETER_NAME_MOBILE; 30 | String mobile = ServletRequestUtils.getRequiredStringParameter(request.getRequest(), paramName); 31 | smsCodeSender.send(mobile, validateCode.getCode()); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SmsCodeProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import lombok.Data; 7 | 8 | /** 9 | * 短信验证码配置项 10 | * @author lizhizhong 11 | * 12 | */ 13 | @Data 14 | public class SmsCodeProperties { 15 | 16 | /** 17 | * 验证码长度 18 | */ 19 | private int length = 6; 20 | /** 21 | * 过期时间 22 | */ 23 | private int expireIn = 60; 24 | /** 25 | * 要拦截的url,多个url用逗号隔开,ant pattern 26 | */ 27 | private String url; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/SmsCodeSender.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | /** 7 | * @author lizhizhong 8 | * 9 | */ 10 | public interface SmsCodeSender { 11 | 12 | /** 13 | * @param mobile 14 | * @param code 15 | */ 16 | void send(String mobile, String code); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import java.io.Serializable; 7 | import java.time.LocalDateTime; 8 | 9 | 10 | /** 11 | * 验证码信息封装类 12 | * 13 | * @author zhailiang 14 | * 15 | */ 16 | public class ValidateCode implements Serializable { 17 | 18 | /** 19 | * 20 | */ 21 | private static final long serialVersionUID = 1588203828504660915L; 22 | 23 | private String code; 24 | 25 | private LocalDateTime expireTime; 26 | 27 | public ValidateCode(String code, int expireIn){ 28 | this.code = code; 29 | this.expireTime = LocalDateTime.now().plusSeconds(expireIn); 30 | } 31 | 32 | public ValidateCode(String code, LocalDateTime expireTime){ 33 | this.code = code; 34 | this.expireTime = expireTime; 35 | } 36 | 37 | public boolean isExpried() { 38 | return LocalDateTime.now().isAfter(expireTime); 39 | } 40 | 41 | public String getCode() { 42 | return code; 43 | } 44 | 45 | public void setCode(String code) { 46 | this.code = code; 47 | } 48 | 49 | public LocalDateTime getExpireTime() { 50 | return expireTime; 51 | } 52 | 53 | public void setExpireTime(LocalDateTime expireTime) { 54 | this.expireTime = expireTime; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.security.core.AuthenticationException; 7 | 8 | /** 9 | * 验证码验证异常 10 | * @author lizhizhong 11 | * 12 | */ 13 | public class ValidateCodeException extends AuthenticationException { 14 | 15 | /** 16 | * 17 | */ 18 | private static final long serialVersionUID = -7285211528095468156L; 19 | 20 | public ValidateCodeException(String msg) { 21 | super(msg); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.beans.factory.InitializingBean; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.AntPathMatcher; 11 | import org.springframework.web.context.request.ServletWebRequest; 12 | import org.springframework.web.filter.OncePerRequestFilter; 13 | import org.zeus.common.CustomAuthenticationFailureHandler; 14 | import org.zeus.common.SecurityConstants; 15 | 16 | import javax.servlet.FilterChain; 17 | import javax.servlet.ServletException; 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.servlet.http.HttpServletResponse; 20 | import java.io.IOException; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | /** 26 | * 校验验证码的过滤器 27 | * 28 | * @author zhailiang 29 | * 30 | */ 31 | @Component("validateCodeFilter") 32 | public class ValidateCodeFilter extends OncePerRequestFilter implements InitializingBean { 33 | 34 | /** 35 | * 验证码校验失败处理器 36 | */ 37 | @Autowired 38 | private CustomAuthenticationFailureHandler authenticationFailureHandler; 39 | /** 40 | * 系统配置信息 41 | */ 42 | @Autowired 43 | private SecurityProperties securityProperties; 44 | /** 45 | * 系统中的校验码处理器 46 | */ 47 | @Autowired 48 | private ValidateCodeProcessorHolder validateCodeProcessorHolder; 49 | /** 50 | * 存放所有需要校验验证码的url 51 | */ 52 | private Map urlMap = new HashMap<>(); 53 | /** 54 | * 验证请求url与配置的url是否匹配的工具类 55 | */ 56 | private AntPathMatcher pathMatcher = new AntPathMatcher(); 57 | 58 | /** 59 | * 初始化要拦截的url配置信息 60 | */ 61 | @Override 62 | public void afterPropertiesSet() throws ServletException { 63 | super.afterPropertiesSet(); 64 | 65 | urlMap.put(SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_FORM, ValidateCodeType.IMAGE); 66 | addUrlToMap(securityProperties.getCode().getImage().getUrl(), ValidateCodeType.IMAGE); 67 | 68 | urlMap.put(SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_MOBILE, ValidateCodeType.SMS); 69 | addUrlToMap(securityProperties.getCode().getSms().getUrl(), ValidateCodeType.SMS); 70 | } 71 | 72 | /** 73 | * 讲系统中配置的需要校验验证码的URL根据校验的类型放入map 74 | * 75 | * @param urlString 76 | * @param type 77 | */ 78 | protected void addUrlToMap(String urlString, ValidateCodeType type) { 79 | if (StringUtils.isNotBlank(urlString)) { 80 | String[] urls = StringUtils.splitByWholeSeparatorPreserveAllTokens(urlString, ","); 81 | for (String url : urls) { 82 | urlMap.put(url, type); 83 | } 84 | } 85 | } 86 | 87 | 88 | @Override 89 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 90 | throws ServletException, IOException { 91 | 92 | ValidateCodeType type = getValidateCodeType(request); 93 | if (type != null) { 94 | logger.info("校验请求(" + request.getRequestURI() + ")中的验证码,验证码类型" + type); 95 | try { 96 | ValidateCodeProcessor validateCodeProcessor = validateCodeProcessorHolder.findValidateCodeProcessor(type); 97 | 98 | validateCodeProcessor.validate(new ServletWebRequest(request, response)); 99 | logger.info("验证码校验通过"); 100 | } catch (ValidateCodeException exception) { 101 | authenticationFailureHandler.onAuthenticationFailure(request, response, exception); 102 | return; 103 | } 104 | } 105 | 106 | chain.doFilter(request, response); 107 | 108 | } 109 | 110 | /** 111 | * 获取校验码的类型,如果当前请求不需要校验,则返回null 112 | * 113 | * @param request 114 | * @return 115 | */ 116 | private ValidateCodeType getValidateCodeType(HttpServletRequest request) { 117 | ValidateCodeType result = null; 118 | if (!StringUtils.equalsIgnoreCase(request.getMethod(), "get")) { 119 | Set urls = urlMap.keySet(); 120 | for (String url : urls) { 121 | if (pathMatcher.match(url, request.getRequestURI())) { 122 | result = urlMap.get(url); 123 | } 124 | } 125 | } 126 | return result; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.web.context.request.ServletWebRequest; 7 | 8 | /** 9 | * 校验码生成器 10 | * @author zhailiang 11 | * 12 | */ 13 | public interface ValidateCodeGenerator { 14 | 15 | /** 16 | * 生成校验码 17 | * @param request 18 | * @return 19 | */ 20 | ValidateCode generate(ServletWebRequest request); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.web.context.request.ServletWebRequest; 7 | 8 | /** 9 | * 校验码处理器,封装不同校验码的处理逻辑 10 | * 11 | * @author zhailiang 12 | * 13 | */ 14 | public interface ValidateCodeProcessor { 15 | 16 | /** 17 | * 创建校验码 18 | * 19 | * @param request 20 | * @throws Exception 21 | */ 22 | void create(ServletWebRequest request) throws Exception; 23 | 24 | /** 25 | * 校验验证码 26 | * 27 | * @param servletWebRequest 28 | * @throws Exception 29 | */ 30 | void validate(ServletWebRequest servletWebRequest); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeProcessorHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * 校验码处理器管理器 13 | * 14 | * @author lizhizhong 15 | * 16 | */ 17 | @Component 18 | public class ValidateCodeProcessorHolder { 19 | 20 | @Autowired 21 | private Map validateCodeProcessors; 22 | 23 | /** 24 | * @param type 25 | * @return 26 | */ 27 | public ValidateCodeProcessor findValidateCodeProcessor(ValidateCodeType type) { 28 | return findValidateCodeProcessor(type.toString().toLowerCase()); 29 | } 30 | 31 | /** 32 | * @param type 33 | * @return 34 | */ 35 | public ValidateCodeProcessor findValidateCodeProcessor(String type) { 36 | String name = type.toLowerCase() + ValidateCodeProcessor.class.getSimpleName(); 37 | ValidateCodeProcessor processor = validateCodeProcessors.get(name); 38 | if (processor == null) { 39 | throw new ValidateCodeException("验证码处理器" + name + "不存在"); 40 | } 41 | return processor; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | /** 7 | * 验证码配置 8 | * @author lizhizhong 9 | * 10 | */ 11 | public class ValidateCodeProperties { 12 | 13 | /** 14 | * 图片验证码配置 15 | */ 16 | private ImageCodeProperties image = new ImageCodeProperties(); 17 | /** 18 | * 短信验证码配置 19 | */ 20 | private SmsCodeProperties sms = new SmsCodeProperties(); 21 | 22 | public ImageCodeProperties getImage() { 23 | return image; 24 | } 25 | 26 | public void setImage(ImageCodeProperties image) { 27 | this.image = image; 28 | } 29 | 30 | public SmsCodeProperties getSms() { 31 | return sms; 32 | } 33 | 34 | public void setSms(SmsCodeProperties sms) { 35 | this.sms = sms; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | import org.springframework.web.context.request.ServletWebRequest; 7 | 8 | /** 9 | * 校验码存取器 10 | * 11 | * @author zhailiang 12 | * 13 | */ 14 | public interface ValidateCodeRepository { 15 | 16 | /** 17 | * 保存验证码 18 | * @param request 19 | * @param code 20 | * @param validateCodeType 21 | */ 22 | void save(ServletWebRequest request, ValidateCode code, ValidateCodeType validateCodeType); 23 | /** 24 | * 获取验证码 25 | * @param request 26 | * @param validateCodeType 27 | * @return 28 | */ 29 | ValidateCode get(ServletWebRequest request, ValidateCodeType validateCodeType); 30 | /** 31 | * 移除验证码 32 | * @param request 33 | * @param codeType 34 | */ 35 | void remove(ServletWebRequest request, ValidateCodeType codeType); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus.common.validator; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.config.annotation.SecurityConfigurerAdapter; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.web.DefaultSecurityFilterChain; 7 | import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.servlet.Filter; 11 | 12 | /** 13 | * 校验码相关安全配置 14 | * 15 | * @author zhailiang 16 | * 17 | */ 18 | @Component("validateCodeSecurityConfig") 19 | public class ValidateCodeSecurityConfig extends SecurityConfigurerAdapter { 20 | 21 | @Autowired 22 | private Filter validateCodeFilter; 23 | 24 | @Override 25 | public void configure(HttpSecurity http) throws Exception { 26 | http.addFilterBefore(validateCodeFilter, AbstractPreAuthenticatedProcessingFilter.class); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/common/validator/ValidateCodeType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.common.validator; 5 | 6 | 7 | import org.zeus.common.SecurityConstants; 8 | 9 | /** 10 | * 11 | * 校验码类型 12 | * 13 | * @author zhailiang 14 | * 15 | */ 16 | public enum ValidateCodeType { 17 | 18 | /** 19 | * 短信验证码 20 | */ 21 | SMS { 22 | @Override 23 | public String getParamNameOnValidate() { 24 | return SecurityConstants.DEFAULT_PARAMETER_NAME_CODE_SMS; 25 | } 26 | }, 27 | /** 28 | * 图片验证码 29 | */ 30 | IMAGE { 31 | @Override 32 | public String getParamNameOnValidate() { 33 | return SecurityConstants.DEFAULT_PARAMETER_NAME_CODE_IMAGE; 34 | } 35 | }; 36 | 37 | /** 38 | * 校验时从请求中获取的参数的名字 39 | * @return 40 | */ 41 | public abstract String getParamNameOnValidate(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/AuthenticationAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.zeus.bean.RespBean; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.web.access.AccessDeniedHandler; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | /** 15 | * 用户权限不足的事件处理器 16 | * @author: lizhizhong 17 | * CreatedDate: 2018/12/29. 18 | */ 19 | @Component 20 | public class AuthenticationAccessDeniedHandler implements AccessDeniedHandler { 21 | @Override 22 | public void handle(HttpServletRequest httpServletRequest, HttpServletResponse resp, 23 | AccessDeniedException e) throws IOException { 24 | 25 | resp.setStatus(HttpServletResponse.SC_FORBIDDEN); 26 | resp.setContentType("application/json;charset=UTF-8"); 27 | PrintWriter out = resp.getWriter(); 28 | RespBean error = RespBean.error("权限不足,请联系管理员!"); 29 | 30 | out.write(new ObjectMapper().writeValueAsString(error)); 31 | out.flush(); 32 | out.close(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/CrossOriginConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import org.zeus.common.LogTrackInterceptor; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.cors.CorsConfiguration; 8 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 9 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 11 | 12 | /** 13 | * @author: lizhizhong 14 | * CreatedDate: 2018/11/30. 15 | */ 16 | @Configuration 17 | public class CrossOriginConfig implements WebMvcConfigurer { 18 | 19 | @Autowired 20 | private LogTrackInterceptor logInterceptor; 21 | 22 | @Override 23 | public void addInterceptors(InterceptorRegistry registry) { 24 | registry.addInterceptor(logInterceptor); 25 | } 26 | 27 | 28 | // During development, webpack server runs on localhost:8080 29 | // Make the browser happy by returning CORS headers in this case 30 | @Bean 31 | // @Profile("dev") 32 | public WebMvcConfigurer corsConfigurer() { 33 | return new WebMvcConfigurer() { 34 | @Override 35 | public void addCorsMappings(CorsRegistry registry) { 36 | registry.addMapping("/**") 37 | .allowedOrigins(CorsConfiguration.ALL) 38 | .allowedHeaders(CorsConfiguration.ALL) 39 | .allowedMethods(CorsConfiguration.ALL) 40 | .allowCredentials(true); 41 | } 42 | }; 43 | } 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/CustomMetadataSource.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import org.zeus.bean.Menu; 4 | import org.zeus.bean.Role; 5 | import org.zeus.service.MenuService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.access.ConfigAttribute; 8 | import org.springframework.security.access.SecurityConfig; 9 | import org.springframework.security.web.FilterInvocation; 10 | import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource; 11 | import org.springframework.stereotype.Component; 12 | import org.springframework.util.AntPathMatcher; 13 | 14 | import java.util.Collection; 15 | import java.util.List; 16 | 17 | /** 18 | * 储存请求和权限的对应关系 19 | * @author: lizhizhong 20 | * CreatedDate: 2018/12/28. 21 | */ 22 | @Component 23 | public class CustomMetadataSource implements FilterInvocationSecurityMetadataSource { 24 | @Autowired 25 | MenuService menuService; 26 | AntPathMatcher antPathMatcher = new AntPathMatcher(); 27 | @Override 28 | public Collection getAttributes(Object o) { 29 | String requestUrl = ((FilterInvocation) o).getRequestUrl(); 30 | List

allMenu = menuService.getAllMenu(); 31 | for (Menu menu : allMenu) { 32 | if (antPathMatcher.match(menu.getUrl(), requestUrl) 33 | &&menu.getRoles().size()>0) { 34 | List roles = menu.getRoles(); 35 | int size = roles.size(); 36 | String[] values = new String[size]; 37 | for (int i = 0; i < size; i++) { 38 | values[i] = roles.get(i).getName(); 39 | } 40 | return SecurityConfig.createList(values); 41 | } 42 | } 43 | //没有匹配上的资源,都是登录访问 44 | return SecurityConfig.createList("ROLE_LOGIN"); 45 | } 46 | @Override 47 | public Collection getAllConfigAttributes() { 48 | return null; 49 | } 50 | 51 | @Override 52 | public boolean supports(Class aClass) { 53 | return FilterInvocation.class.isAssignableFrom(aClass); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/DataSourceContextHolder.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | 4 | /** 5 | * 数据源切换 6 | * 7 | * @author 8 | * 9 | */ 10 | 11 | public class DataSourceContextHolder { 12 | private static final ThreadLocal contextHolder = new ThreadLocal(); 13 | 14 | public static synchronized void setDBType(String dbType){ 15 | contextHolder.set(dbType); 16 | } 17 | 18 | public static String getDBType(){ 19 | return contextHolder.get(); 20 | } 21 | 22 | public static void clearDBType(){ 23 | contextHolder.remove(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/DynamicDataSource.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | 8 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 9 | 10 | 11 | /** 12 | * 数据源 13 | * @author 14 | */ 15 | public class DynamicDataSource extends AbstractRoutingDataSource { 16 | private static DynamicDataSource instance; 17 | private static byte[] lock=new byte[0]; 18 | private static Map dataSourceMap=new HashMap(); 19 | 20 | @Override 21 | public void setTargetDataSources(Map targetDataSources) { 22 | super.setTargetDataSources(targetDataSources); 23 | dataSourceMap.putAll(targetDataSources); 24 | super.afterPropertiesSet();// 必须添加该句,否则新添加数据源无法识别到 25 | } 26 | 27 | public Map getDataSourceMap() { 28 | return dataSourceMap; 29 | } 30 | 31 | public static synchronized DynamicDataSource getInstance(){ 32 | if(instance==null){ 33 | synchronized (lock){ 34 | if(instance==null){ 35 | instance=new DynamicDataSource(); 36 | } 37 | } 38 | } 39 | return instance; 40 | } 41 | //必须实现其方法 42 | protected Object determineCurrentLookupKey() { 43 | return DataSourceContextHolder.getDBType(); 44 | } 45 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 5 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 6 | /** 7 | * swagger 8 | * @author: lizhizhong 9 | * CreatedDate: 2018/12/21. 10 | */ 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig implements WebMvcConfigurer { 14 | 15 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/UrlAccessDecisionManager.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.security.access.AccessDecisionManager; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.access.ConfigAttribute; 7 | import org.springframework.security.authentication.AnonymousAuthenticationToken; 8 | import org.springframework.security.authentication.BadCredentialsException; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.GrantedAuthority; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.util.Collection; 14 | import java.util.Iterator; 15 | 16 | /** 17 | * 自定义实现投票器实现用户鉴权 18 | * @author: lizhizhong 19 | * CreatedDate: 2018/11/30. 20 | */ 21 | @Component 22 | @Slf4j 23 | public class UrlAccessDecisionManager implements AccessDecisionManager { 24 | @Override 25 | public void decide(Authentication auth, Object o, Collection cas){ 26 | Iterator iterator = cas.iterator(); 27 | while (iterator.hasNext()) { 28 | ConfigAttribute ca = iterator.next(); 29 | //当前请求需要的权限 30 | String needRole = ca.getAttribute(); 31 | if ("ROLE_LOGIN".equals(needRole)) { 32 | if (auth instanceof AnonymousAuthenticationToken) { 33 | throw new BadCredentialsException("未登录"); 34 | } else { 35 | return; 36 | } 37 | } 38 | //当前用户所具有的权限 39 | Collection authorities = auth.getAuthorities(); 40 | for (GrantedAuthority authority : authorities) { 41 | if (authority.getAuthority().equals(needRole)) { 42 | return; 43 | } 44 | } 45 | } 46 | throw new AccessDeniedException("权限不足!"); 47 | } 48 | @Override 49 | public boolean supports(ConfigAttribute configAttribute) { 50 | return true; 51 | } 52 | @Override 53 | public boolean supports(Class aClass) { 54 | return true; 55 | } 56 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package org.zeus.config; 2 | 3 | import org.zeus.common.DateConverter; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.format.FormatterRegistry; 7 | import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; 8 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 9 | 10 | import java.util.concurrent.ExecutorService; 11 | import java.util.concurrent.Executors; 12 | 13 | /** 14 | * 通用Bean注册 15 | * @author: lizhizhong 16 | * CreatedDate: 2018/11/26. 17 | */ 18 | @Configuration 19 | public class WebMvcConfig implements WebMvcConfigurer { 20 | @Override 21 | public void addFormatters(FormatterRegistry registry) { 22 | registry.addConverter(new DateConverter()); 23 | } 24 | 25 | @Bean 26 | public ExecutorService executorService() { 27 | return Executors.newCachedThreadPool(); 28 | } 29 | 30 | /** 31 | * 权限重置Mapper 32 | * @return 简单权限映射器 33 | */ 34 | @Bean 35 | public SimpleAuthorityMapper simpleAuthorityMapper(){ 36 | return new SimpleAuthorityMapper(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/controller/ConfigController.java: -------------------------------------------------------------------------------- 1 | package org.zeus.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.zeus.bean.Menu; 7 | import org.zeus.common.UserUtils; 8 | import org.zeus.common.fw.LogType; 9 | import org.zeus.common.fw.annotation.SystemLog; 10 | import org.zeus.service.MenuService; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * 这是一个只要登录就能访问的Controller 20 | * 主要用来获取一些配置信息 21 | * @author: lizhizhong 22 | * CreatedDate: 2018/11/28. 23 | */ 24 | 25 | @RestController 26 | @Api(value="配置controller",tags = {"获取当前菜单项接口"}) 27 | @RequestMapping("/config") 28 | @Slf4j 29 | public class ConfigController { 30 | @Autowired 31 | MenuService menuService; 32 | 33 | /** 34 | * 获取当前用户可访问的菜单选项 35 | * @return 菜单 36 | */ 37 | @GetMapping("/sysmenu") 38 | @ApiOperation(value="得到菜单项",notes = "根据当前用户得到该用户所拥有的菜单项") 39 | public List sysmenu() { 40 | return menuService.getMenusByUserId(); 41 | } 42 | 43 | /** 44 | * 根据用户所选定的角色重新获得该角色所拥有的菜单权限 45 | * @return 菜单项 46 | */ 47 | @GetMapping("/regetMenu") 48 | @ApiOperation(value="重新获得被选定角色的菜单项",notes = "重新获得被选定角色的菜单项") 49 | @SystemLog(type = LogType.AUDITING,description = "获取系统菜单") 50 | public List getsyMenu(){ 51 | 52 | Long rid = UserUtils.getCurrentUser().getRoles().get(0).getId(); 53 | String rzh = UserUtils.getCurrentUser().getRoles().get(0).getName(); 54 | log.info("选择用户角色为{},id为:{},该角色拥有的菜单权限为",rzh,rid); 55 | 56 | return menuService.getMemusInfoByRid(rid); 57 | 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/controller/RegLoginController.java: -------------------------------------------------------------------------------- 1 | package org.zeus.controller; 2 | 3 | import org.zeus.bean.RespBean; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.ResponseStatus; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * Created by lizhizhong on 2018/11/29. 11 | */ 12 | @RestController 13 | public class RegLoginController { 14 | 15 | @GetMapping("/login_p") 16 | @ResponseStatus(HttpStatus.UNAUTHORIZED) 17 | public RespBean login() { 18 | return RespBean.error("尚未登录,请登录!"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/controller/ValidateCodeController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.zeus.controller; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.context.request.ServletWebRequest; 12 | import org.zeus.common.SecurityConstants; 13 | import org.zeus.common.validator.ValidateCodeProcessorHolder; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | 18 | /** 19 | * 生成校验码的请求处理器 20 | * 21 | * @author zhailiang 22 | * 23 | */ 24 | @RestController 25 | public class ValidateCodeController { 26 | 27 | @Autowired 28 | private ValidateCodeProcessorHolder validateCodeProcessorHolder; 29 | 30 | /** 31 | * 创建验证码,根据验证码类型不同,调用不同的 {@link }接口实现 32 | * 33 | * @param request 34 | * @param response 35 | * @param type 36 | * @throws Exception 37 | */ 38 | @PostMapping(SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{type}") 39 | public void createCode(HttpServletRequest request, HttpServletResponse response, @PathVariable String type) 40 | throws Exception { 41 | validateCodeProcessorHolder.findValidateCodeProcessor(type).create(new ServletWebRequest(request, response)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/controller/system/SystemController.java: -------------------------------------------------------------------------------- 1 | package org.zeus.controller.system; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiImplicitParam; 5 | import io.swagger.annotations.ApiImplicitParams; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.zeus.bean.RespBean; 8 | import org.zeus.service.UserService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PutMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | /** 15 | * Created by lizhizhong on 2018/11/22. 16 | */ 17 | @RestController 18 | @Api(value="用户管理controller",tags = {"用户管理相关接口"}) 19 | @RequestMapping("/system/user") 20 | public class SystemController { 21 | @Autowired 22 | UserService userService; 23 | 24 | 25 | @ApiOperation(value = "更新用户角色",notes="更新用户角色") 26 | @ApiImplicitParams({ 27 | @ApiImplicitParam(dataType = "Long", name = "userId", value = "用户id"), 28 | @ApiImplicitParam(dataType = "Long[]", name = "rids", value = "角色id数组")}) 29 | @PutMapping(value = "/roles") 30 | public RespBean updateUserRoles(Long userId, Long[] rids) { 31 | if (userService.updateHrRoles(userId, rids) == rids.length) { 32 | return RespBean.ok("角色更新成功!"); 33 | } 34 | return RespBean.error("角色更新失败!"); 35 | } 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/controller/system/SystemUserController.java: -------------------------------------------------------------------------------- 1 | package org.zeus.controller.system; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.zeus.bean.User; 7 | import org.zeus.bean.UserExample; 8 | import org.zeus.common.ServerResponse; 9 | import org.zeus.common.UserUtils; 10 | import org.zeus.common.fw.LogType; 11 | import org.zeus.common.fw.annotation.SystemLog; 12 | import org.zeus.dmsMapper.UserMapper; 13 | import org.zeus.dto.PassWordResetResource; 14 | import org.zeus.dto.UserInfoUpdateForm; 15 | import org.zeus.dto.UserRegister; 16 | import org.zeus.service.*; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 19 | import org.springframework.validation.BindingResult; 20 | import org.springframework.validation.annotation.Validated; 21 | import org.springframework.web.bind.annotation.*; 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * 系统基本设置 27 | * @author: lizhizhong 28 | * CreatedDate: 2018/11/26. 29 | */ 30 | @RestController 31 | @Api(value="user基本信息controller",tags={"user基本信息controller"}) 32 | @RequestMapping("/system/basic") 33 | @Slf4j 34 | public class SystemUserController { 35 | @Autowired 36 | RoleService roleService; 37 | @Autowired 38 | MenuService menuService; 39 | @Autowired 40 | MenuRoleService menuRoleService; 41 | 42 | @Autowired 43 | BCryptPasswordEncoder bCryptPasswordEncoder; 44 | 45 | /**切换用户选择的角色**/ 46 | @Autowired 47 | RestAuthentication restAuthentication; 48 | 49 | @Autowired 50 | private UserAndRoleService userAndRoleService; 51 | 52 | @Autowired 53 | UserMapper userMapper; 54 | 55 | 56 | 57 | /** 58 | * 添加新用户 59 | * @param user 60 | * @return 61 | */ 62 | @PostMapping("addUser") 63 | @ApiOperation(value = "添加新用户",notes = "添加新用户") 64 | public ServerResponse addUser(UserRegister user){ 65 | 66 | String encodePass = bCryptPasswordEncoder.encode(user.getPassword()); 67 | user.setPassword(encodePass); 68 | userAndRoleService.addNewUser(user); 69 | return ServerResponse.createBySuccess("用户添加成功!"); 70 | 71 | } 72 | 73 | /** 74 | * 获取用户列表 75 | * @return 76 | */ 77 | @ApiOperation(value = "得到所有用户",notes="得到系统中的用户列表") 78 | @GetMapping("users") 79 | @SystemLog(description="查询系统中的所有用户",type= LogType.OPERATION ) 80 | public ServerResponse> getAllUser(){ 81 | UserExample example = new UserExample(); 82 | List lists = userMapper.selectByExample(example); 83 | lists.forEach(o-> o.setRoles(userAndRoleService.getRolesByUserId(o.getId()))); 84 | 85 | return ServerResponse.createBySuccess(lists); 86 | } 87 | 88 | /** 89 | * 用户修改个人信息 90 | * @param userInfo 91 | * @return 92 | */ 93 | @ApiOperation(value = "修改个人信息",notes="用户个人修改信息") 94 | @PutMapping("userInfo") 95 | @SystemLog(description="修改个人信息",type= LogType.UPDATE ) 96 | public ServerResponse updateOwnUserInfo(UserInfoUpdateForm userInfo){ 97 | if(userInfo.isEmpty()){ 98 | return ServerResponse.createBySuccess("请填写需要修改的个人信息"); 99 | } 100 | return userAndRoleService.updateUserInfo(userInfo); 101 | } 102 | 103 | @ApiOperation(value = "修改密码",notes="用户修改个人密码") 104 | @PutMapping("passwordReset") 105 | @SystemLog(description="修改个人密码",type= LogType.UPDATE ) 106 | public ServerResponse passwordReset(@Validated(PassWordResetResource.PasswordChk.class) PassWordResetResource form, String oldPassword, 107 | BindingResult bindingResult){ 108 | if (bindingResult.hasErrors()) { 109 | log.info("传递参数有误:{}", bindingResult.getFieldError().getDefaultMessage()); 110 | return ServerResponse.createByError(bindingResult.getFieldError().getDefaultMessage()); 111 | } 112 | 113 | User user = userMapper.selectByPrimaryKey(UserUtils.getCurrentUser().getId().intValue()); 114 | if(bCryptPasswordEncoder.matches(oldPassword,user.getPassword())){ 115 | // 更新密码 116 | user.setPassword(bCryptPasswordEncoder.encode(form.getPassword())); 117 | // update 118 | userMapper.updateByPrimaryKey(user); 119 | return ServerResponse.createBySuccess("密码更新成功"); 120 | }else{ 121 | return ServerResponse.createByError("密码更新失败!"); 122 | } 123 | 124 | } 125 | 126 | 127 | 128 | 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/CommonMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.zeus.bean.Role; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by aichaellee on 2019/1/9. 10 | */ 11 | public interface CommonMapper { 12 | 13 | /** 14 | * 更新form表(数据库中以form开头的表) 15 | * @param sql 16 | * @return 17 | */ 18 | int updateExecute(String sql); 19 | 20 | /** 21 | * 查询form表 22 | * @param sql 23 | * @param 24 | * @return 25 | */ 26 | List select(String sql); 27 | 28 | /** 29 | * 新增form表中的数据 30 | * @param sql 31 | * @return 32 | */ 33 | int addExecute(String sql); 34 | } 35 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import org.zeus.bean.Menu; 4 | import org.zeus.dto.MenuUpdateForm; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by lizhizhong on 2018/11/28. 10 | */ 11 | public interface MenuMapper { 12 | List getAllMenu(); 13 | 14 | List getMenusByUserId(Long hrId); 15 | 16 | List menuTree(); 17 | 18 | List getMenusByRid(Long rid); 19 | 20 | List getMemusInfoByRid(Long rid); 21 | 22 | int updateMenuByMid(MenuUpdateForm menu); 23 | 24 | Menu getMenuByMid(Long id); 25 | } 26 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/MenuRoleMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | /** 6 | * Created by lizhizhong on 2018/12/2. 7 | */ 8 | public interface MenuRoleMapper { 9 | int deleteMenuByRid(@Param("rid") Long rid); 10 | 11 | int addMenu(@Param("rid") Long rid, @Param("mids") Long[] mids); 12 | 13 | int addDefaultMid(@Param("rid") Long rid); 14 | } 15 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import org.zeus.bean.Role; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by sang on 2018/1/1. 10 | */ 11 | public interface RoleMapper { 12 | List roles(); 13 | 14 | int addNewRole(@Param("role") String role, @Param("roleZh") String roleZh); 15 | 16 | int deleteRoleById(Long rid); 17 | 18 | List getRolesByUserId(Long userId); 19 | } 20 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/SysLogMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import java.util.List; 4 | import org.zeus.entity.SysLog; 5 | import org.zeus.entity.SysLogExample; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface SysLogMapper { 9 | int countByExample(SysLogExample example); 10 | 11 | int deleteByExample(SysLogExample example); 12 | 13 | int deleteByPrimaryKey(Integer logId); 14 | 15 | int insert(SysLog record); 16 | 17 | int insertSelective(SysLog record); 18 | 19 | List selectByExample(SysLogExample example); 20 | 21 | SysLog selectByPrimaryKey(Integer logId); 22 | 23 | int updateByExampleSelective(@Param("record") SysLog record, @Param("example") SysLogExample example); 24 | 25 | int updateByExample(@Param("record") SysLog record, @Param("example") SysLogExample example); 26 | 27 | int updateByPrimaryKeySelective(SysLog record); 28 | 29 | int updateByPrimaryKey(SysLog record); 30 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/SysSchoolMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import java.util.List; 4 | import org.zeus.entity.SysSchool; 5 | import org.zeus.entity.SysSchoolExample; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface SysSchoolMapper { 9 | int countByExample(SysSchoolExample example); 10 | 11 | int deleteByExample(SysSchoolExample example); 12 | 13 | int deleteByPrimaryKey(Integer id); 14 | 15 | int insert(SysSchool record); 16 | 17 | int insertSelective(SysSchool record); 18 | 19 | List selectByExample(SysSchoolExample example); 20 | 21 | SysSchool selectByPrimaryKey(Integer id); 22 | 23 | int updateByExampleSelective(@Param("record") SysSchool record, @Param("example") SysSchoolExample example); 24 | 25 | int updateByExample(@Param("record") SysSchool record, @Param("example") SysSchoolExample example); 26 | 27 | int updateByPrimaryKeySelective(SysSchool record); 28 | 29 | int updateByPrimaryKey(SysSchool record); 30 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/SysSystemMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import java.util.List; 4 | import org.zeus.entity.SysSystem; 5 | import org.zeus.entity.SysSystemExample; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface SysSystemMapper { 9 | int countByExample(SysSystemExample example); 10 | 11 | int deleteByExample(SysSystemExample example); 12 | 13 | int deleteByPrimaryKey(Integer id); 14 | 15 | int insert(SysSystem record); 16 | 17 | int insertSelective(SysSystem record); 18 | 19 | List selectByExample(SysSystemExample example); 20 | 21 | SysSystem selectByPrimaryKey(Integer id); 22 | 23 | int updateByExampleSelective(@Param("record") SysSystem record, @Param("example") SysSystemExample example); 24 | 25 | int updateByExample(@Param("record") SysSystem record, @Param("example") SysSystemExample example); 26 | 27 | int updateByPrimaryKeySelective(SysSystem record); 28 | 29 | int updateByPrimaryKey(SysSystem record); 30 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/UniversityMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import org.zeus.bean.Database; 8 | import org.zeus.entity.University; 9 | 10 | public interface UniversityMapper { 11 | 12 | int addUniversity(University university); 13 | 14 | public int updateUniversity(@Param("database") Database database); 15 | 16 | University findUniversityById(String schoolNum); 17 | 18 | public List queryAllUniversity(); 19 | 20 | /** 21 | * 学校信息查询,用于开通对比数据 22 | * 23 | * @param schoolNum 24 | * 学校编号 25 | * @param schoolName 26 | * 学校名称 27 | * @param strNum 28 | * 起始页码 29 | * @param strRow 30 | * 每页条数 31 | * @return 返回list 32 | */ 33 | public List queryUniversity(String schoolNum, String schoolName, String strNum, String strRow); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/UserAndRoleMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import org.zeus.bean.Role; 4 | import org.zeus.dto.UserInfoUpdateForm; 5 | import org.zeus.dto.UserRegister; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by aichaellee on 2018/12/31. 11 | */ 12 | public interface UserAndRoleMapper { 13 | 14 | 15 | /** 16 | * 根据用户名得到用户的角色 17 | * @param TID 18 | * @return 19 | */ 20 | List getRolesByUserId(Long TID); 21 | 22 | 23 | 24 | /** 25 | * 添加新用户 26 | * @param tblTeacherBase 27 | * @return 28 | */ 29 | int addNewUser(UserRegister tblTeacherBase); 30 | 31 | /** 32 | * 新增用户时添加对应的角色 33 | * @param userRegister 34 | * @return 35 | */ 36 | int addRoleOfUser(UserRegister userRegister); 37 | 38 | int updateUserInfo(UserInfoUpdateForm userInfoUpdateForm); 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/dmsMapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package org.zeus.dmsMapper; 2 | 3 | import java.util.List; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.zeus.bean.User; 6 | import org.zeus.bean.UserExample; 7 | 8 | 9 | public interface UserMapper { 10 | int countByExample(UserExample example); 11 | 12 | int deleteByExample(UserExample example); 13 | 14 | int deleteByPrimaryKey(Integer id); 15 | 16 | int insert(User record); 17 | 18 | int insertSelective(User record); 19 | 20 | List selectByExample(UserExample example); 21 | 22 | User selectByPrimaryKey(Integer id); 23 | 24 | int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); 25 | 26 | int updateByExample(@Param("record") User record, @Param("example") UserExample example); 27 | 28 | int updateByPrimaryKeySelective(User record); 29 | 30 | int updateByPrimaryKey(User record); 31 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/exception/CustomExceptionResolver.java: -------------------------------------------------------------------------------- 1 | package org.zeus.exception; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.servlet.HandlerExceptionResolver; 5 | import org.springframework.web.servlet.ModelAndView; 6 | import org.springframework.web.servlet.view.json.MappingJackson2JsonView; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * Created by lizhizhong on 2018/12/2. 15 | */ 16 | //@Component 17 | @Slf4j 18 | public class CustomExceptionResolver implements HandlerExceptionResolver { 19 | @Override 20 | public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse response, Object o, Exception e) { 21 | log.info("服务器发生错误{}",e.toString()); 22 | ModelAndView mv = new ModelAndView(new MappingJackson2JsonView()); 23 | Map map = new HashMap<>(); 24 | map.put("status", 500); 25 | map.put("msg", "服务器发生未知错误!"); 26 | mv.addAllObjects(map); 27 | return mv; 28 | } 29 | } -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/MenuRoleService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.dmsMapper.MenuRoleMapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | /** 9 | * Created by sang on 2018/1/2. 10 | */ 11 | @Service 12 | @Transactional 13 | public class MenuRoleService { 14 | @Autowired 15 | MenuRoleMapper menuRoleMapper; 16 | 17 | public int updateMenuRole(Long rid, Long[] mids) { 18 | menuRoleMapper.deleteMenuByRid(rid); 19 | if (mids.length == 0) { 20 | return 0; 21 | } 22 | 23 | menuRoleMapper.addDefaultMid(rid); 24 | 25 | return menuRoleMapper.addMenu(rid, mids); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.bean.Menu; 4 | import org.zeus.common.UserUtils; 5 | import org.zeus.dmsMapper.MenuMapper; 6 | import org.zeus.dto.MenuUpdateForm; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by lizhizhong on 2018/11/28. 15 | */ 16 | @Service 17 | @Transactional 18 | //@CacheConfig(cacheNames = "menus_cache") 19 | public class MenuService { 20 | @Autowired 21 | MenuMapper menuMapper; 22 | 23 | //// @Cacheable(key = "#root.methodName") 24 | // @Cacheable(key = "#root.methodName") 25 | public List getAllMenu(){ 26 | return menuMapper.getAllMenu(); 27 | } 28 | // @Cacheable(key = "#root.methodName") 29 | public List getMenusByUserId() { 30 | return menuMapper.getMenusByUserId(UserUtils.getCurrentUser().getId()); 31 | } 32 | // @Cacheable(key = "#root.methodName") 33 | public List menuTree() { 34 | return menuMapper.menuTree(); 35 | } 36 | 37 | // @Cacheable(key = "#root.methodName") 38 | public List getMenusByRid(Long rid) { 39 | return menuMapper.getMenusByRid(rid); 40 | } 41 | 42 | // @Cacheable(key = "#root.methodName") 43 | public List getMemusInfoByRid(Long rid){ 44 | return menuMapper.getMemusInfoByRid(rid); 45 | } 46 | 47 | public int updateMenuByMid(MenuUpdateForm menu){ 48 | return menuMapper.updateMenuByMid(menu); 49 | } 50 | 51 | /** 52 | * 根据菜单id获得该条详细信息 53 | * @param id 54 | * @return 55 | */ 56 | public Menu getMenuByMid(Long id){ 57 | return menuMapper.getMenuByMid(id); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/PlansService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | /** 6 | * Created by aichaellee on 2018/11/30. 7 | */ 8 | 9 | @Service 10 | public class PlansService { 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/RestAuthentication.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; 9 | import org.springframework.security.core.context.SecurityContextHolder; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by lizhizhong on 2018/11/28. 17 | */ 18 | @Service 19 | public class RestAuthentication { 20 | 21 | @Autowired 22 | private SimpleAuthorityMapper simpleAuthorityMapper; 23 | 24 | public void resetUserAuthorities(String choosedRole){ 25 | 26 | 27 | Authentication oldAuth = SecurityContextHolder.getContext().getAuthentication(); 28 | List authorities = new ArrayList<>(); 29 | authorities.add(new SimpleGrantedAuthority(choosedRole)); 30 | Authentication newAuth = new UsernamePasswordAuthenticationToken( 31 | oldAuth.getPrincipal(),oldAuth.getCredentials(), 32 | authorities); 33 | SecurityContextHolder.getContext().setAuthentication(newAuth); 34 | 35 | 36 | 37 | // Authentication oldAuth = SecurityContextHolder.getContext().getAuthentication(); 38 | // 39 | // Authentication newAuth = new UsernamePasswordAuthenticationToken( 40 | // oldAuth.getPrincipal(),oldAuth.getCredentials(), 41 | // simpleAuthorityMapper.mapAuthorities(getAuthorities(hr))); 42 | // SecurityContextHolder.createEmptyContext(); 43 | // SecurityContextHolder.getContext().setAuthentication(newAuth); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.bean.Role; 4 | import org.zeus.dmsMapper.RoleMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by lizhizhong on 2018/11/28. 13 | */ 14 | @Service 15 | @Transactional 16 | public class RoleService { 17 | @Autowired 18 | RoleMapper roleMapper; 19 | 20 | public List roles() { 21 | return roleMapper.roles(); 22 | } 23 | 24 | public List getRolesByUserId(Long id){ 25 | return roleMapper.getRolesByUserId(id); 26 | } 27 | 28 | public int addNewRole(String role, String roleZh) { 29 | if (!role.startsWith("ROLE_")) { 30 | role = "ROLE_" + role; 31 | } 32 | return roleMapper.addNewRole(role, roleZh); 33 | } 34 | 35 | public int deleteRoleById(Long rid) { 36 | return roleMapper.deleteRoleById(rid); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/SecurityMobileUserDetailService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.core.userdetails.UserDetails; 6 | import org.springframework.security.core.userdetails.UserDetailsService; 7 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @author: lizhizhong 12 | * CreatedDate: 2018/11/30. 13 | */ 14 | @Service 15 | @Slf4j 16 | public class SecurityMobileUserDetailService implements UserDetailsService{ 17 | 18 | @Autowired 19 | UserDetailService userDetailService; 20 | 21 | 22 | 23 | 24 | 25 | @Override 26 | public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException { 27 | 28 | System.out.println("mobile phone is :"+mobile); 29 | return userDetailService.loadUserByMobile(mobile); 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/SecurityUserDetailService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.zeus.common.UserTypeEnum; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.util.StringUtils; 11 | 12 | /** 13 | * @author: lizhizhong 14 | * CreatedDate: 2018/11/30. 15 | */ 16 | @Service 17 | @Slf4j 18 | public class SecurityUserDetailService implements UserDetailsService{ 19 | 20 | @Autowired 21 | UserDetailService userDetailService; 22 | 23 | 24 | 25 | @Override 26 | public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { 27 | 28 | 29 | String[] usernameAndUserType = StringUtils.split(s, String.valueOf(Character.LINE_SEPARATOR)); 30 | if (usernameAndUserType == null || usernameAndUserType.length != 2) { 31 | throw new UsernameNotFoundException("Username and UserType must be provided"); 32 | } 33 | String username = usernameAndUserType[0]; 34 | // String userType = usernameAndUserType[1]; 35 | String userType = "2"; 36 | 37 | log.info("登录用户类型为:{},用户名为:{}",UserTypeEnum.getUserTypeZh(userType),username); 38 | 39 | return userDetailService.loadUserByUsername(username); 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/SysLogService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | /** 6 | * @author: lizhizhong 7 | * CreatedDate: 2018/12/30. 8 | */ 9 | @Service 10 | public class SysLogService { 11 | 12 | // @Autowired 13 | // SysLogMapper syslogMapper; 14 | // 15 | // public int insertLog(SysLog sysLog){ 16 | // return syslogMapper.insertLog(sysLog); 17 | // } 18 | } 19 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/SystemUserService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.common.ServerResponse; 4 | import org.zeus.dto.UserRegister; 5 | 6 | /** 7 | * Created by aichaellee on 2018/10/7. 8 | */ 9 | public interface SystemUserService { 10 | 11 | ServerResponse addUser(UserRegister user); 12 | 13 | //ServerResponse> searchUser(AccountSearch accountSearch); 14 | 15 | // ServerResponse deleteUser(Integer id); 16 | // 17 | // ServerResponse updateUserInfo(Integer id, TblTeacherBase users); 18 | 19 | //ServerResponse updateSelfInfo(Users users, UserDetails userDetails); 20 | 21 | // ServerResponse uploadAvator(Integer id, UserDetails userDetails, MultipartFile[] avatarFile); 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/SystemUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.common.ServerResponse; 4 | import org.zeus.dmsMapper.UserAndRoleMapper; 5 | import org.zeus.dto.UserRegister; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Optional; 10 | 11 | /** 12 | * @author: lizhizhong 13 | * CreatedDate: 2018/12/31. 14 | */ 15 | @Service("SystemUserService") 16 | public class SystemUserServiceImpl implements SystemUserService { 17 | 18 | @Autowired 19 | UserAndRoleMapper teachersMapper; 20 | 21 | @Override 22 | public ServerResponse addUser(UserRegister user) { 23 | 24 | if(!Optional.ofNullable(user).isPresent()){ 25 | throw new RuntimeException("用户信息不能为空!"); 26 | } 27 | 28 | teachersMapper.addNewUser(user); 29 | 30 | return ServerResponse.createBySuccess("用户创建成功"); 31 | 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/UserAndRoleService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.zeus.bean.Role; 4 | import org.zeus.common.ServerResponse; 5 | import org.zeus.common.UserUtils; 6 | import org.zeus.dmsMapper.UserAndRoleMapper; 7 | import org.zeus.dto.UserInfoUpdateForm; 8 | import org.zeus.dto.UserRegister; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | /** 16 | * Created by aichaellee on 2018/11/30. 17 | */ 18 | @Service 19 | public class UserAndRoleService { 20 | 21 | @Autowired 22 | UserAndRoleMapper userAndRoleMapper; 23 | 24 | 25 | public List getRolesByUserId(Long id){ 26 | 27 | return userAndRoleMapper.getRolesByUserId(id); 28 | } 29 | 30 | /** 31 | * 添加新用户 32 | * @param user 33 | * @return 34 | */ 35 | public ServerResponse addNewUser(UserRegister user) { 36 | 37 | if(!Optional.ofNullable(user).isPresent()){ 38 | throw new RuntimeException("用户信息不能为空!"); 39 | } 40 | 41 | userAndRoleMapper.addNewUser(user); 42 | 43 | return ServerResponse.createBySuccess("用户创建成功"); 44 | 45 | 46 | } 47 | 48 | /** 49 | * 修改用户信息 50 | * @param userInfo 51 | * @return 52 | */ 53 | public ServerResponse updateUserInfo(UserInfoUpdateForm userInfo){ 54 | userInfo.setId(UserUtils.getCurrentUser().getId()); 55 | int result = userAndRoleMapper.updateUserInfo(userInfo); 56 | if(result>0){ 57 | return ServerResponse.createBySuccess("个人信息修改成功"); 58 | }else{ 59 | return ServerResponse.createBySuccess("个人信息修改失败!"); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/UserDetailService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.core.userdetails.UserDetails; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | import org.zeus.bean.Role; 10 | import org.zeus.bean.User; 11 | import org.zeus.bean.UserExample; 12 | import org.zeus.dmsMapper.UserMapper; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by lizhizhong on 2018/11/28. 18 | */ 19 | @Service 20 | @Transactional 21 | @Slf4j 22 | public class UserDetailService { 23 | 24 | @Autowired 25 | UserAndRoleService teacherService; 26 | 27 | @Autowired 28 | UserMapper userMapper; 29 | 30 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 31 | // load user by userName 32 | UserExample example = new UserExample(); 33 | example.createCriteria().andNameEqualTo(username); 34 | List users = userMapper.selectByExample(example); 35 | if (users == null) { 36 | throw new UsernameNotFoundException("用户名错误"); 37 | } 38 | 39 | List roles = teacherService.getRolesByUserId(users.get(0).getId()); 40 | users.get(0).setRoles(roles); 41 | log.info("教师账号验证开始{}",users.get(0).getName()); 42 | 43 | return users.get(0); 44 | 45 | } 46 | public UserDetails loadUserByMobile(String m) throws UsernameNotFoundException { 47 | 48 | // load user by mobile 49 | UserExample example = new UserExample(); 50 | example.createCriteria().andMobileEqualTo(Integer.valueOf(m)); 51 | List users = userMapper.selectByExample(example); 52 | if (users == null) { 53 | throw new UsernameNotFoundException("未绑定此手机号"); 54 | } 55 | 56 | List roles = teacherService.getRolesByUserId(users.get(0).getId()); 57 | users.get(0).setRoles(roles); 58 | log.info("手机登录验证{}",users.get(0).getMobile()); 59 | 60 | return users.get(0); 61 | 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /zeus-web/src/main/java/org/zeus/service/UserService.java: -------------------------------------------------------------------------------- 1 | package org.zeus.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by lizhizhong on 2018/11/28. 11 | */ 12 | @Service 13 | @Transactional 14 | public class UserService { 15 | 16 | 17 | 18 | 19 | public int updateHrRoles(Long hrId, Long[] rids) { 20 | return 1; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/application.properties -------------------------------------------------------------------------------- /zeus-web/src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 49 | 50 | 51 | 52 | 54 | 55 | 56 | 57 | 58 |
59 | 60 |
61 |
-------------------------------------------------------------------------------- /zeus-web/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | System.out 6 | 7 | %date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level %logger{0} - [userId=%X{userId}] [sessionId=%X{sessionId}] %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis/dmsMapper/CommonMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | ${sql} 8 | 9 | 12 | 13 | ${sql} 14 | 15 | 16 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis/dmsMapper/MenuRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | DELETE FROM menu_role WHERE rid=#{rid} 8 | 9 | 10 | INSERT INTO menu_role(mid,rid) VALUES 11 | 12 | (#{mid},#{rid}) 13 | 14 | 15 | 16 | INSERT INTO menu_role(mid,rid) VALUES 17 | (29,#{rid}) 18 | 19 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis/dmsMapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | INSERT INTO role set name=#{role},nameZh=#{roleZh} 11 | 12 | 13 | DELETE FROM role WHERE id=#{rid} 14 | 15 | 23 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis/dmsMapper/UniversityMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | insert into university set school_name 35 | =#{university.schoolName},school_id= #{university.schoolNum},city=#{ university.city},liaison_name=#{ 36 | university.contacts},liaison_phone=#{university.tel}, liaison_email =#{ university.email},province=#{university.province},property = #{university.property},status=#{university.status}, 37 | begin_time=#{university.begintime}, expire_time=#{university.exportTime} 38 | 39 | 40 | 41 | 42 | 46 | 47 | 51 | 52 | 53 | update 54 | university 55 | set db_ip=#{database.oldServerIp},db_name 56 | =#{database.dbName},db_user=#{database.MysqlUser},db_password=#{database.mysqlPassowrd} 57 | where school_id=#{database.oldSchoolNum}; 58 | 59 | 60 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/mybatis/dmsMapper/UserAndRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 41 | 42 | 43 | 44 | insert into user set name=#{username},password=#{password} 45 | 46 | 47 | update user 48 | 49 | 50 | name=#{name} 51 | 52 | 53 | 54 | 55 | 56 | id = #{id} 57 | 58 | 59 | 60 | update user 61 | 62 | 63 | password=#{password} 64 | 65 | 66 | 67 | 68 | id = #{id} 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | zeus后台管理系统
-------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/explode.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/explode.mp3 -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/fonts/element-icons.6f0a763.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/fonts/element-icons.6f0a763.ttf -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.674f50d.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.674f50d.eot -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.af7ae50.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.af7ae50.woff2 -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.b06871f.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.b06871f.ttf -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.fee66e7.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/fonts/fontawesome-webfont.fee66e7.woff -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/img/2.jpg -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/img/bannerleft.452a4c3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/img/bannerleft.452a4c3.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/img/bannerleft.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/img/bannerleft.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/img/middle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/img/middle.jpg -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/js/manifest.a3151baa22459846f487.js: -------------------------------------------------------------------------------- 1 | !function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,a,c){for(var f,i,u,d=0,s=[];d code[class*="language-"], 58 | pre[class*="language-"] { 59 | background: #f5f2f0; 60 | } 61 | 62 | /* Inline code */ 63 | :not(pre) > code[class*="language-"] { 64 | padding: .1em; 65 | border-radius: .3em; 66 | } 67 | 68 | .token.comment, 69 | .token.prolog, 70 | .token.doctype, 71 | .token.cdata { 72 | color: slategray; 73 | } 74 | 75 | .token.punctuation { 76 | color: #999; 77 | } 78 | 79 | .namespace { 80 | opacity: .7; 81 | } 82 | 83 | .token.property, 84 | .token.tag, 85 | .token.boolean, 86 | .token.number, 87 | .token.constant, 88 | .token.symbol, 89 | .token.deleted { 90 | color: #905; 91 | } 92 | 93 | .token.selector, 94 | .token.attr-name, 95 | .token.string, 96 | .token.char, 97 | .token.builtin, 98 | .token.inserted { 99 | color: #690; 100 | } 101 | 102 | .token.operator, 103 | .token.entity, 104 | .token.url, 105 | .language-css .token.string, 106 | .style .token.string { 107 | color: #a67f59; 108 | background: hsla(0, 0%, 100%, .5); 109 | } 110 | 111 | .token.atrule, 112 | .token.attr-value, 113 | .token.keyword { 114 | color: #07a; 115 | } 116 | 117 | .token.function { 118 | color: #DD4A68; 119 | } 120 | 121 | .token.regex, 122 | .token.important, 123 | .token.variable { 124 | color: #e90; 125 | } 126 | 127 | .token.important, 128 | .token.bold { 129 | font-weight: bold; 130 | } 131 | .token.italic { 132 | font-style: italic; 133 | } 134 | 135 | .token.entity { 136 | cursor: help; 137 | } 138 | 139 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-cool.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-cool.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-cry.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-cry.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-embarassed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-embarassed.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-foot-in-mouth.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-foot-in-mouth.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-frown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-frown.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-innocent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-innocent.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-kiss.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-kiss.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-laughing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-laughing.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-money-mouth.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-money-mouth.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-sealed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-sealed.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-smile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-smile.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-surprised.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-surprised.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-tongue-out.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-tongue-out.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-undecided.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-undecided.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-wink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-wink.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-yell.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/plugins/emoticons/img/smiley-yell.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/content.inline.min.css: -------------------------------------------------------------------------------- 1 | .word-wrap{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#D5D5D5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object[data-mce-selected="2"] .mce-shim{display:none}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-toc{border:1px solid gray}.mce-toc h2{margin:4px}.mce-toc li{list-style-type:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3A3A3A;background:#D5D5D5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#3399ff;color:#fff}.mce-spellchecker-word{border-bottom:2px solid rgba(208,2,27,0.5);cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td[data-mce-selected],th[data-mce-selected]{background-color:#2276d2 !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2276d2}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #2276d2}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2276d2}.mce-content-body *[data-mce-selected="inline-boundary"]{background:#bfe6ff}.mce-content-body .mce-item-anchor[data-mce-selected]{background:#D5D5D5 url(img/anchor.gif) no-repeat center}.mce-content-body hr{cursor:default}.ephox-snooker-resizer-bar{background-color:#2276d2;opacity:0}.ephox-snooker-resizer-cols{cursor:col-resize}.ephox-snooker-resizer-rows{cursor:row-resize}.ephox-snooker-resizer-bar.ephox-snooker-resizer-bar-dragging{opacity:.2}.mce-content-body{line-height:1.3} -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/content.min.css: -------------------------------------------------------------------------------- 1 | body{background-color:#FFFFFF;color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:1.3;scrollbar-3dlight-color:#F0F0EE;scrollbar-arrow-color:#676662;scrollbar-base-color:#F0F0EE;scrollbar-darkshadow-color:#DDDDDD;scrollbar-face-color:#E0E0DD;scrollbar-highlight-color:#F0F0EE;scrollbar-shadow-color:#F0F0EE;scrollbar-track-color:#F5F5F5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px}.word-wrap{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#D5D5D5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object[data-mce-selected="2"] .mce-shim{display:none}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-toc{border:1px solid gray}.mce-toc h2{margin:4px}.mce-toc li{list-style-type:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3A3A3A;background:#D5D5D5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#3399ff;color:#fff}.mce-spellchecker-word{border-bottom:2px solid rgba(208,2,27,0.5);cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td[data-mce-selected],th[data-mce-selected]{background-color:#2276d2 !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2276d2}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #2276d2}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2276d2}.mce-content-body *[data-mce-selected="inline-boundary"]{background:#bfe6ff}.mce-content-body .mce-item-anchor[data-mce-selected]{background:#D5D5D5 url(img/anchor.gif) no-repeat center}.mce-content-body hr{cursor:default}.ephox-snooker-resizer-bar{background-color:#2276d2;opacity:0}.ephox-snooker-resizer-cols{cursor:col-resize}.ephox-snooker-resizer-rows{cursor:row-resize}.ephox-snooker-resizer-bar.ephox-snooker-resizer-bar-dragging{opacity:.2} a {color: #1478F0;} 2 | -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-mobile.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-mobile.woff -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.eot -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.ttf -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce-small.woff -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.eot -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.ttf -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/fonts/tinymce.woff -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/anchor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/anchor.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/loader.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/object.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/object.gif -------------------------------------------------------------------------------- /zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/trans.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AichaelLee/zeusSpring/251777bef6ed018010fe3981ff270d15b8741862/zeus-web/src/main/resources/static/static/tinymce4.7.5/skins/lightgray/img/trans.gif -------------------------------------------------------------------------------- /zeus-web/src/test/java/org/zeus/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.zeus; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | --------------------------------------------------------------------------------