dingxin 6 yıl önce
ebeveyn
işleme
15b5d927b5

+ 2
- 6
whole-estate/src/main/java/com/example/wholeestate/controller/CustomerController.java Dosyayı Görüntüle

@@ -31,14 +31,10 @@ public class CustomerController extends BaseController {
31 31
 
32 32
     @ApiOperation(value = "会员列表", notes = "会员列表")
33 33
     @ApiImplicitParams({
34
-            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "pageNum:分页第几页" +
35
-                    "pageSize:每页长度,phone:手机号,name:姓名"
36
-
37
-            )
38
-
34
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "pageNum:分页第几页,pageSize:每页长度,phone:手机号,name:姓名,beginDate:开始时间,endDate:结束时间")
39 35
     })
40 36
 //    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
41
-    @RequestMapping(value = "/customerList", method = RequestMethod.GET)
37
+    @RequestMapping(value = "/customerList", method = RequestMethod.POST)
42 38
     public ResponseBean buildingList(@RequestBody String parameter, HttpSession session){
43 39
         ResponseBean  responseBean = iCustomerService.customerList(parameter);
44 40
         return responseBean;

+ 3
- 1
whole-estate/src/main/java/com/example/wholeestate/dao/CustomerMapper.java Dosyayı Görüntüle

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.example.wholeestate.model.Customer;
7 7
 import org.apache.ibatis.annotations.Param;
8 8
 
9
+import java.util.Date;
10
+
9 11
 /**
10 12
  * <p>
11 13
  *  Mapper 接口
@@ -21,5 +23,5 @@ public interface CustomerMapper extends BaseMapper<Customer> {
21 23
      * @param page
22 24
      * @return
23 25
      */
24
-    IPage<Customer> customerList(Page<Customer> page, @Param("Name") String name,@Param("phone")String phone);
26
+    IPage<Customer> customerList(Page<Customer> page, @Param("Name") String name, @Param("phone")String phone, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
25 27
 }

+ 4
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/CustomerServiceImpl.java Dosyayı Görüntüle

@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
17 17
 import org.springframework.stereotype.Service;
18 18
 
19 19
 import java.time.LocalDateTime;
20
+import java.util.Date;
20 21
 import java.util.HashMap;
21 22
 import java.util.List;
22 23
 
@@ -40,6 +41,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
40 41
     public ResponseBean customerList(String parameter) {
41 42
         ResponseBean response= new ResponseBean();
42 43
         JSONObject object= JSONObject.parseObject(parameter);
44
+        Date beginDate = object.getDate("beginDate");
45
+        Date endDate = object.getDate("endDate");
43 46
         String phone = object.getString("phone");
44 47
         String name = object.getString("name");
45 48
         Integer pageNum = object.getInteger("pageNum");
@@ -48,7 +51,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
48 51
         Page<Customer> page = new Page<>();
49 52
         page.setSize(pageSize == null ? 10 : pageSize);
50 53
         page.setCurrent(pageNum == null ? 1 : pageNum);
51
-        IPage<Customer> customer= customerMapper.customerList(page,name,phone);
54
+        IPage<Customer> customer= customerMapper.customerList(page,name,phone,beginDate,endDate);
52 55
         List<Customer> customerList=customer.getRecords();
53 56
 
54 57
         HashMap hashMap= new HashMap<>();

+ 6
- 3
whole-estate/src/main/resources/mapper/CustomerMapper.xml Dosyayı Görüntüle

@@ -2,8 +2,7 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.example.wholeestate.dao.CustomerMapper">
4 4
     <select id="customerList" resultType="com.example.wholeestate.model.Customer">
5
-        select * from ta_customer;
6
-        <where>
5
+        select * from ta_customer
7 6
             <where>
8 7
                 status > -1
9 8
                 <if test="Name != null and Name != ''">
@@ -12,8 +11,12 @@
12 11
                 <if test="phone != null and phone != ''">
13 12
                     and  ta_customer.phone like concat('%',#{phone,jdbcType=VARCHAR},'%')
14 13
                 </if>
14
+                <if test="beginDate != null and endDate != null">
15
+                    AND date_format(create_date, '%Y-%m-%d') <![CDATA[>= ]]> date_format(#{beginDate}, '%Y-%m-%d')
16
+                    AND date_format(create_date, '%Y-%m-%d')<![CDATA[<= ]]>  date_format(#{endDate}, '%Y-%m-%d')
17
+                </if>
18
+
15 19
             </where>
16
-        </where>
17 20
     </select>
18 21
 
19 22
 </mapper>