|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using MoYu.FriendlyException;
- using MoYu.RemoteRequest;
- using MoYu.RemoteRequest.Extensions;
- using Newtonsoft.Json.Linq;
- using SafeCampus.Application.Manager.DeepelephManager;
- using SafeCampus.Web.Core.Controllers.Application.Business.Dto;
-
- namespace SafeCampus.Web.Core.Controllers.Application.Business;
- /// <summary>
- /// 服装底库管理接口
- /// </summary>
- [Route("/business/[controller]")]
- [ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Order = 97,Tag = "服装底库管理")]
- public class ClothApi
- {
- private readonly IDeepelephManager _deepelephManager;
-
- public ClothApi(IDeepelephManager deepelephManager)
- {
- _deepelephManager = deepelephManager;
- }
-
- /// <summary>
- /// 新增服装底库
- /// </summary>
- /// <param name="input">人员信息</param>
- /// <returns></returns>
- public async Task<dynamic> AddClothDataBaseA(ClothDataNameInfo input)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/create"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- clothSetId = Guid.NewGuid().ToString("N"),
- clothSetName = input.ClothSetName,
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 删除服装底库
- /// </summary>
- /// <param name="clothSetId"></param>
- /// <returns></returns>
- public async Task<dynamic> DeleteClothDataBaseD(string clothSetId)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/delete"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- clothSetId= clothSetId,
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 更新服装底库
- /// </summary>
- /// <returns></returns>
- public async Task<dynamic> UpdateClothU(ClothDataBaseInfo info)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/update"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- clothSetId = info.ClothSetId,
- clothSetName = info.ClothSetName,
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 查询服装底库列表
- /// </summary>
- /// <returns></returns>
- public async Task<dynamic> GetList()
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/query-list"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 查询服装底库详情
- /// </summary>
- /// <param name="clothSetId">服装库Id</param>
- /// <returns></returns>
- public async Task<dynamic> GetInfo(string clothSetId)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/query-detail"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- clothSetId= clothSetId
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 服装图片上传
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<dynamic> UploadFile([FromForm] BaseFileInput input)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var jsonparam = JsonConvert.SerializeObject(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- usageScenario = "staff"
- });
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/common/upload-file"
- .SetFiles(HttpFile.Create("file", input.File.OpenReadStream(), input.File.FileName))
- .SetBody(new
- {
- param = jsonparam
- })
- .SetContentType("multipart/form-data")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"]["httpUrl"].ToString();
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 新增服装
- /// </summary>
- /// <param name="info"></param>
- /// <returns></returns>
- public async Task<dynamic> AddClothA(ClothInfos info)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/add"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- info.clothSetId,
- info.clothUrl
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- /// <summary>
- /// 删除服装
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<dynamic> DeleteClothD(ClothInfos info)
- {
- var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
- var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/delete"
- .SetBody(new
- {
- token = _deepelephManager.GetToken(),
- tenantCode = appSettings.TenantCode,
- poiId = appSettings.PoiId,
- info.clothSetId,
- info.clothId
- })
- .SetContentType("application/json")
- .PostAsAsync<string>();
- var model = JsonConvert.DeserializeObject<JObject>(str);
- if ((bool)model["success"])
- {
- return model["data"];
- }
- throw Oops.Oh(model["message"].ToString());
- }
- }
|