103 lines
4.2 KiB
C#
103 lines
4.2 KiB
C#
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
//
|
|
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
//
|
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
|
|
using Admin.NET.Core;
|
|
using Furion.DependencyInjection;
|
|
using Furion.DynamicApiController;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Vistar.Application.Const;
|
|
using Vistar.Application.Entity;
|
|
using Vistar.Application.Service.SapOpenInterface.Dto;
|
|
using Vistar.Application.SolidWorksManageService.Dto;
|
|
using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionResponse.Types;
|
|
|
|
namespace Vistar.Application.Service.SapOpenInterface;
|
|
/// <summary>
|
|
/// 开放接口给Sap
|
|
/// </summary>
|
|
[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "SapOpenInterface", Order = 100)]
|
|
public class SapOpenInterfaceService : IDynamicApiController, ITransient
|
|
{
|
|
public SqlSugarRepository<Obj132> _obj132Rep;
|
|
public SolidWorksManageService.SolidWorksManageService _solidWorksManageService;
|
|
public SapOpenInterfaceService(SqlSugarRepository<Obj132> obj132Rep, SolidWorksManageService.SolidWorksManageService solidWorksManageService)
|
|
{
|
|
_obj132Rep = obj132Rep;
|
|
_solidWorksManageService = solidWorksManageService;
|
|
}
|
|
/// <summary>
|
|
/// SAP创建、修改客户档案
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[Authorize(AuthenticationSchemes = SignatureAuthenticationDefaults.AuthenticationScheme)]
|
|
[ApiDescriptionSettings(Name = "CreateClientRecord"), HttpPost]
|
|
[DisplayName("SAP创建、修改客户档案")]
|
|
public async Task<ManageResponse> CreateClientRecord(CreateClientRecordInput input)
|
|
{
|
|
var response = new ManageResponse();
|
|
|
|
if (string.IsNullOrWhiteSpace(input._System_objNBS) || string.IsNullOrWhiteSpace(input._System_objDescription) || string.IsNullOrWhiteSpace(input.actionType))
|
|
{
|
|
response.Success = true;
|
|
response.Message = "请输入必填字段";
|
|
return response;
|
|
}
|
|
|
|
if (input.actionType == "新增")
|
|
{
|
|
var fieldList = new List<Field>();
|
|
|
|
fieldList.Add(new Field { key = "_System_objNBS", value = input._System_objNBS });
|
|
fieldList.Add(new Field { key = "_System_objDescription", value = input._System_objDescription });
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.fld004808))
|
|
{
|
|
fieldList.Add(new Field { key = "fld004808", value = input.fld004808 });
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.fld004950))
|
|
{
|
|
fieldList.Add(new Field { key = "fld004950", value = input.fld004950 });
|
|
}
|
|
|
|
var data = new CreateRecordInput
|
|
{
|
|
object_id = 132,
|
|
field_group_id = 422,
|
|
fields = fieldList
|
|
};
|
|
response= await _solidWorksManageService.CreateRecord(data);
|
|
return response;
|
|
}
|
|
else if (input.actionType == "修改")
|
|
{
|
|
var updateable = await _obj132Rep.AsUpdateable()
|
|
.SetColumns(it => new Obj132
|
|
{
|
|
_System_ObjDescription = input._System_objDescription,
|
|
fld004808 = input.fld004808,
|
|
fld004950 = input.fld004950
|
|
})
|
|
.Where(x => x._System_objNBS == input._System_objNBS)
|
|
.ExecuteCommandHasChangeAsync();
|
|
|
|
response.Success = true;
|
|
response.Message = updateable ? "修改成功" : "修改失败";
|
|
return response;
|
|
}
|
|
|
|
return response;
|
|
}
|
|
}
|