|
@@ -1,20 +1,38 @@
|
|
|
package net.mingsoft.tf.www;
|
|
package net.mingsoft.tf.www;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import net.mingsoft.base.entity.ResultData;
|
|
import net.mingsoft.base.entity.ResultData;
|
|
|
|
|
+import net.mingsoft.basic.bean.EUListBean;
|
|
|
|
|
+import net.mingsoft.basic.util.BasicUtil;
|
|
|
|
|
+import net.mingsoft.tf.biz.IEnterpriseBiz;
|
|
|
|
|
+import net.mingsoft.tf.biz.IEnterpriseProductsBiz;
|
|
|
|
|
+import net.mingsoft.tf.entity.EnterpriseEntity;
|
|
|
import net.mingsoft.tf.entity.EnterpriseProductsEntity;
|
|
import net.mingsoft.tf.entity.EnterpriseProductsEntity;
|
|
|
|
|
+import net.mingsoft.tf.www.dto.EnterpriseProductsListResponse;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
@Controller()
|
|
@Controller()
|
|
|
@RequestMapping("/tf/enterpriseProducts")
|
|
@RequestMapping("/tf/enterpriseProducts")
|
|
|
public class EnterpriseProductsAction {
|
|
public class EnterpriseProductsAction {
|
|
|
@Resource
|
|
@Resource
|
|
|
private net.mingsoft.tf.action.EnterpriseProductsAction action;
|
|
private net.mingsoft.tf.action.EnterpriseProductsAction action;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IEnterpriseProductsBiz enterpriseProductsBiz;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IEnterpriseBiz enterpriseBiz;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询企业产品列表
|
|
* 查询企业产品列表
|
|
@@ -36,8 +54,25 @@ public class EnterpriseProductsAction {
|
|
|
@PostMapping(value = "/list")
|
|
@PostMapping(value = "/list")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public ResultData list(@RequestBody EnterpriseProductsEntity enterpriseProducts) {
|
|
public ResultData list(@RequestBody EnterpriseProductsEntity enterpriseProducts) {
|
|
|
- // TODO 要有企业名和logo
|
|
|
|
|
- return action.list(enterpriseProducts);
|
|
|
|
|
|
|
+ BasicUtil.startPage();
|
|
|
|
|
+ LambdaQueryWrapper<EnterpriseProductsEntity> wrapper = new LambdaQueryWrapper<>(enterpriseProducts).orderByDesc(EnterpriseProductsEntity::getCreateDate);
|
|
|
|
|
+ List<EnterpriseProductsEntity> enterpriseProductsList = enterpriseProductsBiz.list(wrapper);
|
|
|
|
|
+ // 2. 批量查询关联企业信息
|
|
|
|
|
+ Map<String, EnterpriseEntity> enterpriseMap = enterpriseBiz.listByIds(
|
|
|
|
|
+ enterpriseProductsList.stream().map(EnterpriseProductsEntity::getProductEnterpriseId).collect(Collectors.toList())
|
|
|
|
|
+ ).stream().collect(Collectors.toMap(EnterpriseEntity::getId, Function.identity()));
|
|
|
|
|
+ // 3. 组合数据到Response对象
|
|
|
|
|
+ List<EnterpriseProductsListResponse> responses = enterpriseProductsList.stream().map(p -> {
|
|
|
|
|
+ EnterpriseProductsListResponse res = new EnterpriseProductsListResponse();
|
|
|
|
|
+ BeanUtil.copyProperties(p, res);
|
|
|
|
|
+ EnterpriseEntity e = enterpriseMap.get(p.getProductEnterpriseId());
|
|
|
|
|
+ if (e != null) {
|
|
|
|
|
+ res.setEnterpriseName(e.getEnterpriseName());
|
|
|
|
|
+ res.setEnterpriseLogo(e.getEnterpriseLogo());
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ return ResultData.build().success(new EUListBean(responses, (int) BasicUtil.endPage(enterpriseProductsList).getTotal()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|