142 lines
4.5 KiB
C#
142 lines
4.5 KiB
C#
|
|
/**************************************************************
|
|
* Filename: UsersController.cs
|
|
* Copyright: .
|
|
*
|
|
* Description: UsersController ClassFile.
|
|
*
|
|
* @author: Dongliang Yi
|
|
* @version 2021/11/8 17:30:53 @Reviser Initial Version
|
|
**************************************************************/
|
|
using IdentityModel;
|
|
using IdentityServer4;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPlatform.API;
|
|
using NPlatform.Attributes;
|
|
using System.Security.Claims;
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
namespace BZPT.IdentityServer.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 用户管理
|
|
/// </summary>
|
|
#if DEBUG
|
|
[AllowAnonymous]
|
|
#endif
|
|
[Route("api/[controller]/[action]")]
|
|
public class UserController : BaseController {
|
|
|
|
private ILogger<UserController> Loger { get; set; }
|
|
//private IUserService _UserSvc { get; set; }
|
|
|
|
//public UserController(ILogger<UserController> loger, IUserService userSvc)
|
|
//{
|
|
// Loger = loger;
|
|
// _UserSvc = userSvc;
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 获取用户列表
|
|
///// </summary>
|
|
///// <param name="whereExp"></param>
|
|
///// <returns></returns>
|
|
//// GET: api/<UserController>
|
|
//[HttpGet]
|
|
//public async Task<INPResult> GetList([FromQuery] QueryExp whereExp)
|
|
//{
|
|
|
|
// // 获取用户的 ID
|
|
// string userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
|
|
// // 获取用户的用户名
|
|
// string userName = User.FindFirstValue(ClaimTypes.Name);
|
|
|
|
// // 获取用户的角色
|
|
// var roles = User.FindAll(ClaimTypes.Role).Select(c => c.Value).ToList();
|
|
|
|
// // 输出用户信息(可根据实际需求调整)
|
|
// var userInfo = new
|
|
// {
|
|
// UserId = userId,
|
|
// UserName = userName,
|
|
// Roles = roles
|
|
// };
|
|
|
|
// //return await _UserSvc.GetListAsync(whereExp);
|
|
//}
|
|
///// <summary>
|
|
///// 获取用户列表分页
|
|
///// </summary>
|
|
///// <param name="whereExp"></param>
|
|
///// <returns></returns>
|
|
//// GET: api/<UserController>
|
|
//[HttpGet]
|
|
//public async Task<INPResult> GetPage([FromQuery] QueryPageExp whereExp) {
|
|
// var users = await _UserSvc.GetPageAsync(whereExp);
|
|
// return users;
|
|
//}
|
|
|
|
//// GET api/<UserController>/5
|
|
//[HttpGet("{id}")]
|
|
//public async Task<INPResult> Get(string id) {
|
|
// var rst = await _UserSvc.GetAsync(id);
|
|
// return rst;
|
|
//}
|
|
|
|
//// GET api/<UserController>/5
|
|
//[HttpGet]
|
|
//public async Task<INPResult> Info() {
|
|
// var userId = User.GetSubjectId();
|
|
// var rst = await _UserSvc.GetAsync(userId);
|
|
// return rst;
|
|
//}
|
|
///// <summary>
|
|
///// 添加用户
|
|
///// </summary>
|
|
///// <param name="user"></param>
|
|
///// <returns></returns>
|
|
//// POST api/<UserController>
|
|
//[HttpPost]
|
|
//public async Task<INPResult> Post([FromBody] UserDto user) {
|
|
// return await _UserSvc.Add(user);
|
|
//}
|
|
///// <summary>
|
|
///// 编辑用户
|
|
///// </summary>
|
|
///// <param name="user"></param>
|
|
///// <returns></returns>
|
|
//// PUT api/<UserController>/5
|
|
//[HttpPut]
|
|
//public async Task<INPResult> Put( [FromBody] UserDto user) {
|
|
// return await _UserSvc.Edit(user);
|
|
//}
|
|
///// <summary>
|
|
///// 删除用户
|
|
///// </summary>
|
|
///// <param name="id"></param>
|
|
///// <returns></returns>
|
|
//// DELETE api/<UserController>/5
|
|
//[HttpDelete("{id}")]
|
|
//public async Task<INPResult> Delete(string id) {
|
|
// return await _UserSvc.Delete(id);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 获取指定部门下所有同事(所有子级部门的)
|
|
///// </summary>
|
|
///// <param name="parent">指定部门</param>
|
|
///// <param name="userid">用户ID</param>
|
|
///// <returns></returns>
|
|
//[HttpGet]
|
|
//public async Task<INPResult> GetAllColleague(string subId)
|
|
//{
|
|
// //return await _UserSvc.GetShopColleague(subId);
|
|
//}
|
|
}
|
|
}
|