Commit 58430441 authored by 黄奎's avatar 黄奎

课程导入增加单词导入,并替换成批量导入课程

parent 9e75dc21
......@@ -86,6 +86,11 @@ namespace Edu.Model.ViewModel.Course
/// 当前课时(累加计算)
/// </summary>
public double CurrentHours { get; set; }
/// <summary>
/// 章节单词
/// </summary>
public List<RB_Course_Words_Extend> WordsList { get; set; }
}
}
......@@ -33,5 +33,10 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public string CourseName { get; set; }
/// <summary>
/// 创建时间查询
/// </summary>
public string QCreateTime { get; set; }
}
}
This diff is collapsed.
......@@ -23,11 +23,7 @@ namespace Edu.Repository.Course
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_course_chapter
WHERE 1=1
");
builder.AppendFormat(@" SELECT * FROM rb_course_chapter WHERE 1=1 ");
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.Status), EnumHelper.ToInt(DateStateEnum.Normal));
if (query != null)
{
......@@ -43,11 +39,33 @@ namespace Edu.Repository.Course
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Course_Chapter_ViewModel.CourseId), query.CourseIds);
}
if (!string.IsNullOrEmpty(query.QCreateTime))
{
builder.AppendFormat(" AND {0}>='{1}' ", nameof(RB_Course_Chapter_ViewModel.CreateTime), query.QCreateTime);
}
}
//builder.AppendFormat(" ORDER BY {0} ",nameof(RB_Course_Chapter_ViewModel.ChapterNo));
return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 批量插入
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public bool SetBatchInsertCourseChapterRepository(List<RB_Course_Chapter_ViewModel> param)
{
StringBuilder builder = new StringBuilder();
builder.Append("INSERT INTO rb_course_chapter (CourseId, ChapterNo, ChapterName,ChapterContent,ParentId,OpenStatus,Progress,CreateBy,CreateTime,UpdateBy,UpdateTime,Status,School_Id,Group_Id,SortNum,StudyHours,Objectives,Requirement,CourseRate,StudyMinutes,CurrentHours) VALUES");
param.ForEach(x =>
{
var newChapterNo = x.ChapterNo.Replace(".", "");
double.TryParse(newChapterNo, out double SortNum);
builder.Append($"({x.CourseId},'{x.ChapterNo}','{x.ChapterName}','{x.ChapterContent}',{x.ParentId},{x.OpenStatus},{x.Progress},{x.CreateBy},'{x.CreateTime}',{x.UpdateBy},'{x.UpdateTime}',{(int)x.Status},{x.School_Id},{x.Group_Id},{x.SortNum},{x.StudyHours},'{x.Objectives}','{x.Requirement}',{(int)x.CourseRate},{x.StudyMinutes},{x.CurrentHours}),");
});
builder = builder.Remove(builder.Length - 1, 1);
return base.Execute(builder.ToString()) > 0;
}
/// <summary>
/// 批量更新编号
/// </summary>
......@@ -68,6 +86,11 @@ namespace Edu.Repository.Course
return Execute(builder.ToString()) > 0;
}
/// <summary>
/// 批量插入当前课时
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public bool SetBatchCurrentHoursRepository(List<RB_Course_Chapter_ViewModel> param)
{
StringBuilder builder = new StringBuilder();
......@@ -93,7 +116,6 @@ namespace Edu.Repository.Course
builder.AppendFormat("set {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseRate), EnumHelper.ToInt(model.CourseRate));
builder.AppendFormat(" where {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseId), model.CourseId);
builder.AppendFormat(" and {0} like '{1}%'", nameof(RB_Course_Chapter_ViewModel.ChapterNo), model.ChapterNo);
return Execute(builder.ToString()) > 0;
}
......@@ -109,7 +131,6 @@ namespace Edu.Repository.Course
builder.AppendFormat("set {0}={1}", nameof(RB_Course_Chapter_ViewModel.Status), EnumHelper.ToInt(DateStateEnum.Delete));
builder.AppendFormat(" where {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseId), model.CourseId);
builder.AppendFormat(" and ({0} like '{1}%' or {2}={3})", nameof(RB_Course_Chapter_ViewModel.ChapterNo), model.ChapterNo, nameof(RB_Course_Chapter_ViewModel.ChapterId), model.ChapterId);
return Execute(builder.ToString()) > 0;
}
......@@ -123,15 +144,10 @@ namespace Edu.Repository.Course
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_course_chapter
WHERE 1=1
");
builder.AppendFormat(@" SELECT * FROM rb_course_chapter WHERE 1=1 ");
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.Status), EnumHelper.ToInt(DateStateEnum.Normal));
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseId), courseId);
builder.AppendFormat(" AND ({0}='{1}' or {2} like '{3}.%')", nameof(RB_Course_Chapter_ViewModel.ChapterNo), currentHours, nameof(RB_Course_Chapter_ViewModel.ChapterNo), currentHours);
//builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));
return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList();
}
......@@ -146,11 +162,7 @@ namespace Edu.Repository.Course
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_course_chapter
WHERE 1=1
");
builder.AppendFormat(@" SELECT * FROM rb_course_chapter WHERE 1=1 ");
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.Status), EnumHelper.ToInt(DateStateEnum.Normal));
builder.AppendFormat(" AND {0}={1}", nameof(RB_Course_Chapter_ViewModel.CourseId), courseId);
if (!string.IsNullOrWhiteSpace(currentHours))
......@@ -167,15 +179,9 @@ namespace Edu.Repository.Course
builder.AppendFormat(" Or ");
}
}
builder.AppendFormat(" )");
}
//builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));
return Get<RB_Course_Chapter_ViewModel>(builder.ToString(), parameters).ToList();
}
}
}
}
\ No newline at end of file
using Edu.Model.ViewModel.User;
using Edu.Model.CacheModel;
using Edu.Model.ViewModel.User;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
......@@ -111,18 +112,17 @@ namespace Edu.ThirdCore.TenCloud
/// 获取电话客服的Token
/// </summary>
/// <returns></returns>
public async Task<object> GetTenCccUserToken(string mail)
public async Task<TenCccTokenItem> GetTenCccUserToken(string mail)
{
var credential = TenCloudCredential._instance;
var tenCccTokenItem = new TenCccTokenItem();
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest();
req.SdkAppId = SDKAPPID;
req.SeatUserId = mail;
CreateSDKLoginTokenResponse resp = credential.CreateSDKLoginTokenSync(req);
return new
{
SdkURL = resp.SdkURL,
Token = resp.Token
};
tenCccTokenItem.SdkURL = resp.SdkURL;
tenCccTokenItem.Token = resp.Token;
return tenCccTokenItem;
}
}
......
......@@ -1731,12 +1731,8 @@ namespace Edu.WebApi.Controllers.Course
itemDetails.DurationEndTime = startTime.AddMinutes(tempDuration).ToString("HH:mm");
}
}
item.LessonPlanProjectsList = projectList.Where(x => x.LessonPlanId == item.LessonPlanId).ToList();
// item.LessonPlanProjectsList.ForEach(x => x.ProjectContentList = (string.IsNullOrWhiteSpace(x.ProjectContent) ? new List<string>() : Common.Plugin.JsonHelper.DeserializeObject<List<string>>(x.ProjectContent)));
model.IsEditSummary += item.LessonPlanDetailsList.Where(x => !string.IsNullOrWhiteSpace(x.Summary)).Count();
}
}
}
......@@ -1745,19 +1741,15 @@ namespace Edu.WebApi.Controllers.Course
model.LessonPlanList = new List<RB_Class_LessonPlan_ViewModel>
{
new RB_Class_LessonPlan_ViewModel { CourseName = "备课信息", LessonPlanDetailsList = new List<RB_Class_LessonPlanDetails_ViewModel>(), LessonPlanProjectsList = new List<RB_Class_LessonPlanProjects_ViewModel>() },
//new RB_Class_LessonPlan_ViewModel { CourseName = "理解篇", LessonPlanDetailsList = new List<RB_Class_LessonPlanDetails_ViewModel>(), LessonPlanProjectsList = new List<RB_Class_LessonPlanProjects_ViewModel>() }
};
}
#region 追加章节信息
var hours = classModule.GetCurrentPlanStudyHoursRepository(model.ClassPlanId) + 1;
if (hours != -1)
{
var classObj = classModule.GetClassModule(model.ClassId);
var courseOjb = new CourseModule().GetCourseModule(classObj.CouseId);
var chapter = new CourseModule().GetMatchHoursChapterModule(classObj.CouseId, hours);
if (chapter != null && chapter.Count > 0)
{
......@@ -1765,9 +1757,7 @@ namespace Edu.WebApi.Controllers.Course
}
model.CourseName = courseOjb.CourseName;
}
#endregion
return ApiResult.Success("", model);
}
......
......@@ -583,7 +583,7 @@ namespace Edu.WebApi.Controllers.Course
#region 课程章节管理
/// <summary>
/// 导入课程章节到新课程
/// 导入课程章节和单词到新课程
/// </summary>
/// <returns></returns>
[HttpPost]
......@@ -598,12 +598,8 @@ namespace Edu.WebApi.Controllers.Course
query.Group_Id = base.UserInfo.Group_Id;
query.School_Id = base.UserInfo.School_Id;
query.CreateBy = base.UserInfo.Id;
var q = courseModule.SetImportChapterModule(query);
if (q != null && q.Count > 0)
{
return ApiResult.Success();
}
return ApiResult.Failed();
var flag = courseModule.ImportChapterModule(query);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
......
......@@ -243,11 +243,10 @@ namespace Edu.WebApi.Controllers.User
if (model.IsTenCccUser == 1)
{
var tObj = new TenCloudCCCHelper().GetTenCccUserToken(model.Email).Result;
JObject jsobj = JObject.Parse(tObj.ToString());
obj.TenCccToken = new TenCccTokenItem()
{
SdkURL=jsobj.GetStringValue("SdkURL"),
Token=jsobj.GetStringValue("Token")
SdkURL = tObj.SdkURL,
Token = tObj.Token
};
}
UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime);
......
......@@ -54,17 +54,22 @@ namespace Edu.WebApi.Filter
if (allowRepeat == null)
{
//需进行表单重复提交验证
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", controllerName + "/" + actionName, token));
string actionUrl = controllerName + "/" + actionName;
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", actionUrl, token));
try
{
if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
{
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
if (actionUrl != "course/setchapter")
{
Code = (int)ResultCode.FormRepeatSubmit,
Message = "表单重复提交,请稍后再试",
Data = null
});
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
{
Code = (int)ResultCode.FormRepeatSubmit,
Message = "表单重复提交,请稍后再试",
Data = null
});
}
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment