baihe 3 жил өмнө
parent
commit
82b28f0d00
61 өөрчлөгдсөн 1077 нэмэгдсэн , 212 устгасан
  1. 6 1
      common-entity/src/main/java/com/gihon/common/entity/GihonButton.java
  2. 2 1
      common-entity/src/main/java/com/gihon/common/entity/GihonCompany.java
  3. 8 2
      common-entity/src/main/java/com/gihon/common/entity/GihonMenu.java
  4. 11 2
      common-entity/src/main/java/com/gihon/common/entity/GihonModule.java
  5. 1 1
      common-entity/src/main/java/com/gihon/common/entity/GihonRole.java
  6. 1 1
      common-entity/src/main/java/com/gihon/common/entity/GihonUser.java
  7. 16 0
      common-entity/src/main/java/com/gihon/common/entity/vo/CompanyListReq.java
  8. 20 0
      common-entity/src/main/java/com/gihon/common/entity/vo/ModuleListReq.java
  9. 21 0
      common-entity/src/main/java/com/gihon/common/entity/vo/RoleButtonReq.java
  10. 20 0
      common-entity/src/main/java/com/gihon/common/entity/vo/RoleListReq.java
  11. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonButtonMapper.java
  12. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonCompanyMapper.java
  13. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonMenuMapper.java
  14. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonModuleMapper.java
  15. 30 0
      common-entity/src/main/java/com/gihon/common/mapper/GihonRoleButtonMapper.java
  16. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonRoleMapper.java
  17. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonUserMapper.java
  18. 1 1
      common-entity/src/main/java/com/gihon/common/mapper/GihonUserRoleMapper.java
  19. 2 1
      common-springboot/src/main/java/com/gihon/GihonCommonApplication.java
  20. 10 5
      common-springboot/src/main/java/com/gihon/config/swagger/DemoKnife4jConfig.java
  21. 1 2
      common-springboot/src/main/java/com/gihon/config/web/ValidationInterceptor.java
  22. 1 1
      common-springboot/src/main/java/com/gihon/config/web/WebMvcConfig.java
  23. 0 29
      common-springboot/src/main/java/com/gihon/controller/DispatcherController.java
  24. 67 0
      common-springboot/src/main/java/com/gihon/demo/common/controller/CompanyController.java
  25. 113 0
      common-springboot/src/main/java/com/gihon/demo/common/controller/ModuleController.java
  26. 77 0
      common-springboot/src/main/java/com/gihon/demo/common/controller/RoleController.java
  27. 27 0
      common-springboot/src/main/java/com/gihon/demo/common/controller/UserController.java
  28. 27 52
      common-springboot/src/main/resources/application.yml
  29. BIN
      common-springboot/src/main/resources/static/favicon.ico
  30. 0 14
      common-springboot/src/test/java/com/gihon/GihonCommonApplicationTests.java
  31. 2 1
      common-sso/src/main/java/com/gihon/sso/SingleSignOnApp.java
  32. 3 4
      common-sso/src/main/java/com/gihon/sso/auth/AuthService.java
  33. 6 0
      common-sso/src/main/java/com/gihon/sso/auth/AuthTokenInterceptor.java
  34. 11 2
      common-sso/src/main/java/com/gihon/sso/auth/AuthenticationInterceptor.java
  35. 11 8
      common-sso/src/main/java/com/gihon/sso/controller/LoginController.java
  36. 4 0
      common-sso/src/main/java/com/gihon/sso/entity/vo/RefreshTokenVal.java
  37. 4 0
      common-sso/src/main/java/com/gihon/sso/entity/vo/TokenVal.java
  38. 0 11
      common-sso/src/main/java/com/gihon/sso/mapper/GihonRoleButtonMapper.java
  39. 5 2
      common-sso/src/main/java/com/gihon/sso/redis/RedisKeyExpirationListener.java
  40. 51 5
      common-sso/src/main/java/com/gihon/sso/service/GihonButtonService.java
  41. 58 2
      common-sso/src/main/java/com/gihon/sso/service/GihonCompanyService.java
  42. 62 13
      common-sso/src/main/java/com/gihon/sso/service/GihonMenuService.java
  43. 61 2
      common-sso/src/main/java/com/gihon/sso/service/GihonModuleService.java
  44. 45 7
      common-sso/src/main/java/com/gihon/sso/service/GihonRoleButtonService.java
  45. 125 6
      common-sso/src/main/java/com/gihon/sso/service/GihonRoleService.java
  46. 14 4
      common-sso/src/main/java/com/gihon/sso/service/GihonUserRoleService.java
  47. 1 1
      common-sso/src/main/java/com/gihon/sso/service/GihonUserService.java
  48. 1 1
      common-sso/src/main/java/com/gihon/sso/service/TokenService.java
  49. 16 6
      common-sso/src/main/java/com/gihon/sso/service/impl/TokenServiceImpl.java
  50. 14 1
      common-sso/src/main/resources/application.yml
  51. 4 2
      common-util/src/main/java/com/gihon/common/aspect/LogAspect.java
  52. 0 2
      common-util/src/main/java/com/gihon/common/entity/BaseEntity.java
  53. 18 0
      common-util/src/main/java/com/gihon/common/entity/CompanyBaseEntity.java
  54. 8 4
      common-util/src/main/java/com/gihon/common/mybatis/config/MyMetaObjectHandler.java
  55. 1 1
      common-util/src/main/java/com/gihon/common/properties/GihonCommonProperties.java
  56. 7 0
      common-util/src/main/java/com/gihon/common/util/PasswordUtils.java
  57. 2 2
      common-util/src/main/java/com/gihon/common/web/response/PageBean.java
  58. 6 1
      common-util/src/main/java/com/gihon/common/web/response/Response.java
  59. 5 4
      common-util/src/main/resources/application-common.yml
  60. 63 0
      common-util/src/main/resources/logback-spring.xml
  61. 1 1
      pom.xml

+ 6 - 1
common-entity/src/main/java/com/gihon/common/entity/GihonButton.java

@@ -1,5 +1,6 @@
 package com.gihon.common.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -26,7 +27,7 @@ import lombok.Data;
  */
 @Data
 @TableName("gihon_button")
-public class GihonButton extends BaseEntity{
+public class GihonButton extends CompanyBaseEntity{
 
 	@ApiModelProperty(value = "菜单名称")
 	private String buttonName;
@@ -46,4 +47,8 @@ public class GihonButton extends BaseEntity{
 	@ApiModelProperty(value = "后台访问方法:用于服务器判断权限")
 	private String method;
 	
+	@ApiModelProperty(value = "是否选中")
+	@TableField(exist = false)
+	private boolean checked;
+	
 }

+ 2 - 1
common-entity/src/main/java/com/gihon/common/entity/GihonCompany.java

@@ -26,5 +26,6 @@ public class GihonCompany extends BaseEntity{
 	@ApiModelProperty(value = "地址")
 	private String address;
 	
-	
+	@ApiModelProperty(value = "是否启用")
+	private Boolean enable;
 }

+ 8 - 2
common-entity/src/main/java/com/gihon/common/entity/GihonMenu.java

@@ -1,5 +1,8 @@
 package com.gihon.common.entity;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -20,21 +23,24 @@ import lombok.Data;
  */
 @Data
 @TableName("gihon_menu")
-public class GihonMenu extends BaseEntity{
+public class GihonMenu extends CompanyBaseEntity{
 
-	
+	@NotBlank
 	@ApiModelProperty(value = "菜单名称")
 	private String menuName;
 	
+	@NotBlank
 	@ApiModelProperty(value = "菜单编码唯一")
 	private String menuCode;
 	
 	@ApiModelProperty(value = "排序号升序")
 	private Integer orderNum;
 	
+	@NotNull
 	@ApiModelProperty(value = "所属模块")
 	private Long moduleId;	
 
+	@NotNull
 	@ApiModelProperty(value = "父菜单:-1的代表顶级菜单")
 	private Long parentId = -1L;
 	

+ 11 - 2
common-entity/src/main/java/com/gihon/common/entity/GihonModule.java

@@ -1,5 +1,10 @@
 package com.gihon.common.entity;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -12,12 +17,13 @@ import lombok.Data;
  */
 @Data
 @TableName("gihon_module")
-public class GihonModule extends BaseEntity{
+public class GihonModule extends CompanyBaseEntity{
 
-	
+	@NotBlank(message = "模块名称不许为空")
 	@ApiModelProperty(value = "模块名称")
 	private String moduleName;
 	
+	@NotBlank(message = "模块编码不许为空")
 	@ApiModelProperty(value = "模块编码")
 	private String moduleCode;
 	
@@ -33,6 +39,9 @@ public class GihonModule extends BaseEntity{
 	/**
 	 * @see com.gihon.common.enums.ModuleType
 	 */
+	@Min(value = 1,message = "模块类型请设置1-3范围内")
+	@Max(value = 3,message = "模块类型请设置1-3范围内")
+	@NotNull(message = "模块类型不许为空")
 	@ApiModelProperty(value = "模块类型")
 	private Integer moduleType;
 }

+ 1 - 1
common-entity/src/main/java/com/gihon/common/entity/GihonRole.java

@@ -12,7 +12,7 @@ import lombok.Data;
  */
 @Data
 @TableName("gihon_role")
-public class GihonRole extends BaseEntity{
+public class GihonRole extends CompanyBaseEntity{
 
 	
 	@ApiModelProperty(value = "角色名称")

+ 1 - 1
common-entity/src/main/java/com/gihon/common/entity/GihonUser.java

@@ -13,7 +13,7 @@ import lombok.Data;
  */
 @Data
 @TableName("gihon_user")
-public class GihonUser extends BaseEntity{
+public class GihonUser extends CompanyBaseEntity{
 
 	@ApiModelProperty(value = "名称")
 	private String nickName;

+ 16 - 0
common-entity/src/main/java/com/gihon/common/entity/vo/CompanyListReq.java

@@ -0,0 +1,16 @@
+package com.gihon.common.entity.vo;
+
+import com.gihon.common.web.request.PageReq;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("公司列表")
+@Data
+public class CompanyListReq extends PageReq{
+
+	@ApiModelProperty("公司名称")
+	private String companyName;
+	
+}

+ 20 - 0
common-entity/src/main/java/com/gihon/common/entity/vo/ModuleListReq.java

@@ -0,0 +1,20 @@
+package com.gihon.common.entity.vo;
+
+import com.gihon.common.web.request.PageReq;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("模块列表")
+@Data
+public class ModuleListReq extends PageReq{
+
+	@ApiModelProperty("模块名称")
+	private String moduleName;
+	
+
+	@ApiModelProperty("模块编码")
+	private String moduleCode;
+	
+}

+ 21 - 0
common-entity/src/main/java/com/gihon/common/entity/vo/RoleButtonReq.java

@@ -0,0 +1,21 @@
+package com.gihon.common.entity.vo;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("角色按钮设置")
+@Data
+public class RoleButtonReq {
+
+	@ApiModelProperty("角色ID")
+	private Long roleId;
+	@ApiModelProperty("模块ID")
+	private Long moduleId;
+	
+	@ApiModelProperty("按钮ID")
+	private List<Long> buttonList;
+	
+}

+ 20 - 0
common-entity/src/main/java/com/gihon/common/entity/vo/RoleListReq.java

@@ -0,0 +1,20 @@
+package com.gihon.common.entity.vo;
+
+import com.gihon.common.web.request.PageReq;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("角色列表")
+@Data
+public class RoleListReq extends PageReq{
+
+	@ApiModelProperty("角色名称")
+	private String roleName;
+	
+
+	@ApiModelProperty("角色编码")
+	private String roleCode;
+	
+}

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonButtonMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonButtonMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonCompanyMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonCompanyMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonMenuMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonMenuMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonModuleMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonModuleMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 30 - 0
common-entity/src/main/java/com/gihon/common/mapper/GihonRoleButtonMapper.java

@@ -0,0 +1,30 @@
+package com.gihon.common.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gihon.common.entity.GihonRoleButton;
+
+@Mapper
+public interface GihonRoleButtonMapper extends BaseMapper<GihonRoleButton>{
+
+	@Insert({"<script>"
+			,"insert ignore into gihon_role_button_tr (role_id,button_id) values "
+			,"<foreach collection=\"buttonList\"  item=\"item\" separator=\",\" >"
+			,"(#{roleId},#{item})"
+			,"</foreach>"
+			,"</script>"})
+	boolean insertRoleButton(@Param("roleId")Long roleId,@Param("buttonList")List<Long> buttonList);
+	
+	@Insert({"<script>"
+		,"delete from gihon_role_button_tr where role_id = #{roleId} and button_id in "
+		,"<foreach collection=\"buttonList\"  item=\"item\" separator=\",\" open=\"(\" close=\")\">"
+		,"#{item}"
+		,"</foreach>"
+		,"</script>"})
+	boolean deleteRoleButton(@Param("roleId")Long roleId,@Param("buttonList")List<Long> buttonList);
+}

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonRoleMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonRoleMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonUserMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonUserMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/mapper/GihonUserRoleMapper.java → common-entity/src/main/java/com/gihon/common/mapper/GihonUserRoleMapper.java

@@ -1,4 +1,4 @@
-package com.gihon.sso.mapper;
+package com.gihon.common.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 

+ 2 - 1
common-springboot/src/main/java/com/gihon/GihonCommonApplication.java

@@ -2,8 +2,9 @@ package com.gihon;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
 
-@SpringBootApplication
+@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
 public class GihonCommonApplication {
 
 	public static void main(String[] args) {

+ 10 - 5
common-springboot/src/main/java/com/gihon/common/swagger/Knife4jConfig.java → common-springboot/src/main/java/com/gihon/config/swagger/DemoKnife4jConfig.java

@@ -1,4 +1,4 @@
-package com.gihon.common.swagger;
+package com.gihon.config.swagger;
 
 import java.net.Inet4Address;
 import java.net.InetAddress;
@@ -6,6 +6,7 @@ import java.util.List;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.boot.ansi.AnsiColor;
 import org.springframework.boot.web.context.WebServerInitializedEvent;
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.annotation.Bean;
@@ -34,9 +35,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 @EnableSwagger2
 @EnableKnife4j
 @Import(BeanValidatorPluginsConfiguration.class)
-public class Knife4jConfig implements ApplicationListener<WebServerInitializedEvent> {
+public class DemoKnife4jConfig implements ApplicationListener<WebServerInitializedEvent> {
 
-    private static Logger logger = LoggerFactory.getLogger(Knife4jConfig.class);
+    private static Logger logger = LoggerFactory.getLogger(DemoKnife4jConfig.class);
 
     @Bean(value = "web")
     public Docket createRestAdmin() {
@@ -45,12 +46,13 @@ public class Knife4jConfig implements ApplicationListener<WebServerInitializedEv
         List<RequestParameter> parameters = Lists.newArrayList();
         parameters.add(parameter);
         return new Docket(DocumentationType.SWAGGER_2)
+        		.enable(true)
                 .useDefaultResponseMessages(false)
                 .groupName("DEMO")
                 .apiInfo(apiInfo())
                 .globalRequestParameters(parameters)
                 .select()
-                .apis(RequestHandlerSelectors.basePackage("com.gihon.**.controller"))
+                .apis(RequestHandlerSelectors.basePackage("com.gihon"))
                 .paths(PathSelectors.any())
                 .build();
 
@@ -62,11 +64,14 @@ public class Knife4jConfig implements ApplicationListener<WebServerInitializedEv
                 .build();
     }
 
+    /**
+     * @see org.springframework.boot.ansi.AnsiColor.RED
+     */
     @Override
     public void onApplicationEvent(WebServerInitializedEvent event) {
         try {
             InetAddress inetAddress = Inet4Address.getLocalHost();
-            logger.info("\033[1;33m项目启动成功!接口文档地址: http://" + inetAddress.getHostAddress() + ":" + event.getWebServer().getPort() + event.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path") + "/doc.html\033[0m");
+            logger.info("\033[1;32m项目启动成功!接口文档地址: http://" + inetAddress.getHostAddress() + ":" + event.getWebServer().getPort() + event.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path") + "/doc.html\033[0m");
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 1 - 2
common-springboot/src/main/java/com/gihon/common/web/ValidationInterceptor.java → common-springboot/src/main/java/com/gihon/config/web/ValidationInterceptor.java

@@ -1,5 +1,4 @@
-package com.gihon.common.web;
-
+package com.gihon.config.web;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;

+ 1 - 1
common-springboot/src/main/java/com/gihon/common/web/WebMvcConfig.java → common-springboot/src/main/java/com/gihon/config/web/WebMvcConfig.java

@@ -1,4 +1,4 @@
-package com.gihon.common.web;
+package com.gihon.config.web;
 
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;

+ 0 - 29
common-springboot/src/main/java/com/gihon/controller/DispatcherController.java

@@ -1,29 +0,0 @@
-package com.gihon.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-/**
- * 视图跳转控制器
- */
-@Controller
-public class DispatcherController {
-    @RequestMapping(value={"/fail"}, method = {RequestMethod.GET, RequestMethod.POST})
-    public String toFail(){
-        System.out.println("fail");
-        return "/fail";
-    }
-
-    @RequestMapping(value={"/success"}, method = {RequestMethod.GET, RequestMethod.POST})
-    public String toSuccess(){
-        return "success";
-    }
-
-    // 跳转到登录页面
-    @GetMapping("/")
-    public String toLogin(){
-        return "login";
-    }
-}

+ 67 - 0
common-springboot/src/main/java/com/gihon/demo/common/controller/CompanyController.java

@@ -0,0 +1,67 @@
+package com.gihon.demo.common.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gihon.common.auth.AuthUtils;
+import com.gihon.common.entity.GihonCompany;
+import com.gihon.common.entity.vo.CompanyListReq;
+import com.gihon.common.web.response.PageBean;
+import com.gihon.common.web.response.Response;
+import com.gihon.sso.service.GihonCompanyService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value ="公司模块" ,tags = "公司模块")
+@RestController
+@RequestMapping("company")
+public class CompanyController {
+
+	@Autowired
+	private GihonCompanyService companyService;
+	
+	@Autowired
+	private MybatisPlusProperties mybatisPlusProperties;
+	
+	@ApiOperation("COMPANY:列表")
+	@GetMapping("list")
+	public Response<PageBean<GihonCompany>> list(CompanyListReq  companyListReq) {
+		System.out.println(mybatisPlusProperties.getGlobalConfig().getDbConfig().getLogicDeleteValue());
+		IPage<GihonCompany> list = companyService.getCompanylistPage(companyListReq);
+		return Response.okPage(list);
+	}
+	
+	@ApiOperation("COMPANY:启用")
+	@PostMapping("enable/{id}")
+	public Response<Void> enable(@PathVariable Long id) {
+		companyService.enableCompany(id, AuthUtils.getUserId(), true);
+		return Response.ok();
+	}
+	@ApiOperation("COMPANY:禁用")
+	@PostMapping("disable/{id}")
+	public Response<Void> disable(@PathVariable Long id) {
+		companyService.enableCompany(id, AuthUtils.getUserId(), false);
+		return Response.ok();
+	}
+	@ApiOperation("COMPANY:新增")
+	@PostMapping("")
+	public Response<Void> saveCompany(@RequestBody GihonCompany company) {
+		companyService.saveCompany(company);
+		return Response.ok();
+	}
+	@ApiOperation("COMPANY:编辑")
+	@PostMapping("/{id}")
+	public Response<Void> updateCompany(@RequestBody GihonCompany company,@PathVariable Long id) {
+		company.setId(id);
+		companyService.updateCompany(company);
+		return Response.ok();
+	}
+}

+ 113 - 0
common-springboot/src/main/java/com/gihon/demo/common/controller/ModuleController.java

@@ -0,0 +1,113 @@
+package com.gihon.demo.common.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gihon.common.entity.GihonButton;
+import com.gihon.common.entity.GihonMenu;
+import com.gihon.common.entity.GihonModule;
+import com.gihon.common.entity.vo.ModuleListReq;
+import com.gihon.common.web.response.PageBean;
+import com.gihon.common.web.response.Response;
+import com.gihon.sso.service.GihonButtonService;
+import com.gihon.sso.service.GihonMenuService;
+import com.gihon.sso.service.GihonModuleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value ="系统菜单权限模块" ,tags = "系统菜单权限")
+@RestController
+@RequestMapping("module")
+public class ModuleController {
+
+	@Autowired
+	private GihonModuleService moduleService;
+	@Autowired
+	private GihonMenuService menuService;
+	@Autowired
+	private GihonButtonService buttonService;
+	
+	@ApiOperation("模块:列表")
+	@GetMapping("list")
+	public Response<PageBean<GihonModule>> list(ModuleListReq  moduleListReq) {
+		IPage<GihonModule> list = moduleService.getModulelistPage(moduleListReq);
+		return Response.okPage(list);
+	}
+	
+	@ApiOperation("模块:新增")
+	@PostMapping("")
+	public Response<Void> saveModule(@RequestBody GihonModule module) {
+		moduleService.saveModule(module);
+		return Response.ok();
+	}
+	@ApiOperation("模块:编辑")
+	@PostMapping("/{id}")
+	public Response<Void> updateModule(@RequestBody GihonModule module,@PathVariable Long id) {
+		module.setId(id);
+		moduleService.updateModule(module);
+		return Response.ok();
+	}
+	@ApiOperation("模块:全部列表")
+	@GetMapping("all")
+	public Response<List<GihonModule>> list() {
+		List<GihonModule> list = moduleService.list();
+		return Response.ok(list);
+	}
+	/**************菜单**********************/
+	@ApiOperation("菜单:列表")
+	@GetMapping("menu/list")
+	public Response<List<GihonMenu>> listMenu(@RequestParam Long moduleId,@RequestParam(required = false) Long menuId) {
+		if(menuId==null) {
+			menuId = -1L;
+		}
+		List<GihonMenu> list = menuService.getSubMenu(moduleId,menuId);
+		return Response.ok(list);
+	}
+	
+	@ApiOperation("菜单:新增")
+	@PostMapping("menu")
+	public Response<Void> saveMenu(@RequestBody GihonMenu menu) {
+		menuService.saveMenu(menu);
+		return Response.ok();
+	}
+	@ApiOperation("菜单:编辑")
+	@PostMapping("menu/{id}")
+	public Response<Void> updateMenu(@RequestBody GihonMenu menu,@PathVariable Long id) {
+		menu.setId(id);
+		menuService.updateMenu(menu);
+		return Response.ok();
+	}
+	/***************权限按钮******************/
+	@ApiOperation("按钮权限:列表")
+	@GetMapping("button/list")
+	public Response<List<GihonButton>> listButton(@RequestParam Long menuId) {
+		List<GihonButton> list = buttonService.getMenuButton(menuId);
+		return Response.ok(list);
+	}
+	
+	@ApiOperation("按钮权限:新增")
+	@PostMapping("button")
+	public Response<Void> saveButton(@RequestBody GihonButton bottun) {
+		buttonService.saveButton(bottun);
+		return Response.ok();
+	}
+	@ApiOperation("按钮权限:编辑")
+	@PostMapping("button/{id}")
+	public Response<Void> updateButton(@RequestBody GihonButton bottun,@PathVariable Long id) {
+		bottun.setId(id);
+		buttonService.updateButton(bottun);
+		return Response.ok();
+	}
+	
+	
+}

+ 77 - 0
common-springboot/src/main/java/com/gihon/demo/common/controller/RoleController.java

@@ -0,0 +1,77 @@
+package com.gihon.demo.common.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gihon.common.entity.GihonButton;
+import com.gihon.common.entity.GihonRole;
+import com.gihon.common.entity.vo.RoleButtonReq;
+import com.gihon.common.entity.vo.RoleListReq;
+import com.gihon.common.web.response.PageBean;
+import com.gihon.common.web.response.Response;
+import com.gihon.sso.service.GihonRoleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value = "角色模块", tags = "角色模块")
+@RestController
+@RequestMapping("role")
+public class RoleController {
+
+	@Autowired
+	private GihonRoleService roleService;
+
+	@ApiOperation("ROLE:角色列表")
+	@GetMapping("list")
+	public Response<PageBean<GihonRole>> list(RoleListReq roleListReq) {
+		IPage<GihonRole> list = roleService.getRolelistPage(roleListReq);
+		return Response.okPage(list);
+	}
+
+	@ApiOperation("模块:新增")
+	@PostMapping("")
+	public Response<Void> saveRole(@RequestBody GihonRole role) {
+		roleService.saveRole(role);
+		return Response.ok();
+	}
+
+	@ApiOperation("模块:编辑")
+	@PostMapping("/{id}")
+	public Response<Void> updateRole(@RequestBody GihonRole role, @PathVariable Long id) {
+		role.setId(id);
+		roleService.updateRole(role);
+		return Response.ok();
+	}
+
+	@ApiOperation("模块:删除")
+	@DeleteMapping("/{id}")
+	public Response<Void> removeRole(@RequestBody GihonRole role, @PathVariable Long id) {
+		role.setId(id);
+		roleService.removeRole(role);
+		return Response.ok();
+	}
+
+	@ApiOperation("ROLE:权限列表")
+	@GetMapping("button/list")
+	public Response<List<GihonButton>> getButtonByRoleModule(@RequestParam Long roleId, @RequestParam Long moduleId) {
+		return Response.ok(roleService.getButtonByRoleModule(roleId, moduleId));
+	}
+
+	@ApiOperation("ROLE:设置权限列表")
+	@PostMapping("button/set")
+	public Response<Void> setButtonByRoleModule(@RequestBody RoleButtonReq req) {
+		roleService.setButtonByRoleModule(req);
+		return Response.ok();
+	}
+}

+ 27 - 0
common-springboot/src/main/java/com/gihon/demo/common/controller/UserController.java

@@ -0,0 +1,27 @@
+package com.gihon.demo.common.controller;
+
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.gihon.common.web.response.Response;
+import com.gihon.sso.entity.vo.LoginUser;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+
+@Api(value ="人员模块" ,tags = "人员模块")
+@Slf4j
+@RestController
+@RequestMapping("user")
+public class UserController {
+
+	@ApiOperation("USER:用户列表")
+	@PostMapping()
+	public Response<Void> login(@RequestBody LoginUser loginUser) {
+		log.debug("SSO登录开始:{}", loginUser.getUserAccount());
+		return Response.ok();
+	}
+}

+ 27 - 52
common-springboot/src/main/resources/application.yml

@@ -1,67 +1,42 @@
-sso: 
-  root-path: login
 server:
   port: 10021
   servlet:
-    context-path: /security
+    context-path: /demo
   tomcat: 
     uri-encoding: UTF-8
     basedir: /data/tmp
+    
+spring: 
+  profiles:
+    include:
+      - common
 
-spring:
-  jackson:
-    time-zone: GMT+8
-    date-format: yyyy-MM-dd HH:mm:ss   
-    serialization: 
-      WRITE_DURATIONS_AS_TIMESTAMPS: false
-# Redis           
+  # Redis           
   redis:
-    database: 1          # Redis数据库索引(默认为0)
+    database: 8          # Redis数据库索引(默认为0)
     timeout: 0            # 连接超时时间(毫秒)
     host: 172.18.0.23
     port: 6379
     password: Ebe1tech/Passw0rd
-    jedis: 
-      pool:
-        max-idle: 10
-        max-active: 10
-        max-wait: 1000
         
 # dataBase
-           
   datasource: 
-   platform: mysql
-   url: jdbc:mysql://172.18.0.23:3306/gihon?characterEncoding=UTF-8&useSSL=false
-   username: root
-   password: 1q2w3e4r
-   driver-class-name: com.mysql.cj.jdbc.Driver
-   hikari: 
-     idle-timeout: 600000
-     validation-timeout: 1000
-     maximum-pool-size: 30
-     connection-timeout: 60000
-     transactionIsolation: TRANSACTION_READ_COMMITTED
-mybatis-plus:
-  mapper-locations:
-      - classpath:/mapper/**Mapper.xml
-  #实体扫描,多个package用逗号或者分号分隔
-  typeAliasesPackage: 
-  global-config:
-    db-config:
-      dbType: MYSQL
-      #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
-      id-type: AUTO
-      #字段策略IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
-      field-strategy: NOT_NULL
-      #逻辑删除配置(下面3个配置)
-      logic-delete-value: 1
-      logic-not-delete-value: 0
-  configuration:
-    #驼峰下划线转换
-    map-underscore-to-camel-case: true
-    cache-enabled: false
-    jdbc-type-for-null: 'null'
-
-logging:
-  level:
-    com.gihon.mapper: debug
+    druid:
+      # 从这里开始(druid),中间的这段配置用于 pocky.database.multiTenantType != DATASOURCE 时
+      url: jdbc:mysql://172.18.0.23:3306/gihon?characterEncoding=UTF-8&useSSL=false
+      username: root
+      password: 1q2w3e4r
+knife4j: 
+  # 开启增强配置 
+  enable: true
+  setting: 
+    swaggerModelName: '模型名称'
+    enableFooter: false
+  documents:
+    - 
+      group: SSO
+      name: 登录验证模块
+gihon:
+  common:
+    module-type: 1
+    module-code: SystemManage

BIN
common-springboot/src/main/resources/static/favicon.ico


+ 0 - 14
common-springboot/src/test/java/com/gihon/GihonCommonApplicationTests.java

@@ -1,14 +0,0 @@
-package com.gihon;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class GihonCommonApplicationTests {
-
-	@Test
-	void contextLoads() {
-
-	}
-
-}

+ 2 - 1
common-sso/src/main/java/com/gihon/sso/SingleSignOnApp.java

@@ -2,6 +2,7 @@ package com.gihon.sso;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
 import org.springframework.boot.builder.SpringApplicationBuilder;
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
 import org.springframework.context.annotation.ComponentScan;
@@ -14,7 +15,7 @@ import org.springframework.context.annotation.ComponentScan;
  *
  */
 @ComponentScan(basePackages = {"com.gihon.common","com.gihon.sso"})
-@SpringBootApplication
+@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
 public class SingleSignOnApp extends SpringBootServletInitializer {
 	
 	public static void main(String[] args) {

+ 3 - 4
common-sso/src/main/java/com/gihon/sso/auth/AuthService.java

@@ -72,7 +72,7 @@ public class AuthService {
 		// 获取全部的权限列表匹配
 		// 用权限匹配角色
 		List<String> needRole = getPermission(uri);
-		if (needRole == null || needRole.isEmpty()) {
+		if (needRole == null ) {
 			return true;
 		} else if (role == null) {
 			return false;
@@ -151,12 +151,11 @@ public class AuthService {
 				if (StringUtils.isBlank(btn.getPath())) {
 					continue;
 				}
-				List<GihonRoleButton> rbtnList = gihonRoleButtonService.getButtonListByBtn(btn.getId());
+				List<Long> rbtnList = gihonRoleButtonService.getRoleListByBtn(btn.getId());
 				PermissionVO pvo = new PermissionVO();
 				pvo.setUrl(btn.getPath());
 				pvo.setMethod(btn.getMethod());
-				List<GihonRole> rl = gihonRoleService
-						.getRoleListByIds(rbtnList.stream().map(rb -> rb.getButtonId()).collect(Collectors.toList()));
+				List<GihonRole> rl = gihonRoleService.getRoleListByIds(rbtnList);
 				pvo.setRoleList(rl.stream().map(r -> r.getRoleCode()).collect(Collectors.toList()));
 				plist.add(pvo);
 			}

+ 6 - 0
common-sso/src/main/java/com/gihon/sso/auth/AuthTokenInterceptor.java

@@ -81,6 +81,12 @@ public class AuthTokenInterceptor implements HandlerInterceptor {
 				// todo: support additional authorization schemes for different token types,
 				// e.g. "MAC" specified by
 				// http://tools.ietf.org/html/draft-hammer-oauth-v2-mac-token
+				String authHeaderValue = value.trim();
+				int commaIndex = authHeaderValue.indexOf(',');
+				if (commaIndex > 0) {
+					authHeaderValue = authHeaderValue.substring(0, commaIndex);
+				}
+				return authHeaderValue;
 			}
 		}
 

+ 11 - 2
common-sso/src/main/java/com/gihon/sso/auth/AuthenticationInterceptor.java

@@ -61,14 +61,23 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
         }else if (AuthConstans.ADMIN.equals(user.getUsername())) {
             return false;
         }
-
         //动态鉴权
-        boolean checkPermission = authService.checkPermission(request.getMethod()+RedisConstants.SEP+request.getRequestURI(),gihonCommonProperties.getModuleType(),token,user);
+        boolean checkPermission = authService.checkPermission(request.getMethod()+RedisConstants.SEP+getUri(request),gihonCommonProperties.getModuleType(),token,user);
         if (!checkPermission) {
             throw new LoginException(ResponseStatus.FORBIDDEN);
         }
         return true;
     }
 
+    private String getUri(HttpServletRequest request) {
+    	String uri = request.getContextPath();
+    	String url = request.getRequestURI();
+//    	String url3 = request.getServletPath();
+    	if(uri.equals("/")) {
+    		return url;
+    	}else {
+    		return url.replace(uri, "");
+    	}
+    }
 
 }

+ 11 - 8
common-sso/src/main/java/com/gihon/sso/controller/LoginController.java

@@ -1,12 +1,14 @@
 package com.gihon.sso.controller;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.gihon.common.auth.AuthUtils;
 import com.gihon.common.web.response.Response;
 import com.gihon.common.web.response.ResponseStatus;
 import com.gihon.sso.entity.vo.LoginUser;
@@ -22,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
 
 @Api("SSO认证模块")
 @Slf4j
-@RequestMapping("${sso.root-path}")
+@RequestMapping("${gihon.common.login-path}")
 @RestController
 public class LoginController {
 	@Autowired
@@ -37,7 +39,7 @@ public class LoginController {
 	 * @return
 	 */
 	@ApiOperation("SSO:登录")
-	@PostMapping("/")
+	@PostMapping()
 	public Response<SsoToken> login(@RequestBody LoginUser loginUser) {
 		log.debug("SSO登录开始:{}", loginUser.getUserAccount());
 		UserInfo userInfo = userService.queryUserForLogin(loginUser.getUserAccount(),loginUser.getPassWord());
@@ -59,9 +61,10 @@ public class LoginController {
 	 * @return
 	 */
 	@ApiOperation("SSO:token获取用户信息")
-	@PostMapping("useInfo")
-	public Response<UserInfo> userInfo(@RequestBody LoginUser loginUser) {
-		UserInfo userInfo = tokenService.checkToken(loginUser);
+	@GetMapping("useInfo")
+	public Response<UserInfo> userInfo() {
+		String token = (String)AuthUtils.getRequest().getAttribute(AuthUtils.REQ_TOKEN);
+		UserInfo userInfo = tokenService.checkTokenInfo(token);
 		Response<UserInfo> result = null;
 		if(userInfo!=null) {
 			result = Response.ok(userInfo);
@@ -78,9 +81,9 @@ public class LoginController {
 	 * @return
 	 */
 	@ApiOperation("SSO:登出")
-	@ApiParam(name="Token",value = "token" ,required = true,type = "query")
-	@PostMapping("logout")
-	public Response<Void> logOut(@RequestParam("token") String token) {
+	@GetMapping("logout")
+	public Response<Void> logOut() {
+		String token = (String)AuthUtils.getRequest().getAttribute(AuthUtils.REQ_TOKEN);
 		tokenService.clearToken(token);
 		log.debug("SSO退出:{}", token);
 		return Response.ok();

+ 4 - 0
common-sso/src/main/java/com/gihon/sso/entity/vo/RefreshTokenVal.java

@@ -2,11 +2,15 @@ package com.gihon.sso.entity.vo;
 
 import java.io.Serializable;
 
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 
 @Builder
+@NoArgsConstructor
+@AllArgsConstructor
 @Data
 @EqualsAndHashCode(of = {"token","refreshToken"})
 public class RefreshTokenVal implements Serializable{

+ 4 - 0
common-sso/src/main/java/com/gihon/sso/entity/vo/TokenVal.java

@@ -2,11 +2,15 @@ package com.gihon.sso.entity.vo;
 
 import java.io.Serializable;
 
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 
 @Builder
+@NoArgsConstructor
+@AllArgsConstructor
 @Data
 @EqualsAndHashCode(of = {"token","refreshToken"})
 public class TokenVal implements Serializable{

+ 0 - 11
common-sso/src/main/java/com/gihon/sso/mapper/GihonRoleButtonMapper.java

@@ -1,11 +0,0 @@
-package com.gihon.sso.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gihon.common.entity.GihonRoleButton;
-
-@Mapper
-public interface GihonRoleButtonMapper extends BaseMapper<GihonRoleButton>{
-
-}

+ 5 - 2
common-sso/src/main/java/com/gihon/sso/redis/RedisKeyExpirationListener.java

@@ -19,6 +19,9 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
 	@Autowired
 	private StringRedisTemplate redisTemplate;
 	
+	@Autowired
+	private TokenService tokenService;
+	
 	public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
 	    super(listenerContainer);
     }
@@ -34,8 +37,8 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
         log.debug("[失效RedisKey] [key:{}] [pattern:{}]",expiredKey,new String(pattern));
         if(expiredKey.startsWith(TokenService.REFRESH_TOKEN_PRE)) {
         	String rkey = expiredKey.replace(TokenService.REFRESH_TOKEN_PRE, "");
-        	String userAccount = expiredKey.split("@")[0];
-        	
+        	String userAccount = tokenService.getUserName(rkey);
+        	tokenService.autoClearRefreshToken(rkey,userAccount);
         }
        
     }

+ 51 - 5
common-sso/src/main/java/com/gihon/sso/service/GihonButtonService.java

@@ -6,21 +6,67 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonButton;
-import com.gihon.sso.mapper.GihonButtonMapper;
+import com.gihon.common.exception.BusinessException;
+import com.gihon.common.mapper.GihonButtonMapper;
+import com.google.common.collect.Lists;
 
 /**
  * 直接继承没有多实现处理
+ * 
  * @author edz
  *
  */
 @Service
-public class GihonButtonService extends ServiceImpl<GihonButtonMapper, GihonButton>{
+public class GihonButtonService extends ServiceImpl<GihonButtonMapper, GihonButton> {
 
-	public List<GihonButton> getMenuButton(Long menuId){
+	/**
+	 * 获取菜单下按钮权限
+	 */
+	public List<GihonButton> getMenuButton(Long menuId) {
 		return this.lambdaQuery().eq(GihonButton::getMenuId, menuId).orderByAsc(GihonButton::getOrderNum).list();
 	}
-	
-	public List<GihonButton> getMenuButton(List<Long> menuIdList){
+	/**
+	 * 获取菜单列表下按钮权限
+	 */
+	public List<GihonButton> getMenuButton(List<Long> menuIdList) {
+		if (menuIdList.isEmpty()) {
+			return Lists.newArrayList();
+		}
 		return this.lambdaQuery().in(GihonButton::getMenuId, menuIdList).orderByAsc(GihonButton::getOrderNum).list();
 	}
+	/**
+	 * 新增按钮权限
+	 */
+	public boolean saveButton(GihonButton button) {
+		int count = this.lambdaQuery().eq(GihonButton::getMenuId, button.getMenuId()).and(p -> {
+			p.eq(GihonButton::getButtonName, button.getButtonName()).or().eq(GihonButton::getButtonCode,
+					button.getButtonCode());
+		}).count();
+		if (count > 0) {
+			throw new BusinessException("按钮编码或者名称重复");
+		}
+		return this.save(button);
+
+	}
+	/**
+	 * 更新按钮权限
+	 */
+	public boolean updateButton(GihonButton button) {
+		GihonButton buttonOld = this.getById(button.getId());
+		if (buttonOld == null) {
+			throw new BusinessException("按钮不存在");
+		}
+		int count = this.lambdaQuery().eq(GihonButton::getMenuId, buttonOld.getMenuId())
+				.ne(GihonButton::getId, button.getId()).and(p -> {
+					p.eq(GihonButton::getButtonName, button.getButtonName()).or().eq(GihonButton::getButtonCode,
+							button.getButtonCode());
+				}).count();
+		if (count > 0) {
+			throw new BusinessException("按钮编码或者名称重复");
+		}
+		button.setMenuId(buttonOld.getMenuId());
+
+		return this.updateById(button);
+
+	}
 }

+ 58 - 2
common-sso/src/main/java/com/gihon/sso/service/GihonCompanyService.java

@@ -1,17 +1,73 @@
 package com.gihon.sso.service;
 
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonCompany;
-import com.gihon.sso.mapper.GihonCompanyMapper;
+import com.gihon.common.entity.vo.CompanyListReq;
+import com.gihon.common.exception.BusinessException;
+import com.gihon.common.mapper.GihonCompanyMapper;
 
 /**
  * 直接继承没有多实现处理
+ * 
  * @author edz
  *
  */
 @Service
-public class GihonCompanyService extends ServiceImpl<GihonCompanyMapper, GihonCompany>{
+public class GihonCompanyService extends ServiceImpl<GihonCompanyMapper, GihonCompany> {
 
+	/**
+	 * 分页获取公司列表
+	 */
+	public IPage<GihonCompany> getCompanylistPage(CompanyListReq companyListReq) {
+		Page<GihonCompany> page = new Page<GihonCompany>(companyListReq.getPageIndex(), companyListReq.getPageSize());
+		return this.lambdaQuery().like(StringUtils.hasText(companyListReq.getCompanyName()), GihonCompany::getCompanyName,
+				companyListReq.getCompanyName()).page(page);
+	}
+	/**
+	 * 激活(禁用)公司
+	 */
+	public boolean enableCompany(Long companyId, Long userId, boolean enableFlag) {
+
+		return this.lambdaUpdate().eq(GihonCompany::getId, companyId).eq(GihonCompany::getEnable, !enableFlag)
+				.set(GihonCompany::getEnable, enableFlag).update();
+
+	}
+	/**
+	 * 新增公司
+	 */
+	public boolean saveCompany(GihonCompany compnay) {
+		int count = this.lambdaQuery().eq(GihonCompany::getCompanyName, compnay.getCompanyName()).count();
+		if (count > 0) {
+			throw new BusinessException("公司名称重复");
+		}
+		return this.save(compnay);
+
+	}
+	/**
+	 * 更新公司
+	 */
+	public boolean updateCompany(GihonCompany company) {
+		GihonCompany compnayOld = this.getById(company.getId());
+		if (compnayOld == null) {
+			throw new BusinessException("公司不存在");
+		}
+		int count = this.lambdaQuery().eq(GihonCompany::getCompanyName, company.getCompanyName())
+				.ne(GihonCompany::getId, company.getId()).count();
+		if (count > 0) {
+			throw new BusinessException("公司名称重复");
+		}
+		GihonCompany compnayUpdate = new GihonCompany();
+		compnayUpdate.setId(company.getId());
+		compnayUpdate.setCompanyDescription(company.getCompanyDescription());
+		compnayUpdate.setCompanyName(company.getCompanyName());
+		compnayUpdate.setTelephone(company.getTelephone());
+		compnayUpdate.setAddress(company.getAddress());
+		return this.updateById(compnayUpdate);
+
+	}
 }

+ 62 - 13
common-sso/src/main/java/com/gihon/sso/service/GihonMenuService.java

@@ -7,39 +7,88 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonMenu;
-import com.gihon.sso.mapper.GihonMenuMapper;
+import com.gihon.common.exception.BusinessException;
+import com.gihon.common.mapper.GihonMenuMapper;
 
 /**
  * 直接继承没有多实现处理
+ * 
  * @author edz
  *
  */
 @Service
-public class GihonMenuService extends ServiceImpl<GihonMenuMapper, GihonMenu>{
+public class GihonMenuService extends ServiceImpl<GihonMenuMapper, GihonMenu> {
 
-	public List<GihonMenu> getAllMenu(Long moduleId){
+	/**
+	 * 获取模块下全部菜单
+	 */
+	public List<GihonMenu> getAllMenu(Long moduleId) {
 		List<GihonMenu> rootList = new ArrayList<>();
-		getMenuList(moduleId,-1L,rootList);
+		getMenuList(moduleId, -1L, rootList);
 		return rootList;
 	}
-	
-	public List<GihonMenu> getSubMenu(Long moduleId,Long menuId){
-		return this.lambdaQuery().eq(GihonMenu::getModuleId, moduleId).eq(GihonMenu::getParentId, menuId).orderByAsc(GihonMenu::getOrderNum).list();
+	/**
+	 * 获取模块下子菜单
+	 */
+	public List<GihonMenu> getSubMenu(Long moduleId, Long menuId) {
+		return this.lambdaQuery().eq(GihonMenu::getModuleId, moduleId).eq(GihonMenu::getParentId, menuId)
+				.orderByAsc(GihonMenu::getOrderNum).list();
 	}
+
 	/**
 	 * 递归
-	 * @param moduleId
+	 * 
+	 * @param MenuId
 	 * @param menuId
 	 * @param result
 	 */
-	private void getMenuList(Long moduleId,Long menuId,List<GihonMenu> result) {
-		List<GihonMenu> sublist = this.getSubMenu(moduleId,menuId);
-		if(sublist.isEmpty()) {
+	private void getMenuList(Long moduleId, Long menuId, List<GihonMenu> result) {
+		List<GihonMenu> sublist = this.getSubMenu(moduleId, menuId);
+		if (sublist.isEmpty()) {
 			return;
 		}
 		result.addAll(sublist);
-		for(GihonMenu menu:sublist) {
-			getMenuList(moduleId,menu.getId(),result);
+		for (GihonMenu menu : sublist) {
+			getMenuList(moduleId, menu.getId(), result);
+		}
+	}
+	/**
+	 * 新增菜单
+	 */
+	public boolean saveMenu(GihonMenu menu) {
+		int count = this.lambdaQuery().eq(GihonMenu::getModuleId, menu.getModuleId()).and(p -> {
+			p.eq(GihonMenu::getMenuName, menu.getMenuName()).or().eq(GihonMenu::getMenuCode, menu.getMenuCode());
+		}).count();
+		if (count > 0) {
+			throw new BusinessException("菜单编码或者名称重复");
 		}
+		return this.save(menu);
+
+	}
+	/**
+	 * 编辑菜单
+	 */
+	public boolean updateMenu(GihonMenu menu) {
+		GihonMenu menuOld = this.getById(menu.getId());
+		if (menuOld == null) {
+			throw new BusinessException("菜单不存在");
+		}
+		int count = this.lambdaQuery().eq(GihonMenu::getModuleId, menu.getModuleId()).ne(GihonMenu::getId, menu.getId())
+				.and(p -> {
+					p.eq(GihonMenu::getMenuName, menu.getMenuName()).or().eq(GihonMenu::getMenuCode,
+							menu.getMenuCode());
+				}).count();
+		if (count > 0) {
+			throw new BusinessException("菜单编码或者名称重复");
+		}
+		GihonMenu menuUpdate = new GihonMenu();
+		menuUpdate.setId(menu.getId());
+		menuUpdate.setMenuCode(menu.getMenuCode());
+		menuUpdate.setMenuName(menu.getMenuName());
+		menuUpdate.setOrderNum(menu.getOrderNum());
+		menuUpdate.setPath(menu.getPath());
+
+		return this.updateById(menuUpdate);
+
 	}
 }

+ 61 - 2
common-sso/src/main/java/com/gihon/sso/service/GihonModuleService.java

@@ -1,20 +1,79 @@
 package com.gihon.sso.service;
 
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonModule;
-import com.gihon.sso.mapper.GihonModuleMapper;
+import com.gihon.common.entity.vo.ModuleListReq;
+import com.gihon.common.exception.BusinessException;
+import com.gihon.common.mapper.GihonModuleMapper;
 
 /**
  * 直接继承没有多实现处理
+ * 
  * @author edz
  *
  */
 @Service
-public class GihonModuleService extends ServiceImpl<GihonModuleMapper, GihonModule>{
+public class GihonModuleService extends ServiceImpl<GihonModuleMapper, GihonModule> {
 
+	/**
+	 * 按照code获取模块
+	 */
 	public GihonModule getModuleByCode(String code) {
 		return this.lambdaQuery().eq(GihonModule::getModuleCode, code).one();
 	}
+	/**
+	 * 分页获取模块
+	 */
+	public IPage<GihonModule> getModulelistPage(ModuleListReq moduleListReq) {
+		Page<GihonModule> page = new Page<GihonModule>(moduleListReq.getPageIndex(), moduleListReq.getPageSize());
+		return this.lambdaQuery()
+				.like(StringUtils.hasText(moduleListReq.getModuleName()), GihonModule::getModuleName,
+						moduleListReq.getModuleName())
+				.like(StringUtils.hasText(moduleListReq.getModuleCode()), GihonModule::getModuleCode,
+						moduleListReq.getModuleCode())
+				.page(page);
+	}
+	/**
+	 * 新增模块
+	 */
+	public boolean saveModule(GihonModule module) {
+		int count = this.lambdaQuery().eq(GihonModule::getModuleName, module.getModuleName()).or()
+				.eq(GihonModule::getModuleCode, module.getModuleCode()).count();
+		if (count > 0) {
+			throw new BusinessException("模块编码或者名称重复");
+		}
+		return this.save(module);
+
+	}
+	/**
+	 * 编辑模块
+	 */
+	public boolean updateModule(GihonModule module) {
+		GihonModule moduleOld = this.getById(module.getId());
+		if (moduleOld == null) {
+			throw new BusinessException("模块不存在");
+		}
+		int count = this.lambdaQuery().ne(GihonModule::getId, module.getId()).and(p -> {
+			p.eq(GihonModule::getModuleName, module.getModuleName()).or().eq(GihonModule::getModuleCode,
+					module.getModuleCode());
+		}).count();
+		if (count > 0) {
+			throw new BusinessException("模块编码或者名称重复");
+		}
+		GihonModule moduleUpdate = new GihonModule();
+		moduleUpdate.setId(module.getId());
+		moduleUpdate.setModuleCode(module.getModuleCode());
+		moduleUpdate.setModuleName(module.getModuleName());
+		moduleUpdate.setOrderNum(module.getOrderNum());
+		moduleUpdate.setModuleDescription(module.getModuleDescription());
+		moduleUpdate.setModuleLogo(module.getModuleLogo());
+
+		return this.updateById(moduleUpdate);
+
+	}
 }

+ 45 - 7
common-sso/src/main/java/com/gihon/sso/service/GihonRoleButtonService.java

@@ -1,26 +1,64 @@
 package com.gihon.sso.service;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonRoleButton;
-import com.gihon.sso.mapper.GihonRoleButtonMapper;
+import com.gihon.common.mapper.GihonRoleButtonMapper;
 
 /**
  * 直接继承没有多实现处理
+ * 
  * @author edz
  *
  */
 @Service
-public class GihonRoleButtonService extends ServiceImpl<GihonRoleButtonMapper, GihonRoleButton>{
+public class GihonRoleButtonService extends ServiceImpl<GihonRoleButtonMapper, GihonRoleButton> {
 
-	public List<GihonRoleButton>  getButtonListByBtn(Long buttonId){
-		return this.lambdaQuery().eq(GihonRoleButton::getButtonId, buttonId).list();
+	/**
+	 * 获取按钮关联的角色
+	 */
+	public List<Long> getRoleListByBtn(Long buttonId) {
+		List<GihonRoleButton> list = this.lambdaQuery().eq(GihonRoleButton::getButtonId, buttonId)
+				.select(GihonRoleButton::getRoleId).list();
+		return list.stream().map(rb -> rb.getRoleId()).collect(Collectors.toList());
 	}
-	
-	public List<GihonRoleButton>  getButtonListByRole(Long roleId){
-		return this.lambdaQuery().eq(GihonRoleButton::getRoleId, roleId).list();
+	/**
+	 * 获取角色关联的按钮
+	 */
+	public List<Long> getButtonListByRole(Long roleId) {
+		List<GihonRoleButton> list = this.lambdaQuery().eq(GihonRoleButton::getRoleId, roleId)
+				.select(GihonRoleButton::getButtonId).list();
+		return list.stream().map(rb -> rb.getButtonId()).collect(Collectors.toList());
+	}
+	/**
+	 * 移除角色关联的按钮(buttonList为null的时候是删除全部,否则只是部分删除)
+	 */
+	public boolean removeButtonByRoleId(Long roleId, List<Long> buttonList) {
+		if (buttonList != null && buttonList.isEmpty()) {
+			return false;
+		}
+		return this.lambdaUpdate().eq(GihonRoleButton::getRoleId, roleId).in(buttonList!=null,GihonRoleButton::getButtonId, buttonList).remove();
+	}
+	/**
+	 * 新增角色关联的按钮
+	 */
+	public boolean insertRoleButton(Long roleId, List<Long> buttonList) {
+		if(buttonList==null||buttonList.isEmpty()) {
+			return false;
+		}
+		return this.baseMapper.insertRoleButton(roleId, buttonList);
+	}
+	/**
+	 * 移除角色关联的按钮
+	 */
+	public boolean deleteRoleButton(Long roleId, List<Long> buttonList) {
+		if(buttonList==null||buttonList.isEmpty()) {
+			return false;
+		}
+		return this.baseMapper.deleteRoleButton(roleId, buttonList);
 	}
 }

+ 125 - 6
common-sso/src/main/java/com/gihon/sso/service/GihonRoleService.java

@@ -6,11 +6,19 @@ import java.util.stream.Collectors;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gihon.common.entity.GihonButton;
 import com.gihon.common.entity.GihonRole;
-import com.gihon.common.entity.GihonUserRole;
-import com.gihon.sso.mapper.GihonRoleMapper;
+import com.gihon.common.entity.GihonRoleButton;
+import com.gihon.common.entity.vo.RoleButtonReq;
+import com.gihon.common.entity.vo.RoleListReq;
+import com.gihon.common.exception.BusinessException;
+import com.gihon.common.mapper.GihonRoleMapper;
 
 /**
  * 直接继承没有多实现处理
@@ -24,17 +32,128 @@ public class GihonRoleService extends ServiceImpl<GihonRoleMapper, GihonRole> {
 	@Autowired
 	private GihonUserRoleService gihonUserRoleService;
 
+	@Autowired
+	private GihonRoleButtonService gihonRoleButtonService;
+	
+	@Autowired
+	private GihonButtonService gihonButtonService;
+	@Autowired
+	private GihonMenuService gihonMenuService;
+
+	/**
+	 * 获取用户的角色列表
+	 */
 	public List<GihonRole> getRoleList(Long userId) {
-		List<GihonUserRole> roleList = gihonUserRoleService.roleList(userId);
+		List<Long> roleList = gihonUserRoleService.roleListByUserId(userId);
 		if (roleList.isEmpty()) {
 			return new ArrayList<>(0);
 		}
-		return this.lambdaQuery()
-				.in(GihonRole::getId, roleList.stream().map(ur -> ur.getRoleId()).collect(Collectors.toList())).list();
+		return this.getRoleListByIds(roleList);
 	}
-	
+
+	/**
+	 * 按照角色IDS获取角色列表
+	 */
 	public List<GihonRole> getRoleListByIds(List<Long> ids) {
 		return this.lambdaQuery().in(GihonRole::getId, ids).list();
 	}
+	/**
+	 * 前端分页获取角色列表
+	 */
+	public IPage<GihonRole> getRolelistPage(RoleListReq companyListReq) {
+		Page<GihonRole> page = new Page<GihonRole>(companyListReq.getPageIndex(), companyListReq.getPageSize());
+		return this.lambdaQuery()
+				.like(StringUtils.hasText(companyListReq.getRoleName()), GihonRole::getRoleName,
+						companyListReq.getRoleName())
+				.like(StringUtils.hasText(companyListReq.getRoleCode()), GihonRole::getRoleCode,
+						companyListReq.getRoleCode())
+				.page(page);
+	}
+	/**
+	 * 新增角色
+	 */
+	public boolean saveRole(GihonRole role) {
+		int count = this.lambdaQuery().eq(GihonRole::getRoleName, role.getRoleName()).or()
+				.eq(GihonRole::getRoleCode, role.getRoleCode()).count();
+		if (count > 0) {
+			throw new BusinessException("角色名称或编码重复");
+		}
+		return this.save(role);
 
+	}
+	/**
+	 * 更新角色
+	 */
+	public boolean updateRole(GihonRole role) {
+		GihonRole roleOld = this.getById(role.getId());
+		if (roleOld == null) {
+			throw new BusinessException("角色不存在");
+		}
+		int count = this.lambdaQuery().ne(GihonRole::getId, role.getId()).and(p -> {
+			p.eq(GihonRole::getRoleName, role.getRoleName()).or().eq(GihonRole::getRoleCode, role.getRoleCode());
+		}).count();
+
+		if (count > 0) {
+			throw new BusinessException("角色名称或编码重复");
+		}
+		GihonRole roleUpdate = new GihonRole();
+		roleUpdate.setId(role.getId());
+		roleUpdate.setRoleName(role.getRoleName());
+		roleUpdate.setRoleCode(role.getRoleCode());
+		roleUpdate.setRoleDescription(role.getRoleDescription());
+		return this.updateById(roleUpdate);
+
+	}
+	/**
+	 * 移除一个角色
+	 */
+	@Transactional
+	public boolean removeRole(GihonRole role) {
+		GihonRole roleOld = this.getById(role.getId());
+		if (roleOld == null) {
+			throw new BusinessException("角色不存在");
+		}
+		// 异步通知
+		gihonRoleButtonService.removeButtonByRoleId(role.getId(),null);
+		gihonUserRoleService.removeRoleByUserId(role.getId());
+		return this.removeById(role.getId());
+	}
+
+	/**
+	 * 获取在某个模块下的按钮权限
+	 */
+	public List<GihonButton> getButtonByRoleModule(Long roleId, Long moduleId) {
+		List<Long> menuIdList = gihonMenuService.getAllMenu(moduleId).stream().map(m -> m.getId())
+				.collect(Collectors.toList());
+		List<GihonButton> btnList = gihonButtonService.getMenuButton(menuIdList);
+		List<Long> btnCheckedList = gihonRoleButtonService.getButtonListByRole(roleId);
+		btnList.forEach(b -> b.setChecked(btnCheckedList.contains(b.getId())));
+		return btnList;
+	}
+	/**
+	 * 设置角色在某个模块下的按钮权限
+	 */
+	public boolean setButtonByRoleModule(RoleButtonReq req) {
+		List<Long> menuIdList = gihonMenuService.getAllMenu(req.getModuleId()).stream().map(m -> m.getId())
+				.collect(Collectors.toList());
+		List<Long> allbtnList = gihonButtonService.getMenuButton(menuIdList).stream().map(m -> m.getId())
+				.collect(Collectors.toList());
+		List<Long> btnoldList = gihonRoleButtonService.getButtonListByRole(req.getRoleId());
+		btnoldList.retainAll(allbtnList);//求交集,属于当前模块的角色配置
+		req.getButtonList().retainAll(allbtnList);
+		if(req.getButtonList().isEmpty()) {
+			return gihonRoleButtonService.removeButtonByRoleId(req.getRoleId(),btnoldList);
+		}else if(btnoldList.isEmpty()) {
+			return gihonRoleButtonService.insertRoleButton(req.getRoleId(), req.getButtonList());
+		}else {
+			List<Long> tempList = new ArrayList<>();
+			tempList.addAll(req.getButtonList());
+			tempList.removeAll(btnoldList);//新增
+			btnoldList.removeAll(req.getButtonList() );//需要删除的
+			gihonRoleButtonService.insertRoleButton(req.getRoleId(), tempList);
+			gihonRoleButtonService.removeButtonByRoleId(req.getRoleId(),btnoldList);
+		}
+		
+		return true;
+	}
 }

+ 14 - 4
common-sso/src/main/java/com/gihon/sso/service/GihonUserRoleService.java

@@ -1,12 +1,13 @@
 package com.gihon.sso.service;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonUserRole;
-import com.gihon.sso.mapper.GihonUserRoleMapper;
+import com.gihon.common.mapper.GihonUserRoleMapper;
 
 /**
  * 直接继承没有多实现处理
@@ -16,8 +17,17 @@ import com.gihon.sso.mapper.GihonUserRoleMapper;
 @Service
 public class GihonUserRoleService extends ServiceImpl<GihonUserRoleMapper, GihonUserRole>{
 
-	
-	public List<GihonUserRole> roleList(Long id){
-		return this.lambdaQuery().eq(GihonUserRole::getUserId, id).list();
+	/**
+	 * 获取某个用户的全部角色
+	 */
+	public List<Long> roleListByUserId(Long id){
+		List<GihonUserRole> roleList = this.lambdaQuery().eq(GihonUserRole::getUserId, id).select(GihonUserRole::getRoleId).list();
+		return roleList.stream().map(ur -> ur.getRoleId()).collect(Collectors.toList());
+	}
+	/**
+	 * 删除某个用户的全部角色
+	 */
+	public boolean removeRoleByUserId(Long id){
+		return this.lambdaUpdate().eq(GihonUserRole::getUserId, id).remove();
 	}
 }

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/service/GihonUserService.java

@@ -4,7 +4,7 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gihon.common.entity.GihonUser;
-import com.gihon.sso.mapper.GihonUserMapper;
+import com.gihon.common.mapper.GihonUserMapper;
 
 /**
  * 直接继承没有多实现处理

+ 1 - 1
common-sso/src/main/java/com/gihon/sso/service/TokenService.java

@@ -32,7 +32,7 @@ public interface TokenService {
 	final long EXIPRED_MORE = 1000*60;
 	
 	
-	
+	String getUserName(String securityToken) ;
 	/**
 	 * 创建token
 	 * 

+ 16 - 6
common-sso/src/main/java/com/gihon/sso/service/impl/TokenServiceImpl.java

@@ -11,6 +11,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Service;
+import org.springframework.util.Base64Utils;
 import org.springframework.util.StringUtils;
 
 import com.fasterxml.jackson.core.type.TypeReference;
@@ -50,6 +51,14 @@ public class TokenServiceImpl implements TokenService {
 	@Autowired
 	private GihonRoleService gihonRoleService;
 
+	private String parseToken(String originToken) {
+		return Base64Utils.encodeToUrlSafeString(originToken.getBytes());
+	}
+	@Override
+	public String getUserName(String securityToken) {
+		String token = new String(Base64Utils.decodeFromUrlSafeString(securityToken));
+		return token.split(RedisConstants.SEP)[0];
+	}
 	@Override
 	public SsoToken createToken(UserInfo userInfo, int moduleType) {
 		if (userInfo == null || !StringUtils.hasText(userInfo.getUsername())) {
@@ -70,8 +79,8 @@ public class TokenServiceImpl implements TokenService {
 		SsoToken tokenEntity = new SsoToken();
 		tokenEntity.setModuleType(moduleType);
 		tokenEntity.setUserInfo(userInfo);
-		tokenEntity.setToken(userInfo.getUsername() + RedisConstants.SEP + UUIDGenerater.genUUID());
-		tokenEntity.setRefreshToken(userInfo.getUsername() +  RedisConstants.SEP + UUIDGenerater.genUUID());
+		tokenEntity.setToken(parseToken(userInfo.getUsername() + RedisConstants.SEP + UUIDGenerater.genUUID()));
+		tokenEntity.setRefreshToken(parseToken(userInfo.getUsername() +  RedisConstants.SEP + UUIDGenerater.genUUID()));
 		long now = System.currentTimeMillis();
 		tokenEntity.setRefreshTokenExpire(now + gihonCommonProperties.getRefreshTokenExpired());
 		tokenEntity.setTokenExpire(now + gihonCommonProperties.getTokenExpired());
@@ -213,9 +222,10 @@ public class TokenServiceImpl implements TokenService {
 		}
 		if (!mutiLogin) {
 			// 强制踢掉其他同类型的token
-			tokenList = tokenList.stream().filter(t -> t.getModuleType() == tokenEntity.getModuleType())
+			List<TokenVal> removeList = tokenList.stream().filter(t -> t.getModuleType() == tokenEntity.getModuleType())
 					.collect(Collectors.toList());
-			tokenList.forEach(t -> removeToken(t));
+			removeList.forEach(t -> removeToken(t));
+			tokenList.removeAll(removeList);
 		}
 		TokenVal tv = TokenVal.builder().expireTime(tokenEntity.getTokenExpire()).userAccount(userAccount)
 				.refreshToken(tokenEntity.getRefreshToken()).token(tokenEntity.getToken())
@@ -229,7 +239,7 @@ public class TokenServiceImpl implements TokenService {
 		tokenList.add(tv);
 		boolean flag = stringRedisTemplate.opsForHash().hasKey(USER_STORE, userAccount);
 		if (!flag) {
-			stringRedisTemplate.opsForHash().putIfAbsent(USER_STORE, userAccount, tokenEntity.getUserInfo());
+			stringRedisTemplate.opsForHash().putIfAbsent(USER_STORE, userAccount, JacksonJsonUtils.writeObject(tokenEntity.getUserInfo()));
 		}
 		stringRedisTemplate.opsForValue().set(TOKEN_PRE + tokenEntity.getToken(), JacksonJsonUtils.writeObject(tv),
 				gihonCommonProperties.getTokenExpired() + gihonCommonProperties.getExipredMore(), TimeUnit.MILLISECONDS);
@@ -251,7 +261,7 @@ public class TokenServiceImpl implements TokenService {
 		notifyToken(tokenVal);
 	}
 
-	// 移除Redis中token
+	// 移除Redis中token 多线程有问题
 	private void removeToken(TokenVal tokenVal, List<TokenVal> tokenList) {
 		String userAccount = tokenVal.getUserAccount();
 		stringRedisTemplate.opsForHash().put(USER_TOKEN_STORE, userAccount, JacksonJsonUtils.writeObject(tokenList));

+ 14 - 1
common-sso/src/main/resources/application.yml

@@ -21,4 +21,17 @@ spring:
       # 从这里开始(druid),中间的这段配置用于 pocky.database.multiTenantType != DATASOURCE 时
       url: jdbc:mysql://172.18.0.23:3306/gihon?characterEncoding=UTF-8&useSSL=false
       username: root
-      password: 1q2w3e4r
+      password: 1q2w3e4r
+knife4j: 
+  # 开启增强配置 
+  enable: true
+  setting: 
    swaggerModelName: '模型名称'
+    enableFooter: false
+  documents:
+    - 
+      group: SSO
+      name: 登录验证模块
+    
+  
+      
+  

+ 4 - 2
common-util/src/main/java/com/gihon/common/aspect/LogAspect.java

@@ -58,14 +58,14 @@ public class LogAspect {
             url = request.getRequestURL().toString();      
          
             param = getArgs(thisJoinPoint,((MethodSignature)thisJoinPoint.getSignature()).getParameterNames());
-            log.info("[访问地址:{}] [方法:{}] [{}] [userId:{}] [参数:{}]",url,method,uuid,userId,param);
+            log.info("\033[1;32m[访问地址:{}] [方法:{}] [{}] [userId:{}] [参数:{}]\033[0m",url,method,uuid,userId,param);
             r = thisJoinPoint.proceed ();//被代理对象执行结果
            
         } catch (Throwable e) {
         	flag = true;
             throw e;//异常信息有统一异常处理器处理
         }
-        log.info("[访问地址:{}] [方法:{}] [{}] [执行时间:{}(豪秒)] [{}]",url,method,uuid,Duration.between(startTime, LocalDateTime.now()).toMillis(),flag?"异常":"正常");
+        log.info("\033[1;32m[访问地址:{}] [方法:{}] [{}] [执行时间:{}(豪秒)] [{}]\033[0m",url,method,uuid,Duration.between(startTime, LocalDateTime.now()).toMillis(),flag?"异常":"正常");
         return r;
     }
     private static String types = "java.lang.Integer,java.lang.Double,java.lang.Float,java.lang.Long,java.lang.Short,java.lang.Byte,java.lang.Boolean,java.lang.Char,java.lang.String,int,double,long,short,byte,boolean,char,float";
@@ -88,6 +88,8 @@ public class LogAspect {
     	    	   allArgs.put(parameterNames[k],arg);
     	       }else if(arg instanceof Collection) {//集合
     	    	   allArgs.put(parameterNames[k],arg);
+    	       }else if(arg.getClass().isArray()) {//数组
+    	    	   allArgs.put(parameterNames[k],arg);
     	       }else {//复杂类型
     	    	   Map m = JacksonJsonUtils.readObject(JacksonJsonUtils.writeObject(arg), Map.class);
     	    	   if(m!=null) {

+ 0 - 2
common-util/src/main/java/com/gihon/common/entity/BaseEntity.java

@@ -50,6 +50,4 @@ public class BaseEntity {
 	@TableLogic
 	protected Integer state;
 	
-	@ApiModelProperty(value = "公司Id(支持SAAS)")
-	protected Long companyId;
 }

+ 18 - 0
common-util/src/main/java/com/gihon/common/entity/CompanyBaseEntity.java

@@ -0,0 +1,18 @@
+package com.gihon.common.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 基础实体类
+ * @author edz
+ *
+ */
+@Getter
+@Setter
+public class CompanyBaseEntity extends BaseEntity{
+	
+	@ApiModelProperty(value = "公司Id(支持SAAS)")
+	protected Long companyId;
+}

+ 8 - 4
common-util/src/main/java/com/gihon/common/mybatis/config/MyMetaObjectHandler.java

@@ -7,10 +7,10 @@ import org.apache.ibatis.reflection.MetaObject;
 
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
 import com.gihon.common.auth.AuthUtils;
 import com.gihon.common.entity.BaseEntity;
+import com.gihon.common.entity.CompanyBaseEntity;
 
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.IdUtil;
@@ -76,8 +76,12 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
 	        if (entity.getUpdateUser() == null) {
 	        	entity.setUpdateUser(AuthUtils.getUserId());//线程获取不到用户的时候
 	        }
-	        if (entity.getCompanyId() == null) {
-	        	entity.setCompanyId(AuthUtils.getCompanyId());//线程获取不到用户的时候
+	        if (metaObject.getOriginalObject() instanceof CompanyBaseEntity) {
+	        	CompanyBaseEntity entity2 = (CompanyBaseEntity) metaObject.getOriginalObject();
+	        	
+	        	if (entity2.getCompanyId() == null) {
+	        		entity2.setCompanyId(AuthUtils.getCompanyId());//线程获取不到用户的时候
+	        	}
 	        }
 	        //都是自增长
 	        return;

+ 1 - 1
common-util/src/main/java/com/gihon/common/properties/GihonCommonProperties.java

@@ -12,7 +12,7 @@ import lombok.Data;
 @EnableConfigurationProperties(GihonCommonProperties.class)
 public class GihonCommonProperties {
 	
-	private String rootPath;
+	private String loginPath;
 
 	private long tokenExpired = 1000*60*60*24L;//24小时
 	

+ 7 - 0
common-util/src/main/java/com/gihon/common/util/PasswordUtils.java

@@ -15,4 +15,11 @@ public class PasswordUtils {
 		String degist = DigestUtils.md5DigestAsHex(strIn.getBytes());
 		return degist;
 	}
+	
+	public static void main(String[] args) {
+		System.out.println(makePassword("123456","yujiaadmin"));
+		System.out.println(makePassword("123456","yoke1"));
+		System.out.println(makePassword("123456","yoke2"));
+		System.out.println(makePassword("123456","yoke3"));
+	}
 }

+ 2 - 2
common-util/src/main/java/com/gihon/common/web/response/PageBean.java

@@ -2,7 +2,7 @@ package com.gihon.common.web.response;
 
 import java.util.Collection;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -26,7 +26,7 @@ public class PageBean<T> {
 	public PageBean() {
 	}
 
-	public PageBean(Page<T> page) {
+	public PageBean(IPage<T> page) {
         this.records = page.getRecords();
         this.total = (int)page.getTotal();
         this.current = (int)page.getCurrent();

+ 6 - 1
common-util/src/main/java/com/gihon/common/web/response/Response.java

@@ -6,6 +6,8 @@ import static com.gihon.common.web.response.ResponseStatus.SUCCESS;
 
 import java.util.Map;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -62,5 +64,8 @@ public class Response<T> {
     public static<T> Response<T> error(ResponseStatus status) {
         return error(status,status.getDesc());
     }
-
+    public static <T> Response<PageBean<T>> okPage(IPage<T> data) {
+    	PageBean<T> pageBean = new PageBean<T>(data);
+    	return new Response<PageBean<T>>(SUCCESS.getCode(),SUCCESS.getDesc(), pageBean);
+    }
 }

+ 5 - 4
common-util/src/main/resources/application-common.yml

@@ -2,7 +2,7 @@ gihon:
   common:
     module-type: 1
     module-code: sso  
-    root-path: login
+    login-path: login
     muti-login: true
     white-url-list: 
       - /**error**
@@ -12,7 +12,7 @@ gihon:
       - /v2/**
       - /doc.html
       - /favicon.ico
-      - /login
+      - /**login
     id-strategy:
 #   按需更新
       worker-id: 0
@@ -80,18 +80,19 @@ spring:
         login-password: gihon         
 #mybatis-plus 通用配置   
 mybatis-plus:
+  banner: false
   mapper-locations:
       - classpath:/mapper/**/*Mapper.xml
   #实体扫描,多个package用逗号或者分号分隔
   typeAliasesPackage: com.gihon.**.entity
   global-config:
     db-config:
-      dbType: MYSQL
       #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
       id-type: AUTO
       #字段策略IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
-      field-strategy: NOT_NULL
+      insert-strategy: NOT_NULL
       #逻辑删除配置(下面3个配置)
+      logic-delete-field: state
       logic-delete-value: 1
       logic-not-delete-value: 0
   configuration:

+ 63 - 0
common-util/src/main/resources/logback-spring.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
+<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
+<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
+<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
+<configuration  scan="true" scanPeriod="10 seconds">
+
+    <contextName>logback</contextName>
+    <!-- name的值是变量的名称,value的值是变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
+    <!-- 定义日志文件的存储地址 -->
+    <!--<property name="log.path" value="C:/other/java/javaTotalWorkSpace/logTotalWorkSpace/wp" />-->
+    <property name="log.path" value="log" />
+
+    <!-- 彩色日志格式 -->
+    <property name="CONSOLE_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level]  [%thread] [%logger-%L] - %msg%n"/>
+
+
+    <!--输出到控制台-->
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>debug</level>
+        </filter>
+        <encoder>
+            <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
+            <!-- 设置字符集 -->
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+
+
+    <!--输出到文件-->
+
+    <!-- 时间滚动输出 level为 DEBUG 日志 -->
+    <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文件的路径及文件名 -->
+        <file>${log.path}/log_debug.log</file>
+        <!--日志文件输出格式-->
+        <encoder>
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+            <charset>UTF-8</charset> <!-- 设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志归档 -->
+            <fileNamePattern>${log.path}/log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文件保留天数-->
+            <maxHistory>15</maxHistory>
+        </rollingPolicy>
+    </appender>
+    
+    <!-- 打印sql语句 -->
+    <logger name="com.gihon" level="debug"/>
+    
+    <root level="info">
+        <appender-ref ref="CONSOLE" />
+        <appender-ref ref="DEBUG_FILE" />
+    </root>
+
+</configuration>

+ 1 - 1
pom.xml

@@ -29,7 +29,7 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <mybatis.version>2.1.3</mybatis.version>
-        <mybatis.plus.version>3.1.0</mybatis.plus.version>
+        <mybatis.plus.version>3.3.1</mybatis.plus.version>
         <lombok.version>1.16.20</lombok.version>
         <easyexcel.version>2.2.8</easyexcel.version>
         <druid.version>1.1.21</druid.version>