ApplicationUpdateController.java 1.7 KB
package com.ruoyi.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.AppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 管理应用更新
 * @author 20412
 */
@RestController
@Api(tags = "管理应用更新")
@RequestMapping("/app")
public class ApplicationUpdateController {

    @Resource
    private AppService appService;

    /**
     * 校验版本号
     */
    @GetMapping("/version/check/{currentVersion}")
    @ApiOperation("校验版本号")
    public AjaxResult checkVersionNum(@PathVariable("currentVersion") Integer currentVersion) {
        return AjaxResult.success(appService.checkVersionNum(currentVersion));
    }

    /**
     * 下载最新apk 弃用
     */
    @Deprecated
    @PostMapping("/download")
//    @ApiOperation("下载最新apk")
    public void downloadApk(String apkUrl, HttpServletResponse response) {
        try {
            appService.downloadApk(apkUrl, response);
        } catch (IOException e) {
            throw new RuntimeException("下载失败,请联系管理员处理,失败原因 :" + e.getMessage());
        }
    }

    @PostMapping("/uploadApk")
    @ApiOperation("上传apk文件")
    public AjaxResult uploadApk(MultipartFile file) {
        try {
            return appService.uploadApk(file);
        } catch (Exception e) {
            return AjaxResult.error("上传失败,请重试,再次失败请联系管理员,失败原因:" + e.getMessage());
        }
    }

}