package com.sw.appcloudv1.controller;

import com.sw.appcloudv1.entities.ResultData;
import com.sw.appcloudv1.service.AppDownloadService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * app下载\更新\查询版本
 */
@RestController
@RequestMapping("appDown")
public class AppDownloadController {
    @Resource
    private AppDownloadService appDownloadService;

    /**
     * @Description: 下载app
     * @Param: [response,  projectId：项目id]
     * @Return:
     */
    @GetMapping("/download")
    public void download(HttpServletResponse response, Integer projectId) {
        appDownloadService.download(response, projectId);
    }

    /**
     * @Description: 查询最新的版本号
     * @Param: [projectId]
     * @Return:
     */
    @GetMapping("/getNewVersion")
    public ResultData getNewVersion(Integer projectId) {
        return ResultData.success(appDownloadService.getNewVersion(projectId));
    }
}
