|
@@ -0,0 +1,55 @@
|
|
|
|
+package com.persagy.dmp.rwd.edit.service;
|
|
|
|
+
|
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
|
+import com.persagy.common.criteria.CriteriaUtils;
|
|
|
|
+import com.persagy.common.criteria.JacksonCriteria;
|
|
|
|
+import com.persagy.common.web.PagedResponse;
|
|
|
|
+import com.persagy.dmp.rwd.edit.entity.QRwdeditRefType;
|
|
|
|
+import com.persagy.dmp.rwd.edit.entity.RwdeditRefType;
|
|
|
|
+import com.persagy.dmp.rwd.edit.model.RwdeditRefTypeModel;
|
|
|
|
+import com.querydsl.core.types.dsl.BooleanExpression;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class RwdeditRefTypeService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CriteriaUtils criteriaUtils;
|
|
|
|
+
|
|
|
|
+ private List<BooleanExpression> parse(ObjectNode object) {
|
|
|
|
+ List<BooleanExpression> list = new LinkedList<>();
|
|
|
|
+ QRwdeditRefType qt = QRwdeditRefType.rwdeditRefType;
|
|
|
|
+ list.addAll(CriteriaUtils.parse(qt.refKey, object.get("refKey")));
|
|
|
|
+ list.addAll(CriteriaUtils.parse(qt.createUser, object.get("createUser")));
|
|
|
|
+ list.addAll(CriteriaUtils.parse(qt.updateUser, object.get("updateUser")));
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PagedResponse<RwdeditRefTypeModel> query(JacksonCriteria criteria) {
|
|
|
|
+ PagedResponse<RwdeditRefType> resp = criteriaUtils.query(QRwdeditRefType.rwdeditRefType, this::parse, criteria);
|
|
|
|
+ PagedResponse<RwdeditRefTypeModel> result = new PagedResponse<>();
|
|
|
|
+ result.setCount(resp.getCount());
|
|
|
|
+ List<RwdeditRefType> dataList = resp.getData();
|
|
|
|
+ Set<String> withColumns = criteria.getWithColumns();
|
|
|
|
+ if (dataList != null && dataList.size() > 0) {
|
|
|
|
+ List<RwdeditRefTypeModel> collect = dataList.stream().map(entity -> {
|
|
|
|
+ RwdeditRefTypeModel model = entity.toModel();
|
|
|
|
+ if (withColumns != null && withColumns.contains("infos")) {
|
|
|
|
+ model.setInfos(entity.getInfos());
|
|
|
|
+ }
|
|
|
|
+ return model;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ result.setData(collect);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|