You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
4.5 KiB
C#

2 years ago
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.WebApi.Controllers;
/// <summary>
/// 公共模块
/// </summary>
public class CommonController : ApiController
{
private readonly ICommonService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public CommonController(ICommonService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("Login")]
public DataResult<string> Login([FromBody] UserLoginModel model)
{
var res = _invokeService.UserLogin(model);
return res;
}
/// <summary>
/// 获取用户
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetUserInfo")]
public DataResult<CurrentUserViewModel> GetUserInfo()
{
var res = _invokeService.GetUserInfo();
return res;
}
/// <summary>
/// 登出
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("Logout")]
public DataResult<string> Logout()
{
return DataResult<string>.Success("");
}
/// <summary>
/// 获取用户权限菜单
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("GetUserPermission")]
public DataResult<Permission> GetUserPermission([FromQuery]string userId)
{
var res = _invokeService.GetUserPermission(userId);
return res;
}
/// <summary>
/// 获取用户菜单
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("GetUserMenuList")]
public DataResult<List<UserMenu>> GetUserMenuList([FromQuery]string userId)
{
var res = _invokeService.GetUserMenuList(userId);
return res;
}
/// <summary>
/// 版本升级
/// </summary>
/// <param name="appVersion">版本号</param>
/// <returns></returns>
[HttpGet]
[Route("AppUpdate")]
public JsonResult AppUpdate([FromQuery] string appVersion)
{
var res = _invokeService.AppUpdate(appVersion);
return Json(res);
}
/// <summary>
/// 查询用户拥有的菜单权限
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetUserPermissionByToken")]
public DataResult<List<RouteItem>> GetUserPermissionByToken()
{
var res = _invokeService.GetUserPermissionByToken();
return res;
}
/// <summary>
/// 获取权限按钮
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetPermCode")]
public DataResult<string[]> GetPermCode()
{
var res = _invokeService.GetPermCode();
return res;
}
/// <summary>
/// 获取字典下拉明细
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("GetDictTypeDropDown")]
public DataResult GetDictTypeDropDown([FromBody] DropDownDictTypeInput model)
{
var res = _invokeService.GetDictTypeDropDown(model);
return res;
}
/// <summary>
/// 批量获取字典值
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("GetDictOptions")]
public DataResult<List<DictOptions>> GetDictOptions([FromBody] DropDownDictTypeInput model)
{
var res = _invokeService.GetDictOptions(model);
return res;
}
2 years ago
/// <summary>
/// 获取角色下拉选项
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetRoleList")]
public DataResult<List<ApiSelectViewModel>> GetRoleList()
{
var res = _invokeService.GetRoleList();
return res;
}
/// <summary>
/// 获取用户租户列表
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetUserTenants")]
public DataResult<List<TenantViewModel>> GetUserTenants()
{
var res = _invokeService.GetUserTenants();
return res;
}
/// <summary>
/// 更换租户
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("ChangeTenant")]
public DataResult<string> ChangeTenant([FromQuery]string id)
{
var res = _invokeService.ChangeTenant(id);
return res;
}
2 years ago
}