Commit 81730c81 authored by 黄奎's avatar 黄奎

新增试听课程

parent c9838e7b
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 试听课课程实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_TrialLesson
{
/// <summary>
/// 试听课主键编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 试听课程名称
/// </summary>
public string LessonName { get; set; }
/// <summary>
/// 试听课主讲老师
/// </summary>
public int TeacherId { get; set; }
/// <summary>
/// 课时费
/// </summary>
public decimal ClassHourFee { get; set; }
/// <summary>
/// 核算方式(1-单次,2-按月)
/// </summary>
public int CalculateType { 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; }
/// <summary>
/// 学校Id
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 状态
/// </summary>
public DateStateEnum Status { get; set; }
}
}
using Edu.Model.Entity.Course;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Course
{
/// <summary>
/// 试听课课程扩展实体类
/// </summary>
public class RB_TrialLesson_Extend: RB_TrialLesson
{
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
}
}
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 TrialLessonModule
{
/// <summary>
/// 试听课程仓储层对象
/// </summary>
private readonly RB_TrialLessonRepository trialLessonRepository = new RB_TrialLessonRepository();
/// <summary>
/// 获取试听课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCuont"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_TrialLesson_Extend> GetTrialLessonPageModule(int pageIndex, int pageSize, out long rowsCuont, RB_TrialLesson_Extend query)
{
var list = trialLessonRepository.GetTrialLessonPageRepository(pageIndex, pageSize, out rowsCuont, query);
return list;
}
/// <summary>
/// 获取试听课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_TrialLesson_Extend> GetTrialLessonListModule(RB_TrialLesson_Extend query)
{
var list = trialLessonRepository.GetTrialLessonListRepository(query);
return list;
}
/// <summary>
/// 新增修改试听课程
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetTrialLessonModule(RB_TrialLesson_Extend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_TrialLesson_Extend.LessonName),model.LessonName },
{nameof(RB_TrialLesson_Extend.TeacherId),model.TeacherId },
{nameof(RB_TrialLesson_Extend.ClassHourFee),model.ClassHourFee },
{nameof(RB_TrialLesson_Extend.CalculateType),model.CalculateType },
};
flag = trialLessonRepository.Update(fileds, new WhereHelper(nameof(RB_TrialLesson_Extend.Id), model.Id));
}
else
{
var newId = trialLessonRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取试听课程信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_TrialLesson_Extend GetTrialLessonModule(object Id)
{
var extModel = trialLessonRepository.GetEntity<RB_TrialLesson_Extend>(Id);
return extModel;
}
/// <summary>
/// 根据编号删除试听课程
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveTrialLessonModule(object Id)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_TrialLesson_Extend.Status), (int)DateStateEnum.Delete},
};
bool flag = trialLessonRepository.Update(fileds, new WhereHelper(nameof(RB_TrialLesson_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;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Course
{
/// <summary>
/// 试听课程仓储层
/// </summary>
public class RB_TrialLessonRepository : BaseRepository<RB_TrialLesson>
{
/// <summary>
/// 获取试听课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCuont"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_TrialLesson_Extend> GetTrialLessonPageRepository(int pageIndex, int pageSize, out long rowsCuont, RB_TrialLesson_Extend query)
{
StringBuilder builder = new StringBuilder();
var parameters = new DynamicParameters();
builder.AppendFormat(@"
SELECT A.*
FROM RB_TrialLesson AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_TrialLesson_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_TrialLesson_Extend.Group_Id), query.Group_Id);
}
if (!string.IsNullOrWhiteSpace(query.LessonName))
{
builder.AppendFormat(" AND A.{0} LIKE @LessonName ", nameof(RB_TrialLesson_Extend.LessonName));
parameters.Add("LessonName", "%" + query.LessonName.Trim() + "%");
}
}
return GetPage<RB_TrialLesson_Extend>(pageIndex, pageSize, out rowsCuont, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取试听课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_TrialLesson_Extend> GetTrialLessonListRepository(RB_TrialLesson_Extend query)
{
StringBuilder builder = new StringBuilder();
var parameters = new DynamicParameters();
builder.AppendFormat(@"
SELECT A.*
FROM RB_TrialLesson AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_TrialLesson_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_TrialLesson_Extend.Group_Id), query.Group_Id);
}
if (!string.IsNullOrWhiteSpace(query.LessonName))
{
builder.AppendFormat(" AND A.{0} LIKE @LessonName ", nameof(RB_TrialLesson_Extend.LessonName));
parameters.Add("LessonName", "%" + query.LessonName.Trim() + "%");
}
}
return Get<RB_TrialLesson_Extend>(builder.ToString(), parameters).ToList();
}
}
}
......@@ -33,6 +33,11 @@ namespace Edu.WebApi.Controllers.Course
/// </summary>
private readonly CourseModule courseModule = AOP.AOPHelper.CreateAOPObject<CourseModule>();
/// <summary>
/// 试听课处理类对象
/// </summary>
private readonly TrialLessonModule trialLessonModule = AOP.AOPHelper.CreateAOPObject<TrialLessonModule>();
#region 科目管理
/// <summary>
/// 获取课程科目分页列表
......@@ -1425,5 +1430,104 @@ namespace Edu.WebApi.Controllers.Course
}
#endregion
#region 试听课程关联
/// <summary>
/// 获取试听课程分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetTrialLessonPage()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_TrialLesson_Extend()
{
LessonName = base.ParmJObj.GetStringValue("LessonName"),
};
query.Group_Id = base.UserInfo.Group_Id;
query.School_Id = base.UserInfo.School_Id;
var list = trialLessonModule.GetTrialLessonPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
foreach (var item in list)
{
if (item.CreateBy > 0)
{
item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
}
}
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取试听课程列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetTrialLessonList()
{
var query = new RB_TrialLesson_Extend()
{
LessonName = base.ParmJObj.GetStringValue("LessonName"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = trialLessonModule.GetTrialLessonListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改试听课程
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetTrialLesson()
{
var extModel = new RB_TrialLesson_Extend()
{
Id = base.ParmJObj.GetInt("Id"),
LessonName = base.ParmJObj.GetStringValue("LessonName"),
TeacherId = base.ParmJObj.GetInt("TeacherId"),
ClassHourFee=base.ParmJObj.GetDecimal("ClassHourFee"),
CalculateType=base.ParmJObj.GetInt("CalculateType"),
};
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = UserInfo.Id;
extModel.UpdateBy = UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
extModel.Group_Id = this.UserInfo.Group_Id;
extModel.School_Id = this.UserInfo.School_Id;
extModel.Status = DateStateEnum.Normal;
bool flag = trialLessonModule.SetTrialLessonModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取试听课程信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetTrialLesson()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var extModel = trialLessonModule.GetTrialLessonModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 根据编号删除试听课程
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveTrialLesson()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var flag = trialLessonModule.RemoveTrialLessonModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
\ No newline at end of file
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