dingxin 6 年前
父节点
当前提交
15b5d927b5

+ 2
- 6
whole-estate/src/main/java/com/example/wholeestate/controller/CustomerController.java 查看文件

31
 
31
 
32
     @ApiOperation(value = "会员列表", notes = "会员列表")
32
     @ApiOperation(value = "会员列表", notes = "会员列表")
33
     @ApiImplicitParams({
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
 //    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
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
     public ResponseBean buildingList(@RequestBody String parameter, HttpSession session){
38
     public ResponseBean buildingList(@RequestBody String parameter, HttpSession session){
43
         ResponseBean  responseBean = iCustomerService.customerList(parameter);
39
         ResponseBean  responseBean = iCustomerService.customerList(parameter);
44
         return responseBean;
40
         return responseBean;

+ 3
- 1
whole-estate/src/main/java/com/example/wholeestate/dao/CustomerMapper.java 查看文件

6
 import com.example.wholeestate.model.Customer;
6
 import com.example.wholeestate.model.Customer;
7
 import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Param;
8
 
8
 
9
+import java.util.Date;
10
+
9
 /**
11
 /**
10
  * <p>
12
  * <p>
11
  *  Mapper 接口
13
  *  Mapper 接口
21
      * @param page
23
      * @param page
22
      * @return
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 查看文件

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

+ 6
- 3
whole-estate/src/main/resources/mapper/CustomerMapper.xml 查看文件

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