StaffDAL.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.UniversityManage.TeacherManage;
  8. using EMIS.ViewModel.SystemManage.UserManage;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.UniversityManage.TeacherManage
  11. {
  12. public class StaffDAL
  13. {
  14. public StaffRepository staffRepository { get; set; }
  15. public StaffProfileRepository staffProfileRepository { get; set; }
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public DepartmentRepository DepartmentRepository { get; set; }
  18. public UserRepository UserRepository { get; set; }
  19. public RoleRepository RoleRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public ParameterRepository ParameterRepository { get; set; }
  22. /// <summary>
  23. /// 查询教师信息StaffView(根据教师信息)
  24. /// </summary>
  25. /// <param name="exp"></param>
  26. /// <returns></returns>
  27. public IQueryable<StaffView> GetStaffViewQueryable(Expression<Func<CF_Staff, bool>> exp)
  28. {
  29. var query = from sf in staffRepository.GetList(exp)
  30. join pr in staffProfileRepository.Entities
  31. on sf.UserID equals pr.UserID into temppr
  32. from sfpr in temppr.DefaultIfEmpty()
  33. join col in CollegeRepository.Entities
  34. on sf.CollegeID equals col.CollegeID into tempcol
  35. from sfcol in tempcol.DefaultIfEmpty()
  36. join dep in DepartmentRepository.Entities
  37. on sf.DepartmentID equals dep.DepartmentID into tempdep
  38. from sfdep in tempdep.DefaultIfEmpty()
  39. join us in UserRepository.Entities
  40. on sf.UserID equals us.UserID
  41. select new StaffView
  42. {
  43. UserID = sf.UserID,
  44. StaffCode = us.LoginID,
  45. Name = us.Name,
  46. UsedName = sfpr.UsedName,
  47. CampusID = sfcol.CampusID,
  48. CampusCode = sfcol.CF_Campus.No,
  49. CampusName = sfcol.CF_Campus.Name,
  50. CollegeID = sf.CollegeID,
  51. CollegeNo = sfcol.No,
  52. CollegeName = sfcol.Name,
  53. DepartmentID = sf.DepartmentID,
  54. DepartmentCode = sfdep.No,
  55. DepartmentName = sfdep.Name,
  56. Nationality = sfpr.Nationality,
  57. Place = sfpr.Place,
  58. SexID = sf.SexID,
  59. BirthDate = sf.BirthDate,
  60. NationID = sf.NationID,
  61. PoliticsID = sf.PoliticsID,
  62. CertificatesType = sf.CertificatesType,
  63. CertificatesNum = sf.CertificatesNum,
  64. TeacherTypeID = sf.TeacherTypeID,
  65. IncumbencyState = sf.IncumbencyState,
  66. SituationID = sf.SituationID,
  67. TitleID = sf.TitleID,
  68. LiteracyLevelID = sf.LiteracyLevelID,
  69. LearnPositionID = sf.LearnPositionID,
  70. IsDualTeacher = sf.IsDualTeacher ?? false,
  71. PaymentLevelID = sf.PaymentLevelID,
  72. WorkDate = sf.WorkDate,
  73. ComeSchoolDate = sf.ComeSchoolDate,
  74. Email = sfpr.Email,
  75. ZIPCode = sfpr.ZIPCode,
  76. WeChatNum = sfpr.WeChatNum,
  77. QQ = sfpr.QQ,
  78. Telephone = sfpr.Telephone,
  79. OfficeTelephone = sfpr.OfficeTelephone,
  80. HousePhone = sfpr.HousePhone,
  81. Mobile = sfpr.Mobile,
  82. Speciality = sfpr.Speciality,
  83. HealthStateID = sfpr.HealthStateID,
  84. ReligionID = sfpr.ReligionID,
  85. Account = sfpr.Account,
  86. Residence = sfpr.Residence,
  87. HomeAddress = sfpr.HomeAddress,
  88. Address = sfpr.Address,
  89. NowAddress = sfpr.NowAddress,
  90. PhotoUrl = sf.PhotoUrl,
  91. PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
  92. Profile = sf.Profile,
  93. RoleCount = us.Sys_Role.Count() == null ? 0 : us.Sys_Role.Count(),
  94. AccountStatus = us.RecordStatus,
  95. Remark = sf.Remark,
  96. RecordStatus = sf.RecordStatus,
  97. CreateUserID = sf.CreateUserID,
  98. CreateTime = sf.CreateTime,
  99. ModifyUserID = sf.ModifyUserID,
  100. ModifyTime = sf.ModifyTime
  101. };
  102. return query;
  103. }
  104. /// <summary>
  105. /// 查询教师信息CF_Staff(根据用户信息)
  106. /// </summary>
  107. /// <param name="expUser"></param>
  108. /// <returns></returns>
  109. public IQueryable<CF_Staff> GetStaffQueryable(Expression<Func<Sys_User, bool>> expUser)
  110. {
  111. var query = from us in UserRepository.GetList(expUser)
  112. join sf in staffRepository.Entities
  113. on us.UserID equals sf.UserID
  114. select sf;
  115. return query;
  116. }
  117. /// <summary>
  118. /// 查询教师对应的校区信息CF_Campus
  119. /// </summary>
  120. /// <param name="exp"></param>
  121. /// <returns></returns>
  122. public IQueryable<CF_Campus> GetUserInChargeCampus(Expression<Func<CF_Staff, bool>> exp)
  123. {
  124. var query = from sf in staffRepository.GetList(exp)
  125. from smc in sf.CF_StaffManageCampus
  126. select smc.CF_Campus;
  127. return query;
  128. }
  129. /// <summary>
  130. /// 查询教师对应的院系所信息CF_College
  131. /// </summary>
  132. /// <param name="exp"></param>
  133. /// <returns></returns>
  134. public IQueryable<CF_College> GetUserInChargeCollege(Expression<Func<CF_Staff, bool>> exp)
  135. {
  136. var query = from sf in staffRepository.GetList(exp)
  137. from smc in sf.CF_StaffManageCollege
  138. select smc.CF_College;
  139. return query;
  140. }
  141. /// <summary>
  142. /// 查询教师对应的教研室信息CF_Department
  143. /// </summary>
  144. /// <param name="exp"></param>
  145. /// <returns></returns>
  146. public IQueryable<CF_Department> GetUserInChargeDepartment(Expression<Func<CF_Staff, bool>> exp)
  147. {
  148. var query = from sf in staffRepository.GetList(exp)
  149. from smd in sf.CF_StaffManageDepartment
  150. select smd.CF_Department;
  151. return query;
  152. }
  153. /// <summary>
  154. /// 查询教师对应的角色信息UserView
  155. /// </summary>
  156. /// <param name="exp"></param>
  157. /// <returns></returns>
  158. public IQueryable<UserView> GetStaffRoleViewQueryable(Expression<Func<CF_Staff, bool>> exp)
  159. {
  160. var query = from sf in staffRepository.GetList(exp)
  161. join us in UserRepository.Entities
  162. on sf.UserID equals us.UserID
  163. from rl in us.Sys_Role
  164. select new UserView
  165. {
  166. UserID = sf.UserID,
  167. LoginID = us.LoginID,
  168. Name = us.Name,
  169. SexID = sf.SexID,
  170. BirthDate = sf.BirthDate,
  171. CampusID = sf.CF_College.CampusID,
  172. CampusCode = sf.CF_College.CF_Campus.No,
  173. CampusName = sf.CF_College.CF_Campus.Name,
  174. CollegeID = sf.CollegeID,
  175. CollegeCode = sf.CF_College.No,
  176. CollegeName = sf.CF_College.Name,
  177. DepartmentID = sf.DepartmentID,
  178. DepartmentCode = sf.CF_Department.No,
  179. DepartmentName = sf.CF_Department.Name,
  180. RoleID = rl.RoleID,
  181. RoleOrderNo = rl.OrderNo,
  182. RoleName = rl.RoleName,
  183. TypeID = rl.TypeID,
  184. DataRange = rl.DefaultDataRange,
  185. RoleStatus = rl.RecordStatus,
  186. Remark = sf.Remark,
  187. RecordStatus = us.RecordStatus,
  188. CreateUserID = us.CreateUserID,
  189. CreateTime = us.CreateTime,
  190. ModifyUserID = us.ModifyUserID,
  191. ModifyTime = us.ModifyTime
  192. };
  193. return query;
  194. }
  195. }
  196. }