去掉多余代码

This commit is contained in:
pangwenpeng 2024-05-29 09:47:00 +08:00
parent 0541f5d08d
commit 0f9ab916fa
2 changed files with 8 additions and 27 deletions

View File

@ -4,7 +4,6 @@ using langguanApi.Model.Dto.SystemConfigurationDto;
using langguanApi.Model; using langguanApi.Model;
using langguanApi.Model.Entity; using langguanApi.Model.Entity;
using langguanApi.Model.SystemConfigurationEntity; using langguanApi.Model.SystemConfigurationEntity;
using StackExchange.Redis;
using Mapster; using Mapster;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using System.Linq.Expressions; using System.Linq.Expressions;
@ -14,6 +13,9 @@ using System.Collections.Generic;
namespace langguanApi.Service namespace langguanApi.Service
{ {
/// <summary>
/// 校色服务
/// </summary>
[ServiceInjection(InjectionType.Transient)] [ServiceInjection(InjectionType.Transient)]
public class RoleService : BaseService<Role> public class RoleService : BaseService<Role>
{ {
@ -105,8 +107,8 @@ namespace langguanApi.Service
/// <returns></returns> /// <returns></returns>
public async Task<bool> Exist(RoleDto input) public async Task<bool> Exist(RoleDto input)
{ {
var entity = input.Adapt<UserRole>(); var entity = input.Adapt<Role>();
Expression<Func<UserRole, bool>> exp = filter => filter.RoleName == entity.RoleName; Expression<Func<Role, bool>> exp = filter => filter.RoleName == entity.RoleName;
return await base.Exist(exp); return await base.Exist(exp);
} }
/// <summary> /// <summary>
@ -120,7 +122,7 @@ namespace langguanApi.Service
{ {
return new ApiResult { code = 1, msg = $"{input.RoleName}的角色已存在" }; return new ApiResult { code = 1, msg = $"{input.RoleName}的角色已存在" };
} }
var entity = input.Adapt<UserRole>(); var entity = input.Adapt<Role>();
if (entity != null) if (entity != null)
{ {
await base.CreateAsync(entity); await base.CreateAsync(entity);
@ -133,9 +135,9 @@ namespace langguanApi.Service
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="ids"></param>
/// <returns></returns> /// <returns></returns>
public async Task<List<UserRole>> GetRoleListByIds(IEnumerable<string> ids) public async Task<List<Role>> GetRoleListByIds(IEnumerable<string> ids)
{ {
Expression<Func<UserRole, bool>> exp = filter => ids.Contains(filter.Id) && filter.IsDelete == false; Expression<Func<Role, bool>> exp = filter => ids.Contains(filter.Id) && filter.IsDelete == false;
var list = (await base.GetListWithExp(exp)).ToList(); var list = (await base.GetListWithExp(exp)).ToList();
return list; return list;
} }

View File

@ -186,18 +186,6 @@ namespace langguanApi.Service
{ {
exp = filter => filter.Username.Contains(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 #endregion
#region #region
@ -211,17 +199,8 @@ namespace langguanApi.Service
list.Add(new UserListDto list.Add(new UserListDto
{ {
Username = item.Username, Username = item.Username,
Education = item.Education,
Tel = item.Tel,
Email = item.Email, Email = item.Email,
roleName = roleList.FirstOrDefault(s => s.Id == item.roleId)?.RoleName, 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 #endregion