using Attribute;
using Base;
using Common;
using Dto;
using Enums;
using Filters;
using Infrastructure;
using Infrastructure.Model;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Middleware;
using Model;
using Model.Base;
using Services;
using Util;
namespace Controllers
{
///
/// 主界面Controller
///
[Route("/")]
public class HomeController : BaseController
{
private readonly ISysPermissionService permissionService;
public HomeController(ISysPermissionService permissionService)
{
this.permissionService = permissionService;
}
[HttpPost("testlogin")]
public IActionResult Login([FromBody] LoginDto parm)
{
TokenModel loginUser = new(new TokenModel()
{
username = parm.AdminName,
userId = 1
}, new List());
List permissions = permissionService.List();
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + "1", permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)));
}
[HttpGet(template: "test")]
public IActionResult Test([FromQuery] LoginDto parm)
{
TokenModel loginUser = new(new TokenModel()
{
username = parm.AdminName,
userId = 1
}, new List());
List permissions = permissionService.List();
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + "1", permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)));
}
// [HttpGet(template: "test1")]
// public IActionResult Test1()
// {
// List list = new List();
// list.Add(new TestVo());
// list.Add(new TestVo(){
// Subs = new TestSubVo()
// });
// return SUCCESS(list);
// }
}
}