2021-10-17 18:37:07 +08:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-10-11 21:50:50 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Yi.Framework.Common.Models;
|
2022-04-26 01:31:14 +08:00
|
|
|
|
using Yi.Framework.DTOModel;
|
2021-10-11 21:50:50 +08:00
|
|
|
|
using Yi.Framework.Interface;
|
|
|
|
|
|
using Yi.Framework.Model.Models;
|
2022-04-06 18:05:00 +08:00
|
|
|
|
using Yi.Framework.Repository;
|
2021-10-13 16:44:15 +08:00
|
|
|
|
using Yi.Framework.WebCore;
|
2022-04-06 22:22:45 +08:00
|
|
|
|
using Yi.Framework.WebCore.AttributeExtend;
|
2022-01-11 16:40:15 +08:00
|
|
|
|
using Yi.Framework.WebCore.AuthorizationPolicy;
|
2021-10-11 21:50:50 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Yi.Framework.ApiMicroservice.Controllers
|
|
|
|
|
|
{
|
2022-04-26 01:31:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用户管理
|
|
|
|
|
|
/// </summary>
|
2021-10-11 21:50:50 +08:00
|
|
|
|
[ApiController]
|
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
2022-09-11 15:55:08 +08:00
|
|
|
|
public class UserController : BaseSimpleRdController<UserEntity>
|
2021-10-11 21:50:50 +08:00
|
|
|
|
{
|
2022-04-12 18:09:13 +08:00
|
|
|
|
private IUserService _iUserService;
|
2022-04-06 18:05:00 +08:00
|
|
|
|
public UserController(ILogger<UserEntity> logger, IUserService iUserService) : base(logger, iUserService)
|
2021-10-11 21:50:50 +08:00
|
|
|
|
{
|
2022-04-12 18:09:13 +08:00
|
|
|
|
_iUserService = iUserService;
|
2021-10-11 21:50:50 +08:00
|
|
|
|
}
|
2022-04-26 01:31:14 +08:00
|
|
|
|
|
2022-09-09 15:53:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 动态条件分页查询
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
|
/// <param name="page"></param>
|
2022-09-13 19:39:16 +08:00
|
|
|
|
/// <param name="deptId"></param>
|
2022-09-09 15:53:11 +08:00
|
|
|
|
/// <returns></returns>
|
2022-09-06 19:32:32 +08:00
|
|
|
|
[HttpGet]
|
2022-09-13 19:39:16 +08:00
|
|
|
|
public async Task<Result> PageList([FromQuery] UserEntity user, [FromQuery] PageParModel page,[FromQuery] long? deptId)
|
2022-09-06 19:32:32 +08:00
|
|
|
|
{
|
2022-09-13 19:39:16 +08:00
|
|
|
|
return Result.Success().SetData(await _iUserService.SelctPageList(user, page, deptId));
|
2022-09-06 19:32:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更改用户状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
|
/// <param name="isDel"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
2022-09-09 15:53:11 +08:00
|
|
|
|
public async Task<Result> UpdateStatus(long userId, bool isDel)
|
2022-09-06 19:32:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
return Result.Success().SetData(await _iUserService._repository.UpdateIgnoreNullAsync(new UserEntity() { Id = userId, IsDeleted = isDel }));
|
2022-09-09 15:53:11 +08:00
|
|
|
|
|
2022-09-06 19:32:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-26 01:31:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 给多用户设置多角色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="giveUserSetRoleDto"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
public async Task<Result> GiveUserSetRole(GiveUserSetRoleDto giveUserSetRoleDto)
|
|
|
|
|
|
{
|
2022-04-26 18:29:18 +08:00
|
|
|
|
return Result.Success().SetStatus(await _iUserService.GiveUserSetRole(giveUserSetRoleDto.UserIds, giveUserSetRoleDto.RoleIds));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-09-11 02:39:33 +08:00
|
|
|
|
/// 通过用户id得到用户信息关联部门、岗位、角色
|
2022-04-26 18:29:18 +08:00
|
|
|
|
/// </summary>
|
2022-09-11 15:55:08 +08:00
|
|
|
|
/// <param name="id"></param>
|
2022-04-26 18:29:18 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet]
|
2022-09-11 02:39:33 +08:00
|
|
|
|
[Route("{id}")]
|
2022-09-11 15:55:08 +08:00
|
|
|
|
public override async Task<Result> GetById([FromRoute] long id)
|
2022-04-26 18:29:18 +08:00
|
|
|
|
{
|
2022-09-11 02:39:33 +08:00
|
|
|
|
return Result.Success().SetData(await _iUserService.GetInfoById(id));
|
2022-04-26 01:31:14 +08:00
|
|
|
|
}
|
2022-09-11 12:39:22 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新用户信息
|
|
|
|
|
|
/// </summary>
|
2022-09-11 15:55:08 +08:00
|
|
|
|
/// <param name="userDto"></param>
|
2022-09-11 12:39:22 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
2022-09-11 15:55:08 +08:00
|
|
|
|
public async Task<Result> Update(UserInfoDto userDto)
|
2022-09-11 12:39:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
return Result.Success().SetStatus(await _iUserService.UpdateInfo(userDto));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-14 20:35:45 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新个人中心信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="userDto"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
public async Task<Result> UpdateProfile(UserInfoDto userDto)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-11 12:39:22 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加用户
|
|
|
|
|
|
/// </summary>
|
2022-09-11 15:55:08 +08:00
|
|
|
|
/// <param name="userDto"></param>
|
2022-09-11 12:39:22 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
2022-09-11 15:55:08 +08:00
|
|
|
|
public async Task<Result> Add(UserInfoDto userDto)
|
2022-09-11 12:39:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
return Result.Success().SetStatus(await _iUserService.AddInfo(userDto));
|
|
|
|
|
|
}
|
2022-09-11 13:16:24 +08:00
|
|
|
|
|
2022-09-11 15:55:08 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重置密码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2022-09-11 13:16:24 +08:00
|
|
|
|
[HttpPut]
|
|
|
|
|
|
public async Task<Result> RestPassword(UserEntity user)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Result.Success().SetStatus(await _iUserService.RestPassword(user.Id, user.Password));
|
|
|
|
|
|
}
|
2021-10-11 21:50:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|