🤣去除SAP创建、修改客户档案接口操作类型,逻辑改为存在客户记录为修改不存在为添加

This commit is contained in:
bairubing 2024-10-16 13:49:11 +08:00
parent 4747009617
commit ce21fa4543
2 changed files with 10 additions and 7 deletions

View File

@ -13,10 +13,11 @@ using System.Threading.Tasks;
namespace Vistar.Application.Service.SapOpenInterface.Dto; namespace Vistar.Application.Service.SapOpenInterface.Dto;
public class CreateClientRecordInput public class CreateClientRecordInput
{ {
/// <summary> ///// <summary>
/// 标识 新增或修改 ///// 标识 新增或修改
/// </summary> ///// </summary>
public string actionType { get; set; } //public string actionType { get; set; }
/// <summary> /// <summary>
/// 客户编码 /// 客户编码

View File

@ -47,14 +47,16 @@ public class SapOpenInterfaceService : IDynamicApiController, ITransient
{ {
var response = new ManageResponse(); var response = new ManageResponse();
if (string.IsNullOrWhiteSpace(input._System_objNBS) || string.IsNullOrWhiteSpace(input._System_objDescription) || string.IsNullOrWhiteSpace(input.actionType)) if (string.IsNullOrWhiteSpace(input._System_objNBS) || string.IsNullOrWhiteSpace(input._System_objDescription))
{ {
response.Success = true; response.Success = true;
response.Message = "请输入必填字段"; response.Message = "请输入必填字段";
return response; return response;
} }
//判断是否存在客户记录
var clientExists = await _obj132Rep.AsQueryable().AnyAsync(x => x._System_objNBS == input._System_objNBS);
if (input.actionType == "新增") if (clientExists == false)
{ {
var fieldList = new List<Field>(); var fieldList = new List<Field>();
@ -80,7 +82,7 @@ public class SapOpenInterfaceService : IDynamicApiController, ITransient
response= await _solidWorksManageService.CreateRecord(data); response= await _solidWorksManageService.CreateRecord(data);
return response; return response;
} }
else if (input.actionType == "修改") else if (clientExists == true)
{ {
var updateable = await _obj132Rep.AsUpdateable() var updateable = await _obj132Rep.AsUpdateable()
.SetColumns(it => new Obj132 .SetColumns(it => new Obj132