Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using SqlSugar;
|
|
using WmsLite.Api.Models;
|
|
using WmsLite.Api.Repositories.Interfaces;
|
|
|
|
namespace WmsLite.Api.Repositories;
|
|
|
|
public class SysDictItemRepository : ISysDictItemRepository
|
|
{
|
|
private readonly ISqlSugarClient _db;
|
|
|
|
public SysDictItemRepository(ISqlSugarClient db)
|
|
{
|
|
_db = db;
|
|
}
|
|
|
|
public async Task<List<SysDictItem>> ListEnabledAsync(string tenantId, string ownerCode, IReadOnlyList<string>? categories)
|
|
{
|
|
var tenant = tenantId.Trim();
|
|
var owner = ownerCode.Trim();
|
|
|
|
var q = _db.Queryable<SysDictItem>()
|
|
.Where(x => !x.IsDeleted && x.IsEnabled &&
|
|
((x.TenantId == tenant && x.OwnerCode == owner)
|
|
|| (x.TenantId == "system" && x.OwnerCode == "system")));
|
|
|
|
if (categories is { Count: > 0 })
|
|
{
|
|
var set = categories.Select(c => c.Trim()).Where(c => c.Length > 0).Distinct().ToList();
|
|
if (set.Count > 0)
|
|
{
|
|
q = q.Where(x => set.Contains(x.Category));
|
|
}
|
|
}
|
|
|
|
return await q.OrderBy(x => x.Category).OrderBy(x => x.SortOrder).OrderBy(x => x.Code).ToListAsync();
|
|
}
|
|
}
|