基础服务api
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.
 
 

554 lines
24 KiB

  1. From 395b6f040824087ef4616402b301ef7ae19f825e Mon Sep 17 00:00:00 2001
  2. From: gwbvipvip <gwbvipvip@163.com>
  3. Date: Mon, 8 Jul 2024 17:27:56 +0800
  4. Subject: 重写商品导入,商品及分类验重
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs
  9. index 99d9933..d896ecd 100644
  10. --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs
  11. +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs
  12. @@ -1,4 +1,5 @@
  13. using BPA.SAAS.Manage.Comm.Enum;
  14. +using Npoi.Mapper.Attributes;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. @@ -24,4 +25,22 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
  19. public string GoodsTypeId { get; set; }
  20. public string Status { get; set; }
  21. }
  22. +
  23. + public class GoodsImportDto
  24. + {
  25. + [Column("商品名称")]
  26. + public string Name { get;set; }
  27. + [Column("商品分类")]
  28. + public string Type { get; set; }
  29. + [Column("商品单位")]
  30. + public string Uint { get; set; }
  31. + [Column("商品价格")]
  32. + public decimal Price { get; set; }
  33. + [Column("是否称重")]
  34. + public string IsWeigh { get; set; }
  35. + [Column("备注")]
  36. + public string Descritption { get; set; }
  37. + [Column("图片")]
  38. + public object ImgUrl { get; set; }
  39. + }
  40. }
  41. diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs
  42. index b9fec40..08978b6 100644
  43. --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs
  44. +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs
  45. @@ -11,7 +11,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
  46. /// <summary>
  47. /// 文件
  48. /// </summary>
  49. - public IFormFile file { get; set; }
  50. + public IFormFile File { get; set; }
  51. }
  52. public class GoodsTechnologyExportDto
  53. @@ -29,4 +29,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
  54. /// </summary>
  55. public string FileName { get; set; }
  56. }
  57. +
  58. + public class GoodsInfoImportDto
  59. + {
  60. + /// <summary>
  61. + /// 文件
  62. + /// </summary>
  63. + public IFormFile File { get; set; }
  64. + }
  65. }
  66. diff --git a/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs b/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
  67. index c88368f..ce5fc0c 100644
  68. --- a/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
  69. +++ b/BPA.SAAS.Manage.Application/DataBase/GoodsServices.cs
  70. @@ -205,13 +205,36 @@ namespace BPA.SAAS.Manage.Application.DataBase
  71. }
  72. /// <summary>
  73. - /// 商品工艺导出
  74. + /// 商品工艺模版导出
  75. /// </summary>
  76. + /// <param name="exportDto"></param>
  77. /// <returns></returns>
  78. [HttpPost("/api/goods/goodsTechnologyExport"), NonUnify]
  79. public async Task<string> GoodsTechnologyExport(GoodsTechnologyExportDto exportDto)
  80. {
  81. return await _goodsService.GoodsTechnologyExport(exportDto);
  82. }
  83. +
  84. + /// <summary>
  85. + /// 商品导入
  86. + /// </summary>
  87. + /// <param name="importDto"></param>
  88. + /// <returns></returns>
  89. + [HttpPost("/api/goods/goodsImport"), NonUnify]
  90. + public async Task<bool> GoodsImport([FromForm] GoodsInfoImportDto importDto)
  91. + {
  92. + return await _goodsService.GoodsImport(importDto);
  93. + }
  94. +
  95. + /// <summary>
  96. + /// 商品工艺导出
  97. + /// </summary>
  98. + /// <param name="goodName"></param>
  99. + /// <returns></returns>
  100. + [HttpPost("/api/goods/goodsSimpleExport"), NonUnify]
  101. + public async Task<string> GoodsSimpleExport(string goodName)
  102. + {
  103. + return await _goodsService.GoodsSimpleExport(goodName);
  104. + }
  105. }
  106. }
  107. diff --git a/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs
  108. index 29f725a..c628ddb 100644
  109. --- a/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs
  110. +++ b/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsService.cs
  111. @@ -111,9 +111,23 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface
  112. Task<bool> GoodsTechnologyImport([FromForm] GoodsTechnologyImportDto importDto);
  113. /// <summary>
  114. - /// 商品工艺导出
  115. + /// 商品工艺模版导出
  116. /// </summary>
  117. /// <returns></returns>
  118. Task<string> GoodsTechnologyExport(GoodsTechnologyExportDto exportDto);
  119. +
  120. + /// <summary>
  121. + /// 商品导入
  122. + /// </summary>
  123. + /// <param name="importDto"></param>
  124. + /// <returns></returns>
  125. + Task<bool> GoodsImport([FromForm] GoodsInfoImportDto importDto);
  126. +
  127. + /// <summary>
  128. + /// 商品工艺导出
  129. + /// </summary>
  130. + /// <param name="goodName"></param>
  131. + /// <returns></returns>
  132. + Task<string> GoodsSimpleExport(string goodName);
  133. }
  134. }
  135. diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  136. index 63f13a1..08f787d 100644
  137. --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  138. +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  139. @@ -1,5 +1,4 @@
  140. -using BPA.Franchisee.Application.FranchiseeCenter.GoodsServices;
  141. -using BPA.SAAS.Manage.Application.DataBase.Dtos;
  142. +using BPA.SAAS.Manage.Application.DataBase.Dtos;
  143. using BPA.SAAS.Manage.Application.DataBase.Dtos.Batching;
  144. using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom;
  145. using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods;
  146. @@ -34,7 +33,6 @@ using System.Linq;
  147. using System.Reflection;
  148. using System.Text;
  149. using System.Text.RegularExpressions;
  150. -using System.Threading.Tasks;
  151. namespace BPA.SAAS.Manage.Application.DataBase.Services
  152. {
  153. @@ -44,14 +42,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  154. IGoodsAttributeService _goodsAttributeService;
  155. ISystemConfigService _SystemConfigService;
  156. IAliyunOssService _aliyunOssService;
  157. - IWebHostEnvironment _hostingEnvironment;
  158. public GoodsService(ISqlSugarClient db, IGoodsAttributeService goodsAttributeService, ISystemConfigService SystemConfigService, IAliyunOssService aliyunOssService, IWebHostEnvironment webHostEnvironment)
  159. {
  160. _db=db;
  161. _goodsAttributeService=goodsAttributeService;
  162. _SystemConfigService = SystemConfigService;
  163. _aliyunOssService = aliyunOssService;
  164. - _hostingEnvironment = webHostEnvironment;
  165. }
  166. /// <summary>
  167. /// 分页查询
  168. @@ -383,7 +379,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  169. var productCode = _db.Queryable<BPA_GoodsUint>().Where(x =>x.Name == dto.Name).ToList();
  170. if (productCode.Count() > 0)
  171. {
  172. - throw Oops.Oh("商品单位已存在");
  173. + throw Oops.Oh($"{dto.Name}已存在,添加失败!");
  174. }
  175. try
  176. {
  177. @@ -392,9 +388,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  178. var res = await _db.Insertable(bPA_Product).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
  179. return res > 0;
  180. }
  181. - catch (Exception ex)
  182. + catch (Exception e)
  183. {
  184. - throw Oops.Oh("添加失败");
  185. + throw Oops.Oh(e.Message);
  186. }
  187. }
  188. /// <summary>
  189. @@ -1257,15 +1253,170 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  190. return true;
  191. }
  192. + /// <summary>
  193. + /// 商品导入
  194. + /// </summary>
  195. + /// <param name="importDto"></param>
  196. + /// <returns></returns>
  197. + public async Task<bool> GoodsImport(GoodsInfoImportDto importDto)
  198. + {
  199. + var file = importDto.File;
  200. + var aliyunHost = "https://bpa.oss-cn-chengdu.aliyuncs.com/";
  201. + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
  202. + if (string.IsNullOrEmpty(userId))
  203. + {
  204. + userId = "";
  205. + }
  206. + var goodsInfo = await _db.Queryable<BPA_GoodsInfo>().ToListAsync();
  207. + var goodsType = await _db.Queryable<BPA_GoodsType>().ToListAsync();
  208. + var goodsUint = await _db.Queryable<BPA_GoodsUint>().ToListAsync();
  209. + try
  210. + {
  211. + _db.Ado.BeginTran();
  212. + var source = file.OpenReadStream();
  213. + var mapper = new Mapper(source);
  214. + var excelDto = new ReadExcel<GoodsImportDto>();
  215. + var dataList = excelDto.ExcelToList(source, mapper);
  216. + dataList.RemoveAll(t => t.Name == null);
  217. + UpdateGoodsImportDto(dataList);
  218. + var imageList = await GetImagesWithExcel(file.OpenReadStream(), Path.GetExtension(file.FileName));
  219. + var newUnitList = new List<BPA_GoodsUint>();
  220. + var i = 0;
  221. + foreach (var data in dataList)
  222. + {
  223. + if (data.Type == null)
  224. + throw Oops.Oh($"商品分类不能为空!");
  225. + if (data.Name == null)
  226. + throw Oops.Oh($"商品名称不能为空!");
  227. + if (data.Uint == null)
  228. + throw Oops.Oh($"商品单位不能为空!");
  229. + var type = goodsType.FirstOrDefault(t => t.Name == data.Type);
  230. + if (type == null)
  231. + throw Oops.Oh($"{data.Name} 不存在分类:{data.Type}!");
  232. + var old = goodsInfo.FirstOrDefault(t => t.Name == data.Name && t.GoodsTypeId == type.Id);
  233. + if (old != null)
  234. + throw Oops.Oh($"{data.Name} 已存在该商品!");
  235. + var uintId = "";
  236. + var uintData = goodsUint.FirstOrDefault(t => t.Name == data.Uint);
  237. + var newUnitData = newUnitList.FirstOrDefault(t => t.Name == data.Uint);
  238. + if (uintData != null || newUnitData != null)
  239. + uintId = uintData != null ? uintData.Id : newUnitData.Id;
  240. + else
  241. + {
  242. + uintId = Guid.NewGuid().ToString();
  243. + var newUint = new BPA_GoodsUint
  244. + {
  245. + Id = uintId,
  246. + Name = data.Uint,
  247. + CreateBy = userId
  248. + };
  249. + newUnitList.Add(newUint);
  250. + await _db.Insertable(newUint).ExecuteCommandAsync();
  251. + }
  252. + var imgUrl = data.ImgUrl != null ? data.ImgUrl.ToString() : "";
  253. + if (!imgUrl.Contains("=DISPIMG"))
  254. + imgUrl = null;
  255. + else
  256. + {
  257. + imgUrl = aliyunHost + imageList[i];
  258. + i++;
  259. + }
  260. + var newValue = new BPA_GoodsInfo
  261. + {
  262. + Id = Guid.NewGuid().ToString(),
  263. + Name = data.Name,
  264. + GoodsTypeId = type.Id,
  265. + Descritption = data.Descritption,
  266. + ImgUrl = imgUrl,
  267. + Code = GetNumber2(8),
  268. + Price = data.Price,
  269. + CreateBy = userId,
  270. + GoodsUintId = uintId,
  271. + IsWeigh = data.IsWeigh == "是",
  272. + IsAttrubute = true
  273. + };
  274. + await _db.Insertable(newValue).ExecuteCommandAsync();
  275. + }
  276. + _db.Ado.CommitTran();
  277. + }
  278. + catch (Exception e)
  279. + {
  280. + _db.Ado.RollbackTran();
  281. + throw Oops.Oh($"Excel导入错误," + e.Message);
  282. + }
  283. + return true;
  284. + }
  285. +
  286. + public List<GoodsImportDto> UpdateGoodsImportDto(List<GoodsImportDto> list)
  287. + {
  288. + foreach (var item in list)
  289. + {
  290. + item.Name = item.Name?.Trim();
  291. + item.Type = item.Type?.Trim();
  292. + item.Uint = item.Uint?.Trim();
  293. + item.IsWeigh = item.IsWeigh?.Trim();
  294. + item.Descritption = item.Descritption?.Trim();
  295. + }
  296. + return list;
  297. + }
  298. +
  299. + public async Task<List<string>> GetImagesWithExcel(Stream stream, string fileType)
  300. + {
  301. + try
  302. + {
  303. + var result = new List<string>();
  304. + IWorkbook workbook;
  305. + if (fileType == ".xlsx")
  306. + {
  307. + workbook = new XSSFWorkbook(stream);
  308. + var pictures = workbook.GetAllPictures();
  309. + foreach (XSSFPictureData pic in pictures)
  310. + {
  311. + using (var ms = new MemoryStream(pic.Data))
  312. + {
  313. + var suffix = pic.SuggestFileExtension();
  314. + var fileName = Guid.NewGuid().ToString();
  315. + IFormFile formFile = new FormFile(ms, 0, ms.Length, "name", $"{fileName}.{suffix}");
  316. + result.Add(await _aliyunOssService.UpFileAsync(formFile));
  317. + }
  318. + }
  319. + }
  320. + else if (fileType == ".xls")
  321. + {
  322. + workbook = new HSSFWorkbook(stream);
  323. + var pictures = workbook.GetAllPictures();
  324. + foreach (HSSFPictureData pic in pictures)
  325. + {
  326. + using (var ms = new MemoryStream(pic.Data))
  327. + {
  328. + var suffix = pic.SuggestFileExtension();
  329. + var fileName = Guid.NewGuid().ToString();
  330. + IFormFile formFile = new FormFile(ms, 0, ms.Length, "name", $"{fileName}.{suffix}");
  331. + result.Add(await _aliyunOssService.UpFileAsync(formFile));
  332. + }
  333. + }
  334. + }
  335. + else
  336. + {
  337. + throw new Exception("传入的不是Excel文件!");
  338. + }
  339. + return result;
  340. + }
  341. + catch (Exception ex)
  342. + {
  343. + throw new Exception(ex.Message);
  344. + }
  345. + }
  346. +
  347. /// <summary>
  348. /// 商品工艺导入
  349. /// </summary>
  350. /// <param name="importDto"></param>
  351. /// <returns></returns>
  352. public async Task<bool> GoodsTechnologyImport(GoodsTechnologyImportDto importDto)
  353. - {
  354. + {
  355. string pattern = @"(?<part1>[^,(]+),(?<part2>\([^)]+\)),(?<part3>[^,]+)";
  356. - var file = importDto.file;
  357. + var file = importDto.File;
  358. var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
  359. if (string.IsNullOrEmpty(userId))
  360. {
  361. @@ -1480,7 +1631,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  362. }
  363. /// <summary>
  364. - /// 商品工艺导出
  365. + /// 商品工艺模版导出
  366. /// </summary>
  367. /// <param name="exportDto"></param>
  368. /// <returns></returns>
  369. @@ -1576,7 +1727,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  370. sheet.AddMergedRegion(new CellRangeAddress(1, 2, 4, 4));
  371. #endregion
  372. }
  373. - var tempFolder = Path.Combine(_hostingEnvironment.ContentRootPath, "TechnologyTemplate");
  374. + var tempFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TechnologyTemplate");
  375. if (!Directory.Exists(tempFolder))
  376. Directory.CreateDirectory(tempFolder);
  377. var time = DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒");
  378. @@ -1589,6 +1740,70 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  379. return fileBase64;
  380. }
  381. + /// <summary>
  382. + /// 商品工艺导出
  383. + /// </summary>
  384. + /// <param name="goodName"></param>
  385. + /// <returns></returns>
  386. + public async Task<string> GoodsSimpleExport(string goodName)
  387. + {
  388. + var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().ToListAsync();
  389. + var goodsAttributeValueList = await _db.Queryable<BPA_GoodsAttributeValue>().Where(t => goodsAttributeList.Select(a => a.Id).Contains(t.GoodsAttributeId)).OrderBy(a => a.Sort).ToListAsync();
  390. + var goodsType = await _db.Queryable<BPA_GoodsType>().ToListAsync();
  391. + var goodsInfo = await _db.Queryable<BPA_GoodsInfo>().FirstAsync(t => t.Name == goodName);
  392. + if (goodsInfo == null)
  393. + throw Oops.Oh("商品不存在!");
  394. + var actionList = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => t.GoodsId == goodsInfo.Id).OrderBy(a => a.GoodsAttributeId).OrderBy(a => a.Order).ToListAsync();
  395. + IWorkbook workbook = new XSSFWorkbook();
  396. + string[] charsToReplace = new string[] { "\\", "/", "?", "*", "[", "]" };
  397. + foreach (string c in charsToReplace)
  398. + {
  399. + goodName = goodName.Replace(c, " ");
  400. + }
  401. + ISheet sheet = workbook.CreateSheet(goodName);
  402. + IRow headerRow = sheet.CreateRow(0);
  403. + headerRow.CreateCell(0).SetCellValue("商品名称");
  404. + headerRow.CreateCell(1).SetCellValue("属性组合");
  405. + headerRow.CreateCell(2).SetCellValue("工序");
  406. + headerRow.CreateCell(3).SetCellValue("工序参数");
  407. + headerRow.CreateCell(4).SetCellValue("参数值");
  408. + var k = 1;
  409. + for (int i = 0; i < actionList.Count; i++)
  410. + {
  411. + var stepName = actionList[i].StepName;
  412. + var attributeNames = "";
  413. + var attributeNameList = new List<string>();
  414. + var goodsAttributeIdList = actionList[i].GoodsAttributeId.Split(',');
  415. + foreach (var goodsAttributeId in goodsAttributeIdList)
  416. + {
  417. + attributeNameList.Add(goodsAttributeValueList.FirstOrDefault(t => t.Id == goodsAttributeId)?.AttributeValue);
  418. + }
  419. + attributeNames = string.Join("-", attributeNameList);
  420. + var actionJsonList = JsonConvert.DeserializeObject<List<ActionJsonModel>>(actionList[i].ActionJson);
  421. + for (int j = 0; j < actionJsonList.Count; j++)
  422. + {
  423. + IRow dataRow = sheet.CreateRow(k);
  424. + dataRow.CreateCell(0).SetCellValue(goodName);
  425. + dataRow.CreateCell(1).SetCellValue(attributeNames);
  426. + dataRow.CreateCell(2).SetCellValue(stepName);
  427. + dataRow.CreateCell(3).SetCellValue(actionJsonList[j].actionName);
  428. + dataRow.CreateCell(4).SetCellValue(actionJsonList[j].actionValue);
  429. + k++;
  430. + }
  431. + }
  432. + var tempFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GoodsTechnologyData");
  433. + if (!Directory.Exists(tempFolder))
  434. + Directory.CreateDirectory(tempFolder);
  435. + var time = DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒");
  436. + var filePath = Path.Combine(tempFolder, $"{goodName}导出-{time}.xlsx");
  437. + using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
  438. + {
  439. + workbook.Write(stream);
  440. + }
  441. + var fileBase64 = Convert.ToBase64String(File.ReadAllBytes(filePath));
  442. + return fileBase64;
  443. + }
  444. +
  445. public static List<string> GenerateCombinations(Dictionary<string, List<string>> values, bool isId, BPA_GoodsInfo goodInfo, BPA_DeviceInfo deviceInfo)
  446. {
  447. var attributes = values.Keys.ToList();
  448. @@ -1858,5 +2073,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  449. var str = string.Format("{0}", ram.ToString().Substring(0, Length));
  450. return str;
  451. }
  452. +
  453. }
  454. }
  455. diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTypeService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTypeService.cs
  456. index 44e08c6..42500c8 100644
  457. --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTypeService.cs
  458. +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTypeService.cs
  459. @@ -93,6 +93,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  460. {
  461. try
  462. {
  463. + var old = await _db.Queryable<BPA_GoodsType>().FirstAsync(t => t.Name == dto.Name);
  464. + if (old != null)
  465. + throw Oops.Oh($"已存在{dto.Name},添加失败!");
  466. var res = 0;
  467. if (string.IsNullOrWhiteSpace(dto.Id))
  468. {
  469. @@ -132,10 +135,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
  470. return res > 0;
  471. }
  472. }
  473. - catch (Exception)
  474. + catch (Exception e)
  475. {
  476. _db.Ado.RollbackTran();
  477. - throw Oops.Oh("添加失败!");
  478. + throw Oops.Oh(e.Message);
  479. }
  480. }
  481. public async Task<int> HandleGoodsAttribute(BPA_GoodsType typeEntity, List<AttributeDto> AttributeList)
  482. diff --git a/BPA.SAAS.Manage.Application/System/AliyunOssServices.cs b/BPA.SAAS.Manage.Application/System/AliyunOssServices.cs
  483. index 5cb3938..613d2dc 100644
  484. --- a/BPA.SAAS.Manage.Application/System/AliyunOssServices.cs
  485. +++ b/BPA.SAAS.Manage.Application/System/AliyunOssServices.cs
  486. @@ -23,5 +23,11 @@ namespace BPA.SAAS.Manage.Application.System
  487. {
  488. return await _aliyunOssService.GeneratePostPolicyAsync(request);
  489. }
  490. +
  491. + [HttpPost("/api/systemconfig/UpFileAsync"), ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify]
  492. + public async Task<string> UpFileAsync(IFormFile formFile)
  493. + {
  494. + return await _aliyunOssService.UpFileAsync(formFile);
  495. + }
  496. }
  497. }
  498. diff --git a/BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs b/BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs
  499. index e619ed5..3730776 100644
  500. --- a/BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs
  501. +++ b/BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs
  502. @@ -11,5 +11,6 @@ namespace BPA.SAAS.Manage.Application.System.Interface
  503. public interface IAliyunOssService
  504. {
  505. Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request);
  506. + Task<string> UpFileAsync(IFormFile formFile);
  507. }
  508. }
  509. diff --git a/BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs b/BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs
  510. index 69afe6f..fa3c4c9 100644
  511. --- a/BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs
  512. +++ b/BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs
  513. @@ -1,4 +1,5 @@
  514. -using BPA.Aliyun.OSS;
  515. +using Aliyun.OSS.Util;
  516. +using BPA.Aliyun.OSS;
  517. using BPA.Aliyun.OSS.Options;
  518. using BPA.SAAS.Manage.Application.System.Dtos;
  519. using BPA.SAAS.Manage.Application.System.Interface;
  520. @@ -27,5 +28,11 @@ namespace BPA.SAAS.Manage.Application.System.Services
  521. var data = await _aliyunOssClient.GeneratePostPolicyAsync(dir);
  522. return data;
  523. }
  524. +
  525. + public async Task<string> UpFileAsync(IFormFile formFile)
  526. + {
  527. + var data = await _aliyunOssClient.UpFileAsync(formFile);
  528. + return data;
  529. + }
  530. }
  531. }
  532. diff --git a/BPA.SAAS.Manage.Web.Entry/appsettings.json b/BPA.SAAS.Manage.Web.Entry/appsettings.json
  533. index fd1d125..6488e7d 100644
  534. --- a/BPA.SAAS.Manage.Web.Entry/appsettings.json
  535. +++ b/BPA.SAAS.Manage.Web.Entry/appsettings.json
  536. @@ -41,7 +41,7 @@
  537. "PresignedUriExpirationMinutes": 1440,
  538. "PolicyExpirationMinutes": 1440,
  539. "ProjectName": "hkerp",
  540. - "ServiceName": "test"
  541. + "ServiceName": "test/goods"
  542. }
  543. }
  544. },