package com.flossom.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.flossom.common.core.domain.entity.WxParameterSetting;
import com.flossom.common.core.utils.poi.ExcelUtil;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.common.core.web.page.TableDataInfo;
import com.flossom.common.log.annotation.Log;
import com.flossom.common.log.enums.BusinessType;
import com.flossom.common.security.annotation.RequiresPermissions;
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.flossom.system.service.IWxParameterSettingService;

/**
 * 微信参数配属Controller
 *
 * @author flossom
 * @date 2023-12-13
 */
@RestController
@RequestMapping("/wxSetting")
public class WxParameterSettingController extends BaseController {
    @Autowired
    private IWxParameterSettingService wxParameterSettingService;

    /**
     * 查询微信参数配属列表
     */
    @RequiresPermissions("system:wxSetting:list")
    @GetMapping("/list")
    public TableDataInfo list(WxParameterSetting wxParameterSetting) {
        startPage();
        List<WxParameterSetting> list = wxParameterSettingService.selectWxParameterSettingList(wxParameterSetting);
        return getDataTable(list);
    }

    /**
     * 导出微信参数配属列表
     */
    @RequiresPermissions("system:wxSetting:export")
    @Log(title = "微信参数配属", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxParameterSetting wxParameterSetting) {
        List<WxParameterSetting> list = wxParameterSettingService.selectWxParameterSettingList(wxParameterSetting);
        ExcelUtil<WxParameterSetting> util = new ExcelUtil<WxParameterSetting>(WxParameterSetting.class);
        util.exportExcel(response, list, "微信参数配属数据");
    }

    /**
     * 获取微信参数配属详细信息
     */
    @RequiresPermissions("system:wxSetting:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wxParameterSettingService.selectWxParameterSettingById(id));
    }

    /**
     * 新增微信参数配属
     */
    @RequiresPermissions("system:wxSetting:add")
    @Log(title = "微信参数配属", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxParameterSetting wxParameterSetting) {
        return toAjax(wxParameterSettingService.insertWxParameterSetting(wxParameterSetting));
    }

    /**
     * 修改微信参数配属
     */
    @RequiresPermissions("system:wxSetting:edit")
    @Log(title = "微信参数配属", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxParameterSetting wxParameterSetting) {
        return toAjax(wxParameterSettingService.updateWxParameterSetting(wxParameterSetting));
    }

    /**
     * 删除微信参数配属
     */
    @RequiresPermissions("system:wxSetting:remove")
    @Log(title = "微信参数配属", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wxParameterSettingService.deleteWxParameterSettingByIds(ids));
    }
}
