OL.FrameCore.Application/Role/RoleService.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Transactions;
using Microsoft.EntityFrameworkCore;
using OL.FrameCore.Application.Module;
using OL.FrameCore.Application.Module.Enum;
using OL.FrameCore.Application.Role.Dto;
using OL.FrameCore.Domain.Entity;
//using OL.FrameCore.Domain.IRepository;
using OL.FrameCore.Infrastructure.UnitOfWork;
using OL.FrameCore.Infrastructure.Utility;
using OL.FrameCore.Repository.EF;

namespace OL.FrameCore.Application.Role
{
    public class RoleService :  IRoleService
    {
        IUnitOfWork _unitOfwork;
        IModuleService _moduleService;
        public RoleService(IUnitOfWork unitOfwork, IModuleService moduleService)
        {
            _unitOfwork = unitOfwork;
            _moduleService = moduleService;
        }

        //public List<RoleDto> GetRoleList(int roleId, string roleName)
        //{
        //    Expression<Func<SysRole, bool>> predicate = p =>
        //    (roleId <= 0 ? true : p.Id == roleId)
        //    && (string.IsNullOrEmpty(roleName) ? true : p.RoleName.Contains(roleName));

        //    //var repositoryRole = _unitOfwork.GetRepository<SysRole>();
        //    //var query = repositoryRole.TableNoTracking.Where(predicate).AsQueryable();
        //    //return repositoryRole.PagingAsync<GetDeptListModel>(query, request.PageIndex, request.PageSize).Result;
        //}
        public PageData<GeRoleListResponse> GetRoleList(GetRoleListRequest request)
        {
            Expression<Func<SysRole, bool>> predicate = p =>
            (request.RoleId.HasValue== false ? true : p.Id == request.RoleId)
            && (string.IsNullOrEmpty(request.RoleName) ? true : p.RoleName.Contains(request.RoleName))
            && p.IsDelete == false;

            var repositoryRole = _unitOfwork.GetRepository<SysRole>();
            var query = repositoryRole.TableNoTracking.Where(predicate).Select(p => new GeRoleListResponse
            {
                Id = p.Id,
                RoleName = p.RoleName,
                Remark = p.Remark,
                CreateTime = p.CreateTime
            });
            return repositoryRole.PagingAsync<GeRoleListResponse>(query, request.PageIndex, request.PageSize).Result;
        }
        /// <summary>
        /// 获取空角色,用于新建角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
后面还有 246 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。