Browse Source

酒店信息 修改更改

LEIYI 3 months ago
parent
commit
b06958188a

+ 26 - 4
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -11,6 +11,7 @@ using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
 using Org.BouncyCastle.Utilities.Encoders;
@@ -750,6 +751,31 @@ namespace OASystem.API.Controllers
         #endregion
 
         #region 酒店资料数据
+
+
+        /// <summary>
+        /// 酒店信息查询 批量加密
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryHotelDataBatchEncryption(QueryHotelDataDto dto)
+        {
+            var hotelData = await _sqlSugar.Queryable<Res_HotelData>().ToListAsync();
+            foreach (var item in hotelData)
+            {
+                EncryptionProcessor.EncryptProperties(item);
+            }
+
+            var total = await _sqlSugar.Updateable(hotelData).ExecuteCommandAsync();
+
+            return Ok(JsonView(true, "操作成功", new { }, total));
+
+
+        }
+
+
         /// <summary>
         /// 酒店信息查询 Page
         /// </summary>
@@ -828,10 +854,6 @@ namespace OASystem.API.Controllers
                     //})
                     .ToListAsync();
 
-
-
-
-
                 if (HotelDataData.Count == 0)
                 {
                     return Ok(JsonView(false, "暂无数据"));

+ 10 - 20
OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs

@@ -1,5 +1,7 @@
 using AutoMapper;
+using MathNet.Numerics.Statistics.Mcmc;
 using MySqlX.XDevAPI.Common;
+using NPOI.SS.Formula.Functions;
 using OASystem.Domain;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Groups;
@@ -62,6 +64,9 @@ WHERE
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
+            var hotelDataDto = _mapper.Map<Res_HotelData>(dto);
+
+            EncryptionProcessor.EncryptProperties(hotelDataDto);// 加密属性
             if (dto.Status == 1)//添加
             {
                 string selectSql = string.Format(@"select * from Res_HotelData where Name='{0}' and IsDel='{1}'"
@@ -74,10 +79,7 @@ WHERE
                 }
                 else//不存在,可添加
                 {
-                    var _HotelDataDto = _mapper.Map<Res_HotelData>(dto);
-                    
-                    EncryptionProcessor.EncryptProperties(_HotelDataDto);// 加密属性
-                    int id = await AddAsyncReturnId(_HotelDataDto);
+                    int id = await AddAsyncReturnId(hotelDataDto);
                     if (id == 0)
                     {
                         return result = new Result() { Code = -1, Msg = "添加失败!" };
@@ -88,22 +90,10 @@ WHERE
             }
             else if (dto.Status == 2)//修改
             {
-                var updateInfo = new Res_HotelData
-                {
-                    City = dto.City,
-                    Name = dto.Name,
-                    Level = dto.Level,
-                    Address = dto.Address,
-                    Tel = dto.Tel,
-                    Fax = dto.Fax,
-                    Contact = dto.Contact,
-                    ContactPhone = dto.ContactPhone,
-                    OtherInformation = dto.OtherInformation,
-                    Remark = dto.Remark,
-                };
-                EncryptionProcessor.EncryptProperties(updateInfo);// 加密属性
-                bool res = await UpdateAsync(a => a.Id == dto.Id, a => updateInfo);
-                if (!res)
+                var res = await _sqlSugar.Updateable(hotelDataDto)
+                    .IgnoreColumns(x => new { x.CreateTime, x.CreateUserId, x.DeleteTime, x.DeleteUserId, x.IsDel })
+                    .ExecuteCommandAsync();
+                if (res < 1)
                 {
                     return result = new Result() { Code = -1, Msg = "修改失败!" };
                 }