Просмотр исходного кода

新增客户资料的关联rep

wangh 1 год назад
Родитель
Сommit
b508851c2d

+ 109 - 3
OASystem/OASystem.Api/Controllers/CRMController.cs

@@ -17,16 +17,24 @@ namespace OASystem.API.Controllers
     {
         private readonly VisaDeleClientCompanyRepository _clientCompanyRepository;
         private readonly VisaDeleClientRepository _clientRepository;
-
+        private readonly CustomerCertRepository _customerCertRep;
+        private readonly CustomerFamilyRepository _customerFamilyRep;
+        private readonly CustomerSchoolRepository _customerSchoolRep;
+        private readonly CustomerCompanyRepository _customerCompanyRep;
         /// <summary>
         /// 初始化
         /// </summary>
         /// <param name="clientCompanyRepository"></param>
         /// <param name="clientRepository"></param>
-        public CRMController(VisaDeleClientCompanyRepository clientCompanyRepository, VisaDeleClientRepository clientRepository)
+        public CRMController(VisaDeleClientCompanyRepository clientCompanyRepository, VisaDeleClientRepository clientRepository,
+            CustomerCertRepository customerCertRep, CustomerFamilyRepository customerFamilyRep,CustomerSchoolRepository customerSchoolRep, CustomerCompanyRepository customerCompanyRep)
         {
             this._clientCompanyRepository = clientCompanyRepository;
             this._clientRepository = clientRepository;
+            this._customerCertRep = customerCertRep;
+            this._customerFamilyRep = customerFamilyRep;
+            this._customerSchoolRep = customerSchoolRep;
+            _customerCompanyRep = customerCompanyRep;
         }
 
         /// <summary>
@@ -92,7 +100,7 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> DelClientCompany(ClientCompanyDto dto)
+        public async Task<IActionResult> DelClientCompany(DelBaseDto dto)
         {
             try
             {
@@ -217,5 +225,103 @@ namespace OASystem.API.Controllers
             }
             return Ok(JsonView(false, "程序错误!"));
         }
+        /// <summary>
+        /// 证件表数据删除
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelCustomerCerts(DelBaseDto dto)
+        {
+            try
+            {
+                var result = await _customerCertRep.SoftDeleteByIdAsync<Crm_CustomerCert>(dto.Id.ToString(),dto.DeleteUserId);
+                if (!result)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            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> DelCustomerFamily(DelBaseDto dto)
+        {
+            try
+            {
+                var result = await _customerFamilyRep.SoftDeleteByIdAsync<Crm_VisaCustomerFamily>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!result)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            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> DelCustomerSchool(DelBaseDto dto)
+        {
+            try
+            {
+                var result = await _customerSchoolRep.SoftDeleteByIdAsync<Crm_VisaCustomerSchool>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!result)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            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> DelVisaCustomerCompany(DelBaseDto dto)
+        {
+            try
+            {
+                var result = await _customerCompanyRep.SoftDeleteByIdAsync<Crm_VisaCustomerCompany>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!result)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
     }
 }

+ 14 - 0
OASystem/OASystem.Domain/Dtos/DtoBase.cs

@@ -25,4 +25,18 @@ namespace OASystem.Domain.Dtos
     {
         public string Paras { get; set; }
     }
+    /// <summary>
+    /// 删除参数
+    /// </summary>
+    public class DelBaseDto
+    {
+        /// <summary>
+        /// 删除的数据Id
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 删除者Id
+        /// </summary>
+        public int DeleteUserId { get; set; }
+    }
 }

+ 22 - 0
OASystem/OASystem.Infrastructure/Repositories/CRM/CustomerCertRepository.cs

@@ -0,0 +1,22 @@
+using AutoMapper;
+using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.ViewModels.CRM;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.CRM
+{
+    public class CustomerCertRepository : BaseRepository<Crm_CustomerCert, CustomerCertView>
+    {
+        private readonly IMapper _mapper;
+        public CustomerCertRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+            base(sqlSugar)
+        {
+            this._mapper = mapper;
+
+        }
+    }
+}

+ 23 - 0
OASystem/OASystem.Infrastructure/Repositories/CRM/CustomerCompanyRepository.cs

@@ -0,0 +1,23 @@
+using AutoMapper;
+using OASystem.Domain.Dtos.CRM;
+using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.ViewModels.CRM;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.CRM
+{
+    public class CustomerCompanyRepository : BaseRepository<Crm_VisaCustomerCompany, VisaCustomerCompany>
+    {
+        private readonly IMapper _mapper;
+        public CustomerCompanyRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+            base(sqlSugar)
+        {
+            this._mapper = mapper;
+
+        }
+    }
+}

+ 22 - 0
OASystem/OASystem.Infrastructure/Repositories/CRM/CustomerFamilyRepository.cs

@@ -0,0 +1,22 @@
+using AutoMapper;
+using OASystem.Domain.Dtos.CRM;
+using OASystem.Domain.Entities.Customer;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.CRM
+{
+    public class CustomerFamilyRepository : BaseRepository<Crm_VisaCustomerFamily, CustomerFamily>
+    {
+        private readonly IMapper _mapper;
+        public CustomerFamilyRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+            base(sqlSugar)
+        {
+            this._mapper = mapper;
+
+        }
+    }
+}

+ 23 - 0
OASystem/OASystem.Infrastructure/Repositories/CRM/CustomerSchoolRepository.cs

@@ -0,0 +1,23 @@
+using AutoMapper;
+using OASystem.Domain.Dtos.CRM;
+using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.ViewModels.CRM;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.CRM
+{
+    public class CustomerSchoolRepository : BaseRepository<Crm_VisaCustomerSchool, VisaCustomerSchool>
+    {
+        private readonly IMapper _mapper;
+        public CustomerSchoolRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+            base(sqlSugar)
+        {
+            this._mapper = mapper;
+
+        }
+    }
+}

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientRepository.cs

@@ -334,7 +334,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                             int res = await _sqlSugar.Updateable<Crm_CustomerCert>().Where(a => a.Id == CustomerCert.Id).SetColumns(a => new Crm_CustomerCert
                             {
                                 DcId=CustomerCert.DcId,
-                                SdId = CustomerCert.DcId,
+                                SdId = CustomerCert.SdId,
                                 CertNo = CustomerCert.CertNo,
                                 Country = CustomerCert.Country,
                                 Area = CustomerCert.Area,