package com.jeeplus.finance.projectReport.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.finance.projectReport.domain.CwProjectReportData;
import com.jeeplus.finance.projectReport.service.CwProjectReportPaperArchivingService;
import com.jeeplus.logging.annotation.ApiLog;
import com.jeeplus.logging.constant.enums.LogTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 王强
 * @version 1.0
 * @date 2024-01-31 15:55
 */
@RestController
@Api("纸质归档信息")
@RequestMapping(value = "/cwProjectReport/paperArchiving")
public class CwProjectReportPaperArchivingController {

    @Resource
    private CwProjectReportPaperArchivingService paperArchivingService;

    /**
     * 保存财务报告纸质归档信息-流程
     * @param reportData
     * @return
     */
    @ApiLog(value = "保存财务报告纸质归档信息", type = LogTypeEnum.SAVE)
    @PostMapping("saveForm")
    public ResponseEntity saveForm(@Valid @RequestBody CwProjectReportData reportData) throws Exception {
        String id = paperArchivingService.saveForm(reportData);
        return ResponseUtil.newInstance().add("businessTable", "cw_project_report_paper_archiving").add("businessId", id).ok ("操作成功");
    }

    /**
     * 根据报告id查询报告纸质归档信息
     * @param id
     * @return
     */
    @ApiLog("根据报告id查询纸质归档信息")
    @GetMapping("queryByReportId")
    public ResponseEntity queryByReportId(@RequestParam("id") String id) {
        CwProjectReportData projectReportData = paperArchivingService.queryByReportId(id);
        return ResponseEntity.ok (projectReportData);
    }

    /**
     * 根据id修改状态值status
     * @param data
     * @return
     */
    @ApiOperation(value = "根据报告id修改状态值status")
    @PostMapping(value = "/updateStatusByReportId")
    public ResponseEntity<String> updateStatusByReportId(@RequestBody CwProjectReportData data) {
        String s = paperArchivingService.updateStatusByReportId(data);
        return ResponseEntity.ok(s);
    }

}


