89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
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 CustomerOrderService(ISqlSugarClient context) : base(context)
|
|
{
|
|
}
|
|
|
|
|
|
public async Task<List<CustomerOrderEntity>> GetList(string keyword = "")
|
|
{
|
|
var query = repository.IQueryable();
|
|
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.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
|
|
} |