|
|
@ -42,6 +42,75 @@ namespace _24Hour.Controllers |
|
|
|
_db = db; |
|
|
|
_db = db; |
|
|
|
_configuration = configuration; |
|
|
|
_configuration = configuration; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
|
|
[Route("LoginDefault")] |
|
|
|
|
|
|
|
[CustomCorsActionFilterAttribute] |
|
|
|
|
|
|
|
public async Task<Result> LoginDefault() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var Passmd5 = Md5.Encrypt32("jcy@123456").ToLower(); |
|
|
|
|
|
|
|
var date = await _db.Queryable<App_Sys_UserModel>().Where(x => x.phone== "admin" && x.IsDeleted==0).FirstAsync(); |
|
|
|
|
|
|
|
if (date == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ret.IsSucceed = false; |
|
|
|
|
|
|
|
ret.Message = "账号不存在,请先注册!"; |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (Passmd5 != date.Password) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ret.IsSucceed = false; |
|
|
|
|
|
|
|
ret.Message = "账号或者密码错误!"; |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(date.department)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var dept = await _db.Queryable<App_Sys_DepartModel>().Where(x => x.Id== date.department && x.IsDelete==0).FirstAsync(); |
|
|
|
|
|
|
|
if (dept!= null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
date.departmentName= dept.departname; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#region jwt生成token |
|
|
|
|
|
|
|
var tokenHandler = new JwtSecurityTokenHandler(); |
|
|
|
|
|
|
|
var claims = new Claim[] |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
new Claim(ClaimTypes.UserData,JsonConvert.SerializeObject(date)), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_configuration.GetSection("JwtConfiguration:Jwtkey").Value)); |
|
|
|
|
|
|
|
var signingCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); |
|
|
|
|
|
|
|
//Token |
|
|
|
|
|
|
|
var jwttoken = new JwtSecurityToken( |
|
|
|
|
|
|
|
issuer: _configuration.GetSection("JwtConfiguration:Issuer").Value, |
|
|
|
|
|
|
|
audience: _configuration.GetSection("JwtConfiguration:Audience").Value, |
|
|
|
|
|
|
|
claims: claims, |
|
|
|
|
|
|
|
notBefore: DateTime.Now, |
|
|
|
|
|
|
|
expires: DateTime.Now.AddDays(1), |
|
|
|
|
|
|
|
signingCredentials: signingCredentials |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
//var token = new JwtSecurityTokenHandler().CreateToken(jwttoken); |
|
|
|
|
|
|
|
var tokenString = new JwtSecurityTokenHandler().WriteToken(jwttoken); |
|
|
|
|
|
|
|
ret.IsSucceed=true; |
|
|
|
|
|
|
|
ret.result = new |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = date.Id, |
|
|
|
|
|
|
|
name = date.name, |
|
|
|
|
|
|
|
sex = date.sex, |
|
|
|
|
|
|
|
phone = date.phone, |
|
|
|
|
|
|
|
photo = date.photo, |
|
|
|
|
|
|
|
duties = date.duties, |
|
|
|
|
|
|
|
identity = date.identity, |
|
|
|
|
|
|
|
unitCode = date.unitCode, |
|
|
|
|
|
|
|
department = date.department, |
|
|
|
|
|
|
|
departmentName = date.departmentName, |
|
|
|
|
|
|
|
token = tokenString |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
ret.IsSucceed=true; |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// ϵͳµÇ¼ |
|
|
|
/// ϵͳµÇ¼ |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -459,11 +528,12 @@ namespace _24Hour.Controllers |
|
|
|
/// download file for video repot module |
|
|
|
/// download file for video repot module |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
/// <returns></returns> |
|
|
|
[HttpGet, AllowAnonymous] |
|
|
|
[HttpGet] |
|
|
|
[Route("download")] |
|
|
|
[Route("download")] |
|
|
|
|
|
|
|
[CustomCorsActionFilterAttribute] |
|
|
|
public IActionResult DownloadFile(string filepath) |
|
|
|
public IActionResult DownloadFile(string filepath) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var fileaddr = Path.Combine(Environment.CurrentDirectory,"wwwroot"); |
|
|
|
var fileaddr = Path.Combine(Environment.CurrentDirectory, "wwwroot"); |
|
|
|
fileaddr += filepath; |
|
|
|
fileaddr += filepath; |
|
|
|
if (System.IO.File.Exists(fileaddr) == false) |
|
|
|
if (System.IO.File.Exists(fileaddr) == false) |
|
|
|
{ |
|
|
|
{ |
|
|
|