| | |
| | | using System.Net; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEA_ISerialPortRepository; |
| | | using Microsoft.AspNetCore.Http; |
| | | using SqlSugar; |
| | | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; |
| | | using Microsoft.AspNetCore.Builder; |
| | | |
| | | namespace WIDESEAWCS_SystemServices |
| | | { |
| | |
| | | nameof(Sys_User.LastModifyPwdDate), |
| | | nameof(Sys_User.UserPwd) |
| | | }); |
| | | |
| | | content = WebResponseContent.Instance.OK("å¯ç ä¿®æ¹æå"); |
| | | //content = WebResponseContent.Instance.OK("å¯ç ä¿®æ¹æå",userId); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | content = WebResponseContent.Instance.Error("æå¡å¨äºç¹é®é¢,请ç¨ååè¯"); |
| | | } |
| | | return content; |
| | | |
| | | } |
| | | |
| | | public WebResponseContent GetUerType() |
| | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent PermissionView(int userId, string group) |
| | | public WebResponseContent PermissionView(int userId, string group) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent UploaDavatar(List<IFormFile> files, int userId) |
| | | { |
| | | if (files == null || files.Count == 0) |
| | | return new WebResponseContent { Status = false, Message = "请ä¸ä¼ æä»¶" }; |
| | | |
| | | // 1. æå®åºå®çåå¨ç®å½ |
| | | //string baseDirectory = @"E:\ç¾å\NiuJuKongZhi\项ç®ä»£ç \WIDESEAWCS_Server æ£å¼\WIDESEAWCS_Server\wwwroot\image\"; |
| | | string baseDirectory = @"wwwroot\image\"; |
| | | |
| | | // 2. çæåç®å½ï¼é¿å
æä»¶å²çª |
| | | string subDirectory = $"{DateTime.Now:yyMMddHHmmss}_{new Random().Next(1000, 9999)}"; |
| | | string filePath = Path.Combine(baseDirectory, subDirectory); |
| | | |
| | | //3. ç¡®ä¿ç®å½åå¨ |
| | | if (!Directory.Exists(filePath)) |
| | | Directory.CreateDirectory(filePath); |
| | | |
| | | try |
| | | { |
| | | string uploadedFilePath = ""; |
| | | for (int i = 0; i < files.Count; i++) |
| | | { |
| | | // 4. çæå¯ä¸æä»¶åï¼é²æ¢éåè¦çï¼ |
| | | string fileName = $"{Guid.NewGuid()}{Path.GetExtension(files[i].FileName)}"; |
| | | string fullFilePath = Path.Combine(filePath, fileName); |
| | | |
| | | // 5. ä¿åæä»¶å°æå®è·¯å¾ |
| | | using (var stream = new FileStream(fullFilePath, FileMode.Create)) |
| | | { |
| | | files[i].CopyTo(stream); |
| | | } |
| | | |
| | | // 6. è®°å½æä»¶è·¯å¾ï¼åå
¥æ°æ®åºçç¸å¯¹è·¯å¾ï¼ |
| | | uploadedFilePath = Path.Combine("/image", subDirectory, fileName).Replace("\\", "/"); |
| | | break; // åªå¤ç第ä¸ä¸ªæä»¶ |
| | | } |
| | | |
| | | //7. æ´æ°ç¨æ·å¤´åè·¯å¾å°æ°æ®åº |
| | | var user = BaseDal.QueryData(u => u.User_Id == userId).FirstOrDefault(); |
| | | if (user != null) |
| | | { |
| | | user.HeadImageUrl = uploadedFilePath; |
| | | UpdateData(user); |
| | | } |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "ç¨æ·ä¸åå¨" }; |
| | | } |
| | | |
| | | return new WebResponseContent { Status = true, Message = "æä»¶ä¸ä¼ æå", Data = uploadedFilePath }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "ä¸ä¼ æä»¶å¤±è´¥ï¼" + ex.Message }; |
| | | } |
| | | } |
| | | } |
| | | } |