MyBatisPlus实现车辆故障码列表查询分页操作
parent
f0eca2995b
commit
0d84a6d188
|
@ -0,0 +1,26 @@
|
|||
package com.february.fault.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
* @description:
|
||||
* @author: Mr.Wang
|
||||
* @create: 2023-11-21 19:53
|
||||
**/
|
||||
@EnableTransactionManagement
|
||||
@Configuration
|
||||
@MapperScan("com.february.fault.mapper.FaultCodeMapper")
|
||||
public class MybatisPlusConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
||||
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return mybatisPlusInterceptor;
|
||||
}
|
||||
}
|
|
@ -12,9 +12,7 @@ import com.february.fault.domain.FaultCode;
|
|||
import com.february.fault.service.FaultCodeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
@ -33,12 +31,13 @@ public class FaultCodeController {
|
|||
|
||||
/**
|
||||
* 查询车辆故障表信息列表
|
||||
* @param faultCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<List<FaultCode>> faultCodeList(){
|
||||
@PostMapping("/list")
|
||||
public Result<List<FaultCode>> faultCodeList(@RequestBody FaultCode faultCode){
|
||||
log.info("功能名称:车辆故障码列表,请求路径:{},请求方式:{}",request.getRequestURI(),request.getMethod());
|
||||
Result<List<FaultCode>> result=faultCodeService.faultCodeList();
|
||||
Result<List<FaultCode>> result=faultCodeService.faultCodeList(faultCode);
|
||||
log.info("响应结果:{}",result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -14,5 +14,5 @@ import java.util.List;
|
|||
**/
|
||||
public interface FaultCodeService extends IService<FaultCode> {
|
||||
|
||||
Result<List<FaultCode>> faultCodeList();
|
||||
Result<List<FaultCode>> faultCodeList(FaultCode faultCode);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.february.fault.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.february.common.core.domain.Result;
|
||||
import com.february.fault.domain.FaultCode;
|
||||
|
@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
|
@ -25,9 +27,17 @@ public class FaultCodeServiceImpl extends ServiceImpl<FaultCodeMapper, FaultCode
|
|||
@Autowired
|
||||
private FaultCodeMapper faultCodeMapper;
|
||||
@Override
|
||||
public Result<List<FaultCode>> faultCodeList() {
|
||||
public Result<List<FaultCode>> faultCodeList(FaultCode faultCode) {
|
||||
QueryWrapper<FaultCode> faultCodeQueryWrapper = new QueryWrapper<>();
|
||||
List<FaultCode> faultCodes = faultCodeMapper.selectList(faultCodeQueryWrapper);
|
||||
return Result.success(faultCodes);
|
||||
if(!Objects.equals(faultCode.getFaultBh(), "") && faultCode.getFaultBh()!=null){
|
||||
faultCodeQueryWrapper.eq("fault_bh",faultCode.getFaultBh());
|
||||
}
|
||||
if(!Objects.equals(faultCode.getFaultSeat(), "") && faultCode.getFaultSeat()!=null){
|
||||
faultCodeQueryWrapper.eq("fault_seat",faultCode.getFaultSeat());
|
||||
}
|
||||
Page<FaultCode> faultCodePage = new Page<>(1,2);
|
||||
List<FaultCode> records = faultCodeMapper.selectPage(faultCodePage, faultCodeQueryWrapper).getRecords();
|
||||
// List<FaultCode> faultCodes = faultCodeMapper.selectList(faultCodeQueryWrapper);
|
||||
return Result.success(records);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue