李昊 4 jaren geleden
bovenliggende
commit
b3b7d789e1

+ 14 - 1
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminSystemLabelController.cs

@@ -19,11 +19,14 @@ namespace GxPress.Api.AdminControllers
     public class AdminSystemLabelController : ControllerBase
     {
         private readonly ISystemLabelRepository _repository;
+        private readonly ISystemLableMediaRepository systemLableMediaRepository;
+
         private readonly ISystemLabelService systemLabelService;
-        public AdminSystemLabelController(ISystemLabelRepository repository, ISystemLabelService systemLabelService)
+        public AdminSystemLabelController(ISystemLabelRepository repository, ISystemLabelService systemLabelService, ISystemLableMediaRepository systemLableMediaRepository)
         {
             _repository = repository;
             this.systemLabelService = systemLabelService;
+            this.systemLableMediaRepository = systemLableMediaRepository;
         }
         /// <summary>
         /// 添加
@@ -64,5 +67,15 @@ namespace GxPress.Api.AdminControllers
         {
             return await _repository.DeleteAsync(id);
         }
+        /// <summary>
+        /// 添加标签媒体
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("add")]
+        public async Task<bool> InsertAsync(SystemLableMediaRequest request)
+        {
+            return await systemLableMediaRepository.InsertAsync(request);
+        }
     }
 }

+ 1 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/SystemLabel/SystemLableMediaRepository.cs

@@ -62,6 +62,7 @@ namespace GxPress.Repository.Implement.SystemLabel
             {
                 using (var transactions = new TransactionScope())
                 {
+                    await _repository.DeleteAsync(Q.Where(nameof(Entity.SystemLabel.SystemLableMedia.LableId), request.LableId));
                     var sql = $@"INSERT INTO `tede_system_lable_media`(`Guid`,`CreatedDate`,`LastModifiedDate`,`LableId`,`MediaId`) VALUES";
                     var createdDate = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                     foreach (var item in request.MediaIds)