代码拉取完成,页面将自动刷新
同步操作将从 uncle wang/OAuthApp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OAuthApp.Data;
using Swashbuckle.AspNetCore.Annotations;
using System.ComponentModel.DataAnnotations;
using System;
using OAuthApp.Filters;
using OAuthApp.Services;
using Microsoft.AspNetCore.Authorization;
namespace OAuthApp.Apis
{
[SwaggerTag("应用属性")]
[ServiceFilter(typeof(ApiRequestLoggingAttribute))]
public class PropertySettingsController : BaseController
{
private readonly AppDbContext _context;
public PropertySettingsController(AppDbContext context)
{
_context = context;
}
[HttpGet]
[SwaggerOperation(OperationId = "PropertySettings")]
[EncryptResultFilter]
public IActionResult List([Required]string channelCode,long channelAppId)
{
var result = _context.PropertySettings
.Where(x => x.ChannelCode == channelCode && x.ChannelAppId == channelAppId).ToList();
return OK(result);
}
[HttpPut("{id}")]
[SwaggerOperation(OperationId = "PropertySettingPut")]
public IActionResult Put(long id, PropertySetting appProperty)
{
var item = _context.PropertySettings
.FirstOrDefault(x => x.ID == appProperty.ID);
if (item == null)
{
return Error("不存在的属性");
}
try
{
item.Value = appProperty.Value;
item.Tag = appProperty.Tag;
item.APICanUse = appProperty.APICanUse;
_context.SaveChanges();
}
catch (Exception ex)
{
return Error(ex.Message);
}
return OK(true);
}
[HttpPost]
[SwaggerOperation(OperationId = "PropertySettingPost")]
public IActionResult Post(PropertySetting appProperty)
{
if (_context.PropertySettings.Any(x =>
x.ChannelCode == appProperty.ChannelCode &&
x.ChannelAppId == appProperty.ChannelAppId &&
x.Name == appProperty.Name))
{
return Error("已存在的属性");
}
_context.PropertySettings.Add(appProperty);
_context.SaveChanges();
return OK(new { id = appProperty.ID });
}
[HttpDelete("{id}")]
[SwaggerOperation(OperationId = "PropertySettingDelete")]
public IActionResult Delete(long id)
{
var appProperty = _context.PropertySettings.FirstOrDefault(x => x.ID == id);
if (appProperty == null)
{
return NotFound();
}
_context.PropertySettings.Remove(appProperty);
_context.SaveChanges();
return OK(true);
}
// 免验证获取应用配置信息
[HttpGet("{id}")]
[SwaggerOperation(OperationId = "PropertySetting")]
[AllowAnonymous]
public IActionResult Detail(long id, string tag, string name)
{
var result = _context.PropertySettings
.Where(x => x.ChannelCode.Equals(ChannelCodes.App)
&& x.ChannelAppId == id
&& x.Tag.Equals(tag)
&& x.Name.Equals(name))
.Select(x => new { id = x.ID, settings = x.Value })
.FirstOrDefault();
if (result == null)
{
return Error("不存在的配置");
}
return OK(result);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。