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

Loading…
Cancel
Save