package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TbUserBidRecord;
import com.ruoyi.business.service.ITbUserBidRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目搜索记录Controller
 * 
 * @author xiatao
 * @date 2022-01-18
 */
@Controller
@RequestMapping("/business/bidRecord")
public class TbUserBidRecordController extends BaseController
{
    private String prefix = "business/bidRecord";

    @Autowired
    private ITbUserBidRecordService tbUserBidRecordService;

    @RequiresPermissions("business:bidRecord:view")
    @GetMapping()
    public String bidRecord()
    {
        return prefix + "/bidRecord";
    }

    /**
     * 查询项目搜索记录列表
     */
    @RequiresPermissions("business:bidRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbUserBidRecord tbUserBidRecord)
    {
        startPage();
        List<TbUserBidRecord> list = tbUserBidRecordService.selectTbUserBidRecordList(tbUserBidRecord);
        return getDataTable(list);
    }

    /**
     * 导出项目搜索记录列表
     */
    @RequiresPermissions("business:bidRecord:export")
    @Log(title = "项目搜索记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbUserBidRecord tbUserBidRecord)
    {
        List<TbUserBidRecord> list = tbUserBidRecordService.selectTbUserBidRecordList(tbUserBidRecord);
        ExcelUtil<TbUserBidRecord> util = new ExcelUtil<TbUserBidRecord>(TbUserBidRecord.class);
        return util.exportExcel(list, "项目搜索记录数据");
    }

    /**
     * 新增项目搜索记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存项目搜索记录
     */
    @RequiresPermissions("business:bidRecord:add")
    @Log(title = "项目搜索记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbUserBidRecord tbUserBidRecord)
    {
        return toAjax(tbUserBidRecordService.insertTbUserBidRecord(tbUserBidRecord));
    }

    /**
     * 修改项目搜索记录
     */
    @RequiresPermissions("business:bidRecord:edit")
    @GetMapping("/edit/{recordBidId}")
    public String edit(@PathVariable("recordBidId") Long recordBidId, ModelMap mmap)
    {
        TbUserBidRecord tbUserBidRecord = tbUserBidRecordService.selectTbUserBidRecordByRecordBidId(recordBidId);
        mmap.put("tbUserBidRecord", tbUserBidRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存项目搜索记录
     */
    @RequiresPermissions("business:bidRecord:edit")
    @Log(title = "项目搜索记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbUserBidRecord tbUserBidRecord)
    {
        return toAjax(tbUserBidRecordService.updateTbUserBidRecord(tbUserBidRecord));
    }

    /**
     * 删除项目搜索记录
     */
    @RequiresPermissions("business:bidRecord:remove")
    @Log(title = "项目搜索记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbUserBidRecordService.deleteTbUserBidRecordByRecordBidIds(ids));
    }
}
