using System.Threading.Tasks;
using New_College.IServices;
using New_College.Model;
using New_College.Model.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace New_College.Controllers
{
///
/// 用户角色关系
///
[Produces("application/json")]
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class UserRoleController : Controller
{
readonly ISysUserInfoServices _sysUserInfoServices;
readonly IUserRoleServices _userRoleServices;
readonly IRoleServices _roleServices;
///
/// 构造函数
///
///
///
///
public UserRoleController(ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices)
{
this._sysUserInfoServices = sysUserInfoServices;
this._userRoleServices = userRoleServices;
this._roleServices = roleServices;
}
///
/// 新建用户
///
///
///
///
[HttpGet]
public async Task> AddUser(string loginName, string loginPwd)
{
return new MessageModel()
{
success = true,
msg = "添加成功",
response = await _sysUserInfoServices.SaveUserInfo(loginName, loginPwd)
};
}
///
/// 新建Role
///
///
///
[HttpGet]
public async Task> AddRole(string roleName)
{
return new MessageModel()
{
success = true,
msg = "添加成功",
response = await _roleServices.SaveRole(roleName)
};
}
///
/// 新建用户角色关系
///
///
///
///
[HttpGet]
public async Task> AddUserRole(int uid, int rid)
{
return new MessageModel()
{
success = true,
msg = "添加成功",
response = await _userRoleServices.SaveUserRole(uid, rid)
};
}
}
}