|
|
@@ -11,13 +11,13 @@ import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.assess.program.commonIssue.domain.CommonIssue;
|
|
|
import com.jeeplus.assess.program.commonIssue.dto.CommonIssueDto;
|
|
|
import com.jeeplus.assess.program.commonIssue.mapper.CommonIssueMapper;
|
|
|
-import com.jeeplus.assess.program.commonIssue.service.mapstruct.CommonIssueWrapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -37,7 +37,8 @@ public class CommonIssueService extends ServiceImpl<CommonIssueMapper, CommonIss
|
|
|
}
|
|
|
|
|
|
public ResponseEntity save(CommonIssueDto dto) {
|
|
|
- CommonIssue entity = CommonIssueWrapper.INSTANCE.toEntity(dto);
|
|
|
+ CommonIssue entity = new CommonIssue();
|
|
|
+ BeanUtils.copyProperties(dto, entity);
|
|
|
this.saveOrUpdate(entity);
|
|
|
return ResponseEntity.ok("保存成功");
|
|
|
}
|
|
|
@@ -63,4 +64,63 @@ public class CommonIssueService extends ServiceImpl<CommonIssueMapper, CommonIss
|
|
|
wrapper.orderByAsc("category", "sort_order");
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取树结构数据(含各节点计数)
|
|
|
+ */
|
|
|
+ public List<Map<String, Object>> getTreeData() {
|
|
|
+ List<Map<String, Object>> tree = new ArrayList<>();
|
|
|
+ // 全部节点
|
|
|
+ long totalCount = this.count(new QueryWrapper<CommonIssue>().eq("del_flag", 0));
|
|
|
+ Map<String, Object> allNode = new LinkedHashMap<>();
|
|
|
+ allNode.put("id", "all");
|
|
|
+ allNode.put("label", "全部");
|
|
|
+ allNode.put("count", totalCount);
|
|
|
+ tree.add(allNode);
|
|
|
+ // 一级/二级/三级
|
|
|
+ String[] levels = {"1", "2", "3"};
|
|
|
+ String[] levelNames = {"一级校审", "二级校审", "三级校审"};
|
|
|
+ for (int i = 0; i < levels.length; i++) {
|
|
|
+ long count = this.count(new QueryWrapper<CommonIssue>().eq("del_flag", 0).eq("audit_level", levels[i]));
|
|
|
+ Map<String, Object> node = new LinkedHashMap<>();
|
|
|
+ node.put("id", levels[i]);
|
|
|
+ node.put("label", levelNames[i]);
|
|
|
+ node.put("count", count);
|
|
|
+ tree.add(node);
|
|
|
+ }
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有分类列表(去重)
|
|
|
+ */
|
|
|
+ public List<String> getCategoryList() {
|
|
|
+ List<CommonIssue> list = this.list(new QueryWrapper<CommonIssue>()
|
|
|
+ .eq("del_flag", 0)
|
|
|
+ .isNotNull("category")
|
|
|
+ .ne("category", "")
|
|
|
+ .select("category")
|
|
|
+ .groupBy("category")
|
|
|
+ .orderByAsc("category"));
|
|
|
+ return list.stream().map(CommonIssue::getCategory).distinct().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量更新状态
|
|
|
+ */
|
|
|
+ public ResponseEntity batchUpdateStatus(String ids, String status) {
|
|
|
+ if (StrUtil.isBlank(ids) || StrUtil.isBlank(status)) {
|
|
|
+ return ResponseEntity.ok("参数错误");
|
|
|
+ }
|
|
|
+ String[] idArray = ids.split(",");
|
|
|
+ List<CommonIssue> updateList = new ArrayList<>();
|
|
|
+ for (String id : idArray) {
|
|
|
+ CommonIssue entity = new CommonIssue();
|
|
|
+ entity.setId(id);
|
|
|
+ entity.setStatus(status);
|
|
|
+ updateList.add(entity);
|
|
|
+ }
|
|
|
+ this.updateBatchById(updateList);
|
|
|
+ return ResponseEntity.ok("操作成功");
|
|
|
+ }
|
|
|
}
|