OpenAuth.Net/OpenAuth.Mvc/Controllers/ApplicationsController.cs

87 lines
2.1 KiB
C#
Raw Normal View History

2018-04-13 17:25:49 +08:00
using System;
using System.Collections.Generic;
2020-12-17 23:04:04 +08:00
using System.Threading.Tasks;
2018-04-13 17:25:49 +08:00
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
2018-04-13 17:25:49 +08:00
using OpenAuth.App;
using OpenAuth.App.Interface;
2018-04-13 17:25:49 +08:00
using OpenAuth.App.Request;
using OpenAuth.Repository.Domain;
namespace OpenAuth.Mvc.Controllers
{
public class ApplicationsController : BaseController
{
private readonly AppManager _app;
2018-04-13 17:25:49 +08:00
2020-12-17 23:04:04 +08:00
public async Task<string> GetList([FromQuery]QueryAppListReq request)
2018-04-13 17:25:49 +08:00
{
var resp = new Response<List<Application>>();
try
{
2020-12-17 23:04:04 +08:00
resp.Result = await _app.GetList(request);
}
catch (Exception e)
{
resp.Code = 500;
resp.Message = e.Message;
}
return JsonHelper.Instance.Serialize(resp);
2018-04-13 17:25:49 +08:00
}
[HttpPost]
2018-04-13 17:25:49 +08:00
public string Delete(string[] ids)
{
Response resp = new Response();
try
{
_app.Delete(ids);
2018-04-13 17:25:49 +08:00
}
catch (Exception e)
{
resp.Code = 500;
resp.Message = e.Message;
}
return JsonHelper.Instance.Serialize(resp);
}
[HttpPost]
2018-04-13 17:25:49 +08:00
public string Add(Application obj)
{
Response resp = new Response();
try
{
_app.Add(obj);
2018-04-13 17:25:49 +08:00
}
catch (Exception e)
{
resp.Code = 500;
resp.Message = e.Message;
}
return JsonHelper.Instance.Serialize(resp);
}
[HttpPost]
2018-04-13 17:25:49 +08:00
public string Update(Application obj)
{
Response resp = new Response();
try
{
_app.Update(obj);
2018-04-13 17:25:49 +08:00
}
catch (Exception e)
{
resp.Code = 500;
resp.Message = e.Message;
}
return JsonHelper.Instance.Serialize(resp);
}
public ApplicationsController(IAuth authUtil, AppManager app) : base(authUtil)
{
_app = app;
}
2018-04-13 17:25:49 +08:00
}
}