From 17308f6494c81fb5a5ee035724a414ec7da11936 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 22 八月 2024 08:38:45 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/cylsg

---
 cylsg/cylsg.Application/Users/UserAppService.cs |  206 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 206 insertions(+), 0 deletions(-)

diff --git a/cylsg/cylsg.Application/Users/UserAppService.cs b/cylsg/cylsg.Application/Users/UserAppService.cs
new file mode 100644
index 0000000..baf8708
--- /dev/null
+++ b/cylsg/cylsg.Application/Users/UserAppService.cs
@@ -0,0 +1,206 @@
+锘縰sing cylsg.Core.Attributes;
+using cylsg.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using cylsg.Application.Users.Dtos;
+using cylsg.Model.UserModel;
+using System.Security.Claims;
+using System.Runtime.Intrinsics.Arm;
+using MapsterMapper;
+
+namespace cylsg.Application.Users
+{
+    /// <summary>
+    /// 鐢ㄦ埛鎺ュ彛
+    /// </summary>
+    [Authorize]
+    public class UserAppService : IDynamicApiController
+    {
+        private readonly ISystemService _systemService;
+        private ISqlSugarClient _sqlSugarClient;
+        private IMapper _mapper;
+        public UserAppService(ISystemService systemService, ISqlSugarClient sqlSugarClient, IMapper mapper)
+        {
+            _systemService = systemService;
+            _sqlSugarClient = sqlSugarClient;
+            _mapper = mapper;
+        }
+
+
+
+        /// <summary>
+        /// 鏌ヨ褰撳墠鐢ㄦ埛
+        /// </summary>
+        /// <returns></returns>
+        public async Task<UserDto> getUser()
+        {
+
+            var UserID = App.User?.FindFirstValue("UserID");
+            int userid = 0;
+            if (!string.IsNullOrEmpty(UserID))
+            {
+                userid = int.Parse(UserID);
+            }
+            UserDto userDto = new UserDto();
+            var userRes = new BaseRepository<User>();
+            var userWorkerRes = new BaseRepository<UserWorker>();
+            var userCompanyRes = new BaseRepository<UserCompany>();
+            var user = await userRes.GetByIdAsync(userid);
+            userDto = _mapper.Map<UserDto>(user);
+
+            var userWorker = await userWorkerRes.GetFirstAsync(p=>p.UserId== userid);
+            userDto.userWorker = _mapper.Map<UserWorkerDto>(userWorker);
+
+            var userCompany = await userCompanyRes.GetFirstAsync(p => p.UserId == userid);
+            userDto.userCompany = _mapper.Map<UserCompanyDto>(userCompany);
+
+
+
+            return userDto;
+        }
+
+
+        /// <summary>
+        /// 淇濆瓨鐢ㄦ埛宸ヤ汉淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        public async Task<bool> saveUserWorker(UserWorkerDto userWorkerDto)
+        {
+
+            var UserID = App.User?.FindFirstValue("UserID");
+            int userid = 0;
+            string ITCode = App.User?.FindFirstValue("ITCode");
+            if (!string.IsNullOrEmpty(UserID))
+            {
+                userid = int.Parse(UserID);
+            }
+         
+            var userWorkerRes = new BaseRepository<UserWorker>();
+            bool res;
+            if (userWorkerDto.Id > 0)
+            {
+                var userWorker1 = await userWorkerRes.GetByIdAsync(userWorkerDto.Id);
+                userWorker1.IdCardBack = userWorkerDto.IdCardBack;
+                userWorker1.IdCardFace = userWorkerDto.IdCardFace;
+                userWorker1.name = userWorkerDto.name;
+                userWorker1.Phone = userWorkerDto.Phone;
+                userWorker1.IdCode = userWorkerDto.IdCode;
+                userWorker1.Address = userWorkerDto.Address;
+                userWorker1.Resume = userWorkerDto.Resume;
+
+                userWorker1.UpDataBy = ITCode;
+                userWorker1.UpDataTime = DateTime.Now;
+                res = await userWorkerRes.UpdateAsync(userWorker1);
+
+
+            }
+            else
+            {
+                var userWorker = _mapper.Map<UserWorker>(userWorkerDto);
+                userWorker.UpDataBy = ITCode;
+                userWorker.UpDataTime = DateTime.Now;
+                userWorker.CreateBy = ITCode;
+                userWorker.CreateTime = DateTime.Now;
+                userWorker.UserId = userid;
+                res = await userWorkerRes.InsertAsync(userWorker);
+            }
+
+
+
+           
+
+
+
+            return res;
+        }
+
+
+
+
+        /// <summary>
+        /// 淇濆瓨鐢ㄦ埛鍏徃淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        public async Task<bool> saveUserCompany(UserCompanyDto userCompanyDto)
+        {
+
+            var UserID = App.User?.FindFirstValue("UserID");
+            int userid = 0;
+            string ITCode = App.User?.FindFirstValue("ITCode");
+            if (!string.IsNullOrEmpty(UserID))
+            {
+                userid = int.Parse(UserID);
+            }
+          
+            var userCompanyRes = new BaseRepository<UserCompany>();
+            bool res;
+            if (userCompanyDto.Id > 0)
+            {
+                var userCompany1 = await userCompanyRes.GetByIdAsync(userCompanyDto.Id);
+                userCompany1.BusinessLicense = userCompanyDto.BusinessLicense;
+                userCompany1.Suppliername = userCompanyDto.Suppliername;
+                userCompany1.Regtime = userCompanyDto.Regtime;
+                userCompany1.Address = userCompanyDto.Address;
+                userCompany1.Suppliercode = userCompanyDto.Suppliercode;
+                userCompany1.Contact = userCompanyDto.Contact;
+                userCompany1.Phone = userCompanyDto.Phone;
+                userCompany1.Resume = userCompanyDto.Resume;
+ 
+
+                userCompany1.UpDataBy = ITCode;
+                userCompany1.UpDataTime = DateTime.Now;
+                res = await userCompanyRes.UpdateAsync(userCompany1);
+
+
+            }
+            else
+            {
+                var userCompany = _mapper.Map<UserCompany>(userCompanyDto);
+                userCompany.UpDataBy = ITCode;
+                userCompany.UpDataTime = DateTime.Now;
+                userCompany.CreateBy = ITCode;
+                userCompany.CreateTime = DateTime.Now;
+                userCompany.UserId = userid;
+                res = await userCompanyRes.InsertAsync(userCompany);
+            }
+
+
+
+
+
+
+
+            return res;
+        }
+
+
+
+        /// <summary>
+        /// 鏍规嵁Id鏌ヨ鐢ㄦ埛
+        /// </summary>
+        /// <returns></returns>
+        public async Task<UserDto> getUser(int userid)
+        {
+            UserDto userDto = new UserDto();
+            var userRes = new BaseRepository<User>();
+            var userWorkerRes = new BaseRepository<UserWorker>();
+            var userCompanyRes = new BaseRepository<UserCompany>();
+            var user = await userRes.GetByIdAsync(userid);
+            userDto = _mapper.Map<UserDto>(user);
+
+            var userWorker = await userWorkerRes.GetFirstAsync(p => p.UserId == userid);
+            userDto.userWorker = _mapper.Map<UserWorkerDto>(userWorker);
+
+            var userCompany = await userCompanyRes.GetFirstAsync(p => p.UserId == userid);
+            userDto.userCompany = _mapper.Map<UserCompanyDto>(userCompany);
+
+
+
+            return userDto;
+        }
+
+    }
+}

--
Gitblit v1.9.1