package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.project.BmConstructionEntry;
import com.ruoyi.system.service.project.IBmConstructionEntryService;
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.core.page.TableDataInfo;

/**
 * 项目入规
(跟项目一对一)Controller
 * 
 * @author ruoyi
 * @date 2021-12-20
 */
@RestController
@RequestMapping("/constructionEntry/entry")
public class BmConstructionEntryController extends BaseController
{
    @Autowired
    private IBmConstructionEntryService bmConstructionEntryService;

    /**
     * 查询项目入规
(跟项目一对一)列表
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmConstructionEntry bmConstructionEntry)
    {
        startPage();
        List<BmConstructionEntry> list = bmConstructionEntryService.selectBmConstructionEntryList(bmConstructionEntry);
        return getDataTable(list);
    }

    /**
     * 导出项目入规
(跟项目一对一)列表
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:export')")
    @Log(title = "项目入规 (跟项目一对一)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmConstructionEntry bmConstructionEntry)
    {
        List<BmConstructionEntry> list = bmConstructionEntryService.selectBmConstructionEntryList(bmConstructionEntry);
        ExcelUtil<BmConstructionEntry> util = new ExcelUtil<BmConstructionEntry>(BmConstructionEntry.class);
        return util.exportExcel(list, "entry");
    }

    /**
     * 获取项目入规
(跟项目一对一)详细信息
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmConstructionEntryService.selectBmConstructionEntryById(id));
    }

    /**
     * 新增项目入规
(跟项目一对一)
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:add')")
    @Log(title = "项目入规 (跟项目一对一)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmConstructionEntry bmConstructionEntry)
    {
        return toAjax(bmConstructionEntryService.insertBmConstructionEntry(bmConstructionEntry));
    }

    /**
     * 修改项目入规
(跟项目一对一)
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:edit')")
    @Log(title = "项目入规 (跟项目一对一)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmConstructionEntry bmConstructionEntry)
    {
        return toAjax(bmConstructionEntryService.updateBmConstructionEntry(bmConstructionEntry));
    }

    /**
     * 删除项目入规
(跟项目一对一)
     */
    @PreAuthorize("@ss.hasPermi('constructionEntry:entry:remove')")
    @Log(title = "项目入规 (跟项目一对一)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmConstructionEntryService.deleteBmConstructionEntryByIds(ids));
    }
}
