Преглед изворни кода

供应商资料(加密解密--> CRUD、其他相关接口代码更改、测试(本地、生产环境))

LEIYI пре 3 месеци
родитељ
комит
ed3b8e174d

+ 24 - 12
OASystem/OASystem.Domain/Entities/Resource/Res_MediaSuppliers.cs

@@ -1,4 +1,5 @@
-using System;
+using OASystem.Domain.Attributes;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -21,37 +22,43 @@ namespace OASystem.Domain.Entities.Resource
         /// <summary>
         /// 省份
         /// </summary>
-        [SugarColumn(ColumnDescription = "省份", ColumnName = "Privince", IsNullable = true, ColumnDataType = "varchar(120)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "省份", ColumnName = "Privince", IsNullable = true, ColumnDataType = "nvarchar(240)")]
         public string Privince { get; set; }
 
         /// <summary>
         /// 城市
         /// </summary>
-        [SugarColumn(ColumnDescription = "城市", ColumnName = "City", IsNullable = true, ColumnDataType = "varchar(120)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "城市", ColumnName = "City", IsNullable = true, ColumnDataType = "nvarchar(240)")]
         public string City { get; set; }
 
         /// <summary>
         /// 单位名称
         /// </summary>
-        [SugarColumn(ColumnDescription = "单位名称", ColumnName = "UnitName", IsNullable = true, ColumnDataType = "varchar(200)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "单位名称", ColumnName = "UnitName", IsNullable = true, ColumnDataType = "nvarchar(400)")]
         public string UnitName { get; set; }
 
         /// <summary>
         /// 单位缩写
         /// </summary>
-        [SugarColumn(ColumnDescription = "单位缩写", ColumnName = "UnitAbbreviation", IsNullable = true, ColumnDataType = "varchar(200)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "单位缩写", ColumnName = "UnitAbbreviation", IsNullable = true, ColumnDataType = "nvarchar(400)")]
         public string UnitAbbreviation { get; set; }
 
         /// <summary>
         /// 单位地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "单位地址", ColumnName = "UnitAddress", IsNullable = true, ColumnDataType = "varchar(120)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "单位地址", ColumnName = "UnitAddress", IsNullable = true, ColumnDataType = "nvarchar(240)")]
         public string UnitAddress { get; set; }
 
         /// <summary>
         /// 单位联系人
         /// </summary>
-        [SugarColumn(ColumnDescription = "单位联系人", ColumnName = "Contact", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "单位联系人", ColumnName = "Contact", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Contact { get; set; }
 
         /// <summary>
@@ -63,30 +70,35 @@ namespace OASystem.Domain.Entities.Resource
         /// <summary>
         /// 联系人职位
         /// </summary>
-        [SugarColumn(ColumnDescription = "联系人职位", ColumnName = "Post", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "联系人职位", ColumnName = "Post", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Post { get; set; }
 
         /// <summary>
         /// 联系人电话
         /// </summary>
-        [SugarColumn(ColumnDescription = "联系人电话", ColumnName = "Tel", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "联系人电话", ColumnName = "Tel", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Tel { get; set; }
 
         /// <summary>
         /// 联系人邮箱
         /// </summary>
-        [SugarColumn(ColumnDescription = "联系人邮箱", ColumnName = "Email", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "联系人邮箱", ColumnName = "Email", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Email { get; set; }
 
         /// <summary>
         /// 联系人微信
         /// </summary>
-        [SugarColumn(ColumnDescription = "联系人微信", ColumnName = "WeChat", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "联系人微信", ColumnName = "WeChat", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string WeChat { get; set; }
         /// <summary>
         /// 传真
         /// </summary>
-        [SugarColumn(ColumnDescription = "传真", ColumnName = "Fax", IsNullable = true, ColumnDataType = "varchar(100)")]
+        [Encrypted]
+        [SugarColumn(ColumnDescription = "传真", ColumnName = "Fax", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Fax { get; set; }
 
     }

+ 65 - 0
OASystem/OASystem.Domain/ViewModels/Resource/MediaSupplierView.cs

@@ -0,0 +1,65 @@
+using OASystem.Domain.Attributes;
+using OASystem.Domain.Entities.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Resource
+{
+    public class MediaSupplierView : Res_MediaSuppliers
+    {
+    }
+
+    public class MediaSupplierInfoView
+    {
+        public int Id { get; set; }
+        public int TypeId { get; set; }
+        [Encrypted]
+        public string Privince { get; set; }
+        [Encrypted]
+        public string City { get; set; }
+        [Encrypted]
+        public string UnitName { get; set; }
+        [Encrypted]
+        public string UnitAbbreviation { get; set; }
+        [Encrypted]
+        public string UnitAddress { get; set; }
+        [Encrypted]
+        public string Contact { get; set; }
+        public int Sex { get; set; }
+        [Encrypted]
+        public string Post { get; set; }
+        [Encrypted]
+        public string Fax { get; set; }
+        [Encrypted]
+        public string Tel { get; set; }
+        [Encrypted]
+        public string Email { get; set; }
+        [Encrypted]
+        public string WeChat { get; set; }
+        [Encrypted]
+        public string Remark { get; set; }
+    }
+
+    public class PageItemView
+    {
+        public int Id { get; set; }
+        [Encrypted]
+        public string Privince { get; set; }
+        [Encrypted]
+        public string City { get; set; }
+        [Encrypted]
+        public string UnitName { get; set; }
+        [Encrypted]
+        public string Contact { get; set; }
+        public int Sex { get; set; }
+        [Encrypted]
+        public string Post { get; set; }
+        [Encrypted]
+        public string Tel { get; set; }
+        public string CreateUserName { get; set; }
+        public DateTime CreateTime { get; set; }
+    }
+}

+ 39 - 28
OASystem/OASystem.Infrastructure/Repositories/Resource/MediaSuppliersRepository.cs

@@ -8,6 +8,8 @@ using AutoMapper;
 using OASystem.Domain.Dtos.Resource;
 using EyeSoft.Extensions;
 using OASystem.Domain;
+using OASystem.Domain.ViewModels.Resource;
+using OASystem.Domain.AesEncryption;
 
 namespace OASystem.Infrastructure.Repositories.Resource
 {
@@ -33,7 +35,10 @@ namespace OASystem.Infrastructure.Repositories.Resource
         {
             var result = new JsonView() { Code = 400, Msg = "操作失败" };
 
-            var typeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 21).Select(x => new { x.Id, Text = x.Name }).ToListAsync();
+            var typeData = await _sqlSugar.Queryable<Sys_SetData>()
+                .Where(x => x.IsDel == 0 && x.STid == 21)
+                .Select(x => new { x.Id, Text = x.Name })
+                .ToListAsync();
             result.Code = 200;
             result.Data = typeData;
             return result;
@@ -54,26 +59,28 @@ namespace OASystem.Infrastructure.Repositories.Resource
 
             var info = await _sqlSugar.Queryable<Res_MediaSuppliers>()
                 .Where(x => x.IsDel == 0 && x.Id == dto.Id)
-                .Select(x => new
+                .Select(x => new MediaSupplierInfoView()
                 {
-                    x.Id,
-                    x.TypeId,
-                    x.Privince,
-                    x.City,
-                    x.UnitName,
-                    x.UnitAbbreviation,
-                    x.UnitAddress,
-                    x.Contact,
-                    x.Sex,
-                    x.Post,
-                    x.Fax,
-                    x.Tel,
-                    x.Email,
-                    x.WeChat,
-                    x.Remark
+                    Id = x.Id,
+                    TypeId = x.TypeId,
+                    Privince = x.Privince,
+                    City = x.City,
+                    UnitName = x.UnitName,
+                    UnitAbbreviation = x.UnitAbbreviation,
+                    UnitAddress = x.UnitAddress,
+                    Contact = x.Contact,
+                    Sex = x.Sex,
+                    Post = x.Post,
+                    Fax = x.Fax,
+                    Tel = x.Tel,
+                    Email = x.Email,
+                    WeChat = x.WeChat,
+                    Remark = x.Remark
                 })
                 .FirstAsync();
 
+            EncryptionProcessor.DecryptProperties(info);
+
             result.Code = 200;
             result.Data = info;
             result.Msg = MsgTips.Succeed;
@@ -91,7 +98,6 @@ namespace OASystem.Infrastructure.Repositories.Resource
 
             if (!_portIds.Contains(dto.PortType)) { result.Msg = MsgTips.Port; return result; }
 
-
             var typeLabel = new List<int>();
             if (!string.IsNullOrEmpty(dto.TypeLabel))
             {
@@ -114,21 +120,23 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 .WhereIF(typeLabel.Count > 0 , (ms, u) => typeLabel.Contains(ms.TypeId))
                 .WhereIF(!string.IsNullOrEmpty(search), (ms, u) => ms.UnitName.Contains(search) || ms.Contact.Contains(search) || ms.Tel.Contains(search))
                 .OrderByDescending((ms, u) => ms.CreateTime)
-                .Select((ms, u) => new
+                .Select((ms, u) => new PageItemView()
                 {
-                    ms.Id,
-                    ms.Privince,
-                    ms.City,
-                    ms.UnitName,
-                    ms.Contact,
-                    ms.Sex,
-                    ms.Post,
-                    ms.Tel,
+                    Id = ms.Id,
+                    Privince = ms.Privince,
+                    City = ms.City,
+                    UnitName = ms.UnitName,
+                    Contact = ms.Contact,
+                    Sex = ms.Sex,
+                    Post = ms.Post,
+                    Tel = ms.Tel,
                     CreateUserName = u.CnName,
-                    ms.CreateTime
+                    CreateTime = ms.CreateTime
                 })
                 .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
+            foreach (var info in infos) EncryptionProcessor.DecryptProperties(info);
+
             result.Msg = MsgTips.Succeed;
             result.Code = 200;
             result.Data = infos;
@@ -151,6 +159,9 @@ namespace OASystem.Infrastructure.Repositories.Resource
 
             var info = _mapper.Map<Res_MediaSuppliers>(dto);
             info.CreateUserId = userId;
+
+            EncryptionProcessor.DecryptProperties(info);
+
             if (info.Id < 1) //添加
             {
                 var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();