package com.fs.store.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.store.domain.FsWechatTemplate;
import com.fs.store.service.IFsWechatTemplateService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 微信模板Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/wechatTemplate")
public class FsWechatTemplateController extends BaseController
{
    @Autowired
    private IFsWechatTemplateService fsWechatTemplateService;

    /**
     * 查询微信模板列表
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsWechatTemplate fsWechatTemplate)
    {
        startPage();
        List<FsWechatTemplate> list = fsWechatTemplateService.selectFsWechatTemplateList(fsWechatTemplate);
        return getDataTable(list);
    }

    /**
     * 导出微信模板列表
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:export')")
    @Log(title = "微信模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsWechatTemplate fsWechatTemplate)
    {
        List<FsWechatTemplate> list = fsWechatTemplateService.selectFsWechatTemplateList(fsWechatTemplate);
        ExcelUtil<FsWechatTemplate> util = new ExcelUtil<FsWechatTemplate>(FsWechatTemplate.class);
        return util.exportExcel(list, "wechatTemplate");
    }

    /**
     * 获取微信模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(fsWechatTemplateService.selectFsWechatTemplateById(id));
    }

    /**
     * 新增微信模板
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:add')")
    @Log(title = "微信模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsWechatTemplate fsWechatTemplate)
    {
        return toAjax(fsWechatTemplateService.insertFsWechatTemplate(fsWechatTemplate));
    }

    /**
     * 修改微信模板
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:edit')")
    @Log(title = "微信模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsWechatTemplate fsWechatTemplate)
    {
        return toAjax(fsWechatTemplateService.updateFsWechatTemplate(fsWechatTemplate));
    }

    /**
     * 删除微信模板
     */
    @PreAuthorize("@ss.hasPermi('store:wechatTemplate:remove')")
    @Log(title = "微信模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(fsWechatTemplateService.deleteFsWechatTemplateByIds(ids));
    }
}
