using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using Entity.DbModel;
using Entity.Dto.Req;
using HybirdFrameworkCore.Entity;
using Service.Mgr;
using Service.System;
using Entity.Base;
using Entity.DbModel.System;
namespace WebStarter.Controllers.System
{
[Produces("application/json")]
[ApiController]
public class SysUserController
{
private readonly SysUserService _sysUserService;
public SysUserController(SysUserService sysAuthService)
{
_sysUserService = sysAuthService;
}
///
/// 获取用户分页列表
///
///
///
[HttpPost]
[Route("api/sysUser/page")]
public async Task> UserPageList([FromBody] PageUserReq input)
{
return await _sysUserService.Page(input);
}
//UpdateUser
[HttpPost]
[Route("api/sysUser/update")]
public async Task> UpdateUser(UpdateUserReq input)
{
var data = await _sysUserService.UpdateUser(input);
return Result.Success(data);
}
///
/// 增加用户
///
/// param >
/// < returns > returns >
[HttpPost]
[Route("api/sysUser/add")]
public async Task> AddUser([FromBody][Required] AddUserReq input)
{
var data = await _sysUserService.AddUser(input);
return Result.Success(data);
}
///
/// 删除用户
///
///
///
[HttpPost]
[Route("/api/sysUser/delete")]
public async Task DeleteUser([FromBody][Required] DeleteUserReq input)
{
await _sysUserService.DeleteUser(input);
}
///
/// 得到当前用户的基本信息
///
///
///
[HttpGet]
[Route("api/sysUser/baseInfo")]
public async Task GetBaseInfo()
{
return await _sysUserService.GetBaseInfo(UserManager.Account);
}
///
/// 更新用户信息
///
///
///
[HttpPost]
[Route("/api/sysUser/baseInfo")]
public async Task> UpdateBaseInfo([FromBody] SysUser user)
{
var data = await _sysUserService.UpdateBaseInfo(user);
if (data)
return Result.Success(data);
else
return Result.Fail(data);
}
///
/// 设置用户状态
///
///
///
[HttpPost]
[Route("/api/sysUser/setStatus")]
public async Task> SetStatusInfo([FromBody] UserReq input)
{
var data = await _sysUserService.SetStatus(input);
return Result.Success(data);
}
///
/// 授权用户角色
///
///
///
[HttpPost]
[Route("/api/sysUsergrantRole")]
public async Task GrantRole([FromBody] UserRoleReq input)
{
await _sysUserService.GrantRole(input);
}
///
/// 修改用户密码
///
///
///
[HttpPost]
[Route("/api/sysUser/changePwd")]
public async Task> ChangePwd([FromBody] ChangePwdReq input)
{
var data = await _sysUserService.ChangePwd(input);
return Result.Success(data);
}
///
/// 获取用户拥有角色集合
///
///
///
[HttpGet]
[Route("/api/sysUser/ownRoleList/{userId}")]
public async Task> GetOwnRoleList(long userId)
{
return await _sysUserService.GetOwnRoleList(userId);
}
[HttpPost]
[Route("/api/sysUser/unlockLogin")]
public async Task> UnlockLogin(UnlockLoginReq input)
{
var data = await _sysUserService.UnlockLogin(input);
return Result.Success(data);
}
[HttpPost]
[Route("/api/sysUser/resetPwd")]
public async Task> ResetPwd(ResetPwdUserReq input)
{
var data = await _sysUserService.ResetPwd(input);
return Result.Success(data);
}
}
}