package cn.minestar.agriculture.controller;

import cn.minestar.agriculture.entity.WxMiniInfo;
import cn.minestar.agriculture.service.IWxMiniInfoService;
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/info")
public class WxMiniInfoController
{
    @Autowired
    private IWxMiniInfoService wxMiniInfoService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:info:list')")
    @GetMapping("/list")
    public AjaxResult list(WxMiniInfo wxMiniInfo)
    {
        List<WxMiniInfo> list = wxMiniInfoService.selectWxMiniInfoList(wxMiniInfo);
        return AjaxResult.success(list);
    }

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

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

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

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

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