Commit 574c2ebf by 胡明森

获取最新版本

parent 54a06331
package cn.meteor.beyondclouds.modules.app.controller;
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.service.IAppVersionService;
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;
......@@ -21,10 +25,24 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api")
public class AppVersionApi {
private IAppVersionService appVersionService;
@Autowired
public void setAppVersionService(IAppVersionService appVersionService) {
this.appVersionService = appVersionService;
}
@Anonymous
@ApiOperation("获取版本号")
@GetMapping("/app/version/latest")
public Response<AppVersion> getLatestVersion() {
// TODO 获取最新版本信息
return null;
AppVersion appVersion = appVersionService.getAppVersion();
if (appVersion == null) {
return Response.error();
}
return Response.success(appVersion);
}
}
......
......@@ -2,6 +2,9 @@ package cn.meteor.beyondclouds.modules.app.mapper;
import cn.meteor.beyondclouds.modules.app.entity.AppVersion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.mapstruct.Mapper;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* <p>
......@@ -13,4 +16,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface AppVersionMapper extends BaseMapper<AppVersion> {
/**
* 通过sql语句根据时间降序排序数据后,限制返回最新一条
* @return
*/
AppVersion getVersionMapper();
}
......@@ -2,4 +2,8 @@
<!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="getVersionMapper" resultType="cn.meteor.beyondclouds.modules.app.entity.AppVersion">
select * from app_version order by create_time desc limit 1
</select>
</mapper>
......@@ -13,4 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IAppVersionService extends IService<AppVersion> {
/**
* 根据时间倒序查询最新版本
* @return AppVersion
*/
AppVersion getAppVersion();
}
......@@ -3,7 +3,9 @@ package cn.meteor.beyondclouds.modules.app.service.impl;
import cn.meteor.beyondclouds.modules.app.entity.AppVersion;
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;
/**
......@@ -17,4 +19,25 @@ import org.springframework.stereotype.Service;
@Service
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements IAppVersionService {
private AppVersionMapper appVersionMapper;
@Autowired
public void setAppVersionMapper(AppVersionMapper appVersionMapper) {
this.appVersionMapper = appVersionMapper;
}
/**
* 根据时间倒序查询最新版本
* @return AppVersion
*/
@Override
public AppVersion getAppVersion() {
AppVersion appVersion = appVersionMapper.getVersionMapper();
if (appVersion == null) {
}
return appVersion;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment