package com.skr.mdm.api.admin.controller;

import com.skr.mdm.api.admin.service.AdminPermissionService;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author nfq
 * @date 2020/9/10 16:23
 */
@RestController
@Api(tags = "管理员权限控制")
public class AdminPermission {

    @Autowired
    private AdminPermissionService adminPermissionService;

    @PostMapping("menuTree")
    @ApiOperation(value = "菜单树")
    public ResponseResult menuTree(@ApiIgnore Authentication authentication) {
        LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
        return adminPermissionService.menuTree(loginAdminDTO.getCompanyId(), loginAdminDTO.getRoleId());
    }

    @PostMapping("gaode/available")
    @ApiOperation(value = "高德服务是否可用")
    public ResponseResult getGaodeSid(@ApiIgnore Authentication authentication) {
        LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
        return adminPermissionService.getGaodeSid(loginAdminDTO.getCompanyId());
    }

}
