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.WxOtherSetting;
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.IWxOtherSettingService;

/**
 * 其他配置Controller
 *
 * @author flossom
 * @date 2023-12-13
 */
@RestController
@RequestMapping("/otherSetting")
public class WxOtherSettingController extends BaseController {
    @Autowired
    private IWxOtherSettingService wxOtherSettingService;

    /**
     * 查询其他配置列表
     */
    @RequiresPermissions("system:otherSetting:list")
    @GetMapping("/list")
    public TableDataInfo list(WxOtherSetting wxOtherSetting) {
        startPage();
        List<WxOtherSetting> list = wxOtherSettingService.selectWxOtherSettingList(wxOtherSetting);
        return getDataTable(list);
    }

    /**
     * 导出其他配置列表
     */
    @RequiresPermissions("system:otherSetting:export")
    @Log(title = "其他配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxOtherSetting wxOtherSetting) {
        List<WxOtherSetting> list = wxOtherSettingService.selectWxOtherSettingList(wxOtherSetting);
        ExcelUtil<WxOtherSetting> util = new ExcelUtil<WxOtherSetting>(WxOtherSetting.class);
        util.exportExcel(response, list, "其他配置数据");
    }

    /**
     * 获取其他配置详细信息
     */
    @RequiresPermissions("system:otherSetting:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wxOtherSettingService.selectWxOtherSettingById(id));
    }

    /**
     * 新增其他配置
     */
    @RequiresPermissions("system:otherSetting:add")
    @Log(title = "其他配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxOtherSetting wxOtherSetting) {
        return toAjax(wxOtherSettingService.insertWxOtherSetting(wxOtherSetting));
    }

    /**
     * 修改其他配置
     */
    @RequiresPermissions("system:otherSetting:edit")
    @Log(title = "其他配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxOtherSetting wxOtherSetting) {
        return toAjax(wxOtherSettingService.updateWxOtherSetting(wxOtherSetting));
    }

    /**
     * 删除其他配置
     */
    @RequiresPermissions("system:otherSetting:remove")
    @Log(title = "其他配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wxOtherSettingService.deleteWxOtherSettingByIds(ids));
    }
}
