package com.ruoyi.mall.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallConfigFunction;
import com.ruoyi.mall.service.IMallConfigFunctionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 更多功能Controller
 *
 * @author LCL
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/mall/mallConfigFunction")
public class MallConfigFunctionController extends BaseController
{
    @Resource
    private IMallConfigFunctionService mallConfigFunctionService;

    /**
     * 查询更多功能列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallConfigFunction mallConfigFunction)
    {
        startPage();
        List<MallConfigFunction> list = mallConfigFunctionService.selectMallConfigFunctionList(mallConfigFunction);
        return getDataTable(list);
    }

    /**
     * 导出更多功能列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:export')")
    @Log(title = "更多功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallConfigFunction mallConfigFunction)
    {
        List<MallConfigFunction> list = mallConfigFunctionService.selectMallConfigFunctionList(mallConfigFunction);
        ExcelUtil<MallConfigFunction> util = new ExcelUtil<MallConfigFunction>(MallConfigFunction.class);
        util.exportExcel(response, list, "更多功能数据");
    }

    /**
     * 获取更多功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:query')")
    @GetMapping(value = "/{configFunctionId}")
    public AjaxResult getInfo(@PathVariable("configFunctionId") Long configFunctionId)
    {
        return AjaxResult.success(mallConfigFunctionService.selectMallConfigFunctionByConfigFunctionId(configFunctionId));
    }

    /**
     * 新增更多功能
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:add')")
    @Log(title = "更多功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallConfigFunction mallConfigFunction)
    {
        return toAjax(mallConfigFunctionService.insertMallConfigFunction(mallConfigFunction));
    }

    /**
     * 修改更多功能
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:edit')")
    @Log(title = "更多功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallConfigFunction mallConfigFunction)
    {
        return toAjax(mallConfigFunctionService.updateMallConfigFunction(mallConfigFunction));
    }

    /**
     * 删除更多功能
     */
    @PreAuthorize("@ss.hasPermi('mall:mallConfigFunction:remove')")
    @Log(title = "更多功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configFunctionIds}")
    public AjaxResult remove(@PathVariable Long[] configFunctionIds)
    {
        return toAjax(mallConfigFunctionService.deleteMallConfigFunctionByConfigFunctionIds(configFunctionIds));
    }
}
