浏览代码

feat: add game over time

张延森 3 年前
父节点
当前提交
92a6aed0ec

+ 1
- 1
deploy/bootstrap 查看文件

2
 #
2
 #
3
 #
3
 #
4
 
4
 
5
-java -jar ./roundabout-0.0.4.jar
5
+java -jar ./roundabout-0.0.5.jar

+ 1
- 1
deploy/s.yml 查看文件

15
         name: roundabout-func
15
         name: roundabout-func
16
         description: 'Roundabout h5'
16
         description: 'Roundabout h5'
17
         ossBucket: yz-serverless
17
         ossBucket: yz-serverless
18
-        ossKey: honghe/roundabout-0.0.4.zip
18
+        ossKey: honghe/roundabout-0.0.5.zip
19
         handler: 'com.yunzhi.roundabout.Application::main'
19
         handler: 'com.yunzhi.roundabout.Application::main'
20
         memorySize: 1024
20
         memorySize: 1024
21
         timeout: 30
21
         timeout: 30

+ 1
- 1
pom.xml 查看文件

10
 	</parent>
10
 	</parent>
11
 	<groupId>com.yunzhi</groupId>
11
 	<groupId>com.yunzhi</groupId>
12
 	<artifactId>roundabout</artifactId>
12
 	<artifactId>roundabout</artifactId>
13
-	<version>0.0.4</version>
13
+	<version>0.0.5</version>
14
 	<name>roundabout</name>
14
 	<name>roundabout</name>
15
 	<description>华侨城-摩天轮</description>
15
 	<description>华侨城-摩天轮</description>
16
 	<properties>
16
 	<properties>

+ 13
- 0
src/main/java/com/yunzhi/roundabout/controller/TaPersonController.java 查看文件

143
     @RequestMapping(value="/wx/game/start",method= RequestMethod.POST)
143
     @RequestMapping(value="/wx/game/start",method= RequestMethod.POST)
144
     @ApiOperation(value="游戏开始", notes = "游戏开始", httpMethod = "POST", response = ResponseBean.class)
144
     @ApiOperation(value="游戏开始", notes = "游戏开始", httpMethod = "POST", response = ResponseBean.class)
145
     public ResponseBean gameStart(HttpServletRequest request) throws Exception{
145
     public ResponseBean gameStart(HttpServletRequest request) throws Exception{
146
+        LocalDateTime gameEndTime = iTaPersonService.getGameEndTime();
147
+        if (LocalDateTime.now().isAfter(gameEndTime)) {
148
+            // 游戏继续, 但是不会被计入成绩
149
+            return ResponseBean.success(null);
150
+        }
151
+
152
+
146
         TaPerson taPerson = currentPerson(request);
153
         TaPerson taPerson = currentPerson(request);
147
         long startTime = System.currentTimeMillis();
154
         long startTime = System.currentTimeMillis();
148
 
155
 
157
     @RequestMapping(value="/wx/game/over",method= RequestMethod.POST)
164
     @RequestMapping(value="/wx/game/over",method= RequestMethod.POST)
158
     @ApiOperation(value="游戏结束", notes = "游戏结束", httpMethod = "POST", response = ResponseBean.class)
165
     @ApiOperation(value="游戏结束", notes = "游戏结束", httpMethod = "POST", response = ResponseBean.class)
159
     public ResponseBean gameOver(HttpServletRequest request) throws Exception{
166
     public ResponseBean gameOver(HttpServletRequest request) throws Exception{
167
+        LocalDateTime gameEndTime = iTaPersonService.getGameEndTime();
168
+        if (LocalDateTime.now().isAfter(gameEndTime)) {
169
+            // 游戏继续, 但是不会被计入成绩
170
+            return ResponseBean.success(null);
171
+        }
172
+
160
         TaPerson taPerson = currentPerson(request);
173
         TaPerson taPerson = currentPerson(request);
161
         Long startTime = Long.parseLong(taPerson.getLastStart());
174
         Long startTime = Long.parseLong(taPerson.getLastStart());
162
         if (startTime == null) {
175
         if (startTime == null) {

+ 2
- 0
src/main/java/com/yunzhi/roundabout/mapper/TaPersonMapper.java 查看文件

23
     IPage<TaPerson> getPageBy(IPage<TaPerson> pg, @Param("start") LocalDateTime start, @Param("end")  LocalDateTime end);
23
     IPage<TaPerson> getPageBy(IPage<TaPerson> pg, @Param("start") LocalDateTime start, @Param("end")  LocalDateTime end);
24
 
24
 
25
     List<TaPerson> getListBy(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
25
     List<TaPerson> getListBy(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
26
+
27
+    String getGameEndTime();
26
 }
28
 }

+ 2
- 0
src/main/java/com/yunzhi/roundabout/service/ITaPersonService.java 查看文件

26
     IPage<TaPerson> getPageBy(IPage<TaPerson> pg, LocalDateTime start, LocalDateTime end);
26
     IPage<TaPerson> getPageBy(IPage<TaPerson> pg, LocalDateTime start, LocalDateTime end);
27
 
27
 
28
     List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end);
28
     List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end);
29
+
30
+    LocalDateTime getGameEndTime();
29
 }
31
 }

+ 7
- 0
src/main/java/com/yunzhi/roundabout/service/impl/TaPersonServiceImpl.java 查看文件

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.yunzhi.roundabout.common.DateUtils;
6
 import com.yunzhi.roundabout.entity.TaPerson;
7
 import com.yunzhi.roundabout.entity.TaPerson;
7
 import com.yunzhi.roundabout.mapper.TaPersonMapper;
8
 import com.yunzhi.roundabout.mapper.TaPersonMapper;
8
 import com.yunzhi.roundabout.service.ITaPersonService;
9
 import com.yunzhi.roundabout.service.ITaPersonService;
70
     public List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end) {
71
     public List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end) {
71
         return baseMapper.getListBy(start, end);
72
         return baseMapper.getListBy(start, end);
72
     }
73
     }
74
+
75
+    @Override
76
+    public LocalDateTime getGameEndTime() {
77
+        String dtStr = baseMapper.getGameEndTime();
78
+        return DateUtils.from(dtStr + "+0800", "yyyy-MM-dd HH:mm:ssX");
79
+    }
73
 }
80
 }

+ 8
- 0
src/main/resources/mapper/TaPersonMapper.xml 查看文件

21
     <select id="getListBy" resultType="com.yunzhi.roundabout.entity.TaPerson">
21
     <select id="getListBy" resultType="com.yunzhi.roundabout.entity.TaPerson">
22
         <include refid="listSQL"></include>
22
         <include refid="listSQL"></include>
23
     </select>
23
     </select>
24
+    <select id="getGameEndTime" resultType="java.lang.String">
25
+        SELECT
26
+            t.param_value
27
+        FROM
28
+            `sys_param_setting` t
29
+        WHERE
30
+            t.param__code = 'game_end_date'
31
+    </select>
24
 </mapper>
32
 </mapper>