Browse Source

新增酒店增删改方法及对应的Dto、rep方法

wangh 1 year ago
parent
commit
bc00fac25f

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

@@ -489,7 +489,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
             {
@@ -534,7 +534,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, "删除失败"));

+ 65 - 2
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1403,15 +1403,78 @@ namespace OASystem.API.Controllers
         #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>
+        /// 操作权限功能表
+        /// </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
@@ -80,6 +84,7 @@ namespace OASystem.Domain.AutoMappers
             #endregion
             #region 酒店资料数据
             CreateMap<Res_HotelData, HotelDataView>();
+            CreateMap<OperationHotelDto, Res_HotelData>();
             #endregion
             #endregion
         }

+ 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>
         /// 操作状态

+ 48 - 1
OASystem/OASystem.Domain/Dtos/System/PageFunDto.cs

@@ -13,9 +13,56 @@ namespace OASystem.Domain.Dtos.System
         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; }
+    }
 }

+ 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;
+        }
     }
 }