forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserRoleController.cs
More file actions
92 lines (81 loc) · 2.69 KB
/
UserRoleController.cs
File metadata and controls
92 lines (81 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Threading.Tasks;
using Blog.Core.IServices;
using Blog.Core.Model;
using Blog.Core.Model.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Blog.Core.Controllers
{
/// <summary>
/// 用户角色关系
/// </summary>
[Produces("application/json")]
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class UserRoleController : Controller
{
readonly ISysUserInfoServices _sysUserInfoServices;
readonly IUserRoleServices _userRoleServices;
readonly IRoleServices _roleServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="sysUserInfoServices"></param>
/// <param name="userRoleServices"></param>
/// <param name="roleServices"></param>
public UserRoleController(ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices)
{
this._sysUserInfoServices = sysUserInfoServices;
this._userRoleServices = userRoleServices;
this._roleServices = roleServices;
}
/// <summary>
/// 新建用户
/// </summary>
/// <param name="loginName"></param>
/// <param name="loginPwd"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<sysUserInfo>> AddUser(string loginName, string loginPwd)
{
return new MessageModel<sysUserInfo>()
{
success = true,
msg = "添加成功",
response = await _sysUserInfoServices.SaveUserInfo(loginName, loginPwd)
};
}
/// <summary>
/// 新建Role
/// </summary>
/// <param name="roleName"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<Role>> AddRole(string roleName)
{
return new MessageModel<Role>()
{
success = true,
msg = "添加成功",
response = await _roleServices.SaveRole(roleName)
};
}
/// <summary>
/// 新建用户角色关系
/// </summary>
/// <param name="uid"></param>
/// <param name="rid"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<UserRole>> AddUserRole(int uid, int rid)
{
return new MessageModel<UserRole>()
{
success = true,
msg = "添加成功",
response = await _userRoleServices.SaveUserRole(uid, rid)
};
}
}
}