Эх сурвалжийг харах

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

hy 7 жил өмнө
parent
commit
810d25a702
42 өөрчлөгдсөн 152 нэмэгдсэн , 36 устгасан
  1. 4 4
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Vendor.java
  2. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerkindController.java
  3. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/AddressMapper.java
  4. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerkindMapper.java
  5. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/FundinouttypeMapper.java
  6. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductbrandMapper.java
  7. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProducttypeMapper.java
  8. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductunitMapper.java
  9. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorkindMapper.java
  10. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/AddressService.java
  11. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerkindService.java
  12. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/FundinouttypeService.java
  13. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductbrandService.java
  14. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProducttypeService.java
  15. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductunitService.java
  16. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorkindService.java
  17. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java
  18. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerkindServiceImpl.java
  19. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/FundinouttypeServiceImpl.java
  20. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductbrandServiceImpl.java
  21. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProducttypeServiceImpl.java
  22. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductunitServiceImpl.java
  23. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorkindServiceImpl.java
  24. 1 1
      applications/document/document-server/src/main/resources/mapper/AddressMapper.xml
  25. 1 1
      applications/document/document-server/src/main/resources/mapper/CustomerkindMapper.xml
  26. 1 1
      applications/document/document-server/src/main/resources/mapper/FundinouttypeMapper.xml
  27. 2 1
      applications/document/document-server/src/main/resources/mapper/ProductMapper.xml
  28. 1 1
      applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml
  29. 1 1
      applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml
  30. 1 1
      applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml
  31. 1 1
      applications/document/document-server/src/main/resources/mapper/VendorkindMapper.xml
  32. 1 4
      applications/storage/storage-server/src/main/resources/mapper/MakematerialMapper.xml
  33. 1 1
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/AccountCache.java
  34. 1 1
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/ResourceCache.java
  35. 1 1
      base-servers/account/account-server/src/main/resources/application.yml
  36. 2 1
      base-servers/auth/auth-client/src/main/java/com/usoftchina/saas/auth/client/interceptor/AuthRestInterceptor.java
  37. 1 1
      base-servers/auth/auth-common/src/main/java/com/usoftchina/saas/auth/common/jwt/JwtHelper.java
  38. 21 12
      base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/AuthFilter.java
  39. 6 0
      base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/WebConfig.java
  40. 28 0
      base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/interceptor/ServiceFeignInterceptor.java
  41. 2 0
      base-servers/gateway-server/src/main/resources/application.yml
  42. 16 2
      framework/core/src/main/java/com/usoftchina/saas/cache/BaseRedisCache.java

+ 4 - 4
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Vendor.java

@@ -35,19 +35,19 @@ public class Vendor extends CommonBaseEntity implements Serializable{
     /**
      * 期初应付
      */
-    private long ve_beginapamount;
+    private Long ve_beginapamount;
     /**
      * 期初预付
      */
-    private long ve_beginprepayamount;
+    private Long ve_beginprepayamount;
     /**
      * 承付天数
      */
-    private long ve_promisedays;
+    private Long ve_promisedays;
     /**
      * 税率
      */
-    private double ve_taxrate;
+    private Double ve_taxrate;
     /**
      * 纳税人识别号
      */

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerkindController.java

@@ -31,7 +31,7 @@ public class CustomerkindController {
 
     @GetMapping("/list")
     public Result getAll(){
-        List<Customerkind> customerkindList = customerkindService.findAll();
+        List<Customerkind> customerkindList = customerkindService.selectAll();
         return Result.success(customerkindList);
     }
 

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/AddressMapper.java

@@ -28,4 +28,6 @@ public interface AddressMapper extends CommonBaseMapper<Address> {
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
+
+    List<Address> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerkindMapper.java

@@ -23,4 +23,6 @@ public interface CustomerkindMapper extends CommonBaseMapper<Customerkind> {
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
 
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
+
+    List<Customerkind> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/FundinouttypeMapper.java

@@ -24,4 +24,6 @@ public interface FundinouttypeMapper extends CommonBaseMapper<Fundinouttype> {
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
+
+    List<Fundinouttype> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductbrandMapper.java

@@ -24,4 +24,6 @@ public interface ProductbrandMapper extends CommonBaseMapper<Productbrand> {
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
 
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
+
+    List<Productbrand> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProducttypeMapper.java

@@ -23,4 +23,6 @@ public interface ProducttypeMapper extends CommonBaseMapper<Producttype> {
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
+
+    List<Producttype> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductunitMapper.java

@@ -23,4 +23,6 @@ public interface ProductunitMapper extends CommonBaseMapper<Productunit> {
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
+
+    List<Productunit> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorkindMapper.java

@@ -24,4 +24,6 @@ public interface VendorkindMapper extends CommonBaseMapper<Vendorkind> {
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
 
     int selectCountByName(@Param("name") String name, @Param("companyId") Long companyId, @Param("id") Long id);
+
+    List<Vendorkind> selectAll(@Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/AddressService.java

@@ -12,4 +12,6 @@ public interface AddressService extends CommonBaseService<AddressMapper, Address
     void removeByIds(String ids);
 
     List<ComboDTO> getCombo();
+
+    List<Address> selectAll();
 }

+ 1 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerkindService.java

@@ -11,4 +11,5 @@ public interface CustomerkindService extends CommonBaseService<CustomerkindMappe
 
     List<ComboDTO> getCombo();
 
+    List<Customerkind> selectAll();
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/FundinouttypeService.java

@@ -4,6 +4,7 @@ import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.document.entities.Fundinouttype;
 import com.usoftchina.saas.document.mapper.FundinouttypeMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -11,4 +12,5 @@ public interface FundinouttypeService extends CommonBaseService<FundinouttypeMap
 
     List<ComboDTO> getCombo();
 
+    List<Fundinouttype> selectAll();
 }

+ 1 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductbrandService.java

@@ -11,4 +11,5 @@ public interface ProductbrandService extends CommonBaseService<ProductbrandMappe
 
     List<ComboDTO> getCombo();
 
+    List<Productbrand> selectAll();
 }

+ 1 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProducttypeService.java

@@ -11,4 +11,5 @@ public interface ProducttypeService extends CommonBaseService<ProducttypeMapper,
 
     List<ComboDTO> getCombo();
 
+    List<Producttype> selectAll();
 }

+ 1 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductunitService.java

@@ -11,4 +11,5 @@ public interface ProductunitService extends CommonBaseService<ProductunitMapper,
 
     List<ComboDTO> getCombo();
 
+    List<Productunit> selectAll();
 }

+ 1 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorkindService.java

@@ -11,4 +11,5 @@ public interface VendorkindService extends CommonBaseService<VendorkindMapper, V
 
     List<ComboDTO> getCombo();
 
+    List<Vendorkind> selectAll();
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java

@@ -84,6 +84,11 @@ public class AddressServiceImpl extends CommonBaseServiceImpl<AddressMapper, Add
        return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
 
+    @Override
+    public List<Address> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
+
     private DocBaseDTO generateMsgObj(Long id){
         return new DocBaseDTO(id, "", "Address");
     }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerkindServiceImpl.java

@@ -81,6 +81,11 @@ public class CustomerkindServiceImpl extends CommonBaseServiceImpl<CustomerkindM
         return customerkindList;
     }
 
+    @Override
+    public List<Customerkind> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
+
     /**
      * 校验
      * @param name

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/FundinouttypeServiceImpl.java

@@ -89,4 +89,9 @@ public class FundinouttypeServiceImpl extends CommonBaseServiceImpl<Fundinouttyp
     public List<ComboDTO> getCombo() {
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
+
+    @Override
+    public List<Fundinouttype> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductbrandServiceImpl.java

@@ -67,6 +67,11 @@ public class ProductbrandServiceImpl extends CommonBaseServiceImpl<ProductbrandM
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
 
+    @Override
+    public List<Productbrand> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
+
     /**
      * 校验
      * @param name

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProducttypeServiceImpl.java

@@ -93,4 +93,9 @@ public class ProducttypeServiceImpl extends CommonBaseServiceImpl<ProducttypeMap
     public List<ComboDTO> getCombo() {
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
+
+    @Override
+    public List<Producttype> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductunitServiceImpl.java

@@ -88,4 +88,9 @@ public class ProductunitServiceImpl extends CommonBaseServiceImpl<ProductunitMap
     public List<ComboDTO> getCombo() {
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
+
+    @Override
+    public List<Productunit> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorkindServiceImpl.java

@@ -71,6 +71,11 @@ public class VendorkindServiceImpl extends CommonBaseServiceImpl<VendorkindMappe
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
 
+    @Override
+    public List<Vendorkind> selectAll() {
+        return getMapper().selectAll(BaseContextHolder.getCompanyId());
+    }
+
     /**
      * 校验
      * @param name

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/AddressMapper.xml

@@ -179,7 +179,7 @@
     where ad_id in (#{ids,jdbcType=VARCHAR})
   </delete>
   <select id="selectAll" resultMap="ResultMapWithBLOBs">
-    SELECT * FROM ADDRESS
+    SELECT * FROM ADDRESS where COMPANYID=#{companyId}
   </select>
   <select id="selectCountByName" resultType="int">
     SELECT count(*) FROM ADDRESS

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomerkindMapper.xml

@@ -120,7 +120,7 @@
     where ck_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM CUSTOMERKIND
+    SELECT * FROM CUSTOMERKIND WHERE COMPANYID=#{companyId}
   </select>
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
     SELECT ck_name display,ck_name value FROM CUSTOMERKIND WHERE COMPANYID=#{companyId}

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/FundinouttypeMapper.xml

@@ -140,7 +140,7 @@
     where ft_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM FUNDINOUTTYPE
+    SELECT * FROM FUNDINOUTTYPE where companyId=#{companyId}
   </select>
   <select id="selectCountByName" resultType="int">
     SELECT COUNT(*) FROM FUNDINOUTTYPE

+ 2 - 1
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -472,7 +472,7 @@
         <result column="pr_detail" property="rc_prodDetail" jdbcType="VARCHAR" />
         <result column="pr_unit" property="rc_prodUnit" jdbcType="VARCHAR" />
         <result column="wh_code" property="rc_whCode" jdbcType="VARCHAR" />
-        <result column="wh_name" property="rc_whName" jdbcType="VARCHAR" />
+        <result column="wh_description" property="rc_whName" jdbcType="VARCHAR" />
         <result column="pw_onhand" property="rc_number" jdbcType="DOUBLE" />
         <result column="pw_avprice" property="rc_price" jdbcType="DOUBLE" />
         <result column="pw_amount" property="rc_amount" jdbcType="DOUBLE" />
@@ -485,6 +485,7 @@
           </if>
           <if test="companyId!=null">
               and tab.companyId=#{companyId} and Product.companyId=#{companyId} and warehouse.companyId=#{companyId}
+              and pw_onhand!=0
           </if>
         </where>
         ORDER BY PR_ID DESC

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml

@@ -126,7 +126,7 @@
     where pb_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM PRODUCTBRAND
+    SELECT * FROM PRODUCTBRAND where companyId = #{companyId}
   </select>
 
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml

@@ -126,7 +126,7 @@
     where pt_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM PRODUCTTYPE
+    SELECT * FROM PRODUCTTYPE where companyId=#{companyId}
   </select>
     <select id="selectCountByName" resultType="int">
         SELECT COUNT(*) FROM PRODUCTTYPE

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml

@@ -120,7 +120,7 @@
     where pu_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM PRODUCTUNIT
+    SELECT * FROM PRODUCTUNIT where companyId=#{companyId}
   </select>
     <select id="selectCountByName" resultType="int">
         SELECT COUNT(*) FROM productunit

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/VendorkindMapper.xml

@@ -126,7 +126,7 @@
     where vk_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM VENDORKIND
+    SELECT * FROM VENDORKIND where companyId = #{companyId}
   </select>
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
     SELECT VK_NAME display, VK_NAME value FROM VENDORKIND WHERE COMPANYID=#{companyId}

+ 1 - 4
applications/storage/storage-server/src/main/resources/mapper/MakematerialMapper.xml

@@ -18,7 +18,7 @@
     <result column="companyId" property="companyId" jdbcType="INTEGER" />
     <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
     <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
-    <association property="product" jdbcType="com.usoftchina.saas.document.entities.Product">
+    <association property="product" javaType="com.usoftchina.saas.document.dto.ProductDTO">
         <id column="pr_id" property="id" jdbcType="INTEGER" />
         <result column="pr_code" property="pr_code" jdbcType="VARCHAR" />
         <result column="pr_detail" property="pr_detail" jdbcType="VARCHAR" />
@@ -43,14 +43,11 @@
         <result column="pr_recordman" property="pr_recordman" jdbcType="VARCHAR" />
         <result column="pr_status" property="pr_status" jdbcType="VARCHAR" />
         <result column="pr_statuscode" property="pr_statuscode" jdbcType="VARCHAR" />
-        <result column="companyId" property="companyId" jdbcType="INTEGER" />
-        <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
         <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
         <result column="pr_text1" property="pr_text1" jdbcType="VARCHAR" />
         <result column="pr_text2" property="pr_text2" jdbcType="VARCHAR" />
         <result column="pr_text3" property="pr_text3" jdbcType="VARCHAR" />
         <result column="pr_text4" property="pr_text4" jdbcType="VARCHAR" />
-        <result column="pr_text5" property="pr_text5" jdbcType="VARCHAR" />
     </association>
   </resultMap>
   <sql id="Base_Column_List" >

+ 1 - 1
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/AccountCache.java

@@ -38,7 +38,7 @@ public class AccountCache extends RedisHashCache<String, String, String> {
 
     @Override
     protected String key() {
-        return generateKey("account", "account");
+        return generatePublicKey("account", "account");
     }
 
     @Override

+ 1 - 1
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/ResourceCache.java

@@ -40,7 +40,7 @@ public class ResourceCache extends RedisHashCache<String, String, String> {
 
     @Override
     protected String key() {
-        return generateKey("account", "resource");
+        return generatePublicKey("account", "resource");
     }
 
     @Override

+ 1 - 1
base-servers/account/account-server/src/main/resources/application.yml

@@ -50,7 +50,7 @@ eureka:
   client:
     registryFetchIntervalSeconds: 5
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@192.168.0.181:8510/eureka/
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:8500/eureka/
 server:
   port: 8580
   tomcat:

+ 2 - 1
base-servers/auth/auth-client/src/main/java/com/usoftchina/saas/auth/client/interceptor/AuthRestInterceptor.java

@@ -44,7 +44,8 @@ public class AuthRestInterceptor extends HandlerInterceptorAdapter {
                 BaseContextHolder.setUserId(infoFromToken.getUserId());
                 BaseContextHolder.setCompanyId(infoFromToken.getCompanyId());
                 BaseContextHolder.setToken(token);
-                log.info("token={} \\r\\n userName={}", token, infoFromToken.getUserName());
+                log.info("request={} token={} \\r\\n userName={}", request.getRequestURI(),
+                        token, infoFromToken.getUserName());
             }
         } else {
             // no mapping

+ 1 - 1
base-servers/auth/auth-common/src/main/java/com/usoftchina/saas/auth/common/jwt/JwtHelper.java

@@ -95,8 +95,8 @@ public class JwtHelper {
         Claims body = claimsJws.getBody();
         return new JwtInfo(
                 ObjectUtils.getStringValue(body.get("appId")),
-                ObjectUtils.getLongValue(body.get("userId")),
                 ObjectUtils.getLongValue(body.get("companyId")),
+                ObjectUtils.getLongValue(body.get("userId")),
                 ObjectUtils.getStringValue(body.get("userName"))
         );
     }

+ 21 - 12
base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/AuthFilter.java

@@ -6,6 +6,7 @@ import com.usoftchina.saas.account.dto.AccountDTO;
 import com.usoftchina.saas.account.dto.UrlResourceDTO;
 import com.usoftchina.saas.auth.common.jwt.JwtHelper;
 import com.usoftchina.saas.auth.common.jwt.JwtInfo;
+import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
 import com.usoftchina.saas.gateway.error.PermissionException;
@@ -40,17 +41,26 @@ public class AuthFilter implements GlobalFilter, Ordered {
 
     @Override
     public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
-        if (!isIgnore(exchange.getRequest())) {
-            // 鉴别身份信息
-            JwtInfo jwt = getJwtInfoFromHeader(exchange.getRequest());
-            AccountDTO accountDTO = AccountCache.of(jwt.getUserId()).getAccount();
-            if (null == accountDTO) {
-                throw new BizException(ExceptionCode.USER_NOT_EXIST);
+        try {
+            if (!isIgnore(exchange.getRequest())) {
+                // 鉴别身份信息
+                String token = getAuthHeaderToken(exchange.getRequest());
+                JwtInfo jwt = JwtHelper.getInfoFromToken(token, authConfig.getPublicKey());
+                BaseContextHolder.setAppId(jwt.getAppId());
+                BaseContextHolder.setUserId(jwt.getUserId());
+                BaseContextHolder.setCompanyId(jwt.getCompanyId());
+                BaseContextHolder.setToken(token);
+                AccountDTO accountDTO = AccountCache.of(jwt.getUserId()).getAccount();
+                if (null == accountDTO) {
+                    throw new BizException(ExceptionCode.USER_NOT_EXIST);
+                }
+                // 鉴别角色权限
+                checkPermission(exchange.getRequest(), jwt, accountDTO);
             }
-            // 鉴别角色权限
-            checkPermission(exchange.getRequest(), jwt, accountDTO);
+            return chain.filter(exchange);
+        } finally {
+            BaseContextHolder.remove();
         }
-        return chain.filter(exchange);
     }
 
     /**
@@ -97,7 +107,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
         return authConfig.getIgnores().stream().anyMatch(ignore -> ignore.equals(path));
     }
 
-    private JwtInfo getJwtInfoFromHeader(ServerHttpRequest request) {
+    private String getAuthHeaderToken(ServerHttpRequest request) {
         if (!request.getHeaders().containsKey(authConfig.getAuthHeader())) {
             throw new BizException(ExceptionCode.JWT_ILLEGAL_ARGUMENT);
         }
@@ -105,8 +115,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
         if (headers.isEmpty()) {
             throw new BizException(ExceptionCode.JWT_ILLEGAL_ARGUMENT);
         }
-        String token = headers.get(0).trim();
-        return JwtHelper.getInfoFromToken(token, authConfig.getPublicKey());
+        return headers.get(0).trim();
     }
 
     @Override

+ 6 - 0
base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/WebConfig.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.gateway.config;
 
+import com.usoftchina.saas.gateway.interceptor.ServiceFeignInterceptor;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.HttpHeaders;
@@ -46,4 +47,9 @@ public class WebConfig {
             return chain.filter(ctx);
         };
     }
+	
+	@Bean
+    public ServiceFeignInterceptor serviceFeignInterceptor() {
+        return new ServiceFeignInterceptor();
+    }
 }

+ 28 - 0
base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/interceptor/ServiceFeignInterceptor.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.gateway.interceptor;
+
+import com.usoftchina.saas.gateway.config.AuthConfig;
+import com.usoftchina.saas.context.BaseContextHolder;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author yingp
+ * @date 2018/10/2
+ */
+public class ServiceFeignInterceptor implements RequestInterceptor {
+    @Autowired
+    private AuthConfig authConfig;
+
+    public ServiceFeignInterceptor() {
+    }
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        requestTemplate.header(authConfig.getAuthHeader(), BaseContextHolder.getToken());
+    }
+
+    public void setAuthConfig(AuthConfig authConfig) {
+        this.authConfig = authConfig;
+    }
+}

+ 2 - 0
base-servers/gateway-server/src/main/resources/application.yml

@@ -172,3 +172,5 @@ auth:
   public-key: auth/pub.key
   ignores:
     - /api/auth/authorize
+    - /api/account/account/register
+    - /api/account/company/register

+ 16 - 2
framework/core/src/main/java/com/usoftchina/saas/cache/BaseRedisCache.java

@@ -101,17 +101,31 @@ public abstract class BaseRedisCache<K, V> implements Cache<V> {
     }
 
     /**
-     * 产生key
+     * 产生key (每个应用会不一样)
      * 规则:[env profile]:[application name]:[business key]
      *
      * @param values
      * @return
      */
-    protected String generateKey(CharSequence... values) {
+    protected String generatePrivateKey(CharSequence... values) {
         return new StringJoiner(":")
                 .add(SpringContextHolder.getActiveProfile())
                 .add(SpringContextHolder.getApplicationName())
                 .add(String.join(":", values))
                 .toString();
     }
+
+    /**
+     * 产生key (所有应用一样)
+     * 规则:[env profile]:[business key]
+     *
+     * @param values
+     * @return
+     */
+    protected String generatePublicKey(CharSequence... values) {
+        return new StringJoiner(":")
+                .add(SpringContextHolder.getActiveProfile())
+                .add(String.join(":", values))
+                .toString();
+    }
 }