张延森 3 years ago
parent
commit
1e9072e827

+ 1
- 1
deploy/template.yml View File

11
       Properties:
11
       Properties:
12
         Handler: com.yunzhi.demo.SpringApplication::main
12
         Handler: com.yunzhi.demo.SpringApplication::main
13
         Runtime: custom
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
         MemorySize: 1024
15
         MemorySize: 1024
16
         Timeout: 30
16
         Timeout: 30
17
         InitializationTimeout: 30
17
         InitializationTimeout: 30

+ 1
- 1
pom.xml View File

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

+ 7
- 0
src/main/java/com/yunzhi/demo/controller/TaPostTestController.java View File

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

+ 21
- 1
src/main/java/com/yunzhi/demo/controller/TaStudentController.java View File

72
             throw new Exception("校验人员信息失败");
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
             TaStudent origin = iTaStudentService.getByPersonId(currentPerson.getPersonId());
97
             TaStudent origin = iTaStudentService.getByPersonId(currentPerson.getPersonId());
78
             if (null != origin) {
98
             if (null != origin) {
79
                 taStudent.setStudentId(origin.getStudentId());
99
                 taStudent.setStudentId(origin.getStudentId());

+ 1
- 1
src/main/java/com/yunzhi/demo/mapper/TaReadLogMapper.java View File

20
 @Mapper
20
 @Mapper
21
 public interface TaReadLogMapper extends BaseMapper<TaReadLog> {
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
     IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId);
25
     IPage<MyReadLog> getMyReadList(IPage<MyReadLog> pg, String personId);
26
 
26
 

+ 4
- 0
src/main/java/com/yunzhi/demo/service/ITaReadLogService.java View File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.demo.entity.MyReadLog;
4
 import com.yunzhi.demo.entity.MyReadLog;
5
+import com.yunzhi.demo.entity.TaPerson;
6
+import com.yunzhi.demo.entity.TaPost;
5
 import com.yunzhi.demo.entity.TaReadLog;
7
 import com.yunzhi.demo.entity.TaReadLog;
6
 import com.baomidou.mybatisplus.extension.service.IService;
8
 import com.baomidou.mybatisplus.extension.service.IService;
7
 
9
 
27
     List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate);
29
     List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate);
28
 
30
 
29
     IPage<TaReadLog> getReadList(IPage<TaReadLog> pg, String personId);
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 View File

43
     @Override
43
     @Override
44
     public void recordBy(String postId, TaPerson taPerson) {
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
         int addPv = 1;
49
         int addPv = 1;
50
         int addUv = readed ? 0 : 1;
50
         int addUv = readed ? 0 : 1;
59
 
59
 
60
         // 如果当前人员以前未读过
60
         // 如果当前人员以前未读过
61
         if (!readed) {
61
         if (!readed) {
62
-            taReadLog = new TaReadLog();
62
+            TaReadLog taReadLog = new TaReadLog();
63
             taReadLog.setPostId(postId);
63
             taReadLog.setPostId(postId);
64
             taReadLog.setPersonId(taPerson.getPersonId());
64
             taReadLog.setPersonId(taPerson.getPersonId());
65
             taReadLog.setStatus(Constants.READ_READY);
65
             taReadLog.setStatus(Constants.READ_READY);
66
             taReadLogMapper.insert(taReadLog);
66
             taReadLogMapper.insert(taReadLog);
67
         } else {
67
         } else {
68
+            TaReadLog taReadLog = logList.get(0);
68
             taReadLog.setUpdateDate(LocalDateTime.now());
69
             taReadLog.setUpdateDate(LocalDateTime.now());
69
             taReadLogMapper.updateById(taReadLog);
70
             taReadLogMapper.updateById(taReadLog);
70
         }
71
         }

+ 21
- 2
src/main/java/com/yunzhi/demo/service/impl/TaReadLogServiceImpl.java View 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;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.demo.common.Constants;
4
 import com.yunzhi.demo.common.DateUtils;
5
 import com.yunzhi.demo.common.DateUtils;
5
 import com.yunzhi.demo.entity.MyReadLog;
6
 import com.yunzhi.demo.entity.MyReadLog;
7
+import com.yunzhi.demo.entity.TaPerson;
8
+import com.yunzhi.demo.entity.TaPost;
6
 import com.yunzhi.demo.entity.TaReadLog;
9
 import com.yunzhi.demo.entity.TaReadLog;
7
 import com.yunzhi.demo.mapper.TaReadLogMapper;
10
 import com.yunzhi.demo.mapper.TaReadLogMapper;
8
 import com.yunzhi.demo.service.ITaReadLogService;
11
 import com.yunzhi.demo.service.ITaReadLogService;
9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.scheduling.annotation.Async;
11
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
12
 
16
 
13
 import java.time.LocalDateTime;
17
 import java.time.LocalDateTime;
42
     public List<Map<String, Integer>> getIndexPostPV(String startDate, String endDate) {
46
     public List<Map<String, Integer>> getIndexPostPV(String startDate, String endDate) {
43
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
47
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
44
         LocalDateTime dt2 = DateUtils.from(endDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
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
         return taReadLogMapper.getIndexPostPV(startDate, endDate, days);
50
         return taReadLogMapper.getIndexPostPV(startDate, endDate, days);
47
     }
51
     }
48
 
52
 
50
     public List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate) {
54
     public List<Map<String, Integer>> getIndexPostUV(String startDate, String endDate) {
51
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
55
         LocalDateTime dt1 = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
52
         LocalDateTime dt2 = DateUtils.from(endDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
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
         return taReadLogMapper.getIndexPostUV(startDate, endDate, days);
58
         return taReadLogMapper.getIndexPostUV(startDate, endDate, days);
55
     }
59
     }
56
 
60
 
59
         return taReadLogMapper.getPersonReadList(pg, personId);
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 View File

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

+ 2
- 1
src/main/resources/mapper/TaReadLogMapper.xml View File

25
         WHERE
25
         WHERE
26
             t.person_id = #{personId}
26
             t.person_id = #{personId}
27
           AND t.post_id = #{postId}
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
     </select>
30
     </select>
30
     <select id="getMyReadList" resultType="com.yunzhi.demo.entity.MyReadLog">
31
     <select id="getMyReadList" resultType="com.yunzhi.demo.entity.MyReadLog">
31
         SELECT
32
         SELECT