平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

229 lines
7.9 KiB

  1. using MoYu.FriendlyException;
  2. using MoYu.RemoteRequest;
  3. using MoYu.RemoteRequest.Extensions;
  4. using Newtonsoft.Json.Linq;
  5. using SafeCampus.Application.Manager.DeepelephManager;
  6. using SafeCampus.Web.Core.Controllers.Application.Business.Dto;
  7. namespace SafeCampus.Web.Core.Controllers.Application.Business;
  8. /// <summary>
  9. /// 服装底库管理接口
  10. /// </summary>
  11. [Route("/business/[controller]")]
  12. [ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Order = 97,Tag = "服装底库管理")]
  13. public class ClothApi
  14. {
  15. private readonly IDeepelephManager _deepelephManager;
  16. public ClothApi(IDeepelephManager deepelephManager)
  17. {
  18. _deepelephManager = deepelephManager;
  19. }
  20. /// <summary>
  21. /// 新增服装底库
  22. /// </summary>
  23. /// <param name="input">人员信息</param>
  24. /// <returns></returns>
  25. public async Task<dynamic> AddClothDataBaseA(ClothDataNameInfo input)
  26. {
  27. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  28. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/create"
  29. .SetBody(new
  30. {
  31. token = _deepelephManager.GetToken(),
  32. tenantCode = appSettings.TenantCode,
  33. poiId = appSettings.PoiId,
  34. clothSetId = Guid.NewGuid().ToString("N"),
  35. clothSetName = input.ClothSetName,
  36. })
  37. .SetContentType("application/json")
  38. .PostAsAsync<string>();
  39. var model = JsonConvert.DeserializeObject<JObject>(str);
  40. if ((bool)model["success"])
  41. {
  42. return model["data"];
  43. }
  44. throw Oops.Oh(model["message"].ToString());
  45. }
  46. /// <summary>
  47. /// 删除服装底库
  48. /// </summary>
  49. /// <param name="clothSetId"></param>
  50. /// <returns></returns>
  51. public async Task<dynamic> DeleteClothDataBaseD(string clothSetId)
  52. {
  53. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  54. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/delete"
  55. .SetBody(new
  56. {
  57. token = _deepelephManager.GetToken(),
  58. tenantCode = appSettings.TenantCode,
  59. poiId = appSettings.PoiId,
  60. clothSetId= clothSetId,
  61. })
  62. .SetContentType("application/json")
  63. .PostAsAsync<string>();
  64. var model = JsonConvert.DeserializeObject<JObject>(str);
  65. if ((bool)model["success"])
  66. {
  67. return model["data"];
  68. }
  69. throw Oops.Oh(model["message"].ToString());
  70. }
  71. /// <summary>
  72. /// 更新服装底库
  73. /// </summary>
  74. /// <returns></returns>
  75. public async Task<dynamic> UpdateClothU(ClothDataBaseInfo info)
  76. {
  77. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  78. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/update"
  79. .SetBody(new
  80. {
  81. token = _deepelephManager.GetToken(),
  82. tenantCode = appSettings.TenantCode,
  83. poiId = appSettings.PoiId,
  84. clothSetId = info.ClothSetId,
  85. clothSetName = info.ClothSetName,
  86. })
  87. .SetContentType("application/json")
  88. .PostAsAsync<string>();
  89. var model = JsonConvert.DeserializeObject<JObject>(str);
  90. if ((bool)model["success"])
  91. {
  92. return model["data"];
  93. }
  94. throw Oops.Oh(model["message"].ToString());
  95. }
  96. /// <summary>
  97. /// 查询服装底库列表
  98. /// </summary>
  99. /// <returns></returns>
  100. public async Task<dynamic> GetList()
  101. {
  102. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  103. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/query-list"
  104. .SetBody(new
  105. {
  106. token = _deepelephManager.GetToken(),
  107. tenantCode = appSettings.TenantCode,
  108. poiId = appSettings.PoiId,
  109. })
  110. .SetContentType("application/json")
  111. .PostAsAsync<string>();
  112. var model = JsonConvert.DeserializeObject<JObject>(str);
  113. if ((bool)model["success"])
  114. {
  115. return model["data"];
  116. }
  117. throw Oops.Oh(model["message"].ToString());
  118. }
  119. /// <summary>
  120. /// 查询服装底库详情
  121. /// </summary>
  122. /// <param name="clothSetId">服装库Id</param>
  123. /// <returns></returns>
  124. public async Task<dynamic> GetInfo(string clothSetId)
  125. {
  126. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  127. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/set/query-detail"
  128. .SetBody(new
  129. {
  130. token = _deepelephManager.GetToken(),
  131. tenantCode = appSettings.TenantCode,
  132. poiId = appSettings.PoiId,
  133. clothSetId= clothSetId
  134. })
  135. .SetContentType("application/json")
  136. .PostAsAsync<string>();
  137. var model = JsonConvert.DeserializeObject<JObject>(str);
  138. if ((bool)model["success"])
  139. {
  140. return model["data"];
  141. }
  142. throw Oops.Oh(model["message"].ToString());
  143. }
  144. /// <summary>
  145. /// 服装图片上传
  146. /// </summary>
  147. /// <param name="input"></param>
  148. /// <returns></returns>
  149. public async Task<dynamic> UploadFile([FromForm] BaseFileInput input)
  150. {
  151. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  152. var jsonparam = JsonConvert.SerializeObject(new
  153. {
  154. token = _deepelephManager.GetToken(),
  155. tenantCode = appSettings.TenantCode,
  156. poiId = appSettings.PoiId,
  157. usageScenario = "staff"
  158. });
  159. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/common/upload-file"
  160. .SetFiles(HttpFile.Create("file", input.File.OpenReadStream(), input.File.FileName))
  161. .SetBody(new
  162. {
  163. param = jsonparam
  164. })
  165. .SetContentType("multipart/form-data")
  166. .PostAsAsync<string>();
  167. var model = JsonConvert.DeserializeObject<JObject>(str);
  168. if ((bool)model["success"])
  169. {
  170. return model["data"]["httpUrl"].ToString();
  171. }
  172. throw Oops.Oh(model["message"].ToString());
  173. }
  174. /// <summary>
  175. /// 新增服装
  176. /// </summary>
  177. /// <param name="info"></param>
  178. /// <returns></returns>
  179. public async Task<dynamic> AddClothA(ClothInfos info)
  180. {
  181. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  182. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/add"
  183. .SetBody(new
  184. {
  185. token = _deepelephManager.GetToken(),
  186. tenantCode = appSettings.TenantCode,
  187. poiId = appSettings.PoiId,
  188. info.clothSetId,
  189. info.clothUrl
  190. })
  191. .SetContentType("application/json")
  192. .PostAsAsync<string>();
  193. var model = JsonConvert.DeserializeObject<JObject>(str);
  194. if ((bool)model["success"])
  195. {
  196. return model["data"];
  197. }
  198. throw Oops.Oh(model["message"].ToString());
  199. }
  200. /// <summary>
  201. /// 删除服装
  202. /// </summary>
  203. /// <returns></returns>
  204. [HttpPost]
  205. public async Task<dynamic> DeleteClothD(ClothInfos info)
  206. {
  207. var appSettings = App.GetOptionsMonitor<AppInfoOptions>();
  208. var str = await $"{appSettings.SXAPIURL}/dfield-api/ecology/cloth/delete"
  209. .SetBody(new
  210. {
  211. token = _deepelephManager.GetToken(),
  212. tenantCode = appSettings.TenantCode,
  213. poiId = appSettings.PoiId,
  214. info.clothSetId,
  215. info.clothId
  216. })
  217. .SetContentType("application/json")
  218. .PostAsAsync<string>();
  219. var model = JsonConvert.DeserializeObject<JObject>(str);
  220. if ((bool)model["success"])
  221. {
  222. return model["data"];
  223. }
  224. throw Oops.Oh(model["message"].ToString());
  225. }
  226. }