package com.yida.data.system.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.Role;
import com.yida.data.system.service.IRoleService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "角色管理 不鉴权")
@RestController
@RequestMapping("/in/role")
public class InRoleController {
    @Resource
    private IRoleService roleService;

    @ApiOperation("根据角色名查询角色 不存在进行新增")
    @GetMapping("/getRoleByName")
    public ResultBean<Role> getRoleByName(String roleName) {
        return ResultBean.buildSuccess(roleService.getRoleByNameOrCreate(roleName));
    }
}
