package com.hz.pm.api.projectlib.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.hz.pm.api.projectlib.manage.ApplicationManage;
import com.hz.pm.api.projectlib.model.dto.ApplicationAppCodeSaveDTO;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * @Classname ProjectApplicationController
 * @Description
 * @Date 2023/6/27 11:32
 * @Author PoffyZhang
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "项目应用控制器")
@RequestMapping("/api/v1/application")
public class ProjectApplicationController {

    private final ApplicationManage applicationManage;

    @GetMapping("/get-report/{appCode}")
    @ApiOperation("获取应用 试运行报告")
    @WebLog("获取应用 试运行报告")
    public String getReport(@PathVariable String appCode) {
        return applicationManage.getReport(appCode);
    }

    @PostMapping("/save-appcode")
    @ApiOperation("保存应用注册的appCode")
    @WebLog("保存应用注册的appCode")
    public String saveAppCode(@Valid @RequestBody ApplicationAppCodeSaveDTO dto) {
        return applicationManage.saveAppCode(dto);
    }

    @GetMapping("/to-register-app-project-list")
    @ApiOperation("待应用预注册的项目应用列表")
    public PageVo<ProjectDetailVO> toRegisterAppProjectLibList(ProjectListReq req) {
        return applicationManage.toRegisterAppProjectLibList(req);
    }
}
