2016-01-05 17:14:10 +08:00
|
|
|
|
using Infrastructure;
|
2015-10-26 21:58:12 +08:00
|
|
|
|
using OpenAuth.App;
|
2015-11-05 23:27:08 +08:00
|
|
|
|
using OpenAuth.Mvc.Models;
|
2015-11-06 00:27:08 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Web.Mvc;
|
2017-11-29 20:49:14 +08:00
|
|
|
|
using OpenAuth.Repository.Domain;
|
2015-10-26 21:58:12 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
|
|
|
{
|
2015-11-06 00:27:08 +08:00
|
|
|
|
public class OrgManagerController : BaseController
|
|
|
|
|
{
|
2017-03-24 15:35:52 +08:00
|
|
|
|
public OrgManagerApp OrgApp { get; set; }
|
2015-11-06 00:27:08 +08:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// GET: /OrgManager/
|
2016-05-26 20:10:22 +08:00
|
|
|
|
[Authenticate]
|
2015-11-06 00:27:08 +08:00
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2018-05-20 13:54:56 +08:00
|
|
|
|
|
2017-10-11 16:19:34 +08:00
|
|
|
|
public string LoadForUser(string firstId)
|
2016-01-07 11:47:43 +08:00
|
|
|
|
{
|
2017-03-24 15:35:52 +08:00
|
|
|
|
var orgs = OrgApp.LoadForUser(firstId);
|
2016-01-07 11:47:43 +08:00
|
|
|
|
return JsonHelper.Instance.Serialize(orgs);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-11 16:19:34 +08:00
|
|
|
|
public string LoadForRole(string firstId)
|
2016-01-07 11:47:43 +08:00
|
|
|
|
{
|
2017-03-24 15:35:52 +08:00
|
|
|
|
var orgs = OrgApp.LoadForRole(firstId);
|
2016-01-07 11:47:43 +08:00
|
|
|
|
return JsonHelper.Instance.Serialize(orgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-11-05 23:27:08 +08:00
|
|
|
|
//添加组织提交
|
|
|
|
|
[HttpPost]
|
2017-12-08 05:49:00 +08:00
|
|
|
|
public string Add(Org org)
|
2015-11-05 23:27:08 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-08 05:49:00 +08:00
|
|
|
|
OrgApp.Add(org);
|
2015-11-06 00:27:08 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2017-11-28 23:54:49 +08:00
|
|
|
|
Result.Code = 500;
|
2016-10-14 11:22:16 +08:00
|
|
|
|
Result.Message = ex.Message;
|
2015-11-06 00:27:08 +08:00
|
|
|
|
}
|
2016-10-14 11:22:16 +08:00
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
2015-11-06 00:27:08 +08:00
|
|
|
|
}
|
2017-12-08 05:49:00 +08:00
|
|
|
|
|
|
|
|
|
//编辑
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public string Update(Org org)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OrgApp.Update(org);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Result.Code = 500;
|
|
|
|
|
Result.Message = ex.Message;
|
|
|
|
|
}
|
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 11:42:57 +08:00
|
|
|
|
/// <summary>
|
2015-11-05 23:27:08 +08:00
|
|
|
|
/// 删除指定ID的组织
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>System.String.</returns>
|
2016-10-14 17:50:44 +08:00
|
|
|
|
[HttpPost]
|
2017-10-27 00:26:06 +08:00
|
|
|
|
public string Delete(string[] ids)
|
2015-10-30 23:14:31 +08:00
|
|
|
|
{
|
2015-11-03 00:22:54 +08:00
|
|
|
|
try
|
2015-10-30 23:14:31 +08:00
|
|
|
|
{
|
2017-03-24 15:35:52 +08:00
|
|
|
|
OrgApp.DelOrg(ids);
|
2015-10-30 23:14:31 +08:00
|
|
|
|
}
|
2015-11-03 00:22:54 +08:00
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2017-11-28 23:54:49 +08:00
|
|
|
|
Result.Code = 500;
|
2016-10-14 11:22:16 +08:00
|
|
|
|
Result.Message = e.Message;
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-14 11:22:16 +08:00
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
2015-10-30 23:14:31 +08:00
|
|
|
|
}
|
2015-11-06 00:27:08 +08:00
|
|
|
|
}
|
2015-10-26 21:58:12 +08:00
|
|
|
|
}
|