Add WmsLite monorepo with JWT auth, tenant context, and project READMEs.
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>
This commit is contained in:
commit
fa1b286463
241 files changed
+31188
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
using WmsLite.Api.Common;
|
||||
using WmsLite.Api.Dtos.Container;
|
||||
using WmsLite.Api.Infrastructure.Auth;
|
||||
using WmsLite.Api.Models;
|
||||
using WmsLite.Api.Repositories.Interfaces;
|
||||
|
||||
namespace WmsLite.Api.Repositories;
|
||||
|
||||
public class ContainerRepository : BaseRepository<Container>, IContainerRepository
|
||||
{
|
||||
public ContainerRepository(ISqlSugarClient db, ICurrentUserContext userContext) : base(db, userContext)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Container?> GetByCodeAsync(string tenantId, string ownerCode, string code)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var tenant = tenantId.Trim();
|
||||
var owner = ownerCode.Trim();
|
||||
return await Db.Queryable<Container>()
|
||||
.Where(x => !x.IsDeleted && x.TenantId == tenant && x.OwnerCode == owner && x.Code == code.Trim())
|
||||
.FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<PagedResult<Container>> GetPagedListAsync(ContainerPagedQuery query)
|
||||
{
|
||||
var pageIndex = query.PageIndex <= 0 ? 1 : query.PageIndex;
|
||||
var pageSize = query.PageSize <= 0 ? 20 : query.PageSize;
|
||||
var tenantId = query.TenantId.Trim();
|
||||
var ownerCode = query.OwnerCode.Trim();
|
||||
var kw = query.Keyword?.Trim();
|
||||
|
||||
var dbQuery = Db.Queryable<Container>()
|
||||
.Where(x => !x.IsDeleted && x.TenantId == tenantId && x.OwnerCode == ownerCode)
|
||||
.WhereIF(
|
||||
!string.IsNullOrWhiteSpace(kw),
|
||||
x =>
|
||||
x.Code.Contains(kw!) ||
|
||||
(x.Name != null && x.Name.Contains(kw!)))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(query.Code), x => x.Code.Contains(query.Code!.Trim()))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(query.Name), x => x.Name != null && x.Name.Contains(query.Name!.Trim()))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(query.ContainerType),
|
||||
x => x.ContainerType != null && x.ContainerType.Contains(query.ContainerType!.Trim()));
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
var items = await dbQuery
|
||||
.OrderByDescending(x => x.UpdateTime)
|
||||
.OrderByDescending(x => x.CreateTime)
|
||||
.ToPageListAsync(pageIndex, pageSize, total);
|
||||
|
||||
return new PagedResult<Container>
|
||||
{
|
||||
PageIndex = pageIndex,
|
||||
PageSize = pageSize,
|
||||
TotalCount = total,
|
||||
Items = items
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user