添加项目文件。

This commit is contained in:
2026-10-12 16:22:04 +08:00
parent 7c68a0ca0a
commit aad11be43d
1000 changed files with 120807 additions and 0 deletions
@@ -0,0 +1,63 @@
using Common;
using CommonDomain;
using CommonInfrastructure;
using Microsoft.AspNetCore.Mvc;
using MongoDB.Driver;
using MongoRepository;
namespace AdminApi.GameConfigs
{
[ApiController, Route("adminapi/[controller]")]
public class BotConfigController : BaseController
{
private readonly IMongoBaseRepository<BotProfileEntity> _botRepo;
public BotConfigController(IMongoBaseRepository<BotProfileEntity> botRepo)
{
_botRepo = botRepo;
}
[HttpGet("GetAll")]
public async Task<BaseResponse<List<BotProfileEntity>>> GetAll()
{
var list = await _botRepo.FilterByAsync(_ => true);
return this.ToResult(list.ToList());
}
[HttpPost("Add")]
public async Task<BaseResponse<string>> Add(BotProfileEntity entity)
{
if (string.IsNullOrWhiteSpace(entity.Name))
return this.ToFailResult<string>("名称不能为空");
await _botRepo.InsertOneAsync(entity);
return this.ToResult("添加成功");
}
[HttpPost("Update")]
public async Task<BaseResponse<string>> Update(BotProfileEntity entity)
{
if (string.IsNullOrWhiteSpace(entity.Id))
return this.ToFailResult<string>("缺少Id");
if (string.IsNullOrWhiteSpace(entity.Name))
return this.ToFailResult<string>("名称不能为空");
var update = Builders<BotProfileEntity>.Update
.Set(x => x.Name, entity.Name)
.Set(x => x.Avatar, entity.Avatar ?? string.Empty);
await _botRepo.UpdateByIdAsync(entity.Id, update);
return this.ToResult("更新成功");
}
[HttpPost("Delete")]
public async Task<BaseResponse<string>> Delete([FromQuery] string id)
{
if (string.IsNullOrWhiteSpace(id))
return this.ToFailResult<string>("缺少Id");
await _botRepo.DeleteByIdAsync(id);
return this.ToResult("删除成功");
}
}
}