1
This commit is contained in:
parent
3013bf3c0d
commit
56cdd668ee
@ -24,6 +24,7 @@ import com.ruoyi.common.core.domain.R;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.constant.StrConstants;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.webSocket.Message;
|
import com.ruoyi.webSocket.Message;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -36,12 +37,17 @@ import org.springframework.web.HttpRequestHandler;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.ruoyi.constant.DictConstants.*;
|
import static com.ruoyi.constant.DictConstants.*;
|
||||||
import static com.ruoyi.constant.DictConstants.CATG_TYPE_WZ;
|
import static com.ruoyi.constant.DictConstants.CATG_TYPE_WZ;
|
||||||
|
import static com.ruoyi.constant.StrConstants.UPLOAD_DIR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web 专用Controller
|
* Web 专用Controller
|
||||||
@ -502,4 +508,46 @@ public class WebController extends BaseController {
|
|||||||
public R<BaseApp> getNewApp() {
|
public R<BaseApp> getNewApp() {
|
||||||
return R.ok(appService.selectNewApp());
|
return R.ok(appService.selectNewApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("下载APK文件")
|
||||||
|
@GetMapping("/downloadApk")
|
||||||
|
public void downloadApk(HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
// APK文件路径
|
||||||
|
File file = new File(UPLOAD_DIR);
|
||||||
|
|
||||||
|
// 检查文件是否存在
|
||||||
|
if (!file.exists()) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
response.getWriter().write("文件不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置响应头
|
||||||
|
response.setContentType("application/vnd.android.package-archive");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=truck.apk");
|
||||||
|
response.setHeader("Content-Length", String.valueOf(file.length()));
|
||||||
|
|
||||||
|
// 写入响应流
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
fis.close();
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
response.getWriter().write("文件下载失败: " + e.getMessage());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("下载APK文件时发生错误", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,7 @@ public class BaseApp extends DlBaseEntity
|
|||||||
|
|
||||||
/** 版本 */
|
/** 版本 */
|
||||||
@Excel(name = "版本")
|
@Excel(name = "版本")
|
||||||
private BigDecimal version;
|
private String version;
|
||||||
|
|
||||||
/** app包下载地址 */
|
|
||||||
@Excel(name = "app包下载地址")
|
|
||||||
private String apkUrl;
|
|
||||||
|
|
||||||
/** 本次升级描述 */
|
/** 本次升级描述 */
|
||||||
@Excel(name = "本次升级描述")
|
@Excel(name = "本次升级描述")
|
||||||
|
@ -36,4 +36,8 @@ public class StrConstants {
|
|||||||
* 国家
|
* 国家
|
||||||
*/
|
*/
|
||||||
public static final String COUNTRY = "country";
|
public static final String COUNTRY = "country";
|
||||||
|
/**
|
||||||
|
* app下载目录
|
||||||
|
*/
|
||||||
|
public static final String UPLOAD_DIR = "/app/apk/truck.apk";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<resultMap type="BaseApp" id="BaseAppResult">
|
<resultMap type="BaseApp" id="BaseAppResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="version" column="version" />
|
<result property="version" column="version" />
|
||||||
<result property="apkUrl" column="apk_url" />
|
|
||||||
<result property="content" column="content" />
|
<result property="content" column="content" />
|
||||||
<result property="creator" column="creator" />
|
<result property="creator" column="creator" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
@ -17,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectBaseAppVo">
|
<sql id="selectBaseAppVo">
|
||||||
select id, version, apk_url, content, creator, create_time, updater, update_time, del_flag from dl_base_app
|
select id, version, content, creator, create_time, updater, update_time, del_flag from dl_base_app
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="queryListPage" parameterType="BaseApp" resultMap="BaseAppResult">
|
<select id="queryListPage" parameterType="BaseApp" resultMap="BaseAppResult">
|
||||||
@ -25,6 +24,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<where>
|
<where>
|
||||||
<if test="entity.version != null "> and version like concat('%', #{entity.version}, '%')</if>
|
<if test="entity.version != null "> and version like concat('%', #{entity.version}, '%')</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by version DESC,create_time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -33,12 +33,7 @@
|
|||||||
<el-table-column type="index" width="60" label="序号" align="center"/>
|
<el-table-column type="index" width="60" label="序号" align="center"/>
|
||||||
<el-table-column label="版本" align="center" prop="version" >
|
<el-table-column label="版本" align="center" prop="version" >
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag>{{ parseFloat(scope.row.version).toFixed(1) }}</el-tag>
|
<el-tag>{{scope.row.version }}</el-tag>
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="app包" align="center" prop="apkUrl" >
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<file-upload v-model="scope.row.apkUrl" :limit="1" :fileType="fileType" :fileSize="50" :disabled="true" />
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="本次升级描述" align="center" prop="content" />
|
<el-table-column label="本次升级描述" align="center" prop="content" />
|
||||||
@ -74,10 +69,7 @@
|
|||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
<el-form-item label="版本" prop="version">
|
<el-form-item label="版本" prop="version">
|
||||||
<el-input type="number" v-model="form.version" placeholder="请输入版本" />
|
<el-input v-model="form.version" placeholder="请输入版本" />
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="app包" prop="apkUrl">
|
|
||||||
<file-upload v-model="form.apkUrl" :limit="1" :fileType="fileType" :fileSize="50"/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="本次升级描述" prop="content">
|
<el-form-item label="本次升级描述" prop="content">
|
||||||
<el-input v-model="form.content" type="textarea" placeholder="请输入内容" />
|
<el-input v-model="form.content" type="textarea" placeholder="请输入内容" />
|
||||||
@ -130,9 +122,6 @@ export default {
|
|||||||
version: [
|
version: [
|
||||||
{ required: true, message: '请输入版本号', trigger: 'blur' }
|
{ required: true, message: '请输入版本号', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
apkUrl: [
|
|
||||||
{ required: true, message: '请上传程序包', trigger: 'blur' }
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -159,7 +148,6 @@ export default {
|
|||||||
this.form = {
|
this.form = {
|
||||||
id: null,
|
id: null,
|
||||||
version: null,
|
version: null,
|
||||||
apkUrl: null,
|
|
||||||
content: null,
|
content: null,
|
||||||
creator: null,
|
creator: null,
|
||||||
createTime: null,
|
createTime: null,
|
||||||
|
Loading…
Reference in New Issue
Block a user