123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel.UniversityManage.TeacherManage;
- using EMIS.ViewModel.SystemManage.UserManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.UniversityManage.TeacherManage
- {
- public class StaffDAL
- {
- public StaffRepository staffRepository { get; set; }
- public StaffProfileRepository staffProfileRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DepartmentRepository DepartmentRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public RoleRepository RoleRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public ParameterRepository ParameterRepository { get; set; }
- /// <summary>
- /// 查询教师信息StaffView(根据教师信息)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<StaffView> GetStaffViewQueryable(Expression<Func<CF_Staff, bool>> exp)
- {
- var query = from sf in staffRepository.GetList(exp)
- join pr in staffProfileRepository.Entities
- on sf.UserID equals pr.UserID into temppr
- from sfpr in temppr.DefaultIfEmpty()
- join col in CollegeRepository.Entities
- on sf.CollegeID equals col.CollegeID into tempcol
- from sfcol in tempcol.DefaultIfEmpty()
- join dep in DepartmentRepository.Entities
- on sf.DepartmentID equals dep.DepartmentID into tempdep
- from sfdep in tempdep.DefaultIfEmpty()
- join us in UserRepository.Entities
- on sf.UserID equals us.UserID
- select new StaffView
- {
- UserID = sf.UserID,
- StaffCode = us.LoginID,
- Name = us.Name,
- UsedName = sfpr.UsedName,
- CampusID = sfcol.CampusID,
- CampusCode = sfcol.CF_Campus.No,
- CampusName = sfcol.CF_Campus.Name,
- CollegeID = sf.CollegeID,
- CollegeNo = sfcol.No,
- CollegeName = sfcol.Name,
- DepartmentID = sf.DepartmentID,
- DepartmentCode = sfdep.No,
- DepartmentName = sfdep.Name,
- Nationality = sfpr.Nationality,
- Place = sfpr.Place,
- SexID = sf.SexID,
- BirthDate = sf.BirthDate,
- NationID = sf.NationID,
- PoliticsID = sf.PoliticsID,
- CertificatesType = sf.CertificatesType,
- CertificatesNum = sf.CertificatesNum,
- TeacherTypeID = sf.TeacherTypeID,
- IncumbencyState = sf.IncumbencyState,
- SituationID = sf.SituationID,
- TitleID = sf.TitleID,
- LiteracyLevelID = sf.LiteracyLevelID,
- LearnPositionID = sf.LearnPositionID,
- IsDualTeacher = sf.IsDualTeacher ?? false,
- PaymentLevelID = sf.PaymentLevelID,
- WorkDate = sf.WorkDate,
- ComeSchoolDate = sf.ComeSchoolDate,
- Email = sfpr.Email,
- ZIPCode = sfpr.ZIPCode,
- WeChatNum = sfpr.WeChatNum,
- QQ = sfpr.QQ,
- Telephone = sfpr.Telephone,
- OfficeTelephone = sfpr.OfficeTelephone,
- HousePhone = sfpr.HousePhone,
- Mobile = sfpr.Mobile,
- Speciality = sfpr.Speciality,
- HealthStateID = sfpr.HealthStateID,
- ReligionID = sfpr.ReligionID,
- Account = sfpr.Account,
- Residence = sfpr.Residence,
- HomeAddress = sfpr.HomeAddress,
- Address = sfpr.Address,
- NowAddress = sfpr.NowAddress,
- PhotoUrl = sf.PhotoUrl,
- PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
- Profile = sf.Profile,
- RoleCount = us.Sys_Role.Count() == null ? 0 : us.Sys_Role.Count(),
- AccountStatus = us.RecordStatus,
- Remark = sf.Remark,
- RecordStatus = sf.RecordStatus,
- CreateUserID = sf.CreateUserID,
- CreateTime = sf.CreateTime,
- ModifyUserID = sf.ModifyUserID,
- ModifyTime = sf.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询教师信息CF_Staff(根据用户信息)
- /// </summary>
- /// <param name="expUser"></param>
- /// <returns></returns>
- public IQueryable<CF_Staff> GetStaffQueryable(Expression<Func<Sys_User, bool>> expUser)
- {
- var query = from us in UserRepository.GetList(expUser)
- join sf in staffRepository.Entities
- on us.UserID equals sf.UserID
- select sf;
- return query;
- }
- /// <summary>
- /// 查询教师对应的校区信息CF_Campus
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<CF_Campus> GetUserInChargeCampus(Expression<Func<CF_Staff, bool>> exp)
- {
- var query = from sf in staffRepository.GetList(exp)
- from smc in sf.CF_StaffManageCampus
- select smc.CF_Campus;
- return query;
- }
- /// <summary>
- /// 查询教师对应的院系所信息CF_College
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<CF_College> GetUserInChargeCollege(Expression<Func<CF_Staff, bool>> exp)
- {
- var query = from sf in staffRepository.GetList(exp)
- from smc in sf.CF_StaffManageCollege
- select smc.CF_College;
- return query;
- }
- /// <summary>
- /// 查询教师对应的教研室信息CF_Department
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<CF_Department> GetUserInChargeDepartment(Expression<Func<CF_Staff, bool>> exp)
- {
- var query = from sf in staffRepository.GetList(exp)
- from smd in sf.CF_StaffManageDepartment
- select smd.CF_Department;
- return query;
- }
- /// <summary>
- /// 查询教师对应的角色信息UserView
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<UserView> GetStaffRoleViewQueryable(Expression<Func<CF_Staff, bool>> exp)
- {
- var query = from sf in staffRepository.GetList(exp)
- join us in UserRepository.Entities
- on sf.UserID equals us.UserID
- from rl in us.Sys_Role
- select new UserView
- {
- UserID = sf.UserID,
- LoginID = us.LoginID,
- Name = us.Name,
- SexID = sf.SexID,
- BirthDate = sf.BirthDate,
- CampusID = sf.CF_College.CampusID,
- CampusCode = sf.CF_College.CF_Campus.No,
- CampusName = sf.CF_College.CF_Campus.Name,
- CollegeID = sf.CollegeID,
- CollegeCode = sf.CF_College.No,
- CollegeName = sf.CF_College.Name,
- DepartmentID = sf.DepartmentID,
- DepartmentCode = sf.CF_Department.No,
- DepartmentName = sf.CF_Department.Name,
- RoleID = rl.RoleID,
- RoleOrderNo = rl.OrderNo,
- RoleName = rl.RoleName,
- TypeID = rl.TypeID,
- DataRange = rl.DefaultDataRange,
- RoleStatus = rl.RecordStatus,
- Remark = sf.Remark,
- RecordStatus = us.RecordStatus,
- CreateUserID = us.CreateUserID,
- CreateTime = us.CreateTime,
- ModifyUserID = us.ModifyUserID,
- ModifyTime = us.ModifyTime
- };
- return query;
- }
- }
- }
|