Commit c8c568be authored by 黄奎's avatar 黄奎

页面修改

parent 60cc3d4e
......@@ -10,8 +10,13 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Course_Category_ViewModel : Model.Entity.Course.RB_Course_Category
public class RB_Course_Category_ViewModel : Entity.Course.RB_Course_Category
{
/// <summary>
/// 分类编号(查询使用)
/// </summary>
public string QCateIds { get; set; }
/// <summary>
/// 创建人
/// </summary>
......
......@@ -10,6 +10,11 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public class RB_Course_Subject_ViewModel: RB_Course_Subject
{
/// <summary>
/// 科目编号【查询使用】
/// </summary>
public string QIds { get; set; }
/// <summary>
/// 创建人
/// </summary>
......
using Edu.Model.Entity.Customer;
using Edu.Common.Plugin;
using Edu.Model.Entity.Customer;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -16,9 +17,9 @@ namespace Edu.Model.ViewModel.Customer
public string QTaskIds { get; set; }
/// <summary>
/// 关联目标名称
/// 任务类型名称
/// </summary>
public string TargetName { get; set; }
public string TaskTypeName { get { return this.TaskType.ToName(); } }
/// <summary>
/// 目标值数组
......@@ -31,5 +32,11 @@ namespace Edu.Model.ViewModel.Customer
return ids;
}
}
/// <summary>
/// 目标列表
/// </summary>
public List<object> TargetList { get; set; }
}
}
......@@ -6,6 +6,8 @@ using System.Text;
using System.Linq;
using VT.FW.DB;
using Edu.Common.Enum;
using Edu.Repository.Course;
using Edu.Model.ViewModel.Course;
namespace Edu.Module.Customer
{
......@@ -24,6 +26,20 @@ namespace Edu.Module.Customer
/// </summary>
private readonly RB_Customer_TaskDetailsRepository detailsRepository = new RB_Customer_TaskDetailsRepository();
/// <summary>
/// 课程仓储层对象
/// </summary>
private readonly RB_CourseRepository courseRepository = new RB_CourseRepository();
/// <summary>
/// 课程系列仓储层对象
/// </summary>
private readonly RB_Course_CategoryRepository course_CategoryRepository = new RB_Course_CategoryRepository();
/// <summary>
/// 科目仓储层对象
/// </summary>
private readonly RB_Course_SubjectRepository course_SubjectRepository = new RB_Course_SubjectRepository();
/// <summary>
/// 获取任务分页列表
......@@ -49,11 +65,78 @@ namespace Edu.Module.Customer
if (detailsList != null && detailsList.Count > 0)
{
var groupList = detailsList.GroupBy(qitem => new { qitem.TaskType }).Select(qitem => new { qitem.Key.TaskType });
var courseList = new List<RB_Course_ViewModel>();
var cateList = new List<RB_Course_Category_ViewModel>();
var subjectList = new List<RB_Course_Subject_ViewModel>();
foreach (var item in groupList)
{
if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.Course)
{
string courseIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType==item.TaskType).Select(qitem=>qitem.TargetId));
string courseIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
courseList = courseRepository.GetCourseListRepository(new RB_Course_ViewModel()
{
QCourseIds = courseIds
});
}
else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseCate)
{
string catdIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
cateList = course_CategoryRepository.GetCourseCategoryListRepository(new RB_Course_Category_ViewModel() { QCateIds = catdIds });
}
else if (item.TaskType == Common.Enum.Customer.TaskTypeEnum.CourseSuject)
{
string subjectIds = string.Join(",", detailsList.Where(qitem => qitem.TaskType == item.TaskType).Select(qitem => qitem.TargetId));
subjectList = course_SubjectRepository.GetCourseSubjectListRepository(new RB_Course_Subject_ViewModel()
{
QIds = subjectIds
});
}
}
foreach (var item in detailsList)
{
item.TargetList = new List<object>();
if (item.TargetIdList != null && item.TargetIdList.Count > 0)
{
foreach (var subItem in item.TargetIdList)
{
switch (item.TaskType)
{
case Common.Enum.Customer.TaskTypeEnum.Course:
var courseModel = courseList.Where(qitem => qitem.CourseId == subItem)?.FirstOrDefault();
if (courseModel != null)
{
item.TargetList.Add(new
{
TargetId=courseModel.CourseId,
TargetName=courseModel.CourseName
});
}
break;
case Common.Enum.Customer.TaskTypeEnum.CourseCate:
var cateModel = cateList.Where(qitem => qitem.CateId == subItem)?.FirstOrDefault();
if (cateModel != null)
{
item.TargetList.Add(new
{
TargetId = cateModel.CateId,
TargetName = cateModel.CateName
});
}
break;
case Common.Enum.Customer.TaskTypeEnum.CourseSuject:
var subjectModel = subjectList.Where(qitem => qitem.Id == subItem)?.FirstOrDefault();
if (subjectModel != null)
{
item.TargetList.Add(new
{
TargetId = subjectModel.Id,
TargetName = subjectModel.SubjectName
});
}
break;
}
}
}
}
}
......
......@@ -42,6 +42,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Category_ViewModel.CateId), query.CateId);
}
if (!string.IsNullOrEmpty(query.QCateIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Course_Category_ViewModel.CateId), query.QCateIds);
}
if (!string.IsNullOrWhiteSpace(query.CateName))
{
builder.AppendFormat(" AND {0} LIKE @CateName ", nameof(RB_Course_Category_ViewModel.CateName));
......
......@@ -73,6 +73,10 @@ WHERE 1=1
builder.AppendFormat(" AND A.{0} LIKE @SubjectName ", nameof(RB_Course_Subject_ViewModel.SubjectName));
parameters.Add("SubjectName", "%" + query.SubjectName.Trim() + "%");
}
if (!string.IsNullOrEmpty(query.QIds))
{
builder.AppendFormat(" AND A.{0} IN ({1}) ", nameof(RB_Course_Subject_ViewModel.Id), query.QIds);
}
}
return Get<RB_Course_Subject_ViewModel>(builder.ToString(), parameters).ToList();
}
......
......@@ -252,6 +252,22 @@ namespace Edu.WebApi.Controllers.Customer
}
}
}
if (model.DetailsList == null || (model.DetailsList != null && model.DetailsList.Count() == 0))
{
return ApiResult.ParamIsNull(message: "请添加任务类型!");
}
if (model.DetailsList != null)
{
var groupList= model.DetailsList.GroupBy(qitem => new { qitem.TaskType })
.Select(qitem => new { qitem.Key.TaskType, TaskTypeCount = qitem.Count() });
foreach (var item in groupList)
{
if (item.TaskTypeCount > 1)
{
return ApiResult.ParamIsNull(message: $"已经存在【{item.TaskType.ToName()}】类型,请重新选择!");
}
}
}
var flag = taskModule.SetCustomerTaskModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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