package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.system.domain.project.BmProjectInfo;
import com.ruoyi.system.service.project.IBmProjectInfoService;
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-04
 */
@RestController
@RequestMapping("/projectInfo/info")
public class BmProjectInfoController extends BaseController
{
    @Autowired
    private IBmProjectInfoService bmProjectInfoService;

    /**
     * 查询项目-线索信息列表
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectInfo bmProjectInfo)
    {
        startPage();
        List<BmProjectInfo> list = bmProjectInfoService.selectBmProjectInfoList(bmProjectInfo);
        return getDataTable(list);
    }

    /**
     * 导出项目-线索信息列表
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:export')")
    @Log(title = "项目-线索信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectInfo bmProjectInfo)
    {
        List<BmProjectInfo> list = bmProjectInfoService.selectBmProjectInfoList(bmProjectInfo);
        ExcelUtil<BmProjectInfo> util = new ExcelUtil<BmProjectInfo>(BmProjectInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取项目-线索信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmProjectInfoService.selectBmProjectInfoById(id));
    }

    /**
     * 新增项目-线索信息
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:add')")
    @Log(title = "项目-线索信息", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody BmProjectInfo bmProjectInfo)
    {
        return toAjax(bmProjectInfoService.insertBmProjectInfo(bmProjectInfo));
    }

    /**
     * 修改项目-线索信息
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:edit')")
    @Log(title = "项目-线索信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectInfo bmProjectInfo)
    {
        return toAjax(bmProjectInfoService.updateBmProjectInfo(bmProjectInfo));
    }

    /**
     * 删除项目-线索信息
     */
    @PreAuthorize("@ss.hasPermi('projectInfo:info:remove')")
    @Log(title = "项目-线索信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectInfoService.deleteBmProjectInfoByIds(ids));
    }
}
