├── README.md ├── focus ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── generator.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── melo │ │ │ └── focus │ │ │ ├── FocusApplication.java │ │ │ ├── config │ │ │ ├── RedissonAutoConfiguration.java │ │ │ ├── RedissonProperties.java │ │ │ ├── ShiroConfig.java │ │ │ └── Swagger2Config.java │ │ │ ├── controller │ │ │ ├── AuthorityController.java │ │ │ ├── HelloController.java │ │ │ ├── LoginController.java │ │ │ ├── ResourceController.java │ │ │ ├── RoleController.java │ │ │ └── UserController.java │ │ │ ├── domain │ │ │ ├── basic │ │ │ │ ├── Authority.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceAuthority.java │ │ │ │ ├── Role.java │ │ │ │ ├── RoleBusiness.java │ │ │ │ ├── RoleResourcer.java │ │ │ │ ├── User.java │ │ │ │ └── UserRoleR.java │ │ │ ├── extend │ │ │ │ └── AuthorityController.java │ │ │ └── vm │ │ │ │ ├── AuthoritySaveVM.java │ │ │ │ ├── AuthorityUpdateVM.java │ │ │ │ ├── AuthorityVMS.java │ │ │ │ ├── ResourceAuthorityVM.java │ │ │ │ ├── ResourceSaveVM.java │ │ │ │ ├── ResourceUpdateVM.java │ │ │ │ ├── ResourceVM.java │ │ │ │ ├── RoleResourceVM.java │ │ │ │ ├── RoleSaveVM.java │ │ │ │ ├── RoleUpdateVM.java │ │ │ │ ├── UserRoleSaveVM.java │ │ │ │ ├── UserRoleSaveVMS.java │ │ │ │ ├── UserSaveVM.java │ │ │ │ └── UserUpdateVM.java │ │ │ ├── exception │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── mapper │ │ │ ├── basic │ │ │ │ ├── AuthorityMapper.java │ │ │ │ ├── ResourceAuthorityMapper.java │ │ │ │ ├── ResourceMapper.java │ │ │ │ ├── RoleBusinessMapper.java │ │ │ │ ├── RoleMapper.java │ │ │ │ ├── RoleResourcerMapper.java │ │ │ │ ├── UserMapper.java │ │ │ │ └── UserRoleRMapper.java │ │ │ └── extend │ │ │ │ ├── AuthorityExtendMapper.java │ │ │ │ ├── ResourceAuthorityExtendMapper.java │ │ │ │ ├── ResourceExtendMapper.java │ │ │ │ ├── RoleExtendMapper.java │ │ │ │ ├── RoleResourceExtendMapper.java │ │ │ │ ├── UserExtendMapper.java │ │ │ │ └── UserRoleRExtendMapper.java │ │ │ ├── realm │ │ │ └── MyShiroRealm.java │ │ │ ├── service │ │ │ ├── AuthorityService.java │ │ │ ├── ResourceAuthorityService.java │ │ │ ├── ResourceService.java │ │ │ ├── RoleResourceService.java │ │ │ ├── RoleService.java │ │ │ ├── UserRoleService.java │ │ │ └── UserService.java │ │ │ └── util │ │ │ ├── Asserts.java │ │ │ ├── Constants.java │ │ │ ├── DataValidateFiledException.java │ │ │ ├── EntityUtils.java │ │ │ ├── FiledError.java │ │ │ ├── Message.java │ │ │ └── groupage.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── mapper │ │ ├── basic │ │ │ ├── AuthorityMapper.xml │ │ │ ├── ResourceAuthorityMapper.xml │ │ │ ├── ResourceMapper.xml │ │ │ ├── RoleBusinessMapper.xml │ │ │ ├── RoleMapper.xml │ │ │ ├── RoleResourcerMapper.xml │ │ │ ├── UserMapper.xml │ │ │ └── UserRoleRMapper.xml │ │ └── extend │ │ │ ├── AuthorityExtendMapper.xml │ │ │ ├── ResourceAuthorityExtendMapper.xml │ │ │ ├── ResourceExtendMapper.xml │ │ │ ├── RoleExtendMapper.xml │ │ │ ├── RoleResourcerExtendMapper.xml │ │ │ ├── UserExtendMapper.xml │ │ │ └── UserRoleRExtendMapper.xml │ │ ├── sql │ │ └── focus.sql │ │ ├── static │ │ ├── 1.png │ │ ├── authority_manage.html │ │ ├── blog.html │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ ├── head.html │ │ ├── helloboot.html │ │ ├── homm.html │ │ ├── introduction.html │ │ ├── jquery-3.0.0.min.js │ │ ├── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ │ ├── left.html │ │ ├── resource_authority.html │ │ ├── resource_manage.html │ │ ├── resource_save.html │ │ ├── resource_update.html │ │ ├── role_manage.html │ │ ├── role_resource.html │ │ ├── role_save.html │ │ ├── role_update.html │ │ ├── test.html │ │ ├── user_manage.html │ │ ├── user_role.html │ │ ├── user_save.html │ │ └── user_update.html │ │ └── templates │ │ ├── 403.html │ │ ├── NewFile.html │ │ ├── index.html │ │ ├── login.html │ │ ├── no.html │ │ └── session.html │ └── test │ └── java │ └── com │ └── melo │ └── focus │ └── FocusApplicationTests.java └── img ├── auth.png ├── authority.png ├── resource.png ├── role.png └── user.png /README.md: -------------------------------------------------------------------------------- 1 | #focus 2 | 权限管理系统,学习springboot和shiro
3 | [访问地址] http://47.98.153.30:8080/ 账号:melo 密码:12345678 4 | 5 | 一。采用框架 6 | =========== 7 | 前端:jquery、bootstrap 8 | 后端:springboot、shiro、mybatis、redisson、swagger 9 | 数据库:mysql 10 | jdk:1.8 11 | 12 | 二。编程记录 13 | ========== 14 | [我的博客记录了 后端基本搭建过程] https://blog.csdn.net/u014203449/article/details/79330811
15 | [访问地址] http://47.98.153.30:8080/ 账号:melo 密码:12345678 16 | 17 | 三。部署过程 18 | ========== 19 | 1.建立名为focus的数据库,执行项目中的 sql文件
20 | 2.更改application 中数据库和redis 的用户名密码
21 | 3.如果不用redis的朋友,可以将配置文件、config类、安全管理器、和resouceservice中redis业务注释掉即可
22 | 4.访问 localhost:8080 账号:melo 密码:12345678
23 | 24 | ![](https://github.com/MeloFocus/focus/raw/master/img/user.png)
25 | ![](https://github.com/MeloFocus/focus/raw/master/img/role.png)
26 | ![](https://github.com/MeloFocus/focus/raw/master/img/resource.png)
27 | ![](https://github.com/MeloFocus/focus/raw/master/img/auth.png)
28 | ![](https://github.com/MeloFocus/focus/raw/master/img/authority.png)
29 | -------------------------------------------------------------------------------- /focus/.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 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /focus/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/focus/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /focus/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /focus/generator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 20 | 22 | 25 | 26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
-------------------------------------------------------------------------------- /focus/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.melo 7 | focus 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | focus 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-data-redis 44 | 45 | 46 | 47 | 48 | org.redisson 49 | redisson 50 | 3.4.3 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-thymeleaf 56 | 57 | 58 | 59 | 60 | org.mybatis.spring.boot 61 | mybatis-spring-boot-starter 62 | 1.3.1 63 | 64 | 65 | 66 | 67 | mysql 68 | mysql-connector-java 69 | runtime 70 | 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-starter-test 75 | test 76 | 77 | 78 | 79 | org.apache.shiro 80 | shiro-spring 81 | 1.3.2 82 | 83 | 84 | 85 | org.crazycake 86 | shiro-redis 87 | 2.4.2.1-RELEASE 88 | 89 | 90 | 91 | 92 | io.springfox 93 | springfox-swagger2 94 | 2.2.2 95 | 96 | 97 | io.springfox 98 | springfox-swagger-ui 99 | 2.2.2 100 | 101 | 102 | 103 | 104 | org.apache.commons 105 | commons-lang3 106 | 3.5 107 | 108 | 109 | 110 | 111 | org.springframework 112 | spring-beans 113 | 114 | 115 | com.github.pagehelper 116 | pagehelper 117 | 5.0.1 118 | 119 | 120 | 121 | org.springframework.boot 122 | spring-boot-devtools 123 | runtime 124 | 125 | 126 | 127 | 128 | 129 | 130 | org.springframework.boot 131 | spring-boot-maven-plugin 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/FocusApplication.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 7 | 8 | @SpringBootApplication 9 | @EnableSwagger2 10 | public class FocusApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(FocusApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/config/RedissonAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.config; 2 | 3 | import org.redisson.Redisson; 4 | import org.redisson.api.RedissonClient; 5 | import org.redisson.config.Config; 6 | import org.redisson.config.SingleServerConfig; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 10 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.apache.commons.lang3.StringUtils; 14 | 15 | @Configuration 16 | @ConditionalOnClass(Config.class) 17 | @EnableConfigurationProperties(RedissonProperties.class) 18 | public class RedissonAutoConfiguration { 19 | 20 | @Autowired 21 | private RedissonProperties redssionProperties; 22 | 23 | /** 24 | * 单机模式自动装配 25 | * @return 26 | */ 27 | @Bean 28 | @ConditionalOnProperty(name="spring.redisson.address") 29 | RedissonClient redissonSingle() { 30 | Config config = new Config(); 31 | SingleServerConfig serverConfig = config.useSingleServer() 32 | .setAddress(redssionProperties.getAddress()) 33 | .setTimeout(redssionProperties.getTimeout()) 34 | .setConnectionPoolSize(redssionProperties.getConnectionPoolSize()) 35 | .setConnectionMinimumIdleSize(redssionProperties.getConnectionMinimumIdleSize()); 36 | 37 | if(StringUtils.isNotBlank(redssionProperties.getPassword())) { 38 | serverConfig.setPassword(redssionProperties.getPassword()); 39 | } 40 | 41 | return Redisson.create(config); 42 | } 43 | 44 | /** 45 | * 哨兵模式自动装配 46 | * @return 47 | */ 48 | /* @Bean 49 | @ConditionalOnProperty(name="redisson.master-name") 50 | RedissonClient redissonSentinel() { 51 | Config config = new Config(); 52 | SentinelServersConfig serverConfig = config.useSentinelServers().addSentinelAddress(redssionProperties.getSentinelAddresses()) 53 | .setMasterName(redssionProperties.getMasterName()) 54 | .setTimeout(redssionProperties.getTimeout()) 55 | .setMasterConnectionPoolSize(redssionProperties.getMasterConnectionPoolSize()) 56 | .setSlaveConnectionPoolSize(redssionProperties.getSlaveConnectionPoolSize()); 57 | 58 | if(StringUtils.isNotBlank(redssionProperties.getPassword())) { 59 | serverConfig.setPassword(redssionProperties.getPassword()); 60 | } 61 | return Redisson.create(config); 62 | }*/ 63 | 64 | 65 | /** 66 | * 装配locker类,并将实例注入到RedissLockUtil中 67 | * @return 68 | */ 69 | /* @Bean 70 | DistributedLocker distributedLocker(RedissonClient redissonClient) { 71 | DistributedLocker locker = new RedissonDistributedLocker(); 72 | locker.setRedissonClient(redissonClient); 73 | RedissLockUtil.setLocker(locker); 74 | return locker; 75 | }*/ 76 | 77 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/config/RedissonProperties.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | @ConfigurationProperties(prefix = "spring.redisson") 6 | public class RedissonProperties { 7 | 8 | private int timeout = 3000; 9 | 10 | private String address; 11 | 12 | private String password; 13 | 14 | private int connectionPoolSize = 64; 15 | 16 | private int connectionMinimumIdleSize=10; 17 | 18 | private int slaveConnectionPoolSize = 250; 19 | 20 | private int masterConnectionPoolSize = 250; 21 | 22 | private String[] sentinelAddresses; 23 | 24 | private String masterName; 25 | 26 | public int getTimeout() { 27 | return timeout; 28 | } 29 | 30 | public void setTimeout(int timeout) { 31 | this.timeout = timeout; 32 | } 33 | 34 | public int getSlaveConnectionPoolSize() { 35 | return slaveConnectionPoolSize; 36 | } 37 | 38 | public void setSlaveConnectionPoolSize(int slaveConnectionPoolSize) { 39 | this.slaveConnectionPoolSize = slaveConnectionPoolSize; 40 | } 41 | 42 | public int getMasterConnectionPoolSize() { 43 | return masterConnectionPoolSize; 44 | } 45 | 46 | public void setMasterConnectionPoolSize(int masterConnectionPoolSize) { 47 | this.masterConnectionPoolSize = masterConnectionPoolSize; 48 | } 49 | 50 | public String[] getSentinelAddresses() { 51 | return sentinelAddresses; 52 | } 53 | 54 | public void setSentinelAddresses(String sentinelAddresses) { 55 | this.sentinelAddresses = sentinelAddresses.split(","); 56 | } 57 | 58 | public String getMasterName() { 59 | return masterName; 60 | } 61 | 62 | public void setMasterName(String masterName) { 63 | this.masterName = masterName; 64 | } 65 | 66 | public String getPassword() { 67 | return password; 68 | } 69 | 70 | public void setPassword(String password) { 71 | this.password = password; 72 | } 73 | 74 | public String getAddress() { 75 | return address; 76 | } 77 | 78 | public void setAddress(String address) { 79 | this.address = address; 80 | } 81 | 82 | public int getConnectionPoolSize() { 83 | return connectionPoolSize; 84 | } 85 | 86 | public void setConnectionPoolSize(int connectionPoolSize) { 87 | this.connectionPoolSize = connectionPoolSize; 88 | } 89 | 90 | public int getConnectionMinimumIdleSize() { 91 | return connectionMinimumIdleSize; 92 | } 93 | 94 | public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) { 95 | this.connectionMinimumIdleSize = connectionMinimumIdleSize; 96 | } 97 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/config/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | @Configuration 15 | @EnableSwagger2 16 | public class Swagger2Config { 17 | 18 | @Bean 19 | public Docket createRestApi() { 20 | return new Docket(DocumentationType.SWAGGER_2) 21 | .apiInfo(apiInfo()) 22 | .select() 23 | .apis(RequestHandlerSelectors.basePackage("com.melo.focus")) 24 | .paths(PathSelectors.any()) 25 | .build(); 26 | } 27 | 28 | 29 | private ApiInfo apiInfo() { 30 | return new ApiInfoBuilder() 31 | .title("Spring Boot中使用Swagger2构建RESTful APIs") 32 | .description("怎么ApiModel没有效果") 33 | .termsOfServiceUrl("") 34 | .contact("Focus") 35 | .version("1.0") 36 | .build(); 37 | } 38 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/controller/AuthorityController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.controller; 2 | 3 | import io.swagger.annotations.ApiImplicitParam; 4 | import io.swagger.annotations.ApiImplicitParams; 5 | import io.swagger.annotations.ApiOperation; 6 | import io.swagger.annotations.ApiResponse; 7 | import io.swagger.annotations.ApiResponses; 8 | 9 | import java.util.List; 10 | 11 | import org.apache.shiro.authz.annotation.Logical; 12 | import org.apache.shiro.authz.annotation.RequiresPermissions; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.RequestParam; 19 | import org.springframework.web.bind.annotation.RestController; 20 | 21 | import com.melo.focus.domain.basic.Authority; 22 | import com.melo.focus.domain.vm.AuthoritySaveVM; 23 | import com.melo.focus.domain.vm.AuthorityUpdateVM; 24 | import com.melo.focus.domain.vm.AuthorityVMS; 25 | import com.melo.focus.service.AuthorityService; 26 | import com.melo.focus.util.Constants; 27 | import com.melo.focus.util.Message; 28 | 29 | @RestController 30 | @RequestMapping(value="/focus") 31 | public class AuthorityController { 32 | 33 | @Autowired 34 | AuthorityService authorityService; 35 | 36 | @ApiImplicitParams({ 37 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 38 | }) 39 | @ApiOperation(value="按controller分组,得到authority列表",notes="按controller分组,得到authority列表,需要authority_getAuthority权限或管理员权限") 40 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 41 | @RequiresPermissions(value={"authority_getAuthority","administrator"},logical=Logical.OR) 42 | @RequestMapping(value="/authority",method=RequestMethod.GET) 43 | public Message> getAuthority(){ 44 | List list=authorityService.getAuthority(); 45 | return Message.ok(list); 46 | } 47 | 48 | @ApiImplicitParams({ 49 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header"), 50 | @ApiImplicitParam(name = "method", value = "请求方式", dataType = "string", paramType = "query"), 51 | @ApiImplicitParam(name = "word", value = "关键字", dataType = "string", paramType = "query") 52 | }) 53 | @ApiOperation(value="根据请求方式,按关键字模糊查询",notes="根据请求方式,按关键字模糊查询,需要authority_getLikeAuthority权限或管理员权限") 54 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 55 | @RequiresPermissions(value={"authority_getLikeAuthority","administrator"},logical=Logical.OR) 56 | @RequestMapping(value="/getLikeAuthority",method=RequestMethod.GET) 57 | public Message> getLikeAuthority(@RequestParam("method")String method,@RequestParam("word")String word){ 58 | List list=authorityService.getLikeAuthority(method,word); 59 | return Message.ok(list); 60 | } 61 | 62 | @ApiImplicitParams({ 63 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 64 | }) 65 | @ApiOperation(value="新增操作码",notes="新增操作码,需要authority_saveAuthority权限或管理员权限") 66 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 67 | @RequiresPermissions(value={"authority_saveAuthority","administrator"},logical=Logical.OR) 68 | @RequestMapping(value="/authority",method=RequestMethod.POST) 69 | public Message saveAuthority(@RequestBody AuthoritySaveVM authoritySaveVM){ 70 | authorityService.saveAuthority(authoritySaveVM); 71 | return Message.ok(Constants.SUCCESS); 72 | } 73 | 74 | @ApiImplicitParams({ 75 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 76 | }) 77 | @ApiOperation(value="修改操作码",notes="修改操作码,需要authority_updateAuhtority权限或管理员权限") 78 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 79 | @RequiresPermissions(value={"authority_updateAuhtority","administrator"},logical=Logical.OR) 80 | @RequestMapping(value="/authority",method=RequestMethod.PUT) 81 | public Message updateAuhtority(@RequestBody AuthorityUpdateVM authorityUpdateVM){ 82 | authorityService.updateAuhtority(authorityUpdateVM); 83 | return Message.ok(Constants.SUCCESS); 84 | } 85 | 86 | @ApiImplicitParams({ 87 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 88 | }) 89 | @ApiOperation(value="删除操作码",notes="删除操作码,需要authority_deleteAuthority权限或管理员权限") 90 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 91 | @RequiresPermissions(value={"authority_deleteAuthority","administrator"},logical=Logical.OR) 92 | @RequestMapping(value="/authority/{id}",method=RequestMethod.DELETE) 93 | public Message deleteAuthority(@PathVariable("id")String id){ 94 | authorityService.deleteAuthority(id); 95 | return Message.ok(Constants.SUCCESS); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | 11 | @RequestMapping(value="/hello",method=RequestMethod.GET) 12 | //@RequiresPermissions(value="how_are_you") 13 | public String hello(){ 14 | 15 | return "HelloWorld"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.controller; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import javax.servlet.http.HttpSession; 8 | 9 | import org.apache.shiro.SecurityUtils; 10 | import org.apache.shiro.authc.AuthenticationException; 11 | import org.apache.shiro.authc.IncorrectCredentialsException; 12 | import org.apache.shiro.authc.UsernamePasswordToken; 13 | import org.apache.shiro.subject.Subject; 14 | import org.redisson.api.RMapCache; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Controller; 17 | import org.springframework.ui.Model; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.ResponseBody; 21 | 22 | import com.melo.focus.domain.basic.User; 23 | import com.melo.focus.domain.vm.ResourceVM; 24 | import com.melo.focus.service.ResourceService; 25 | import com.melo.focus.util.Constants; 26 | import com.melo.focus.util.Message; 27 | 28 | 29 | @Controller 30 | public class LoginController { 31 | 32 | @Autowired 33 | ResourceService resourceService; 34 | 35 | @RequestMapping(value="/focus/userlogin") 36 | @ResponseBody 37 | public Message userLogin(User user){ 38 | if(user==null){ 39 | //return "login"; 40 | return Message.ok("登录失败"); 41 | } 42 | 43 | /*if(SecurityUtils.getSubject().getSession().getAttribute("login")!=null){ 44 | return "index"; 45 | }*/ 46 | //两个session是一样的。 47 | /*if(session.getAttribute("login")!=null){ 48 | return Message.ok(Constants.SUCCESS); 49 | }*/ 50 | 51 | String account=user.getLoginName(); 52 | String password=user.getPassword(); 53 | UsernamePasswordToken token = new UsernamePasswordToken(account,password,false); 54 | token.setRememberMe(true); 55 | Subject currentUser = SecurityUtils.getSubject(); 56 | try { 57 | currentUser.login(token); 58 | //此步将 调用realm的认证方法 59 | } catch(IncorrectCredentialsException e){ 60 | //这最好把 所有的 异常类型都背会 61 | //model.addAttribute("message", "密码错误"); 62 | return Message.ok("密码错误"); 63 | } catch (AuthenticationException e) { 64 | //model.addAttribute("message", "登录失败"); 65 | return Message.ok("登录失败"); 66 | } 67 | 68 | return Message.ok(Constants.SUCCESS); 69 | } 70 | 71 | //配合shiro配置中的默认访问url 72 | @RequestMapping(value="/login",method=RequestMethod.GET) 73 | public String getLogin(HttpServletRequest request,Model model,HttpSession session,HttpServletResponse response){ 74 | 75 | return "login"; 76 | } 77 | 78 | 79 | @RequestMapping(value="/",method=RequestMethod.GET) 80 | public String index(){ 81 | System.out.println("访问了后端 / 请求"); 82 | return "login"; 83 | } 84 | 85 | /** 86 | * 退出 87 | * @return 88 | */ 89 | @RequestMapping(value="/focus/logout",method =RequestMethod.GET) 90 | public String logout(HttpServletRequest request){ 91 | 92 | //subject的实现类DelegatingSubject的logout方法,将本subject对象的session清空了 93 | //即使session托管给了redis ,redis有很多个浏览器的session 94 | //只要调用退出方法,此subject的、此浏览器的session就没了 95 | try { 96 | User user = (User)SecurityUtils.getSubject().getPrincipal(); 97 | String userId=user.getId(); 98 | resourceService.deleteRedis(userId); 99 | //退出 100 | SecurityUtils.getSubject().logout(); 101 | 102 | } catch (Exception e) { 103 | System.err.println(e.getMessage()); 104 | } 105 | return "login"; 106 | } 107 | 108 | @RequestMapping(value="403",method=RequestMethod.GET) 109 | public String unAuth(){ 110 | 111 | return "403"; 112 | } 113 | 114 | 115 | /*@RequestMapping(value="play") 116 | public String play(){ 117 | System.out.println("11111"); 118 | return "NewFile"; 119 | }*/ 120 | } 121 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.controller; 2 | import io.swagger.annotations.ApiImplicitParam; 3 | import io.swagger.annotations.ApiImplicitParams; 4 | import io.swagger.annotations.ApiOperation; 5 | import io.swagger.annotations.ApiResponse; 6 | import io.swagger.annotations.ApiResponses; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import org.apache.shiro.authz.annotation.Logical; 12 | import org.apache.shiro.authz.annotation.RequiresPermissions; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestMethod; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import com.melo.focus.domain.basic.Role; 21 | import com.melo.focus.domain.vm.RoleResourceVM; 22 | import com.melo.focus.domain.vm.RoleSaveVM; 23 | import com.melo.focus.domain.vm.RoleUpdateVM; 24 | import com.melo.focus.service.RoleResourceService; 25 | import com.melo.focus.service.RoleService; 26 | import com.melo.focus.util.Constants; 27 | import com.melo.focus.util.Message; 28 | 29 | 30 | @RestController 31 | @RequestMapping(value="/focus") 32 | public class RoleController { 33 | 34 | @Autowired 35 | RoleService roleService; 36 | 37 | @Autowired 38 | RoleResourceService roleResourceService; 39 | 40 | @ApiImplicitParams({ 41 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 42 | }) 43 | @ApiOperation(value="新增角色",notes="新增角色,需要 role_saveRole权限或管理员权限") 44 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 45 | @RequestMapping(value="/role",method=RequestMethod.POST) 46 | @RequiresPermissions(value={"role_saveRole","administrator"},logical=Logical.OR) 47 | public Message saveRole(RoleSaveVM role){ 48 | roleService.saveRole(role); 49 | return Message.ok(Constants.SUCCESS); 50 | } 51 | 52 | @ApiImplicitParams({ 53 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 54 | }) 55 | @ApiOperation(value="删除角色",notes="删除角色,需要role_deleteRole 权限或管理员权限") 56 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 57 | @RequestMapping(value="/role/{roleId}",method=RequestMethod.DELETE) 58 | @RequiresPermissions(value={"role_deleteRole","administrator"},logical=Logical.OR) 59 | public Message deleteRole(@PathVariable("roleId")String roleId){ 60 | roleService.deleteRole(roleId); 61 | return Message.ok(roleId); 62 | } 63 | 64 | @ApiImplicitParams({ 65 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 66 | }) 67 | @ApiOperation(value="修改角色",notes="修改角色,需要 role_updateRole权限或管理员权限") 68 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 69 | @RequiresPermissions(value={"role_updateRole","administrator"},logical=Logical.OR) 70 | @RequestMapping(value="/role",method=RequestMethod.PUT) 71 | public MessageupdateRole(RoleUpdateVM roleUpdateVM){ 72 | roleService.updateRole(roleUpdateVM); 73 | return Message.ok(Constants.SUCCESS); 74 | } 75 | 76 | @ApiImplicitParams({ 77 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 78 | }) 79 | @ApiOperation(value="查询角色列表",notes="查询角色列表,需要role_getRoleList权限或管理员权限") 80 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 81 | @RequiresPermissions(value={"role_getRoleList","administrator"},logical=Logical.OR) 82 | @RequestMapping(value="/role",method=RequestMethod.GET) 83 | public Message>getRoleList(){ 84 | List roleList=roleService.getRoleList(); 85 | return Message.ok(roleList); 86 | } 87 | 88 | @ApiImplicitParams({ 89 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 90 | }) 91 | @ApiOperation(value="给角色授权",notes="给角色授权,需要role_authorize权限或管理员权限") 92 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 93 | @RequiresPermissions(value={"role_authorize","administrator"},logical=Logical.OR) 94 | @RequestMapping(value="/role/authorize",method=RequestMethod.POST) 95 | public Message authorize(RoleResourceVM roleResource){ 96 | roleService.authorize(roleResource); 97 | return Message.ok(Constants.SUCCESS); 98 | } 99 | 100 | @ApiImplicitParams({ 101 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 102 | }) 103 | @ApiOperation(value="校验code唯一性",notes="校验code唯一性,需要role_isExist权限或管理员权限") 104 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 105 | @RequiresPermissions(value={"role_isExist","administrator"},logical=Logical.OR) 106 | @RequestMapping(value="/role/isExist",method=RequestMethod.GET) 107 | public Message isExist(@RequestParam(value="code")String code){ 108 | Boolean isExist=roleService.isExist(code); 109 | return Message.ok(isExist); 110 | } 111 | 112 | @ApiImplicitParams({ 113 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 114 | }) 115 | @ApiOperation(value="得到某角色拥有的资源",notes="校验code唯一性,需要role_isExist权限或管理员权限") 116 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 117 | @RequiresPermissions(value={"role_getRoleResource","administrator"},logical=Logical.OR) 118 | @RequestMapping(value="/role/getRoleResource",method=RequestMethod.GET) 119 | public Message>getRoleResource(String roleId){ 120 | ListroleIds=new ArrayList<>();roleIds.add(roleId); 121 | Listlist=roleResourceService.getResource(roleIds); 122 | return Message.ok(list); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.controller; 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 io.swagger.annotations.ApiResponse; 8 | import io.swagger.annotations.ApiResponses; 9 | 10 | import java.util.List; 11 | 12 | import org.apache.shiro.authz.annotation.Logical; 13 | import org.apache.shiro.authz.annotation.RequiresPermissions; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.PathVariable; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RequestMethod; 19 | import org.springframework.web.bind.annotation.RequestParam; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import com.melo.focus.domain.basic.User; 23 | import com.melo.focus.domain.vm.UserRoleSaveVMS; 24 | import com.melo.focus.domain.vm.UserSaveVM; 25 | import com.melo.focus.domain.vm.UserUpdateVM; 26 | import com.melo.focus.service.UserRoleService; 27 | import com.melo.focus.service.UserService; 28 | import com.melo.focus.util.Constants; 29 | import com.melo.focus.util.Message; 30 | 31 | @Api(description="对用户操作") 32 | @RestController 33 | public class UserController { 34 | 35 | @Autowired 36 | UserService userService; 37 | 38 | @Autowired 39 | UserRoleService userRoleService; 40 | 41 | @ApiImplicitParams({ 42 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 43 | }) 44 | @ApiOperation(value="新增用户",notes="新增用户,需要 user_saveUser权限或管理员权限") 45 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 46 | @RequiresPermissions(value={"user_saveUser","administrator"},logical=Logical.OR) 47 | @RequestMapping(value="/focus/user",method=RequestMethod.POST) 48 | public Message saveUser(UserSaveVM user){ 49 | userService.saveUser(user); 50 | return Message.ok(Constants.SUCCESS); 51 | } 52 | 53 | @ApiImplicitParams({ 54 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 55 | }) 56 | @ApiOperation(value="修改用户",notes="修改用户,需要user_updateUser 权限或管理员权限") 57 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 58 | @RequiresPermissions(value={"user_updateUser","administrator"},logical=Logical.OR) 59 | @RequestMapping(value="/focus/user",method=RequestMethod.PUT) 60 | public Message updateUser(UserUpdateVM user){ 61 | userService.updateUser(user); 62 | return Message.ok(Constants.SUCCESS); 63 | } 64 | 65 | @ApiImplicitParams({ 66 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 67 | }) 68 | @ApiOperation(value="删除用户",notes="删除用户,需要 user_deleteUser权限或管理员权限") 69 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 70 | @RequiresPermissions(value={"user_deleteUser","administrator"},logical=Logical.OR) 71 | @RequestMapping(value="/focus/user/{id}",method=RequestMethod.DELETE) 72 | public Message deleteUser(@PathVariable("id")String id){ 73 | userService.deleteUser(id); 74 | return Message.ok(Constants.SUCCESS); 75 | 76 | } 77 | 78 | @ApiImplicitParams({ 79 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 80 | }) 81 | @ApiOperation(value="将角色授予用户",notes="将角色授予用户,需要 user_delegate权限或管理员权限") 82 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 83 | @RequiresPermissions(value={"user_delegate","administrator"},logical=Logical.OR) 84 | @RequestMapping(value="/focus/user/delegate",method=RequestMethod.POST) 85 | public Message delegate(UserRoleSaveVMS userRoleVMS){ 86 | userRoleService.delegate(userRoleVMS); 87 | return Message.ok(Constants.SUCCESS); 88 | } 89 | 90 | @ApiImplicitParams({ 91 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 92 | }) 93 | @ApiOperation(value="查所有用户",notes="查所有用户,需要 user_findAllUser权限或管理员权限") 94 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 95 | @RequiresPermissions(value={"user_findAllUser","administrator"},logical=Logical.OR) 96 | @RequestMapping(value="/focus/user",method=RequestMethod.GET) 97 | public Message> findAllUser(){ 98 | List userList=userService.findAllUser(); 99 | return Message.ok(userList); 100 | } 101 | 102 | @ApiImplicitParams({ 103 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 104 | }) 105 | @ApiOperation(value="校验用户名唯一性,账号",notes="校验用户名唯一性,需要 user_isExist权限或管理员权限") 106 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 107 | @RequiresPermissions(value={"user_isExist","administrator"},logical=Logical.OR) 108 | @RequestMapping(value="/focus/user/isExist",method=RequestMethod.GET) 109 | public Message isExist(/*@RequestParam(value="loginName")*/String loginName){ 110 | return Message.ok(userService.isExist(loginName)); 111 | } 112 | 113 | @ApiImplicitParams({ 114 | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "string", paramType = "header") 115 | }) 116 | @ApiOperation(value="查单个用户所拥有的角色id",notes="查单个用户所拥有的角色id,需要 user_getRoleByUser权限或管理员权限") 117 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) 118 | @RequiresPermissions(value={"user_getRoleByUser","administrator"},logical=Logical.OR) 119 | @RequestMapping(value="/focus/user/getRoleByUser",method=RequestMethod.GET) 120 | public Message>getRoleByUser(@RequestParam(value="userId")String userId){ 121 | return Message.ok(userRoleService.getRoleByUser(userId)); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/Authority.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class Authority { 4 | private String id; 5 | 6 | private String name; 7 | 8 | private String code; 9 | 10 | private String url; 11 | 12 | private String method; 13 | 14 | private String controller; 15 | 16 | private String des; 17 | 18 | public String getId() { 19 | return id; 20 | } 21 | 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public String getCode() { 35 | return code; 36 | } 37 | 38 | public void setCode(String code) { 39 | this.code = code; 40 | } 41 | 42 | public String getUrl() { 43 | return url; 44 | } 45 | 46 | public void setUrl(String url) { 47 | this.url = url; 48 | } 49 | 50 | public String getMethod() { 51 | return method; 52 | } 53 | 54 | public void setMethod(String method) { 55 | this.method = method; 56 | } 57 | 58 | public String getController() { 59 | return controller; 60 | } 61 | 62 | public void setController(String controller) { 63 | this.controller = controller; 64 | } 65 | 66 | public String getDes() { 67 | return des; 68 | } 69 | 70 | public void setDes(String des) { 71 | this.des = des; 72 | } 73 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/Resource.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class Resource { 4 | private String id; 5 | 6 | private String name; 7 | 8 | private Byte type; 9 | 10 | private String code; 11 | 12 | private String pid; 13 | 14 | private String des; 15 | 16 | private Byte sort; 17 | 18 | private String path;//path可以方便的查 某个节点下的所有数据,省去递归,但树封装还得自己做。 19 | 20 | private String menuRoute; 21 | 22 | public String getMenuRoute() { 23 | return menuRoute; 24 | } 25 | 26 | public void setMenuRoute(String menuRoute) { 27 | this.menuRoute = menuRoute; 28 | } 29 | 30 | public String getPath() { 31 | return path; 32 | } 33 | 34 | public void setPath(String path) { 35 | this.path = path; 36 | } 37 | 38 | public String getId() { 39 | return id; 40 | } 41 | 42 | public void setId(String id) { 43 | this.id = id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | public void setName(String name) { 51 | this.name = name; 52 | } 53 | 54 | public Byte getType() { 55 | return type; 56 | } 57 | 58 | public void setType(Byte type) { 59 | this.type = type; 60 | } 61 | 62 | public String getCode() { 63 | return code; 64 | } 65 | 66 | public void setCode(String code) { 67 | this.code = code; 68 | } 69 | 70 | public String getPid() { 71 | return pid; 72 | } 73 | 74 | public void setPid(String pid) { 75 | this.pid = pid; 76 | } 77 | 78 | public String getDes() { 79 | return des; 80 | } 81 | 82 | public void setDes(String des) { 83 | this.des = des; 84 | } 85 | 86 | public Byte getSort() { 87 | return sort; 88 | } 89 | 90 | public void setSort(Byte sort) { 91 | this.sort = sort; 92 | } 93 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/ResourceAuthority.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class ResourceAuthority { 4 | private String id; 5 | 6 | private String resourceId; 7 | 8 | private String authorityId; 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | 18 | public String getResourceId() { 19 | return resourceId; 20 | } 21 | 22 | public void setResourceId(String resourceId) { 23 | this.resourceId = resourceId; 24 | } 25 | 26 | public String getAuthorityId() { 27 | return authorityId; 28 | } 29 | 30 | public void setAuthorityId(String authorityId) { 31 | this.authorityId = authorityId; 32 | } 33 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/Role.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class Role implements Comparable{ 4 | private String id; 5 | 6 | private String name; 7 | 8 | private String code; 9 | 10 | private Byte sort; 11 | 12 | private Byte type; 13 | 14 | private String des; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getCode() { 33 | return code; 34 | } 35 | 36 | public void setCode(String code) { 37 | this.code = code; 38 | } 39 | 40 | public Byte getSort() { 41 | return sort; 42 | } 43 | 44 | public void setSort(Byte sort) { 45 | this.sort = sort; 46 | } 47 | 48 | public Byte getType() { 49 | return type; 50 | } 51 | 52 | public void setType(Byte type) { 53 | this.type = type; 54 | } 55 | 56 | public String getDes() { 57 | return des; 58 | } 59 | 60 | public void setDes(String des) { 61 | this.des = des; 62 | } 63 | 64 | @Override 65 | public int compareTo(Role o) { 66 | return this.getSort().compareTo(o.getSort()); 67 | } 68 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/RoleBusiness.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class RoleBusiness { 4 | private String id; 5 | 6 | private String roleId; 7 | 8 | private String classPk; 9 | 10 | private String className; 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getRoleId() { 21 | return roleId; 22 | } 23 | 24 | public void setRoleId(String roleId) { 25 | this.roleId = roleId; 26 | } 27 | 28 | public String getClassPk() { 29 | return classPk; 30 | } 31 | 32 | public void setClassPk(String classPk) { 33 | this.classPk = classPk; 34 | } 35 | 36 | public String getClassName() { 37 | return className; 38 | } 39 | 40 | public void setClassName(String className) { 41 | this.className = className; 42 | } 43 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/RoleResourcer.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class RoleResourcer { 4 | private String id; 5 | 6 | private String roleId; 7 | 8 | private String resourceId; 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | 18 | public String getRoleId() { 19 | return roleId; 20 | } 21 | 22 | public void setRoleId(String roleId) { 23 | this.roleId = roleId; 24 | } 25 | 26 | public String getResourceId() { 27 | return resourceId; 28 | } 29 | 30 | public void setResourceId(String resourceId) { 31 | this.resourceId = resourceId; 32 | } 33 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/User.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | private String id; 7 | 8 | private String loginName; 9 | 10 | private String realName; 11 | 12 | private String password; 13 | 14 | private Boolean superman; 15 | 16 | public Boolean getSuperman() { 17 | return superman; 18 | } 19 | 20 | public void setSuperman(Boolean superman) { 21 | this.superman = superman; 22 | } 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getLoginName() { 33 | return loginName; 34 | } 35 | 36 | public void setLoginName(String loginName) { 37 | this.loginName = loginName; 38 | } 39 | 40 | public String getRealName() { 41 | return realName; 42 | } 43 | 44 | public void setRealName(String realName) { 45 | this.realName = realName; 46 | } 47 | 48 | public String getPassword() { 49 | return password; 50 | } 51 | 52 | public void setPassword(String password) { 53 | this.password = password; 54 | } 55 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/basic/UserRoleR.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.basic; 2 | 3 | public class UserRoleR { 4 | 5 | private String id; 6 | 7 | private String userId; 8 | 9 | private String roleId; 10 | 11 | private String ywId; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public String getUserId() { 22 | return userId; 23 | } 24 | 25 | public void setUserId(String userId) { 26 | this.userId = userId; 27 | } 28 | 29 | public String getRoleId() { 30 | return roleId; 31 | } 32 | 33 | public void setRoleId(String roleId) { 34 | this.roleId = roleId; 35 | } 36 | 37 | public String getYwId() { 38 | return ywId; 39 | } 40 | 41 | public void setYwId(String ywId) { 42 | this.ywId = ywId; 43 | } 44 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/extend/AuthorityController.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.extend; 2 | 3 | import java.util.List; 4 | 5 | import com.melo.focus.domain.basic.Authority; 6 | 7 | public class AuthorityController { 8 | 9 | private String controller; 10 | 11 | List authorityList; 12 | 13 | public String getController() { 14 | return controller; 15 | } 16 | 17 | public void setController(String controller) { 18 | this.controller = controller; 19 | } 20 | 21 | public List getAuthorityList() { 22 | return authorityList; 23 | } 24 | 25 | public void setAuthorityList(List authorityList) { 26 | this.authorityList = authorityList; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/AuthoritySaveVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | @ApiModel("新增权限VM") 9 | public class AuthoritySaveVM { 10 | 11 | @ApiModelProperty("名称") 12 | @NotBlank 13 | private String name; 14 | 15 | @ApiModelProperty("操作码") 16 | @NotBlank 17 | private String code; 18 | 19 | @ApiModelProperty("url") 20 | @NotBlank 21 | private String url; 22 | 23 | @ApiModelProperty("请求方式") 24 | @NotBlank 25 | private String method; 26 | 27 | @ApiModelProperty("controller") 28 | @NotBlank 29 | private String controller; 30 | 31 | @ApiModelProperty("描述") 32 | private String des; 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public String getCode() { 43 | return code; 44 | } 45 | 46 | public void setCode(String code) { 47 | this.code = code; 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url; 56 | } 57 | 58 | public String getMethod() { 59 | return method; 60 | } 61 | 62 | public void setMethod(String method) { 63 | this.method = method; 64 | } 65 | 66 | public String getController() { 67 | return controller; 68 | } 69 | 70 | public void setController(String controller) { 71 | this.controller = controller; 72 | } 73 | 74 | public String getDes() { 75 | return des; 76 | } 77 | 78 | public void setDes(String des) { 79 | this.des = des; 80 | } 81 | 82 | 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/AuthorityUpdateVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | @ApiModel("修改权限VM") 9 | public class AuthorityUpdateVM { 10 | 11 | @NotBlank 12 | private String id; 13 | 14 | @ApiModelProperty("名称") 15 | @NotBlank 16 | private String name; 17 | 18 | @ApiModelProperty("操作码") 19 | @NotBlank 20 | private String code; 21 | 22 | @ApiModelProperty("url") 23 | @NotBlank 24 | private String url; 25 | 26 | @ApiModelProperty("请求方式") 27 | @NotBlank 28 | private String method; 29 | 30 | @ApiModelProperty("controller") 31 | @NotBlank 32 | private String controller; 33 | 34 | @ApiModelProperty("描述") 35 | private String des; 36 | } 37 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/AuthorityVMS.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import java.util.List; 4 | 5 | import com.melo.focus.domain.basic.Authority; 6 | 7 | public class AuthorityVMS { 8 | 9 | private String controller; 10 | 11 | List authorityList; 12 | 13 | public String getController() { 14 | return controller; 15 | } 16 | 17 | public void setController(String controller) { 18 | this.controller = controller; 19 | } 20 | 21 | public List getAuthorityList() { 22 | return authorityList; 23 | } 24 | 25 | public void setAuthorityList(List authorityList) { 26 | this.authorityList = authorityList; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/ResourceAuthorityVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import java.util.List; 4 | 5 | import com.melo.focus.domain.basic.ResourceAuthority; 6 | 7 | 8 | public class ResourceAuthorityVM { 9 | 10 | ListresourceAuthorityList; 11 | 12 | public List getResourceAuthorityList() { 13 | return resourceAuthorityList; 14 | } 15 | 16 | public void setResourceAuthorityList( 17 | List resourceAuthorityList) { 18 | this.resourceAuthorityList = resourceAuthorityList; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/ResourceSaveVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.validation.constraints.Max; 7 | import javax.validation.constraints.Min; 8 | import javax.validation.constraints.NotNull; 9 | 10 | import org.hibernate.validator.constraints.NotBlank; 11 | 12 | @ApiModel(value="新增资源vm") 13 | public class ResourceSaveVM { 14 | 15 | @ApiModelProperty(value="资源名") 16 | @NotBlank 17 | private String name; 18 | 19 | @NotNull 20 | @Max(3) 21 | @Min(1) 22 | @ApiModelProperty(value="资源类型") 23 | private Byte type; 24 | 25 | @NotBlank 26 | @ApiModelProperty(value="资源code码") 27 | private String code; 28 | 29 | @ApiModelProperty(value="父资源code") 30 | @NotBlank 31 | private String parentCode; 32 | 33 | @ApiModelProperty(value="描述") 34 | private String des; 35 | 36 | @ApiModelProperty(value="序号") 37 | @NotNull 38 | @Max(99) 39 | private Byte sort; 40 | 41 | private String menuRoute; 42 | 43 | public String getMenuRoute() { 44 | return menuRoute; 45 | } 46 | 47 | public void setMenuRoute(String menuRoute) { 48 | this.menuRoute = menuRoute; 49 | } 50 | 51 | public String getName() { 52 | return name; 53 | } 54 | 55 | public void setName(String name) { 56 | this.name = name; 57 | } 58 | 59 | public Byte getType() { 60 | return type; 61 | } 62 | 63 | public void setType(Byte type) { 64 | this.type = type; 65 | } 66 | 67 | public String getCode() { 68 | return code; 69 | } 70 | 71 | public void setCode(String code) { 72 | this.code = code; 73 | } 74 | 75 | public String getParentCode() { 76 | return parentCode; 77 | } 78 | 79 | public void setParentCode(String parentCode) { 80 | this.parentCode = parentCode; 81 | } 82 | 83 | public String getDes() { 84 | return des; 85 | } 86 | 87 | public void setDes(String des) { 88 | this.des = des; 89 | } 90 | 91 | public Byte getSort() { 92 | return sort; 93 | } 94 | 95 | public void setSort(Byte sort) { 96 | this.sort = sort; 97 | } 98 | 99 | 100 | } 101 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/ResourceUpdateVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.validation.constraints.Max; 7 | import javax.validation.constraints.Min; 8 | import javax.validation.constraints.NotNull; 9 | 10 | import org.hibernate.validator.constraints.NotBlank; 11 | @ApiModel("修改资源VM") 12 | public class ResourceUpdateVM { 13 | @NotBlank 14 | private String id; 15 | 16 | @ApiModelProperty(value="资源名") 17 | @NotBlank 18 | private String name; 19 | 20 | @NotNull 21 | @Max(3) 22 | @Min(1) 23 | @ApiModelProperty(value="资源类型") 24 | private Byte type; 25 | 26 | @NotBlank 27 | @ApiModelProperty(value="资源code码") 28 | private String code; 29 | 30 | @ApiModelProperty(value="路径") 31 | private String path; 32 | 33 | @ApiModelProperty(value="父资源code") 34 | @NotBlank 35 | private String parentCode; 36 | 37 | @ApiModelProperty(value="描述") 38 | private String des; 39 | 40 | @ApiModelProperty(value="序号") 41 | @NotNull 42 | @Max(99) 43 | private Byte sort; 44 | 45 | private String menuRoute; 46 | 47 | public String getMenuRoute() { 48 | return menuRoute; 49 | } 50 | 51 | public void setMenuRoute(String menuRoute) { 52 | this.menuRoute = menuRoute; 53 | } 54 | 55 | public String getId() { 56 | return id; 57 | } 58 | 59 | public void setId(String id) { 60 | this.id = id; 61 | } 62 | 63 | public String getName() { 64 | return name; 65 | } 66 | 67 | public void setName(String name) { 68 | this.name = name; 69 | } 70 | 71 | public Byte getType() { 72 | return type; 73 | } 74 | 75 | public void setType(Byte type) { 76 | this.type = type; 77 | } 78 | 79 | public String getCode() { 80 | return code; 81 | } 82 | 83 | public void setCode(String code) { 84 | this.code = code; 85 | } 86 | 87 | public String getPath() { 88 | return path; 89 | } 90 | 91 | public void setPath(String path) { 92 | this.path = path; 93 | } 94 | 95 | public String getParentCode() { 96 | return parentCode; 97 | } 98 | 99 | public void setParentCode(String parentCode) { 100 | this.parentCode = parentCode; 101 | } 102 | 103 | public String getDes() { 104 | return des; 105 | } 106 | 107 | public void setDes(String des) { 108 | this.des = des; 109 | } 110 | 111 | public Byte getSort() { 112 | return sort; 113 | } 114 | 115 | public void setSort(Byte sort) { 116 | this.sort = sort; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/ResourceVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import java.util.List; 4 | 5 | public class ResourceVM { 6 | 7 | private String id; 8 | 9 | private String name; 10 | 11 | private Byte type; 12 | 13 | private String code; 14 | 15 | private String pid; 16 | 17 | private String des; 18 | 19 | private Byte sort; 20 | 21 | private String path; 22 | 23 | private String menuRoute; 24 | 25 | private Listchildren; 26 | 27 | public String getMenuRoute() { 28 | return menuRoute; 29 | } 30 | 31 | public void setMenuRoute(String menuRoute) { 32 | this.menuRoute = menuRoute; 33 | } 34 | 35 | public String getPath() { 36 | return path; 37 | } 38 | 39 | public void setPath(String path) { 40 | this.path = path; 41 | } 42 | 43 | public String getId() { 44 | return id; 45 | } 46 | 47 | public void setId(String id) { 48 | this.id = id; 49 | } 50 | 51 | public String getName() { 52 | return name; 53 | } 54 | 55 | public void setName(String name) { 56 | this.name = name; 57 | } 58 | 59 | public Byte getType() { 60 | return type; 61 | } 62 | 63 | public void setType(Byte type) { 64 | this.type = type; 65 | } 66 | 67 | public String getCode() { 68 | return code; 69 | } 70 | 71 | public void setCode(String code) { 72 | this.code = code; 73 | } 74 | 75 | public String getPid() { 76 | return pid; 77 | } 78 | 79 | public void setPid(String pid) { 80 | this.pid = pid; 81 | } 82 | 83 | public String getDes() { 84 | return des; 85 | } 86 | 87 | public void setDes(String des) { 88 | this.des = des; 89 | } 90 | 91 | public Byte getSort() { 92 | return sort; 93 | } 94 | 95 | public void setSort(Byte sort) { 96 | this.sort = sort; 97 | } 98 | 99 | public List getChildren() { 100 | return children; 101 | } 102 | 103 | public void setChildren(List children) { 104 | this.children = children; 105 | } 106 | 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/RoleResourceVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import java.util.List; 7 | 8 | import javax.validation.constraints.NotNull; 9 | 10 | @ApiModel(value="给角色授权") 11 | public class RoleResourceVM { 12 | 13 | @ApiModelProperty("角色id集") 14 | @NotNull 15 | String roleIds; 16 | 17 | @ApiModelProperty("资源id集") 18 | @NotNull 19 | String resourceIds; 20 | 21 | public String getRoleIds() { 22 | return roleIds; 23 | } 24 | 25 | public void setRoleIds(String roleIds) { 26 | this.roleIds = roleIds; 27 | } 28 | 29 | public String getResourceIds() { 30 | return resourceIds; 31 | } 32 | 33 | public void setResourceIds(String resourceIds) { 34 | this.resourceIds = resourceIds; 35 | } 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/RoleSaveVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import javax.validation.constraints.Max; 4 | import javax.validation.constraints.Min; 5 | import javax.validation.constraints.NotNull; 6 | import javax.validation.constraints.Size; 7 | 8 | import org.hibernate.validator.constraints.NotBlank; 9 | 10 | public class RoleSaveVM { 11 | 12 | @NotBlank 13 | private String name; 14 | 15 | @NotBlank 16 | private String code; 17 | 18 | @NotNull 19 | @Max(100) 20 | @Min(1) 21 | private Byte sort; 22 | 23 | @NotNull 24 | @Max(3) 25 | @Min(1) 26 | private Byte type;// 27 | 28 | private String des; 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public String getCode() { 39 | return code; 40 | } 41 | 42 | public void setCode(String code) { 43 | this.code = code; 44 | } 45 | 46 | public Byte getSort() { 47 | return sort; 48 | } 49 | 50 | public void setSort(Byte sort) { 51 | this.sort = sort; 52 | } 53 | 54 | public Byte getType() { 55 | return type; 56 | } 57 | 58 | public void setType(Byte type) { 59 | this.type = type; 60 | } 61 | 62 | public String getDes() { 63 | return des; 64 | } 65 | 66 | public void setDes(String des) { 67 | this.des = des; 68 | } 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/RoleUpdateVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | import javax.validation.constraints.Max; 6 | import javax.validation.constraints.Min; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import org.hibernate.validator.constraints.Length; 10 | import org.hibernate.validator.constraints.NotBlank; 11 | 12 | @ApiModel("角色修改VM") 13 | public class RoleUpdateVM { 14 | @NotBlank 15 | private String id; 16 | 17 | @NotBlank 18 | private String name; 19 | 20 | @NotBlank 21 | @Length(max=20) 22 | private String code; 23 | 24 | @NotNull 25 | @Max(99) 26 | @Min(1) 27 | private Byte sort; 28 | 29 | @Max(3) 30 | @Min(1) 31 | private Byte type;// 32 | 33 | private String des; 34 | 35 | public String getId() { 36 | return id; 37 | } 38 | 39 | public void setId(String id) { 40 | this.id = id; 41 | } 42 | 43 | public String getName() { 44 | return name; 45 | } 46 | 47 | public void setName(String name) { 48 | this.name = name; 49 | } 50 | 51 | public String getCode() { 52 | return code; 53 | } 54 | 55 | public void setCode(String code) { 56 | this.code = code; 57 | } 58 | 59 | public Byte getSort() { 60 | return sort; 61 | } 62 | 63 | public void setSort(Byte sort) { 64 | this.sort = sort; 65 | } 66 | 67 | public Byte getType() { 68 | return type; 69 | } 70 | 71 | public void setType(Byte type) { 72 | this.type = type; 73 | } 74 | 75 | public String getDes() { 76 | return des; 77 | } 78 | 79 | public void setDes(String des) { 80 | this.des = des; 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/UserRoleSaveVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | @ApiModel("新增用户角色关系VM") 7 | public class UserRoleSaveVM { 8 | 9 | @ApiModelProperty(value = "用户id") 10 | private String userId; 11 | 12 | @ApiModelProperty(value = "角色id") 13 | private String roleId; 14 | 15 | public String getUserId() { 16 | return userId; 17 | } 18 | 19 | public void setUserId(String userId) { 20 | this.userId = userId; 21 | } 22 | 23 | public String getRoleId() { 24 | return roleId; 25 | } 26 | 27 | public void setRoleId(String roleId) { 28 | this.roleId = roleId; 29 | } 30 | 31 | //这里不需要有业务,新增业务角色应该单独写接口 32 | //@ApiModelProperty(value = "业务角色id") 33 | //private String ywId; 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/UserRoleSaveVMS.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | import org.hibernate.validator.constraints.NotBlank; 6 | 7 | @ApiModel("批量新增用户角色关系VM") 8 | public class UserRoleSaveVMS { 9 | 10 | @NotBlank 11 | private String userId; 12 | @NotBlank 13 | private String roleIds; 14 | 15 | public String getUserId() { 16 | return userId; 17 | } 18 | 19 | public void setUserId(String userId) { 20 | this.userId = userId; 21 | } 22 | 23 | public String getRoleIds() { 24 | return roleIds; 25 | } 26 | 27 | public void setRoleIds(String roleIds) { 28 | this.roleIds = roleIds; 29 | } 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/UserSaveVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | 9 | 10 | @ApiModel("新增用户VM") 11 | public class UserSaveVM { 12 | 13 | @ApiModelProperty(value = "用户登录名") 14 | @NotBlank 15 | private String loginName; 16 | 17 | @ApiModelProperty(value = "用户真实姓名") 18 | @NotBlank 19 | private String realName; 20 | 21 | @ApiModelProperty(value = "密码") 22 | @NotBlank 23 | private String password; 24 | 25 | 26 | public String getLoginName() { 27 | return loginName; 28 | } 29 | 30 | public void setLoginName(String loginName) { 31 | this.loginName = loginName; 32 | } 33 | 34 | public String getRealName() { 35 | return realName; 36 | } 37 | 38 | public void setRealName(String realName) { 39 | this.realName = realName; 40 | } 41 | 42 | public String getPassword() { 43 | return password; 44 | } 45 | 46 | public void setPassword(String password) { 47 | this.password = password; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/domain/vm/UserUpdateVM.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.domain.vm; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import org.hibernate.validator.constraints.NotBlank; 7 | @ApiModel("修改用户VM") 8 | public class UserUpdateVM { 9 | 10 | @ApiModelProperty(value = "id") 11 | @NotBlank 12 | private String id; 13 | 14 | @ApiModelProperty(value = "用户登录名") 15 | @NotBlank 16 | private String loginName; 17 | 18 | @ApiModelProperty(value = "用户真实姓名") 19 | @NotBlank 20 | private String realName; 21 | 22 | @ApiModelProperty(value = "密码") 23 | @NotBlank 24 | private String password; 25 | 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | public void setId(String id) { 31 | this.id = id; 32 | } 33 | 34 | public String getLoginName() { 35 | return loginName; 36 | } 37 | 38 | public void setLoginName(String loginName) { 39 | this.loginName = loginName; 40 | } 41 | 42 | public String getRealName() { 43 | return realName; 44 | } 45 | 46 | public void setRealName(String realName) { 47 | this.realName = realName; 48 | } 49 | 50 | public String getPassword() { 51 | return password; 52 | } 53 | 54 | public void setPassword(String password) { 55 | this.password = password; 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.exception; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.web.bind.annotation.ControllerAdvice; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | import com.melo.focus.util.DataValidateFiledException; 10 | import com.melo.focus.util.Message; 11 | 12 | @ControllerAdvice//@ControllerAdvice拦截异常 13 | @ResponseBody 14 | public class GlobalExceptionHandler { 15 | 16 | /** 17 | * 所有异常报错 18 | * @param request 19 | * @param exception 20 | * @return 21 | * @throws Exception 22 | */ 23 | 24 | //@ExceptionHandler指定处理哪种异常(可指定多个) 25 | @ExceptionHandler(value=DataValidateFiledException.class) 26 | public Message allExceptionHandler(HttpServletRequest request, 27 | DataValidateFiledException exception) throws Exception { 28 | 29 | String string = exception.toString(); 30 | return Message.ok(string,500); 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/AuthorityMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import com.melo.focus.domain.basic.Authority; 4 | 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Mapper; 8 | @Mapper 9 | public interface AuthorityMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(Authority record); 13 | 14 | Authority selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(Authority record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/ResourceAuthorityMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import com.melo.focus.domain.basic.ResourceAuthority; 4 | 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Mapper; 8 | @Mapper 9 | public interface ResourceAuthorityMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(ResourceAuthority record); 13 | 14 | ResourceAuthority selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(ResourceAuthority record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/ResourceMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import com.melo.focus.domain.basic.Resource; 4 | 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Mapper; 8 | @Mapper 9 | public interface ResourceMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(Resource record); 13 | 14 | Resource selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(Resource record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/RoleBusinessMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import com.melo.focus.domain.basic.RoleBusiness; 4 | 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Mapper; 8 | @Mapper 9 | public interface RoleBusinessMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(RoleBusiness record); 13 | 14 | RoleBusiness selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(RoleBusiness record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import com.melo.focus.domain.basic.Role; 8 | @Mapper 9 | public interface RoleMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(Role record); 13 | 14 | Role selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(Role record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/RoleResourcerMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import com.melo.focus.domain.basic.RoleResourcer; 4 | 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Mapper; 8 | @Mapper 9 | public interface RoleResourcerMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(RoleResourcer record); 13 | 14 | RoleResourcer selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(RoleResourcer record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import com.melo.focus.domain.basic.User; 8 | @Mapper 9 | public interface UserMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(User record); 13 | 14 | User selectByPrimaryKey(String id); 15 | 16 | List selectAll(); 17 | 18 | int updateByPrimaryKey(User record); 19 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/basic/UserRoleRMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.basic; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import com.melo.focus.domain.basic.UserRoleR; 8 | @Mapper 9 | public interface UserRoleRMapper { 10 | int insert(UserRoleR record); 11 | 12 | List selectAll(); 13 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/AuthorityExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.melo.focus.domain.basic.Authority; 9 | import com.melo.focus.domain.extend.AuthorityController; 10 | 11 | @Mapper 12 | public interface AuthorityExtendMapper { 13 | 14 | /** 15 | * 根据 权限id 查权限对象集 16 | */ 17 | public ListgetAuthorityByIds(@Param(value="ids")Listids); 18 | 19 | /** 20 | * 按controller分组查 操作码列表 21 | */ 22 | public ListgetAuthority(); 23 | 24 | /** 25 | * 根据请求方式,关键字模糊查询 26 | */ 27 | public ListgetLikeAuthority(@Param(value="method")String method,@Param(value="word")String word); 28 | } 29 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/ResourceAuthorityExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.melo.focus.domain.basic.Resource; 9 | 10 | @Mapper 11 | public interface ResourceAuthorityExtendMapper { 12 | 13 | /** 14 | * 根据参数资源 查出其拥有的 权限ids 15 | */ 16 | List getAuthorityByResource(@Param(value="resourceList")List resourceList); 17 | 18 | /** 19 | * 取消授权 20 | * @param resourceId 21 | * @param authorityId 22 | */ 23 | void deleteResourceAuthority( 24 | @Param(value="resourceId")String resourceId, 25 | @Param(value="authorityId")String authorityId); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/ResourceExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.melo.focus.domain.basic.Resource; 9 | @Mapper 10 | public interface ResourceExtendMapper { 11 | 12 | /** 13 | * 根据资源id集,查资源 14 | */ 15 | public List selectByResourceIds(@Param(value="resourceIds")ListresourceIds); 16 | 17 | /** 18 | * 根据 上级资源的code 模糊path 删除 本身及下级资源 19 | */ 20 | public void deleteByPath(@Param(value="code")String code); 21 | 22 | /** 23 | * 根据资源code 查询本身 及 下级所有资源 24 | */ 25 | public List selectByCode(@Param(value="code")String code); 26 | 27 | /** 28 | * 根据资源code 查资源 29 | */ 30 | public Resource getIdByCode(@Param(value="code")String code); 31 | } -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/RoleExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | @Mapper 7 | public interface RoleExtendMapper { 8 | 9 | /** 10 | * 校验角色code唯一性 11 | */ 12 | Boolean isExist(@Param(value="code")String code); 13 | } 14 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/RoleResourceExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.melo.focus.domain.basic.RoleResourcer; 9 | 10 | @Mapper 11 | public interface RoleResourceExtendMapper { 12 | 13 | /** 14 | * 根据roleid 或resourceid 删除角色资源关系 15 | */ 16 | public void deleteRoleResource( 17 | @Param(value="roleId")String roleId, 18 | @Param(value="resourceId")String resourceId); 19 | 20 | /** 21 | * 批量保存 角色资源关系 22 | */ 23 | public void batchInsert(@Param(value="list")List list); 24 | 25 | /** 26 | * 通过roleid得到拥有的resourceid 27 | */ 28 | public List getResourceByRole(@Param(value="roleIds")ListroleIds); 29 | } 30 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/UserExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import com.melo.focus.domain.basic.User; 7 | 8 | 9 | @Mapper 10 | public interface UserExtendMapper { 11 | 12 | User selectByName(@Param(value="account")String account); 13 | 14 | /** 15 | * 校验用户名唯一,账号 16 | */ 17 | Integer isExist(@Param(value="loginName")String loginName); 18 | } 19 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/mapper/extend/UserRoleRExtendMapper.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.mapper.extend; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.melo.focus.domain.basic.UserRoleR; 9 | 10 | @Mapper 11 | public interface UserRoleRExtendMapper { 12 | 13 | /** 14 | * 批量新增用户角色关系 15 | */ 16 | public void batchInsert(@Param(value="userRoleList")List userRoleList); 17 | 18 | /** 19 | * 根据集合中的user对象id,删除这些用户下所有的角色关系 20 | */ 21 | public void deleteByUserId(@Param(value="userIdList")List userIdList); 22 | 23 | /** 24 | * 根据roleId 删除 用户角色关系 25 | */ 26 | public void deleteByRoleId(@Param(value="roleId")String roleId); 27 | 28 | /** 29 | * 根据‘用户id查所拥有的角色 30 | */ 31 | public ListgetRoleByUser(@Param(value="userId")String userId); 32 | } 33 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/realm/MyShiroRealm.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.realm; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.commons.collections.CollectionUtils; 7 | import org.apache.shiro.SecurityUtils; 8 | import org.apache.shiro.authc.AuthenticationException; 9 | import org.apache.shiro.authc.AuthenticationInfo; 10 | import org.apache.shiro.authc.AuthenticationToken; 11 | import org.apache.shiro.authc.SimpleAuthenticationInfo; 12 | import org.apache.shiro.authc.UsernamePasswordToken; 13 | import org.apache.shiro.authz.AuthorizationInfo; 14 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 15 | import org.apache.shiro.realm.AuthorizingRealm; 16 | import org.apache.shiro.subject.PrincipalCollection; 17 | import org.redisson.api.RedissonClient; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | 20 | import com.melo.focus.domain.basic.Authority; 21 | import com.melo.focus.domain.basic.Resource; 22 | import com.melo.focus.domain.basic.User; 23 | import com.melo.focus.service.AuthorityService; 24 | import com.melo.focus.service.ResourceAuthorityService; 25 | import com.melo.focus.service.ResourceService; 26 | import com.melo.focus.service.UserService; 27 | import com.melo.focus.util.Constants; 28 | 29 | 30 | public class MyShiroRealm extends AuthorizingRealm{ 31 | 32 | Boolean cachingEnabled=true; 33 | 34 | @Autowired 35 | UserService userService; 36 | 37 | @Autowired 38 | ResourceService resourceService; 39 | 40 | @Autowired 41 | RedissonClient redissonClient; 42 | 43 | @Autowired 44 | ResourceAuthorityService resourceAuthorityService; 45 | 46 | @Autowired 47 | AuthorityService authorityService; 48 | 49 | /** 50 | * 1.授权方法,在请求需要操作码的接口时会执行此方法。不需要操作码的接口不会执行 51 | * 2.实际上是 先执行 AuthorizingRealm,自定义realm的父类中的 getAuthorizationInfo方法, 52 | * 逻辑是先判断缓存中是否有用户的授权信息(用户拥有的操作码),如果有 就直返回不调用自定义 realm的授权方法了, 53 | * 如果没缓存,再调用自定义realm,去数据库查询。 54 | * 用库查询一次过后,如果 在安全管理器中注入了 缓存,授权信息就会自动保存在缓存中,下一次调用需要操作码的接口时, 55 | * 就肯定不会再调用自定义realm授权方法了。 网上有分析AuthorizingRealm,shiro使用缓存的过程 56 | * 3.AuthorizingRealm 有多个实现类realm,推测可能是把 自定义realm注入了安全管理器,所以才调用自定义的 57 | */ 58 | @Override 59 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 60 | SimpleAuthorizationInfo simpleAuthorInfo = new SimpleAuthorizationInfo(); 61 | 62 | User user = (User)principals.getPrimaryPrincipal(); 63 | //这应该把查出来的无序菜单手动放到缓存 64 | List resourceList; 65 | if(user.getSuperman()){//超管 66 | resourceList =resourceService.getAll(); 67 | simpleAuthorInfo.addStringPermission("administrator"); 68 | 69 | //List list=new ArrayList<>(); 70 | //list.add("ACTUATOR"); 71 | //simpleAuthorInfo.addRoles(list);//actuator监控 后提示需要加这个角色才能访问/beans等端点 72 | }else{ 73 | resourceList = resourceService.getResourceByUserId(user.getId()); 74 | ListresourceIds=new ArrayList<>(); 75 | for(Resource reousrce:resourceList){ 76 | resourceIds.add(reousrce.getId()); 77 | } 78 | List authorityIds = resourceAuthorityService.getAuthorityByResource(resourceIds); 79 | List authorityList = authorityService.getAuthorityByIds(authorityIds); 80 | if(CollectionUtils.isNotEmpty(authorityIds)){ 81 | for(Authority authority:authorityList){ 82 | simpleAuthorInfo.addStringPermission(authority.getCode()); 83 | } 84 | } 85 | } 86 | if(CollectionUtils.isNotEmpty(resourceList)){redissonClient.getMapCache(Constants.REDIS_RESOURCE).put(user.getId(), resourceList);} 87 | 88 | //simpleAuthorInfo.addStringPermission("how_are_you"); 89 | System.out.println("经试验:并不是每次调用接口就会执行,而是调用需要操作码(permission)的接口就会执行"); 90 | return simpleAuthorInfo; 91 | } 92 | 93 | /** 94 | * 1.和授权方法一样,AuthenticatingRealm的getAuthenticationInfo,先判断缓存是否有认证信息,没有就调用 95 | * 但试验,登录之后,再次登录,发现还是调用了认证方法,说明第一次认证登录时,没有将认证信息存到缓存中。不像授权信息, 96 | * 将缓存注入安全管理器,就自动保存了授权信息。 难道无法 防止故意多次登录 ,按理说不应该啊? 97 | * 2 可以在登录controller简单用session是否有key 判断是否登录? 98 | */ 99 | @Override 100 | protected AuthenticationInfo doGetAuthenticationInfo( 101 | AuthenticationToken authcToken) throws AuthenticationException { 102 | //获取基于用户名和密码的令牌 103 | //实际上这个authcToken是从LoginController里面currentUser.login(token)传过来的 104 | UsernamePasswordToken token = (UsernamePasswordToken) authcToken; 105 | String account = token.getUsername(); 106 | User user = userService.selectByAccount(account); 107 | if(user==null){throw new AuthenticationException("用户不存在");} 108 | 109 | //进行认证,将正确数据给shiro处理 110 | //密码不用自己比对,AuthenticationInfo认证信息对象,一个接口,new他的实现类对象SimpleAuthenticationInfo 111 | /* 第一个参数随便放,可以放user对象,程序可在任意位置获取 放入的对象 112 | * 第二个参数必须放密码, 113 | * 第三个参数放 当前realm的名字,因为可能有多个realm*/ 114 | AuthenticationInfo authcInfo=new SimpleAuthenticationInfo(user, user.getPassword(), this.getName()); 115 | //AuthenticationInfo authcInfo=new SimpleAuthenticationInfo(user,user.getPassword(),new MySimpleByteSource(account), this.getName()); 116 | 117 | //清缓存中的授权信息,保证每次登陆 都可以重新授权。因为AuthorizingRealm会先检查缓存有没有 授权信息,再调用授权方法 118 | super.clearCachedAuthorizationInfo(authcInfo.getPrincipals()); 119 | 120 | SecurityUtils.getSubject().getSession().setAttribute("login", user); 121 | 122 | return authcInfo; 123 | //返回给安全管理器,securityManager,由securityManager比对数据库查询出的密码和页面提交的密码 124 | //如果有问题,向上抛异常,一直抛到控制器 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/AuthorityService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.apache.commons.collections.CollectionUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import com.melo.focus.domain.basic.Authority; 12 | import com.melo.focus.domain.extend.AuthorityController; 13 | import com.melo.focus.domain.vm.AuthoritySaveVM; 14 | import com.melo.focus.domain.vm.AuthorityUpdateVM; 15 | import com.melo.focus.domain.vm.AuthorityVMS; 16 | import com.melo.focus.mapper.basic.AuthorityMapper; 17 | import com.melo.focus.mapper.extend.AuthorityExtendMapper; 18 | import com.melo.focus.util.Asserts; 19 | import com.melo.focus.util.EntityUtils; 20 | 21 | @Service 22 | @Transactional 23 | public class AuthorityService { 24 | 25 | @Autowired 26 | AuthorityExtendMapper authorityExtendMapper; 27 | 28 | @Autowired 29 | AuthorityMapper authorityMapper; 30 | 31 | @Autowired 32 | ResourceAuthorityService resourceAuthorityService; 33 | 34 | 35 | /** 36 | * 根据 权限id 查权限对象集 37 | */ 38 | public List getAuthorityByIds(List ids){ 39 | if(CollectionUtils.isEmpty(ids)){return null;} 40 | return authorityExtendMapper.getAuthorityByIds(ids); 41 | } 42 | 43 | 44 | /** 45 | * 按controller分组,得到authority列表 46 | * @return 47 | */ 48 | public List getAuthority() { 49 | List authorityList = authorityExtendMapper.getAuthority(); 50 | return EntityUtils.entity2VMList(authorityList, AuthorityVMS.class); 51 | } 52 | 53 | 54 | public List getLikeAuthority(String method, String word) { 55 | Asserts.notEmpty(method); 56 | return authorityExtendMapper.getLikeAuthority(method, word); 57 | } 58 | 59 | 60 | public void saveAuthority(AuthoritySaveVM authoritySaveVM) { 61 | Asserts.validate(authoritySaveVM,"authoritySaveVM"); 62 | Authority authority = EntityUtils.entity2VM(authoritySaveVM, Authority.class); 63 | authority.setId(UUID.randomUUID().toString()); 64 | authorityMapper.insert(authority); 65 | } 66 | 67 | 68 | public void updateAuhtority(AuthorityUpdateVM authorityUpdateVM) { 69 | Asserts.validate(authorityUpdateVM, "authorityUpdateVM"); 70 | //校验id是否存在 71 | 72 | Authority authority = EntityUtils.vm2Entity(authorityUpdateVM, Authority.class); 73 | authorityMapper.updateByPrimaryKey(authority); 74 | } 75 | 76 | 77 | public void deleteAuthority(String id) { 78 | Asserts.notEmpty(id); 79 | 80 | //删除资源权限关系 81 | resourceAuthorityService.deleteResourceAuthority(null,id); 82 | 83 | //删除权限 84 | authorityMapper.deleteByPrimaryKey(id); 85 | } 86 | 87 | 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/ResourceAuthorityService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | import org.apache.commons.collections.CollectionUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import com.melo.focus.domain.basic.Authority; 13 | import com.melo.focus.domain.basic.Resource; 14 | import com.melo.focus.domain.basic.ResourceAuthority; 15 | import com.melo.focus.mapper.basic.ResourceAuthorityMapper; 16 | import com.melo.focus.mapper.extend.ResourceAuthorityExtendMapper; 17 | import com.melo.focus.util.Asserts; 18 | 19 | @Service 20 | @Transactional 21 | public class ResourceAuthorityService { 22 | 23 | @Autowired 24 | ResourceAuthorityExtendMapper resourceAuthorityExtendMapper; 25 | 26 | @Autowired 27 | AuthorityService authorityService; 28 | 29 | @Autowired 30 | ResourceAuthorityMapper resourceAuthorityMapper; 31 | 32 | /** 33 | * 根据参数资源 查出其拥有的 权限 34 | */ 35 | public List getAuthorityByResource(List resourceList){ 36 | if(CollectionUtils.isEmpty(resourceList)){return null;} 37 | return resourceAuthorityExtendMapper.getAuthorityByResource(resourceList); 38 | } 39 | 40 | /** 41 | * 查单个资源拥有的权限 42 | * @param resourceId 43 | * @return 44 | */ 45 | public List getAuthorityByResource(String resourceId) { 46 | Listlist=new ArrayList<>(); 47 | list.add(resourceId); 48 | List authorityIds = resourceAuthorityExtendMapper.getAuthorityByResource(list); 49 | 50 | return authorityService.getAuthorityByIds(authorityIds); 51 | } 52 | 53 | /** 54 | * 取消授权 55 | * @param resourceId 56 | * @param authorityId 57 | */ 58 | public void deleteResourceAuthority(String resourceId, String authorityId) { 59 | resourceAuthorityExtendMapper.deleteResourceAuthority(resourceId,authorityId); 60 | } 61 | 62 | /** 63 | * 给资源授权 64 | * @param resourceId 65 | * @param authorityId 66 | */ 67 | public void authorize(String resourceId, String authorityId) { 68 | Asserts.notEmpty(resourceId); 69 | Asserts.notEmpty(authorityId); 70 | 71 | ResourceAuthority resourceAuthority=new ResourceAuthority(); 72 | resourceAuthority.setId(UUID.randomUUID().toString()); 73 | resourceAuthority.setAuthorityId(authorityId); 74 | resourceAuthority.setResourceId(resourceId); 75 | 76 | resourceAuthorityMapper.insert(resourceAuthority); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/RoleResourceService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.commons.collections.CollectionUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import com.melo.focus.domain.basic.RoleResourcer; 11 | import com.melo.focus.mapper.extend.RoleResourceExtendMapper; 12 | 13 | @Service 14 | @Transactional 15 | public class RoleResourceService { 16 | 17 | @Autowired 18 | RoleResourceExtendMapper roleResourceExtendMapper; 19 | 20 | /** 21 | * 根据roleid 或resourceid 删除角色和资源关系 22 | */ 23 | public void deleteRoleResource(String roleId,String resourceId){ 24 | roleResourceExtendMapper.deleteRoleResource(roleId,null); 25 | } 26 | 27 | /** 28 | * 批量新增角色资源关系 29 | */ 30 | public void batchInsert (Listlist){ 31 | roleResourceExtendMapper.batchInsert(list); 32 | } 33 | 34 | /** 35 | * 根据role ID集合,查这些角色拥有的资源id 36 | */ 37 | public ListgetResource(ListroleIds){ 38 | if(roleIds!=null&&CollectionUtils.isNotEmpty(roleIds)){ 39 | List resourceIds = roleResourceExtendMapper.getResourceByRole(roleIds); 40 | return resourceIds; 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | import org.apache.commons.collections.CollectionUtils; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import com.melo.focus.domain.basic.Role; 16 | import com.melo.focus.domain.basic.RoleResourcer; 17 | import com.melo.focus.domain.vm.RoleResourceVM; 18 | import com.melo.focus.domain.vm.RoleSaveVM; 19 | import com.melo.focus.domain.vm.RoleUpdateVM; 20 | import com.melo.focus.mapper.basic.RoleMapper; 21 | import com.melo.focus.mapper.extend.RoleExtendMapper; 22 | import com.melo.focus.util.Asserts; 23 | import com.melo.focus.util.DataValidateFiledException; 24 | 25 | @Service 26 | @Transactional 27 | public class RoleService { 28 | 29 | @Autowired 30 | RoleMapper roleMapper; 31 | 32 | @Autowired 33 | UserRoleService userRoleService; 34 | 35 | @Autowired 36 | RoleResourceService roleResourceService; 37 | 38 | @Autowired 39 | RoleExtendMapper roleExtendMapper; 40 | 41 | public void saveRole(RoleSaveVM roleSaveVM) { 42 | Asserts.validate(roleSaveVM,"roleSaveVM"); 43 | 44 | Role role=new Role(); 45 | role.setId(UUID.randomUUID().toString()); 46 | role.setCode(roleSaveVM.getCode()); 47 | role.setDes(roleSaveVM.getDes()); 48 | role.setName(roleSaveVM.getName()); 49 | role.setSort(roleSaveVM.getSort()); 50 | role.setType(roleSaveVM.getType()); 51 | 52 | roleMapper.insert(role); 53 | } 54 | 55 | public void deleteRole(String roleId) { 56 | if(StringUtils.isBlank(roleId)){ 57 | throw new DataValidateFiledException("角色id不能为空"); 58 | } 59 | 60 | //校验roleId 是否存在 61 | 62 | //删角色和用户的关系 63 | userRoleService.deleteByRoleId(roleId); 64 | //删角色和资源的关系 65 | roleResourceService.deleteRoleResource(roleId,null); 66 | //删角色 67 | roleMapper.deleteByPrimaryKey(roleId); 68 | } 69 | 70 | /** 71 | * 修改角色 72 | * @param roleUpdateVM 73 | */ 74 | public void updateRole(RoleUpdateVM roleUpdateVM) { 75 | Asserts.validate(roleUpdateVM, "roleUpdateVM"); 76 | //校验id是否存在 77 | 78 | Role role=new Role(); 79 | role.setId(roleUpdateVM.getId()); 80 | role.setCode(roleUpdateVM.getCode()); 81 | role.setDes(roleUpdateVM.getDes()); 82 | role.setName(roleUpdateVM.getName()); 83 | role.setSort(roleUpdateVM.getSort()); 84 | role.setType(roleUpdateVM.getType()); 85 | 86 | roleMapper.updateByPrimaryKey(role); 87 | } 88 | 89 | public List getRoleList() { 90 | List roleList = roleMapper.selectAll(); 91 | Collections.sort(roleList); 92 | return roleList; 93 | } 94 | 95 | public void authorize(RoleResourceVM roleResourceVM) { 96 | Asserts.validate(roleResourceVM, "roleResource"); 97 | if(StringUtils.isBlank(roleResourceVM.getRoleIds())||StringUtils.isBlank(roleResourceVM.getResourceIds())){ 98 | throw new DataValidateFiledException("角色或资源不能为空"); 99 | } 100 | String roleIds=roleResourceVM.getRoleIds(); 101 | String resourceIds=roleResourceVM.getResourceIds(); 102 | 103 | List resourceList = Arrays.asList(resourceIds.split(",")); 104 | ListroleList =Arrays.asList(roleIds.split(",")); 105 | 106 | ListroleResourceList=new ArrayList(); 107 | 108 | for(String roleId:roleList){ 109 | 110 | for(String resourceId:resourceList){ 111 | RoleResourcer roleResource=new RoleResourcer(); 112 | roleResource.setId(UUID.randomUUID().toString()); 113 | roleResource.setRoleId(roleId); 114 | roleResource.setResourceId(resourceId); 115 | roleResourceList.add(roleResource); 116 | } 117 | //删角色和资源的关系 118 | roleResourceService.deleteRoleResource(roleId,null); 119 | } 120 | 121 | roleResourceService.batchInsert(roleResourceList); 122 | } 123 | 124 | public Boolean isExist(String code) { 125 | return roleExtendMapper.isExist(code); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import com.melo.focus.domain.basic.UserRoleR; 14 | import com.melo.focus.domain.vm.UserRoleSaveVM; 15 | import com.melo.focus.domain.vm.UserRoleSaveVMS; 16 | import com.melo.focus.mapper.basic.UserRoleRMapper; 17 | import com.melo.focus.mapper.extend.UserRoleRExtendMapper; 18 | import com.melo.focus.util.Asserts; 19 | import com.melo.focus.util.DataValidateFiledException; 20 | 21 | @Service 22 | @Transactional 23 | public class UserRoleService { 24 | 25 | @Autowired 26 | UserRoleRExtendMapper userRoleRExtendMapper; 27 | 28 | @Autowired 29 | UserRoleRMapper userRoleRMapper; 30 | 31 | /** 32 | * 给用户授权 33 | * 单个用户 34 | * @param userRoleVMS 35 | */ 36 | public void delegate(UserRoleSaveVMS userRoleVMS) { 37 | Asserts.validate(userRoleVMS, "userRole"); 38 | 39 | String userId=userRoleVMS.getUserId(); 40 | List roleList = Arrays.asList(userRoleVMS.getRoleIds().split(",")); 41 | List userRoleList=new ArrayList(); 42 | List userIdList=new ArrayList(); 43 | for(String roleId:roleList){ 44 | UserRoleR userRole=new UserRoleR(); 45 | userRole.setId(UUID.randomUUID().toString()); 46 | userRole.setUserId(userId); 47 | userRole.setRoleId(roleId); 48 | userRoleList.add(userRole); 49 | userIdList.add(userRole.getUserId()); 50 | } 51 | 52 | //先删再增 53 | userRoleRExtendMapper.deleteByUserId(userIdList); 54 | userRoleRExtendMapper.batchInsert(userRoleList); 55 | } 56 | 57 | /** 58 | * 根据用户id 删除用户角色关系 59 | */ 60 | public void deleteByUserId(String userId){ 61 | if(StringUtils.isBlank(userId)){throw new DataValidateFiledException("用户Id不能为空");} 62 | 63 | List userIdList=new ArrayList(); 64 | userIdList.add(userId); 65 | userRoleRExtendMapper.deleteByUserId(userIdList); 66 | } 67 | 68 | /** 69 | * 根据角色id删除用户角色关系 70 | */ 71 | public void deleteByRoleId(String roleId){ 72 | if(StringUtils.isBlank(roleId)){throw new DataValidateFiledException("角色Id不能为空");} 73 | 74 | userRoleRExtendMapper.deleteByRoleId(roleId); 75 | } 76 | 77 | /** 78 | * 根据‘用户id查所拥有的角色e 79 | */ 80 | public List getRoleByUser(String userId){ 81 | Asserts.notEmpty(userId); 82 | List roleIds = userRoleRExtendMapper.getRoleByUser(userId); 83 | return roleIds; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.service; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import com.melo.focus.domain.basic.User; 12 | import com.melo.focus.domain.vm.UserRoleSaveVM; 13 | import com.melo.focus.domain.vm.UserRoleSaveVMS; 14 | import com.melo.focus.domain.vm.UserSaveVM; 15 | import com.melo.focus.domain.vm.UserUpdateVM; 16 | import com.melo.focus.mapper.basic.UserMapper; 17 | import com.melo.focus.mapper.extend.UserExtendMapper; 18 | import com.melo.focus.util.Asserts; 19 | import com.melo.focus.util.DataValidateFiledException; 20 | 21 | 22 | @Service 23 | @Transactional 24 | public class UserService { 25 | 26 | @Autowired 27 | UserExtendMapper userExtendMapper; 28 | 29 | @Autowired 30 | UserMapper userMapper; 31 | 32 | @Autowired 33 | UserRoleService userRoleService; 34 | 35 | /** 36 | * 根据用户名查用户对象 37 | * @param account 38 | * @return 39 | */ 40 | public User selectByAccount(String account){ 41 | User user = userExtendMapper.selectByName(account); 42 | return user; 43 | } 44 | 45 | public void saveUser(UserSaveVM user) { 46 | Asserts.validate(user,"user"); 47 | 48 | User u=new User(); 49 | u.setId(UUID.randomUUID().toString()); 50 | u.setLoginName(user.getLoginName()); 51 | u.setRealName(user.getRealName()); 52 | u.setPassword(user.getPassword()); 53 | u.setSuperman(false); 54 | userMapper.insert(u); 55 | 56 | //给用户一个普通的角色 57 | UserRoleSaveVMS userRole=new UserRoleSaveVMS(); 58 | userRole.setRoleIds("a8bfc2b4-ff73-4c35-9a63-ae2c049d3b01");//这应该按照普通用户角色 的code查id,我就不想写了 59 | userRole.setUserId(u.getId()); 60 | userRoleService.delegate(userRole); 61 | } 62 | 63 | public void updateUser(UserUpdateVM user) { 64 | Asserts.validate(user,"user"); 65 | 66 | //校验用户id是否存在 67 | 68 | User u=new User(); 69 | u.setId(user.getId()); 70 | u.setLoginName(user.getLoginName()); 71 | u.setRealName(user.getRealName()); 72 | u.setPassword(user.getPassword()); 73 | 74 | userMapper.updateByPrimaryKey(u); 75 | } 76 | 77 | public void deleteUser(String id) { 78 | if(StringUtils.isBlank(id)){ 79 | throw new DataValidateFiledException("删除的用户id不能为空"); 80 | } 81 | 82 | //校验用户id是否存在 83 | 84 | userRoleService.deleteByUserId(id);//删除用户下的角色关系 85 | userMapper.deleteByPrimaryKey(id); 86 | } 87 | 88 | public List findAllUser() { 89 | List selectAll = userMapper.selectAll(); 90 | return selectAll; 91 | } 92 | 93 | public Boolean isExist(String loginName) { 94 | return userExtendMapper.isExist(loginName)>0; 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/Asserts.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.validation.ConstraintViolation; 7 | import javax.validation.Path; 8 | import javax.validation.Validation; 9 | import javax.validation.Validator; 10 | import javax.validation.ValidatorFactory; 11 | import javax.validation.groups.Default; 12 | 13 | import org.springframework.util.CollectionUtils; 14 | import org.springframework.util.ObjectUtils; 15 | import org.springframework.util.StringUtils; 16 | 17 | /** 18 | * 19 | * @author Melo 20 | * 21 | */ 22 | public class Asserts { 23 | 24 | private static final Validator VALIDATOR; 25 | 26 | static { 27 | 28 | ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); 29 | VALIDATOR = factory.getValidator(); 30 | } 31 | 32 | /** 33 | * 校验bean对象 34 | * @param target 目标对象 35 | * @param beanName 对象名 36 | */ 37 | public static void validate(T target,String beanName){ 38 | validate(target,beanName,Default.class); 39 | } 40 | 41 | /** 42 | * 校验对象 43 | * @param target 目标对象 44 | * @param beanName 对象名 45 | * @param group 分组校验 46 | */ 47 | public static void validate(T target,String beanName,Class...group){ 48 | 49 | notEmpty(target,"对象"+beanName+"不能为空"); 50 | 51 | Set> errors = VALIDATOR.validate(target,group); 52 | Set filedErrors=new HashSet (); 53 | if(!CollectionUtils.isEmpty(errors)){ 54 | error(errors,beanName,filedErrors); 55 | throw new DataValidateFiledException(filedErrors); 56 | } 57 | } 58 | 59 | /** 60 | * 校验对象 61 | * @param target 目标对象 62 | * @param properties 需要校验的字段名 63 | * @param beanName 对象名 64 | * @param group 分组校验 65 | */ 66 | public static void validate(T target,String []properties,String beanName,Class...group){ 67 | notEmpty(target,"对象"+beanName+"不能为空"); 68 | 69 | if(properties!=null&&properties.length>0){ 70 | Set filedErrors=new HashSet (); 71 | for(String property:properties){ 72 | Set> validateProperty = VALIDATOR.validateProperty(target, property, group); 73 | error(validateProperty,beanName,filedErrors); 74 | } 75 | if(!CollectionUtils.isEmpty(filedErrors)){ 76 | throw new DataValidateFiledException(filedErrors); 77 | } 78 | } 79 | } 80 | 81 | /** 82 | * 对象是否非空 83 | * @param target 目标对象 84 | * @param message 提示信息 85 | * @param beanName 对象名 86 | * @param filedName 对象内字段名 87 | */ 88 | public static void notEmpty(T target,String message,String beanName,String filedName){ 89 | if(!ObjectUtils.isEmpty(target)){return;} 90 | throw new DataValidateFiledException(new FiledError(StringUtils.isEmpty(message)?"对象不能为空":message, 91 | StringUtils.isEmpty(beanName)?"":beanName, StringUtils.isEmpty(filedName)?"":filedName)); 92 | } 93 | 94 | /** 95 | * 对象是否非空 96 | * @param target 97 | * @param message 98 | */ 99 | public static void notEmpty(T target,String message){ 100 | notEmpty(target,message,"",""); 101 | } 102 | 103 | /** 104 | * 对象是否非空 105 | * @param target 106 | */ 107 | 108 | public static void notEmpty(T target){ 109 | notEmpty(target,""); 110 | } 111 | 112 | 113 | /** 114 | * 把Set> 中的校验信息,收集,最后放在异常中的message即可 115 | * @param errors 116 | * @param beanName 117 | * @param filedErrors 118 | */ 119 | private static void error(Set> errors,String beanName,Set filedErrors){ 120 | for(ConstraintViolation error:errors){ 121 | 122 | Path path = error.getPropertyPath(); 123 | filedErrors.add(new FiledError( 124 | error.getMessage(), 125 | StringUtils.isEmpty(beanName) ? "" : beanName, 126 | ObjectUtils.isEmpty(path) ? "" : path.toString() 127 | ) 128 | ); 129 | /* FiledError f=new FiledError(); 130 | f.setMessage(error.getMessage()); 131 | filedErrors.add(f);*/ 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | public class Constants { 4 | 5 | public static final String SUCCESS="SUCCESS"; 6 | 7 | public static final String REDIS_RESOURCE="REDIS_RESOURCE"; 8 | 9 | public static final String REDIS_RESOURCE_TREE="REDIS_RESOURCE_TREE"; 10 | 11 | public enum RoleType{ 12 | initial("内置角色",1), 13 | custom("自定义角色",2), 14 | business("业务角色",3); 15 | 16 | private String name; 17 | private int value; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | public int getValue() { 23 | return value; 24 | } 25 | 26 | private RoleType(String name, int value) { 27 | this.name = name; 28 | this.value = value; 29 | } 30 | } 31 | 32 | public enum ResourceType{ 33 | module("模块",1), 34 | column("栏目",2), 35 | button("按钮",3); 36 | 37 | private String name; 38 | private int value; 39 | public String getName() { 40 | return name; 41 | } 42 | public int getValue() { 43 | return value; 44 | } 45 | private ResourceType(String name, int value) { 46 | this.name = name; 47 | this.value = value; 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/DataValidateFiledException.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import java.util.Objects; 6 | 7 | import org.springframework.util.CollectionUtils; 8 | 9 | 10 | public class DataValidateFiledException extends RuntimeException { 11 | 12 | private static final long serialVersionUID = 2256477558314496007L; 13 | 14 | private Collection filedErrors=new HashSet(); 15 | 16 | public DataValidateFiledException(Collection filedError) { 17 | super("数据校验失败"); 18 | fillFieldErrors(filedError); 19 | } 20 | 21 | public DataValidateFiledException() { 22 | super(); 23 | // TODO Auto-generated constructor stub 24 | } 25 | 26 | //字符串抛个检验异常 27 | public DataValidateFiledException(String filedError) { 28 | super(); 29 | fillFieldError(new FiledError(filedError,"","")); 30 | } 31 | 32 | public DataValidateFiledException(FiledError filedError){ 33 | super("数据检验失败"); 34 | filedErrors.add(filedError); 35 | } 36 | 37 | private final void fillFieldErrors(Collection fieldErrors) { 38 | if (Objects.nonNull(fieldErrors)) { 39 | //如果fieldErrors 不为null 40 | this.filedErrors.addAll(fieldErrors); 41 | } 42 | } 43 | 44 | private final void fillFieldError(FiledError fieldError) { 45 | if (Objects.nonNull(filedErrors)) { 46 | this.filedErrors.add(fieldError); 47 | } 48 | } 49 | 50 | /** 51 | * 重写Throwable的getMessage方法,控制台输出的异常信息就是message,把想输出的信息放在message 52 | */ 53 | @Override 54 | public String getMessage() { 55 | StringBuffer msg = new StringBuffer(super.getMessage()); 56 | if (!CollectionUtils.isEmpty(filedErrors)) { 57 | msg.append(":"); 58 | for (FiledError fieldError : 59 | filedErrors) { 60 | msg.append("对象"+fieldError.getBeanName()+","); 61 | msg.append("字段"+fieldError.getFiledName()+","); 62 | msg.append(fieldError.getMessage()).append("\n"); 63 | } 64 | } 65 | return msg.toString(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/EntityUtils.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | 4 | import com.github.pagehelper.Page; 5 | import org.springframework.beans.BeanUtils; 6 | import org.springframework.util.CollectionUtils; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.concurrent.ConcurrentHashMap; 15 | 16 | /** 17 | * 实体转换工具类 18 | * 19 | * @author Carl 20 | */ 21 | public class EntityUtils { 22 | 23 | /** 24 | * 实体列表转Vm 25 | * 26 | * @param source 原列表 27 | * @param vmClass vm类 28 | * @param ignoreProperties 忽略的字段 29 | * @param 泛型 30 | * @return vm列表 31 | */ 32 | public static List entity2VMList(List source, Class vmClass, String... ignoreProperties) { 33 | List target = (source instanceof Page ? new Page() : new ArrayList()); 34 | if (source instanceof Page) { 35 | BeanUtils.copyProperties(source, target); 36 | } 37 | if (CollectionUtils.isEmpty(source)) { 38 | return target; 39 | } 40 | source.forEach(e -> { 41 | target.add(entity2VM(e, vmClass, ignoreProperties)); 42 | }); 43 | return target; 44 | } 45 | 46 | /** 47 | * 实体转VM 48 | * 49 | * @param source 原对象 50 | * @param vmClass 要转换的对象 51 | * @param ignoreProperties 忽略的属性 52 | * @param 泛型 53 | * @return 转换后对象 54 | * @author Say 55 | */ 56 | public static T entity2VM(Object source, Class vmClass, String... ignoreProperties) { 57 | if (null == source) { 58 | return null; 59 | } 60 | try { 61 | T target = vmClass.newInstance(); 62 | BeanUtils.copyProperties(source, target, ignoreProperties); 63 | return target; 64 | } catch (InstantiationException | IllegalAccessException e) { 65 | e.printStackTrace(); 66 | } 67 | return null; 68 | } 69 | 70 | /** 71 | * VM转实体 72 | * 底层用的vm2Entity,只是方法名做区分 73 | * 74 | * @param source vm 75 | * @param entClass 实体 76 | * @param ignoreProperties 忽略的属性 77 | * @param 泛型 78 | * @return 转换后的对象 79 | * @author Say 80 | */ 81 | public static T vm2Entity(Object source, Class entClass, String... ignoreProperties) { 82 | return entity2VM(source, entClass, ignoreProperties); 83 | } 84 | 85 | /** 86 | * VM转实体集合 87 | * 底层用的entity2VMList,只是方法名做区分 88 | * 89 | * @param source 原对象 90 | * @param entClass 实体 91 | * @param ignoreProperties 忽略的属性 92 | * @param 泛型 93 | * @return 转换后的对象 94 | * @author Say 95 | */ 96 | public static List vm2EntityList(List source, Class entClass, String... ignoreProperties) { 97 | return entity2VMList(source, entClass, ignoreProperties); 98 | } 99 | 100 | /** 101 | * Entity VM 互转 102 | * 103 | * @param object 数据源 104 | * @param laterObject 转换对象 105 | * @param 泛型 106 | */ 107 | public static void copyProperties(final T object, T laterObject) { 108 | 109 | if (null == object || null == laterObject) { 110 | return; 111 | } 112 | 113 | ConcurrentHashMap getMethods = findGetMethods(object.getClass().getMethods()); 114 | 115 | ConcurrentHashMap setMethods = findSetMethods(laterObject.getClass().getDeclaredMethods()); 116 | 117 | Iterator> iterator = getMethods.entrySet().iterator(); 118 | 119 | while (iterator.hasNext()) { 120 | Map.Entry entry = iterator.next(); 121 | String methodName = entry.getKey(); 122 | Method getMethod = entry.getValue(); 123 | Method setMethod = setMethods.get(methodName); 124 | if (null == setMethod) { 125 | continue; 126 | } 127 | try { 128 | Object value = getMethod.invoke(object, new Object[]{}); 129 | setMethod.invoke(laterObject, value); 130 | } catch (IllegalAccessException e) { 131 | e.printStackTrace(); 132 | } catch (IllegalArgumentException e) { 133 | e.printStackTrace(); 134 | } catch (InvocationTargetException e) { 135 | e.printStackTrace(); 136 | } 137 | } 138 | } 139 | 140 | /** 141 | * 获取所有的get方法 142 | * 143 | * @param methods 所有的方法 144 | * @return 所有的get方法 145 | */ 146 | private static ConcurrentHashMap findGetMethods(Method[] methods) { 147 | ConcurrentHashMap getMethodsMap = new ConcurrentHashMap<>(); 148 | for (Method method : methods) { 149 | if (isGetMethod(method.getName())) { 150 | getMethodsMap.put(getMethodName(method.getName()), method); 151 | } 152 | } 153 | return getMethodsMap; 154 | } 155 | 156 | /** 157 | * 获取所有的set方法 158 | * 159 | * @param methods 所有的方法 160 | * @return 所有的set方法 161 | */ 162 | private static ConcurrentHashMap findSetMethods(Method[] methods) { 163 | ConcurrentHashMap setMethodsMap = new ConcurrentHashMap<>(); 164 | for (Method method : methods) { 165 | if (isSetMethod(method.getName())) { 166 | setMethodsMap.put(getMethodName(method.getName()), method); 167 | } 168 | } 169 | return setMethodsMap; 170 | } 171 | 172 | 173 | /** 174 | * 取方法名 175 | * 176 | * @param getMethodName 方法名称 177 | * @return 去掉get set的方法名 178 | */ 179 | private static String getMethodName(String getMethodName) { 180 | String fieldName = getMethodName.substring(3, getMethodName.length()); 181 | return fieldName; 182 | } 183 | 184 | /** 185 | * 判断是否是get方法 186 | * 187 | * @param methodName 188 | * @return 189 | */ 190 | private static boolean isGetMethod(String methodName) { 191 | int index = methodName.indexOf("get"); 192 | if (index == 0) { 193 | return true; 194 | } 195 | return false; 196 | } 197 | 198 | /** 199 | * 判断是否是set方法 200 | * 201 | * @param methodName 方法名 202 | * @return 是否为set 方法 203 | */ 204 | private static boolean isSetMethod(String methodName) { 205 | int index = methodName.indexOf("set"); 206 | if (index == 0) { 207 | return true; 208 | } 209 | return false; 210 | } 211 | 212 | } 213 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/FiledError.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | public class FiledError { 4 | 5 | private String message; 6 | 7 | private String beanName; 8 | 9 | private String filedName; 10 | 11 | 12 | @Override 13 | public String toString() { 14 | return "FiledError [message=" + message + ", beanName=" + beanName 15 | + ", filedName=" + filedName + "]"; 16 | } 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | public void setMessage(String message) { 23 | this.message = message; 24 | } 25 | 26 | public String getBeanName() { 27 | return beanName; 28 | } 29 | 30 | public void setBeanName(String beanName) { 31 | this.beanName = beanName; 32 | } 33 | 34 | public String getFiledName() { 35 | return filedName; 36 | } 37 | 38 | public void setFiledName(String filedName) { 39 | this.filedName = filedName; 40 | } 41 | 42 | public FiledError() { 43 | super(); 44 | // TODO Auto-generated constructor stub 45 | } 46 | 47 | public FiledError(String message, String beanName, String filedName) { 48 | super(); 49 | this.message = message; 50 | this.beanName = beanName; 51 | this.filedName = filedName; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/Message.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | public class Message { 4 | 5 | private Integer status; 6 | 7 | private String code; 8 | 9 | private String message; 10 | 11 | private T data; 12 | 13 | public static Message ok(T data){ 14 | return new Message(data); 15 | } 16 | 17 | public static Message ok(T data,Integer status){ 18 | return new Message(data,status); 19 | } 20 | 21 | 22 | public Message() { 23 | } 24 | 25 | public Message(T data,Integer status){ 26 | this.status=status; 27 | this.data=data; 28 | this.code = "ok"; 29 | this.message = "成功"; 30 | } 31 | 32 | public Message(T data) { 33 | this.status = 200; 34 | this.code = "ok"; 35 | this.message = "成功"; 36 | this.data = data; 37 | } 38 | public Message(Integer status, String code, String message, T data) { 39 | super(); 40 | this.status = status; 41 | this.code = code; 42 | this.message = message; 43 | this.data = data; 44 | } 45 | 46 | 47 | public Integer getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(Integer status) { 52 | this.status = status; 53 | } 54 | 55 | public String getCode() { 56 | return code; 57 | } 58 | 59 | public void setCode(String code) { 60 | this.code = code; 61 | } 62 | 63 | public String getMessage() { 64 | return message; 65 | } 66 | 67 | public void setMessage(String message) { 68 | this.message = message; 69 | } 70 | 71 | public T getData() { 72 | return data; 73 | } 74 | 75 | public void setData(T data) { 76 | this.data = data; 77 | } 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /focus/src/main/java/com/melo/focus/util/groupage.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus.util; 2 | 3 | public interface groupage { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /focus/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml 2 | 3 | spring.datasource.driverClassName = com.mysql.jdbc.Driver 4 | spring.datasource.url = jdbc:mysql://localhost:3306/focus?useUnicode=true&characterEncoding=utf-8 5 | spring.datasource.username = root 6 | spring.datasource.password = root 7 | 8 | spring.redisson.address= redis://localhost:6379 9 | 10 | spring.application.name=spring-cloud-focus 11 | eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/ 12 | 13 | -------------------------------------------------------------------------------- /focus/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | mybatis: 2 | mapper-locations: classpath*:mapper/**/*Mapper.xml 3 | 4 | spring: 5 | datasource: 6 | driverClassNam: com.mysql.jdbc.Driver 7 | url: jdbc:mysql://localhost:3306/focus?useUnicode=true&characterEncoding=utf-8 8 | username: root 9 | password: root 10 | redisson: 11 | #address: redis://192.168.242.128:6379 12 | address: redis://127.0.0.1:6379 13 | profiles: 14 | active: dev 15 | application: 16 | name: spring-cloud-focus 17 | 18 | server: 19 | port: 8080 -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/AuthorityMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | delete from authority 15 | where id = #{id,jdbcType=VARCHAR} 16 | 17 | 18 | insert into authority (id, name, code, 19 | url, method, controller, 20 | des) 21 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 22 | #{url,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{controller,jdbcType=VARCHAR}, 23 | #{des,jdbcType=VARCHAR}) 24 | 25 | 26 | update authority 27 | set name = #{name,jdbcType=VARCHAR}, 28 | code = #{code,jdbcType=VARCHAR}, 29 | url = #{url,jdbcType=VARCHAR}, 30 | method = #{method,jdbcType=VARCHAR}, 31 | controller = #{controller,jdbcType=VARCHAR}, 32 | des = #{des,jdbcType=VARCHAR} 33 | where id = #{id,jdbcType=VARCHAR} 34 | 35 | 40 | 44 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/ResourceAuthorityMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | delete from resouce_authority 11 | where id = #{id,jdbcType=VARCHAR} 12 | 13 | 14 | insert into resouce_authority (id, resource_id, authority_id 15 | ) 16 | values (#{id,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{authorityId,jdbcType=VARCHAR} 17 | ) 18 | 19 | 20 | update resouce_authority 21 | set resource_id = #{resourceId,jdbcType=VARCHAR}, 22 | authority_id = #{authorityId,jdbcType=VARCHAR} 23 | where id = #{id,jdbcType=VARCHAR} 24 | 25 | 30 | 34 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/ResourceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | delete from resource 17 | where id = #{id,jdbcType=VARCHAR} 18 | 19 | 20 | insert into resource (id, name, type, 21 | code, pid, des, sort,path,menu_route 22 | ) 23 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, 24 | #{code,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR}, #{des,jdbcType=VARCHAR}, #{sort,jdbcType=TINYINT}, 25 | #{path,jdbcType=VARCHAR},#{menuRoute,jdbcType=VARCHAR} 26 | ) 27 | 28 | 29 | update resource 30 | set name = #{name,jdbcType=VARCHAR}, 31 | type = #{type,jdbcType=TINYINT}, 32 | code = #{code,jdbcType=VARCHAR}, 33 | pid = #{pid,jdbcType=VARCHAR}, 34 | des = #{des,jdbcType=VARCHAR}, 35 | sort = #{sort,jdbcType=TINYINT}, 36 | path = #{path,jdbcType=VARCHAR}, 37 | menu_route = #{menuRoute,jdbcType=VARCHAR} 38 | where id = #{id,jdbcType=VARCHAR} 39 | 40 | 45 | 49 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/RoleBusinessMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | delete from role_business 12 | where id = #{id,jdbcType=VARCHAR} 13 | 14 | 15 | insert into role_business (id, role_id, class_pk, 16 | class_name) 17 | values (#{id,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{classPk,jdbcType=VARCHAR}, 18 | #{className,jdbcType=VARCHAR}) 19 | 20 | 21 | update role_business 22 | set role_id = #{roleId,jdbcType=VARCHAR}, 23 | class_pk = #{classPk,jdbcType=VARCHAR}, 24 | class_name = #{className,jdbcType=VARCHAR} 25 | where id = #{id,jdbcType=VARCHAR} 26 | 27 | 32 | 36 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | delete from role 14 | where id = #{id,jdbcType=VARCHAR} 15 | 16 | 17 | insert into role (id, name, code, 18 | sort, type, des) 19 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 20 | #{sort,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}, #{des,jdbcType=VARCHAR}) 21 | 22 | 23 | update role 24 | set name = #{name,jdbcType=VARCHAR}, 25 | code = #{code,jdbcType=VARCHAR}, 26 | sort = #{sort,jdbcType=TINYINT}, 27 | type = #{type,jdbcType=TINYINT}, 28 | des = #{des,jdbcType=VARCHAR} 29 | where id = #{id,jdbcType=VARCHAR} 30 | 31 | 36 | 40 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/RoleResourcerMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | delete from role_resource_r 11 | where id = #{id,jdbcType=VARCHAR} 12 | 13 | 14 | insert into role_resource_r (id, role_id, resource_id 15 | ) 16 | values (#{id,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR} 17 | ) 18 | 19 | 20 | update role_resource_r 21 | set role_id = #{roleId,jdbcType=VARCHAR}, 22 | resource_id = #{resourceId,jdbcType=VARCHAR} 23 | where id = #{id,jdbcType=VARCHAR} 24 | 25 | 30 | 34 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | delete from user 13 | where id = #{id,jdbcType=VARCHAR} 14 | 15 | 16 | insert into user (id, login_name, real_name, 17 | password) 18 | values (#{id,jdbcType=VARCHAR}, #{loginName,jdbcType=VARCHAR}, #{realName,jdbcType=VARCHAR}, 19 | #{password,jdbcType=VARCHAR}) 20 | 21 | 22 | update user 23 | set login_name = #{loginName,jdbcType=VARCHAR}, 24 | real_name = #{realName,jdbcType=VARCHAR}, 25 | password = #{password,jdbcType=VARCHAR} 26 | where id = #{id,jdbcType=VARCHAR} 27 | 28 | 33 | 37 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/basic/UserRoleRMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | insert into user_role_r (id,user_id, role_id, yw_id 12 | ) 13 | values (#{id,jdbcType=VARCHAR},#{userId,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{ywId,jdbcType=VARCHAR} 14 | ) 15 | 16 | 20 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/AuthorityExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 35 | 36 | 40 | 41 | 50 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/ResourceAuthorityExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 23 | 24 | delete from resouce_authority 25 | 26 | 27 | and resource_id=#{resourceId,jdbcType=VARCHAR} 28 | 29 | 30 | and authority_id =#{authorityId,jdbcType=VARCHAR} 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/ResourceExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 | 26 | 27 | DELETE 28 | FROM 29 | resource 30 | WHERE 31 | path LIKE #{path} 32 | 33 | 34 | 40 | 41 | 44 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/RoleExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/RoleResourcerExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | delete from role_resource_r 12 | 13 | 14 | role_id = #{roleId,jdbcType=VARCHAR} 15 | 16 | 17 | resource_id = #{resourceId,jdbcType=VARCHAR} 18 | 19 | 20 | 21 | 22 | 23 | insert into role_resource_r (id, role_id, resource_id 24 | ) 25 | values 26 | 27 | ( 28 | #{item.id,jdbcType=VARCHAR}, #{item.roleId,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR} 29 | ) 30 | 31 | 32 | 33 | 39 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/UserExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 23 | 24 | 27 | -------------------------------------------------------------------------------- /focus/src/main/resources/mapper/extend/UserRoleRExtendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | INSERT INTO user_role_r (id, user_id, role_id, yw_id) 14 | VALUES 15 | 16 | (#{userRole.id,jdbcType=VARCHAR}, 17 | #{userRole.userId,jdbcType=VARCHAR}, 18 | #{userRole.roleId,jdbcType=VARCHAR}, 19 | #{userRole.ywId,jdbcType=VARCHAR}) 20 | 21 | 22 | 23 | 24 | DELETE 25 | FROM 26 | user_role_r 27 | WHERE 28 | user_id in 29 | 30 | #{userId,jdbcType=VARCHAR} 31 | 32 | 33 | 34 | 35 | DELETE 36 | FROM 37 | user_role_r 38 | WHERE 39 | role_id = #{roleId,jdbcType=VARCHAR} 40 | 41 | 42 | 45 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/focus/src/main/resources/static/1.png -------------------------------------------------------------------------------- /focus/src/main/resources/static/authority_manage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 64 | 65 | 66 | 73 | 74 |
75 |
76 |
77 | 78 | 79 | 80 | 83 | 86 | 89 | 92 | 95 | 96 | 97 | 98 | 99 |
81 | 名称 82 | 84 | code 85 | 87 | URL 88 | 90 | 请求method 91 | 93 | 描述 94 |
100 |
101 |
102 |
103 | 104 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/blog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |

25 | 博客 26 |

27 |

28 | 记录了后端框架主要搭建过程 29 | https://blog.csdn.net/u014203449/article/details/79330811 30 |

31 |

32 | 查看更多 » 33 |

34 |
35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/css/bootstrap-reboot.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.0.0 (https://getbootstrap.com) 3 | * Copyright 2011-2018 The Bootstrap Authors 4 | * Copyright 2011-2018 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */ 8 | *, 9 | *::before, 10 | *::after { 11 | box-sizing: border-box; 12 | } 13 | 14 | html { 15 | font-family: sans-serif; 16 | line-height: 1.15; 17 | -webkit-text-size-adjust: 100%; 18 | -ms-text-size-adjust: 100%; 19 | -ms-overflow-style: scrollbar; 20 | -webkit-tap-highlight-color: transparent; 21 | } 22 | 23 | @-ms-viewport { 24 | width: device-width; 25 | } 26 | 27 | article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, section { 28 | display: block; 29 | } 30 | 31 | body { 32 | margin: 0; 33 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 34 | font-size: 1rem; 35 | font-weight: 400; 36 | line-height: 1.5; 37 | color: #212529; 38 | text-align: left; 39 | background-color: #fff; 40 | } 41 | 42 | [tabindex="-1"]:focus { 43 | outline: 0 !important; 44 | } 45 | 46 | hr { 47 | box-sizing: content-box; 48 | height: 0; 49 | overflow: visible; 50 | } 51 | 52 | h1, h2, h3, h4, h5, h6 { 53 | margin-top: 0; 54 | margin-bottom: 0.5rem; 55 | } 56 | 57 | p { 58 | margin-top: 0; 59 | margin-bottom: 1rem; 60 | } 61 | 62 | abbr[title], 63 | abbr[data-original-title] { 64 | text-decoration: underline; 65 | -webkit-text-decoration: underline dotted; 66 | text-decoration: underline dotted; 67 | cursor: help; 68 | border-bottom: 0; 69 | } 70 | 71 | address { 72 | margin-bottom: 1rem; 73 | font-style: normal; 74 | line-height: inherit; 75 | } 76 | 77 | ol, 78 | ul, 79 | dl { 80 | margin-top: 0; 81 | margin-bottom: 1rem; 82 | } 83 | 84 | ol ol, 85 | ul ul, 86 | ol ul, 87 | ul ol { 88 | margin-bottom: 0; 89 | } 90 | 91 | dt { 92 | font-weight: 700; 93 | } 94 | 95 | dd { 96 | margin-bottom: .5rem; 97 | margin-left: 0; 98 | } 99 | 100 | blockquote { 101 | margin: 0 0 1rem; 102 | } 103 | 104 | dfn { 105 | font-style: italic; 106 | } 107 | 108 | b, 109 | strong { 110 | font-weight: bolder; 111 | } 112 | 113 | small { 114 | font-size: 80%; 115 | } 116 | 117 | sub, 118 | sup { 119 | position: relative; 120 | font-size: 75%; 121 | line-height: 0; 122 | vertical-align: baseline; 123 | } 124 | 125 | sub { 126 | bottom: -.25em; 127 | } 128 | 129 | sup { 130 | top: -.5em; 131 | } 132 | 133 | a { 134 | color: #007bff; 135 | text-decoration: none; 136 | background-color: transparent; 137 | -webkit-text-decoration-skip: objects; 138 | } 139 | 140 | a:hover { 141 | color: #0056b3; 142 | text-decoration: underline; 143 | } 144 | 145 | a:not([href]):not([tabindex]) { 146 | color: inherit; 147 | text-decoration: none; 148 | } 149 | 150 | a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus { 151 | color: inherit; 152 | text-decoration: none; 153 | } 154 | 155 | a:not([href]):not([tabindex]):focus { 156 | outline: 0; 157 | } 158 | 159 | pre, 160 | code, 161 | kbd, 162 | samp { 163 | font-family: monospace, monospace; 164 | font-size: 1em; 165 | } 166 | 167 | pre { 168 | margin-top: 0; 169 | margin-bottom: 1rem; 170 | overflow: auto; 171 | -ms-overflow-style: scrollbar; 172 | } 173 | 174 | figure { 175 | margin: 0 0 1rem; 176 | } 177 | 178 | img { 179 | vertical-align: middle; 180 | border-style: none; 181 | } 182 | 183 | svg:not(:root) { 184 | overflow: hidden; 185 | } 186 | 187 | table { 188 | border-collapse: collapse; 189 | } 190 | 191 | caption { 192 | padding-top: 0.75rem; 193 | padding-bottom: 0.75rem; 194 | color: #6c757d; 195 | text-align: left; 196 | caption-side: bottom; 197 | } 198 | 199 | th { 200 | text-align: inherit; 201 | } 202 | 203 | label { 204 | display: inline-block; 205 | margin-bottom: .5rem; 206 | } 207 | 208 | button { 209 | border-radius: 0; 210 | } 211 | 212 | button:focus { 213 | outline: 1px dotted; 214 | outline: 5px auto -webkit-focus-ring-color; 215 | } 216 | 217 | input, 218 | button, 219 | select, 220 | optgroup, 221 | textarea { 222 | margin: 0; 223 | font-family: inherit; 224 | font-size: inherit; 225 | line-height: inherit; 226 | } 227 | 228 | button, 229 | input { 230 | overflow: visible; 231 | } 232 | 233 | button, 234 | select { 235 | text-transform: none; 236 | } 237 | 238 | button, 239 | html [type="button"], 240 | [type="reset"], 241 | [type="submit"] { 242 | -webkit-appearance: button; 243 | } 244 | 245 | button::-moz-focus-inner, 246 | [type="button"]::-moz-focus-inner, 247 | [type="reset"]::-moz-focus-inner, 248 | [type="submit"]::-moz-focus-inner { 249 | padding: 0; 250 | border-style: none; 251 | } 252 | 253 | input[type="radio"], 254 | input[type="checkbox"] { 255 | box-sizing: border-box; 256 | padding: 0; 257 | } 258 | 259 | input[type="date"], 260 | input[type="time"], 261 | input[type="datetime-local"], 262 | input[type="month"] { 263 | -webkit-appearance: listbox; 264 | } 265 | 266 | textarea { 267 | overflow: auto; 268 | resize: vertical; 269 | } 270 | 271 | fieldset { 272 | min-width: 0; 273 | padding: 0; 274 | margin: 0; 275 | border: 0; 276 | } 277 | 278 | legend { 279 | display: block; 280 | width: 100%; 281 | max-width: 100%; 282 | padding: 0; 283 | margin-bottom: .5rem; 284 | font-size: 1.5rem; 285 | line-height: inherit; 286 | color: inherit; 287 | white-space: normal; 288 | } 289 | 290 | progress { 291 | vertical-align: baseline; 292 | } 293 | 294 | [type="number"]::-webkit-inner-spin-button, 295 | [type="number"]::-webkit-outer-spin-button { 296 | height: auto; 297 | } 298 | 299 | [type="search"] { 300 | outline-offset: -2px; 301 | -webkit-appearance: none; 302 | } 303 | 304 | [type="search"]::-webkit-search-cancel-button, 305 | [type="search"]::-webkit-search-decoration { 306 | -webkit-appearance: none; 307 | } 308 | 309 | ::-webkit-file-upload-button { 310 | font: inherit; 311 | -webkit-appearance: button; 312 | } 313 | 314 | output { 315 | display: inline-block; 316 | } 317 | 318 | summary { 319 | display: list-item; 320 | cursor: pointer; 321 | } 322 | 323 | template { 324 | display: none; 325 | } 326 | 327 | [hidden] { 328 | display: none !important; 329 | } 330 | /*# sourceMappingURL=bootstrap-reboot.css.map */ -------------------------------------------------------------------------------- /focus/src/main/resources/static/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.0.0 (https://getbootstrap.com) 3 | * Copyright 2011-2018 The Bootstrap Authors 4 | * Copyright 2011-2018 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:transparent}@-ms-viewport{width:device-width}article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent;-webkit-text-decoration-skip:objects}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto;-ms-overflow-style:scrollbar}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg:not(:root){overflow:hidden}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /focus/src/main/resources/static/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 12 | 13 | 15 | 16 | 34 | 35 | 36 |
37 |

Focus管理系统


38 | 39 |
40 |       进入swagger 41 |   退出 42 | 43 |
44 | 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/helloboot.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Hello, world!

16 | 17 |
18 |
19 |
20 |
21 | 22 |

23 | 提示! 24 |

警告! 请注意你的个人隐私安全. 25 |
26 |
27 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/homm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 49 | 50 | 51 | 52 | 53 | 54 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/introduction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |

25 | focus权限管理 26 |

27 |

28 | 前后端分离,加入swagger,restful风格,后端采用 shiro、springboot、mybatis、redis, 29 | 前端采用bootstrap,jquery,本人前端水平有限,将就看吧 30 |

31 |

32 | 查看更多 » 33 |

34 |
35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/left.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 88 | 104 | 111 | 112 | 113 |
    114 |
115 | 122 | 123 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/resource_authority.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 资源管理 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 170 | 171 | 172 | 173 |
174 |
    175 |
    176 |
    177 | 178 | 179 | 180 | 181 | 182 |
      183 |
      184 | 185 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/resource_manage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 资源管理 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 17 | 18 | 19 | 31 | 150 | 151 | 152 | 153 |
      154 |
        155 |
        156 | 157 |
        158 |
        159 |
        160 |
        161 | 162 | 163 | 164 | 165 |
        166 |
        167 |
        168 |
        169 | 170 |
        171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/resource_save.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 57 | 58 | 59 |
        60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 93 | 94 |
        名称:
        资源类型:菜单是2,按钮是3
        资源code码:按钮以btn_开头,菜单以category_开头
        父资源code:
        描述:
        前端路由:
        序号:
        91 | 92 |
        95 |
        96 | 97 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/resource_update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 66 | 67 | 68 |
        69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 103 | 104 |
        名称:
        资源类型:
        资源code码: 81 | 按钮以btn_开头,菜单以category_开头
        父资源code:
        描述:
        前端路由:
        序号:
        101 | 102 |
        105 |
        106 | 107 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/role_manage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 97 | 98 | 99 |
        100 |
        101 |
        102 | 103 | 104 | 105 | 108 | 111 | 114 | 117 | 120 | 121 | 122 | 123 | 124 |
        106 | 序号 107 | 109 | 角色名称 110 | 112 | 角色类型 113 | 115 | 角色描述 116 | 118 | 操作 119 |
        125 |
        126 |   127 |
        128 |
        129 | 130 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/role_resource.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 125 | 126 | 127 |
        128 |
        129 |
        130 |
          131 | 132 |
        133 | 134 |
        135 | 136 |
        137 |
        138 | 139 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/role_save.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 36 | 37 | 38 |
        39 |
        40 |
        41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 53 | 54 | 55 | 58 | 61 | 62 | 63 | 66 | 69 | 70 | 71 | 74 | 77 | 78 | 79 | 82 | 85 | 86 | 87 | 90 | 91 | 92 |
        新增角色
        48 | 角色名称: 49 | 51 | 52 |
        56 | 角色code: 57 | 59 | 60 |
        64 | 序号: 65 | 67 | 68 |
        72 | 角色类型: 73 | 75 | 76 |
        80 | 描述: 81 | 83 | 84 |
        88 | 89 |
        93 |
        94 |
        95 |
        96 | 97 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/role_update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 56 | 57 | 58 |
        59 |
        60 |
        61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 73 | 74 | 75 | 78 | 81 | 82 | 83 | 86 | 89 | 90 | 91 | 94 | 97 | 98 | 99 | 102 | 105 | 106 | 107 | 110 | 111 | 112 |
        修改角色
        68 | 角色名称: 69 | 71 | 72 |
        76 | 角色code: 77 | 79 | 80 |
        84 | 序号: 85 | 87 | 88 |
        92 | 角色类型: 93 | 95 | 96 |
        100 | 描述: 101 | 103 | 104 |
        108 | 109 |
        113 |
        114 |
        115 |
        116 | 117 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 |
          18 |
        • 19 | 20 | test1 21 |
            22 |
          • 23 | 24 | test11 25 |
          • 26 |
          27 |
            28 |
          • 29 | 30 | test12 31 |
              32 |
            • 33 | 34 | test121 35 |
            • 36 |
            37 |
          • 38 |
          39 |
        • 40 |
        41 | 42 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/user_manage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 95 | 96 | 97 | 98 |
        99 |
        100 |
        101 |
        102 |
        103 | 104 |
        105 |
        106 |
          107 | 131 |
        132 |
        133 |
        134 |
        135 | 136 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/user_role.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 110 | 111 | 112 | 113 |
        114 |
        115 |
        116 |
          117 | 118 |
        119 | 120 |
        121 | 122 |
        123 |
        124 | 125 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/user_save.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 71 | 72 | 73 |
        74 |
        75 |
        76 | 77 | 78 | 79 | 80 | 81 | 82 | 85 | 88 | 89 | 90 | 93 | 96 | 97 | 98 | 101 | 104 | 105 | 106 | 109 | 110 | 111 |
        请填写注册用户信息
        83 | 用户登陆名: 84 | 86 | 87 |
        91 | 用户真实姓名: 92 | 94 | 95 |
        99 | 密码: 100 | 102 | 103 |
        107 | 108 |
        112 |
        113 |
        114 |
        115 | 116 | -------------------------------------------------------------------------------- /focus/src/main/resources/static/user_update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 52 | 53 | 54 |
        55 |
        56 |
        57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 68 | 69 | 70 | 73 | 76 | 77 | 78 | 81 | 84 | 85 | 86 | 89 | 90 | 91 |
        修改用户信息
        64 | 66 | 67 |
        71 | 用户真实姓名: 72 | 74 | 75 |
        79 | 密码: 80 | 82 | 83 |
        87 | 88 |
        92 |
        93 |
        94 |
        95 | 96 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/403.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 未授权 9 | 10 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/NewFile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello 5 | 6 | 7 | 8 | 13 | 14 | 15 | 16 |

        3333

        17 | 百度 18 | 当前项目下能直接访问的静态页面 19 | 访问后端首页 20 | how are you 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
        NAMEAGESORT
        Onions2.41yes
        37 | 38 |
        39 | 40 |
        41 | 42 | 43 | 44 |

        Welcome to our grocery store!

        45 | yes

        46 | 47 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 首页 7 | 8 | 11 | 12 | 13 | 14 |
        这是谁
        15 | 退出登录 16 | 17 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 欢迎登陆 6 | 7 | 66 | 67 | 105 | 106 | 107 | 108 | 109 |
        110 |      欢迎登陆 111 |
        112 | 用户名
        113 | 密 码
        114 | 115 |
        116 |
        117 | 118 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/no.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | no 5 | 6 | 7 | 8 | 9 | 10 | yes

        11 | 12 | -------------------------------------------------------------------------------- /focus/src/main/resources/templates/session.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | session是否共享 5 | 6 | 7 | 8 |
        项目一
        9 |

        id是多少

        10 | 11 | -------------------------------------------------------------------------------- /focus/src/test/java/com/melo/focus/FocusApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.melo.focus; 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 FocusApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /img/auth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/img/auth.png -------------------------------------------------------------------------------- /img/authority.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/img/authority.png -------------------------------------------------------------------------------- /img/resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/img/resource.png -------------------------------------------------------------------------------- /img/role.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/img/role.png -------------------------------------------------------------------------------- /img/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MeloFocus/focus/a09cf4ffa10574d0404f603790d54ec94ea45edf/img/user.png --------------------------------------------------------------------------------