TRX 1 ano atrás
pai
commit
cb7f801989

+ 25 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/CardInfoPoolBind2UserParam.java

@@ -0,0 +1,25 @@
+package com.zhongshu.card.client.model.school;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/9/10
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CardInfoPoolBind2UserParam {
+
+    @Schema(description = "卡池卡片ID")
+    @NotEmpty(message = "卡池卡片ID不能为空")
+    private String poolId;
+
+    @Schema(description = "用户userId")
+    @NotEmpty(message = "用户userId")
+    private String userId;
+}

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/service/school/CardInfoService.java

@@ -17,7 +17,7 @@ public interface CardInfoService {
     ResultContent addCardInfo(CardInfoParam param);
 
     // 从卡池选择卡片绑定到个人
-    ResultContent bindCardFromPool(String poolId);
+    ResultContent bindCardFromPool(String poolId, String userId);
 
     ResultContent<List<CardInfoModel>> getCurrentUserOrgAll();
 

+ 14 - 7
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/CardController.java

@@ -18,6 +18,7 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.web.PageableDefault;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -67,13 +68,6 @@ public class CardController {
         return cardInfoService.addCardInfo(param);
     }
 
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "从卡池选择卡片绑定到个人", description = "从卡池选择卡片绑定到个人")
-    @RequestMapping(value = {"bindCardFromPool"}, method = {RequestMethod.POST})
-    public ResultContent bindCardFromPool(@RequestBody IDParam param) {
-        return cardInfoService.bindCardFromPool(param.getId());
-    }
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "删除卡片", description = "用户添加-编辑卡片信息")
     @RequestMapping(value = {"deleteCardInfo"}, method = {RequestMethod.POST})
@@ -158,4 +152,17 @@ public class CardController {
 
     //----------------------------园区卡片操作 end --------------------------
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "从卡池选择卡片绑定到个人", description = "从卡池选择卡片绑定到个人")
+    @RequestMapping(value = {"bindCardFromPool"}, method = {RequestMethod.POST})
+    public ResultContent bindCardFromPool(@RequestBody IDParam param) {
+        return cardInfoService.bindCardFromPool(param.getId(), null);
+    }
+
+    @Operation(summary = "从卡池选择卡片绑定到个人(未登录)", description = "从卡池选择卡片绑定到个人")
+    @RequestMapping(value = {"bindCardFromPoolNotLogged"}, method = {RequestMethod.POST})
+    public ResultContent bindCardFromPoolNotLogged(@RequestBody @Valid CardInfoPoolBind2UserParam param) {
+        return cardInfoService.bindCardFromPool(param.getPoolId(), param.getUserId());
+    }
+
 }

+ 6 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/CardInfoPoolController.java

@@ -39,14 +39,14 @@ public class CardInfoPoolController {
     CardInfoPoolService cardInfoPoolService;
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "保存卡片信息", description = "保存卡片信息 新增加编辑")
+    @Operation(summary = "保存卡池卡片信息", description = "保存卡池卡片信息 新增加编辑")
     @RequestMapping(value = {"saveCardInfoPool"}, method = {RequestMethod.POST})
     public ResultContent saveCardInfoPool(@RequestBody CardInfoPoolParam param) {
         return cardInfoPoolService.saveCardInfoPool(param);
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "卡片列表-分页查询", description = "卡片列表-分页查询")
+    @Operation(summary = "池卡卡片列表-分页查询", description = "池卡卡片列表-分页查询")
     @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
     public ResultContent<Page<CardInfoPoolModel>> page(
             @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
@@ -55,21 +55,21 @@ public class CardInfoPoolController {
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "卡片详情", description = "卡片详情")
+    @Operation(summary = "池卡卡片详情", description = "池卡卡片详情")
     @RequestMapping(value = {"getCardInfoPoolDetail"}, method = {RequestMethod.POST})
     public ResultContent<CardInfoPoolModel> getCardInfoPoolDetail(@RequestBody IDParam param) {
         return cardInfoPoolService.getCardInfoPoolDetail(param.getId());
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "恢复卡片", description = "恢复卡片")
+    @Operation(summary = "池卡恢复卡片", description = "池卡恢复卡片")
     @RequestMapping(value = {"restoreCardInfoPool"}, method = {RequestMethod.POST})
     public ResultContent<CardInfoPoolModel> restoreCardInfoPool(@RequestBody CardInfoPoolRestoreParam param) {
         return cardInfoPoolService.restoreCardInfoPool(param);
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "删除卡片", description = "删除卡片")
+    @Operation(summary = "池卡删除卡片", description = "池卡删除卡片")
     @RequestMapping(value = {"deleteCardInfoPool"}, method = {RequestMethod.POST})
     public ResultContent<CardInfoPoolModel> deleteCardInfoPool(@RequestBody IDParam param) {
         return cardInfoPoolService.deleteCardInfoPool(param.getId());
@@ -87,7 +87,7 @@ public class CardInfoPoolController {
         return cardInfoPoolService.importCardPool(request, response, file);
     }
 
-    @Operation(summary = "搜索卡片", description = "搜索卡片")
+    @Operation(summary = "池卡搜索卡片", description = "池卡搜索卡片")
     @RequestMapping(value = {"queryPoolCard"}, method = {RequestMethod.POST})
     public ResultContent<List<CardInfoPoolSimpleModel>> queryPoolCard(
             @RequestBody @Valid CardInfoPoolQueryParam param) {

+ 1 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/CardInfoPoolService.java

@@ -236,6 +236,7 @@ public class CardInfoPoolService extends SuperService {
         if (StringUtils.isEmpty(param.getCode())) {
             return ResultContent.buildSuccess(Lists.newArrayList());
         }
+        // 查询前十的卡片数据
         List<CardInfoPool> list = cardInfoPoolDao.findTop10BySchoolOidAndCodeLike(param.getSchoolOid(), param.getCode());
         List<CardInfoPoolSimpleModel> models = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(list)) {

+ 11 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/CardInfoServiceImpl.java

@@ -128,11 +128,21 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
      */
     @Transactional
     @Override
-    public ResultContent bindCardFromPool(String poolId) {
+    public ResultContent bindCardFromPool(String poolId, String userId) {
+        // 卡池数据
         CardInfoPool cardInfoPool = cardInfoPoolDao.findTopById(poolId);
         if (ObjectUtils.isEmpty(cardInfoPool)) {
             return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, poolId));
         }
+        if (StringUtils.isEmpty(userId)) {
+            userId = getCurrentUserId();
+        }
+        // 用户信息
+        UserAccount account = userCountDao.findTopByUserId(userId);
+        if (ObjectUtils.isEmpty(account)) {
+            return ResultContent.buildFail(String.format("", userId));
+        }
+
         String code = cardInfoPool.getCode();
         String projectOid = cardInfoPool.getProjectOid();
         CardInfo cardInfo = cardInfoDao.findByCode(code);
@@ -142,8 +152,6 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
         cardInfo = new CardInfo();
         initEntity(cardInfo);
 
-        String userId = getCurrentUserId();
-        UserAccount account = userCountDao.findTopByUserId(userId);
         cardInfo.setName(cardInfoPool.getName());
         cardInfo.setCode(cardInfoPool.getCode());
         cardInfo.setCardType(cardInfoPool.getCardType());