SysDeptController.cs
2.16 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
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using WebApp;
using WebRepository;
namespace WebMvc
{
[Area("base")]
public class SysDeptController : BaseController
{
private SysDeptApp _app;
public SysDeptController(IAuth authUtil, SysDeptApp app) : base(authUtil)
{
_app = app.SetLoginInfo(_loginInfo);
}
//
// GET: /SysDept/
[Authenticate]
public ActionResult Index()
{
return View();
}
//添加组织提交
[HttpPost]
public string Add(SysDept org)
{
try
{
_app.Add(org);
}
catch (Exception ex)
{
Result.Code = 500;
Result.Message = ex.InnerException?.Message ?? ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
//编辑
[HttpPost]
public string Update(SysDept org)
{
try
{
_app.Update(org);
}
catch (Exception ex)
{
Result.Code = 500;
Result.Message = ex.InnerException?.Message ?? ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 删除指定ID的组织
/// </summary>
/// <returns>System.String.</returns>
[HttpPost]
public string Delete(int[] ids)
{
try
{
_app.Del(ids);
}
catch (Exception e)
{
Result.Code = 500;
Result.Message = e.InnerException?.Message ?? e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
public string LoadForUser(int firstId)
{
var orgs = _app.LoadForUser(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
public string LoadForRole(int firstId)
{
var orgs = _app.LoadForRole(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
}
}