package com.fzm.mall.server.admin.auth_center.controller;

import com.fzm.mall.server.admin.auth_center.entity.vo.RoleAuthMenuVO;
import com.fzm.mall.server.admin.auth_center.service.IAuthMenuService;
import com.fzm.mall.server.admin.home_page.enums.type.AdminTypeEnum;
import com.fzm.mall.server.admin.home_page.service.IAdminService;
import com.fzm.mall.server.admin.repo.ResponseFactory;
import com.fzm.mall.server.admin.repo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wangp
 * @date 2021/4/9 13:25
 * @description 功能管理
 * @since JDK 1.8
 */
@Api(tags = "权限中心-功能管理")
@RestController
@RequestMapping("/functionManage")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class FunctionManageController {

    private final IAuthMenuService authMenuService;
    private final IAdminService adminService;
    private final ResponseFactory resFac;

    @ApiOperation(value = "权限目录")
    @GetMapping("/authCatalogue")
    public ResponseVO authCatalogue(@RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        List<RoleAuthMenuVO> authMenu = authMenuService.getAllAuthMenu();
        return resFac.getSuccessResponseWithData(authMenu);
    }
}
