mybatis-plus一个文本框查询多个值模糊查询分页

controller

    @GetMapping("/getcustomerlist")
    public IPage<Customer> getCustomerList(@RequestParam(value = "pageNum" ) Integer pageNum,
                                               @RequestParam(value = "pageSize") Integer pageSize,String name) {
            QueryWrapper<Customer> queryWrapper = new QueryWrapper<Customer>();
            IPage<Customer> page = new Page<>();
            page.setCurrent(pageNum);
            page.setSize(pageSize);
             if(name.equals("")){
             }else{
                 queryWrapper.like("c_name",name).or().like("c_address",name);
             }
             page = customerDao.selectPage(page,queryWrapper);
             return page;
    }

分页插件

package com.yy.util;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableTransactionManagement//开启事务管理器
@Configuration//标识该类是配置类
@MapperScan("com.example.dao")//扫描mapper接口,目的是关联自定义的mapper接口
public class MyBatisPlusConfig {
    /**
     * 分页插件
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }
}

实体类

package com.yy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

@Data
public class Customer {
    @TableId(value = "c_id",type = IdType.AUTO)
    private Integer cId;
    @TableField("c_name")
    private String cName;
    @TableField("c_telephone")
    private String cTelephone;
    @TableField("c_address")
    private String cAddress;
    @TableField("c_remark")
    private String cRemark;


    @Override
    public String toString() {
        return "Customer [cId=" + cId + ", cName=" + cName + ", cTelephone=" + cTelephone + ", cAddress=" + cAddress + ", cRemark=" + cRemark +"]";
    }
}

Dao

package com.yy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yy.entity.Customer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; 

import java.util.List;

@Mapper
public interface CustomerDao  extends BaseMapper<Customer> {
}

service

package com.yy.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.yy.entity.Customer;

import java.util.List;

public interface CustomerService extends IService<Customer> {
}

serviceImpl

package com.yy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yy.dao.CustomerDao;
import com.yy.entity.Customer;
import com.yy.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List; 

@Service
public class CustomerServiceImpl  extends ServiceImpl<CustomerDao,Customer> implements CustomerService {
}

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值