dingxin 6 anni fa
parent
commit
f9c8e80ea8

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/WholeEstateApplication.java Vedi File

@@ -25,7 +25,7 @@ public class WholeEstateApplication {
25 25
         FastJsonConfig fastJsonConfig = new FastJsonConfig();
26 26
         fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.WriteMapNullValue);
27 27
         //日期格式化
28
-        //fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
28
+        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
29 29
         converter.setFastJsonConfig(fastJsonConfig);
30 30
         return new HttpMessageConverters(converter);
31 31
     }

+ 8
- 1
whole-estate/src/main/java/com/example/wholeestate/common/Constant.java Vedi File

@@ -6,9 +6,16 @@ package com.example.wholeestate.common;
6 6
 public class Constant {
7 7
 
8 8
 
9
+    /**
10
+     * 系统异常
11
+     */
9 12
     public static final Integer REQUEST_ERROR = 500;
10 13
 
11
-    public static final Integer NOT_SESSION_USER = 401;
14
+    /**
15
+     * 用户 不存在
16
+     */
17
+    public static final Integer NOT_USER = 401;
18
+
12 19
 
13 20
     /**
14 21
      * 用户 session

+ 11
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/ActivityController.java Vedi File

@@ -118,5 +118,16 @@ public class ActivityController extends BaseController {
118 118
         return responseBean;
119 119
     }
120 120
 
121
+    @RequestMapping(value = "/wx/activity/{openid}", method = RequestMethod.GET)
122
+    @ApiOperation(value = "根据openid查询参加过的活动列表", notes = "根据openid查询参加过的活动列表")
123
+    @ApiImplicitParams({
124
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "pageNum第几页"),
125
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "pageSize一页多少行")
126
+    })
127
+    public ResponseBean getOpenidActivityUpList(@PathVariable("openid") String openid, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
128
+        ResponseBean responseBean = new ResponseBean();
129
+        responseBean = iActivityEnrollService.getOpenidActivityUpList(openid, pageNum, pageSize);
130
+        return responseBean;
131
+    }
121 132
 
122 133
 }

+ 43
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/WxUserController.java Vedi File

@@ -0,0 +1,43 @@
1
+package com.example.wholeestate.controller;
2
+
3
+import com.example.wholeestate.common.base.BaseController;
4
+import com.example.wholeestate.common.resp.ResponseBean;
5
+import com.example.wholeestate.service.ICustomerService;
6
+import io.swagger.annotations.Api;
7
+import io.swagger.annotations.ApiImplicitParam;
8
+import io.swagger.annotations.ApiImplicitParams;
9
+import io.swagger.annotations.ApiOperation;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.web.bind.annotation.*;
12
+
13
+@RestController
14
+@RequestMapping("/")
15
+@Api(value = "微信小程序 用户 API", description = "微信小程序 用户 API")
16
+public class WxUserController extends BaseController {
17
+
18
+    @Autowired
19
+    private ICustomerService iCustomerService;
20
+
21
+    @RequestMapping(value = "/wx/registered", method = RequestMethod.POST)
22
+    @ApiOperation(value = "注册用户", notes = "注册用户")
23
+    @ApiImplicitParams({
24
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "customerName用户姓名;name昵称;phone手机号;idNum证件号码;openid标记;uuid标记;avatar头像;")
25
+    })
26
+    public ResponseBean registeredCustomer(@RequestBody String parameter) {
27
+        ResponseBean responseBean = new ResponseBean();
28
+        responseBean = iCustomerService.registeredCustomer(parameter);
29
+        return responseBean;
30
+    }
31
+
32
+    @RequestMapping(value = "/wx/info/{openid}", method = RequestMethod.GET)
33
+    @ApiOperation(value = "获取微信小程序用户信息", notes = "获取微信小程序用户信息")
34
+    @ApiImplicitParams({
35
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "openid", value = "openid")
36
+    })
37
+    public ResponseBean getWXCustomer(@PathVariable String openid) {
38
+        ResponseBean responseBean = new ResponseBean();
39
+        responseBean = iCustomerService.getWXCustomer(openid);
40
+        return responseBean;
41
+    }
42
+
43
+}

+ 0
- 15
whole-estate/src/main/java/com/example/wholeestate/controller/wx/controller/WxUserController.java Vedi File

@@ -1,15 +0,0 @@
1
-package com.example.wholeestate.controller.wx.controller;
2
-
3
-import com.example.wholeestate.common.base.BaseController;
4
-import io.swagger.annotations.Api;
5
-import org.springframework.web.bind.annotation.RequestMapping;
6
-import org.springframework.web.bind.annotation.RestController;
7
-
8
-@RestController
9
-@RequestMapping("/")
10
-@Api(value = "微信小程序 用户 API", description = "微信小程序 用户 API")
11
-public class WxUserController extends BaseController {
12
-
13
-
14
-
15
-}

+ 24
- 2
whole-estate/src/main/java/com/example/wholeestate/dao/ActivityEnrollMapper.java Vedi File

@@ -3,7 +3,9 @@ package com.example.wholeestate.dao;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.example.wholeestate.model.Activity;
6 7
 import com.example.wholeestate.model.ActivityEnroll;
8
+import org.apache.ibatis.annotations.Param;
7 9
 import org.apache.ibatis.annotations.Select;
8 10
 
9 11
 /**
@@ -16,10 +18,30 @@ import org.apache.ibatis.annotations.Select;
16 18
  */
17 19
 public interface ActivityEnrollMapper extends BaseMapper<ActivityEnroll> {
18 20
 
19
-    @Select("SELECT tac.*,tacus.phone as phone,tacus.`name` as name,tacus.customer_name as customerName FROM ta_activity tac " +
21
+    /**
22
+     * 根据 活动id 查询 活动列表用户
23
+     * @param page
24
+     * @param activityId
25
+     * @return
26
+     */
27
+    @Select("SELECT tacus.phone as phone,tacus.`name` as name,tacus.customer_name as customerName,tab.building_name AS buildingName FROM ta_activity tac " +
20 28
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
21 29
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
30
+            "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
22 31
             "WHERE tac.activity_id = #{activityId}")
23
-    IPage<ActivityEnroll> selectPageActivityEnroll(Page page, String activityId);
32
+    IPage<Activity> selectPageActivityEnroll(Page page, @Param("activityId") String activityId);
33
+
34
+    /**
35
+     * 根据 openid 查询 我参加的活动
36
+     * @param page
37
+     * @param openid
38
+     * @return
39
+     */
40
+    @Select("SELECT tac.*,tacus.phone as phone,tacus.`name` as name,tacus.customer_name as customerName,tab.building_name AS buildingName FROM ta_activity tac " +
41
+            "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
42
+            "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
43
+            "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
44
+            "WHERE tacus.openid = #{openid}")
45
+    IPage<Activity> selectOpenidActivityEnroll(Page page, @Param("openid") String openid);
24 46
 
25 47
 }

+ 1
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/AppointmentMapper.java Vedi File

@@ -20,5 +20,6 @@ public interface AppointmentMapper extends BaseMapper<Appointment> {
20 20
      * @return
21 21
      */
22 22
     IPage<Appendable> appendableList(Page<Appendable> page);
23
+    
23 24
 
24 25
 }

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/exception/ExceptionHandleAdice.java Vedi File

@@ -36,7 +36,7 @@ public class ExceptionHandleAdice {
36 36
         ResponseBean response = new ResponseBean();
37 37
         String message = e.getMessage();
38 38
         if (message.equals("用户 session 不存在!")) {
39
-            response.addError(Constant.NOT_SESSION_USER, message);
39
+            response.addError(Constant.NOT_USER, message);
40 40
             return response;
41 41
         }
42 42
         response.addError(message);

+ 5
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Activity.java Vedi File

@@ -116,4 +116,9 @@ public class Activity implements Serializable {
116 116
     @TableField(exist = false)
117 117
     private String customerName;
118 118
 
119
+    /**
120
+     * 楼盘名称
121
+     */
122
+    @TableField(exist = false)
123
+    private String buildingName;
119 124
 }

+ 7
- 0
whole-estate/src/main/java/com/example/wholeestate/service/IActivityEnrollService.java Vedi File

@@ -23,4 +23,11 @@ public interface IActivityEnrollService extends IService<ActivityEnroll> {
23 23
      */
24 24
     ResponseBean getActivitySignUpList(String activityId, Integer pageNum, Integer pageSize);
25 25
 
26
+    /**
27
+     * 根据 openid 查询. 我的活动记录
28
+     * @param openid
29
+     * @return
30
+     */
31
+    ResponseBean getOpenidActivityUpList(String openid, Integer pageNum, Integer pageSize);
32
+
26 33
 }

+ 15
- 0
whole-estate/src/main/java/com/example/wholeestate/service/ICustomerService.java Vedi File

@@ -27,4 +27,19 @@ public interface ICustomerService extends IService<Customer> {
27 27
      * @return
28 28
      */
29 29
     ResponseBean customerSelectId(Integer id);
30
+
31
+    /**
32
+     * 注册微信小程序用户
33
+     * @param parameter
34
+     * @return
35
+     */
36
+    ResponseBean registeredCustomer(String parameter);
37
+
38
+    /**
39
+     * 根据 openId 获取, 用户信息
40
+     * @param openid
41
+     * @return
42
+     */
43
+    ResponseBean getWXCustomer(String openid);
44
+
30 45
 }

+ 12
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/ActivityEnrollServiceImpl.java Vedi File

@@ -43,9 +43,20 @@ public class ActivityEnrollServiceImpl extends ServiceImpl<ActivityEnrollMapper,
43 43
         Page<Activity> page = new Page<>();
44 44
         page.setCurrent(pageNum == null ? 1 : pageNum);
45 45
         page.setSize(pageSize == null ? 10 : pageSize);
46
-        IPage<ActivityEnroll> activityEnrollIPage = activityEnrollMapper.selectPageActivityEnroll(page, activityId);
46
+        IPage<Activity> activityEnrollIPage = activityEnrollMapper.selectPageActivityEnroll(page, activityId);
47 47
 
48 48
         responseBean.addSuccess(activityEnrollIPage);
49 49
         return responseBean;
50 50
     }
51
+
52
+    @Override
53
+    public ResponseBean getOpenidActivityUpList(String openid, Integer pageNum, Integer pageSize) {
54
+        ResponseBean responseBean = new ResponseBean();
55
+        Page<Activity> page = new Page<>();
56
+        page.setCurrent(pageNum);
57
+        page.setSize(pageSize);
58
+        IPage<Activity> activityIPage = activityEnrollMapper.selectOpenidActivityEnroll(page, openid);
59
+        responseBean.addSuccess(activityIPage);
60
+        return responseBean;
61
+    }
51 62
 }

+ 32
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/CustomerServiceImpl.java Vedi File

@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.example.wholeestate.common.Constant;
8 9
 import com.example.wholeestate.common.resp.ResponseBean;
10
+import com.example.wholeestate.common.uuid.IdGen;
9 11
 import com.example.wholeestate.dao.CustomerMapper;
10 12
 
11 13
 import com.example.wholeestate.model.Building;
@@ -14,6 +16,7 @@ import com.example.wholeestate.service.ICustomerService;
14 16
 import org.springframework.beans.factory.annotation.Autowired;
15 17
 import org.springframework.stereotype.Service;
16 18
 
19
+import java.time.LocalDateTime;
17 20
 import java.util.HashMap;
18 21
 import java.util.List;
19 22
 
@@ -31,6 +34,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
31 34
     @Autowired
32 35
     private CustomerMapper customerMapper;
33 36
 
37
+    private IdGen idGen = IdGen.get();
38
+
34 39
     @Override
35 40
     public ResponseBean customerList(String parameter) {
36 41
         ResponseBean response= new ResponseBean();
@@ -63,4 +68,31 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
63 68
         response.addSuccess(customerList);
64 69
         return response;
65 70
     }
71
+
72
+    @Override
73
+    public ResponseBean registeredCustomer(String parameter) {
74
+        ResponseBean responseBean = new ResponseBean();
75
+        Customer customer = JSONObject.parseObject(parameter, Customer.class);
76
+        customer.setCreateDate(LocalDateTime.now());
77
+        customer.setStatus(1);
78
+
79
+        customer.setCustomerId(idGen.nextId()+"");
80
+        customerMapper.insert(customer);
81
+        return responseBean;
82
+    }
83
+
84
+    @Override
85
+    public ResponseBean getWXCustomer(String openid) {
86
+        ResponseBean responseBean = new ResponseBean();
87
+        QueryWrapper<Customer> customerQueryWrapper = new QueryWrapper<>();
88
+        customerQueryWrapper.eq("openid", openid);
89
+        Customer customer = customerMapper.selectOne(customerQueryWrapper);
90
+        if (null == customer) {
91
+            responseBean.addError(Constant.NOT_USER, "用户不存在!");
92
+            return responseBean;
93
+        }
94
+
95
+        responseBean.addSuccess(customer);
96
+        return responseBean;
97
+    }
66 98
 }