package com.om.controller.admin;


import cn.hutool.core.bean.BeanUtil;
import com.om.entity.dto.UpStatusDto;
import com.om.entity.vo.DiagnosisVersionVO;
import com.om.entity.vo.DignosisPageVO;
import com.om.service.IDiagnosisVersionInfoService;
import com.om.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Generated;
import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bmmx
 * @since 2024-03-06
 */
@RestController
@Slf4j
@Api(tags = "诊断程序相关接口")
@RequestMapping("web/diagnosis-version-info")
public class DiagnosisVersionInfoController {

    @Resource
    IDiagnosisVersionInfoService dvIoService;

    @PostMapping("/add")
    @ApiOperation("新增诊断程序")
    public Result add(@RequestBody DiagnosisVersionVO diagnosisVersionVO){
        log.info("===={}========", diagnosisVersionVO);

        return dvIoService.add(diagnosisVersionVO);
    }

    @GetMapping("/downloadFile/{id}")
    @ApiOperation("下载诊断程序")
    public Result downloadFile(@PathVariable(value = "id")Integer id){

        return dvIoService.downloadFile(id);
    }

    @PostMapping("/edit")
    @ApiOperation("修改诊断程序")
    public Result edit(@RequestBody DiagnosisVersionVO diagnosisVersionVO){

        return dvIoService.edit(diagnosisVersionVO);
    }

    @GetMapping("/getById")
    @ApiOperation("根据id获取诊断程序")
    public Result getByUserId(@RequestParam Integer id){

        return dvIoService.getByUserId(id);
    }

    @PostMapping("/getDesc")
    @ApiOperation("获取Desc诊断程序")
    public Result getDesc(@RequestBody DiagnosisVersionVO diagnosisVersionVO){

        return dvIoService.getDesc(diagnosisVersionVO);
    }
    @GetMapping("/getPageList")
    @ApiOperation("分页查询诊断程序")
    public Result getPageList(@RequestParam Integer pageIndex,
                              @RequestParam Integer pageSize,
                              @RequestParam(required = false) String username){

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

    @GetMapping("/release")
    @ApiOperation("发布")
    public Result release(@RequestParam Integer id){

        return dvIoService.release(id);
    }


    @GetMapping("/repeal")
    @ApiOperation("转为测试")
    public Result repeal(@RequestParam Integer id){

        return dvIoService.repeal(id);
    }

    @GetMapping("/upStatus")
    @ApiOperation("下架")
    public Result upStatus(@RequestParam Integer id){

        return dvIoService.upStatus(id);
    }

    @GetMapping("/push")
    @ApiOperation("推送诊断程序")
    public Result pushDiagnosis(@RequestParam Integer id) {
        return dvIoService.pushDiagnosis(id);
    }




}
