Commit 9f7b3a77 authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 67dfedf6 88f0e029
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace Edu.Common.Data
{
public class CourseWordsHelper
{
/// <summary>
/// 根据Excel文件获取问题列表
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static List<WordsItem> GetXlsWordsData(string filePath)
{
List<WordsItem> xlsItems = new List<WordsItem>();
var dt = Common.Plugin.NPOIHelper.ImportExcelToDatatable(filePath, 0, 0, true);
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
xlsItems.Add(DataRowToModel(item));
}
}
return xlsItems;
}
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private static WordsItem DataRowToModel(DataRow dr)
{
WordsItem model = new WordsItem();
if (dr != null)
{
}
return model;
}
}
public class WordsItem
{
}
}
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 课程章节单词实体类
/// </summary>
public class RB_Course_Words
{
/// <summary>
/// 单词编号(主键Id)
/// </summary>
public int Id { get; set; }
/// <summary>
/// 课程编号
/// </summary>
public int CourseId { get; set; }
/// <summary>
/// 章节编号
/// </summary>
public int ChapterId { get; set; }
/// <summary>
/// 单词类型(名词、动词、形容词等)
/// </summary>
public string WordType { get; set; }
/// <summary>
/// 单词内容
/// </summary>
public string WordContent { get; set; }
/// <summary>
/// 单词声调
/// </summary>
public string WordTone { get; set; }
/// <summary>
/// 单词书写
/// </summary>
public string WordWrite { get; set; }
/// <summary>
/// 中文意思
/// </summary>
public string ChineseMean { get; set; }
/// <summary>
/// 状态
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
}
}
\ No newline at end of file
using Edu.Model.Entity.Course;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Course
{
/// <summary>
/// 课程章节单词扩展实体类
/// </summary>
public class RB_Course_Words_Extend : RB_Course_Words
{
}
}
using Edu.Common.Enum;
using Edu.Model.ViewModel.Course;
using Edu.Repository.Course;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Module.Course
{
/// <summary>
/// 课程章节单词处理类
/// </summary>
public class CourseWordsModule
{
/// <summary>
/// 课程章节单词仓储层对象
/// </summary>
private readonly RB_Course_WordsRepository course_WordsRepository = new RB_Course_WordsRepository();
/// <summary>
/// 获取课程单词列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Words_Extend> GetCourseWordsListModule(RB_Course_Words_Extend query)
{
var list = course_WordsRepository.GetCourseWordsListRepository(query);
return list;
}
/// <summary>
/// 新增修改课程单词
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCourseWordsModule(RB_Course_Words_Extend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Course_Words_Extend.ChapterId),model.ChapterId },
{nameof(RB_Course_Words_Extend.WordType),model.WordType },
{nameof(RB_Course_Words_Extend.WordContent),model.WordContent },
{nameof(RB_Course_Words_Extend.WordTone),model.WordTone },
{nameof(RB_Course_Words_Extend.WordWrite),model.WordWrite },
{nameof(RB_Course_Words_Extend.ChineseMean),model.ChineseMean },
{nameof(RB_Course_Words_Extend.UpdateBy),model.UpdateBy },
{nameof(RB_Course_Words_Extend.UpdateTime),model.UpdateTime },
};
flag = course_WordsRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Words_Extend.Id), model.Id));
}
else
{
var newId = course_WordsRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取单词详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Course_Words_Extend GetCourseWordsModule(object Id)
{
var extModel = course_WordsRepository.GetEntity<RB_Course_Words_Extend>(Id);
return extModel;
}
/// <summary>
/// 根据编号删除单词
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveCourseWordsModule(object Id)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Course_Words_Extend.Status),(int)DateStateEnum.Delete },
};
bool flag = course_WordsRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Words_Extend.Id), Id));
return flag;
}
}
}
using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Course
{
/// <summary>
/// 课程章节单词仓储层
/// </summary>
public class RB_Course_WordsRepository : BaseRepository<RB_Course_Words>
{
/// <summary>
/// 获取课程单词列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Words_Extend> GetCourseWordsListRepository(RB_Course_Words_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Course_Words AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Words_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Words_Extend.Group_Id), query.Group_Id);
}
if (query.CourseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Words_Extend.CourseId), query.CourseId);
}
}
return Get<RB_Course_Words_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -1432,8 +1432,6 @@ namespace Edu.WebApi.Controllers.Course
#endregion
#region 试听课程关联
/// <summary>
......
using Edu.Common.API;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Edu.WebApi.Controllers.Course
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class CourseWordsController : BaseController
{
/// <summary>
/// 导入Excel单词
/// </summary>
/// <returns></returns>
public ApiResult ImportExcelWords(string filePath, int CourseId, int Uid)
{
var userInfo = base.GetUserInfo(Uid);
var dataList = Common.Data.CourseWordsHelper.GetXlsWordsData(filePath);
return ApiResult.Success(data: dataList);
}
}
}
......@@ -53,6 +53,8 @@ namespace Edu.WebApi.Controllers.Upload
Int32.TryParse((json["Word"] != null ? json["Word"].ToString() : "0"), out int Word);
Int32.TryParse((json["CourseId"] != null ? json["CourseId"].ToString() : "0"), out int CourseId);
Int32.TryParse((json["Uid"] != null ? json["Uid"].ToString() : "0"), out int Uid);
//上次课程单词
Int32.TryParse((json["CourseWords"] != null ? json["CourseWords"].ToString() : "0"), out int CourseWords);
string filename = files[0].FileName;
string fileExtention = System.IO.Path.GetExtension(files[0].FileName);
......@@ -90,6 +92,11 @@ namespace Edu.WebApi.Controllers.Upload
{
return new QuestionController().ImportWordQuestion(path_server, CourseId, Uid, isDelete: true);
}
//上传课程单词
if (CourseWords == 1)
{
return new CourseWordsController().ImportExcelWords(path_server, CourseId, Uid);
}
return ApiResult.Success("", new { Name = filename, Path = path_server });
}
catch (Exception ex)
......
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