
package com.jwipc.tender.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.query.BasePageQuery;
import com.jwipc.tender.dto.TenderQuestionBaseDTO;
import com.jwipc.tender.dto.TenderQuestionDetailDTO;
import com.jwipc.tender.logic.TenderQuestionLogic;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import static com.jwipc.tender.constant.ModuleConst.MODULE_ROOT;

/**
 * <p> 投标答疑 相关接口</p>
 *
 * @author BOGON
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(MODULE_ROOT + "/question/rest")
public class TenderQuestionRestController {
    private final TenderQuestionLogic tenderQuestionLogic;


    /**
     * 投标答疑列表
     *
     * @param page
     * @param tenderId
     * @return
     */
    @GetMapping("/list")
    public PageView list(BasePageQuery page, Long tenderId) {
        return tenderQuestionLogic.getList(page, tenderId);
    }

    /**
     * 投标答疑详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public ResponseEntity detail(Long id) {
        TenderQuestionDetailDTO tenderQuestionDetailDTO = tenderQuestionLogic.getDetail(id);
        return ResponseEntity.ok(tenderQuestionDetailDTO);
    }

    /**
     * 保存投标答疑
     *
     * @param tenderQuestionBaseDTO
     * @return
     */
    @PostMapping("/save")
    public ResponseEntity save(@RequestBody TenderQuestionBaseDTO tenderQuestionBaseDTO)
    {
        tenderQuestionLogic.save(tenderQuestionBaseDTO);
        return ResponseEntity.ok().build();
    }

    /**
     * 删除投标答疑
     *
     * @param id 答疑ID
     * @return
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        tenderQuestionLogic.remove(id);
        return ResponseEntity.ok().build();
    }
}
