using Common; using CommonInfrastructure; using Domain.Admin.Admin; using Microsoft.AspNetCore.Mvc; using MongoRepository; namespace UserApi.Dict { [ApiController, Route("api/[controller]")] public class DictController : BaseController { private readonly IMongoBaseRepository _dicRepo; public DictController(IMongoBaseRepository dicRepo) { _dicRepo = dicRepo; } [HttpGet("GetByCode")] public async Task> GetByCode(string code) { var dic = await _dicRepo.FindOneAsync(c => c.IsDelete == false && c.Code == code); return this.ToResult(dic); } [HttpGet("GetListByCode")] public async Task>> GetListByCode(string code) { var all = await _dicRepo.FilterByAsync(c => c.IsDelete == false); var parent = all.FirstOrDefault(c => c.Code == code); if (parent == null) return this.ToResult(new List()); var children = all.Where(c => c.ParentId == parent.Id).OrderBy(c => c.Order).ToList(); return this.ToResult(children); } } }