Parcourir la source

用户权限缓存以及系统字典功能

zdm il y a 7 ans
Parent
commit
0f1c0aae8e
42 fichiers modifiés avec 1603 ajouts et 111 suppressions
  1. 52 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  2. 30 2
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseUserRequestMapping.java
  3. 6 1
      svr/svr-base/pom.xml
  4. 6 0
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SystemController.java
  5. 12 0
      svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictDao.java
  6. 12 0
      svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictListDao.java
  7. 13 0
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictListService.java
  8. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java
  9. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java
  10. 81 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java
  11. 0 33
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployeeController.java
  12. 24 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployDao.java
  13. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployRoleDao.java
  14. 0 12
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployeeDao.java
  15. 0 12
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployeeRoleDao.java
  16. 1 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java
  17. 94 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployRoleService.java
  18. 124 0
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java
  19. 0 10
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployeeService.java
  20. 16 0
      svr/svr-base/src/main/java/com/yihu/jw/cache/Cache.java
  21. 75 0
      svr/svr-base/src/main/java/com/yihu/jw/cache/MapCache.java
  22. 67 0
      svr/svr-base/src/main/java/com/yihu/jw/cache/RedisCache.java
  23. 25 0
      svr/svr-base/src/main/java/com/yihu/jw/cache/model/LoginCacheModel.java
  24. 25 0
      svr/svr-base/src/main/java/com/yihu/jw/cache/model/RoleCacheModel.java
  25. 20 0
      web-gateway/src/main/java/com/yihu/jw/commnon/base/base/BaseContants.java
  26. 32 0
      web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java
  27. 2 6
      web-gateway/src/main/java/com/yihu/jw/config/security/roleService/ClientService.java
  28. 2 2
      web-gateway/src/main/java/com/yihu/jw/config/security/roleService/UserService.java
  29. 52 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/base/SystemDictController.java
  30. 53 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/base/SystemDictListController.java
  31. 135 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java
  32. 136 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/EmployController.java
  33. 0 2
      web-gateway/src/main/java/com/yihu/jw/feign/base/base/FunctionFeign.java
  34. 46 0
      web-gateway/src/main/java/com/yihu/jw/feign/base/base/SystemDictFeign.java
  35. 49 0
      web-gateway/src/main/java/com/yihu/jw/feign/base/base/SystemDictListFeign.java
  36. 46 0
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java
  37. 48 0
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java
  38. 0 25
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployeeFeign.java
  39. 74 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/base/SystemDictFeignFallbackFactory.java
  40. 80 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/base/SystemDictListFeignFallbackFactory.java
  41. 73 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java
  42. 62 4
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java

+ 52 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -96,6 +96,57 @@ public class BaseRequestMapping {
    }
    //SystemDict常量
    public static class SystemDict{
        public static final String message_success_create="SystemDict create success";
        public static final String message_success_update="SystemDict update success";
        public static final String message_success_find="SystemDict find success";
        public static final String message_success_find_saass="SystemDict find success";
        public static final String message_success_delete="SystemDict delete success";
        public static final String message_fail_name_exist="SystemDict name exist";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id no exist";
        public static final String api_create="/systemDict";
        public static final String api_update="/systemDict";
        public static final String api_delete="/systemDict";
        public static final String api_getById="/getById";
        public static final String api_getList="/systemDict/list";
        public static final String api_getListNoPage="/systemDict/listNoPage";
    }
    //SystemDictList常量
    public static class SystemDictList{
        public static final String message_success_create="SystemDictList create success";
        public static final String message_success_update="SystemDictList update success";
        public static final String message_success_find="SystemDictList find success";
        public static final String message_success_find_saass="SystemDictList find success";
        public static final String message_success_delete="SystemDictList delete success";
        public static final String message_fail_name_exist="SystemDictList name exist";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id no exist";
        public static final String api_create="/systemDictList";
        public static final String api_update="/systemDictList";
        public static final String api_delete="/systemDictList";
        public static final String api_getById="/getById";
        public static final String api_getList="/systemDictList/list";
        public static final String api_getListNoPage="/systemDictList/listNoPage";
        public static final String api_getChildren="/systemDictList/children/{id}";
    }
/*
    //d行政人员模块
    public static class Employee{
        public static final String message_success_create="employee create success";
@ -119,5 +170,5 @@ public class BaseRequestMapping {
        public static final String api_getEmployeeByAccount="/getEmployeeByAccount";
        public static final String api_getEmployeeNoPage="/getEmployeeNoPage";
    }
    }*/
}

+ 30 - 2
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseUserRequestMapping.java

@ -12,7 +12,7 @@ public class BaseUserRequestMapping {
        public static final String api_delete = "/baseRole/{ids}";
        public static final String api_getById = "/baseRole/{id}";
        public static final String api_getList="/baseRole/list";
        public static final String api_getOne="/baseRole/one";
        public static final String api_getOne="/baseRole";
        public static final String api_getListNoPage="/baseRole/listNoPage";
        public static final String message_success_create = "baseRole create success";
@ -36,7 +36,7 @@ public class BaseUserRequestMapping {
    /**
     * 用户
     */
    public class Employee {
    public class BaseEmploy {
        public static final String api_create = "/employee";
        public static final String api_update = "/employee";
        public static final String api_delete = "/employee/{ids}";
@ -44,6 +44,8 @@ public class BaseUserRequestMapping {
        public static final String api_getByUserId = "/employeeById/{userId}";
        public static final String api_getList="/employee/list";
        public static final String api_getListNoPage="/employee/listNoPage";
        public static final String api_getByEmployId = "/employee/{employId}";
        public static final String message_success_create="Employee create success";
        public static final String message_success_update="update Employee success";
@ -54,6 +56,32 @@ public class BaseUserRequestMapping {
        public static final String message_fail_name_is_null = "baseRole is null";
        public static final String message_fail_id_is_null = "id is null";
        public static final String message_fail_id_no_exist = "id no exist";
        public static final String message_fail_saasid_is_null = "saasId is null";
        public static final String message_param_saasid_is_null = "baseRole saasId param cannot be null";
        public static final String message_fail_saasid_no_exist = "saasId no exist";
    }
    /**
     * 用户角色
     */
    public class BaseEmployRole {
        public static final String api_create = "/employeeRole";
        public static final String api_update = "/employeeRole";
        public static final String api_delete = "/employeeRole/{ids}";
        public static final String api_getList="/employeeRole/list";
        public static final String api_getListNoPage="/employeeRole/listNoPage";
        public static final String message_success_create="employeeRole create success";
        public static final String message_success_update="update employeeRole success";
        public static final String message_success_delete="employeeRole delete success";
        public static final String message_success_find="employeeRole find success";
        public static final String message_fail_roleId_is_null = "roleId is null";
        public static final String message_fail_employId_is_null = "employId is null";
        public static final String message_fail_id_is_null = "id is null";
        public static final String message_fail_same_roleId = "same roleId";
        public static final String message_fail_employeeRole_no_exist = "employeeRole no exist";
    }
}

+ 6 - 1
svr/svr-base/pom.xml

@ -29,7 +29,8 @@
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>            <artifactId>common-util</artifactId>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -127,6 +128,10 @@
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-base</finalName>

+ 6 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SystemController.java

@ -0,0 +1,6 @@
package com.yihu.jw.business.base.controller;
/**
 * Created by LiTaohong on 2017/11/30.
 */
public class SystemController {
}

+ 12 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.business.base.dao;
import com.yihu.jw.base.base.SaasModuleDO;
import com.yihu.jw.base.base.SystemDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO, String>, JpaSpecificationExecutor<SystemDictDO> {
}

+ 12 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictListDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.business.base.dao;
import com.yihu.jw.base.base.SystemDictDO;
import com.yihu.jw.base.base.SystemDictListDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public interface SystemDictListDao extends PagingAndSortingRepository<SystemDictListDO, String>, JpaSpecificationExecutor<SystemDictListDO> {
}

+ 13 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictListService.java

@ -0,0 +1,13 @@
package com.yihu.jw.business.base.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.base.SystemDictDO;
import com.yihu.jw.base.base.SystemDictListDO;
import com.yihu.jw.business.base.dao.SystemDictDao;
import com.yihu.jw.business.base.dao.SystemDictListDao;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public class SystemDictListService extends BaseJpaService<SystemDictListDO, SystemDictListDao> {
}

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java

@ -0,0 +1,11 @@
package com.yihu.jw.business.base.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.base.SystemDictDO;
import com.yihu.jw.business.base.dao.SystemDictDao;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDao> {
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java

@ -73,7 +73,7 @@ public class BaseRoleController extends EnvelopRestController {
    public Envelop getRoleListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.getRoleListByName(baseRoleDO.getSaasId()));
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findAllBySaasId(baseRoleDO.getSaasId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }

+ 81 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java

@ -0,0 +1,81 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.service.EmployService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseSmsRequestMapping;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_common)
@Api(description = "医生,行政人员等非患者用户(基础用户)")
public class EmployController extends EnvelopRestController {
    @Autowired
    private EmployService employService;
    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建用户", notes = "创建单个用户")
    public Envelop createBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_create,employService.createBaseEmployDO(baseEmployDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改用户", notes = "修改用户")
    public Envelop updateBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_update,employService.updateBaseEmployDO(baseEmployDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据id查找用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
    public Envelop getEmployeeById(@ApiParam(name = "id", value = "id", required = true) @RequestParam(value = "id", required = true) String id) {
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,this.employService.findById(id));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据saasId查找所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getList)
    public Envelop getAllEmployeeBySaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,this.employService.findAllBySaasId(saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据name模糊查询某saasId平台下的所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getList)
    public Envelop getListByNameAndSaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,this.employService.findAllBySaasId(saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 0 - 33
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployeeController.java

@ -1,33 +0,0 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.business.user.service.EmployeeService;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseSmsRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping(BaseSmsRequestMapping.api_common)
@Api(description = "医生,行政人员等非患者用户")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @ApiOperation(value = "根据行政人员账号查找用户")
    @GetMapping(value = BaseRequestMapping.Employee.api_getEmployeeByAccount)
    public String getEmployeeByAccount(
            @ApiParam(name = "userAccount", value = "用户账号", required = true) @RequestParam(value = "userAccount", required = true) String userAccount) {
        
        return "调用根据code查找患者";
    }
}

+ 24 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployDao.java

@ -0,0 +1,24 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/11/28.
 */
/**
 * 基础用户类接口
 */
public interface EmployDao extends PagingAndSortingRepository<BaseEmployDO, String>, JpaSpecificationExecutor<BaseEmployDO> {
    @Query("from BaseEmployDO ba where ba.saasId = 1?")
    List<BaseEmployDO> findAllBySaasId(String saasId);
    @Query("from BaseEmployDO ba where ba.name like 2? and ba.saasId = 1?")
    List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId);
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployRoleDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface EmployRoleDao extends PagingAndSortingRepository<BaseEmployRoleDO, String>, JpaSpecificationExecutor<BaseEmployRoleDO> {
    @Query("from BaseEmployRoleDO ba where ba.employId = 1?")
    List<BaseEmployRoleDO> findRoleListByEmployId(String employId);
}

+ 0 - 12
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployeeDao.java

@ -1,12 +0,0 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/11/28.
 */
public interface EmployeeDao extends PagingAndSortingRepository<BaseEmployDO, String>, JpaSpecificationExecutor<BaseEmployDO> {
}

+ 0 - 12
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployeeRoleDao.java

@ -1,12 +0,0 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface EmployeeRoleDao extends PagingAndSortingRepository<BaseEmployRoleDO, String>, JpaSpecificationExecutor<BaseEmployRoleDO> {
}

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java

@ -17,6 +17,7 @@ import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 * 基础角色功能
 */
@Service
public class BaseRoleService extends BaseJpaService<BaseRoleDO,BaseRoleDao>{

+ 94 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployRoleService.java

@ -0,0 +1,94 @@
package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.business.user.dao.EmployRoleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 * 用户角色表功能
 */
@Service
public class EmployRoleService extends BaseJpaService<BaseEmployRoleDO,EmployRoleDao> {
    @Autowired
    private EmployRoleDao employRoleDao;
    /**
     * 新增用户角色
     * @param baseEmployRoleDO
     * @return
     */
    @Transactional
    public BaseEmployRoleDO createBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
        if (StringUtils.isEmpty(baseEmployRoleDO.getRoleId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseEmployRoleDO.getEmployId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employRoleDao.save(baseEmployRoleDO);
    }
    /**
     * 修改用户角色
     * @param baseEmployRoleDO
     * @return
     */
    @Transactional
    public BaseEmployRoleDO updateBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
        BaseEmployRoleDO OldbaseEmployRoleDO = this.employRoleDao.findOne(baseEmployRoleDO.getId());
        if(null == OldbaseEmployRoleDO){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist, ExceptionCode.common_error_params_code);
        }
        if (baseEmployRoleDO.getRoleId().equals(OldbaseEmployRoleDO.getRoleId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_same_roleId, ExceptionCode.common_error_params_code);
        }
        return this.employRoleDao.save(baseEmployRoleDO);
    }
    /**
     * 查询某一用户的角色列表(用户与角色为一对多关系)
     * @param employId
     * @return
     */
    public List<BaseEmployRoleDO> findAllByEmployId(String employId){
        if (StringUtils.isEmpty(employId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseEmployRoleDO> list = this.employRoleDao.findRoleListByEmployId(employId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 删除用户角色
     * @param id
     * @return
     */
    @Transactional
    public void deleteBaseEmployRoleDO(String id){
        try{
            this.employRoleDao.delete(id);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
}

+ 124 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java

@ -0,0 +1,124 @@
package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.business.user.dao.EmployDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 * 用户信息功能
 */
@Service
public class EmployService extends BaseJpaService<BaseEmployDO,EmployDao> {
    @Autowired
    private EmployDao employDao;
    /**
     * 创建用户
     * @param employeeDO
     * @return
     */
    @Transactional
    public BaseEmployDO createBaseEmployDO(BaseEmployDO employeeDO){
        if (StringUtils.isEmpty(employeeDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employDao.save(employeeDO);
    }
    /**
     * 更新用户
     * @param employeeDO
     * @return
     */
    @Transactional
    public BaseEmployDO updateBaseEmployDO(BaseEmployDO employeeDO){
        if (StringUtils.isEmpty(employeeDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employDao.save(employeeDO);
    }
    /**
     * 根据Id查询用户
     * @param id
     * @return
     */
    public BaseEmployDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
        BaseEmployDO BaseEmployDO = this.employDao.findOne(id);
        if (null == BaseEmployDO) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
        }
        return BaseEmployDO;
    }
    /**
     * 查询某saasId平台下的所有用户
     * @param saasId
     * @return
     */
    public List<BaseEmployDO> findAllBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseEmployDO> list = this.employDao.findAllBySaasId(saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 查询name模糊查询某saasId平台下的所有用户
     * @param saasId
     * @return
     */
    public List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseEmployDO> list = this.employDao.findAllByNameAndSaasId(name,saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 根据Id删除用户
     * @param employDO
     */
    @Transactional
    public void deleteBaseEmploy(BaseEmployDO employDO){
        if (StringUtils.isEmpty(employDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        employDO.setStatus(-1);
        this.employDao.save(employDO);
    }
}

+ 0 - 10
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployeeService.java

@ -1,10 +0,0 @@
package com.yihu.jw.business.user.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/5/11.
 */
@Service
public class EmployeeService {
}

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/cache/Cache.java

@ -0,0 +1,16 @@
package com.yihu.jw.cache;
import java.util.Set;
/**
 * Created by LiTaohong on 2017/12/04.
 */
public interface Cache {
    void setData(String module, String key, String value);
    String getData(String module, String key);
    Set<String> keys(String module, String pattern);
    void removeData(String module, String key) throws Exception;
}

+ 75 - 0
svr/svr-base/src/main/java/com/yihu/jw/cache/MapCache.java

@ -0,0 +1,75 @@
package com.yihu.jw.cache;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
/**
 * Created by LiTaohong on 2017/12/04.
 */
@Component
@Scope("singleton")
public class MapCache implements Cache {
    /**
     * 缓存的map,key是module value是对应model的缓存
     */
    private static Map<String, Map<String, String>> cacha = new HashMap<>();
    @Override
    public void setData(String module, String key, String value) {
        //获取map
        Map<String, String> map=cacha.get(module);
        if(map==null){
            map=new HashMap<>();
            cacha.put(module,map);
        }
        //放入缓存
        map.put(key,value);
    }
    @Override
    public String getData(String module, String key) {
        Map<String, String> map=cacha.get(module);
        if(map==null){
            return null;
        }
        return map.get(key);
    }
    /**
     * 通过正则,获取key值
     * @param module
     * @param pattern
     * @return
     */
    @Override
    public Set<String> keys(String module,String pattern) {
        Map<String, String> map=cacha.get(module);
        if(map==null){
            return null;
        }
        Set<String> keys = map.keySet();
        Set<String> newKeys = new HashSet<String>();
        for(String key:keys){
            if(Pattern.matches(pattern, key)){
                newKeys.add(key);
            }
        }
        return newKeys;
    }
    @Override
    public void removeData(String module, String key) throws Exception {
        Map<String, String> map=cacha.get(module);
        if(map==null){
            throw new Exception("this "+module+" does not exist cache");
        }
        map.remove(key);
    }
}

+ 67 - 0
svr/svr-base/src/main/java/com/yihu/jw/cache/RedisCache.java

@ -0,0 +1,67 @@
package com.yihu.jw.cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by LiTaohong on 2017/12/04.
 */
@Component
@Scope("singleton")
public class RedisCache implements Cache {
    private static String redis_pre = "svr-base";
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Override
    public void setData(String module, String key, String value) {
        //获取key
        String redisKey=getKey(module,key);
        //把数据放入redis中
        redisTemplate.opsForValue().set(redisKey,value);
    }
    @Override
    public String getData(String module, String key) {
        //获取key
        String redisKey=getKey(module,key);
        //从redis中获取数据
        return redisTemplate.opsForValue().get(redisKey);
    }
    @Override
    public Set<String> keys(String module,String pattern) {
        pattern = pattern.replaceAll("\\.", "");
        String redisKey = getKey(module,pattern);
        Set<String> redisKeys = redisTemplate.keys(redisKey);
        Set<String> keys = new HashSet<>();
        for(String key:redisKeys){
            key = key.substring(8+module.length());
            keys.add(key);
        }
        return keys;
    }
    @Override
    public void removeData(String module, String key) throws Exception {
        String redisKey = getKey(module, key);
        redisTemplate.delete(redisKey);//根据key删除缓存
    }
    /**
     * 获取redis中的key
     * @param module
     * @param key
     * @return
     */
    private String getKey(String module, String key) {
        return new StringBuffer(redis_pre+":"+module+":"+key).toString();
    }
}

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/cache/model/LoginCacheModel.java

@ -0,0 +1,25 @@
package com.yihu.jw.cache.model;
/**
 * Created by LiTaohong on 2017/12/04.
 */
public class LoginCacheModel {
    private String code;//用户code
    private String saasId;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/cache/model/RoleCacheModel.java

@ -0,0 +1,25 @@
package com.yihu.jw.cache.model;
/**
 * Created by LiTaohong on 2017/12/04.
 */
public class RoleCacheModel {
    private String url;
    private String method;
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
}

+ 20 - 0
web-gateway/src/main/java/com/yihu/jw/commnon/base/base/BaseContants.java

@ -10,6 +10,8 @@ public class BaseContants {
    public static final String api_module = api_common+"/module";
    public static final String api_moduleFun = api_common+"/moduleFun";
    public static final String api_saas = api_common+"/saas";
    public static final String api_systemDict = api_common+"/systemDict";
    public static final String api_systemDictList = api_common+"/systemDictList";
    //功能模块常量
    public static class Function{
@ -47,4 +49,22 @@ public class BaseContants {
        public static final String api_getSaassNoPage="/getSaassNoPage";
    }
    //SystemDict常量
    public static class SystemDict{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getSystemDictNoPage="/getSaassNoPage";
    }
    //SystemDictList常量
    public static class SystemDictList{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getSystemDictListNoPage="/getSaassNoPage";
    }
}

+ 32 - 0
web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java

@ -0,0 +1,32 @@
package com.yihu.jw.commnon.base.user;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public class BaseUserContants {
    public static final String api_common = "/bases";
    public static final String api_baseRole = api_common+"/baseRole";
    public static final String api_employee = api_common+"/employee";
    //角色常量
    public static class BaseRole{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
        public static final String api_getChildren="/children/{id}";
    }
    //用户常量
    public static class Employee{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
        public static final String api_getChildren="/children/{id}";
    }
}

+ 2 - 6
web-gateway/src/main/java/com/yihu/jw/config/security/roleService/ClientService.java

@ -1,11 +1,7 @@
package com.yihu.jw.config.security.roleService;
import com.yihu.jw.feign.base.user.EmployeeFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.feign.base.user.EmployFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
@ -18,7 +14,7 @@ import org.springframework.stereotype.Service;
@Service
public class ClientService implements ClientDetailsService {
    @Autowired
    private EmployeeFeign employeeFeign;
    private EmployFeign employeeFeign;
    @Override

+ 2 - 2
web-gateway/src/main/java/com/yihu/jw/config/security/roleService/UserService.java

@ -1,6 +1,6 @@
package com.yihu.jw.config.security.roleService;
import com.yihu.jw.feign.base.user.EmployeeFeign;
import com.yihu.jw.feign.base.user.EmployFeign;
import com.yihu.jw.restmodel.common.Envelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
@Service
public class UserService implements UserDetailsService {
    @Autowired
    private EmployeeFeign employeeFeign;
    private EmployFeign employeeFeign;
    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {

+ 52 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/base/SystemDictController.java

@ -0,0 +1,52 @@
package com.yihu.jw.controller.base.base;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.base.BaseContants;
import com.yihu.jw.feign.base.base.SaasFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by LiTaohong on 2017/12/01.
 */
@RestController
@RequestMapping(BaseContants.api_systemDict)
@Api(description = "SystemDict相关")
public class SystemDictController extends EnvelopRestController {
    private Logger logger = LoggerFactory.getLogger(SystemDictController.class);
    @Autowired
    private SaasFeign saasFegin;
    @Autowired
    private Tracer tracer;
    @GetMapping(value = BaseContants.SystemDict.api_getSystemDictNoPage)
    @ApiOperation(value = "获取saas,不分页")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getSaasNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) {
        return saasFegin.getList(fields, filters, sorts);
    }
}

+ 53 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/base/SystemDictListController.java

@ -0,0 +1,53 @@
package com.yihu.jw.controller.base.base;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.base.BaseContants;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.base.SystemDictListFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by LiTaohong on 2017/12/01.
 */
@RestController
@RequestMapping(BaseContants.api_systemDictList)
@Api(description = "SystemDictList相关")
public class SystemDictListController extends EnvelopRestController {
    private Logger logger= LoggerFactory.getLogger(SystemDictListController.class);
    @Autowired
    private SystemDictListFeign SystemDictListFegin;
    @Autowired
    private Tracer tracer;
    @GetMapping(value = BaseContants.SystemDictList.api_getSystemDictListNoPage)
    @ApiOperation(value = "获取SystemDictList,不分页")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getSystemDictListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,SystemDictListId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException {
        return SystemDictListFegin.getListNoPage(fields, filters, sorts);
    }
}

+ 135 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java

@ -0,0 +1,135 @@
package com.yihu.jw.controller.base.user;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.base.BaseContants;
import com.yihu.jw.commnon.base.user.BaseUserContants;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.user.BaseRoleFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@RestController
@RequestMapping(BaseUserContants.api_baseRole)
@Api(value = "角色管理", description = "角色管理")
public class BaseRoleController extends EnvelopRestController {
    @Autowired
    private BaseRoleFeign fegin;
    @Autowired
    private Tracer tracer;
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PostMapping(value = BaseUserContants.BaseRole.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建角色", notes = "创建角色")
    public Envelop createFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws JiWeiException {
        return fegin.create(jsonData);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PutMapping(value = BaseUserContants.BaseRole.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新角色", notes = "更新角色")
    public Envelop updateFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws JiWeiException {
        return fegin.update(jsonData);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @DeleteMapping(value = BaseUserContants.BaseRole.api_delete)
    @ApiOperation(value = "删除角色", notes = "删除角色")
    public Envelop deleteBaseRole(
            @ApiParam(name = "id", value = "uuid")
            @RequestParam(value = "id", required = true) String id
            ) throws JiWeiException {
        return fegin.delete(id);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseRole.api_getById)
    @ApiOperation(value = "根据Id查找", notes = "根据uuid查找")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id", required = true) String id
    ) throws JiWeiException {
        return fegin.findById(id);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @RequestMapping(value = BaseUserContants.BaseRole.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取功能列表(分页)")
    public Envelop getBaseRoles(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        String filterStr = "";
        if(StringUtils.isNotBlank(filters)){
            JSONObject jsonResult = new JSONObject(filters);
            if(jsonResult.has("name")){
                filterStr+="name?"+jsonResult.get("name")+";";
            }
        }
        return fegin.getList(fields, filterStr, sorts, size, page);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseRole.api_getListNoPage)
    @ApiOperation(value = "获取功能列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        String filterStr = "";
        if(StringUtils.isNotBlank(filters)){
            JSONObject jsonResult = new JSONObject(filters);
            if(jsonResult.has("saasId")){
                filterStr+="saasId="+jsonResult.get("saasId")+";";
            }
        }
        return fegin.getListNoPage(fields, filterStr, sorts);
    }
}

+ 136 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/user/EmployController.java

@ -0,0 +1,136 @@
package com.yihu.jw.controller.base.user;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.user.BaseUserContants;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.user.BaseRoleFeign;
import com.yihu.jw.feign.base.user.EmployFeign;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Created by LiTaohong on 2017/11/30.
 */
@RestController
@RequestMapping(BaseUserContants.api_employee)
@Api(value = "用戶管理", description = "用戶管理")
public class EmployController extends EnvelopRestController {
    @Autowired
    private EmployFeign fegin;
    @Autowired
    private Tracer tracer;
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PostMapping(value = BaseUserContants.Employee.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建用戶", notes = "创建用戶")
    public Envelop createFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws JiWeiException {
        return fegin.create(jsonData);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PutMapping(value = BaseUserContants.Employee.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新用戶", notes = "更新用戶")
    public Envelop updateFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws JiWeiException {
        return fegin.update(jsonData);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @DeleteMapping(value = BaseUserContants.Employee.api_delete)
    @ApiOperation(value = "删除用戶", notes = "删除用戶")
    public Envelop deleteBaseRole(
            @ApiParam(name = "id", value = "uuid")
            @RequestParam(value = "id", required = true) String id
            ) throws JiWeiException {
        return fegin.delete(id);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.Employee.api_getById)
    @ApiOperation(value = "根据Id查找", notes = "根据uuid查找")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id", required = true) String id
    ) throws JiWeiException {
        return fegin.findById(id);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @RequestMapping(value = BaseUserContants.Employee.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取功能列表(分页)")
    public Envelop getEmployList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,sex,phone,email,jxzc,lczcn,xlzc,xzzc,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        String filterStr = "";
        if(StringUtils.isNotBlank(filters)){
            JSONObject jsonResult = new JSONObject(filters);
            if(jsonResult.has("name")){
                filterStr+="name?"+jsonResult.get("name")+";";
            }
        }
        return fegin.getList(fields, filterStr, sorts, size, page);
    }
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseRole.api_getListNoPage)
    @ApiOperation(value = "获取功能列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,sex,phone,email,jxzc,lczcn,xlzc,xzzc,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        String filterStr = "";
        if(StringUtils.isNotBlank(filters)){
            JSONObject jsonResult = new JSONObject(filters);
            if(jsonResult.has("saasId")){
                filterStr+="saasId="+jsonResult.get("saasId")+";";
            }
        }
        return fegin.getListNoPage(fields, filterStr, sorts);
    }
}

+ 0 - 2
web-gateway/src/main/java/com/yihu/jw/feign/base/base/FunctionFeign.java

@ -43,6 +43,4 @@ public interface FunctionFeign {
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.Function.api_getChildren)
    Envelop getChildren(@PathVariable(value="id") String id) throws JiWeiException;
}

+ 46 - 0
web-gateway/src/main/java/com/yihu/jw/feign/base/base/SystemDictFeign.java

@ -0,0 +1,46 @@
package com.yihu.jw.feign.base.base;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.fallbackfactory.base.base.SystemDictFeignFallbackFactory;
import com.yihu.jw.feign.fallbackfactory.base.base.SystemDictFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = SystemDictFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface SystemDictFeign {
    @RequestMapping(value = BaseRequestMapping.SystemDict.api_create,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.POST)
    Envelop create(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseRequestMapping.SystemDict.api_update,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.PUT)
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseRequestMapping.SystemDict.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable(value = "ids", required = true) String ids, @RequestParam(value = "userId") String userId, @RequestParam(value = "userName") String userName) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.SystemDict.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;
    @RequestMapping(value = BaseRequestMapping.SystemDict.api_getList, method = RequestMethod.GET)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.SystemDict.api_getListNoPage)
    Envelop getListNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
}

+ 49 - 0
web-gateway/src/main/java/com/yihu/jw/feign/base/base/SystemDictListFeign.java

@ -0,0 +1,49 @@
package com.yihu.jw.feign.base.base;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.fallbackfactory.base.base.SystemDictListFeignFallbackFactory;
import com.yihu.jw.feign.fallbackfactory.base.base.SystemDictListFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = SystemDictListFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface SystemDictListFeign {
    @RequestMapping(value = BaseRequestMapping.SystemDictList.api_create,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.POST)
    Envelop create(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseRequestMapping.SystemDictList.api_update,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.PUT)
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseRequestMapping.SystemDictList.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable(value = "ids", required = true) String ids, @RequestParam(value = "userId") String userId, @RequestParam(value = "userName") String userName) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.SystemDictList.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;
    @RequestMapping(value = BaseRequestMapping.SystemDictList.api_getList, method = RequestMethod.GET)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.SystemDictList.api_getListNoPage)
    Envelop getListNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
    @GetMapping(value = BaseRequestMapping.SystemDictList.api_getChildren)
    Envelop getChildren(@PathVariable(value = "id") String id) throws JiWeiException;
}

+ 46 - 0
web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java

@ -0,0 +1,46 @@
package com.yihu.jw.feign.base.user;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.fallbackfactory.base.user.BaseRoleFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = BaseRoleFeignFallbackFactory.class
)
public interface BaseRoleFeign {
    
    @RequestMapping(value = BaseUserRequestMapping.BaseRole.api_create,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.POST)
    Envelop create(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_update,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.PUT)
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;
    @RequestMapping(value = BaseUserRequestMapping.BaseRole.api_getList, method = RequestMethod.GET)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListNoPage)
    Envelop getListNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
}

+ 48 - 0
web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java

@ -0,0 +1,48 @@
package com.yihu.jw.feign.base.user;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.fallbackfactory.base.user.EmployeeFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by LiTaohong on 2017/11/30.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = EmployeeFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface EmployFeign {
    @RequestMapping(value = BaseUserRequestMapping.BaseRole.api_create,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.POST)
    Envelop create(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_update,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,method = RequestMethod.PUT)
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;
    @RequestMapping(value = BaseUserRequestMapping.BaseRole.api_getList, method = RequestMethod.GET)
    Envelop getList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListNoPage)
    Envelop getListNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
}

+ 0 - 25
web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployeeFeign.java

@ -1,25 +0,0 @@
package com.yihu.jw.feign.base.user;
import com.yihu.jw.feign.fallbackfactory.base.user.EmployeeFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by chenweida on 2017/11/29.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = EmployeeFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface EmployeeFeign {
    @RequestMapping(value = BaseRequestMapping.Employee.api_getEmployeeByAccount, method = RequestMethod.GET)
    Envelop getEmployeeByAccount(@RequestParam(value = "userAccount",required = true)String userAccount);
}

+ 74 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/base/SystemDictFeignFallbackFactory.java

@ -0,0 +1,74 @@
package com.yihu.jw.feign.fallbackfactory.base.base;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.base.FunctionFeign;
import com.yihu.jw.feign.base.base.SystemDictFeign;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@Component
public class SystemDictFeignFallbackFactory implements FallbackFactory<SystemDictFeign> {
    @Autowired
    private Tracer tracer;
    @Override
    public SystemDictFeign create(Throwable e) {
        return new SystemDictFeign() {
            @Override
            public Envelop create(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("创建系統字典失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop update(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("更新系統字典失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop delete(@PathVariable String codes, @RequestParam String userCode, @RequestParam String userName) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("删除系統字典失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("codes:"+codes);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop findById(String code) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找系統字典失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("code:"+code);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getList(String fields, String filterStr, String sorts, int size, int page) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("分页查找系統字典失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filterStr);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                tracer.getCurrentSpan().logEvent("size:" + size);
                tracer.getCurrentSpan().logEvent("page:" + page);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getListNoPage(String fields, String filters, String sorts) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找系統字典列表失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                throw new JiWeiException(e);
            }
        };
    }
}

+ 80 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/base/SystemDictListFeignFallbackFactory.java

@ -0,0 +1,80 @@
package com.yihu.jw.feign.fallbackfactory.base.base;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.base.FunctionFeign;
import com.yihu.jw.feign.base.base.SystemDictListFeign;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@Component
public class SystemDictListFeignFallbackFactory implements FallbackFactory<SystemDictListFeign> {
    @Autowired
    private Tracer tracer;
    @Override
    public SystemDictListFeign create(Throwable e) {
        return new SystemDictListFeign() {
            @Override
            public Envelop create(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("创建系統字典集合失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop update(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("更新系統字典集合失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop delete(@PathVariable String codes, @RequestParam String userCode, @RequestParam String userName) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("删除系統字典集合失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("codes:"+codes);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop findById(String code) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找系統字典集合失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("code:"+code);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getList(String fields, String filterStr, String sorts, int size, int page) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("分页查找系統字典集合失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filterStr);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                tracer.getCurrentSpan().logEvent("size:" + size);
                tracer.getCurrentSpan().logEvent("page:" + page);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getListNoPage(String fields, String filters, String sorts) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找系統字典集合列表失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getChildren(String code) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找系統字典子项失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("code:" + code);
                throw new JiWeiException(e);
            }
        };
    }
}

+ 73 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java

@ -0,0 +1,73 @@
package com.yihu.jw.feign.fallbackfactory.base.user;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.user.BaseRoleFeign;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public class BaseRoleFeignFallbackFactory implements FallbackFactory<BaseRoleFeign> {
    @Autowired
    private Tracer tracer;
    @Override
    public BaseRoleFeign create(Throwable e) {
        return new BaseRoleFeign() {
            @Override
            public Envelop create(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("创建角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop update(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("更新角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop delete(@PathVariable String id) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("删除角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("id:"+id);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop findById(String id) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找单个角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("id:"+id);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getList(String fields, String filterStr, String sorts, int size, int page) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("分页查找角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filterStr);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                tracer.getCurrentSpan().logEvent("size:" + size);
                tracer.getCurrentSpan().logEvent("page:" + page);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getListNoPage(String fields, String filters, String sorts) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找角色列表失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                throw new JiWeiException(e);
            }
        };
    }
}

+ 62 - 4
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java

@ -1,14 +1,72 @@
package com.yihu.jw.feign.fallbackfactory.base.user;
import com.yihu.jw.feign.base.user.EmployeeFeign;
import com.yihu.jw.exception.business.JiWeiException;
import com.yihu.jw.feign.base.user.EmployFeign;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by chenweida on 2017/11/29.
 */
public class EmployeeFeignFallbackFactory  implements FallbackFactory<EmployeeFeign> {
public class EmployeeFeignFallbackFactory  implements FallbackFactory<EmployFeign> {
    @Autowired
    private Tracer tracer;
    @Override
    public EmployeeFeign create(Throwable cause) {
        return null;
    public EmployFeign create(Throwable e) {
        return new EmployFeign() {
            @Override
            public Envelop create(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("创建角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop update(@RequestBody String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("更新角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop delete(@PathVariable String id) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("删除角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("id:"+id);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop findById(String id) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找单个角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("id:"+id);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getList(String fields, String filterStr, String sorts, int size, int page) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("分页查找角色失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filterStr);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                tracer.getCurrentSpan().logEvent("size:" + size);
                tracer.getCurrentSpan().logEvent("page:" + page);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getListNoPage(String fields, String filters, String sorts) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找角色列表失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                throw new JiWeiException(e);
            }
        };
    }
}