Ver código fonte

code viewer更改

wangPH 1 ano atrás
pai
commit
5c1f3327d6

+ 2 - 1
background-gateway/src/main/java/cn/kdan/compdf/filter/AuthGlobalFilter.java

@@ -23,6 +23,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.http.server.reactive.ServerHttpResponse;
 import org.springframework.stereotype.Component;
@@ -69,7 +70,7 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
             LoginUser loginUser = JwtConfig.checkJwt(authorization);
             // 查询用户信息(username - email)
             R<LoginUserDTO> r = userFeign.getUserInfo(loginUser);
-            if (!"200".equals(r.getCode())){
+            if (!String.valueOf(HttpStatus.OK.value()).equals(r.getCode())){
                 ServerHttpResponse response = exchange.getResponse();
                 response.setStatusCode(HttpStatus.OK);
                 // 改变响应的类型

+ 32 - 0
background-user/src/main/java/cn/kdan/compdf/constant/AssetTypeEnum.java

@@ -0,0 +1,32 @@
+package cn.kdan.compdf.constant;
+
+import cn.kdan.compdf.enums.ResponseEnum;
+import cn.kdan.compdf.exception.BusinessException;
+import lombok.Getter;
+
+/**
+ * @author ComPDFKit-WPH 2023/7/4
+ */
+public enum AssetTypeEnum {
+    SUBSCRIPTION(1),
+    PACKAGE(2),
+    FREE(3),
+    ;
+    @Getter
+    private final Integer value;
+
+    AssetTypeEnum(Integer value){
+        this.value = value;
+    }
+
+    public static AssetTypeEnum getByValue(Integer value){
+        for (AssetTypeEnum assetTypeEnum : AssetTypeEnum.values()) {
+            if (assetTypeEnum.getValue().equals(value)) {
+                return assetTypeEnum;
+            }
+        }
+        throw new BusinessException(ResponseEnum.ERROR_ASSET_TYPE_IS_NOT_SUPPORTED_YET);
+    }
+
+
+}

+ 6 - 4
background-user/src/main/java/cn/kdan/compdf/service/impl/BackgroundUserBalanceServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.kdan.compdf.config.ExcelWidthStyleStrategy;
+import cn.kdan.compdf.constant.AssetTypeEnum;
 import cn.kdan.compdf.constant.UserBalanceConstant;
 import cn.kdan.compdf.dto.AddFreePlanDTO;
 import cn.kdan.compdf.dto.Asset;
@@ -304,18 +305,19 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
             BillVO billVO = new BillVO();
             billVO.setAssetType(userRemain.getAssetType());
             billVO.setTotalFiles(userRemain.getTotalFiles());
-            switch (userRemain.getAssetType()) {
-                case 3:
+            //  资产类型enum
+            switch (AssetTypeEnum.getByValue(userRemain.getAssetType())) {
+                case FREE:
                     LocalDateTime userFirstLogin = userService.getUSerFirstLogin(TokenUtil.getRequestHeader().getTenantId());
                     billVO.setStartDate(userFirstLogin.toLocalDate().compareTo(this.getFirstDayOfMonth()) < 0  ? this.getFirstDayOfMonth() : userFirstLogin.toLocalDate() );
                     billVO.setEndDate(this.getLastDayOfMonth());
                     break;
-                case 1:
+                case SUBSCRIPTION:
                     billVO.setStartDate(ObjectUtil.isNotEmpty(userRemain.getStartDate()) ? userRemain.getStartDate().toLocalDate() : null);
                     billVO.setEndDate(ObjectUtil.isNotEmpty(userRemain.getEndDate()) ? userRemain.getEndDate().toLocalDate() : null);
                     billVO.setCycle(userRemain.getCycle());
                     break;
-                case 2: break;
+                case PACKAGE: break;
                 default: throw new BusinessException(ResponseEnum.ERROR_ASSET_TYPE_IS_NOT_SUPPORTED_YET);
             }
             return billVO;

+ 0 - 3
background-user/src/main/java/cn/kdan/compdf/service/impl/UserBillingInformationServiceImpl.java

@@ -99,16 +99,13 @@ public class UserBillingInformationServiceImpl extends ServiceImpl<UserBillingIn
     @Override
     public void updateUserBillingInfo(Integer compdfKitId, UserBillingUpInfoDTO userBillingUpInfoDTO) {
         UserBillingInfoVO userBillingInfo = this.getUserBillingInfo(compdfKitId);
-
         UserBillingInformation userBillingInformation = new UserBillingInformation();
-
         BeanUtil.copyProperties(userBillingUpInfoDTO, userBillingInformation);
         if (BeanUtil.isEmpty(userBillingInfo)) {
             // 新增
             userBillingInformation.setCreatedAt(new Date());
             userBillingInformation.setUpdatedAt(new Date());
             userBillingInformation.setUserId(compdfKitId);
-
             this.baseMapper.insert(userBillingInformation);
         } else {
             // 修改