package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsBidCaller;
import com.goldenwater.slgc.service.pms.IPmsBidCallerService;
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/bidCaller")
public class PmsBidCallerController extends BaseController {
    @Autowired
    private IPmsBidCallerService pmsBidCallerService;

    /**
     * 查询招标列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsBidCaller bidCaller) {
        startPage();
        List<PmsBidCaller> list = pmsBidCallerService.selectList(bidCaller);
        return getDataTable(list);
    }

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

    /**
     * 新增招标
     */
    @Log(title = "招标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsBidCaller bidCaller) {
        return toAjax(pmsBidCallerService.insert(bidCaller));
    }

    /**
     * 修改招标
     */
    @Log(title = "招标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsBidCaller bidCaller) {
        return toAjax(pmsBidCallerService.update(bidCaller));
    }

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