package cn.minestar.agriculture.controller;

import cn.minestar.agriculture.entity.WxMiniBrowsingHistory;
import cn.minestar.agriculture.service.IWxMiniBrowsingHistoryService;
import cn.minestar.common.annotation.Log;
import cn.minestar.common.core.domain.AjaxResult;
import cn.minestar.common.enums.BusinessType;
import cn.minestar.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author www.minestar.cn/
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/weixin/api/ma/agriculture/history")
public class WxMiniBrowsingHistoryController
{
    @Autowired
    private IWxMiniBrowsingHistoryService wxMiniBrowsingHistoryService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:list')")
    @GetMapping("/list")
    public AjaxResult list(WxMiniBrowsingHistory wxMiniBrowsingHistory)
    {
        List<WxMiniBrowsingHistory> list = wxMiniBrowsingHistoryService.selectWxMiniBrowsingHistoryList(wxMiniBrowsingHistory);
        return AjaxResult.success(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxMiniBrowsingHistory wxMiniBrowsingHistory)
    {
        List<WxMiniBrowsingHistory> list = wxMiniBrowsingHistoryService.selectWxMiniBrowsingHistoryList(wxMiniBrowsingHistory);
        ExcelUtil<WxMiniBrowsingHistory> util = new ExcelUtil<WxMiniBrowsingHistory>(WxMiniBrowsingHistory.class);
        return util.exportExcel(list, "history");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wxMiniBrowsingHistoryService.selectWxMiniBrowsingHistoryById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxMiniBrowsingHistory wxMiniBrowsingHistory)
    {
        return AjaxResult.success(wxMiniBrowsingHistoryService.insertWxMiniBrowsingHistory(wxMiniBrowsingHistory));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxMiniBrowsingHistory wxMiniBrowsingHistory)
    {
        return AjaxResult.success(wxMiniBrowsingHistoryService.updateWxMiniBrowsingHistory(wxMiniBrowsingHistory));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:history:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return AjaxResult.success(wxMiniBrowsingHistoryService.deleteWxMiniBrowsingHistoryByIds(ids));
    }
}
