Преглед изворни кода

Merge branch 'groupmealmanage' of http://10.2.1.24:10244/zhaoy/BPA.SAAS.Manage into groupmealmanage

groupmealmanage
gwbvipvip пре 7 месеци
родитељ
комит
590446d462
16 измењених фајлова са 606 додато и 1 уклоњено
  1. +14
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsEnergyConfigQuDto.cs
  2. +23
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsEnergyConfigVuewDto.cs
  3. +11
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs
  4. +33
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs
  5. +7
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs
  6. +16
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsDto.cs
  7. +14
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsQueryDto.cs
  8. +15
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsViewDto.cs
  9. +23
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDto.cs
  10. +15
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigQueryDto.cs
  11. +102
    -0
      BPA.SAAS.Manage.Application/DataBase/GoodsEnergyConfigServices.cs
  12. +63
    -0
      BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsEnergyConfigService.cs
  13. +231
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsEnergyConfigService.cs
  14. +19
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsEnergyConfig.cs
  15. +19
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsEnergyConfigDetails.cs
  16. +1
    -1
      BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json

+ 14
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsEnergyConfigQuDto.cs Прегледај датотеку

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsEnergyConfigQuDto
{
public string GoodsId { get; set; }
public string Name { get; set; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Dtos/GoodsEnergyConfigVuewDto.cs Прегледај датотеку

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos
{
public class GoodsEnergyConfigVuewDto
{
public string Id { get; set; }
public string GoodsId { get; set; }
public string Name { get; set; }
//public string Uint { get; set; }
public List<GoodsEnergyConfigDetailsView> Details { get; set; }
}
public class GoodsEnergyConfigDetailsView
{
public string Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
}

+ 11
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/GoodsServices.cs Прегледај датотеку

@@ -2,6 +2,7 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Core.Base;
using Microsoft.AspNetCore.Components.Forms;
using Org.BouncyCastle.Crypto;
@@ -181,5 +182,15 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods
{
return await _goodsService.DelGoodsUint(dto);
}
/// <summary>
/// 查询商品能量配置
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/ExternalPlatform/Goods/GetGoodsEnergyConfig")]
public async Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto)
{
return await _goodsService.GetGoodsEnergyConfigPage(dto);
}
}
}

+ 33
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/GoodsService.cs Прегледај датотеку

@@ -6,6 +6,7 @@ using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services;
using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsType;
using BPA.SAAS.Manage.Core.Base;
@@ -440,6 +441,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
List<BPA_GoodsType> GoodsTypelist = new();
for (int i = 0; i < dto.Count; i++)
{
if (dto[i].Pid == null) dto[i].Pid = "0";
var resEntity = new BPA_GoodsType();
resEntity.Id = Guid.NewGuid().ToString();
resEntity.Name = dto[i].Name;
@@ -462,6 +464,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
{
var model=SqlSugarDb.Db.Queryable<BPA_GoodsType>().Where(x => x.Id == dto.Id).First();
if(model==null) throw Oops.Oh("商品分类不存在");
if (dto.Pid == null) dto.Pid = "0";
model.Name = dto.Name;
model.Pid =string.IsNullOrEmpty(dto.Pid)?"0": dto.Pid;
model.Sort = dto.Sort;
@@ -559,6 +562,36 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
}

}
/// <summary>
/// 查询商品能量配置
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto)
{
List<IConditionalModel> conModels = new List<IConditionalModel>();
//string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
if (!string.IsNullOrEmpty(dto.Name))
{
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name });
}
if (!string.IsNullOrEmpty(dto.GoodsId))
{
conModels.Add(new ConditionalModel() { FieldName = "GoodsId", ConditionalType = ConditionalType.Like, FieldValue = dto.GoodsId });
}
int total = new RefAsync<int>();
var res = await SqlSugarDb.Db.Queryable<BPA_GoodsEnergyConfig>()
.Where(conModels)
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.Select(x=>new GoodsEnergyConfigVuewDto() { Id=x.Id,Name=x.Name, GoodsId =x.GoodsId})
.Mapper(x =>
{
var data=SqlSugarDb.Db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == x.Id).Select(it=>new GoodsEnergyConfigDetailsView() { Id=it.Id.SelectAll()}).ToList();
x.Details = data;
})
.ToListAsync();
return res;
}
private string GetNumber2(int Length = 10)
{
byte[] buffer = Guid.NewGuid().ToByteArray();


+ 7
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Goods/Services/IGoodsService.cs Прегледај датотеку

@@ -1,5 +1,6 @@
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
@@ -61,5 +62,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services
Task<bool> AddGoodsUint(List<GoodsUintInsertDto> dto);
Task<bool> UpdateGoodsUint(GoodsUintUpdateDto dto);
Task<bool> DelGoodsUint(GoodsUintDelDto dto);
/// <summary>
/// 查询商品能量配置
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto);
}
}

+ 16
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsDto.cs Прегледај датотеку

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig
{
public class GoodsEnergyConfigDetailsDto
{
public string Id { get; set; }
public string GoodsenergyconfigId { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsQueryDto.cs Прегледај датотеку

@@ -0,0 +1,14 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig
{
public class GoodsEnergyConfigDetailsQueryDto: PageInputBase
{
public string GoodsenergyconfigId { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDetailsViewDto.cs Прегледај датотеку

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig
{
public class GoodsEnergyConfigDetailsViewDto
{
public string Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigDto.cs Прегледај датотеку

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig
{
public class GoodsEnergyConfigDto
{
public string Id { get; set; }
public string GoodsId { get; set; }
public string Name { get; set; }
public string Uint { get; set; }
public List<GoodsEnergyConfigDetails> Details { get; set; }

}
public class GoodsEnergyConfigDetails
{
public string Key { get; set; }
public string Value { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsEnergyConfig/GoodsEnergyConfigQueryDto.cs Прегледај датотеку

@@ -0,0 +1,15 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig
{
public class GoodsEnergyConfigQueryDto: PageInputBase
{
public string GoodsId { get; set; }
public string Name { get; set; }
}
}

+ 102
- 0
BPA.SAAS.Manage.Application/DataBase/GoodsEnergyConfigServices.cs Прегледај датотеку

@@ -0,0 +1,102 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase
{
[ApiDescriptionSettings("GoodsEnergyConfig", Tag = "商品能量配置")]
public class GoodsEnergyConfigServices: IDynamicApiController, ITransient
{
IGoodsEnergyConfigService _energyConfigService;
public GoodsEnergyConfigServices(IGoodsEnergyConfigService energyConfigService)
{
_energyConfigService=energyConfigService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsenergyconfig/getgoodsenergyconfigpage")]
public async Task<PageUtil> GetGoodsEnergyConfigPage(GoodsEnergyConfigQueryDto dto)
{
return await _energyConfigService.GetGoodsEnergyConfigPage(dto);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsenergyconfig/addGoodsenergyconfig")]
public async Task<bool> AddGoodsEnergyConfig(GoodsEnergyConfigDto dto)
{
return await _energyConfigService.AddGoodsEnergyConfig(dto);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsenergyconfig/updategoodsenergyconfig")]
public async Task<bool> UpdateGoodsEnergyConfig(GoodsEnergyConfigDto dto)
{
return await _energyConfigService.UpdateGoodsEnergyConfig(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/goodsenergyconfig/delgoodsenergyconfig")]
public async Task<bool> DelGoodsEnergyConfig(string Id)
{
return await _energyConfigService.DelGoodsEnergyConfig(Id);
}
/// <summary>
/// 查询详情
/// </summary>
/// <param name="goodsenergyconfigId"></param>
/// <returns></returns>
[HttpGet("/api/goodsenergyconfig/getgoodsenergyconfigdetailslist")]
public async Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId)
{
return await _energyConfigService.GetGoodsEnergyConfigDetailsList(goodsenergyconfigId);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsenergyconfig/addgoodsenergyconfigdetails")]
public async Task<bool> AddGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto)
{
return await _energyConfigService.AddGoodsEnergyConfigDetails(dto);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsenergyconfig/updategoodsenergyconfigdetails")]
public async Task<bool> UpdateGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto)
{
return await _energyConfigService.UpdateGoodsEnergyConfigDetails(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/goodsenergyconfig/delgoodsenergyconfigdetails")]
public async Task<bool> DelGoodsEnergyConfigDetails(string Id)
{
return await _energyConfigService.DelGoodsEnergyConfigDetails(Id);
}
}
}

+ 63
- 0
BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsEnergyConfigService.cs Прегледај датотеку

@@ -0,0 +1,63 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Interface
{
public interface IGoodsEnergyConfigService
{
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<PageUtil> GetGoodsEnergyConfigPage(GoodsEnergyConfigQueryDto dto);
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoodsEnergyConfig(GoodsEnergyConfigDto dto);
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> UpdateGoodsEnergyConfig(GoodsEnergyConfigDto dto);
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
Task<bool> DelGoodsEnergyConfig(string Id);
/// <summary>
/// 查询详情
/// </summary>
/// <param name="goodsenergyconfigId"></param>
/// <returns></returns>
Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId);
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto);
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> UpdateGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto);
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
Task<bool> DelGoodsEnergyConfigDetails(string Id);
}
}

+ 231
- 0
BPA.SAAS.Manage.Application/DataBase/Services/GoodsEnergyConfigService.cs Прегледај датотеку

@@ -0,0 +1,231 @@
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsType;
using BPA.SAAS.Manage.Application.DataBase.Interface;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
using NPOI.POIFS.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.DataBase.Services
{
public class GoodsEnergyConfigService: IGoodsEnergyConfigService, ITransient
{
private readonly ISqlSugarClient _db;
public GoodsEnergyConfigService(ISqlSugarClient db)
{
_db = db;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<PageUtil> GetGoodsEnergyConfigPage(GoodsEnergyConfigQueryDto dto)
{
List<IConditionalModel> conModels = new List<IConditionalModel>();
//string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
if (!string.IsNullOrEmpty(dto.Name))
{
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name });
}
if (!string.IsNullOrEmpty(dto.GoodsId))
{
conModels.Add(new ConditionalModel() { FieldName = "GoodsId", ConditionalType = ConditionalType.Like, FieldValue = dto.GoodsId });
}
int total = new RefAsync<int>();
var res = await _db.Queryable<BPA_GoodsEnergyConfig>()
.Where(conModels)
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.ToPageListAsync(dto.Current, dto.PageSize, total);
PageUtil util = new PageUtil()
{
Total = total,
Data = res

};
return util;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsEnergyConfig(GoodsEnergyConfigDto dto)
{
try
{
_db.Ado.BeginTran();
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name);
if (resEntity != null) throw Oops.Oh("配置名称已存在");
var newType = new BPA_GoodsEnergyConfig
{
GoodsId = dto.GoodsId,
Name = dto.Name,
Uint = dto.Uint,
};
var model = await _db.Insertable(newType).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
List<BPA_GoodsEnergyConfigDetails> list = new();
for (int i = 0; i < dto.Details.Count; i++)
{
var model1 = new BPA_GoodsEnergyConfigDetails
{
GoodsenergyconfigId = model.Id,
Key = dto.Details[i].Key,
Value = dto.Details[i].Value,
};
list.Add(model1);
}
var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
_db.Ado.CommitTran();
return res > 0;
}
catch (Exception e)
{
_db.Ado.RollbackTran();
throw Oops.Oh("系统异常,异常信息:"+ e.Message);
}
}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateGoodsEnergyConfig(GoodsEnergyConfigDto dto)
{
try
{
_db.Ado.BeginTran();
// 查询数据库中是否存在未删除的商品类型
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == dto.Id);
if (null == resEntity) throw Oops.Oh("配置不存在");
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.Id != dto.Id);
if (resEntity1 != null) throw Oops.Oh("配置名称已存在");
resEntity.Name = dto.Name;
resEntity.Uint = dto.Uint;
await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
var model = _db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == dto.Id).ToList();
if (model.Count > 0) await _db.Deleteable(model).ExecuteCommandAsync();
List<BPA_GoodsEnergyConfigDetails> list = new();
for (int i = 0; i < dto.Details.Count; i++)
{
var model1 = new BPA_GoodsEnergyConfigDetails
{
GoodsenergyconfigId = dto.Id,
Key = dto.Details[i].Key,
Value = dto.Details[i].Value,
};
list.Add(model1);
}
var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
_db.Ado.CommitTran();
return res > 0;
}
catch (Exception e)
{
_db.Ado.RollbackTran();
throw Oops.Oh("系统异常,异常信息:" + e.Message);
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public async Task<bool> DelGoodsEnergyConfig(string Id)
{
try
{
_db.Ado.BeginTran();
// 查询数据库中是否存在未删除的商品类型
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == Id);
if (resEntity == null)
{
throw Oops.Oh("配置不存在");
}
var model = _db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == Id).ToList();
if (model.Count > 0) await _db.Deleteable(model).ExecuteCommandAsync();
var res = await _db.Deleteable(resEntity).ExecuteCommandAsync();
_db.Ado.CommitTran();
return res > 0;
}
catch (Exception e)
{

_db.Ado.RollbackTran();
throw Oops.Oh("系统异常,异常信息:" + e.Message);
}
}
public async Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId)
{

int total = new RefAsync<int>();
var res = await _db.Queryable<BPA_GoodsEnergyConfigDetails>()
.Where(x=>x.GoodsenergyconfigId== goodsenergyconfigId)
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.Select(x => new GoodsEnergyConfigDetailsViewDto() { Id=x.Id,Key=x.Key,Value=x.Value})
.ToListAsync();
return res;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto)
{
var resEntity = _db.Queryable<BPA_GoodsEnergyConfigDetails>().First(it => it.Key == dto.Key);
if(resEntity!=null) throw Oops.Oh("key已存在");
var newType = new BPA_GoodsEnergyConfigDetails
{
GoodsenergyconfigId = dto.GoodsenergyconfigId,
Key = dto.Key,
Value = dto.Value,
};
var res = await _db.Insertable(newType).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateGoodsEnergyConfigDetails(GoodsEnergyConfigDetailsDto dto)
{
// 查询数据库中是否存在未删除的商品类型
var resEntity = _db.Queryable<BPA_GoodsEnergyConfigDetails>().First(it => it.Id == dto.Id);
if (null == resEntity) throw Oops.Oh("配置不存在");
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfigDetails>().First(it => it.Key == dto.Key && it.Id != dto.Id);
if (resEntity1 != null) throw Oops.Oh("配置Key已存在");
resEntity.Key = dto.Key;
resEntity.Value = dto.Value;
var res = await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public async Task<bool> DelGoodsEnergyConfigDetails(string Id)
{
// 查询数据库中是否存在未删除的商品类型
var resEntity = _db.Queryable<BPA_GoodsEnergyConfigDetails>().First(it => it.Id == Id);
if (resEntity == null)
{
throw Oops.Oh("配置不存在");
}
var res = await _db.Deleteable(resEntity).ExecuteCommandAsync();
return res > 0;
}
}
}

+ 19
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsEnergyConfig.cs Прегледај датотеку

@@ -0,0 +1,19 @@
using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.DataBase
{
[SugarTable("bpa_goodsenergyconfig")]
public class BPA_GoodsEnergyConfig : IBaseEntity, IGroupId
{
public string GoodsId { get; set; }
public string Name { get; set; }
public string Uint { get; set; }
public string GroupId { get; set ; }
}
}

+ 19
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsEnergyConfigDetails.cs Прегледај датотеку

@@ -0,0 +1,19 @@
using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.DataBase
{
[SugarTable("bpa_goodsenergyconfigdetails")]
public class BPA_GoodsEnergyConfigDetails : IBaseEntity, IGroupId
{
public string GoodsenergyconfigId { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public string GroupId { get ; set; }
}
}

+ 1
- 1
BPA.SAAS.Manage.Web.Entry/Properties/launchSettings.json Прегледај датотеку

@@ -14,7 +14,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://192.168.1.16:5001"
"applicationUrl": "http://localhost:5001"
},
"Docker": {
"commandName": "Docker",


Loading…
Откажи
Сачувај