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

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

jiangjc пре 2 година
родитељ
комит
9dc1e473f6

+ 2 - 2
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -493,7 +493,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> OperationHotelData(OperationHotelData dto)
+        public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
         {
             try
             {
@@ -538,7 +538,7 @@ namespace OASystem.API.Controllers
         {
             try
             {
-                var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
+                var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
                 if (!res)
                 {
                     return Ok(JsonView(false, "删除失败"));

+ 149 - 3
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1,8 +1,12 @@
 
+using AutoMapper.Execution;
+using Google.Protobuf.WellKnownTypes;
 using Microsoft.AspNetCore.Mvc.Formatters;
+using Newtonsoft.Json.Linq;
 using OASystem.Domain.Dtos.System;
 using Org.BouncyCastle.Asn1.Cms;
 using System.Collections;
+using System.Xml.Linq;
 using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 namespace OASystem.API.Controllers
@@ -1212,6 +1216,8 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> EditPageInfo(SetDataAndPageInfoView dto)
         {
             JsonView view = null;
+            _SystemMenuPermissionRepository.BeginTran();
+
             var istrue = await _SystemMenuPermissionRepository.UpdateAsync(x=>x.Id == dto.Pageid ,x=> new Sys_SystemMenuPermission
             {
                 AndroidUrl = dto.AndroidUrl,
@@ -1231,10 +1237,31 @@ namespace OASystem.API.Controllers
 
             if (istrue)
             {
+
+                //删除页面绑定的操作后重新绑定
+                istrue = await _SystemMenuAndFunctionRepository.DeleteAsync(x => x.SmId == dto.Pageid);
+
+                List<Sys_SystemMenuAndFunction> binFun = new List<Sys_SystemMenuAndFunction>();
+
+                foreach (var item in dto.FunArr)
+                {
+                    binFun.Add(new Sys_SystemMenuAndFunction
+                    {
+                        CreateTime = DateTime.Now,
+                        CreateUserId = 235,
+                        FId = item,
+                        SmId = dto.Pageid,
+                        IsDel = 0,
+                    });
+                }
+               int number = _SystemMenuAndFunctionRepository.Adds<Sys_SystemMenuAndFunction>(binFun);
+
                 view = JsonView(istrue);
+                _SystemMenuPermissionRepository.CommitTran();
             }
             else
             {
+                _SystemMenuPermissionRepository.RollbackTran();
                 view = JsonView("添加失败");
             }
             return Ok(view);
@@ -1251,7 +1278,10 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> AddPageInfo(SetDataAndPageInfoView dto)
         {
             JsonView view = null;
-            int number = await _SystemMenuPermissionRepository.AddAsync(new Sys_SystemMenuPermission
+
+            _SystemMenuPermissionRepository.BeginTran();
+
+            int number = await _SystemMenuPermissionRepository.AddAsyncReturnId(new Sys_SystemMenuPermission
             {
                 AndroidUrl = dto.AndroidUrl,
                 CreateTime = DateTime.Now,
@@ -1268,14 +1298,33 @@ namespace OASystem.API.Controllers
                 WebUrl = dto.WebUrl,
             });
 
+            List<Sys_SystemMenuAndFunction> binFun = new List<Sys_SystemMenuAndFunction>();
+
+            foreach (var item in dto.FunArr)
+            {
+                binFun.Add(new Sys_SystemMenuAndFunction
+                {
+                    CreateTime = DateTime.Now,
+                    CreateUserId = 235,
+                    FId = item,
+                    SmId = number,
+                    IsDel = 0,
+                });
+            }
+
+            number =  _SystemMenuAndFunctionRepository.Adds<Sys_SystemMenuAndFunction>(binFun);
+
             if (number > 0)
             {
                 view = JsonView(number);
+                _SystemMenuPermissionRepository.CommitTran();
             }
             else
             {
+                _SystemMenuPermissionRepository.RollbackTran();
                 view = JsonView("添加失败");
             }
+
             return Ok(view);
         }
 
@@ -1317,18 +1366,115 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(view));
         }
 
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryPageFunById(PageFunDto Dto)
+        {
+            //页面与操作关联表
+            var pageAndFunList =  _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
+            //页面功能表
+            var pageFunList = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>().ToList();
+
+            ArrayList arr = new ArrayList();  
+            foreach (var item in pageFunList)
+            {
+                var FindVal = pageAndFunList.Find(x => x.SmId == Dto.Pageid && x.FId == item.Id);
+                if (FindVal == null)
+                {
+                    arr.Add(new
+                    {
+                        id = item.Id,
+                        name = item.FunctionName,
+                        value =false
+                    });
+                }
+                else
+                {
+                    arr.Add( new {
+                        id = item.Id,
+                        name = item.FunctionName,
+                        value = true
+                    });
+                }
+            }
+            return Ok(JsonView(arr));
+        }
+
         #endregion
 
         #region 页面操作
+        /// <summary>
+        /// 操作权限功能表
+        /// </summary>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PageFunInit()
         {
-            return Ok("");
+            try
+            {
+                var PageFunInit = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, PageFunctionPermissionView>().ToList();
+                if (PageFunInit == null)
+                {
+                    return Ok(JsonView(false, "暂无数据!"));
+                }
+                return Ok(JsonView(true, "查询成功!", PageFunInit));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
         }
 
+        /// <summary>
+        /// 操作权限功能表操作(Status 1:添加,2:编辑)
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OperationFunInit(OperationFunInitDta dto)
+        {
+            try
+            {
+                Result result = await _PageFunctionPermissionRepository.OperationFunInit(dto);
+                if (result.Code != 0)
+                {
+                    return Ok(JsonView(false, result.Msg));
+                }
+                return Ok(JsonView(true, result.Msg));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
 
-
+        /// <summary>
+        /// 删除功能
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelFunInit(DelFunInitDta dto)
+        {
+            try
+            {
+                var res = await _PageFunctionPermissionRepository.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
         #endregion
     }
 }

+ 5 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -53,6 +53,10 @@ namespace OASystem.Domain.AutoMappers
 
             #endregion
 
+            #region 功能权限板块
+            CreateMap<OperationFunInitDta, Sys_PageFunctionPermission>();
+            #endregion
+
             #endregion
 
             #region Group
@@ -78,6 +82,7 @@ namespace OASystem.Domain.AutoMappers
             #endregion
             #region 酒店资料数据
             CreateMap<Res_HotelData, HotelDataView>();
+            CreateMap<OperationHotelDto, Res_HotelData>();
             #endregion
             #region 物料供应商
             CreateMap<Edit_ResItemVendorDto, Res_ItemVendor>()

+ 1 - 1
OASystem/OASystem.Domain/Dtos/Resource/HotelDataDto.cs

@@ -9,7 +9,7 @@ namespace OASystem.Domain.Dtos.Resource
     /// <summary>
     /// 酒店资料操作(增删)
     /// </summary>
-    public class OperationHotelData
+    public class OperationHotelDto
     {
         /// <summary>
         /// 操作状态

+ 68 - 0
OASystem/OASystem.Domain/Dtos/System/PageFunDto.cs

@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.System
+{
+    public class PageFunDto
+    {
+        private int pageid;
+
+        private List<int> bindFunArr;
+
+        private int uid;
+        
+        public int Pageid { get => pageid; set => pageid = value; }
+        public List<int> BindFunArr { get => bindFunArr; set => bindFunArr = value; }
+        public int Uid { get => uid; set => uid = value; }
+    }
+    /// <summary>
+    /// 功能权限表操作
+    /// </summary>
+     public class OperationFunInitDta
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 功能名称
+        /// </summary>
+        public string FunctionName { get; set; }
+        /// <summary>
+        /// 功能权限Code
+        /// </summary>
+        public string FunctionCode { get; set; }
+        /// <summary>
+        /// 是否启用0否1是
+        /// </summary>
+        public int IsEnable { get; set; }
+       
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+       
+    }
+
+    public class DelFunInitDta
+    {
+        /// <summary>
+        /// 主键Id
+        /// </summary>
+        public int Id { get; set; }
+        public int DeleteUserId { get; set; }
+    }
+}

+ 4 - 0
OASystem/OASystem.Domain/ViewModels/System/PageFunctionPermissionView.cs

@@ -8,6 +8,10 @@ namespace OASystem.Domain.ViewModels.System
 {
     public class PageFunctionPermissionView
     {
+        /// <summary>
+        /// 主键id
+        /// </summary>
+        public int Id { get; set; }
         /// <summary>
         /// 功能名称
         /// </summary>

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/System/SetDataView.cs

@@ -90,5 +90,10 @@ namespace OASystem.Domain.ViewModels.System
         /// 页面备注
         /// </summary>
         public string PageRemark { get; set; }
+
+        /// <summary>
+        /// 页面添加的操作
+        /// </summary>
+        public List<int> FunArr { get; set; }
     }
 }

+ 3 - 3
OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs

@@ -19,15 +19,15 @@ namespace OASystem.Infrastructure.Repositories.Resource
             _mapper= mapper;
         }
 
-        public async Task<Result> OperationHotelData(OperationHotelData dto)
+        public async Task<Result> OperationHotelData(OperationHotelDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             try
             {
                 if (dto.Status == 1)//添加
                 {
-                    string selectSql = string.Format(@"select * from Res_HotelData where Name='{0}'"
-                                                       , dto.Name);
+                    string selectSql = string.Format(@"select * from Res_HotelData where Name='{0}' and IsDel='{1}'"
+                                                       , dto.Name,0);
                     var HotelData = await _sqlSugar.SqlQueryable<Res_HotelData>(selectSql).FirstAsync();//查询是否存在
                     if (HotelData != null)
                     {

+ 62 - 2
OASystem/OASystem.Infrastructure/Repositories/System/PageFunctionPermissionRepository.cs

@@ -1,10 +1,70 @@
-namespace OASystem.Infrastructure.Repositories.System
+using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.System;
+using OASystem.Domain.Entities.Resource;
+
+namespace OASystem.Infrastructure.Repositories.System
 {
     public class PageFunctionPermissionRepository : BaseRepository<Sys_PageFunctionPermission, PageFunctionPermissionView>
     {
-        public PageFunctionPermissionRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        private readonly IMapper _mapper;
+        public PageFunctionPermissionRepository(SqlSugarClient sqlSugar,IMapper mapper) : base(sqlSugar)
         {
+            _mapper=mapper;
         }
 
+        public async Task<Result> OperationFunInit(OperationFunInitDta dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                if (dto.Status == 1)//添加
+                {
+                    string selectSql = string.Format(@"select * from Sys_PageFunctionPermission where FunctionName='{0}' and IsDel='{1}'"
+                                                       , dto.FunctionName, 0);
+                    var FunInit = await _sqlSugar.SqlQueryable<Sys_PageFunctionPermission>(selectSql).FirstAsync();//查询是否存在
+                    if (FunInit != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+
+                    }
+                    else//不存在,可添加
+                    {
+                        Sys_PageFunctionPermission Function = _mapper.Map<Sys_PageFunctionPermission>(dto);
+                        int id = await AddAsyncReturnId(Function);
+                        if (id == 0)
+                        {
+                            return result = new Result() { Code = -1, Msg = "添加失败!" };
+
+                        }
+                        result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
+                    }
+                }
+                else if (dto.Status == 2)//修改
+                {
+                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Sys_PageFunctionPermission
+                    {
+                        FunctionName=dto.FunctionName,
+                        FunctionCode=dto.FunctionCode,
+                        IsEnable=dto.IsEnable,
+                        Remark = dto.Remark,
+                    });
+                    if (!res)
+                    {
+                        return result = new Result() { Code = -1, Msg = "修改失败!" };
+                    }
+                    result = new Result() { Code = 0, Msg = "修改成功!" };
+                }
+                else
+                {
+                    return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                }
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "程序错误!" };
+            }
+            return result;
+        }
     }
 }