package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsBidTender;
import com.goldenwater.slgc.service.pms.IPmsBidTenderService;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@RestController
@Validated
@RequestMapping("/pms/bidTender")
public class PmsBidTenderController extends BaseController {
    @Autowired
    private IPmsBidTenderService pmsBidTenderService;

    /**
     * 查询投标列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsBidTender bidTender) {
        startPage();
        List<PmsBidTender> list = pmsBidTenderService.selectList(bidTender);
        return getDataTable(list);
    }

    /**
     * 获取投标详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsBidTenderService.selectById(id));
    }

    /**
     * 新增投标
     */
    @Log(title = "投标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsBidTender bidTender) {
        return toAjax(pmsBidTenderService.insert(bidTender));
    }

    /**
     * 修改投标
     */
    @Log(title = "投标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsBidTender bidTender) {
        return toAjax(pmsBidTenderService.update(bidTender));
    }

    /**
     * 删除投标
     */
    @Log(title = "投标管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pmsBidTenderService.deleteByIds(ids));
    }
}
