Browse Source

客户查询

java8
qiezi 1 year ago
parent
commit
7fe8d39b58
  1. 31
      src/main/java/com/xujie/sys/modules/customer/controller/CustomerController.java
  2. 28
      src/main/java/com/xujie/sys/modules/customer/entity/Customer.java
  3. 19
      src/main/java/com/xujie/sys/modules/customer/mapper/CustomerMapper.java
  4. 14
      src/main/java/com/xujie/sys/modules/customer/service/CustomerService.java
  5. 29
      src/main/java/com/xujie/sys/modules/customer/service/impl/CustomerServiceImpl.java
  6. 56
      src/main/resources/mapper/customer/CustomerMapper.xml

31
src/main/java/com/xujie/sys/modules/customer/controller/CustomerController.java

@ -0,0 +1,31 @@
package com.xujie.sys.modules.customer.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xujie.sys.common.utils.R;
import com.xujie.sys.modules.customer.entity.Customer;
import com.xujie.sys.modules.customer.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
@PostMapping
public R queryCustomerList(@RequestBody Customer customer){
List<Customer> list = customerService.queryCustomerList(customer);
return R.ok().put("rows",list);
}
@PostMapping("/{no}/{size}")
public R queryCustomerListByPage(@RequestBody Customer customer,
@PathVariable Integer no,
@PathVariable Integer size){
IPage<Customer> page = customerService.queryCustomerListByPage(customer, no, size);
return R.ok().put("rows",page.getRecords()).put("total",page.getTotal());
}
}

28
src/main/java/com/xujie/sys/modules/customer/entity/Customer.java

@ -0,0 +1,28 @@
package com.xujie.sys.modules.customer.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@TableName("plm_customer_information")
@Data
public class Customer {
private String site;
private String customerNo;
private String customerDesc;
private String active;
private Date createDate;
private String createBy;
private Date updateDate;
private String updateBy;
}

19
src/main/java/com/xujie/sys/modules/customer/mapper/CustomerMapper.java

@ -0,0 +1,19 @@
package com.xujie.sys.modules.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xujie.sys.modules.customer.entity.Customer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {
List<Customer> queryCustomerList(Customer customer);
IPage<Customer> queryCustomerListByPage(@Param("page") Page<Customer> page, @Param("params") Customer customer);
}

14
src/main/java/com/xujie/sys/modules/customer/service/CustomerService.java

@ -0,0 +1,14 @@
package com.xujie.sys.modules.customer.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xujie.sys.modules.customer.entity.Customer;
import java.util.List;
public interface CustomerService extends IService<Customer> {
List<Customer> queryCustomerList(Customer customer);
IPage<Customer> queryCustomerListByPage(Customer customer, Integer no, Integer size);
}

29
src/main/java/com/xujie/sys/modules/customer/service/impl/CustomerServiceImpl.java

@ -0,0 +1,29 @@
package com.xujie.sys.modules.customer.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xujie.sys.modules.customer.entity.Customer;
import com.xujie.sys.modules.customer.mapper.CustomerMapper;
import com.xujie.sys.modules.customer.service.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
@Override
public List<Customer> queryCustomerList(Customer customer) {
return baseMapper.queryCustomerList(customer);
}
@Override
public IPage<Customer> queryCustomerListByPage(Customer customer, Integer no, Integer size) {
Page<Customer> page = new Page<>(no, size);
return baseMapper.queryCustomerListByPage(page,customer);
}
}

56
src/main/resources/mapper/customer/CustomerMapper.xml

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xujie.sys.modules.customer.mapper.CustomerMapper">
<select id="queryCustomerList" resultType="com.xujie.sys.modules.customer.entity.Customer">
select site,
customer_no,
customer_desc,
active,
create_date,
create_by,
update_date,
update_by
from plm_customer_information
<where>
<if test="createBy != null and createBy != ''">
and site in (select site from eam_access_site where username = #{createBy})
</if>
<if test="customerNo != null and customerNo != ''">
and customer_no = #{customerNo}
</if>
<if test="customerDesc != null and customerDesc != ''">
and customer_desc like #{customerDesc}
</if>
<if test="active != null and active != ''">
and active = #{active}
</if>
</where>
</select>
<select id="queryCustomerListByPage" resultType="com.xujie.sys.modules.customer.entity.Customer">
select site,
customer_no,
customer_desc,
active,
create_date,
create_by,
update_date,
update_by
from plm_customer_information
<where>
<if test="params.createBy != null and params.createBy != ''">
and site in (select site from eam_access_site where username = #{params.createBy})
</if>
<if test="params.customerNo != null and params.customerNo != ''">
and customer_no = #{params.customerNo}
</if>
<if test="params.customerDesc != null and params.customerDesc != ''">
and customer_desc like #{params.customerDesc}
</if>
<if test="params.active != null and params.active != ''">
and active = #{params.active}
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save