| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Caching.Memory; |
| | | using Newtonsoft.Json; |
| | | using StackExchange.Profiling; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Authorization; |
| | | using WIDESEAWCS_Core.BaseController; |
| | | using WIDESEAWCS_Core.Const; |
| | | using WIDESEAWCS_Core.Extensions; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.HttpContextUser; |
| | | using WIDESEAWCS_Core.Utilities; |
| | | using WIDESEAWCS_DTO.SerialPort; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_Model; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | public Sys_UserController(ISys_UserService userService, IHttpContextAccessor httpContextAccessor) : base(userService) |
| | | { |
| | | _httpContextAccessor = httpContextAccessor; |
| | | } |
| | | |
| | | |
| | | |
| | | [HttpPost, Route("swgLogin"), AllowAnonymous] |
| | | public dynamic SwgLogin([FromBody] SwaggerLoginRequest loginRequest) |
| | | { |
| | | if (loginRequest is null) |
| | | { |
| | | return new { result = false }; |
| | | } |
| | | |
| | | try |
| | | { |
| | | LoginInfo loginInfo = new LoginInfo |
| | | { |
| | | Password = loginRequest.pwd, |
| | | UserName = loginRequest.name |
| | | }; |
| | | var result = Service.Login(loginInfo); |
| | | if (result.Status) |
| | | { |
| | | HttpContext.SuccessSwagger(); |
| | | Dictionary<string, object>? dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(result.Data.Serialize()); |
| | | if (dict != null) |
| | | { |
| | | HttpContext.SuccessSwaggerJwt((dict.ContainsKey("token") ? dict["token"].ToString() : "") ?? ""); |
| | | } |
| | | string str = HttpContext.GetSuccessSwaggerJwt(); |
| | | return new { result = true }; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | |
| | | return new { result = false }; |
| | | } |
| | | |
| | | [HttpPost, Route("login"), AllowAnonymous] |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | [HttpGet, Route("GetUerType"), AllowAnonymous] |
| | | public WebResponseContent GetUerType() |
| | | { |
| | | return Service.GetUerType(); |
| | | } |
| | | |
| | | [HttpPost, Route("PermissionView"), AllowAnonymous] |
| | | public WebResponseContent PermissionView(int userId, string group) |
| | | { |
| | | return Service.PermissionView(userId,group); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¸ä¼ å¾çæä»¶å |
| | | /// </summary> |
| | | /// <param name="files"></param> |
| | | /// <param name="sys_User"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("SaveFiles"), AllowAnonymous] |
| | | public WebResponseContent SaveFiles(IFormCollection files) |
| | | { |
| | | return Service.SaveFiles(files); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ç¨æ·å¯ç |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="oldPwd"></param> |
| | | /// <param name="newPwd"></param> |
| | | /// <returns></returns> |
| | | [HttpPost,Route("UpdatePwd")] |
| | | public WebResponseContent UpdatePwd(int id, string oldPwd, string newPwd) |
| | | { |
| | | return Service.UpdatePwd(id, oldPwd, newPwd); |
| | | } |
| | | |
| | | |
| | | [HttpPost,Route("Upuserbase"), AllowAnonymous] |
| | | public WebResponseContent Upuserbase([FromBody]UserDTO userDTO) |
| | | { |
| | | return Service.Upuserbase(userDTO); |
| | | } |
| | | } |
| | | |
| | | |
| | | public class SwaggerLoginRequest |
| | | { |
| | | public string name { get; set; } |
| | | public string pwd { get; set; } |
| | | } |
| | | } |