diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs index fd01dcb5..62b784a2 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_StudyRecordController.cs @@ -39,8 +39,6 @@ public class Ghre_StudyRecordController : BaseController /// 获取课程 @@ -54,4 +52,17 @@ public class Ghre_StudyRecordController : BaseController + /// 加入学习 + /// + /// + /// + [HttpPost, Route("Join/{id}")] + public async Task Join(long id) + { + return await _service.Join(id); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index a003bb73..3266a6f6 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -962,6 +962,13 @@ + + + 加入学习 + + + + 必选修规则(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs index 1f4e925d..d127e8dd 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_StudyRecordServices.cs @@ -16,5 +16,8 @@ namespace Tiobon.Core.IServices Task> QueryESS(QueryBody filter, string condition, bool? IsEnable = true); Task> QueryCourse(QueryBody body, long id); + + + Task Join(long courseId); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 6a87db6d..f4a7ce32 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -21,6 +21,7 @@ using Tiobon.Core.Model.Models; using System.Reflection; using System.Collections; using Microsoft.IdentityModel.Tokens; +using System.Collections.Generic; namespace Tiobon.Core.Services.BASE; @@ -1383,6 +1384,16 @@ public class BaseServices : IBaseServ return queryString; } + public int? GetStaffId() + { + int? StaffId = null; + string sql = $"SELECT UserStaffID FROM Ghrs_User WHERE UserId='{App.User.ID}'"; + string StaffId1 = Convert.ToString(DbAccess.ExecuteScalar(sql)); + if (!StaffId1.IsNull()) + StaffId = Convert.ToInt32(StaffId1); + return StaffId; + } + //public int GetTotalCount(string sqlSelect) //{ // string sql = string.Empty; diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 1acc0fc0..97b7d93a 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -1522,12 +1522,9 @@ public class Ghre_ExamServices : BaseServices>> QueryRuleStaff(long examId) { - var exam = await base.QuerySingle(examId); var Ids = await Db.Queryable() - .Where(x => x.ExamId == null) - .WhereIF(exam.CourseId != null, x => x.CourseId == exam.CourseId) - .WhereIF(exam.CourseSceneId != null, x => x.CourseSceneId == exam.CourseSceneId) + .Where(x => x.ExamId == null && (x.CourseId == examId || x.CourseSceneId == examId)) .Select(x => x.StaffId).Distinct().ToListAsync(); string sql = @"SELECT A.StaffID, A.StaffName, diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index 63f871ef..6eef0525 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -299,8 +299,7 @@ namespace Tiobon.Core.Services } - #endregion - + #endregion #region 获取课程 /// @@ -388,7 +387,7 @@ namespace Tiobon.Core.Services course.CourseWareList = new List(); course.CourseTeacherList = new List(); var courses = await Db.Queryable().Where(x => x.CourseSceneId == course.CourseSceneId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync(); - + for (int i = 0; i < courses.Count; i++) { var course1 = courses[i]; @@ -450,5 +449,35 @@ namespace Tiobon.Core.Services } #endregion + + + #region 获取ESS查询条件 + public async Task Join(long courseId) + { + var staffId = GetStaffId(); + if (!await base.AnyAsync(x => x.CourseId == courseId && x.StaffId == staffId)) + { + var course = await Db.Queryable().Where(x => x.Id == courseId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).FirstAsync(); + if (course.IsNull()) + return ServiceResult.OprateFailed("无效的课程!"); + + DateTime courseTime = Db.GetDate(); + var snap = await Db.Queryable().FirstAsync(x => x.CourseId == courseId); + await base.Add(new InsertGhre_StudyRecordInput + { + StaffId = staffId, + CourseSnapId = snap?.Id, + CourseId = courseId, + JoinTime = courseTime, + CourseBeginTime = courseTime.Date, + CourseEndTime = courseTime.Date.AddMonths(snap?.ValidityPeriod ?? 1), + CourseType = "Elective", + CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, + StudyStatus = Consts.DIC_STUDY_RECORD_STUDY_STATUS_NO_JOIN + }); + } + return ServiceResult.OprateSuccess("加入成功!"); + } + #endregion } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 76d37dbe..3266a6f6 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -745,6 +745,13 @@ insert + + + 获取考试关联人员 + + id + + 考试通知记录(Controller) @@ -955,6 +962,13 @@ + + + 加入学习 + + + + 必选修规则(Controller)