package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.system.domain.project.BmProjectReferral;
import com.ruoyi.system.service.project.IBmProjectReferralService;
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("/projectReferral/referral")
public class BmProjectReferralController extends BaseController
{
    @Autowired
    private IBmProjectReferralService bmProjectReferralService;

    /**
     * 查询项目引荐列表
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectReferral bmProjectReferral)
    {
        startPage();
        List<BmProjectReferral> list = bmProjectReferralService.selectBmProjectReferralList(bmProjectReferral);
        return getDataTable(list);
    }

    /**
     * 导出项目引荐列表
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:export')")
    @Log(title = "项目引荐", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectReferral bmProjectReferral)
    {
        List<BmProjectReferral> list = bmProjectReferralService.selectBmProjectReferralList(bmProjectReferral);
        ExcelUtil<BmProjectReferral> util = new ExcelUtil<BmProjectReferral>(BmProjectReferral.class);
        return util.exportExcel(list, "referral");
    }

    /**
     * 获取项目引荐详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmProjectReferralService.selectBmProjectReferralById(id));
    }

    /**
     * 新增项目引荐
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:add')")
    @Log(title = "项目引荐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmProjectReferral bmProjectReferral)
    {
        return toAjax(bmProjectReferralService.insertBmProjectReferral(bmProjectReferral));
    }

    /**
     * 修改项目引荐
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:edit')")
    @Log(title = "项目引荐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectReferral bmProjectReferral)
    {
        return toAjax(bmProjectReferralService.updateBmProjectReferral(bmProjectReferral));
    }

    /**
     * 删除项目引荐
     */
    @PreAuthorize("@ss.hasPermi('projectReferral:referral:remove')")
    @Log(title = "项目引荐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectReferralService.deleteBmProjectReferralByIds(ids));
    }
}
