using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.ServiceApp.DataMaintenance;
using OpenAuth.Repository.Domain.DataMaintenance;
using OpenAuth.WebApi.Model.CustomAttribute;

namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
{
    /// <summary>
    /// 应用管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApplicationDataController : ControllerBase
    {
        readonly ApplicationManagementApp _app;

        public ApplicationDataController(ApplicationManagementApp app)
        {
            _app = app;
        }

        /// <summary>
        /// 查询应用列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<ApplicationData>>> GetApplicationList(string name)
        {
            return await _app.GetApplicationList(name);
        }
        /// <summary>
        /// 添加应用
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> AddApplication(ApplicationData app)
        {
            return await _app.Add(app);
        }
        /// <summary>
        /// 编辑应用
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateApplication(ApplicationData app)
        {
            return await _app.Update(app);
        }
        /// <summary>
        /// 删除应用
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> DeleteApplication(long id)
        {
            return await _app.Delete(id);
        }
    }
}
