人员管理新增用户和人员列表接口,辅助菜单查询和新增接口(后面会修改),辅角色色查询和新增接口(后面会修改)
This commit is contained in:
		
							parent
							
								
									5e3808fea1
								
							
						
					
					
						commit
						3c257f11c1
					
				| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Controllers
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 菜单控制器
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Route("api/[controller]")]
 | 
			
		||||
    [ApiController]
 | 
			
		||||
    public class MeauController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        private MeauService _meuaService;
 | 
			
		||||
        public MeauController(MeauService meauService)
 | 
			
		||||
        {
 | 
			
		||||
            _meuaService = meauService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取菜单列表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet("GetMenuList")]
 | 
			
		||||
        public async Task<IActionResult> GetMenuList([FromQuery] reqpage input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _meuaService.GetMeauList(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新增菜单
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost("AddMeau")]
 | 
			
		||||
        public async Task<IActionResult> AddMeau([FromBody] MeauDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _meuaService.AddMeau(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Controllers
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 角色
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [Route("api/[controller]")]
 | 
			
		||||
    [ApiController]
 | 
			
		||||
    public class RoleController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        private RoleService _roleService;
 | 
			
		||||
        public RoleController(RoleService roleService)
 | 
			
		||||
        {
 | 
			
		||||
            _roleService = roleService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///新增角色
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost("AddRole")]
 | 
			
		||||
        public async Task<IActionResult> AddRole([FromBody] RoleDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _roleService.AddRole(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto;
 | 
			
		||||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +80,30 @@ namespace langguanApi.Controllers
 | 
			
		|||
 | 
			
		||||
        #region  用户管理相关接口
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///新增用户
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost("AddUser")]
 | 
			
		||||
        public async Task<IActionResult> AddUser([FromBody] UserDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _userService.AddUser(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        //获取用户列表
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取用户列表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet("GetUserList")]
 | 
			
		||||
        public async Task<IActionResult> GetUserList([FromQuery] UserQueryDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _userService.GetUserList(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,57 +0,0 @@
 | 
			
		|||
namespace langguanApi.Model.Dto.SystemConfiguration
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 用于用户管理的Dto
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UserDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户名
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Username { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  角色id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int roleId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 邮箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Email { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 学历
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Education { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 手机号
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Tel { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 性别 0表示男   1表示女
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte Sex { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 毕业院校
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string University { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 出生日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Brithday { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 籍贯
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Native { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 居住地
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Address { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员  0否  1是
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsAdmin { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否删除  0否  1是   
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsDel { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
namespace langguanApi.Model.Dto.SystemConfigurationDto
 | 
			
		||||
{
 | 
			
		||||
    public class MeauDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 父菜单ID 默认首页为1级,有组织为2级,无组织为2级,下面的子菜单为3级
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ParentId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 菜单编码
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string MenuCode { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 菜单名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string MenuName { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 可空,菜单跳转路径
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Url { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 排序
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Sort { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否激活
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsActive { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
namespace langguanApi.Model.Dto.SystemConfigurationDto
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 角色DTO
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class RoleDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 角色名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string RoleName { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 多个菜单用,隔开
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Meaus { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsAdmin { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 角色描述
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Description { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,148 @@
 | 
			
		|||
using MongoDB.Bson.Serialization.Attributes;
 | 
			
		||||
using MongoDB.Bson;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Model.Dto.SystemConfigurationDto
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 用于用户管理的Dto
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UserDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///用户ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [BsonId]
 | 
			
		||||
        [BsonRepresentation(BsonType.ObjectId)]
 | 
			
		||||
        public string Id { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户名
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Username { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  角色id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string roleId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 邮箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Email { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 学历
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Education { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 手机号
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Tel { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 性别 0表示男   1表示女
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte Sex { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 毕业院校
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string University { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 出生日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string BrithdayDateTime { get; set; }
 | 
			
		||||
        public DateTime? Brithday { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 入职日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string HiredateDateTime { get; set; } = DateTime.Now.ToString();
 | 
			
		||||
        public DateTime? Hiredate { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 籍贯
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Native { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 居住地
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Address { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员  0否  1是
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsAdmin { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否删除  0否  1是   
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsDel { get; set; }
 | 
			
		||||
        //是否启用  0表示未启用  1表示启用
 | 
			
		||||
        public byte IsEnable { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///根据用户条件查询
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UserQueryDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户名
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Username { get; set; } = "";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 手机号
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Tel { get; set; } = "";
 | 
			
		||||
        //入职开始时间
 | 
			
		||||
        public string HiredateStart { get; set; } = "";
 | 
			
		||||
        //入职结束时间
 | 
			
		||||
        public string HiredateEnd { get; set; } = "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 用户列表展示
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UserListDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户名
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Username { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 学历
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Education { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 邮箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Email { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  角色名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string roleName{ get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 性别 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Sex { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 毕业院校
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string University { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 联系方式
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Tel { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 出生日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Brithday { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 籍贯
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Native { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 居住地
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Address { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 入职日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string  Hiredate { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员  0否  1是
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string IsAdmin { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
namespace langguanApi.Model.Entity
 | 
			
		||||
using MongoDB.Bson.Serialization.Attributes;
 | 
			
		||||
using MongoDB.Bson;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Model.Entity
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 用户实体
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +19,8 @@
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        ///  角色id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int roleId { get; set; }
 | 
			
		||||
        [BsonRepresentation(BsonType.ObjectId)]
 | 
			
		||||
        public string roleId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 邮箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +32,7 @@
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 手机号
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Tel { get; set; }
 | 
			
		||||
        public string Tel { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 性别 0表示男   1表示女
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +44,7 @@
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 出生日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Brithday { get; set; }
 | 
			
		||||
        public DateTime? Brithday { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 籍贯
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +54,16 @@
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public string Address { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 入职日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateTime? Hiredate { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员  0否  1是
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsAdmin { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否启用  0禁用  1启用
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public byte IsEnable { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
namespace langguanApi.Model
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Model
 | 
			
		||||
{
 | 
			
		||||
    public class ReqPaing
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
namespace langguanApi.Model.SystemConfigurationEntity
 | 
			
		||||
{
 | 
			
		||||
   //菜单实体类
 | 
			
		||||
    public class Meau : BaseModel
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 父菜单ID 默认首页为1级,有组织为2级,无组织为2级,下面的子菜单为3级
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string  ParentId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 菜单编码
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string MenuCode { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 菜单名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string MenuName { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 可空,菜单跳转路径
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Url { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 排序
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Sort { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否激活
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsActive { get; set; }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
namespace langguanApi.Model.SystemConfigurationEntity
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 角色实体类
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UserRole : BaseModel
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 角色名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string RoleName { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 多个菜单用,隔开
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Meaus { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否管理员
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool IsAdmin { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 角色描述
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Description { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,73 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Model.SystemConfigurationEntity;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///  菜单服务
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [ServiceInjection(InjectionType.Transient)]
 | 
			
		||||
    public class MeauService : BaseService<Meau>
 | 
			
		||||
    {
 | 
			
		||||
        public MeauService(IConfiguration config) : base(config, nameof(Meau))
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取菜单列表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<object> GetMeauList(reqpage input)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<Meau, bool>> exp = filter =>filter.IsDelete == false;
 | 
			
		||||
            if (!string.IsNullOrEmpty(input.key))
 | 
			
		||||
            {
 | 
			
		||||
                exp=filter => filter.MenuName.Contains(input.key);
 | 
			
		||||
            }
 | 
			
		||||
            return await base.GetPager(new ReqPaing()
 | 
			
		||||
            {
 | 
			
		||||
                pageSize = input.pageSize,
 | 
			
		||||
                current = input.current
 | 
			
		||||
            }, exp);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新加
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> AddMeau(MeauDto input)
 | 
			
		||||
        {
 | 
			
		||||
            if (await Exist(input))
 | 
			
		||||
            {
 | 
			
		||||
                return new ApiResult { code = 1, msg = $"{input.MenuName}的菜单已存在" };
 | 
			
		||||
            }
 | 
			
		||||
            var entity = input.Adapt<Meau>();
 | 
			
		||||
            if (entity != null)
 | 
			
		||||
            {
 | 
			
		||||
                await base.CreateAsync(entity);
 | 
			
		||||
                return new ApiResult { code = 0, msg = "" };
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult { code = 1, msg = "菜单添加失败" }; ;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 是否存在
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<bool> Exist(MeauDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var entity = input.Adapt<MeauDto>();
 | 
			
		||||
            Expression<Func<Meau, bool>> exp = filter => filter.MenuName == entity.MenuName;
 | 
			
		||||
            return await base.Exist(exp);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,63 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Entity;
 | 
			
		||||
using langguanApi.Model.SystemConfigurationEntity;
 | 
			
		||||
using StackExchange.Redis;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
    [ServiceInjection(InjectionType.Transient)]
 | 
			
		||||
    public class RoleService : BaseService<Model.SystemConfigurationEntity.UserRole>
 | 
			
		||||
    {
 | 
			
		||||
        public RoleService(IConfiguration config) : base(config, nameof(Role))
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户是否存在
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<bool> Exist(RoleDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var entity = input.Adapt<UserRole>();
 | 
			
		||||
            Expression<Func<UserRole, bool>> exp = filter => filter.RoleName == entity.RoleName;
 | 
			
		||||
            return await base.Exist(exp);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新加角色
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> AddRole(RoleDto input)
 | 
			
		||||
        {
 | 
			
		||||
            if (await Exist(input))
 | 
			
		||||
            {
 | 
			
		||||
                return new ApiResult { code = 1, msg = $"{input.RoleName}的角色已存在" };
 | 
			
		||||
            }
 | 
			
		||||
            var entity = input.Adapt<UserRole>();
 | 
			
		||||
            if (entity != null)
 | 
			
		||||
            {
 | 
			
		||||
                await base.CreateAsync(entity);
 | 
			
		||||
                return new ApiResult { code = 0, msg = "" };
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult { code = 1, msg = "菜单添加失败" }; ;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据Id,获取多个校色信息
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="ids"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<List<UserRole>> GetRoleListByIds(IEnumerable<string> ids)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<UserRole, bool>> exp = filter => ids.Contains(filter.Id) && filter.IsDelete == false;
 | 
			
		||||
            var list = (await base.GetListWithExp(exp)).ToList();
 | 
			
		||||
            return list;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -2,8 +2,13 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto;
 | 
			
		||||
using langguanApi.Model.Dto.SystemConfigurationDto;
 | 
			
		||||
using langguanApi.Model.Entity;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc.Filters;
 | 
			
		||||
using MongoDB.Bson.IO;
 | 
			
		||||
using MongoDB.Driver.Linq;
 | 
			
		||||
using Org.BouncyCastle.Asn1.Ocsp;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
| 
						 | 
				
			
			@ -11,8 +16,12 @@ namespace langguanApi.Service
 | 
			
		|||
    [ServiceInjection(InjectionType.Transient)]
 | 
			
		||||
    public class UserService : BaseService<UserEntity>
 | 
			
		||||
    {
 | 
			
		||||
        public UserService(IConfiguration config) : base(config, nameof(UserEntity).Replace("Entity", ""))
 | 
			
		||||
        private ILogger<UserService> _logger;
 | 
			
		||||
        private RoleService _roleService;
 | 
			
		||||
        public UserService(IConfiguration config, ILogger<UserService> logger, RoleService roleService) : base(config, nameof(UserEntity).Replace("Entity", ""))
 | 
			
		||||
        {
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _roleService = roleService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 登录
 | 
			
		||||
| 
						 | 
				
			
			@ -86,5 +95,152 @@ namespace langguanApi.Service
 | 
			
		|||
        {
 | 
			
		||||
            await base.RemoveAsync(id);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region 用户管理
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户是否存在
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<bool> Exist(UserDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var entity = input.Adapt<UserEntity>();
 | 
			
		||||
            Expression<Func<UserEntity, bool>> exp = filter => filter.Id == entity.Id;
 | 
			
		||||
            return await base.Exist(exp);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///新增用户
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input">新增用户dto</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> AddUser(UserDto input)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                #region 校验参数
 | 
			
		||||
                if (string.IsNullOrEmpty(input.Username))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "用户名非空" };
 | 
			
		||||
                }
 | 
			
		||||
                if (string.IsNullOrEmpty(input.Tel))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "手机号非空" };
 | 
			
		||||
                }
 | 
			
		||||
                if (string.IsNullOrEmpty(input.Email))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "邮箱非空" };
 | 
			
		||||
                }
 | 
			
		||||
                if (string.IsNullOrEmpty(input.roleId))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "角色不能为空" };
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 组织数据
 | 
			
		||||
               
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.BrithdayDateTime))
 | 
			
		||||
                {
 | 
			
		||||
                    input.Brithday = Convert.ToDateTime(input.BrithdayDateTime);
 | 
			
		||||
                }
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.HiredateDateTime))
 | 
			
		||||
                {
 | 
			
		||||
                    input.Hiredate = Convert.ToDateTime(input.HiredateDateTime);
 | 
			
		||||
                }
 | 
			
		||||
                input.IsEnable = 1;
 | 
			
		||||
                var entity = input.Adapt<UserEntity>();
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 保存数据
 | 
			
		||||
                if (entity != null && string.IsNullOrEmpty(entity.Id))
 | 
			
		||||
                {
 | 
			
		||||
                    await base.CreateAsync(entity);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                #endregion
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"新增用户出现异常,请求参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
 | 
			
		||||
                                 $"请求接口:'api/User/AddUser'," +
 | 
			
		||||
                                 $"异常信息:{ex.Message}," +
 | 
			
		||||
                                 $"异常位置:{ex.StackTrace}"
 | 
			
		||||
                                 );
 | 
			
		||||
                return new ApiResult { code = 1, msg = "保存用户信息失败" };
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInformation($"新增用户参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult { code = 0, msg = "保存用户信息成功" };
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> GetUserList(UserQueryDto input)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                #region 组织查询条件
 | 
			
		||||
                Expression<Func<UserEntity, bool>> exp = filter => filter.IsDelete == false;
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.Username))
 | 
			
		||||
                {
 | 
			
		||||
                    exp = filter => filter.Username.Contains(input.Username);
 | 
			
		||||
                }
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.Tel))
 | 
			
		||||
                {
 | 
			
		||||
                    exp = filter => filter.Tel.Contains(input.Tel);
 | 
			
		||||
                }
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.HiredateStart))
 | 
			
		||||
                {
 | 
			
		||||
                    exp = filter => filter.Hiredate.Value >= DateTime.Parse(input.HiredateStart);
 | 
			
		||||
                }
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.HiredateEnd))
 | 
			
		||||
                {
 | 
			
		||||
                    exp = filter => filter.Hiredate.Value <= DateTime.Parse(input.HiredateEnd);
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
 | 
			
		||||
                #region 获取数据
 | 
			
		||||
                var result = await base.GetListWithExp(exp);//获取人员信息
 | 
			
		||||
                var roleList = await _roleService.GetRoleListByIds(result.Select(s => s.roleId).ToList());
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 组装返回数据
 | 
			
		||||
                List<UserListDto> list = new List<UserListDto>();
 | 
			
		||||
                foreach (var item in result)
 | 
			
		||||
                {
 | 
			
		||||
                    list.Add(new UserListDto
 | 
			
		||||
                    {
 | 
			
		||||
                        Username = item.Username,
 | 
			
		||||
                        Education = item.Education,
 | 
			
		||||
                        Tel = item.Tel,
 | 
			
		||||
                        Email = item.Email,
 | 
			
		||||
                        roleName = roleList.FirstOrDefault(s => s.Id == item.roleId)?.RoleName,
 | 
			
		||||
                        Sex = item.Sex == 0 ? "男" : "女",
 | 
			
		||||
                        Address = item.Address,
 | 
			
		||||
                        IsAdmin = item.IsAdmin == 0 ? "否" : "是",
 | 
			
		||||
                        Native = item.Native,
 | 
			
		||||
                        University = item.University,
 | 
			
		||||
                        Hiredate = item.Hiredate.HasValue == true ? item.Hiredate.Value.ToString("yyyy-MM-dd") : "",
 | 
			
		||||
                        Brithday = item.Brithday.HasValue == true ? item.Brithday.Value.ToString("yyyy-MM-dd") : "",
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                return new ApiResult { code = 0, data = list };
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"获取用户列表出现异常,请求参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
 | 
			
		||||
                                 $"请求接口:'api/User/GetUserList'," +
 | 
			
		||||
                                 $"异常信息:{ex.Message}," +
 | 
			
		||||
                                 $"异常位置:{ex.StackTrace}"
 | 
			
		||||
                                 );
 | 
			
		||||
                return new ApiResult { code = 1, msg = "获取用户列表失败" };
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInformation($"获取用户列表参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue