|
|
@@ -0,0 +1,94 @@
|
|
|
+package com.zhongshu.card.server.core.service.school;
|
|
|
+
|
|
|
+import com.zhongshu.card.client.model.school.CardInfoModel;
|
|
|
+import com.zhongshu.card.client.model.school.CardInfoParam;
|
|
|
+import com.zhongshu.card.client.ret.ResultContent;
|
|
|
+import com.zhongshu.card.client.service.school.CardInfoService;
|
|
|
+import com.zhongshu.card.server.core.dao.CardInfoDao;
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
+import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
|
+import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 卡片管理Service
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/6/13
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class CardInfoServiceImpl extends SuperService implements CardInfoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CardInfoDao cardInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrganizationDao organizationDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserCountDao userCountDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加或修改卡片信息
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent addCardInfo(CardInfoParam param) {
|
|
|
+ initDefaultUserAndOid(param);
|
|
|
+ CardInfo cardInfo = null;
|
|
|
+ if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
+ cardInfo = cardInfoDao.findTopById(param.getId());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ cardInfo = new CardInfo();
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, cardInfo);
|
|
|
+ Organization organization = organizationDao.findTopByOid(param.getOid());
|
|
|
+ UserAccount account = userCountDao.findTopByUserId(param.getUserId());
|
|
|
+ cardInfo.setUserAccount(account);
|
|
|
+ cardInfo.setOrganization(organization);
|
|
|
+ cardInfoDao.save(cardInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultContent<List<CardInfoModel>> getCurrentUserOrgAll() {
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ String oid = getCurrentOid();
|
|
|
+ return ResultContent.buildSuccess(getUserOrgAllCard(userId, oid));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CardInfoModel> getUserOrgAllCard(String userId, String oid) {
|
|
|
+ List<CardInfoModel> models = new ArrayList<>();
|
|
|
+ List<CardInfo> list = cardInfoDao.findTopByUserIdAndOid(userId, oid);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ models = list.stream().map(this::toModel).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return models;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CardInfoModel toModel(CardInfo entity) {
|
|
|
+ CardInfoModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new CardInfoModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+}
|