Quellcode durchsuchen

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

yuanrf vor 2 Jahren
Ursprung
Commit
05d3534625

+ 12 - 0
OASystem/OASystem.Api/Controllers/BaseController.cs

@@ -60,6 +60,18 @@ public class ControllerBase : Microsoft.AspNetCore.Mvc.ControllerBase
             return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = msg };
         }
     }
+
+    protected virtual JsonView JsonView(bool s, string msg, object obj,int count)
+    {
+        if (s)
+        {
+            return new JsonView { Code = StatusCodes.Status200OK, Msg = msg, Data = obj, Count=count };
+        }
+        else
+        {
+            return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = msg };
+        }
+    }
     protected virtual JsonView JsonView(int code, string msg, object obj)
     {
         return new JsonView { Code = code, Msg = msg, Data = obj };

+ 201 - 12
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1,5 +1,8 @@
 
 
+using NetTaste;
+using System.Drawing.Printing;
+
 namespace OASystem.API.Controllers
 {
     /// <summary>
@@ -14,14 +17,16 @@ namespace OASystem.API.Controllers
         private readonly CarDataRepository _carDataRep;
         private readonly LocalGuideDataRepository _localGuideDataRep;
         private readonly ThreeCodeRepository _ThreeCodeRep;
+        private readonly HotelDataRepository _hotelDataRep;
 
-        public ResourceController(IMapper mapper, IConfiguration config, CarDataRepository carDataRep, LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep)
+        public ResourceController(IMapper mapper, IConfiguration config, CarDataRepository carDataRep, LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep, HotelDataRepository hotelDataRep)
         {
             _mapper = mapper;
             _config = config;
             _carDataRep = carDataRep;
             _localGuideDataRep = localGuideDataRep;
             _ThreeCodeRep = threeCodeRep;
+            _hotelDataRep = hotelDataRep;
         }
         #region 车公司资料板块
 
@@ -31,7 +36,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QuerCarData(DtoBase dto)
+        public async Task<IActionResult> QuertCarData(DtoBase dto)
         {
             try
             {
@@ -206,7 +211,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QuerLocalGuide(DtoBase dto)
+        public async Task<IActionResult> QueryLocalGuide(DtoBase dto)
         {
             try
             {
@@ -246,12 +251,12 @@ namespace OASystem.API.Controllers
         }
 
         /// <summary>
-        /// 导游地接信息操作(增改)
+        /// 导游地接信息操作(Status:1.新,2.修改)
         /// </summary>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> LocalGuideOperation(LocalGuideOperationDto dto)
+        public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
         {
             try
             {
@@ -277,7 +282,7 @@ namespace OASystem.API.Controllers
                 {
                     return Ok(JsonView(false, result.Msg));
                 }
-                return Ok(JsonView(true, result.Msg, new { Id = result.Data }));
+                return Ok(JsonView(true, result.Msg));
             }
             catch (Exception ex)
             {
@@ -292,7 +297,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> LocalGuideDel(LocalGuideDelDto dto)
+        public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
         {
             try
             {
@@ -319,7 +324,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QuerThreeCode(DtoBase dto)
+        public async Task<IActionResult> QueryThreeCode(DtoBase dto)
         {
             try
             {
@@ -335,13 +340,132 @@ namespace OASystem.API.Controllers
                 }
                 else if (dto.PortType == 2)
                 {
-                    var ThreeCode = _localGuideDataRep.QueryDto<Res_ThreeCode, ThreeCodeView>().ToList();
-                    if (ThreeCode.Count == 0)
+                    //分页写法
+                    if (dto.PageIndex==0 || dto.PageSize==0)
+                    {
+                        return Ok(JsonView(false, "请传入PageIndex和PageSize参数"));
+                    }
+                    JsonView _ThreeCode = await _ThreeCodeRep.QuerThreeCode(dto.PageIndex, dto.PageSize);
+                    if (_ThreeCode.Code != 0)
+                    {
+                        return Ok(JsonView(false, _ThreeCode.Msg));
+                    }
+
+                    return Ok(_ThreeCode);
+                }
+                else
+                {
+                    return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
+                }
+
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+
+
+        }
+
+        /// <summary>
+        /// 机场三字码资料操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
+        {
+            try
+            {
+                if (dto.Three == "")
+                {
+                    return Ok(JsonView(false, "请检查三字码是否填写!"));
+                }
+                if (dto.Country == "")
+                {
+                    return Ok(JsonView(false, "请检查国家是否填写!"));
+                }
+                if (dto.City == "")
+                {
+                    return Ok(JsonView(false, "请检查城市是否填写正确!"));
+                }
+                if (dto.AirPort == "")
+                {
+                    return Ok(JsonView(false, "请检查机场是否填写正确!"));
+                }
+
+                Result result = await _ThreeCodeRep.ThreeCodeOperation(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>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
+        {
+            try
+            {
+                var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        #endregion
+
+        #region 酒店资料数据
+        /// <summary>
+        /// 酒店信息查询
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryHotelData(DtoBase dto)
+        {
+            try
+            {
+                if (dto.PortType == 1)
+                {
+                    var HotelData = _localGuideDataRep.QueryDto<Res_HotelData, HotelDataView>().ToList();
+                    if (HotelData.Count == 0)
                     {
                         return Ok(JsonView(false, "暂无数据!"));
                     }
-                    ThreeCode = ThreeCode.OrderByDescending(s => s.CreateTime).ToList();
-                    return Ok(JsonView(true, "查询成功", ThreeCode));
+                    HotelData = HotelData.OrderByDescending(s => s.CreateTime).ToList();
+                    return Ok(JsonView(true, "查询成功", HotelData));
+                }
+                else if (dto.PortType == 2)
+                {
+                    var HotelData = _localGuideDataRep.QueryDto<Res_HotelData, HotelDataView>().ToList();
+                    if (HotelData.Count == 0)
+                    {
+                        return Ok(JsonView(false, "暂无数据!"));
+                    }
+                    HotelData = HotelData.OrderByDescending(s => s.CreateTime).ToList();
+                    return Ok(JsonView(true, "查询成功", HotelData));
                 }
                 else
                 {
@@ -358,6 +482,71 @@ namespace OASystem.API.Controllers
 
         }
 
+        /// <summary>
+        /// 酒店资料操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OperationHotelData(OperationHotelData dto)
+        {
+            try
+            {
+                if (dto.City == "")
+                {
+                    return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
+                }
+                if (dto.Name == "")
+                {
+                    return Ok(JsonView(false, "请检查酒店名称是否填写!"));
+                }
+                if (dto.Address == "")
+                {
+                    return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
+                }
+                if (dto.Tel == "")
+                {
+                    return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
+                }
+
+                Result result = await _hotelDataRep.OperationHotelData(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>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
+        {
+            try
+            {
+                var res = await _ThreeCodeRep.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
     }
 }

+ 1 - 1
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -141,7 +141,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QuerSetData(SetDataDto dto)
+        public async Task<IActionResult> QuerySetData(SetDataDto dto)
         {
             try
             {

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

@@ -76,6 +76,10 @@ namespace OASystem.Domain.AutoMappers
 
             #region 机场三字码资料
             CreateMap<Res_ThreeCode, ThreeCodeView>();
+            CreateMap<ThreeCodeOperationDto, Res_ThreeCode>();
+            #endregion
+            #region 酒店资料数据
+            CreateMap<Res_HotelData, HotelDataView>();
             #endregion
             #endregion
         }

+ 75 - 0
OASystem/OASystem.Domain/Dtos/Resource/HotelDataDto.cs

@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    /// <summary>
+    /// 酒店资料操作(增删)
+    /// </summary>
+    public class OperationHotelData
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 所在城市
+        /// </summary>
+        public string City { get; set; }
+        /// <summary>
+        /// 酒店名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 酒店星级
+        /// </summary>
+        public string Level { get; set; }
+        /// <summary>
+        /// 酒店地址
+        /// </summary>
+        public string Address { get; set; }
+        /// <summary>
+        /// 酒店电话
+        /// </summary>
+        public string Tel { get; set; }
+        /// <summary>
+        /// 酒店传真
+        /// </summary>
+        public string Fax { get; set; }
+        /// <summary>
+        /// 联系人
+        /// </summary>
+        public string Contact { get; set; }
+        /// <summary>
+        /// 联系方式
+        /// </summary>
+        public string ContactPhone { get; set; }
+        /// <summary>
+        /// 酒店其他信息
+        /// </summary>
+        public string OtherInformation { get; set; }
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+       
+    }
+    public class DelHotelDataDto
+    {
+        public int Id { get; set; }
+        public int DeleteUserId { get; set; }
+    }
+}

+ 62 - 0
OASystem/OASystem.Domain/Dtos/Resource/ThreeCodeDto.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    public class ThreeCodeOperationDto
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+        /// <summary>
+        /// 主键Id
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 三字码
+        /// </summary>
+        public string Three { get; set; }
+        /// <summary>
+        /// 四字码
+        /// </summary>
+        public string Four { get; set; }
+        /// <summary>
+        /// 国家
+        /// </summary>
+        public string Country { get; set; }
+        /// <summary>
+        /// 城市
+        /// </summary>
+        public string City { get; set; }
+        /// <summary>
+        /// 机场
+        /// </summary>
+        public string AirPort { get; set; }
+        /// <summary>
+        /// 机场英文名
+        /// </summary>
+        public string AirPort_En { get; set; }
+
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+       
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+       
+    }
+    public class ThreeCodeDelDto
+    {
+        public int Id { get; set; }
+        public int DeleteUserId { get; set; }
+    }
+}

+ 13 - 0
OASystem/OASystem.Domain/ViewModels/Resource/HotelDataView.cs

@@ -0,0 +1,13 @@
+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 HotelDataView:Res_HotelData
+    {
+    }
+}

+ 82 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs

@@ -0,0 +1,82 @@
+using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Resource;
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.Resource
+{
+    public class HotelDataRepository:BaseRepository<Res_HotelData,HotelDataView>
+    {
+        private readonly IMapper _mapper;
+        public HotelDataRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        {
+            _mapper= mapper;
+        }
+
+        public async Task<Result> OperationHotelData(OperationHotelData 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);
+                    var HotelData = await _sqlSugar.SqlQueryable<Res_HotelData>(selectSql).FirstAsync();//查询是否存在
+                    if (HotelData != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+
+                    }
+                    else//不存在,可添加
+                    {
+                        Res_HotelData _HotelDataDto = _mapper.Map<Res_HotelData>(dto);
+                        int id = await AddAsyncReturnId(_HotelDataDto);
+                        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 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,
+                    });
+                    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;
+        }
+    }
+}

+ 4 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/LocalGuideDataRepository.cs

@@ -74,6 +74,10 @@ namespace OASystem.Infrastructure.Repositories.Resource
                     }
                     result = new Result() { Code = 0, Msg = "修改成功!" };
                 }
+                else
+                {
+                    return  result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                }
             }
             catch (Exception ex)
             {

+ 98 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/ThreeCodeRepository.cs

@@ -1,6 +1,9 @@
 using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Resource;
+using SqlSugar;
 
 namespace OASystem.Infrastructure.Repositories.Resource
 {
@@ -11,5 +14,100 @@ namespace OASystem.Infrastructure.Repositories.Resource
         {
             _mapper = mapper;
         }
+        /// <summary>
+        /// sqlSugar分页查询
+        /// </summary>
+        /// <param name="PageIndex"></param>
+        /// <param name="PageSize"></param>
+        /// <returns></returns>
+
+        public async Task<JsonView> QuerThreeCode(int PageIndex, int PageSize)
+        {
+            JsonView result = new JsonView();
+            try
+            {
+               
+                int totalCount = 0;
+                List<Res_ThreeCode> page = _sqlSugar.Queryable<Res_ThreeCode>().ToPageList(PageIndex, PageSize, ref totalCount);
+                if (page.Count != 0)
+                {
+                    result=new JsonView(){Code=200,Msg = "查询成功!",Data = page,Count = totalCount };
+                }
+                else
+                {
+                    result = new JsonView(){ Code = 400, Msg = "查询失败!", Data = page, Count = totalCount };
+                }
+            }
+            catch (Exception)
+            {
+                result = new JsonView() { Code = 400, Msg = "程序错误!", Data = null, Count = 0 };
+                throw;
+            }
+            
+           
+            return result;
+        }
+
+        /// <summary>
+        /// 添加、编辑操作
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        public async Task<Result> ThreeCodeOperation(ThreeCodeOperationDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                if (dto.Status == 1)//添加
+                {
+                    string selectSql = string.Format(@"select * from Res_ThreeCode where Three='{0}' and Country='{1}' and City='{2}' and AirPort='{3}'"
+                                                       , dto.Three, dto.Country, dto.City, dto.AirPort);
+                    var ThreeCode = await _sqlSugar.SqlQueryable<Res_ThreeCode>(selectSql).FirstAsync();//查询是否存在
+                    if (ThreeCode != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+
+                    }
+                    else//不存在,可添加
+                    {
+                        Res_ThreeCode _ThreeCodeDto = _mapper.Map<Res_ThreeCode>(dto);
+                        int id = await AddAsyncReturnId(_ThreeCodeDto);
+                        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 Res_ThreeCode
+                    {
+                        Three=dto.Three,
+                        Four=dto.Four,
+                        Country=dto.Country,
+                        City = dto.City,
+                        AirPort = dto.AirPort,
+                        AirPort_En = dto.AirPort_En,
+                        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;
+        }
     }
 }