dingxin 6 年之前
父節點
當前提交
f9c8e80ea8

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

25
         FastJsonConfig fastJsonConfig = new FastJsonConfig();
25
         FastJsonConfig fastJsonConfig = new FastJsonConfig();
26
         fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.WriteMapNullValue);
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
         converter.setFastJsonConfig(fastJsonConfig);
29
         converter.setFastJsonConfig(fastJsonConfig);
30
         return new HttpMessageConverters(converter);
30
         return new HttpMessageConverters(converter);
31
     }
31
     }

+ 8
- 1
whole-estate/src/main/java/com/example/wholeestate/common/Constant.java 查看文件

6
 public class Constant {
6
 public class Constant {
7
 
7
 
8
 
8
 
9
+    /**
10
+     * 系统异常
11
+     */
9
     public static final Integer REQUEST_ERROR = 500;
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
      * 用户 session
21
      * 用户 session

+ 11
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/ActivityController.java 查看文件

118
         return responseBean;
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 查看文件

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 查看文件

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 查看文件

3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.example.wholeestate.model.Activity;
6
 import com.example.wholeestate.model.ActivityEnroll;
7
 import com.example.wholeestate.model.ActivityEnroll;
8
+import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Select;
9
 import org.apache.ibatis.annotations.Select;
8
 
10
 
9
 /**
11
 /**
16
  */
18
  */
17
 public interface ActivityEnrollMapper extends BaseMapper<ActivityEnroll> {
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
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
28
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
21
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
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
             "WHERE tac.activity_id = #{activityId}")
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 查看文件

20
      * @return
20
      * @return
21
      */
21
      */
22
     IPage<Appendable> appendableList(Page<Appendable> page);
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 查看文件

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

+ 5
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Activity.java 查看文件

116
     @TableField(exist = false)
116
     @TableField(exist = false)
117
     private String customerName;
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 查看文件

23
      */
23
      */
24
     ResponseBean getActivitySignUpList(String activityId, Integer pageNum, Integer pageSize);
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 查看文件

27
      * @return
27
      * @return
28
      */
28
      */
29
     ResponseBean customerSelectId(Integer id);
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 查看文件

43
         Page<Activity> page = new Page<>();
43
         Page<Activity> page = new Page<>();
44
         page.setCurrent(pageNum == null ? 1 : pageNum);
44
         page.setCurrent(pageNum == null ? 1 : pageNum);
45
         page.setSize(pageSize == null ? 10 : pageSize);
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
         responseBean.addSuccess(activityEnrollIPage);
48
         responseBean.addSuccess(activityEnrollIPage);
49
         return responseBean;
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 查看文件

5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.example.wholeestate.common.Constant;
8
 import com.example.wholeestate.common.resp.ResponseBean;
9
 import com.example.wholeestate.common.resp.ResponseBean;
10
+import com.example.wholeestate.common.uuid.IdGen;
9
 import com.example.wholeestate.dao.CustomerMapper;
11
 import com.example.wholeestate.dao.CustomerMapper;
10
 
12
 
11
 import com.example.wholeestate.model.Building;
13
 import com.example.wholeestate.model.Building;
14
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
16
 
18
 
19
+import java.time.LocalDateTime;
17
 import java.util.HashMap;
20
 import java.util.HashMap;
18
 import java.util.List;
21
 import java.util.List;
19
 
22
 
31
     @Autowired
34
     @Autowired
32
     private CustomerMapper customerMapper;
35
     private CustomerMapper customerMapper;
33
 
36
 
37
+    private IdGen idGen = IdGen.get();
38
+
34
     @Override
39
     @Override
35
     public ResponseBean customerList(String parameter) {
40
     public ResponseBean customerList(String parameter) {
36
         ResponseBean response= new ResponseBean();
41
         ResponseBean response= new ResponseBean();
63
         response.addSuccess(customerList);
68
         response.addSuccess(customerList);
64
         return response;
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
 }