第八节:OA权限管理系统(Queryable动态扩展)

using log4net;
using OYW.OA.DTO;
using OYW.OA.DTO.People;
using OYW.OA.EFRepositories;
using System;
using System.Collections.Generic;
using System.Text;
using Mapster;
using OYW.OA.Domain.People;
using System.Linq;
using System.Linq.Dynamic.Core;
using OYW.OA.Infrastructure.User;
using OYW.OA.ApplicationInterface.People;

namespace OYW.OA.Application.People
{

    public class UserService : IUserService
    {
        private readonly OAEntity db;
        public UserService(OAEntity db)
        {
            this.db = db;
        }

        public void Save(ORG_UserLogonDTO logon, OAUser oAUser)
        {
            var userLogon = logon.Adapt<ORG_UserLogon>();
            userLogon.UserID = oAUser.ID;
            db.ORG_UserLogon.Add(userLogon);
            db.SaveChanges();
        }


        public ResponseResult<ORG_UserLogonDTO> GetLogonList(int page, int rows, string sort, string order)
        {
            var response = new ResponseResult<ORG_UserLogonDTO> { };
            TypeAdapterConfig typeAdapterConfig = new TypeAdapterConfig();
            typeAdapterConfig.NewConfig<ORG_UserLogon, ORG_UserLogonDTO>().Ignore(p => p.IP);
            response.rows = db.ORG_UserLogon.OrderBy($"{sort} {order}").Skip((page - 1) * rows).Take(rows).Adapt<List<ORG_UserLogonDTO>>(typeAdapterConfig);
            response.total = db.ORG_UserLogon.Count();
            return response;
        }
    }
}
OrderBy($"{sort} {order}").Skip((page - 1) * rows).Take(rows).Adapt<List<ORG_UserLogonDTO>>(typeAdapterConfig);
            response.total = db.ORG_UserLogon.Count();
            return response;
        }
    }
}
发布了128 篇原创文章 · 获赞 18 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/xiaoxionglove/article/details/80872193