package cn.minestar.agriculture.controller;

import cn.minestar.agriculture.entity.WxMiniStarRecord;
import cn.minestar.agriculture.service.IWxMiniStarRecordService;
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/record")
public class WxMiniStarRecordController
{
    @Autowired
    private IWxMiniStarRecordService wxMiniStarRecordService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('agriculture:record:list')")
    @GetMapping("/list")
    public AjaxResult list(WxMiniStarRecord wxMiniStarRecord)
    {
        List<WxMiniStarRecord> list = wxMiniStarRecordService.selectWxMiniStarRecordList(wxMiniStarRecord);
        return AjaxResult.success(list);
    }

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

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

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

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

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