package com.vctgo.system.controller;

import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.vctgo.common.security.utils.SecurityUtils;
import com.vctgo.system.domain.SysAdminManage;
import com.vctgo.system.service.ISysAdminManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;

import java.util.List;

/**
 * 租户超管菜单管理Controller
 *
 * @author caesar
 * @date 2023-11-13
 */
@Api(tags = "租户超管菜单管理")
@RestController
@RequestMapping("/admin/manage")
public class SysAdminManageController extends BaseController {

    @Autowired
    private ISysAdminManageService sysAdminManageService;

    /**
     * 查询租户超管菜单管理分页列表
     */
    @ApiOperation("查询租户超管菜单管理分页列表")
    @RequiresPermissions("admin:manage:page")
    @GetMapping("/page")
    public AjaxResult page(SysAdminManage sysAdminManage) {
        IPage<SysAdminManage> pageList = sysAdminManageService.selectSysAdminManagePage(sysAdminManage);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出租户超管菜单管理列表
     */
    @ApiOperation("导出租户超管菜单管理列表")
    @RequiresPermissions("admin:manage:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAdminManage sysAdminManage) {
        List<SysAdminManage> list = sysAdminManageService.selectSysAdminManageList(sysAdminManage);
        ExcelUtil<SysAdminManage> util = new ExcelUtil<SysAdminManage>(SysAdminManage.class);
        util.exportExcel(response, list, "租户超管菜单管理数据");
    }

    /**
     * 获取租户超管菜单管理详细信息
     */
    @ApiOperation("获取租户超管菜单管理详细信息")
    @RequiresPermissions("admin:manage:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success((sysAdminManageService.selectSysAdminManageById(id)));
    }

    /**
     * 新增租户超管菜单管理
     */
    @ApiOperation("新增租户超管菜单管理")
    @RequiresPermissions("admin:manage:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysAdminManage sysAdminManage) {
        return toAjax(sysAdminManageService.insertSysAdminManage(sysAdminManage));
    }

    /**
     * 修改租户超管菜单管理
     */
    @ApiOperation("修改租户超管菜单管理")
    @RequiresPermissions("admin:manage:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysAdminManage sysAdminManage) {
        return toAjax(sysAdminManageService.updateSysAdminManage(sysAdminManage));
    }

    /**
     * 逻辑删除租户超管菜单管理
     */
    @ApiOperation("逻辑删除租户超管菜单管理")
    @RequiresPermissions("admin:manage:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysAdminManageService.logicalDeleteSysAdminManageByIds(ids));
    }

    /**
     * 删除租户超管菜单管理
     */
    @ApiOperation("删除租户超管菜单管理")
    @RequiresPermissions("admin:manage:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysAdminManageService.deleteSysAdminManageByIds(ids));
    }
}
