package cn.minestar.agriculture.controller;

import cn.minestar.agriculture.entity.WxMiniLabel;
import cn.minestar.agriculture.service.IWxMiniLabelService;
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-12
 */
@RestController
@RequestMapping("/weixin/api/ma/agriculture/label")
public class WxMiniLabelController
{
    @Autowired
    private IWxMiniLabelService wxMiniLabelService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:label:list')")
    @GetMapping("/list")
    public AjaxResult list(WxMiniLabel wxMiniLabel)
    {
        List<WxMiniLabel> list = wxMiniLabelService.selectWxMiniLabelList(wxMiniLabel);
        return AjaxResult.success(list);
    }

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

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

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:label:add')")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxMiniLabel wxMiniLabel)
    {
        return AjaxResult.success(wxMiniLabelService.insertWxMiniLabel(wxMiniLabel));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:label:edit')")
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxMiniLabel wxMiniLabel)
    {
        return AjaxResult.success(wxMiniLabelService.updateWxMiniLabel(wxMiniLabel));
    }

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