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

161 lines
4.9 KiB

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;
}
/// <summary>
/// 获取用户分页列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("api/sysUser/page")]
public async Task<SqlSugarPagedList<SysUser>> UserPageList([FromBody] PageUserReq input)
{
return await _sysUserService.Page(input);
}
//UpdateUser
[HttpPost]
[Route("api/sysUser/update")]
public async Task<Result<string>> UpdateUser(UpdateUserReq input)
{
var data = await _sysUserService.UpdateUser(input);
return Result<string>.Success(data);
}
/// <summary>
/// 增加用户
/// </summary>
/// <param name = "input" ></ param >
/// < returns ></ returns >
[HttpPost]
[Route("api/sysUser/add")]
public async Task<Result<string>> AddUser([FromBody][Required] AddUserReq input)
{
var data = await _sysUserService.AddUser(input);
return Result<string>.Success(data);
}
/// <summary>
/// 删除用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/sysUser/delete")]
public async Task DeleteUser([FromBody][Required] DeleteUserReq input)
{
await _sysUserService.DeleteUser(input);
}
/// <summary>
/// 得到当前用户的基本信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[Route("api/sysUser/baseInfo")]
public async Task<SysUser> GetBaseInfo()
{
return await _sysUserService.GetBaseInfo(UserManager.Account);
}
/// <summary>
/// 更新用户信息
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/sysUser/baseInfo")]
public async Task<Result<bool>> UpdateBaseInfo([FromBody] SysUser user)
{
var data = await _sysUserService.UpdateBaseInfo(user);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
/// <summary>
/// 设置用户状态
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/sysUser/setStatus")]
public async Task<Result<string>> SetStatusInfo([FromBody] UserReq input)
{
var data = await _sysUserService.SetStatus(input);
return Result<string>.Success(data);
}
/// <summary>
/// 授权用户角色
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/sysUsergrantRole")]
public async Task GrantRole([FromBody] UserRoleReq input)
{
await _sysUserService.GrantRole(input);
}
/// <summary>
/// 修改用户密码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/sysUser/changePwd")]
public async Task<Result<string>> ChangePwd([FromBody] ChangePwdReq input)
{
var data = await _sysUserService.ChangePwd(input);
return Result<string>.Success(data);
}
/// <summary>
/// 获取用户拥有角色集合
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("/api/sysUser/ownRoleList/{userId}")]
public async Task<List<long>> GetOwnRoleList(long userId)
{
return await _sysUserService.GetOwnRoleList(userId);
}
[HttpPost]
[Route("/api/sysUser/unlockLogin")]
public async Task<Result<bool>> UnlockLogin(UnlockLoginReq input)
{
var data = await _sysUserService.UnlockLogin(input);
return Result<bool>.Success(data);
}
[HttpPost]
[Route("/api/sysUser/resetPwd")]
public async Task<Result<string>> ResetPwd(ResetPwdUserReq input)
{
var data = await _sysUserService.ResetPwd(input);
return Result<string>.Success(data);
}
}
}