package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.system.domain.project.BmProjectOrderinfo;
import com.ruoyi.system.service.project.IBmProjectOrderinfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目签约Controller
 * 
 * @author ruoyi
 * @date 2021-03-05
 */
@RestController
@RequestMapping("/projectOrderInfo/orderinfo")
public class BmProjectOrderinfoController extends BaseController
{
    @Autowired
    private IBmProjectOrderinfoService bmProjectOrderinfoService;

    /**
     * 查询项目签约列表
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectOrderinfo bmProjectOrderinfo)
    {
        startPage();
        List<BmProjectOrderinfo> list = bmProjectOrderinfoService.selectBmProjectOrderinfoList(bmProjectOrderinfo);
        return getDataTable(list);
    }

    /**
     * 导出项目签约列表
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:export')")
    @Log(title = "项目签约", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectOrderinfo bmProjectOrderinfo)
    {
        List<BmProjectOrderinfo> list = bmProjectOrderinfoService.selectBmProjectOrderinfoList(bmProjectOrderinfo);
        ExcelUtil<BmProjectOrderinfo> util = new ExcelUtil<BmProjectOrderinfo>(BmProjectOrderinfo.class);
        return util.exportExcel(list, "orderinfo");
    }

    /**
     * 获取项目签约详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmProjectOrderinfoService.selectBmProjectOrderinfoById(id));
    }

    /**
     * 新增项目签约
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:add')")
    @Log(title = "项目签约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmProjectOrderinfo bmProjectOrderinfo)
    {
        return bmProjectOrderinfoService.insertBmProjectOrderinfo(bmProjectOrderinfo);
    }

    /**
     * 修改项目签约
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:edit')")
    @Log(title = "项目签约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectOrderinfo bmProjectOrderinfo)
    {
        return bmProjectOrderinfoService.updateBmProjectOrderinfo(bmProjectOrderinfo);
    }

    /**
     * 删除项目签约
     */
    @PreAuthorize("@ss.hasPermi('projectOrderInfo:orderinfo:remove')")
    @Log(title = "项目签约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectOrderinfoService.deleteBmProjectOrderinfoByIds(ids));
    }
}
