Ver código fonte

活动管理

weiximei 6 anos atrás
pai
commit
3c0a32554d

+ 108
- 0
whole-estate/src/main/java/com/example/wholeestate/common/uuid/IdGen.java Ver arquivo

1
+package com.example.wholeestate.common.uuid;
2
+
3
+/**
4
+ * ID 生成策略
5
+ * @author  weiximei
6
+ */
7
+public class IdGen {
8
+
9
+    private long workerId;
10
+    private long datacenterId;
11
+    private long sequence = 0L;
12
+    private long twepoch = 1288834974657L;
13
+    //Thu, 04 Nov 2010 01:42:54 GMT
14
+    private long workerIdBits = 5L;
15
+    //节点ID长度
16
+    private long datacenterIdBits = 5L;
17
+    //数据中心ID长度
18
+    private long maxWorkerId = -1L ^ (-1L << workerIdBits);
19
+    //最大支持机器节点数0~31,一共32个
20
+    private long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
21
+    //最大支持数据中心节点数0~31,一共32个
22
+    private long sequenceBits = 12L;
23
+    //序列号12位
24
+    private long workerIdShift = sequenceBits;
25
+    //机器节点左移12位
26
+    private long datacenterIdShift = sequenceBits + workerIdBits;
27
+    //数据中心节点左移17位
28
+    private long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
29
+    //时间毫秒数左移22位
30
+    private long sequenceMask = -1L ^ (-1L << sequenceBits);
31
+    //最大为4095
32
+    private long lastTimestamp = -1L;
33
+
34
+    private static class IdGenHolder {
35
+        private static final IdGen instance = new IdGen();
36
+    }
37
+
38
+    public static IdGen get(){
39
+        return IdGenHolder.instance;
40
+    }
41
+
42
+    public IdGen() {
43
+        this(0L, 0L);
44
+    }
45
+
46
+    public IdGen(long workerId, long datacenterId) {
47
+        if (workerId > maxWorkerId || workerId < 0) {
48
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
49
+        }
50
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
51
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
52
+        }
53
+        this.workerId = workerId;
54
+        this.datacenterId = datacenterId;
55
+    }
56
+
57
+    public synchronized long nextId() {
58
+        long timestamp = timeGen();
59
+        //获取当前毫秒数
60
+        //如果服务器时间有问题(时钟后退) 报错。
61
+        if (timestamp < lastTimestamp) {
62
+            throw new RuntimeException(String.format(
63
+                    "Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
64
+        }
65
+        //如果上次生成时间和当前时间相同,在同一毫秒内
66
+        if (lastTimestamp == timestamp) {
67
+            //sequence自增,因为sequence只有12bit,所以和sequenceMask相与一下,去掉高位
68
+            sequence = (sequence + 1) & sequenceMask;
69
+            //判断是否溢出,也就是每毫秒内超过4095,当为4096时,与sequenceMask相与,sequence就等于0
70
+            if (sequence == 0) {
71
+                timestamp = tilNextMillis(lastTimestamp);
72
+                //自旋等待到下一毫秒
73
+            }
74
+        } else {
75
+            sequence = 0L;
76
+            //如果和上次生成时间不同,重置sequence,就是下一毫秒开始,sequence计数重新从0开始累加
77
+        }
78
+        lastTimestamp = timestamp;
79
+        // 最后按照规则拼出ID。
80
+        // 000000000000000000000000000000000000000000  00000            00000       000000000000
81
+        // time                                      datacenterId      workerId     sequence
82
+        // return ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift)
83
+        //        | (workerId << workerIdShift) | sequence;
84
+
85
+        long longStr= ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence;
86
+        // System.out.println(longStr);
87
+        return longStr;
88
+    }
89
+
90
+    protected long tilNextMillis(long lastTimestamp) {
91
+        long timestamp = timeGen();
92
+        while (timestamp <= lastTimestamp) {
93
+            timestamp = timeGen();
94
+        }
95
+        return timestamp;
96
+    }
97
+
98
+    protected long timeGen() {
99
+        return System.currentTimeMillis();
100
+    }
101
+
102
+
103
+    public static void main(String[] args) {
104
+        IdGen idGen = IdGen.get();
105
+        System.out.println(idGen.nextId());
106
+    }
107
+
108
+}

+ 86
- 4
whole-estate/src/main/java/com/example/wholeestate/controller/ActivityController.java Ver arquivo

1
 package com.example.wholeestate.controller;
1
 package com.example.wholeestate.controller;
2
 
2
 
3
 
3
 
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.example.wholeestate.common.base.BaseController;
6
 import com.example.wholeestate.common.base.BaseController;
5
 import com.example.wholeestate.common.resp.ResponseBean;
7
 import com.example.wholeestate.common.resp.ResponseBean;
8
+import com.example.wholeestate.common.uuid.IdGen;
9
+import com.example.wholeestate.model.Activity;
10
+import com.example.wholeestate.service.IActivityEnrollService;
6
 import com.example.wholeestate.service.IActivityService;
11
 import com.example.wholeestate.service.IActivityService;
7
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.Api;
8
 import io.swagger.annotations.ApiImplicitParam;
13
 import io.swagger.annotations.ApiImplicitParam;
9
 import io.swagger.annotations.ApiImplicitParams;
14
 import io.swagger.annotations.ApiImplicitParams;
10
 import io.swagger.annotations.ApiOperation;
15
 import io.swagger.annotations.ApiOperation;
11
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
12
-import org.springframework.web.bind.annotation.RequestBody;
13
-import org.springframework.web.bind.annotation.RequestMapping;
14
-import org.springframework.web.bind.annotation.RequestMethod;
15
-import org.springframework.web.bind.annotation.RestController;
17
+import org.springframework.web.bind.annotation.*;
16
 
18
 
17
 /**
19
 /**
18
  * <p>
20
  * <p>
27
 @Api(value = "活动 API", description = "活动 API")
29
 @Api(value = "活动 API", description = "活动 API")
28
 public class ActivityController extends BaseController {
30
 public class ActivityController extends BaseController {
29
 
31
 
32
+    private IdGen idGen = IdGen.get();
33
+
30
     @Autowired
34
     @Autowired
31
     private IActivityService iActivityService;
35
     private IActivityService iActivityService;
32
 
36
 
37
+    @Autowired
38
+    private IActivityEnrollService iActivityEnrollService;
39
+
40
+
33
     @RequestMapping(value = "/activity/list", method = RequestMethod.POST)
41
     @RequestMapping(value = "/activity/list", method = RequestMethod.POST)
34
     @ApiOperation(value = "活动列表", notes = "活动列表")
42
     @ApiOperation(value = "活动列表", notes = "活动列表")
35
     @ApiImplicitParams({
43
     @ApiImplicitParams({
41
         return responseBean;
49
         return responseBean;
42
     }
50
     }
43
 
51
 
52
+    @RequestMapping(value = "/activity/{activityId}", method = RequestMethod.GET)
53
+    @ApiOperation(value = "活动详情", notes = "活动详情")
54
+    @ApiImplicitParams({
55
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "activityId", value = "activityId活动id")
56
+    })
57
+    public ResponseBean getById(@PathVariable String activityId) {
58
+        ResponseBean responseBean = new ResponseBean();
59
+        responseBean = iActivityService.getActivityId(activityId);
60
+        return responseBean;
61
+    }
62
+
63
+    @RequestMapping(value = "/activity/add", method = RequestMethod.POST)
64
+    @ApiOperation(value = "添加活动", notes = "添加活动")
65
+    @ApiImplicitParams({
66
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "title活动标题;activityDate活动时间;beginDate活动开始时间;endDate活动截止时间;maxNum人数限制;context内容;imgUrl图片地址"),
67
+//            @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
68
+    })
69
+    public ResponseBean add(@RequestBody String parameter) {
70
+        ResponseBean responseBean = new ResponseBean();
71
+        Activity activity = JSONObject.parseObject(parameter, Activity.class);
72
+        activity.setActivityId(idGen.nextId()+"");
73
+        iActivityService.save(activity);
74
+        return responseBean;
75
+    }
76
+
77
+    @RequestMapping(value = "/activity/update", method = RequestMethod.PUT)
78
+    @ApiOperation(value = "修改活动", notes = "修改活动")
79
+    @ApiImplicitParams({
80
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "activityId活动编号;title活动标题;activityDate活动时间;beginDate活动开始时间;endDate活动截止时间;maxNum人数限制;context内容;imgUrl图片地址"),
81
+//            @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
82
+    })
83
+    public ResponseBean update(@RequestBody String parameter) {
84
+        ResponseBean responseBean = new ResponseBean();
85
+        Activity activity = JSONObject.parseObject(parameter, Activity.class);
86
+        QueryWrapper<Activity> activityQueryWrapper = new QueryWrapper<>();
87
+        activityQueryWrapper.eq("activity_id", activity.getActivityId());
88
+        iActivityService.update(activity, activityQueryWrapper);
89
+        return responseBean;
90
+    }
91
+
92
+    @RequestMapping(value = "/activity/delete/{activityId}", method = RequestMethod.DELETE)
93
+    @ApiOperation(value = "删除活动", notes = "删除活动")
94
+    @ApiImplicitParams({
95
+//            @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
96
+    })
97
+    public ResponseBean delete(@PathVariable String activityId) {
98
+        ResponseBean responseBean = new ResponseBean();
99
+        Activity activity = iActivityService.getById(activityId);
100
+        if (null == activity) {
101
+            responseBean.addError("活动不存在!");
102
+            return responseBean;
103
+        }
104
+        activity.setStatus(-1);
105
+        QueryWrapper<Activity> activityQueryWrapper = new QueryWrapper<>();
106
+        activityQueryWrapper.eq("activity_id", activity.getActivityId());
107
+        iActivityService.update(activity, activityQueryWrapper);
108
+        responseBean.addSuccess("操作成功!");
109
+        return responseBean;
110
+    }
111
+
112
+
113
+    @RequestMapping(value = "/activity/enroll/list/{activityId}", method = RequestMethod.POST)
114
+    @ApiOperation(value = "根据活动id查询活动报名列表", notes = "根据活动id查询活动报名列表")
115
+    @ApiImplicitParams({
116
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "pageNum第几页;pageSize一页多少行")
117
+//            @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
118
+    })
119
+    public ResponseBean activityEnrollList(@PathVariable("activityId") String activityId, @RequestBody String parameter) {
120
+        ResponseBean responseBean = new ResponseBean();
121
+        responseBean = iActivityEnrollService.getActivitySignUpList(activityId, parameter);
122
+        return responseBean;
123
+    }
124
+
125
+
44
 }
126
 }

+ 63
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/CommentController.java Ver arquivo

1
+package com.example.wholeestate.controller;
2
+
3
+
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.example.wholeestate.common.base.BaseController;
6
+import com.example.wholeestate.common.resp.ResponseBean;
7
+import com.example.wholeestate.model.Comment;
8
+import com.example.wholeestate.service.ICommentService;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiImplicitParam;
11
+import io.swagger.annotations.ApiImplicitParams;
12
+import io.swagger.annotations.ApiOperation;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RestController;
18
+
19
+/**
20
+ * <p>
21
+ * 评论表 前端控制器
22
+ * </p>
23
+ *
24
+ * @author weiximei
25
+ * @since 2019-03-20
26
+ */
27
+@RestController
28
+@RequestMapping("/")
29
+@Api(value = "评论 API", description = "评论 API")
30
+public class CommentController extends BaseController {
31
+
32
+    @Autowired
33
+    private ICommentService iCommentService;
34
+
35
+    @RequestMapping(value = "/comment/delete/{commentId}", method = RequestMethod.DELETE)
36
+    @ApiOperation(value = "删除评论", notes = "删除评论")
37
+    @ApiImplicitParams({
38
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "commentId",value = "评论编号")
39
+    })
40
+    public ResponseBean delete(@PathVariable("commentId") String commentId) {
41
+        ResponseBean responseBean = new ResponseBean();
42
+        QueryWrapper<Comment> commentQueryWrapper = new QueryWrapper<>();
43
+        commentQueryWrapper.eq("comment_id", commentId);
44
+        Comment comment = iCommentService.getOne(commentQueryWrapper);
45
+        if (null == comment) {
46
+            responseBean.addError("评论不存在!");
47
+            return responseBean;
48
+        }
49
+
50
+        comment.setStatus(-1);
51
+        iCommentService.update(comment,commentQueryWrapper);
52
+
53
+        // 删除这个评论下的子评论
54
+        Comment  childComment = new Comment();
55
+        childComment.setStatus(-1);
56
+        QueryWrapper<Comment> childCommentQueryWrapper = new QueryWrapper<>();
57
+        childCommentQueryWrapper.eq("parent_id", commentId);
58
+        iCommentService.update(childComment, childCommentQueryWrapper);
59
+        responseBean.addSuccess("操作成功!");
60
+        return responseBean;
61
+    }
62
+
63
+}

+ 9
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/ActivityEnrollMapper.java Ver arquivo

1
 package com.example.wholeestate.dao;
1
 package com.example.wholeestate.dao;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4
 import com.example.wholeestate.model.ActivityEnroll;
6
 import com.example.wholeestate.model.ActivityEnroll;
7
+import org.apache.ibatis.annotations.Select;
5
 
8
 
6
 /**
9
 /**
7
  * <p>
10
  * <p>
13
  */
16
  */
14
 public interface ActivityEnrollMapper extends BaseMapper<ActivityEnroll> {
17
 public interface ActivityEnrollMapper extends BaseMapper<ActivityEnroll> {
15
 
18
 
19
+    @Select("SELECT tac.*,tacus.phone as phone,tacus.`name` as name,tacus.customer_name as customerName FROM ta_activity tac " +
20
+            "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 " +
22
+            "WHERE tac.activity_id = #{activityId}")
23
+    IPage<ActivityEnroll> selectPageActivityEnroll(Page page, String activityId);
24
+
16
 }
25
 }

+ 1
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/ActivityMapper.java Ver arquivo

1
 package com.example.wholeestate.dao;
1
 package com.example.wholeestate.dao;
2
 
2
 
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.example.wholeestate.model.Activity;
5
 import com.example.wholeestate.model.Activity;
5
 
6
 
6
 /**
7
 /**

+ 16
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/CommentMapper.java Ver arquivo

1
+package com.example.wholeestate.dao;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.example.wholeestate.model.Comment;
5
+
6
+/**
7
+ * <p>
8
+ * 评论表 Mapper 接口
9
+ * </p>
10
+ *
11
+ * @author weiximei
12
+ * @since 2019-03-20
13
+ */
14
+public interface CommentMapper extends BaseMapper<Comment> {
15
+
16
+}

+ 24
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Activity.java Ver arquivo

92
     private Integer maxNum;
92
     private Integer maxNum;
93
 
93
 
94
 
94
 
95
+    /**
96
+     * 楼盘
97
+     */
98
+    @TableField(exist = false)
99
+    private Building building;
100
+
101
+    /**
102
+     * 客户手机号
103
+     */
104
+    @TableField(exist = false)
105
+    private String phone;
106
+
107
+    /**
108
+     * 微信昵称
109
+     */
110
+    @TableField(exist = false)
111
+    private String name;
112
+
113
+    /**
114
+     * 客户姓名
115
+     */
116
+    @TableField(exist = false)
117
+    private String customerName;
118
+
95
 }
119
 }

+ 78
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Comment.java Ver arquivo

1
+package com.example.wholeestate.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.io.Serializable;
9
+import java.time.LocalDateTime;
10
+
11
+/**
12
+ * <p>
13
+ * 评论表
14
+ * </p>
15
+ *
16
+ * @author weiximei
17
+ * @since 2019-03-20
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@TableName("ta_comment")
23
+public class Comment implements Serializable {
24
+
25
+    private static final long serialVersionUID = 1L;
26
+
27
+    /**
28
+     * 评论ID
29
+     */
30
+    private String commentId;
31
+
32
+    /**
33
+     * 用户ID
34
+     */
35
+    private String customerId;
36
+
37
+    /**
38
+     * 用户姓名
39
+     */
40
+    private String customerName;
41
+
42
+    /**
43
+     * 头像
44
+     */
45
+    private String avatar;
46
+
47
+    /**
48
+     * 评论主题类型
49
+     */
50
+    private String commentType;
51
+
52
+    /**
53
+     * 评论主体
54
+     */
55
+    private String mainId;
56
+
57
+    /**
58
+     * 父级
59
+     */
60
+    private String parentId;
61
+
62
+    /**
63
+     * 评论
64
+     */
65
+    private String commentContent;
66
+
67
+    /**
68
+     * 创建时间
69
+     */
70
+    private LocalDateTime createDate;
71
+
72
+    /**
73
+     * 0正常,-1删除
74
+     */
75
+    private Integer status;
76
+
77
+
78
+}

+ 8
- 0
whole-estate/src/main/java/com/example/wholeestate/service/IActivityEnrollService.java Ver arquivo

1
 package com.example.wholeestate.service;
1
 package com.example.wholeestate.service;
2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.example.wholeestate.common.resp.ResponseBean;
4
 import com.example.wholeestate.model.ActivityEnroll;
5
 import com.example.wholeestate.model.ActivityEnroll;
5
 
6
 
6
 /**
7
 /**
13
  */
14
  */
14
 public interface IActivityEnrollService extends IService<ActivityEnroll> {
15
 public interface IActivityEnrollService extends IService<ActivityEnroll> {
15
 
16
 
17
+    /**
18
+     * 活动报名
19
+     * @param parameter
20
+     * @return
21
+     */
22
+    ResponseBean getActivitySignUpList(String activityId,String parameter);
23
+
16
 }
24
 }

+ 1
- 1
whole-estate/src/main/java/com/example/wholeestate/service/IActivityService.java Ver arquivo

26
      * @param activityId
26
      * @param activityId
27
      * @return
27
      * @return
28
      */
28
      */
29
-    ResponseBean getById(String activityId);
29
+    ResponseBean getActivityId(String activityId);
30
 
30
 
31
 }
31
 }

+ 25
- 0
whole-estate/src/main/java/com/example/wholeestate/service/ICommentService.java Ver arquivo

1
+package com.example.wholeestate.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.example.wholeestate.common.resp.ResponseBean;
5
+import com.example.wholeestate.model.Comment;
6
+
7
+/**
8
+ * <p>
9
+ * 评论表 服务类
10
+ * </p>
11
+ *
12
+ * @author weiximei
13
+ * @since 2019-03-20
14
+ */
15
+public interface ICommentService extends IService<Comment> {
16
+
17
+    /**
18
+     * 回复评论
19
+     * @param commentId
20
+     * @param parameter
21
+     * @return
22
+     */
23
+    ResponseBean addComment(String commentId, String parameter);
24
+
25
+}

+ 35
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/ActivityEnrollServiceImpl.java Ver arquivo

1
 package com.example.wholeestate.service.impl;
1
 package com.example.wholeestate.service.impl;
2
 
2
 
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
3
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.example.wholeestate.common.resp.ResponseBean;
4
 import com.example.wholeestate.dao.ActivityEnrollMapper;
8
 import com.example.wholeestate.dao.ActivityEnrollMapper;
9
+import com.example.wholeestate.dao.ActivityMapper;
10
+import com.example.wholeestate.model.Activity;
5
 import com.example.wholeestate.model.ActivityEnroll;
11
 import com.example.wholeestate.model.ActivityEnroll;
6
 import com.example.wholeestate.service.IActivityEnrollService;
12
 import com.example.wholeestate.service.IActivityEnrollService;
13
+import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
8
 
15
 
9
 /**
16
 /**
17
 @Service
24
 @Service
18
 public class ActivityEnrollServiceImpl extends ServiceImpl<ActivityEnrollMapper, ActivityEnroll> implements IActivityEnrollService {
25
 public class ActivityEnrollServiceImpl extends ServiceImpl<ActivityEnrollMapper, ActivityEnroll> implements IActivityEnrollService {
19
 
26
 
27
+    @Autowired
28
+    private ActivityEnrollMapper activityEnrollMapper;
29
+
30
+    @Autowired
31
+    private ActivityMapper activityMapper;
32
+
33
+    @Override
34
+    public ResponseBean getActivitySignUpList(String activityId,String parameter) {
35
+        ResponseBean responseBean = new ResponseBean();
36
+
37
+        Activity activity = activityMapper.selectById(activityId);
38
+        if (null == activity) {
39
+            responseBean.addError("活动不存在!");
40
+            return responseBean;
41
+        }
42
+
43
+        JSONObject jsonObject = JSONObject.parseObject(parameter);
44
+        Integer pageNum = jsonObject.getInteger("pageNum");
45
+        Integer pageSize = jsonObject.getInteger("pageSize");
46
+
47
+        Page<Activity> page = new Page<>();
48
+        page.setCurrent(pageNum == null ? 1 : pageNum);
49
+        page.setSize(pageSize == null ? 10 : pageSize);
50
+        IPage<ActivityEnroll> activityEnrollIPage = activityEnrollMapper.selectPageActivityEnroll(page, activityId);
51
+
52
+        responseBean.addSuccess(activityEnrollIPage);
53
+        return responseBean;
54
+    }
20
 }
55
 }

+ 16
- 5
whole-estate/src/main/java/com/example/wholeestate/service/impl/ActivityServiceImpl.java Ver arquivo

7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.example.wholeestate.common.resp.ResponseBean;
8
 import com.example.wholeestate.common.resp.ResponseBean;
9
 import com.example.wholeestate.dao.ActivityMapper;
9
 import com.example.wholeestate.dao.ActivityMapper;
10
+import com.example.wholeestate.dao.BuildingMapper;
10
 import com.example.wholeestate.model.Activity;
11
 import com.example.wholeestate.model.Activity;
12
+import com.example.wholeestate.model.Building;
11
 import com.example.wholeestate.service.IActivityService;
13
 import com.example.wholeestate.service.IActivityService;
12
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
26
     @Autowired
28
     @Autowired
27
     private ActivityMapper activityMapper;
29
     private ActivityMapper activityMapper;
28
 
30
 
31
+    @Autowired
32
+    private BuildingMapper buildingMapper;
33
+
29
     @Override
34
     @Override
30
     public ResponseBean getList(String parameter) {
35
     public ResponseBean getList(String parameter) {
31
         ResponseBean responseBean = new ResponseBean();
36
         ResponseBean responseBean = new ResponseBean();
35
         Integer pageSize = jsonObject.getInteger("pageSize");
40
         Integer pageSize = jsonObject.getInteger("pageSize");
36
 
41
 
37
         Page<Activity> page = new Page<>();
42
         Page<Activity> page = new Page<>();
38
-        page.setCurrent(pageNum);
39
-        page.setSize(pageSize);
43
+        page.setCurrent(pageNum == null ? 1 : pageNum);
44
+        page.setSize(pageSize == null ? 10 : pageSize);
40
         QueryWrapper<Activity> queryWrapper = new QueryWrapper<>();
45
         QueryWrapper<Activity> queryWrapper = new QueryWrapper<>();
41
         IPage<Activity> activityIPage = activityMapper.selectPage(page, queryWrapper);
46
         IPage<Activity> activityIPage = activityMapper.selectPage(page, queryWrapper);
42
         responseBean.addSuccess(activityIPage);
47
         responseBean.addSuccess(activityIPage);
44
     }
49
     }
45
 
50
 
46
     @Override
51
     @Override
47
-    public ResponseBean getById(String activityId) {
52
+    public ResponseBean getActivityId(String activityId) {
48
         ResponseBean responseBean = new ResponseBean();
53
         ResponseBean responseBean = new ResponseBean();
49
 
54
 
50
-        Activity activity = activityMapper.selectById(activityId);
55
+        QueryWrapper<Activity> activityQueryWrapper = new QueryWrapper<>();
56
+        activityQueryWrapper.eq("activity_id", activityId);
57
+        Activity activity = activityMapper.selectOne(activityQueryWrapper);
51
         if (null == activity) {
58
         if (null == activity) {
52
             responseBean.addError("活动不存在!");
59
             responseBean.addError("活动不存在!");
53
             return responseBean;
60
             return responseBean;
54
         }
61
         }
55
 
62
 
56
-        responseBean.addSuccess(activityId);
63
+        QueryWrapper<Building> buildingQueryWrapper = new QueryWrapper<>();
64
+        buildingQueryWrapper.eq("building_id", activity.getBuildingId());
65
+        Building building = buildingMapper.selectOne(buildingQueryWrapper);
66
+        activity.setBuilding(building);
67
+        responseBean.addSuccess(activity);
57
         return responseBean;
68
         return responseBean;
58
     }
69
     }
59
 }
70
 }

+ 29
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/CommentServiceImpl.java Ver arquivo

1
+package com.example.wholeestate.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.example.wholeestate.common.resp.ResponseBean;
5
+import com.example.wholeestate.dao.CommentMapper;
6
+import com.example.wholeestate.model.Activity;
7
+import com.example.wholeestate.model.Comment;
8
+import com.example.wholeestate.service.ICommentService;
9
+import org.springframework.stereotype.Service;
10
+
11
+/**
12
+ * <p>
13
+ * 评论表 服务实现类
14
+ * </p>
15
+ *
16
+ * @author weiximei
17
+ * @since 2019-03-20
18
+ */
19
+@Service
20
+public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
21
+
22
+    @Override
23
+    public ResponseBean addComment(String commentId, String parameter) {
24
+        ResponseBean responseBean = new ResponseBean();
25
+
26
+
27
+        return responseBean;
28
+    }
29
+}