|
@@ -0,0 +1,74 @@
|
|
|
+package com.fdkankan.manage.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.common.response.PageInfo;
|
|
|
+import com.fdkankan.manage.entity.Case;
|
|
|
+import com.fdkankan.manage.entity.CaseIcon;
|
|
|
+import com.fdkankan.manage.mapper.ICaseMapper;
|
|
|
+import com.fdkankan.manage.service.ICaseIconService;
|
|
|
+import com.fdkankan.manage.service.ICaseService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.vo.request.CaseParam;
|
|
|
+import com.fdkankan.manage.vo.response.CaseVo;
|
|
|
+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-10-25
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CaseServiceImpl extends ServiceImpl<ICaseMapper, Case> implements ICaseService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ICaseIconService caseIconService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object pageList(CaseParam param) {
|
|
|
+ LambdaQueryWrapper<Case> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(param.getTypeId() != null){
|
|
|
+ wrapper.eq(Case::getTypeId,param.getTypeId());
|
|
|
+ }
|
|
|
+ wrapper.orderByAsc(Case::getSort);
|
|
|
+ wrapper.orderByDesc(Case::getCreateTime);
|
|
|
+ Page<Case> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
+ List<CaseIcon> list = caseIconService.list();
|
|
|
+ HashMap<Integer,CaseIcon> map = new HashMap<>();
|
|
|
+ for (CaseIcon icon : list) {
|
|
|
+ map.put(icon.getId(),icon);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CaseVo> caseVos = new ArrayList<>();
|
|
|
+ for (Case record : page.getRecords()) {
|
|
|
+ CaseVo vo = new CaseVo();
|
|
|
+ BeanUtils.copyProperties(record,vo);
|
|
|
+ String iconIds = record.getIconIds();
|
|
|
+ JSONArray jsonArray = JSONObject.parseArray(iconIds);
|
|
|
+ List<CaseIcon> iconList = new ArrayList<>();
|
|
|
+ for (Object o : jsonArray) {
|
|
|
+ Integer id = (Integer) o;
|
|
|
+ iconList.add(map.get(id));
|
|
|
+ }
|
|
|
+ vo.setIconList(iconList);
|
|
|
+ caseVos.add(vo);
|
|
|
+ }
|
|
|
+ Page<CaseVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
|
|
|
+ voPage.setTotal(page.getTotal());
|
|
|
+ voPage.setRecords(caseVos);
|
|
|
+ return PageInfo.PageInfo(voPage);
|
|
|
+ }
|
|
|
+}
|