package com.jeeplus.test.proofread.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.test.proofread.domain.ProofreadIssued;
import com.jeeplus.test.proofread.service.ProofreadIssuedService;
import com.jeeplus.test.proofread.service.dto.ProofreadInfoDto;
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;

@RestController
@Api(tags ="报告签发单")
@RequestMapping(value = "/proofread/issued")
public class ProofreadIssuedController {

    @Resource
    private ProofreadIssuedService service;

    /**
     * 新增/修改
     * @param issued
     * @return
     */
    @ApiOperation(value = "新增/修改")
    @PostMapping("/save")
    public ResponseEntity<String> save(@RequestBody ProofreadIssued issued) {
        String s = service.save(issued);
        return ResponseUtil.newInstance().add("businessTable", "proofread_issued").add("businessId", s).ok ("操作成功");
    }

    /**
     * 根据项目id查询
     * @param id
     * @return
     */
    @ApiOperation(value = "根据项目id查询")
    @GetMapping("/findById")
    public ResponseEntity<ProofreadIssued> findById(String id) {
        ProofreadIssued info = service.findById(id);
        return ResponseEntity.ok(info);
    }

    /**
     * 根据项目id查询初始化信息
     * @param id
     * @return
     */
    @ApiOperation(value = "根据项目id查询初始化信息")
    @GetMapping("/findProjectInfoById")
    public ResponseEntity<ProofreadIssued> findProjectInfoById(String id) {
        ProofreadIssued info = service.findProjectInfoById(id);
        return ResponseEntity.ok(info);
    }

    /**
     * 根据项目id修改状态值
     * @param issued
     * @return
     */
    @ApiOperation(value = "根据项目id修改状态值")
    @PostMapping("/updateStatusById")
    public void updateStatusById(@RequestBody ProofreadIssued issued) {
        service.updateStatusById(issued);
    }
}
