浏览代码

市政工程|工业工程 根据工程类型查询列表

刘浩男 1 年之前
父节点
当前提交
7f20e8039f

+ 2 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zdsz/ZEngineeringIndustryController.java

@@ -114,13 +114,12 @@ public class ZEngineeringIndustryController extends BaseController {
         return R.ok(iZEngineeringIndustryService.query(id));
     }
 
-    /***
+    /**
      * 工业工程|市政工程根据工程类型查询工程名称
      */
     @GetMapping("/queryNameByType")
     @SaCheckPermission("zdsz:engineeringIndustry:type")
-    public TableDataInfo<ZEngineeringIndustryVo> queryNameByType(ZEngineeringIndustryBo bo, PageQuery pageQuery,String type) {
-        bo.setType(type);
+    public TableDataInfo queryNameByType(ZEngineeringIndustryBo bo, PageQuery pageQuery) {
         return iZEngineeringIndustryService.queryNameByType(bo, pageQuery);
     }
 }

+ 0 - 1
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/IZEngineeringIndustryService.java

@@ -3,7 +3,6 @@ package com.ruoyi.zdsz.service;
 import com.ruoyi.common.core.domain.PageQuery;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.zdsz.domain.bo.ZEngineeringIndustryBo;
-import com.ruoyi.zdsz.domain.bo.ZEngineeringReviewBo;
 import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryVo;
 
 import java.util.Collection;

+ 23 - 8
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/impl/ZEngineeringIndustryServiceImpl.java

@@ -2,6 +2,8 @@ package com.ruoyi.zdsz.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.PageQuery;
@@ -241,16 +243,29 @@ public class ZEngineeringIndustryServiceImpl implements IZEngineeringIndustrySer
 
     @Override
     public TableDataInfo<ZEngineeringIndustryVo> queryNameByType(ZEngineeringIndustryBo bo, PageQuery pageQuery) {
-        LambdaQueryWrapper<ZEngineeringIndustry> lqw = buildListByType(bo);
-        Page<ZEngineeringIndustryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
-        return TableDataInfo.build(result);
+        QueryWrapper<ZEngineeringIndustry> zEngineeringIndustryQueryWrapper = buildListByType(bo);
+
+        IPage<ZEngineeringIndustry> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
+        IPage<ZEngineeringIndustry> result = baseMapper.selectPage(page, zEngineeringIndustryQueryWrapper);
+
+        List<ZEngineeringIndustryVo> voList = result.getRecords().stream()
+            .map(record -> {
+                ZEngineeringIndustryVo vo = new ZEngineeringIndustryVo();
+                vo.setId(record.getId());
+                vo.setEnginName(record.getEnginName());
+                return vo;
+            })
+            .collect(Collectors.toList());
+
+        return new TableDataInfo<>(voList, (int)result.getTotal());
     }
 
-    private LambdaQueryWrapper<ZEngineeringIndustry> buildListByType(ZEngineeringIndustryBo bo) {
-        LambdaQueryWrapper<ZEngineeringIndustry> lqw = Wrappers.lambdaQuery();
-        lqw.eq(StringUtils.isNotBlank(bo.getEnginType()), ZEngineeringIndustry::getEnginType, bo.getEnginType());
-        lqw.eq(StringUtils.isNotBlank(bo.getType()), ZEngineeringIndustry::getType, bo.getType());
-        return lqw;
+    private QueryWrapper<ZEngineeringIndustry> buildListByType(ZEngineeringIndustryBo bo) {
+        QueryWrapper<ZEngineeringIndustry> queryWrapper = new QueryWrapper<ZEngineeringIndustry>()
+            .select("id", "engin_name")
+            .eq("engin_type", bo.getEnginType())
+            .eq("type", bo.getType());
+        return queryWrapper;
     }