Browse Source

优化footBar方法

dev_shibei_match
jianjun 4 years ago
parent
commit
5a2758b3a2
  1. 20
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java

20
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java

@ -17,34 +17,35 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerFootBarDTO; import com.epmet.dto.CustomerFootBarDTO;
import com.epmet.dto.form.CustomerFootBarFormDTO; import com.epmet.dto.form.CustomerFootBarFormDTO;
import com.epmet.dto.result.CustomerFootBarResultDTO; import com.epmet.dto.result.CustomerFootBarResultDTO;
import com.epmet.entity.CustomerFootBarEntity; import com.epmet.entity.CustomerFootBarEntity;
import com.epmet.excel.CustomerFootBarExcel; import com.epmet.excel.CustomerFootBarExcel;
import com.epmet.service.CustomerFootBarService; import com.epmet.service.CustomerFootBarService;
import com.epmet.service.impl.CustomerFunctionDetailServiceImpl;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
@ -127,12 +128,13 @@ public class CustomerFootBarController {
// 查询db // 查询db
List<CustomerFootBarEntity> footbars = customerFootBarService.listCustomerFootBars(customerId, appType); List<CustomerFootBarEntity> footbars = customerFootBarService.listCustomerFootBars(customerId, appType);
List<CustomerFootBarDTO> barDTOS = new LinkedList<>(); List<CustomerFootBarDTO> barDTOS = new LinkedList<>();
footbars.forEach(barEntity -> {
CustomerFootBarEntity defaultFootBarEntity = customerFootBarService.getByAppTypeAndBarKeyOfCustomer("default", barEntity.getAppType(), barEntity.getBarKey());
CustomerFootBarDTO barDTO = new CustomerFootBarDTO(); List<CustomerFootBarEntity> defaultFootBarList = customerFootBarService.listCustomerFootBars("default", appType);
BeanUtils.copyProperties(barEntity, barDTO); Map<String, String> defaultBarNameMaps = defaultFootBarList.stream().collect(Collectors.toMap(CustomerFootBarEntity::getBarKey, CustomerFootBarEntity::getBarName));
barDTO.setDefaultBarName(defaultFootBarEntity.getBarName()); footbars.forEach(barEntity -> {
String defaultName = defaultBarNameMaps.getOrDefault(barEntity.getBarKey(), StrConstant.EPMETY_STR);
CustomerFootBarDTO barDTO = ConvertUtils.sourceToTarget(barEntity, CustomerFootBarDTO.class);
barDTO.setDefaultBarName(defaultName);
barDTOS.add(barDTO); barDTOS.add(barDTO);
}); });
@ -253,4 +255,4 @@ public class CustomerFootBarController {
return new Result(); return new Result();
} }
} }

Loading…
Cancel
Save