|
@@ -0,0 +1,82 @@
|
|
|
+package com.fdkankan.fusion.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.fusion.entity.CaseTag;
|
|
|
+import com.fdkankan.fusion.entity.CaseTagPoint;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
+import com.fdkankan.fusion.mapper.ICaseTagPointMapper;
|
|
|
+import com.fdkankan.fusion.response.CaseTagPointVo;
|
|
|
+import com.fdkankan.fusion.response.GroupCount;
|
|
|
+import com.fdkankan.fusion.service.ICaseTagPointService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.fusion.service.ICaseTagService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-08-08
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CaseTagPointServiceImpl extends ServiceImpl<ICaseTagPointMapper, CaseTagPoint> implements ICaseTagPointService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ICaseTagService caseTagService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Integer, Long> getGroupByTagId() {
|
|
|
+ List<GroupCount> list = this.getBaseMapper().getGroupByTagId();
|
|
|
+ HashMap<Integer,Long> map = new HashMap<>();
|
|
|
+ list.forEach(entity -> map.put(entity.getId(),entity.getCount()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void place(CaseTagPoint caseTagPoint) {
|
|
|
+ if(caseTagPoint.getTagId() == null || StringUtils.isEmpty(caseTagPoint.getTagPoint())){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(caseTagPoint.getTagPointTitle())){
|
|
|
+ Long count = this.getCountByTagId(caseTagPoint.getTagId());
|
|
|
+ caseTagPoint.setTagPointTitle("位置"+count+1);
|
|
|
+ }
|
|
|
+ this.save(caseTagPoint);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long getCountByTagId(Integer tagId) {
|
|
|
+ LambdaQueryWrapper<CaseTagPoint> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CaseTagPoint::getTagId,tagId);
|
|
|
+ return this.count(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object allList(Integer tagId) {
|
|
|
+ CaseTag caseTag = caseTagService.getById(tagId);
|
|
|
+ if(caseTag == null){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<CaseTagPoint> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CaseTagPoint::getTagId,tagId);
|
|
|
+ List<CaseTagPoint> list = this.list(wrapper);
|
|
|
+ List<CaseTagPointVo> caseTagPointVoList = new ArrayList<>();
|
|
|
+ for (CaseTagPoint caseTagPoint : list) {
|
|
|
+ CaseTagPointVo caseTagPointVo = new CaseTagPointVo();
|
|
|
+ BeanUtils.copyProperties(caseTagPoint,caseTagPointVo);
|
|
|
+ BeanUtils.copyProperties(caseTag,caseTagPointVo);
|
|
|
+ caseTagPointVoList.add(caseTagPointVo);
|
|
|
+ }
|
|
|
+ return caseTagPointVoList;
|
|
|
+ }
|
|
|
+}
|