This commit is contained in:
zel
2025-03-09 03:46:28 +08:00
parent fb8c34f604
commit 7c4b851b43
8 changed files with 463 additions and 11 deletions

View File

@@ -1,11 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using SqlSugar;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.DataBase;
using WaterCloud.Domain.Entity.CustomerOrder;
namespace WaterCloud.Service.CustomerOrder;
public class CustomerOrderService:BaseService<CustomerOrderEntity>,IDenpendency
public class CustomerOrderService : BaseService<CustomerOrderEntity>, IDenpendency
{
public CustomerOrderService(ISqlSugarClient context) : base(context)
{
@@ -16,7 +20,70 @@ public class CustomerOrderService:BaseService<CustomerOrderEntity>,IDenpendency
{
var query = repository.IQueryable();
if (!string.IsNullOrWhiteSpace(keyword))
query = query.Where(oo=>oo.F_Name.Contains(keyword));
return await query.OrderBy(oo=>oo.F_CreatorTime).ToListAsync();
query = query.Where(oo => oo.F_Name.Contains(keyword));
//普通用户仅可查看自己的数据
if (!currentuser.IsAdmin || !currentuser.IsBoss || !currentuser.IsSuperAdmin || !currentuser.IsSenior)
query = query.Where(oo => oo.F_CreatorUserId == currentuser.UserId);
return await query.OrderBy(oo => oo.F_CreatorTime).ToListAsync();
}
public async Task<List<CustomerOrderEntity>> GetPageList(Pagination pagination, string keyword = "")
{
var query = repository.IQueryable().Where(a => a.F_DeleteMark == false);
if (!string.IsNullOrWhiteSpace(keyword))
query = query.Where(oo => oo.F_Name.Contains(keyword));
//普通用户仅可查看自己的数据
if (!currentuser.IsAdmin || !currentuser.IsBoss || !currentuser.IsSuperAdmin || !currentuser.IsSenior)
query = query.Where(oo => oo.F_CreatorUserId == currentuser.UserId);
return await query.ToPageListAsync(pagination);
}
public async Task<CustomerOrderEntity> GetForm(string keyValue)
{
var data = await repository.FindEntity(keyValue);
return data;
}
#region
public async Task SubmitForm(CustomerOrderEntity entity, string keyValue)
{
if (string.IsNullOrWhiteSpace(keyValue))
{
entity.F_DeleteMark = false;
entity.Create();
await repository.Insert(entity);
}
else
{
if ((!currentuser.IsAdmin || !currentuser.IsBoss || !currentuser.IsSuperAdmin || !currentuser.IsSenior) &&
currentuser.UserId != entity.F_CreatorUserId)
{
return;
}
entity.Modify(keyValue);
await repository.Update(entity);
}
}
public async Task DeleteForm(string keyValue)
{
var ids = keyValue.Split(',');
var data = await repository.FindEntity(keyValue);
if (data == null)
return;
if ((!currentuser.IsAdmin || !currentuser.IsBoss || !currentuser.IsSuperAdmin || !currentuser.IsSenior) &&
currentuser.UserId != data.F_CreatorUserId)
throw new Exception("违规删除");
await repository.Delete(oo=>ids.Contains(oo.F_Id));
}
#endregion
}