Commit 0a09ce7c authored by 黄奎's avatar 黄奎

修改

parent a237975d
using Edu.Common.Enum;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.Course
{
/// <summary>
/// 班级实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Class
{
/// <summary>
/// 主键(班级ID)
/// </summary>
public int ClassId { get; set; }
/// <summary>
/// 班级名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 课程Id
/// </summary>
public int CouseId { get; set; }
/// <summary>
/// 讲师Id
/// </summary>
public int Teacher_Id { get; set; }
/// <summary>
/// 助教Id
/// </summary>
public int Assist_Id { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 学校编号
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 删除状态(0-正常,1-禁用)
/// </summary>
public DateStateEnum Status { get; set; }
}
}
using System;
namespace Edu.Model.ViewModel.Course
{
/// <summary>
/// 班级实体类
/// </summary>
[Serializable]
public class RB_Class_ViewModel : Model.Entity.Course.RB_Class
{
}
}
\ No newline at end of file
using Edu.Common.Enum;
using Edu.Model.ViewModel.Course;
using Edu.Repository.Course;
using System.Collections.Generic;
using VT.FW.DB;
namespace Edu.Module.Course
{
/// <summary>
/// 班级管理处理类
/// </summary>
public class ClassModule
{
/// <summary>
/// 班级仓储层对象
/// </summary>
private readonly RB_ClassRepository classRepository = new RB_ClassRepository();
/// <summary>
/// 获取班级列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetClassListModule(RB_Class_ViewModel query)
{
return classRepository.GetClassListRepository(query);
}
/// <summary>
/// 获取班级分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetClassPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Class_ViewModel query)
{
return classRepository.GetClassPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 检查班级是否存在
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool ExistsClassModule(RB_Class_ViewModel model)
{
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper (nameof(RB_Class_ViewModel.ClassName),model.ClassName.Trim()),
};
if (model.ClassId > 0)
{
wheres.Add(new WhereHelper(nameof(RB_Class_ViewModel.ClassId), model.ClassId, OperatorEnum.NotEqual));
}
return classRepository.Exists(wheres);
}
/// <summary>
/// 新增修改班级
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetClassModule(RB_Class_ViewModel model)
{
if (model.ClassId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Class_ViewModel.ClassName),model.ClassName},
{ nameof(RB_Class_ViewModel.CouseId),model.CouseId},
{ nameof(RB_Class_ViewModel.Teacher_Id),model.Teacher_Id},
{ nameof(RB_Class_ViewModel.Assist_Id),model.Assist_Id},
};
return classRepository.Update(fileds, new WhereHelper(nameof(RB_Class_ViewModel.ClassId), model.ClassId));
}
else
{
var newId = classRepository.Insert(model);
model.ClassId = newId;
return newId > 0;
}
}
/// <summary>
/// 根据班级编号获取班级详细信息
/// </summary>
/// <param name="ClassId"></param>
/// <returns></returns>
public RB_Class_ViewModel GetClassModule(object ClassId)
{
return classRepository.GetEntity<RB_Class_ViewModel>(ClassId);
}
/// <summary>
/// 删除班级
/// </summary>
/// <param name="ClassId"></param>
/// <returns></returns>
public bool RemoveClassModule(object ClassId)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Class_ViewModel.Status),(int)DateStateEnum.Delete},
};
return classRepository.Update(fileds, new WhereHelper(nameof(RB_Class_ViewModel.ClassId), ClassId));
}
}
}
using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Course
{
/// <summary>
/// 班级仓储层
/// </summary>
public class RB_ClassRepository : BaseRepository<RB_Class>
{
/// <summary>
/// 获取班级列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetClassListRepository(RB_Class_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM rb_class AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_ViewModel.Status), (int)DateStateEnum.Normal);
return Get<RB_Class_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 获取班级分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Class_ViewModel> GetClassPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Class_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM rb_class AS A
WHERE 1=1
");
if (query != null)
{
if (query.Status >=0 )
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_ViewModel.Status), (int)query.Status);
}
}
return GetPage<RB_Class_ViewModel>(pageIndex,pageSize,out rowsCount,builder.ToString()).ToList();
}
}
}
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