|
|
@ -18,17 +18,17 @@ import com.epmet.dto.form.AddcategoryFormDTO; |
|
|
|
import com.epmet.dto.form.AddruleFormDTO; |
|
|
|
import com.epmet.dto.form.List4applyFormDTO; |
|
|
|
import com.epmet.dto.form.List4treeFormDTO; |
|
|
|
import com.epmet.dto.result.List4ApplyResultDTO; |
|
|
|
import com.epmet.entity.PointAdditiveRuleEntity; |
|
|
|
import com.epmet.redis.PointAdditiveRuleRedis; |
|
|
|
import com.epmet.service.PointAdditiveRuleService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 附加积分规则 |
|
|
@ -164,10 +164,36 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<PointAdditiveRuleDTO>> list4apply(List4applyFormDTO dto) { |
|
|
|
dto.setType(PointAddRuleEnum.RULE_TYPE.getCode()); |
|
|
|
List<PointAdditiveRuleDTO> result = baseDao.selectList4apply(dto); |
|
|
|
return new Result<List<PointAdditiveRuleDTO>>().ok(result); |
|
|
|
public Result<List<List4ApplyResultDTO>> list4apply(List4applyFormDTO dto) { |
|
|
|
List<List4ApplyResultDTO> list = baseDao.selectList4apply(dto); |
|
|
|
List<List4ApplyResultDTO> result = build(list); |
|
|
|
result.removeIf(category ->CollectionUtils.isEmpty(category.getChildren())); |
|
|
|
return new Result<List<List4ApplyResultDTO>>().ok(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构建树节点 |
|
|
|
*/ |
|
|
|
public static List<List4ApplyResultDTO> build(List<List4ApplyResultDTO> treeNodes) { |
|
|
|
List<List4ApplyResultDTO> result = new ArrayList<>(); |
|
|
|
|
|
|
|
//list转map
|
|
|
|
Map<String, List4ApplyResultDTO> nodeMap = new LinkedHashMap<>(treeNodes.size()); |
|
|
|
for(List4ApplyResultDTO treeNode : treeNodes){ |
|
|
|
nodeMap.put(treeNode.getId(), treeNode); |
|
|
|
} |
|
|
|
|
|
|
|
for(List4ApplyResultDTO node : nodeMap.values()) { |
|
|
|
List4ApplyResultDTO parent = nodeMap.get(node.getPid()); |
|
|
|
if(parent != null && !(node.getId().equals(parent.getId()))){ |
|
|
|
parent.getChildren().add(node); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
result.add(node); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|