diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
index 9d5a9b5..20bc9e5 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
@@ -114,5 +114,20 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum
///
[ErrorCodeItemMetadata("名称或编码重复")]
Code10017,
+ ///
+ /// 模板名称不能重复
+ ///
+ [ErrorCodeItemMetadata("模板名称不能重复")]
+ Code10018,
+ ///
+ /// 设备id不能为空
+ ///
+ [ErrorCodeItemMetadata("设备id不能为空")]
+ Code10019,
+ ///
+ /// 模板名称不能为空
+ ///
+ [ErrorCodeItemMetadata("模板名称不能为空")]
+ Code10020,
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
index b3055f3..bb82c63 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/Services/WarehouseTemplateService.cs
@@ -1,4 +1,5 @@
using BPA.KitChen.GroupMeal.SqlSugar;
+using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate.Dtos;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Core.Base;
@@ -80,8 +81,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
try
{
SqlSugarDb.Db.Ado.BeginTran();
+ if(string.IsNullOrWhiteSpace(inputDto.DeviceId)) throw Oops.Oh(ErrorCodeEnum.Code10019);
+ if (string.IsNullOrWhiteSpace(inputDto.TemplateName)) throw Oops.Oh(ErrorCodeEnum.Code10020);
var check = SqlSugarDb.Db.Queryable().Where(x => x.TemplateName == inputDto.TemplateName).Any();
- if (check) throw Oops.Oh("模板名称不能重复");
+ if (check) throw Oops.Oh(ErrorCodeEnum.Code10018);
+ var dev = SqlSugarDb.Db.Queryable().Where(x => x.Id == inputDto.DeviceId).Any();
+ if (!dev) throw Oops.Oh(ErrorCodeEnum.Code10012);
var res = await SqlSugarDb.Db.Insertable(new BPA_WarehouseTemplate
{
DeviceId = inputDto.DeviceId,
@@ -120,8 +125,9 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
try
{
SqlSugarDb.Db.Ado.BeginTran();
+ var check = SqlSugarDb.Db.Queryable().Where(x => x.TemplateName == inputDto.TemplateName && x.Id!= inputDto.Id).Any();
+ if (check) throw Oops.Oh(ErrorCodeEnum.Code10018);
var model = SqlSugarDb.Db.Queryable().Where(x => x.Id == inputDto.Id).First();
- model.DeviceId = inputDto.DeviceId;
model.TemplateName = inputDto.TemplateName;
var res = await SqlSugarDb.Db.Updateable(model).ExecuteCommandAsync();
var warehousePostion = SqlSugarDb.Db.Queryable().Where(x => x.TemplateId == inputDto.Id).ToList();
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs
index 214bda1..392cf37 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/WarehouseTemplate/WarehouseTemplateServices.cs
@@ -4,7 +4,7 @@ using BPA.SAAS.Manage.Core.Base;
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplate
{
- [ApiDescriptionSettings("开放平台", Tag = "设备仓位模板")]
+ [ApiDescriptionSettings("开放平台", Tag = "设备仓位模板"), AllowAnonymous]
public class WarehouseTemplateServices : IDynamicApiController, ITransient
{
IWarehouseTemplateService _warehouseTemplateService;
@@ -17,7 +17,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
///
///
///
- [HttpPost("/api/WareHouseTemplate/GetWarehouseTemplatePage")]
+ [HttpPost("/api/ExternalPlatform/WareHouseTemplate/GetWarehouseTemplatePage")]
public async Task GetWarehouseTemplatePage(WarehouseTemplateQueryDto inputDto)
{
return await _warehouseTemplateService.GetWarehouseTemplatePage(inputDto);
@@ -27,7 +27,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
///
///
///
- [HttpPost("/api/WareHouseTemplate/GetWarehouseTemplateList")]
+ [HttpPost("/api/ExternalPlatform/WareHouseTemplate/GetWarehouseTemplateList")]
public async Task> GetWarehouseTemplateList(WarehouseDevideId dto)
{
return await _warehouseTemplateService.GetWarehouseTemplateList(dto);
@@ -37,7 +37,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
///
///
///
- [HttpPost("/api/WareHouseTemplate/AddWarehouseTemplate")]
+ [HttpPost("/api/ExternalPlatform/WareHouseTemplate/AddWarehouseTemplate")]
public async Task AddWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
return await _warehouseTemplateService.AddWarehouseTemplate(inputDto);
@@ -47,7 +47,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.WarehouseTemplat
///
///
///
- [HttpPost("/api/WareHouseTemplate/UpdateWarehouseTemplate")]
+ [HttpPost("/api/ExternalPlatform/WareHouseTemplate/UpdateWarehouseTemplate")]
public async Task UpdateWarehouseTemplate(WarehouseTemplatInsertDto inputDto)
{
return await _warehouseTemplateService.UpdateWarehouseTemplate(inputDto);