Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
8923ddab
Commit
8923ddab
authored
Mar 20, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构app版本获取
parent
574c2ebf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
23 deletions
+68
-23
src/main/java/cn/meteor/beyondclouds/modules/app/api/AppVersionApi.java
+10
-10
src/main/java/cn/meteor/beyondclouds/modules/app/enums/VersionErrorCode.java
+27
-0
src/main/java/cn/meteor/beyondclouds/modules/app/exception/VersionServiceException.java
+17
-0
src/main/java/cn/meteor/beyondclouds/modules/app/mapper/AppVersionMapper.java
+1
-1
src/main/java/cn/meteor/beyondclouds/modules/app/mapper/xml/AppVersionMapper.xml
+1
-1
src/main/java/cn/meteor/beyondclouds/modules/app/service/IAppVersionService.java
+3
-2
src/main/java/cn/meteor/beyondclouds/modules/app/service/impl/AppVersionServiceImpl.java
+9
-9
No files found.
src/main/java/cn/meteor/beyondclouds/modules/app/
controller
/AppVersionApi.java
→
src/main/java/cn/meteor/beyondclouds/modules/app/
api
/AppVersionApi.java
View file @
8923ddab
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
controller
;
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
api
;
import
cn.meteor.beyondclouds.core.annotation.Anonymous
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.modules.app.entity.AppVersion
;
import
cn.meteor.beyondclouds.modules.app.exception.VersionServiceException
;
import
cn.meteor.beyondclouds.modules.app.service.IAppVersionService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RestController
;
/**
...
...
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author 段启岩
* @since 2020-03-19
*/
@Api
(
tags
=
"app接口"
)
@RestController
@RequestMapping
(
"/api"
)
public
class
AppVersionApi
{
...
...
@@ -33,17 +35,15 @@ public class AppVersionApi {
}
@Anonymous
@ApiOperation
(
"获取
版本号
"
)
@ApiOperation
(
"获取
最新版本信息
"
)
@GetMapping
(
"/app/version/latest"
)
public
Response
<
AppVersion
>
getLatestVersion
()
{
// TODO 获取最新版本信息
AppVersion
appVersion
=
appVersionService
.
getApp
Version
();
if
(
appVersion
==
null
)
{
return
Response
.
error
();
try
{
AppVersion
appVersion
=
appVersionService
.
getLatest
Version
();
return
Response
.
success
(
appVersion
);
}
catch
(
VersionServiceException
e
)
{
return
Response
.
error
(
e
);
}
return
Response
.
success
(
appVersion
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/app/enums/VersionErrorCode.java
0 → 100644
View file @
8923ddab
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
enums
;
import
cn.meteor.beyondclouds.core.IErrorCode
;
/**
* @author meteor
*/
public
enum
VersionErrorCode
implements
IErrorCode
{
VERSION_FETCH_FAILURE
(
20000
,
"版本信息获取失败!"
);
private
Integer
code
;
private
String
msg
;
VersionErrorCode
(
Integer
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
@Override
public
long
code
()
{
return
0
;
}
@Override
public
String
msg
()
{
return
null
;
}
}
src/main/java/cn/meteor/beyondclouds/modules/app/exception/VersionServiceException.java
0 → 100644
View file @
8923ddab
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
exception
;
import
cn.meteor.beyondclouds.core.IErrorCode
;
import
cn.meteor.beyondclouds.core.exception.ServiceException
;
/**
* @author meteor
*/
public
class
VersionServiceException
extends
ServiceException
{
public
VersionServiceException
(
long
errorCode
,
String
errorMsg
)
{
super
(
errorCode
,
errorMsg
);
}
public
VersionServiceException
(
IErrorCode
errorCode
)
{
super
(
errorCode
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/app/mapper/AppVersionMapper.java
View file @
8923ddab
...
...
@@ -20,5 +20,5 @@ public interface AppVersionMapper extends BaseMapper<AppVersion> {
* 通过sql语句根据时间降序排序数据后,限制返回最新一条
* @return
*/
AppVersion
get
VersionMapper
();
AppVersion
get
LatestVersion
();
}
src/main/java/cn/meteor/beyondclouds/modules/app/mapper/xml/AppVersionMapper.xml
View file @
8923ddab
...
...
@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.meteor.beyondclouds.modules.app.mapper.AppVersionMapper"
>
<select
id=
"get
VersionMapper
"
resultType=
"cn.meteor.beyondclouds.modules.app.entity.AppVersion"
>
<select
id=
"get
LatestVersion
"
resultType=
"cn.meteor.beyondclouds.modules.app.entity.AppVersion"
>
select * from app_version order by create_time desc limit 1
</select>
...
...
src/main/java/cn/meteor/beyondclouds/modules/app/service/IAppVersionService.java
View file @
8923ddab
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
service
;
import
cn.meteor.beyondclouds.modules.app.entity.AppVersion
;
import
cn.meteor.beyondclouds.modules.app.exception.VersionServiceException
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
...
...
@@ -14,8 +15,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
public
interface
IAppVersionService
extends
IService
<
AppVersion
>
{
/**
* 根据
时间倒序查询最新版本
* 根据
最新版本信息
* @return AppVersion
*/
AppVersion
get
AppVersion
()
;
AppVersion
get
LatestVersion
()
throws
VersionServiceException
;
}
src/main/java/cn/meteor/beyondclouds/modules/app/service/impl/AppVersionServiceImpl.java
View file @
8923ddab
package
cn
.
meteor
.
beyondclouds
.
modules
.
app
.
service
.
impl
;
import
cn.meteor.beyondclouds.modules.app.entity.AppVersion
;
import
cn.meteor.beyondclouds.modules.app.enums.VersionErrorCode
;
import
cn.meteor.beyondclouds.modules.app.exception.VersionServiceException
;
import
cn.meteor.beyondclouds.modules.app.mapper.AppVersionMapper
;
import
cn.meteor.beyondclouds.modules.app.service.IAppVersionService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -22,22 +23,21 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
private
AppVersionMapper
appVersionMapper
;
@Autowired
public
void
setAppVersionMapper
(
AppVersionMapper
appVersionMapper
)
{
public
AppVersionServiceImpl
(
AppVersionMapper
appVersionMapper
)
{
this
.
appVersionMapper
=
appVersionMapper
;
}
/**
*
根据时间倒序查询最新版本
*
查询最新版本信息
* @return AppVersion
*/
@Override
public
AppVersion
getAppVersion
()
{
AppVersion
appVersion
=
appVersionMapper
.
getVersionMapper
();
if
(
appVersion
==
null
)
{
public
AppVersion
getLatestVersion
()
throws
VersionServiceException
{
AppVersion
appVersion
=
appVersionMapper
.
getLatestVersion
();
if
(
null
==
appVersion
)
{
throw
new
VersionServiceException
(
VersionErrorCode
.
VERSION_FETCH_FAILURE
);
}
return
appVersion
;
}
}
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