package com.cpop.system.business.controller.backstage;

import com.cpop.core.base.R;
import com.cpop.system.business.service.LoginService;
import com.cpop.system.business.vo.LoginUserInfoVo;
import com.cpop.system.business.vo.MenuRouteVo;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author DB
 * @createTime 2023/09/10 11:13
 * @description 系统登陆
 */
@Api(tags = "通用系统登录模块")
@RestController
@RequestMapping("/backstage")
public class BackstageLoginController {

    @Autowired
    private LoginService loginService;

    /**
     * @author LOST.yuan
     * @Description 获取登录用户详情
     * @date 14:52 2022/9/7
     * @return {@link R<LoginUserInfoVo>}
     **/
    @GetMapping("/getUserInfo")
    @ApiOperation("获取登录用户详情")
    public R<LoginUserInfoVo> getUserInfo() {
        return R.ok(loginService.getUserInfo());
    }

    /**
     * @author LOST.yuan
     * @Description 获取权限码
     * @date 14:52 2022/9/7
     * @return {@link List<String>}
     **/
    @ApiOperation("获取权限码")
    @GetMapping("/getPermCode")
    public R<Set<String>> getPermCode(){
        Set<String> list = loginService.getPermCode();
        return R.ok(list);
    }

    /**
     * @author LOST.yuan
     * @Description 获取菜单列表
     * @date 14:52 2022/9/7
     * @return {@link R<List<MenuRouteVo>>}
     **/
    @ApiOperation("获取菜单列表")
    @GetMapping("/getMenuList")
    public R<List<MenuRouteVo>> getMenuList(){
        List<MenuRouteVo> list = loginService.getSysMenuList();
        return R.ok(list);
    }
}
