package com.om.controller.admin;


import com.om.entity.po.App;
import com.om.entity.vo.AppVO;
import com.om.entity.vo.DignosisPageVO;
import com.om.service.IAppService;
import com.om.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bmmx
 * @since 2024-03-11
 */
@RestController
@Api(tags = "APP版本")
@Slf4j
@RequestMapping("/app")
public class AppController {

    @Resource
    private IAppService appService;

    @PostMapping("/add")
    @ApiOperation("新增应用软件")
    Result add(@RequestBody AppVO app){

        return appService.add(app);
    }

    @ApiOperation("删除应用软件")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable(name = "id") Integer id){
        log.info("获取的id={}",id);

        return appService.delete(id);
    }

    @PostMapping("/downloadFile")
    @ApiOperation("下载应用软件")
    Result downloadFile(@RequestBody AppVO app){

        return appService.downloadFile(app);
    }


    @ApiOperation("分页查询应用软件")
    @GetMapping("/getPageList")
    public Result getPageList(@RequestParam Integer pageIndex,
                              @RequestParam Integer pageSize,
                              @RequestParam String username){

        return appService.getPageList(pageIndex,pageSize,username);
    }

    @PostMapping("/edit")
    @ApiOperation("修改应用软件")
    Result edit(@RequestBody AppVO app){

        return appService.edit(app);
    }

    @GetMapping("/push")
    @ApiOperation("推送VCI固件更新")
    public Result pushVCI(@RequestParam Integer id) {
        return appService.pushVCI(id);
    }




}
