123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Bowin.Common.ServiceToken;
- using Bowin.Common.ServiceToken.Permission;
- using Bowin.Common.WebModels;
- using YLShipBuildLandMap.Entity.ViewModel;
- using YLShipBuildLandMap.Services.SystemSetting;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Newtonsoft.Json.Linq;
- using Bowin.Common.DES;
- using Bowin.Common.Cache;
- namespace YLShipBuildLandMap.Web.Controllers.SystemSetting
- {
- [Route("api/systemsetting/[controller]/[action]")]
- [Authorize]
- public class AccountController : ControllerBase
- {
- private IUserService UserService { get; set; }
- private IFunctionCodeService FunctionCodeService { get; set; }
- readonly IDesAccessor DesAccessor;
- public AccountController(IUserService userService, IFunctionCodeService functionCodeService,IDesAccessor desAccessor)
- {
- UserService = userService;
- FunctionCodeService = functionCodeService;
- this.DesAccessor = desAccessor;
- }
- [AllowAnonymous]
- [HttpPost]
- public ResultMessage GetToken([FromBody] DesModel inputObject)
- {
- var data = this.DesAccessor.DeDesToken(inputObject);
- var datas = data.Split('|');
- string loginID = datas[0];
- string pdmd = datas[1];
- string verfiyKey = datas[2];
- string verfiyCode = datas[3];
- if (CacheHelper.Get(verfiyKey)?.ToString() != verfiyCode.ToUpper())
- {
- CacheHelper.Remove(verfiyKey);
- return ResultMessage.GetError("验证码错误,请重新输入。");
- }
- else
- {
- CacheHelper.Remove(verfiyKey);
- }
- ResultMessage result = new ResultMessage();
-
- var token = JwtHelper.GetToken(() => UserService.Login(loginID, pdmd), (x => x.UserID));
- return ResultMessage.Success(token);
- }
- [AllowAnonymous]
- [HttpPost]
- public ResultMessage TestToken([FromBody] DesModel inputObject)
- {
- var data = this.DesAccessor.DeDesToken(inputObject);
- return ResultMessage.Success(data);
- }
- [HttpPost]
- public ResultMessage GetUserFunctionCode()
- {
- return ResultMessage.Success(FunctionCodeService.GetUserFunctionCodes(LoginUser.Current.UserID));
- }
- [HttpPost]
- public ResultMessage RefreshToken()
- {
- return ResultMessage.Success(JwtHelper.RefreshToken<LoginUser>());
- }
- [HttpPost]
- public ResultMessage GetUsersForSelect([FromBody] dynamic inputObj)
- {
- string loginID = inputObj.loginID;
- string name = inputObj.name;
- int? pageIndex = inputObj.pageIndex;
- int? pageSize = inputObj.pageSize;
- return ResultMessage.Success(UserService.GetUserViewsForSelect(loginID, name, pageIndex, pageSize));
- }
-
- [HttpPost]
- public ResultMessage GetAllUsersForSelect([FromBody] dynamic inputObj)
- {
- string loginID = inputObj.loginID;
- string name = inputObj.name;
- bool isAllUser = true;
- int? pageIndex = inputObj.pageIndex;
- int? pageSize = inputObj.pageSize;
- return ResultMessage.Success(UserService.GetUserViewsForSelect(loginID, name, pageIndex, pageSize,null, isAllUser));
- }
- [HttpPost]
- public ResultMessage Test([FromBody] dynamic inputObject)
- {
- DateTime? testTime = inputObject.testTime;
- return ResultMessage.Success();
- }
- }
- }
|