Your Name 4 anni fa
parent
commit
6583013bfa
30 ha cambiato i file con 555 aggiunte e 149 eliminazioni
  1. 8
    0
      src/main/java/com/yunzhi/demo/common/Constants.java
  2. 23
    9
      src/main/java/com/yunzhi/demo/controller/TaMedicalLogController.java
  3. 99
    55
      src/main/java/com/yunzhi/demo/controller/TaPersonController.java
  4. 60
    36
      src/main/java/com/yunzhi/demo/controller/TaPostSaveController.java
  5. 60
    7
      src/main/java/com/yunzhi/demo/controller/TaPostTestController.java
  6. 21
    21
      src/main/java/com/yunzhi/demo/controller/TaReadLogController.java
  7. 14
    6
      src/main/java/com/yunzhi/demo/controller/TdSchoolController.java
  8. 16
    6
      src/main/java/com/yunzhi/demo/controller/TdSpecialtyController.java
  9. 23
    0
      src/main/java/com/yunzhi/demo/entity/MyReadLog.java
  10. 18
    3
      src/main/java/com/yunzhi/demo/entity/TaPerson.java
  11. 1
    1
      src/main/java/com/yunzhi/demo/entity/TaPersonData.java
  12. 1
    1
      src/main/java/com/yunzhi/demo/entity/TaPointsLog.java
  13. 3
    0
      src/main/java/com/yunzhi/demo/entity/TaPost.java
  14. 4
    1
      src/main/java/com/yunzhi/demo/entity/TaPostTest.java
  15. 4
    0
      src/main/java/com/yunzhi/demo/entity/TaTopic.java
  16. 1
    0
      src/main/java/com/yunzhi/demo/mapper/TaPersonDataMapper.java
  17. 3
    0
      src/main/java/com/yunzhi/demo/mapper/TaPostSaveMapper.java
  18. 6
    0
      src/main/java/com/yunzhi/demo/mapper/TaReadLogMapper.java
  19. 3
    0
      src/main/java/com/yunzhi/demo/service/ITaPointsLogService.java
  20. 6
    0
      src/main/java/com/yunzhi/demo/service/ITaPostSaveService.java
  21. 2
    0
      src/main/java/com/yunzhi/demo/service/ITaPostTestService.java
  22. 5
    0
      src/main/java/com/yunzhi/demo/service/ITaReadLogService.java
  23. 71
    0
      src/main/java/com/yunzhi/demo/service/impl/TaPointsLogServiceImpl.java
  24. 2
    0
      src/main/java/com/yunzhi/demo/service/impl/TaPostDataServiceImpl.java
  25. 23
    3
      src/main/java/com/yunzhi/demo/service/impl/TaPostSaveServiceImpl.java
  26. 19
    0
      src/main/java/com/yunzhi/demo/service/impl/TaPostTestServiceImpl.java
  27. 15
    0
      src/main/java/com/yunzhi/demo/service/impl/TaReadLogServiceImpl.java
  28. 7
    0
      src/main/resources/mapper/TaPersonDataMapper.xml
  29. 13
    0
      src/main/resources/mapper/TaPostSaveMapper.xml
  30. 24
    0
      src/main/resources/mapper/TaReadLogMapper.xml

+ 8
- 0
src/main/java/com/yunzhi/demo/common/Constants.java Vedi File

1
 package com.yunzhi.demo.common;
1
 package com.yunzhi.demo.common;
2
 
2
 
3
 public class Constants {
3
 public class Constants {
4
+    // 基本状态
4
     public final static Integer STATUS_DELETED = -1;
5
     public final static Integer STATUS_DELETED = -1;
5
     public final static Integer STATUS_READY = 0;
6
     public final static Integer STATUS_READY = 0;
6
     public final static Integer STATUS_NORMAL = 1;
7
     public final static Integer STATUS_NORMAL = 1;
8
+
9
+    // 阅读状态
10
+    public final static Integer READ_READY = 0;
11
+    public final static Integer READ_FINISHED = 1;
12
+
13
+    // 资源类型
14
+    public final static String RESOURCE_TYPE_POST = "post"; // 科普文章
7
 }
15
 }

+ 23
- 9
src/main/java/com/yunzhi/demo/controller/TaMedicalLogController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.entity.TaPerson;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
11
 import org.slf4j.Logger;
13
 import org.slf4j.Logger;
12
 import org.slf4j.LoggerFactory;
14
 import org.slf4j.LoggerFactory;
13
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.PathVariable;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RequestMethod;
18
-import org.springframework.web.bind.annotation.RequestParam;
16
+import org.springframework.web.bind.annotation.*;
19
 import com.yunzhi.demo.service.ITaMedicalLogService;
17
 import com.yunzhi.demo.service.ITaMedicalLogService;
20
 import com.yunzhi.demo.entity.TaMedicalLog;
18
 import com.yunzhi.demo.entity.TaMedicalLog;
21
-import org.springframework.web.bind.annotation.RestController;
22
 
19
 
23
 /**
20
 /**
24
  * <p>
21
  * <p>
39
     @Autowired
36
     @Autowired
40
     public ITaMedicalLogService iTaMedicalLogService;
37
     public ITaMedicalLogService iTaMedicalLogService;
41
 
38
 
39
+    @GetMapping("/ma/medical-log")
40
+    @ApiOperation(value="我的就诊记录", notes = "我的就诊记录", httpMethod = "GET", response = ResponseBean.class)
41
+    public ResponseBean maMedicalList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
42
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
43
+        TaPerson taPerson = getCurrentPerson();
44
+
45
+        IPage<TaMedicalLog> pg = new Page<>(pageNum, pageSize);
46
+        QueryWrapper<TaMedicalLog> queryWrapper = new QueryWrapper<>();
47
+        queryWrapper.eq("person_id", taPerson.getPersonId());
48
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
49
+        queryWrapper.orderByDesc("create_date");
50
+
51
+        IPage<TaMedicalLog> result = iTaMedicalLogService.page(pg, queryWrapper);
52
+        return ResponseBean.success(result);
53
+    }
54
+
42
 
55
 
43
     /**
56
     /**
44
      * 分页查询列表
57
      * 分页查询列表
111
      * 根据id查询对象
124
      * 根据id查询对象
112
      * @param id  实体ID
125
      * @param id  实体ID
113
      */
126
      */
114
-    @RequestMapping(value="/taMedicalLog/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taMedicalLogGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
127
+    @RequestMapping(value="/{client}/medical-log/{id}",method= RequestMethod.GET)
128
+    @ApiOperation(value="就诊详情", notes = "就诊详情", httpMethod = "GET", response = ResponseBean.class)
129
+    public ResponseBean taMedicalLogGet(@ApiParam(value = "客户端", allowableValues = "admin,ma") @PathVariable String client,
130
+                                        @ApiParam("就诊ID") @PathVariable Integer id) throws Exception{
117
         return ResponseBean.success(iTaMedicalLogService.getById(id));
131
         return ResponseBean.success(iTaMedicalLogService.getById(id));
118
     }
132
     }
119
 }
133
 }

+ 99
- 55
src/main/java/com/yunzhi/demo/controller/TaPersonController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
8
 import com.yunzhi.demo.entity.TaPersonData;
10
 import com.yunzhi.demo.entity.TaPersonData;
9
-import com.yunzhi.demo.service.ITaPersonDataService;
10
-import com.yunzhi.demo.service.ITaPostDataService;
11
+import com.yunzhi.demo.entity.TdSchool;
12
+import com.yunzhi.demo.entity.TdSpecialty;
13
+import com.yunzhi.demo.service.*;
11
 import io.swagger.annotations.Api;
14
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiOperation;
15
 import io.swagger.annotations.ApiOperation;
13
 import io.swagger.annotations.ApiParam;
16
 import io.swagger.annotations.ApiParam;
15
 import org.slf4j.LoggerFactory;
18
 import org.slf4j.LoggerFactory;
16
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.web.bind.annotation.*;
20
 import org.springframework.web.bind.annotation.*;
18
-import com.yunzhi.demo.service.ITaPersonService;
19
 import com.yunzhi.demo.entity.TaPerson;
21
 import com.yunzhi.demo.entity.TaPerson;
20
 
22
 
23
+import java.time.LocalDateTime;
21
 import java.util.HashMap;
24
 import java.util.HashMap;
22
 import java.util.Map;
25
 import java.util.Map;
23
 
26
 
43
     @Autowired
46
     @Autowired
44
     ITaPersonDataService iTaPersonDataService;
47
     ITaPersonDataService iTaPersonDataService;
45
 
48
 
49
+    @Autowired
50
+    ITdSchoolService iTdSchoolService;
51
+
52
+    @Autowired
53
+    ITdSpecialtyService iTdSpecialtyService;
54
+
46
     /**
55
     /**
47
      * 分页查询列表
56
      * 分页查询列表
48
      * @param pageNum
57
      * @param pageNum
49
      * @param pageSize
58
      * @param pageSize
50
      * @return
59
      * @return
51
      */
60
      */
52
-    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
53
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
61
+    @RequestMapping(value="/admin/person",method= RequestMethod.GET)
62
+    @ApiOperation(value="查询学生列表", notes = "查询学生列表", httpMethod = "GET", response = ResponseBean.class)
54
     public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
63
     public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
64
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
65
+                                     @ApiParam("名称") @RequestParam(value ="name", required = false) String name,
66
+                                     @ApiParam("学校ID") @RequestParam(value ="schoolId", required = false) String schoolId,
67
+                                     @ApiParam("专业ID") @RequestParam(value ="specialtyId", required = false) String specialtyId,
68
+                                     @ApiParam("手机") @RequestParam(value ="phone", required = false) String phone,
69
+                                     @ApiParam("学号") @RequestParam(value ="studentId", required = false) String studentId) throws Exception{
56
 
70
 
57
 		    IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
71
 		    IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
58
-            QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
59
-            queryWrapper.orderByDesc("create_date");
72
+            QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<TaPerson>()
73
+                    .gt("status", Constants.STATUS_DELETED)
74
+                    .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
75
+                    .eq(!StringUtils.isEmpty(schoolId), "school_id", schoolId)
76
+                    .eq(!StringUtils.isEmpty(specialtyId), "specialty_id", specialtyId)
77
+                    .like(!StringUtils.isEmpty(phone), "phone", "%"+phone+"%")
78
+                    .like(!StringUtils.isEmpty(studentId), "student_id", "%"+studentId+"%")
79
+                    .orderByDesc("create_date");
60
 
80
 
61
             IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
81
             IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
62
             return ResponseBean.success(result);
82
             return ResponseBean.success(result);
63
     }
83
     }
64
 
84
 
85
+//    /**
86
+//     * 保存对象
87
+//     * @param taPerson 实体对象
88
+//     * @return
89
+//     */
90
+//    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
91
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
92
+//    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
93
+//
94
+//        if (iTaPersonService.save(taPerson)){
95
+//            return ResponseBean.success(taPerson);
96
+//        }else {
97
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
98
+//        }
99
+//    }
100
+
101
+//    /**
102
+//     * 根据id删除对象
103
+//     * @param id  实体ID
104
+//     */
105
+//    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
106
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
107
+//    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
108
+//        if(iTaPersonService.removeById(id)){
109
+//            return ResponseBean.success("success");
110
+//        }else {
111
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
112
+//        }
113
+//    }
114
+
65
     /**
115
     /**
66
-     * 保存对象
116
+     * 小程序完善信息
67
      * @param taPerson 实体对象
117
      * @param taPerson 实体对象
68
      * @return
118
      * @return
69
      */
119
      */
70
-    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
71
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
72
-    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
73
-
74
-        if (iTaPersonService.save(taPerson)){
75
-            return ResponseBean.success(taPerson);
76
-        }else {
77
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
78
-        }
79
-    }
80
-
81
-    /**
82
-     * 根据id删除对象
83
-     * @param id  实体ID
84
-     */
85
-    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
86
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
87
-    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
88
-        if(iTaPersonService.removeById(id)){
89
-            return ResponseBean.success("success");
90
-        }else {
91
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
120
+    @RequestMapping(value="/ma/person",method= RequestMethod.PUT)
121
+    @ApiOperation(value="小程序完善信息", notes = "更新当前人自己的信息", httpMethod = "PUT", response = TaPerson.class)
122
+    public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
123
+        TaPerson currentPerson = getCurrentPerson();
124
+        if (null == currentPerson || null == taPerson || !currentPerson.getPersonId().equals(taPerson.getPersonId())) {
125
+            throw new Exception("校验人员信息失败");
92
         }
126
         }
93
-    }
94
 
127
 
95
-    /**
96
-     * 修改对象
97
-     * @param id  实体ID
98
-     * @param taPerson 实体对象
99
-     * @return
100
-     */
101
-    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.PUT)
102
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
103
-    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
104
-                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
128
+        taPerson.setUpdateDate(LocalDateTime.now());
105
 
129
 
106
         if (iTaPersonService.updateById(taPerson)){
130
         if (iTaPersonService.updateById(taPerson)){
107
-            return ResponseBean.success(iTaPersonService.getById(id));
131
+            return ResponseBean.success(iTaPersonService.getById(taPerson.getPersonId()));
108
         }else {
132
         }else {
109
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
133
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
110
         }
134
         }
114
      * 根据id查询对象
138
      * 根据id查询对象
115
      * @param id  实体ID
139
      * @param id  实体ID
116
      */
140
      */
117
-    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.GET)
118
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
119
-    public ResponseBean taPersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
120
-        return ResponseBean.success(iTaPersonService.getById(id));
141
+    @RequestMapping(value="/admin/person/{id}",method= RequestMethod.GET)
142
+    @ApiOperation(value="学生详情", notes = "查询人员详细信息", httpMethod = "GET", response = TaPerson.class)
143
+    public ResponseBean taPersonGet(@ApiParam("学生ID") @PathVariable String id) throws Exception{
144
+        TaPerson taPerson = iTaPersonService.getById(id);
145
+        if (null == taPerson || Constants.STATUS_DELETED.equals(taPerson.getStatus())) {
146
+            throw new Exception("验证人员信息失败, 请退出重试");
147
+        }
148
+
149
+        fillInfo(taPerson);
150
+
151
+        return ResponseBean.success(taPerson);
121
     }
152
     }
122
 
153
 
123
     @GetMapping("/ma/currentPerson")
154
     @GetMapping("/ma/currentPerson")
124
-    @ApiOperation(value="获取当前人员信息", notes = "获取当前人员信息", httpMethod = "GET", response = TaPerson.class)
155
+    @ApiOperation(value="小程序当前人员", notes = "获取当前人员信息", httpMethod = "GET", response = TaPerson.class)
125
     public ResponseBean getCurrent() throws Exception {
156
     public ResponseBean getCurrent() throws Exception {
126
-        Map<String, Object> result = new HashMap<>();
127
-
128
         TaPerson taPerson = getCurrentPerson();
157
         TaPerson taPerson = getCurrentPerson();
129
         if (null == taPerson) {
158
         if (null == taPerson) {
130
             throw new Exception("验证人员信息失败, 请退出重试");
159
             throw new Exception("验证人员信息失败, 请退出重试");
131
         }
160
         }
132
 
161
 
133
-        // 获取统计数据
134
-        TaPersonData taPersonData = iTaPersonDataService.getById(taPerson.getPersonId());
162
+        fillInfo(taPerson);
163
+
164
+        return ResponseBean.success(taPerson);
165
+    }
135
 
166
 
136
-        result.put("person", taPerson);
137
-        result.put("personData", taPersonData);
167
+    private void fillInfo(TaPerson taPerson) {
168
+        // 冗余学校名称, 专业名称
169
+        if (null != taPerson.getSchoolId()) {
170
+            TdSchool tdSchool = iTdSchoolService.getById(taPerson.getSchoolId());
171
+            if (null != tdSchool) {
172
+                taPerson.setSchoolName(tdSchool.getName());
173
+            }
174
+
175
+            TdSpecialty tdSpecialty = iTdSpecialtyService.getById(taPerson.getSpecialtyId());
176
+            if (null != tdSpecialty) {
177
+                taPerson.setSpecialtyName(tdSpecialty.getName());
178
+            }
179
+        }
138
 
180
 
139
-        return ResponseBean.success(taPersonData);
181
+        // 获取统计数据
182
+        TaPersonData taPersonData = iTaPersonDataService.getById(taPerson.getPersonId());
183
+        taPerson.setPersonData(taPersonData);
140
     }
184
     }
141
 }
185
 }

+ 60
- 36
src/main/java/com/yunzhi/demo/controller/TaPostSaveController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.entity.TaPerson;
10
+import com.yunzhi.demo.entity.TaPost;
8
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
13
 import io.swagger.annotations.ApiParam;
20
 import com.yunzhi.demo.entity.TaPostSave;
23
 import com.yunzhi.demo.entity.TaPostSave;
21
 import org.springframework.web.bind.annotation.RestController;
24
 import org.springframework.web.bind.annotation.RestController;
22
 
25
 
26
+import java.time.LocalDateTime;
27
+
23
 /**
28
 /**
24
  * <p>
29
  * <p>
25
     * 收藏 前端控制器
30
     * 收藏 前端控制器
46
      * @param pageSize
51
      * @param pageSize
47
      * @return
52
      * @return
48
      */
53
      */
49
-    @RequestMapping(value="/taPostSave",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
+    @RequestMapping(value="/ma/post-save",method= RequestMethod.GET)
55
+    @ApiOperation(value="我的收藏", notes = "小程序我的收藏列表", httpMethod = "GET", response = ResponseBean.class)
51
     public ResponseBean taPostSaveList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
     public ResponseBean taPostSaveList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
57
+                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
 
58
 
54
-		    IPage<TaPostSave> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaPostSave> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
59
+        IPage<TaPost> pg = new Page<>(pageNum, pageSize);
60
+        TaPerson taPerson = getCurrentPerson();
57
 
61
 
58
-            IPage<TaPostSave> result = iTaPostSaveService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
62
+        IPage<TaPost> result = iTaPostSaveService.getMyPostSaveList(pg, taPerson.getPersonId());
63
+        return ResponseBean.success(result);
60
     }
64
     }
61
 
65
 
62
     /**
66
     /**
63
-     * 保存对象
64
-     * @param taPostSave 实体对象
67
+     * 添加收藏
68
+     * @param postId 文章ID
65
      * @return
69
      * @return
66
      */
70
      */
67
-    @RequestMapping(value="/taPostSave",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taPostSaveAdd(@ApiParam("保存内容") @RequestBody TaPostSave taPostSave) throws Exception{
71
+    @RequestMapping(value="/ma/post-save",method= RequestMethod.POST)
72
+    @ApiOperation(value="添加我的收藏", notes = "添加我的收藏", httpMethod = "POST", response = ResponseBean.class)
73
+    public ResponseBean taPostSaveAdd(@ApiParam("文章ID") @RequestParam String postId) throws Exception{
74
+        TaPerson taPerson = getCurrentPerson();
75
+        TaPostSave taPostSave = new TaPostSave();
76
+        taPostSave.setPostId(postId);
77
+        taPostSave.setPersonId(taPerson.getPersonId());
78
+
79
+        // 先校验是否存在
80
+        boolean saved = iTaPostSaveService.checkSaved(taPerson.getPersonId(), postId);
81
+        if (saved) {
82
+            return ResponseBean.success("已收藏");
83
+        }
70
 
84
 
71
         if (iTaPostSaveService.save(taPostSave)){
85
         if (iTaPostSaveService.save(taPostSave)){
72
             return ResponseBean.success(taPostSave);
86
             return ResponseBean.success(taPostSave);
76
     }
90
     }
77
 
91
 
78
     /**
92
     /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
93
+     * 取消我的收藏
94
+     * @param postId  文章ID
81
      */
95
      */
82
-    @RequestMapping(value="/taPostSave/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taPostSaveDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaPostSaveService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
96
+    @RequestMapping(value="/ma/post-save", method= RequestMethod.DELETE)
97
+    @ApiOperation(value="取消我的收藏", notes = "取消我的收藏", httpMethod = "DELETE", response = ResponseBean.class)
98
+    public ResponseBean taPostSaveDelete(@ApiParam("文章ID") @RequestParam String postId) throws Exception{
99
+        TaPerson taPerson = getCurrentPerson();
100
+        TaPostSave taPostSave = iTaPostSaveService.getMyPostSave(taPerson.getPersonId(), postId);
101
+
102
+        if (null == taPostSave) {
103
+            return ResponseBean.success("已取消收藏");
89
         }
104
         }
90
-    }
91
 
105
 
92
-    /**
93
-     * 修改对象
94
-     * @param id  实体ID
95
-     * @param taPostSave 实体对象
96
-     * @return
97
-     */
98
-    @RequestMapping(value="/taPostSave/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taPostSaveUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaPostSave taPostSave) throws Exception{
106
+        taPostSave.setStatus(Constants.STATUS_DELETED);
107
+        taPostSave.setUpdateDate(LocalDateTime.now());
102
 
108
 
103
-        if (iTaPostSaveService.updateById(taPostSave)){
104
-            return ResponseBean.success(iTaPostSaveService.getById(id));
109
+        if(iTaPostSaveService.updateById(taPostSave)){
110
+            return ResponseBean.success("success");
105
         }else {
111
         }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
112
+            return ResponseBean.error("取消我的收藏失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
         }
113
         }
108
     }
114
     }
109
 
115
 
116
+//    /**
117
+//     * 修改对象
118
+//     * @param id  实体ID
119
+//     * @param taPostSave 实体对象
120
+//     * @return
121
+//     */
122
+//    @RequestMapping(value="/taPostSave/{id}",method= RequestMethod.PUT)
123
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
124
+//    public ResponseBean taPostSaveUpdate(@ApiParam("对象ID") @PathVariable Integer id,
125
+//                                        @ApiParam("更新内容") @RequestBody TaPostSave taPostSave) throws Exception{
126
+//
127
+//        if (iTaPostSaveService.updateById(taPostSave)){
128
+//            return ResponseBean.success(iTaPostSaveService.getById(id));
129
+//        }else {
130
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
131
+//        }
132
+//    }
133
+
110
     /**
134
     /**
111
      * 根据id查询对象
135
      * 根据id查询对象
112
      * @param id  实体ID
136
      * @param id  实体ID

+ 60
- 7
src/main/java/com/yunzhi/demo/controller/TaPostTestController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
10
+import com.yunzhi.demo.entity.TaPost;
11
+import com.yunzhi.demo.service.ITaPointsLogService;
12
+import com.yunzhi.demo.service.ITaPostService;
8
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
14
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
15
 import io.swagger.annotations.ApiParam;
11
 import org.slf4j.Logger;
16
 import org.slf4j.Logger;
12
 import org.slf4j.LoggerFactory;
17
 import org.slf4j.LoggerFactory;
13
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.PathVariable;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RequestMethod;
18
-import org.springframework.web.bind.annotation.RequestParam;
19
+import org.springframework.web.bind.annotation.*;
19
 import com.yunzhi.demo.service.ITaPostTestService;
20
 import com.yunzhi.demo.service.ITaPostTestService;
20
 import com.yunzhi.demo.entity.TaPostTest;
21
 import com.yunzhi.demo.entity.TaPostTest;
21
-import org.springframework.web.bind.annotation.RestController;
22
+
23
+import java.util.List;
22
 
24
 
23
 /**
25
 /**
24
  * <p>
26
  * <p>
37
     private final Logger logger = LoggerFactory.getLogger(TaPostTestController.class);
39
     private final Logger logger = LoggerFactory.getLogger(TaPostTestController.class);
38
 
40
 
39
     @Autowired
41
     @Autowired
40
-    public ITaPostTestService iTaPostTestService;
42
+    ITaPostTestService iTaPostTestService;
43
+
44
+    @Autowired
45
+    ITaPostService iTaPostService;
46
+
47
+    @Autowired
48
+    ITaPointsLogService iTaPointsLogService;
49
+
50
+    @PostMapping("/ma/answer-test")
51
+    public ResponseBean answerPostTest(@ApiParam("答题内容") @RequestBody List<TaPostTest> postTestList) throws Exception {
52
+        if (null == postTestList || postTestList.size() == 0) {
53
+            throw new Exception("未发现答题内容");
54
+        }
55
+
56
+        String postId = postTestList.get(0).getPostId();
57
+        TaPost taPost = iTaPostService.getById(postId);
58
+        if (null == taPost || Constants.STATUS_DELETED.equals(taPost.getStatus())) {
59
+            throw new Exception("答题文章内容不存在");
60
+        }
61
+
62
+        if (null != taPost.getAnswerNum() && taPost.getAnswerNum() > postTestList.size()) {
63
+            throw new Exception(String.format("当前知识需至少答 %d 题", taPost.getAnswerNum()));
64
+        }
65
+
66
+        boolean allRight = true;
67
+        for(int i = 0; i < postTestList.size(); i++) {
68
+            TaPostTest myTest = postTestList.get(i);
69
+            TaPostTest postTest = iTaPostTestService.getById(myTest.getSerialNo());
70
+            if (null == postTest || StringUtils.isEmpty(postTest.getCorrectAnswers())) {
71
+                throw new Exception("部分考题未设置正确答案, 请退出重试");
72
+            }
73
+
74
+            String myAnswer = myTest.getCorrectAnswers();
75
+            if (StringUtils.isEmpty(myAnswer)) {
76
+                throw new Exception("部分考题未作答");
77
+            }
78
+
79
+            boolean isRight = iTaPostTestService.checkAnswer(postTest.getCorrectAnswers(), myAnswer);
80
+            myTest.setIsRight(isRight);
81
+
82
+            allRight = allRight && isRight;
83
+        }
84
+
85
+        if (!allRight) {
86
+            return ResponseBean.error("答题失败", ResponseBean.ERROR_UNAVAILABLE, postTestList);
87
+        }
88
+
89
+        // 奖励积分
90
+        iTaPointsLogService.sendPoints(taPost, getCurrentPerson());
91
+
92
+        return ResponseBean.success("答题全对");
93
+    }
41
 
94
 
42
 
95
 
43
     /**
96
     /**

+ 21
- 21
src/main/java/com/yunzhi/demo/controller/TaReadLogController.java Vedi File

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
 import com.yunzhi.demo.common.ResponseBean;
7
 import com.yunzhi.demo.common.ResponseBean;
8
+import com.yunzhi.demo.common.StringUtils;
9
+import com.yunzhi.demo.entity.MyReadLog;
10
+import com.yunzhi.demo.entity.TaPerson;
8
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
13
 import io.swagger.annotations.ApiParam;
46
      * @param pageSize
49
      * @param pageSize
47
      * @return
50
      * @return
48
      */
51
      */
49
-    @RequestMapping(value="/taReadLog",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
52
+    @RequestMapping(value="/ma/read-log",method= RequestMethod.GET)
53
+    @ApiOperation(value="我的阅读记录", notes = "我的阅读记录", httpMethod = "GET", response = ResponseBean.class)
51
     public ResponseBean taReadLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
     public ResponseBean taReadLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-
54
-		    IPage<TaReadLog> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaReadLog> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57
-
58
-            IPage<TaReadLog> result = iTaReadLogService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
55
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
+        TaPerson taPerson = getCurrentPerson();
57
+        IPage<MyReadLog> pg = new Page<>(pageNum, pageSize);
58
+        IPage<MyReadLog> result = iTaReadLogService.getMyReadList(pg, taPerson.getPersonId());
59
+        return ResponseBean.success(result);
60
     }
60
     }
61
 
61
 
62
     /**
62
     /**
90
     }
90
     }
91
 
91
 
92
     /**
92
     /**
93
-     * 修改对象
94
-     * @param id  实体ID
93
+     * 更新文章阅读时长
95
      * @param taReadLog 实体对象
94
      * @param taReadLog 实体对象
96
      * @return
95
      * @return
97
      */
96
      */
98
-    @RequestMapping(value="/taReadLog/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taReadLogUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaReadLog taReadLog) throws Exception{
102
-
103
-        if (iTaReadLogService.updateById(taReadLog)){
104
-            return ResponseBean.success(iTaReadLogService.getById(id));
105
-        }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
97
+    @RequestMapping(value="/ma/read-log",method= RequestMethod.PUT)
98
+    @ApiOperation(value="更新文章阅读时长", notes = "更新文章阅读时长", httpMethod = "PUT", response = ResponseBean.class)
99
+    public ResponseBean taReadLogUpdate(@ApiParam("更新内容") @RequestBody TaReadLog taReadLog) throws Exception{
100
+        if (StringUtils.isEmpty(taReadLog.getPostId()) || null == taReadLog.getDuration()) {
101
+            throw new Exception("未设置更新文章及时长");
107
         }
102
         }
103
+
104
+        TaPerson taPerson = getCurrentPerson();
105
+        iTaReadLogService.updateDuration(taPerson.getPersonId(), taReadLog.getPostId(), taReadLog.getDuration());
106
+
107
+        return ResponseBean.success("更新成功");
108
     }
108
     }
109
 
109
 
110
     /**
110
     /**

+ 14
- 6
src/main/java/com/yunzhi/demo/controller/TdSchoolController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
11
 import org.slf4j.Logger;
13
 import org.slf4j.Logger;
12
 import org.slf4j.LoggerFactory;
14
 import org.slf4j.LoggerFactory;
13
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.PathVariable;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RequestMethod;
18
-import org.springframework.web.bind.annotation.RequestParam;
16
+import org.springframework.web.bind.annotation.*;
19
 import com.yunzhi.demo.service.ITdSchoolService;
17
 import com.yunzhi.demo.service.ITdSchoolService;
20
 import com.yunzhi.demo.entity.TdSchool;
18
 import com.yunzhi.demo.entity.TdSchool;
21
-import org.springframework.web.bind.annotation.RestController;
22
 
19
 
23
 /**
20
 /**
24
  * <p>
21
  * <p>
39
     @Autowired
36
     @Autowired
40
     public ITdSchoolService iTdSchoolService;
37
     public ITdSchoolService iTdSchoolService;
41
 
38
 
39
+    @GetMapping("/ma/school")
40
+    @ApiOperation(value="小程序学校字典", notes = "学校列表", httpMethod = "GET", response = ResponseBean.class)
41
+    public ResponseBean maSchoolList(@ApiParam(value = "名称", required = false) @RequestParam(value ="name", required = false) String name) throws Exception {
42
+        QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
43
+                .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
44
+                .eq("status", Constants.STATUS_NORMAL)
45
+                .orderByAsc("sort_no")
46
+                .orderByDesc("create_date");
47
+
48
+        return ResponseBean.success(iTdSchoolService.list(queryWrapper));
49
+    }
42
 
50
 
43
     /**
51
     /**
44
      * 分页查询列表
52
      * 分页查询列表

+ 16
- 6
src/main/java/com/yunzhi/demo/controller/TdSpecialtyController.java Vedi File

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.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
11
 import org.slf4j.Logger;
13
 import org.slf4j.Logger;
12
 import org.slf4j.LoggerFactory;
14
 import org.slf4j.LoggerFactory;
13
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.PathVariable;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RequestMethod;
18
-import org.springframework.web.bind.annotation.RequestParam;
16
+import org.springframework.web.bind.annotation.*;
19
 import com.yunzhi.demo.service.ITdSpecialtyService;
17
 import com.yunzhi.demo.service.ITdSpecialtyService;
20
 import com.yunzhi.demo.entity.TdSpecialty;
18
 import com.yunzhi.demo.entity.TdSpecialty;
21
-import org.springframework.web.bind.annotation.RestController;
22
 
19
 
23
 /**
20
 /**
24
  * <p>
21
  * <p>
39
     @Autowired
36
     @Autowired
40
     public ITdSpecialtyService iTdSpecialtyService;
37
     public ITdSpecialtyService iTdSpecialtyService;
41
 
38
 
39
+    @GetMapping("/ma/specialty")
40
+    @ApiOperation(value="小程序学科专业字典", notes = "学科专业", httpMethod = "GET", response = ResponseBean.class)
41
+    public ResponseBean maSchoolList(@ApiParam(value = "学校ID", required = false) @RequestParam(value ="school", required = false) String school,
42
+                                     @ApiParam(value = "名称", required = false) @RequestParam(value ="name", required = false) String name) throws Exception {
43
+        QueryWrapper<TdSpecialty> queryWrapper = new QueryWrapper<TdSpecialty>()
44
+                .eq(!StringUtils.isEmpty(school),"schoolId", school)
45
+                .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
46
+                .eq("status", Constants.STATUS_NORMAL)
47
+                .orderByAsc("sort_no")
48
+                .orderByDesc("create_date");
49
+
50
+        return ResponseBean.success(iTdSpecialtyService.list(queryWrapper));
51
+    }
42
 
52
 
43
     /**
53
     /**
44
      * 分页查询列表
54
      * 分页查询列表

+ 23
- 0
src/main/java/com/yunzhi/demo/entity/MyReadLog.java Vedi File

1
+package com.yunzhi.demo.entity;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+import lombok.EqualsAndHashCode;
7
+import lombok.experimental.Accessors;
8
+
9
+@Data
10
+@EqualsAndHashCode(callSuper = false)
11
+@Accessors(chain = true)
12
+@ApiModel(value="MyReadLog", description="我的阅读记录")
13
+public class MyReadLog extends TaPost {
14
+
15
+    @ApiModelProperty(value = "人员ID")
16
+    private String personId;
17
+
18
+    @ApiModelProperty(value = "时长 单位秒")
19
+    private Integer duration;
20
+
21
+    @ApiModelProperty(value = "状态")
22
+    private Integer readStatus;
23
+}

+ 18
- 3
src/main/java/com/yunzhi/demo/entity/TaPerson.java Vedi File

2
 
2
 
3
 import com.baomidou.mybatisplus.annotation.IdType;
3
 import com.baomidou.mybatisplus.annotation.IdType;
4
 import java.time.LocalDateTime;
4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5
 import com.baomidou.mybatisplus.annotation.TableId;
7
 import com.baomidou.mybatisplus.annotation.TableId;
6
 import java.io.Serializable;
8
 import java.io.Serializable;
7
 import io.swagger.annotations.ApiModel;
9
 import io.swagger.annotations.ApiModel;
51
     @ApiModelProperty(value = "邮箱")
53
     @ApiModelProperty(value = "邮箱")
52
     private String eMail;
54
     private String eMail;
53
 
55
 
54
-    @ApiModelProperty(value = "学校")
55
-    private String school;
56
+    @ApiModelProperty(value = "学校ID")
57
+    private String schoolId;
58
+
59
+    @ApiModelProperty(value = "学校名称")
60
+    @TableField(exist = false)
61
+    private String schoolName;
56
 
62
 
57
     @ApiModelProperty(value = "学界")
63
     @ApiModelProperty(value = "学界")
58
     private String schoolBatch;
64
     private String schoolBatch;
59
 
65
 
66
+    @ApiModelProperty(value = "专业ID")
67
+    private String specialtyId;
68
+
69
+    @ApiModelProperty(value = "专业名称")
70
+    @TableField(exist = false)
71
+    private String specialtyName;
72
+
60
     @ApiModelProperty(value = "学号")
73
     @ApiModelProperty(value = "学号")
61
     private String studentId;
74
     private String studentId;
62
 
75
 
69
     @ApiModelProperty(value = "更新时间")
82
     @ApiModelProperty(value = "更新时间")
70
     private LocalDateTime updateDate;
83
     private LocalDateTime updateDate;
71
 
84
 
72
-
85
+    @ApiModelProperty(value = "统计数据")
86
+    @TableField(exist = false)
87
+    private TaPersonData personData;
73
 }
88
 }

+ 1
- 1
src/main/java/com/yunzhi/demo/entity/TaPersonData.java Vedi File

33
     private Integer pointNum;
33
     private Integer pointNum;
34
 
34
 
35
     @ApiModelProperty(value = "学分")
35
     @ApiModelProperty(value = "学分")
36
-    private Integer creditNum;
36
+    private String creditNum;
37
 
37
 
38
     @ApiModelProperty(value = "收藏文章")
38
     @ApiModelProperty(value = "收藏文章")
39
     private Integer savedNum;
39
     private Integer savedNum;

+ 1
- 1
src/main/java/com/yunzhi/demo/entity/TaPointsLog.java Vedi File

37
     private Integer pointsNum;
37
     private Integer pointsNum;
38
 
38
 
39
     @ApiModelProperty(value = "学分")
39
     @ApiModelProperty(value = "学分")
40
-    private Integer creditNum;
40
+    private String creditNum;
41
 
41
 
42
     @ApiModelProperty(value = "兑换比例")
42
     @ApiModelProperty(value = "兑换比例")
43
     private String ratio;
43
     private String ratio;

+ 3
- 0
src/main/java/com/yunzhi/demo/entity/TaPost.java Vedi File

64
     @ApiModelProperty(value = "视频地址")
64
     @ApiModelProperty(value = "视频地址")
65
     private String videoUrl;
65
     private String videoUrl;
66
 
66
 
67
+    @ApiModelProperty(value = "视频封面")
68
+    private String videoPoster;
69
+
67
     @ApiModelProperty(value = "标签组")
70
     @ApiModelProperty(value = "标签组")
68
     private String tags;
71
     private String tags;
69
 
72
 

+ 4
- 1
src/main/java/com/yunzhi/demo/entity/TaPostTest.java Vedi File

1
 package com.yunzhi.demo.entity;
1
 package com.yunzhi.demo.entity;
2
 
2
 
3
 import com.baomidou.mybatisplus.annotation.IdType;
3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4
 import com.baomidou.mybatisplus.annotation.TableId;
5
 import com.baomidou.mybatisplus.annotation.TableId;
5
 import java.time.LocalDateTime;
6
 import java.time.LocalDateTime;
6
 import java.io.Serializable;
7
 import java.io.Serializable;
63
     @ApiModelProperty(value = "更新时间")
64
     @ApiModelProperty(value = "更新时间")
64
     private LocalDateTime updateDate;
65
     private LocalDateTime updateDate;
65
 
66
 
66
-
67
+    @ApiModelProperty("是否答对")
68
+    @TableField(exist = false)
69
+    private Boolean isRight;
67
 }
70
 }

+ 4
- 0
src/main/java/com/yunzhi/demo/entity/TaTopic.java Vedi File

26
 
26
 
27
     private static final long serialVersionUID = 1L;
27
     private static final long serialVersionUID = 1L;
28
 
28
 
29
+    @ApiModelProperty(value = "主键")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
29
     @ApiModelProperty(value = "对象")
33
     @ApiModelProperty(value = "对象")
30
     private String targetType;
34
     private String targetType;
31
 
35
 

+ 1
- 0
src/main/java/com/yunzhi/demo/mapper/TaPersonDataMapper.java Vedi File

15
 @Mapper
15
 @Mapper
16
 public interface TaPersonDataMapper extends BaseMapper<TaPersonData> {
16
 public interface TaPersonDataMapper extends BaseMapper<TaPersonData> {
17
 
17
 
18
+    int updatePoints(String personId, Integer points, String creditNum);
18
 }
19
 }

+ 3
- 0
src/main/java/com/yunzhi/demo/mapper/TaPostSaveMapper.java Vedi File

1
 package com.yunzhi.demo.mapper;
1
 package com.yunzhi.demo.mapper;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.entity.TaPost;
3
 import com.yunzhi.demo.entity.TaPostSave;
5
 import com.yunzhi.demo.entity.TaPostSave;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
15
 @Mapper
17
 @Mapper
16
 public interface TaPostSaveMapper extends BaseMapper<TaPostSave> {
18
 public interface TaPostSaveMapper extends BaseMapper<TaPostSave> {
17
 
19
 
20
+    IPage<TaPost> getMyPostSaveList(IPage<TaPost> pg, String personId);
18
 }
21
 }

+ 6
- 0
src/main/java/com/yunzhi/demo/mapper/TaReadLogMapper.java Vedi File

1
 package com.yunzhi.demo.mapper;
1
 package com.yunzhi.demo.mapper;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.entity.MyReadLog;
3
 import com.yunzhi.demo.entity.TaReadLog;
5
 import com.yunzhi.demo.entity.TaReadLog;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
16
 public interface TaReadLogMapper extends BaseMapper<TaReadLog> {
18
 public interface TaReadLogMapper extends BaseMapper<TaReadLog> {
17
 
19
 
18
     int countBy(String personId, String postId);
20
     int countBy(String personId, String postId);
21
+
22
+    IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId);
23
+
24
+    int updateDuration(String personId, String postId, Integer duration);
19
 }
25
 }

+ 3
- 0
src/main/java/com/yunzhi/demo/service/ITaPointsLogService.java Vedi File

1
 package com.yunzhi.demo.service;
1
 package com.yunzhi.demo.service;
2
 
2
 
3
+import com.yunzhi.demo.entity.TaPerson;
3
 import com.yunzhi.demo.entity.TaPointsLog;
4
 import com.yunzhi.demo.entity.TaPointsLog;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.yunzhi.demo.entity.TaPost;
5
 
7
 
6
 /**
8
 /**
7
  * <p>
9
  * <p>
13
  */
15
  */
14
 public interface ITaPointsLogService extends IService<TaPointsLog> {
16
 public interface ITaPointsLogService extends IService<TaPointsLog> {
15
 
17
 
18
+    void sendPoints(TaPost taPost, TaPerson taPerson);
16
 }
19
 }

+ 6
- 0
src/main/java/com/yunzhi/demo/service/ITaPostSaveService.java Vedi File

1
 package com.yunzhi.demo.service;
1
 package com.yunzhi.demo.service;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.entity.TaPost;
3
 import com.yunzhi.demo.entity.TaPostSave;
5
 import com.yunzhi.demo.entity.TaPostSave;
4
 import com.baomidou.mybatisplus.extension.service.IService;
6
 import com.baomidou.mybatisplus.extension.service.IService;
5
 
7
 
14
 public interface ITaPostSaveService extends IService<TaPostSave> {
16
 public interface ITaPostSaveService extends IService<TaPostSave> {
15
 
17
 
16
     boolean checkSaved(String personId, String postId);
18
     boolean checkSaved(String personId, String postId);
19
+
20
+    IPage<TaPost> getMyPostSaveList(IPage<TaPost> pg, String personId);
21
+
22
+    TaPostSave getMyPostSave(String personId, String postId);
17
 }
23
 }

+ 2
- 0
src/main/java/com/yunzhi/demo/service/ITaPostTestService.java Vedi File

18
     List<TaPostTest> getListByPostId(String postId);
18
     List<TaPostTest> getListByPostId(String postId);
19
 
19
 
20
     TaPostTest getRandRowBy(String postId);
20
     TaPostTest getRandRowBy(String postId);
21
+
22
+    boolean checkAnswer(String target, String answer);
21
 }
23
 }

+ 5
- 0
src/main/java/com/yunzhi/demo/service/ITaReadLogService.java Vedi File

1
 package com.yunzhi.demo.service;
1
 package com.yunzhi.demo.service;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.entity.MyReadLog;
3
 import com.yunzhi.demo.entity.TaReadLog;
5
 import com.yunzhi.demo.entity.TaReadLog;
4
 import com.baomidou.mybatisplus.extension.service.IService;
6
 import com.baomidou.mybatisplus.extension.service.IService;
5
 
7
 
13
  */
15
  */
14
 public interface ITaReadLogService extends IService<TaReadLog> {
16
 public interface ITaReadLogService extends IService<TaReadLog> {
15
 
17
 
18
+    IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId);
19
+int
20
+     updateDuration(String personId, String postId, Integer duration);
16
 }
21
 }

+ 71
- 0
src/main/java/com/yunzhi/demo/service/impl/TaPointsLogServiceImpl.java Vedi File

1
 package com.yunzhi.demo.service.impl;
1
 package com.yunzhi.demo.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.demo.common.Constants;
5
+import com.yunzhi.demo.common.StringUtils;
6
+import com.yunzhi.demo.entity.TaPerson;
3
 import com.yunzhi.demo.entity.TaPointsLog;
7
 import com.yunzhi.demo.entity.TaPointsLog;
8
+import com.yunzhi.demo.entity.TaPost;
9
+import com.yunzhi.demo.mapper.TaPersonDataMapper;
4
 import com.yunzhi.demo.mapper.TaPointsLogMapper;
10
 import com.yunzhi.demo.mapper.TaPointsLogMapper;
5
 import com.yunzhi.demo.service.ITaPointsLogService;
11
 import com.yunzhi.demo.service.ITaPointsLogService;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.scheduling.annotation.Async;
7
 import org.springframework.stereotype.Service;
16
 import org.springframework.stereotype.Service;
8
 
17
 
9
 /**
18
 /**
14
  * @author yansen
23
  * @author yansen
15
  * @since 2021-04-15
24
  * @since 2021-04-15
16
  */
25
  */
26
+@Slf4j
17
 @Service
27
 @Service
18
 public class TaPointsLogServiceImpl extends ServiceImpl<TaPointsLogMapper, TaPointsLog> implements ITaPointsLogService {
28
 public class TaPointsLogServiceImpl extends ServiceImpl<TaPointsLogMapper, TaPointsLog> implements ITaPointsLogService {
19
 
29
 
30
+    @Autowired
31
+    TaPersonDataMapper taPersonDataMapper;
32
+
33
+    @Async
34
+    @Override
35
+    public void sendPoints(TaPost taPost, TaPerson taPerson) {
36
+        if (null == taPost || null == taPerson) {
37
+            return;
38
+        }
39
+
40
+        Integer points = taPost.getPoints();
41
+        if (null == points) {
42
+            points = 0;
43
+        }
44
+
45
+        // 先验证是否已经获取过积分
46
+        TaPointsLog taPointsLog = getByPersonPost(taPerson.getPersonId(), taPost.getPostId());
47
+        if (null != taPointsLog) {
48
+            // 已经答过该题, 不处理
49
+            return;
50
+        }
51
+
52
+        // 查询积分-学分转换规则
53
+        // TODO 此处需要查询系统参数
54
+        String ratio = "1";
55
+        String creditNum = points.toString();
56
+
57
+        taPointsLog = new TaPointsLog();
58
+        taPointsLog.setPersonId(taPerson.getPersonId());
59
+        taPointsLog.setTargetType(Constants.RESOURCE_TYPE_POST);
60
+        taPointsLog.setTargetId(taPost.getPostId());
61
+        taPointsLog.setPointsNum(points);
62
+        taPointsLog.setRatio(ratio);
63
+        taPointsLog.setCreditNum(creditNum);
64
+
65
+        try {
66
+            save(taPointsLog);
67
+
68
+            // 累计入账户
69
+            taPersonDataMapper.updatePoints(taPerson.getPersonId(), points, creditNum);
70
+        } catch (Exception e) {
71
+            e.printStackTrace();
72
+
73
+            log.error(String.format("奖励[%s-%s] 阅读[%s-%s] 积分 %d 失败: %s",
74
+                    StringUtils.ifNull(taPerson.getName(), taPerson.getNickName()),
75
+                    taPerson.getPersonId(),
76
+                    taPost.getName(),
77
+                    taPost.getPostId(),
78
+                    points,
79
+                    e.getMessage()));
80
+        }
81
+    }
82
+
83
+    private TaPointsLog getByPersonPost(String personId, String postId) {
84
+        QueryWrapper<TaPointsLog> queryWrapper = new QueryWrapper<TaPointsLog>()
85
+                .eq("person_id", personId)
86
+                .eq("post_id", postId)
87
+                .eq("status", Constants.STATUS_NORMAL);
88
+
89
+        return getOne(queryWrapper);
90
+    }
20
 }
91
 }

+ 2
- 0
src/main/java/com/yunzhi/demo/service/impl/TaPostDataServiceImpl.java Vedi File

1
 package com.yunzhi.demo.service.impl;
1
 package com.yunzhi.demo.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.demo.common.Constants;
4
 import com.yunzhi.demo.entity.TaPerson;
5
 import com.yunzhi.demo.entity.TaPerson;
5
 import com.yunzhi.demo.entity.TaPostData;
6
 import com.yunzhi.demo.entity.TaPostData;
6
 import com.yunzhi.demo.entity.TaReadLog;
7
 import com.yunzhi.demo.entity.TaReadLog;
45
             TaReadLog taReadLog = new TaReadLog();
46
             TaReadLog taReadLog = new TaReadLog();
46
             taReadLog.setPostId(postId);
47
             taReadLog.setPostId(postId);
47
             taReadLog.setPersonId(taPerson.getPersonId());
48
             taReadLog.setPersonId(taPerson.getPersonId());
49
+            taReadLog.setStatus(Constants.READ_READY);
48
             taReadLogMapper.insert(taReadLog);
50
             taReadLogMapper.insert(taReadLog);
49
         }
51
         }
50
     }
52
     }

+ 23
- 3
src/main/java/com/yunzhi/demo/service/impl/TaPostSaveServiceImpl.java Vedi File

1
 package com.yunzhi.demo.service.impl;
1
 package com.yunzhi.demo.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.yunzhi.demo.common.Constants;
6
+import com.yunzhi.demo.entity.TaPost;
4
 import com.yunzhi.demo.entity.TaPostSave;
7
 import com.yunzhi.demo.entity.TaPostSave;
5
 import com.yunzhi.demo.mapper.TaPostSaveMapper;
8
 import com.yunzhi.demo.mapper.TaPostSaveMapper;
6
 import com.yunzhi.demo.service.ITaPostSaveService;
9
 import com.yunzhi.demo.service.ITaPostSaveService;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
+import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
9
 
13
 
10
 /**
14
 /**
17
  */
21
  */
18
 @Service
22
 @Service
19
 public class TaPostSaveServiceImpl extends ServiceImpl<TaPostSaveMapper, TaPostSave> implements ITaPostSaveService {
23
 public class TaPostSaveServiceImpl extends ServiceImpl<TaPostSaveMapper, TaPostSave> implements ITaPostSaveService {
24
+    @Autowired
25
+    TaPostSaveMapper taPostSaveMapper;
20
 
26
 
21
     @Override
27
     @Override
22
     public boolean checkSaved(String personId, String postId) {
28
     public boolean checkSaved(String personId, String postId) {
23
-        QueryWrapper<TaPostSave> queryWrapper = new QueryWrapper<TaPostSave>()
29
+        return count(queryByPersonAndPost(personId, postId)) > 0;
30
+    }
31
+
32
+    @Override
33
+    public IPage<TaPost> getMyPostSaveList(IPage<TaPost> pg, String personId) {
34
+        return taPostSaveMapper.getMyPostSaveList(pg, personId);
35
+    }
36
+
37
+    @Override
38
+    public TaPostSave getMyPostSave(String personId, String postId) {
39
+        return getOne(queryByPersonAndPost(personId, postId));
40
+    }
41
+
42
+    private QueryWrapper<TaPostSave> queryByPersonAndPost(String personId, String postId) {
43
+        return new QueryWrapper<TaPostSave>()
24
                 .eq("person_id", personId)
44
                 .eq("person_id", personId)
25
-                .eq("post_id", postId);
26
-        return count(queryWrapper) > 0;
45
+                .eq("post_id", postId)
46
+                .eq("status", Constants.STATUS_NORMAL);
27
     }
47
     }
28
 }
48
 }

+ 19
- 0
src/main/java/com/yunzhi/demo/service/impl/TaPostTestServiceImpl.java Vedi File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.yunzhi.demo.common.Constants;
4
 import com.yunzhi.demo.common.Constants;
5
+import com.yunzhi.demo.common.StringUtils;
5
 import com.yunzhi.demo.entity.TaPostTest;
6
 import com.yunzhi.demo.entity.TaPostTest;
6
 import com.yunzhi.demo.mapper.TaPostTestMapper;
7
 import com.yunzhi.demo.mapper.TaPostTestMapper;
7
 import com.yunzhi.demo.service.ITaPostTestService;
8
 import com.yunzhi.demo.service.ITaPostTestService;
9
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.stereotype.Service;
11
 import org.springframework.stereotype.Service;
11
 
12
 
13
+import java.util.Arrays;
12
 import java.util.List;
14
 import java.util.List;
13
 
15
 
14
 /**
16
 /**
38
     public TaPostTest getRandRowBy(String postId) {
40
     public TaPostTest getRandRowBy(String postId) {
39
         return taPostTestMapper.getRandRowBy(postId);
41
         return taPostTestMapper.getRandRowBy(postId);
40
     }
42
     }
43
+
44
+    /**
45
+     * 判断是否答题正确
46
+     * @param target
47
+     * @param answer
48
+     */
49
+    @Override
50
+    public boolean checkAnswer(String target, String answer) {
51
+        List<String> correctAnswers = Arrays.asList(target.split(","));
52
+        List<String> myAnswers = Arrays.asList(answer.split(","));
53
+
54
+        if (correctAnswers.size() != myAnswers.size()) {
55
+            return false;
56
+        }
57
+
58
+        return myAnswers.containsAll(correctAnswers);
59
+    }
41
 }
60
 }

+ 15
- 0
src/main/java/com/yunzhi/demo/service/impl/TaReadLogServiceImpl.java Vedi File

1
 package com.yunzhi.demo.service.impl;
1
 package com.yunzhi.demo.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.entity.MyReadLog;
3
 import com.yunzhi.demo.entity.TaReadLog;
5
 import com.yunzhi.demo.entity.TaReadLog;
4
 import com.yunzhi.demo.mapper.TaReadLogMapper;
6
 import com.yunzhi.demo.mapper.TaReadLogMapper;
5
 import com.yunzhi.demo.service.ITaReadLogService;
7
 import com.yunzhi.demo.service.ITaReadLogService;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.stereotype.Service;
10
 import org.springframework.stereotype.Service;
8
 
11
 
9
 /**
12
 /**
17
 @Service
20
 @Service
18
 public class TaReadLogServiceImpl extends ServiceImpl<TaReadLogMapper, TaReadLog> implements ITaReadLogService {
21
 public class TaReadLogServiceImpl extends ServiceImpl<TaReadLogMapper, TaReadLog> implements ITaReadLogService {
19
 
22
 
23
+    @Autowired
24
+    TaReadLogMapper taReadLogMapper;
25
+
26
+    @Override
27
+    public IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId) {
28
+        return taReadLogMapper.getMyReadList(pg, personId);
29
+    }
30
+
31
+    @Override
32
+    public int updateDuration(String personId, String postId, Integer duration) {
33
+        return taReadLogMapper.updateDuration(personId, postId, duration);
34
+    }
20
 }
35
 }

+ 7
- 0
src/main/resources/mapper/TaPersonDataMapper.xml Vedi File

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.yunzhi.demo.mapper.TaPersonDataMapper">
3
 <mapper namespace="com.yunzhi.demo.mapper.TaPersonDataMapper">
4
 
4
 
5
+    <update id="updatePoints">
6
+        UPDATE ta_person_data
7
+        SET point_num = point_num + ${points},
8
+            credit_num = credit_num + ${creditNum}
9
+        WHERE
10
+            person_id = #{personId}
11
+    </update>
5
 </mapper>
12
 </mapper>

+ 13
- 0
src/main/resources/mapper/TaPostSaveMapper.xml Vedi File

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.yunzhi.demo.mapper.TaPostSaveMapper">
3
 <mapper namespace="com.yunzhi.demo.mapper.TaPostSaveMapper">
4
 
4
 
5
+    <select id="getMyPostSaveList" resultType="com.yunzhi.demo.entity.TaPost">
6
+        SELECT
7
+            s.*
8
+        FROM
9
+            ta_post_save t
10
+                INNER JOIN ta_post s ON t.post_id = s.post_id
11
+        WHERE
12
+            t.person_id = #{personId}
13
+          AND t.`status` = 1
14
+          AND s.`status` > - 1
15
+        ORDER BY
16
+            t.create_date DESC
17
+    </select>
5
 </mapper>
18
 </mapper>

+ 24
- 0
src/main/resources/mapper/TaReadLogMapper.xml Vedi File

1
 <?xml version="1.0" encoding="UTF-8"?>
1
 <?xml version="1.0" encoding="UTF-8"?>
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.yunzhi.demo.mapper.TaReadLogMapper">
3
 <mapper namespace="com.yunzhi.demo.mapper.TaReadLogMapper">
4
+    <update id="updateDuration">
5
+        UPDATE ta_read_log
6
+        SET duration = duration + #{duration},
7
+            update_date = now()
8
+        WHERE
9
+            person_id = #{personId}
10
+          AND post_id = #{postId}
11
+    </update>
4
 
12
 
5
     <select id="countBy" resultType="java.lang.Integer">
13
     <select id="countBy" resultType="java.lang.Integer">
6
         SELECT
14
         SELECT
11
             t.person_id = #{personId}
19
             t.person_id = #{personId}
12
           AND t.post_id = #{postId}
20
           AND t.post_id = #{postId}
13
     </select>
21
     </select>
22
+    <select id="getMyReadList" resultType="com.yunzhi.demo.entity.MyReadLog">
23
+        SELECT
24
+            s.*,
25
+            t.person_id,
26
+            t.duration,
27
+            t.`status` AS read_status
28
+        FROM
29
+            ta_read_log t
30
+                INNER JOIN ta_post s ON t.post_id = s.post_id
31
+        WHERE
32
+            t.person_id = #{personId}
33
+          AND t.`status` > - 1
34
+          AND s.`status` > - 1
35
+        ORDER BY
36
+            t.create_date DESC
37
+    </select>
14
 </mapper>
38
 </mapper>