Browse Source

积分列表调整为树

dev
Jackwang 3 years ago
parent
commit
fb2c04a06d
  1. 27
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/List4ApplyResultDTO.java
  2. 3
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java
  3. 3
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java
  4. 3
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java
  5. 40
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java
  6. 10
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml

27
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/List4ApplyResultDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-06-17 10:50
**/
@Data
public class List4ApplyResultDTO implements Serializable {
private String id;
private String name;
private String pid;
private Integer pointValue;
private List<List4ApplyResultDTO> children = new ArrayList<>();
}

3
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java

@ -17,6 +17,7 @@ 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.excel.PointAdditiveRuleExcel;
import com.epmet.service.PointAdditiveRuleService;
import org.springframework.beans.factory.annotation.Autowired;
@ -157,7 +158,7 @@ public class PointAdditiveRuleController {
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
@PostMapping("list4apply")
public Result<List<PointAdditiveRuleDTO>> list4apply(@LoginUser TokenDto tokenDto,@RequestBody List4applyFormDTO dto){
public Result<List<List4ApplyResultDTO>> list4apply(@LoginUser TokenDto tokenDto, @RequestBody List4applyFormDTO dto){
ValidatorUtils.validateEntity(dto);
dto.setCustomerId(tokenDto.getCustomerId());
return pointAdditiveRuleService.list4apply(dto);

3
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java

@ -6,6 +6,7 @@ import com.epmet.dto.PointAdditiveRuleDTO;
import com.epmet.dto.form.List4applyFormDTO;
import com.epmet.dto.form.List4treeFormDTO;
import com.epmet.dto.form.SubmitRewardFormDTO;
import com.epmet.dto.result.List4ApplyResultDTO;
import com.epmet.entity.PointAdditiveRuleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -46,7 +47,7 @@ public interface PointAdditiveRuleDao extends BaseDao<PointAdditiveRuleEntity> {
* @params [dto]
* @return java.util.List<com.epmet.dto.PointAdditiveRuleDTO>
*/
List<PointAdditiveRuleDTO> selectList4apply(List4applyFormDTO dto);
List<List4ApplyResultDTO> selectList4apply(List4applyFormDTO dto);
/**
* @describe: 查询积分类别规则列表

3
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java

@ -9,6 +9,7 @@ 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 java.util.List;
@ -125,7 +126,7 @@ public interface PointAdditiveRuleService extends BaseService<PointAdditiveRuleE
* @params [categoryId]
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.PointAdditiveRuleDTO>>
*/
Result<List<PointAdditiveRuleDTO>> list4apply(List4applyFormDTO dto);
Result<List<List4ApplyResultDTO>> list4apply(List4applyFormDTO dto);
/**
* @describe: 查询积分类别规则列表

40
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java

@ -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

10
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml

@ -43,17 +43,17 @@
and c.DEL_FLAG='0'
and c.id = #{categoryId}
</select>
<select id="selectList4apply" resultType="com.epmet.dto.PointAdditiveRuleDTO">
select id,
RULE_NAME,
POINT_VALUE
<select id="selectList4apply" resultType="com.epmet.dto.result.List4ApplyResultDTO">
select id,
if(CATEGORY_NAME is null,RULE_NAME,CATEGORY_NAME) as name,
pid,
POINT_VALUE
from point_additive_rule
where DEL_FLAG='0'
and CATEGORY_CODE=#{categoryCode}
<if test="applyFlag != null and applyFlag != ''">
and APPLY_FLAG= #{applyFlag}
</if>
and TYPE=#{type}
and CUSTOMER_ID=#{customerId}
order by UPDATED_TIME desc
</select>

Loading…
Cancel
Save