Kaynağa Gözat

兼容制卡分配接口

mingfu 1 gün önce
ebeveyn
işleme
7cb8b325ab

+ 11 - 10
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzCardsController.java

@@ -4,7 +4,6 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.ValidationException;
 
-import cn.hutool.core.util.NumberUtil;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.ExamType;
 import com.ruoyi.common.utils.NumberUtils;
@@ -137,9 +136,8 @@ public class DzCardsController extends BaseController
     @Log(title = "制卡", businessType = BusinessType.INSERT)
     @PostMapping("/issueCard")
     @ApiOperation("制卡")
-    public AjaxResult issueCard(@ApiParam("机构") Long institutionId, @ApiParam("卡类型") Integer type, @ApiParam("数量") Integer count)
+    public AjaxResult issueCard(@ApiParam("机构") Long institutionId, @ApiParam("卡类型") String type, @ApiParam("数量") Integer count)
     {
-
         dzCardsService.issueCard(institutionId, getCardType(institutionId, type), count);
         return AjaxResult.success();
     }
@@ -147,7 +145,7 @@ public class DzCardsController extends BaseController
     @Log(title = "分配卡", businessType = BusinessType.INSERT)
     @PostMapping("/assignCard")
     @ApiOperation("分配卡")
-    public AjaxResult assignCard(@ApiParam("代理商") @RequestParam Long agentId, @ApiParam("卡类型") Integer type,
+    public AjaxResult assignCard(@ApiParam("代理商") @RequestParam Long agentId, @ApiParam("卡类型") String type, @ApiParam(value = "卡类型") Integer cardType,
                                  @ApiParam("开始号") @RequestParam String begin, @ApiParam("结束号") @RequestParam String end,
                                  @ApiParam("省份") @RequestParam(required = false) String location,
                                  @ApiParam("考生类型") @RequestParam(required = false) ExamType examType,
@@ -156,19 +154,19 @@ public class DzCardsController extends BaseController
     {
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
         DzAgent agent = agentService.selectDzAgentByAgentId(agentId);
-        CardType cardType = getCardType(agent.getDeptId(), type);
+        CardType ct = getCardType(agent.getDeptId(), null != cardType ? cardType.toString() : type);
         if(UserTypeEnum.Agent.getVal().equals(sysUser.getUserType())) { // 代理商分配
             if (!sysUser.getUserTypeId().equals(agent.getParentId())) {
                 throw new ValidationException("只能分配给下级代理");
             }
-            dzCardsService.assignCard(sysUser.getUserTypeId(), agentId, cardType, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(sysUser.getUserTypeId(), agentId, ct, begin, end, location, examType, schoolId, days);
         } else if(UserTypeEnum.Institution.getVal().equals(sysUser.getUserType())) { // 机构分配卡给自己的下级
             if (!sysUser.getDeptId().equals(agent.getDeptId())) {
                 throw new ValidationException("只能分配给下级代理");
             }
-            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, cardType, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, ct, begin, end, location, examType, schoolId, days);
         } else { // 平台指定, TODO 暂只支持二级代理
-            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, cardType, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, ct, begin, end, location, examType, schoolId, days);
         }
         return AjaxResult.success();
     }
@@ -200,8 +198,11 @@ public class DzCardsController extends BaseController
     }
 
 
-    private CardType getCardType(Long institutionId, Integer type) {
-        if(type.equals(9)) {
+    private CardType getCardType(Long institutionId, String type) {
+        if(!NumberUtils.isNumeric(type)) {
+            return CardType.valueOf(type);
+        }
+        if(Integer.parseInt(type) == 9) {
             return CardType.Experience;
         }
         return (null == institutionId || institutionId.equals(101L)) ? CardType.Platform : CardType.Dept;