瀏覽代碼

机构类型

TRX 1 年之前
父節點
當前提交
6719f95e43

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

@@ -23,10 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.web.PageableDefault;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -119,4 +116,11 @@ public class CardController {
         return cardInfoService.getCardDetail(param.getId());
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "code查询卡片详情", description = "code查询卡片详情")
+    @RequestMapping(value = {"getCardDetailByCode"}, method = {RequestMethod.POST})
+    public ResultContent<CardInfoModel> getCardDetailByCode(@RequestParam(name = "code") String code) {
+        return cardInfoService.getCardDetailByCode(code);
+    }
+
 }

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

@@ -87,6 +87,9 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
             }
         }
         BeanUtils.copyProperties(param, cardInfo, "cardState");
+        if(cardInfo.getCardState() == null) {
+            cardInfo.setCardState(CardState.Enable);
+        }
         if (StringUtils.isNotEmpty(oid)) {
             Organization organization = organizationDao.findTopByOid(oid);
             cardInfo.setOrganization(organization);
@@ -334,6 +337,17 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
         return ResultContent.buildSuccess(model);
     }
 
+    @Override
+    public ResultContent<CardInfoModel> getCardDetailByCode(String code) {
+        Assert.hasText(code, "code不能为空");
+        CardInfo cardInfo = cardInfoDao.findByCode(code);
+        if (ObjectUtils.isEmpty(cardInfo)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, code));
+        }
+        CardInfoModel model = toModel(cardInfo);
+        return ResultContent.buildSuccess(model);
+    }
+
     public CardInfoModel toModel(CardInfo entity) {
         CardInfoModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {