张延森 пре 3 година
родитељ
комит
1e9072e827

+ 1
- 1
deploy/template.yml Прегледај датотеку

@@ -11,7 +11,7 @@ Resources:
11 11
       Properties:
12 12
         Handler: com.yunzhi.demo.SpringApplication::main
13 13
         Runtime: custom
14
-        CodeUri: 'oss://yz-serverless/medical-plat/medical-plat-0.0.3.zip'
14
+        CodeUri: 'oss://yz-serverless/medical-plat/medical-plat-0.0.4.zip'
15 15
         MemorySize: 1024
16 16
         Timeout: 30
17 17
         InitializationTimeout: 30

+ 1
- 1
pom.xml Прегледај датотеку

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.yunzhi</groupId>
12 12
 	<artifactId>medical-plat</artifactId>
13
-	<version>0.0.3</version>
13
+	<version>0.0.4</version>
14 14
 	<name>medical-plat</name>
15 15
 	<description>Demo project for Spring Boot</description>
16 16
 

+ 7
- 0
src/main/java/com/yunzhi/demo/controller/TaPostTestController.java Прегледај датотеку

@@ -11,6 +11,7 @@ import com.yunzhi.demo.common.StringUtils;
11 11
 import com.yunzhi.demo.entity.TaPost;
12 12
 import com.yunzhi.demo.service.ITaPointsLogService;
13 13
 import com.yunzhi.demo.service.ITaPostService;
14
+import com.yunzhi.demo.service.ITaReadLogService;
14 15
 import io.swagger.annotations.Api;
15 16
 import io.swagger.annotations.ApiOperation;
16 17
 import io.swagger.annotations.ApiParam;
@@ -48,6 +49,9 @@ public class TaPostTestController extends BaseController {
48 49
     @Autowired
49 50
     ITaPointsLogService iTaPointsLogService;
50 51
 
52
+    @Autowired
53
+    ITaReadLogService iTaReadLogService;
54
+
51 55
     @PostMapping("/ma/answer-test")
52 56
     public ResponseBean answerPostTest(@ApiParam("答题内容") @RequestBody String paramStr) throws Exception {
53 57
         List<TaPostTest> postTestList = JSONObject.parseArray(paramStr, TaPostTest.class);
@@ -88,6 +92,9 @@ public class TaPostTestController extends BaseController {
88 92
             return ResponseBean.error("部分题目作答错误, 请再接再厉!", ResponseBean.ERROR_UNAVAILABLE, postTestList);
89 93
         }
90 94
 
95
+        // 读取记录
96
+        iTaReadLogService.updateReadLog(taPost, getCurrentPerson());
97
+
91 98
         // 奖励积分
92 99
         iTaPointsLogService.sendPoints(taPost, getCurrentPerson());
93 100
 

+ 21
- 1
src/main/java/com/yunzhi/demo/controller/TaStudentController.java Прегледај датотеку

@@ -72,8 +72,28 @@ public class TaStudentController extends BaseController {
72 72
             throw new Exception("校验人员信息失败");
73 73
         }
74 74
 
75
+        if (StringUtils.isEmpty(taStudent.getName())) {
76
+            throw new Exception("姓名不能为空");
77
+        }
78
+
79
+        if (StringUtils.isEmpty(taStudent.getPhone())) {
80
+            throw new Exception("手机号不能为空");
81
+        }
82
+
83
+        if (StringUtils.isEmpty(taStudent.getSchoolId())) {
84
+            throw new Exception("学校不能为空");
85
+        }
86
+
87
+        if (StringUtils.isEmpty(taStudent.getSpecialtyId())) {
88
+            throw new Exception("专业不能为空");
89
+        }
90
+
91
+        if (StringUtils.isEmpty(taStudent.getStudentNo())) {
92
+            throw new Exception("学号不能为空");
93
+        }
94
+
75 95
         // 解决人员跟学生映射问题
76
-        if (!StringUtils.isEmpty(taStudent.getStudentId())) {
96
+        if (StringUtils.isEmpty(taStudent.getStudentId())) {
77 97
             TaStudent origin = iTaStudentService.getByPersonId(currentPerson.getPersonId());
78 98
             if (null != origin) {
79 99
                 taStudent.setStudentId(origin.getStudentId());

+ 1
- 1
src/main/java/com/yunzhi/demo/mapper/TaReadLogMapper.java Прегледај датотеку

@@ -20,7 +20,7 @@ import java.util.Map;
20 20
 @Mapper
21 21
 public interface TaReadLogMapper extends BaseMapper<TaReadLog> {
22 22
 
23
-    TaReadLog getReadBy(String personId, String postId);
23
+    List<TaReadLog> getReadBy(String personId, String postId);
24 24
 
25 25
     IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId);
26 26
 

+ 4
- 0
src/main/java/com/yunzhi/demo/service/ITaReadLogService.java Прегледај датотеку

@@ -2,6 +2,8 @@ package com.yunzhi.demo.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.demo.entity.MyReadLog;
5
+import com.yunzhi.demo.entity.TaPerson;
6
+import com.yunzhi.demo.entity.TaPost;
5 7
 import com.yunzhi.demo.entity.TaReadLog;
6 8
 import com.baomidou.mybatisplus.extension.service.IService;
7 9
 
@@ -27,4 +29,6 @@ int
27 29
     List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate);
28 30
 
29 31
     IPage<TaReadLog> getReadList(IPage<TaReadLog> pg, String personId);
32
+
33
+    void updateReadLog(TaPost taPost, TaPerson currentPerson);
30 34
 }

+ 4
- 3
src/main/java/com/yunzhi/demo/service/impl/TaPostDataServiceImpl.java Прегледај датотеку

@@ -43,8 +43,8 @@ public class TaPostDataServiceImpl extends ServiceImpl<TaPostDataMapper, TaPostD
43 43
     @Override
44 44
     public void recordBy(String postId, TaPerson taPerson) {
45 45
         // 先查询当前人员以前有没有阅读过
46
-        TaReadLog taReadLog = taReadLogMapper.getReadBy(taPerson.getPersonId(), postId);
47
-        boolean readed = null != taReadLog;
46
+        List<TaReadLog> logList = taReadLogMapper.getReadBy(taPerson.getPersonId(), postId);
47
+        boolean readed = null != logList && logList.size() > 0;
48 48
 
49 49
         int addPv = 1;
50 50
         int addUv = readed ? 0 : 1;
@@ -59,12 +59,13 @@ public class TaPostDataServiceImpl extends ServiceImpl<TaPostDataMapper, TaPostD
59 59
 
60 60
         // 如果当前人员以前未读过
61 61
         if (!readed) {
62
-            taReadLog = new TaReadLog();
62
+            TaReadLog taReadLog = new TaReadLog();
63 63
             taReadLog.setPostId(postId);
64 64
             taReadLog.setPersonId(taPerson.getPersonId());
65 65
             taReadLog.setStatus(Constants.READ_READY);
66 66
             taReadLogMapper.insert(taReadLog);
67 67
         } else {
68
+            TaReadLog taReadLog = logList.get(0);
68 69
             taReadLog.setUpdateDate(LocalDateTime.now());
69 70
             taReadLogMapper.updateById(taReadLog);
70 71
         }

+ 21
- 2
src/main/java/com/yunzhi/demo/service/impl/TaReadLogServiceImpl.java Прегледај датотеку

@@ -1,13 +1,17 @@
1 1
 package com.yunzhi.demo.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.common.Constants;
4 5
 import com.yunzhi.demo.common.DateUtils;
5 6
 import com.yunzhi.demo.entity.MyReadLog;
7
+import com.yunzhi.demo.entity.TaPerson;
8
+import com.yunzhi.demo.entity.TaPost;
6 9
 import com.yunzhi.demo.entity.TaReadLog;
7 10
 import com.yunzhi.demo.mapper.TaReadLogMapper;
8 11
 import com.yunzhi.demo.service.ITaReadLogService;
9 12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10 13
 import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.scheduling.annotation.Async;
11 15
 import org.springframework.stereotype.Service;
12 16
 
13 17
 import java.time.LocalDateTime;
@@ -42,7 +46,7 @@ public class TaReadLogServiceImpl extends ServiceImpl<TaReadLogMapper, TaReadLog
42 46
     public List<Map<String, Integer>> getIndexPostPV(String startDate, String endDate) {
43 47
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
44 48
         LocalDateTime dt2 = DateUtils.from(endDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
45
-        long days = DateUtils.daysBetween(dt1, dt2);
49
+        long days = DateUtils.daysBetween(dt1, dt2) + 1;
46 50
         return taReadLogMapper.getIndexPostPV(startDate, endDate, days);
47 51
     }
48 52
 
@@ -50,7 +54,7 @@ public class TaReadLogServiceImpl extends ServiceImpl<TaReadLogMapper, TaReadLog
50 54
     public List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate) {
51 55
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
52 56
         LocalDateTime dt2 = DateUtils.from(endDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
53
-        long days = DateUtils.daysBetween(dt1, dt2);
57
+        long days = DateUtils.daysBetween(dt1, dt2) + 1;
54 58
         return taReadLogMapper.getIndexPostUV(startDate, endDate, days);
55 59
     }
56 60
 
@@ -59,4 +63,19 @@ public class TaReadLogServiceImpl extends ServiceImpl<TaReadLogMapper, TaReadLog
59 63
         return taReadLogMapper.getPersonReadList(pg, personId);
60 64
     }
61 65
 
66
+    @Async
67
+    @Override
68
+    public void updateReadLog(TaPost taPost, TaPerson currentPerson) {
69
+        try {
70
+            List<TaReadLog> logList = taReadLogMapper.getReadBy(currentPerson.getPersonId(), taPost.getPostId());
71
+            TaReadLog taReadLog = logList.get(0);
72
+
73
+            taReadLog.setStatus(Constants.STATUS_NORMAL);
74
+            taReadLog.setUpdateDate(LocalDateTime.now());
75
+            updateById(taReadLog);
76
+        } catch (Exception e) {
77
+            e.printStackTrace();
78
+        }
79
+    }
80
+
62 81
 }

+ 1
- 1
src/main/resources/application.yml Прегледај датотеку

@@ -1,6 +1,6 @@
1 1
 ###
2 2
 server:
3
-  port: 8080
3
+  port: 8081
4 4
   servlet:
5 5
     context-path: /api
6 6
 

+ 2
- 1
src/main/resources/mapper/TaReadLogMapper.xml Прегледај датотеку

@@ -25,7 +25,8 @@
25 25
         WHERE
26 26
             t.person_id = #{personId}
27 27
           AND t.post_id = #{postId}
28
-          AND t.status = 1
28
+          AND t.status &gt; -1
29
+        ORDER BY t.create_date DESC
29 30
     </select>
30 31
     <select id="getMyReadList" resultType="com.yunzhi.demo.entity.MyReadLog">
31 32
         SELECT