|
@@ -5,8 +5,6 @@ using System.IdentityModel.Tokens.Jwt;
|
|
using System.Security.Claims;
|
|
using System.Security.Claims;
|
|
using StackExchange.Redis;
|
|
using StackExchange.Redis;
|
|
using OASystem.Domain.Dtos.UserDto;
|
|
using OASystem.Domain.Dtos.UserDto;
|
|
-using OASystem.Domain.Entities.System;
|
|
|
|
-using OASystem.Domain;
|
|
|
|
using OASystem.RedisRepository;
|
|
using OASystem.RedisRepository;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
namespace OASystem.API.Controllers
|
|
@@ -20,11 +18,17 @@ namespace OASystem.API.Controllers
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
private readonly IConfiguration _config;
|
|
private readonly IConfiguration _config;
|
|
private readonly LoginRepository _loginRep;
|
|
private readonly LoginRepository _loginRep;
|
|
- public AuthController(IConfiguration config, LoginRepository loginRep, IMapper mapper)
|
|
+ private readonly UsersRepository _usersRepository;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public AuthController(IConfiguration config, LoginRepository loginRep, IMapper mapper,
|
|
|
|
+ SetDataRepository setDataRepository, CompanyRepository companyRepository,
|
|
|
|
+ SystemMenuPermissionRepository systemMenuPermissionRepository)
|
|
{
|
|
{
|
|
_config = config;
|
|
_config = config;
|
|
_loginRep = loginRep;
|
|
_loginRep = loginRep;
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -32,14 +36,13 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- [AllowAnonymous]
|
|
|
|
[Route("login")]
|
|
[Route("login")]
|
|
[HttpPost]
|
|
[HttpPost]
|
|
[ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
[ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
public async Task<IActionResult> LoginAsync(LoginDto dto)
|
|
public async Task<IActionResult> LoginAsync(LoginDto dto)
|
|
{
|
|
{
|
|
- #region 校验用户信息,假设此处我们已经校验成功
|
|
+ #region 校验用户信息
|
|
- var userData = _loginRep.Login(_loginRep, dto);
|
|
+ var userData = _loginRep.Login(dto);
|
|
if (userData.Result.Code != 0)
|
|
if (userData.Result.Code != 0)
|
|
{
|
|
{
|
|
if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Msg)); }
|
|
if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Msg)); }
|
|
@@ -47,23 +50,11 @@ namespace OASystem.API.Controllers
|
|
return Ok(JsonView(false, "暂无该员工信息!"));
|
|
return Ok(JsonView(false, "暂无该员工信息!"));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- if (userData.Result.Data.HrAudit != 1)
|
|
|
|
- {
|
|
|
|
- return Ok(JsonView(false, "该员工账号暂无登录权限,人事审核未通过!"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (userData.Result.Data.HrAudit != 1)
|
|
|
|
- {
|
|
|
|
- return Ok(JsonView(false, "已离职员工没有登录权限"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#endregion
|
|
#endregion
|
|
var view = new LoginView
|
|
var view = new LoginView
|
|
{
|
|
{
|
|
- Expires = DateTime.Now.AddMinutes(30)
|
|
+ Expires = DateTime.Now.AddMinutes(30),
|
|
|
|
+ UserInfo = userData.Result.Data
|
|
};
|
|
};
|
|
|
|
|
|
string authorId = dto.Number + "Token";
|
|
string authorId = dto.Number + "Token";
|
|
@@ -158,5 +149,79 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
return Ok(JsonView(view));
|
|
return Ok(JsonView(view));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ [Authorize]
|
|
|
|
+ [HttpPost("GetAuth")]
|
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
|
+ public async Task<IActionResult> GetAuth(AuthDto dto)
|
|
|
|
+ {
|
|
|
|
+ Result result = new Result();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var setDataResult = await _setDataRepository.GetSySDefultModule(_setDataRepository);
|
|
|
|
+ if (setDataResult.Code != 0)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(setDataResult.Msg)) ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SetDataView> setDataList = _mapper.Map<List<SetDataView>>(setDataResult.Data);
|
|
|
|
+ var mod = setDataList.Find(x => x.Name == "权限模块");
|
|
|
|
+ if (mod == null)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView("未找到权限模块!"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var SystemMenuPermissionData = _SystemMenuPermissionRepository.GetSystemMenuViweData(_SystemMenuPermissionRepository, mod.Id, dto.pageSize,dto.currentPage);
|
|
|
|
+ if (SystemMenuPermissionData.Code != 0)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(SystemMenuPermissionData.Msg));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var CompanyDataResult = _CompanyRepository.GetCompanyData(_CompanyRepository);
|
|
|
|
+ if (CompanyDataResult.Code != 0)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(CompanyDataResult.Msg));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.Code = 0;
|
|
|
|
+ result.Msg = "成功!";
|
|
|
|
+ var Dyresult = new
|
|
|
|
+ {
|
|
|
|
+ setDataResult = setDataResult.Data,
|
|
|
|
+ CompanyDataResult = CompanyDataResult.Data,
|
|
|
|
+ SystemMenuPermissionData = SystemMenuPermissionData.Data
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return Ok(JsonView(200 ,"成功!", Dyresult));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ [Authorize]
|
|
|
|
+ [HttpPost("QueryDepartmentListByCompId")]
|
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
|
+ public IActionResult QueryDepartmentListByCompId(int companyid)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Ok(JsonView(""));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|