|
|
@@ -0,0 +1,97 @@ |
|
|
|
using BPA.SAAS.Manage.Application.Device.Dtos.Device; |
|
|
|
using BPA.SAAS.Manage.Application.Device.Dtos.ProductTopics; |
|
|
|
using BPA.SAAS.Manage.Application.Device.Interface; |
|
|
|
using BPA.SAAS.Manage.Comm.Enum; |
|
|
|
using BPA.SAAS.Manage.Core.Base; |
|
|
|
using BPA.SAAS.Manage.Core.Device; |
|
|
|
using BPA.SAAS.Manage.Core.Product; |
|
|
|
using StackExchange.Profiling.Internal; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace BPA.SAAS.Manage.Application.Device.Services |
|
|
|
{ |
|
|
|
public class ProductTopicsService : IProductTopicsService, ITransient |
|
|
|
{ |
|
|
|
private readonly ISqlSugarClient _db; |
|
|
|
public ProductTopicsService(ISqlSugarClient db) |
|
|
|
{ |
|
|
|
_db= db; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 分页查询 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<PageUtil> GetProductTopicsPage(ProductTopicsQueryInputDto inputDto) |
|
|
|
{ |
|
|
|
var total = new RefAsync<int>(); |
|
|
|
var data = await _db.Queryable<BPA_ProductTopics>().Where(x=>x.ProductId== inputDto.ProductId) |
|
|
|
.WhereIF(inputDto.TopicsType!=null, x => x.TopicsType==Convert.ToInt32(inputDto.TopicsType)) |
|
|
|
.OrderBy(x => x.CreateAt, OrderByType.Desc) |
|
|
|
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); |
|
|
|
|
|
|
|
return new PageUtil() |
|
|
|
{ |
|
|
|
Data = data, |
|
|
|
Total = total |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 添加 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> AddProductTopics(ProductTopicsBaseDto inputDto) |
|
|
|
{ |
|
|
|
BPA_ProductTopics BPA_ProductTopics = inputDto.Adapt<BPA_ProductTopics>(); |
|
|
|
var res = await _db.Insertable(BPA_ProductTopics).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); |
|
|
|
return res != null; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 更新 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> UpdateProductTopics(ProductTopicsBaseDto inputDto) |
|
|
|
{ |
|
|
|
var data = await _db.Queryable<BPA_ProductTopics>().Where(x => x.Id == inputDto.Id).FirstAsync(); |
|
|
|
|
|
|
|
if (data != null) |
|
|
|
{ |
|
|
|
var product = _db.Queryable<BPA_ProductTopics>().Where(x => x.Id == inputDto.ProductId).First(); |
|
|
|
var inputData = inputDto.Adapt<BPA_ProductTopics>(); |
|
|
|
var res = await _db.Updateable(inputData) |
|
|
|
.UpdateColumns(x => new |
|
|
|
{ |
|
|
|
x.Topics, |
|
|
|
x.TopicsType, |
|
|
|
x.Description, |
|
|
|
}) |
|
|
|
.Where(x => x.Id == inputDto.Id).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 删除 |
|
|
|
/// </summary> |
|
|
|
/// <param name="inputList"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> DelProductTopics(List<string> inputList) |
|
|
|
{ |
|
|
|
var data = await _db.Queryable<BPA_ProductTopics>().Where(x => inputList.Contains(x.Id)).ToListAsync(); |
|
|
|
foreach (var item in data) |
|
|
|
{ |
|
|
|
item.IsDeleted = 1; |
|
|
|
} |
|
|
|
var res = await _db.Updateable(data).ExecuteCommandAsync(); |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |