lxw
2022-08-19 47e56bf8919dc916b34744e7bb5223b20445378d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class ProductService {
    @Autowired(required = false)
    private ProductMapper mapper;
 
    //查询出所有的产品信息(分页加模糊查询<产品的编码,型号,名字,定制表编号>
    public Response getAllProduct(String parentCode, String parentName, String parentModel, String customCode, int pageCurr, int pageSize) {
        PageHelper.startPage(pageCurr,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(parentCode!=null&&!parentCode.isEmpty()){
            wrapper.like("parent_code",parentCode);
        }
        if(parentName!=null&&!parentName.isEmpty()){
            wrapper.like("parent_name",parentName);
        }
        if(parentModel!=null&&!parentModel.isEmpty()){
            wrapper.like("parent_model",parentModel);
        }
        if(customCode!=null&&!customCode.isEmpty()){
            wrapper.like("custom_code",customCode);
        }
        wrapper.orderByAsc("id");
        List list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list.size()>0?true:false,pageInfo,"返回产品信息");
    }
 
}