package cn.minestar.agriculture.controller;

import cn.minestar.agriculture.entity.WxMiniUserLabel;
import cn.minestar.agriculture.service.IWxMiniUserLabelService;
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.security.access.prepost.PreAuthorize;
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/userlabel")
public class WxMiniUserLabelController
{
    @Autowired
    private IWxMiniUserLabelService wxMiniUserLabelService;

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

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:label:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxMiniUserLabel wxMiniUserLabel)
    {
        List<WxMiniUserLabel> list = wxMiniUserLabelService.selectWxMiniUserLabelList(wxMiniUserLabel);
        ExcelUtil<WxMiniUserLabel> util = new ExcelUtil<WxMiniUserLabel>(WxMiniUserLabel.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(wxMiniUserLabelService.selectWxMiniUserLabelById(id));
    }

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

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

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