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.CwProjectReportNumberApplyService;
import com.jeeplus.finance.projectReport.service.CwProjectReportNumberReviewApplyService;
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;
import java.lang.reflect.InvocationTargetException;

/**
 * @author: 徐滕
 * @create: 2022-12-14 14:23
 **/
@RestController
@Api(tags ="报告审核校对")
@RequestMapping(value = "/projectReport/numberReviewApply")
public class CwProjectReportNumberReviewApplyController {

    @Resource
    private CwProjectReportNumberReviewApplyService service;

    /**
     * 财务报告号复核-流程
     * @param reportData
     * @return
     */
    @ApiLog(value = "财务报告号复核-流程", type = LogTypeEnum.SAVE)
    @PostMapping("saveForm")
    public ResponseEntity saveForm(@Valid @RequestBody CwProjectReportData reportData) throws Exception {
        String id = service.reviewSaveForm(reportData);
        return ResponseUtil.newInstance().add("businessTable", "cw_project_report_number_review_apply").add("businessId", id).ok ("操作成功");
    }

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

    /**
     * 查询客户信息数据
     * @param id
     * @return
     */
    @ApiLog("查询财务报告数据")
    @GetMapping("queryByReportId")
    public ResponseEntity queryByReportId(@RequestParam("id") String id) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        CwProjectReportData projectReportData = service.queryByReportId(id);
        return ResponseEntity.ok (projectReportData);
    }

}
