sysappsetting

main
冉成楼 1 month ago
parent 471ffd2fe1
commit a0942d1dbe

@ -0,0 +1,38 @@
using Infrastructure;
using Infrastructure.Extensions;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Interface;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App
{
public class SysAppSettingApp : SqlSugarBaseApp<SysAppSetting, SugarDbContext>
{
public SysAppSettingApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<SysAppSetting> repository, IAuth auth) : base(unitWork, repository, auth)
{
}
public async Task<SysAppSetting> Get(long id)
{
return await Repository.GetByIdAsync(id);
}
public async Task<Response<bool>> Save(SysAppSetting model)
{
var flag = await base.UnitWork.Db.Storageable(model).ExecuteCommandAsync();
return new Response<bool>
{
Result = flag > 0,
Message = flag > 0 ? "success" : "error"
};
}
}
}

@ -0,0 +1,19 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.Repository.Domain
{
[SugarTable]
public class SysAppSetting
{
[SugarColumn(IsPrimaryKey = true)]
public long UserId { get; set; }
[SugarColumn(IsJson = true)]
public string SettingInfo { get; set; }
}
}

@ -0,0 +1,58 @@
using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
using System.Threading.Tasks;
namespace OpenAuth.WebApi.Controllers.BaseControllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class SysAppSettingController : ControllerBase
{
private readonly SysAppSettingApp _app;
public SysAppSettingController(SysAppSettingApp app)
{
_app = app;
}
[AllowAnonymous]
[HttpGet]
public async Task<Response<SysAppSetting>> Get(long id)
{
var result = new Response<SysAppSetting>();
try
{
result.Result = await _app.Get(id);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
[AllowAnonymous]
[HttpPost]
public async Task<Response<bool>> Save(SysAppSetting obj)
{
var result = new Response<bool>();
try
{
result = await _app.Save(obj);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
}
}
Loading…
Cancel
Save