SysRoleController.cs
2.89 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using WebApp;
using WebRepository;
namespace WebMvc
{
[Area("base")]
public class SysRoleController : BaseController
{
private readonly SysRoleApp _app;
private readonly SysRevelanceApp _sysRevelanceApp;
public SysRoleController(IAuth authUtil, SysRevelanceApp sysRevelanceApp, SysRoleApp app) : base(authUtil)
{
_sysRevelanceApp = sysRevelanceApp.SetLoginInfo(_loginInfo);
_app = app.SetLoginInfo(_loginInfo);
}
//
// GET: /SysUser/
[Authenticate]
public ActionResult Index()
{
return View();
}
public ActionResult Assign()
{
return View();
}
//添加或修改组织
[HttpPost]
public string Add(SysRoleView obj)
{
try
{
_app.Add(obj);
}
catch (Exception ex)
{
Result.Code = 500;
Result.Message = ex.InnerException?.Message ?? ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
//添加或修改组织
[HttpPost]
public string Update(SysRoleView obj)
{
try
{
_app.Update(obj);
}
catch (Exception ex)
{
Result.Code = 500;
Result.Message = ex.InnerException?.Message ?? ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
[HttpPost]
public string Delete(int[] ids)
{
try
{
_app.Delete(ids);
}
catch (Exception e)
{
Result.Code = 500;
Result.Message = e.InnerException?.Message ?? e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载用户的角色
/// </summary>
public string LoadForUser(int userId)
{
try
{
var result = new Response<List<int>>
{
Result = _sysRevelanceApp.Get(Define.USERROLE, true, userId)
};
return JsonHelper.Instance.Serialize(result);
}
catch (Exception e)
{
Result.Code = 500;
Result.Message = e.InnerException?.Message ?? e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载组织下面的所有用户
/// </summary>
[HttpPost]
public string Load(PageReq pageRequest)
{
return JsonHelper.Instance.Serialize(_app.Load(pageRequest));
}
}
}