Browse Source

新增用车资料,增删改接口,新增相应的dto

wangh 1 year ago
parent
commit
b306991ec3

+ 192 - 0
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -0,0 +1,192 @@
+
+
+namespace OASystem.API.Controllers
+{
+    /// <summary>
+    /// 资料相关
+    /// </summary>
+    //[Authorize]
+    [Route("api/[controller]/[action]")]
+    public class ResourceController : ControllerBase
+    {
+        private readonly IMapper _mapper;
+        private readonly IConfiguration _config;
+        private readonly CarDataRepository _carDataRep;
+       
+        public ResourceController(IMapper mapper, IConfiguration config,CarDataRepository carDataRep)
+        {
+            _mapper = mapper;
+            _config = config;
+            _carDataRep = carDataRep;
+        }
+        #region 车公司资料板块
+
+        /// <summary>
+        /// 车公司信息查询
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QuerCarData(DtoBase dto)
+        {
+            try
+            {
+                if (dto.PortType==1)
+                {
+                    var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>().ToList();
+                    if (carDada.Count == 0)
+                    {
+                        return Ok(JsonView(false, "暂无数据!"));
+                    }
+                    carDada = carDada.OrderByDescending(s => s.CreateTime).ToList();
+                    return Ok(JsonView(true, "查询成功", carDada));
+                }
+                else if(dto.PortType==2)
+                {
+                    var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>().ToList();
+                    if (carDada.Count == 0)
+                    {
+                        return Ok(JsonView(false, "暂无数据!"));
+                    }
+                    carDada=carDada.OrderByDescending(s=>s.CreateTime).ToList();
+                    return Ok(JsonView(true, "查询成功", carDada));
+                }
+                else
+                {
+                    return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
+                }
+               
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+           
+            
+        }
+
+        /// <summary>
+        /// 车公司信息添加
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> AddCarData(AddCarDataDto dto)
+        {
+            try
+            {
+                if (dto.UnitArea == "")
+                {
+                    return Ok(JsonView(false, "请检查单位区域是否填写!"));
+                }
+                if (dto.UnitName == "")
+                {
+                    return Ok(JsonView(false, "请检查单位名称是否填写!"));
+                }
+                if (dto.Contact == "")
+                {
+                    return Ok(JsonView(false, "请检查单位联系人是否填写!"));
+                }
+                if (dto.ContactTel == "")
+                {
+                    return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
+                }
+                Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
+                int id = await _carDataRep.AddAsyncReturnId(_CarData);
+                if (id == 0) 
+                {
+                    return Ok(JsonView(false, "添加失败!"));
+                }
+                return Ok(JsonView(true, "添加成功", new { Id = id }));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 车公司信息修改
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> UpCarData(UpCarDataDto dto)
+        {
+            try
+            {
+                if (dto.UnitArea == "")
+                {
+                    return Ok(JsonView(false, "请检查单位区域是否填写!"));
+                }
+                if (dto.UnitName == "")
+                {
+                    return Ok(JsonView(false, "请检查单位名称是否填写!"));
+                }
+                if (dto.Contact == "")
+                {
+                    return Ok(JsonView(false, "请检查单位联系人是否填写!"));
+                }
+                if (dto.ContactTel == "")
+                {
+                    return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
+                }
+                bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
+                {
+                    UnitArea = dto.UnitArea,
+                    UnitName = dto.UnitName,
+                    Address = dto.Address,
+                    Contact = dto.Contact,
+                    ContactTel = dto.ContactTel,
+                    ContactEmail = dto.ContactEmail,
+                    ContactFax = dto.ContactFax,
+                    CarDes = dto.CarDes,
+                    CarPicPaths = dto.CarPicPaths,
+                    OtherInfo = dto.OtherInfo,
+                    Score = dto.Score,
+                    QualificationScore = dto.QualificationScore,
+                    CarAgeScore = dto.CarAgeScore,
+                    CleanImgScore = dto.CleanImgScore,
+                    SmellScore = dto.SmellScore,
+                    WaterPaperScore = dto.WaterPaperScore,
+                    HardwareScore = dto.HardwareScore,
+                    TimeScore = dto.TimeScore,
+                    SafetyScore = dto.SafetyScore,
+                    DrivingAgeScore = dto.DrivingAgeScore,
+                    Remark = dto.Remark,
+                });
+                if (!res) { return Ok(JsonView(false, "修改失败!")); }
+                return Ok(JsonView(true, "修改成功"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        /// <summary>
+        /// 车公司信息修改
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelCarData(DelCarDataDto dto)
+        {
+            try
+            {
+                bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res) { return Ok(JsonView(false, "删除失败!")); }
+                return Ok(JsonView(true, "删除成功"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        #endregion
+
+    }
+}

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

@@ -1,4 +1,5 @@
-using System.Collections;
+using Org.BouncyCastle.Asn1.Cms;
+using System.Collections;
 using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 namespace OASystem.API.Controllers
@@ -50,6 +51,37 @@ namespace OASystem.API.Controllers
 
 
 
+        #endregion
+
+        #region 类型表
+        /// <summary>
+        /// 查询类型数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QuerSetData(SetDataDto dto)
+        {
+            try
+            {
+                if (dto.DataType==0)
+                {
+                    return Ok(JsonView(false, "请传类型Id!"));
+                }
+                var setData = _setDataRepository.QueryDto<Sys_SetData, SetDataView>(s=>s.STid==dto.DataType).ToList();
+                if (setData.Count == 0)
+                {
+                    return Ok(JsonView(false, "暂无数据!"));
+                }
+                return Ok(JsonView(true, "查询成功!",setData));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
         #endregion
 
         #region 企业操作

+ 4 - 0
OASystem/OASystem.Api/GlobalUsings.cs

@@ -51,5 +51,9 @@ global using OASystem.Domain.Dtos.System;
 global using OASystem.Domain.Entities.System;
 global using OASystem.Domain.ViewModels.System;
 global using OASystem.Infrastructure.Repositories.System;
+global using OASystem.Domain.Dtos.Resource;
+global using OASystem.Domain.Entities.Resource;
+global using OASystem.Domain.ViewModels.Resource;
+global using OASystem.Infrastructure.Repositories.Resource;
 
 

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

@@ -1,10 +1,13 @@
 using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Dtos.System;
 using OASystem.Domain.Dtos.UserDto;
 using OASystem.Domain.Entities;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.Entities.System;
 using OASystem.Domain.ViewModels;
+using OASystem.Domain.ViewModels.Resource;
 using OASystem.Domain.ViewModels.System;
 
 namespace OASystem.Domain.AutoMappers
@@ -56,6 +59,13 @@ namespace OASystem.Domain.AutoMappers
 
             CreateMap<GroupListDto, Grp_DelegationInfo>();
             #endregion
+
+            #region Resource
+            #region 车公司资料
+            CreateMap<Res_CarData, CarDataView>();
+            CreateMap<AddCarDataDto, Res_CarData>();
+            #endregion
+            #endregion
         }
     }
 }

+ 311 - 0
OASystem/OASystem.Domain/Dtos/Resource/CarDataDto.cs

@@ -0,0 +1,311 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    /// <summary>
+    /// 添加车公司数据参数
+    /// </summary>
+    public class AddCarDataDto
+    {
+        /// <summary>
+        /// 区域
+        /// </summary>
+        public string UnitArea { get; set; }
+
+        /// <summary>
+        /// 公司名称
+        /// </summary>
+        public string UnitName { get; set; }
+
+        /// <summary>
+        /// 地址
+        /// </summary>
+        public string Address { get; set; }
+
+        /// <summary>
+        /// 联系人
+        /// </summary>
+        public string Contact { get; set; }
+
+        /// <summary>
+        /// 联系人手机号
+        /// </summary>
+        private string contactTel;
+        public string ContactTel
+        {
+            get
+            {
+                return contactTel;
+            }
+            set
+            {
+                if (Regex.IsMatch(value, @"^[1]+[2,3,4,5,6,7,8,9]+\d{9}"))
+                {
+                    contactTel = value;
+                }
+                else
+                {
+                    contactTel = "";
+                }
+
+            }
+        }
+
+        /// <summary>
+        /// 联系人邮箱
+        /// </summary>
+        public string ContactEmail { get; set; }
+
+        /// <summary>
+        /// 联系人传真
+        /// </summary>
+        public string ContactFax { get; set; }
+
+        /// <summary>
+        /// 车描述
+        /// </summary>
+        public string CarDes { get; set; }
+
+        /// <summary>
+        /// 车图片路径
+        /// 存储多个 使用/r/n
+        /// </summary>
+        public string CarPicPaths { get; set; }
+
+
+        /// <summary>
+        /// 其他信息
+        /// </summary>
+        public string OtherInfo { get; set; }
+
+        /// <summary>
+        /// 服务评分
+        /// </summary>
+        public int Score { get; set; }
+
+        /// <summary>
+        /// 相关的车辆资质
+        /// A B C  选择
+        /// </summary>
+        public string QualificationScore { get; set; }
+
+        /// <summary>
+        /// 车辆2-4年新,VIP及以上需要2年新
+        /// A B C  选择
+        /// </summary>
+        public string CarAgeScore { get; set; }
+
+        /// <summary>
+        /// 车身干净,无文字图片等
+        /// A B C  选择
+        /// </summary>
+        public string CleanImgScore { get; set; }
+
+        /// <summary>
+        /// 车内整洁、无异味
+        /// A B C  选择
+        /// </summary>
+        public string SmellScore { get; set; }
+
+        /// <summary>
+        /// 提前备水,纸巾等
+        /// A B C  选择
+        /// </summary>
+        public string WaterPaperScore { get; set; }
+
+        /// <summary>
+        /// 车辆配置高(皮座椅等)
+        /// A B C  选择
+        /// </summary>
+        public string HardwareScore { get; set; }
+
+        /// <summary>
+        /// 时间概念强
+        /// A B C  选择
+        /// </summary>
+        public string TimeScore { get; set; }
+
+        /// <summary>
+        /// 安全意识高
+        /// A B C  选择
+        /// </summary>
+        public string SafetyScore { get; set; }
+
+        /// <summary>
+        /// 司机驾龄时间长,提前熟悉路线
+        /// A B C  选择
+        /// </summary>
+        public string DrivingAgeScore { get; set; }
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string Remark { get; set; }
+    }
+    /// <summary>
+    /// 修改车公司数据参数
+    /// </summary>
+    public class UpCarDataDto
+    {
+        /// <summary>
+        /// Id
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 区域
+        /// </summary>
+        public string UnitArea { get; set; }
+
+        /// <summary>
+        /// 公司名称
+        /// </summary>
+        public string UnitName { get; set; }
+
+        /// <summary>
+        /// 地址
+        /// </summary>
+        public string Address { get; set; }
+
+        /// <summary>
+        /// 联系人
+        /// </summary>
+        public string Contact { get; set; }
+
+        /// <summary>
+        /// 联系人手机号
+        /// </summary>
+        private string contactTel;
+        public string ContactTel
+        {
+            get
+            {
+                return contactTel;
+            }
+            set
+            {
+                if (Regex.IsMatch(value, @"^[1]+[2,3,4,5,6,7,8,9]+\d{9}"))
+                {
+                    contactTel = value;
+                }
+                else
+                {
+                    contactTel = "";
+                }
+
+            }
+        }
+
+        /// <summary>
+        /// 联系人邮箱
+        /// </summary>
+        public string ContactEmail { get; set; }
+
+        /// <summary>
+        /// 联系人传真
+        /// </summary>
+        public string ContactFax { get; set; }
+
+        /// <summary>
+        /// 车描述
+        /// </summary>
+        public string CarDes { get; set; }
+
+        /// <summary>
+        /// 车图片路径
+        /// 存储多个 使用/r/n
+        /// </summary>
+        public string CarPicPaths { get; set; }
+
+
+        /// <summary>
+        /// 其他信息
+        /// </summary>
+        public string OtherInfo { get; set; }
+
+        /// <summary>
+        /// 服务评分
+        /// </summary>
+        public int Score { get; set; }
+
+        /// <summary>
+        /// 相关的车辆资质
+        /// A B C  选择
+        /// </summary>
+        public string QualificationScore { get; set; }
+
+        /// <summary>
+        /// 车辆2-4年新,VIP及以上需要2年新
+        /// A B C  选择
+        /// </summary>
+        public string CarAgeScore { get; set; }
+
+        /// <summary>
+        /// 车身干净,无文字图片等
+        /// A B C  选择
+        /// </summary>
+        public string CleanImgScore { get; set; }
+
+        /// <summary>
+        /// 车内整洁、无异味
+        /// A B C  选择
+        /// </summary>
+        public string SmellScore { get; set; }
+
+        /// <summary>
+        /// 提前备水,纸巾等
+        /// A B C  选择
+        /// </summary>
+        public string WaterPaperScore { get; set; }
+
+        /// <summary>
+        /// 车辆配置高(皮座椅等)
+        /// A B C  选择
+        /// </summary>
+        public string HardwareScore { get; set; }
+
+        /// <summary>
+        /// 时间概念强
+        /// A B C  选择
+        /// </summary>
+        public string TimeScore { get; set; }
+
+        /// <summary>
+        /// 安全意识高
+        /// A B C  选择
+        /// </summary>
+        public string SafetyScore { get; set; }
+
+        /// <summary>
+        /// 司机驾龄时间长,提前熟悉路线
+        /// A B C  选择
+        /// </summary>
+        public string DrivingAgeScore { get; set; }
+       
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string Remark { get; set; }
+    }
+
+    public class DelCarDataDto
+    {
+        /// <summary>
+        /// 删除Id
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 删除人Id
+        /// </summary>
+        public int DeleteUserId { get; set; }
+    }
+}

+ 19 - 0
OASystem/OASystem.Domain/Dtos/System/SetDataDto.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.System
+{
+    /// <summary>
+    /// 类型表参数
+    /// </summary>
+    public class SetDataDto
+    {
+        /// <summary>
+        /// 数据类型
+        /// </summary>
+        public int DataType { get; set; }
+    }
+}

+ 13 - 0
OASystem/OASystem.Domain/ViewModels/Resource/CarDataView.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 CarDataView:Res_CarData
+    {
+    }
+}

+ 11 - 0
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -177,6 +177,7 @@ namespace OASystem.Infrastructure.Repositories
             }).ExecuteCommandAsync();
             return result > 0;
         }
+       
         public virtual async Task<bool> SoftDeleteAsync(Expression<Func<TEntity, bool>> wherexp)
         {
             var result = await _sqlSugar.Updateable<TEntity>().Where(wherexp).SetColumns(a => new TEntity()
@@ -244,6 +245,16 @@ namespace OASystem.Infrastructure.Repositories
             }).ExecuteCommandAsync();
             return result > 0;
         }
+        public virtual async Task<bool> SoftDeleteByIdAsync<T>(string id,int DeleteUserId) where T : EntityBase, new()
+        {
+            var result = await _sqlSugar.Updateable<TEntity>().Where(a => a.Id.Equals(id)).SetColumns(a => new TEntity()
+            {
+                IsDel = 1,
+                DeleteUserId = DeleteUserId,
+                DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+            }).ExecuteCommandAsync();
+            return result > 0;
+        }
         public virtual async Task<bool> SoftDeleteAsync<T>(Expression<Func<TEntity, bool>> wherexp) where T : EntityBase, new()
         {
             var result = await _sqlSugar.Updateable<TEntity>().Where(wherexp).SetColumns(a => new TEntity()

+ 12 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/CarDataRepository.cs

@@ -0,0 +1,12 @@
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Resource;
+namespace OASystem.Infrastructure.Repositories.Resource
+{
+    public class CarDataRepository: BaseRepository<Res_CarData, CarDataView>
+    {
+        public CarDataRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        {
+
+        }
+    }
+}