package com.jeeplus.finance.proofread.controller;

import com.jeeplus.finance.proofread.domain.ProofreadDetail;
import com.jeeplus.finance.proofread.service.ProofreadInfoService;
import com.jeeplus.finance.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;
import java.util.List;

@RestController
@Api(tags ="项目登记校对")
@RequestMapping(value = "/proofread/info")
public class ProofreadInfoController {

    @Resource
    private ProofreadInfoService service;

    /**
     * 新增/修改
     * @param dto
     * @return
     */
    @ApiOperation(value = "新增/修改")
    @PostMapping("/save")
    public ResponseEntity<String> save(@RequestBody ProofreadInfoDto dto) {
        String s = service.save(dto);
        return ResponseEntity.ok(s);
    }

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

    /**
     * 初始化类型列表查询
     * @return
     */
    @ApiOperation(value = "初始化类型列表查询")
    @GetMapping("/list")
    public ResponseEntity<List<ProofreadDetail>> list(String type) {
        List<ProofreadDetail> list = service.list(type);
        return ResponseEntity.ok(list);
    }

}
