Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
antai-sport
antai-sport-http-server
Commits
d4aff474
Commit
d4aff474
authored
Apr 22, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步通知游戏go服务器日常赛变更
parent
aa2c56f2
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
95 additions
and
9 deletions
+95
-9
RestTemplateConfiguration.java
.../http/server/common/config/RestTemplateConfiguration.java
+30
-0
ManagementApiApplication.java
.../http/server/management/api/ManagementApiApplication.java
+2
-0
SimpleMatchChangeNotifyService.java
...s/simplematch/service/SimpleMatchChangeNotifyService.java
+30
-0
SimpleMatchService.java
.../api/business/simplematch/service/SimpleMatchService.java
+4
-0
BaseConfig.java
...i/sport/http/server/management/api/config/BaseConfig.java
+15
-3
application-dev.yaml
management-api/src/main/resources/application-dev.yaml
+3
-1
application-local.yaml
management-api/src/main/resources/application-local.yaml
+3
-1
application-prod.yaml
management-api/src/main/resources/application-prod.yaml
+3
-1
application-test.yaml
management-api/src/main/resources/application-test.yaml
+3
-1
MatchBicycleService.java
...i/business/match/bicycle/service/MatchBicycleService.java
+2
-2
No files found.
common/src/main/java/com/antai/sport/http/server/common/config/RestTemplateConfiguration.java
0 → 100644
View file @
d4aff474
package
com
.
antai
.
sport
.
http
.
server
.
common
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.web.client.RestTemplate
;
import
java.nio.charset.StandardCharsets
;
@Configuration
public
class
RestTemplateConfiguration
{
@Bean
public
RestTemplate
restTemplate
()
{
SimpleClientHttpRequestFactory
requestFactory
=
new
SimpleClientHttpRequestFactory
();
// 设置连接超时,单位毫秒
requestFactory
.
setConnectTimeout
(
3000
);
//设置读取超时
requestFactory
.
setReadTimeout
(
10000
);
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
setRequestFactory
(
requestFactory
);
restTemplate
.
getMessageConverters
().
add
(
new
StringHttpMessageConverter
(
StandardCharsets
.
UTF_8
)
);
return
restTemplate
;
}
}
\ No newline at end of file
management-api/src/main/java/com/antai/sport/http/server/management/api/ManagementApiApplication.java
View file @
d4aff474
...
...
@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
springfox.documentation.oas.annotations.EnableOpenApi
;
/**
...
...
@@ -15,6 +16,7 @@ import springfox.documentation.oas.annotations.EnableOpenApi;
@SpringBootApplication
@EnableOpenApi
@EnableAsync
@ComponentScan
(
value
=
"com.antai"
)
@MapperScan
(
"com.antai.**.mapper"
)
public
class
ManagementApiApplication
{
...
...
management-api/src/main/java/com/antai/sport/http/server/management/api/business/simplematch/service/SimpleMatchChangeNotifyService.java
0 → 100644
View file @
d4aff474
package
com
.
antai
.
sport
.
http
.
server
.
management
.
api
.
business
.
simplematch
.
service
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
@Service
@Slf4j
public
class
SimpleMatchChangeNotifyService
{
@Value
(
"${simple-match-change-notify-url}"
)
private
String
simpleMatchChangeNotifyUrl
;
@Resource
private
RestTemplate
restTemplate
;
@Async
(
"asyncTaskExecutor"
)
public
void
notifyGameServerSimpleMatchChange
()
{
log
.
info
(
"异步通知比赛列表变更"
);
String
result
=
"执行失败"
;
try
{
result
=
restTemplate
.
getForObject
(
simpleMatchChangeNotifyUrl
,
String
.
class
);
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
}
log
.
info
(
"比赛变更结果:"
+
result
);
}
}
management-api/src/main/java/com/antai/sport/http/server/management/api/business/simplematch/service/SimpleMatchService.java
View file @
d4aff474
...
...
@@ -39,6 +39,8 @@ public class SimpleMatchService {
private
MapPathMapper
mapPathMapper
;
@Resource
private
SimpleMatchConverter
simpleMatchConverter
;
@Resource
private
SimpleMatchChangeNotifyService
simpleMatchChangeNotifyService
;
public
SimpleMatchListResponseDTO
getMatchList
(
SimpleMatchListRequestDTO
param
)
{
Page
<
SimpleMatchListVO
>
pageParam
=
new
Page
<>(
param
.
getPageNo
(),
param
.
getPageSize
());
...
...
@@ -72,6 +74,7 @@ public class SimpleMatchService {
simpleMatch
.
setStatus
(
10
);
}
simpleMatchMapper
.
updateById
(
simpleMatch
);
simpleMatchChangeNotifyService
.
notifyGameServerSimpleMatchChange
();
}
public
SimpleMatchResponseDTO
getSimpleMatch
(
Long
matchId
)
{
...
...
@@ -122,6 +125,7 @@ public class SimpleMatchService {
simpleMatch
.
setStatus
(
10
);
simpleMatchMapper
.
insert
(
simpleMatch
);
}
simpleMatchChangeNotifyService
.
notifyGameServerSimpleMatchChange
();
}
}
management-api/src/main/java/com/antai/sport/http/server/management/api/config/BaseConfig.java
View file @
d4aff474
...
...
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerIntercept
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.task.AsyncTaskExecutor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
...
...
@@ -68,9 +70,9 @@ public class BaseConfig implements WebMvcConfigurer {
}
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
(){
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
PaginationInnerInterceptor
innerInterceptor
=
new
PaginationInnerInterceptor
();
PaginationInnerInterceptor
innerInterceptor
=
new
PaginationInnerInterceptor
();
innerInterceptor
.
setDbType
(
DbType
.
MYSQL
);
innerInterceptor
.
setOverflow
(
true
);
interceptor
.
addInnerInterceptor
(
new
OptimisticLockerInnerInterceptor
());
...
...
@@ -79,7 +81,17 @@ public class BaseConfig implements WebMvcConfigurer {
}
@Bean
public
ConfigurationCustomizer
configurationCustomizer
(){
public
ConfigurationCustomizer
configurationCustomizer
()
{
return
mybatisConfiguration
->
mybatisConfiguration
.
setUseGeneratedShortKey
(
false
);
}
@Bean
(
"asyncTaskExecutor"
)
public
AsyncTaskExecutor
asyncTaskExecutor
()
{
ThreadPoolTaskExecutor
asyncTaskExecutor
=
new
ThreadPoolTaskExecutor
();
asyncTaskExecutor
.
setMaxPoolSize
(
50
);
asyncTaskExecutor
.
setCorePoolSize
(
20
);
asyncTaskExecutor
.
setThreadNamePrefix
(
"异步线程-"
);
asyncTaskExecutor
.
initialize
();
return
asyncTaskExecutor
;
}
}
management-api/src/main/resources/application-dev.yaml
View file @
d4aff474
...
...
@@ -20,3 +20,5 @@ aliyun:
endpoint
:
https://oss-cn-beijing.aliyuncs.com
bucket-name
:
antai-sport
cdn-url
:
http://antai-sport.oss-cn-beijing.aliyuncs.com/
simple-match-change-notify-url
:
http://47.100.168.51:3281/api/match/update
\ No newline at end of file
management-api/src/main/resources/application-local.yaml
View file @
d4aff474
...
...
@@ -19,3 +19,5 @@ aliyun:
endpoint
:
https://oss-cn-beijing.aliyuncs.com
bucket-name
:
antai-sport
cdn-url
:
http://antai-sport.oss-cn-beijing.aliyuncs.com/
simple-match-change-notify-url
:
http://47.100.168.51:3281/api/match/update
\ No newline at end of file
management-api/src/main/resources/application-prod.yaml
View file @
d4aff474
...
...
@@ -20,3 +20,5 @@ aliyun:
endpoint
:
https://oss-cn-shanghai.aliyuncs.com
bucket-name
:
shanghaijingji-sport-prod
cdn-url
:
https://shanghaijingji-sport-prod.oss-cn-shanghai.aliyuncs.com/
simple-match-change-notify-url
:
http://127.0.0.1:3281/api/match/update
\ No newline at end of file
management-api/src/main/resources/application-test.yaml
View file @
d4aff474
...
...
@@ -20,3 +20,5 @@ aliyun:
endpoint
:
https://oss-cn-beijing.aliyuncs.com
bucket-name
:
antai-sport
cdn-url
:
http://antai-sport.oss-cn-beijing.aliyuncs.com/
simple-match-change-notify-url
:
http://47.100.168.51:3281/api/match/update
\ No newline at end of file
mobile-api/src/main/java/com/antai/sport/http/server/mobile/api/business/match/bicycle/service/MatchBicycleService.java
View file @
d4aff474
...
...
@@ -2,10 +2,10 @@ package com.antai.sport.http.server.mobile.api.business.match.bicycle.service;
import
com.antai.sport.http.server.common.exception.BusinessException
;
import
com.antai.sport.http.server.constants.DeleteStatus
;
import
com.antai.sport.http.server.mobile.api.business.match.bicycle.mapper.MatchBicycleBusinessMapper
;
import
com.antai.sport.http.server.mobile.api.business.match.bicycle.dto.DtoMatchAutoCreate
;
import
com.antai.sport.http.server.mobile.api.business.match.bicycle.dto.ReqMatchBicycleSave
;
import
com.antai.sport.http.server.mobile.api.business.match.bicycle.dto.RespMatchBicycleList
;
import
com.antai.sport.http.server.mobile.api.business.match.bicycle.mapper.MatchBicycleBusinessMapper
;
import
com.antai.sport.http.server.repository.match.entity.MatchBicycle
;
import
com.antai.sport.http.server.repository.match.mapper.MatchBicycleMapper
;
import
com.antai.sport.http.server.repository.sport.entity.SportUser
;
...
...
@@ -102,7 +102,7 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
}
//调用游戏服务端的暂停接口
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
getForObject
(
gameServerAddress
,
String
.
class
);
restTemplate
.
getForObject
(
gameServerAddress
,
String
.
class
);
//创建一场新的比赛 创建比赛规则:进入时间=当前时间+1分钟 开始时间=进入时间+1分钟 结束时间=开始时间+20分钟
MatchBicycle
match
=
new
MatchBicycle
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment