Commit fe3fb865 authored by 吴春's avatar 吴春

提交网课

parent d639455e
using Mall.Common.Enum.GuideCar;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 网课-老师实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Teacher
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 头像
/// </summary>
public string TeacherLogo { get; set; }
/// <summary>
/// 专业
/// </summary>
public string Major { get; set; }
/// <summary>
/// 状态1上架 2下架
/// </summary>
public int TeacherStatus { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// 简介
/// </summary>
public string Introduction { get; set; }
/// <summary>
/// 用户评分
/// </summary>
public decimal Score { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 网课-教师扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Teacher_Extend: Entity.Education.RB_Education_Teacher
{
/// <summary>
/// 订单数
/// </summary>
public int OrderNum { get; set; }
/// <summary>
/// 订单人数
/// </summary>
public int OrderGuestNum { get; set; }
/// <summary>
/// 商品数
/// </summary>
public int GoodsNum { get; set; }
/// <summary>
/// 关联商品
/// </summary>
public List<Product.RB_Goods_Extend> GoodsList { get; set; }
}
}
using Mall.Common.Plugin;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using Mall.Repository.Education;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
namespace Mall.Module.Education
{
public class EducationModule
{
/// <summary>
/// 教师仓储
/// </summary>
private readonly RB_Education_TeacherRepository educationTeacherRepository = new RB_Education_TeacherRepository();
#region 教师管理
/// <summary>
///教师配置列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Teacher_Extend> GetTeacherPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Education_Teacher_Extend query)
{
List<RB_Education_Teacher_Extend> list = educationTeacherRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
return list;
}
/// <summary>
/// 教师配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Education_Teacher_Extend GetTeacherModel(RB_Education_Teacher_Extend query)
{
RB_Education_Teacher_Extend model = educationTeacherRepository.GetTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
///教师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public RB_Education_Teacher_Extend GetTeacherOrderInfo(RB_Education_Teacher_Extend query)
{
RB_Education_Teacher_Extend model = educationTeacherRepository.GetTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
/// 教师配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_Teacher_Extend> GetTeacherList(RB_Education_Teacher_Extend query)
{
return educationTeacherRepository.GetTeacherList(query);
}
/// <summary>
/// 新增/修改教师配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateTeacher(RB_Education_Teacher_Extend model)
{
bool flag = false;
try
{
if (model.ID == 0)
{
flag = educationTeacherRepository.Insert(model) > 0;
}
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_Teacher_Extend.TeacherLogo),model.TeacherLogo},
{ nameof(RB_Education_Teacher_Extend.Name),model.Name},
{ nameof(RB_Education_Teacher_Extend.Telephone),model.Telephone},
{ nameof(RB_Education_Teacher_Extend.Introduction),model.Introduction},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_Teacher_Extend.ID),
FiledValue=model.ID,
OperatorEnum=OperatorEnum.Equal
}
};
flag = educationTeacherRepository.Update(keyValues, wheres);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateTeacher");
return false;
}
return flag;
}
/// <summary>
/// 批量上下架教师
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool EnableTeacherInfo(List<string> ids, int TeacherStatus, int uid, int mallBaseId)
{
var trans = educationTeacherRepository.DbTransaction;
bool flag = false;
try
{
foreach (var item in ids)
{
if (!string.IsNullOrWhiteSpace(item))
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_Education_Teacher.TeacherStatus),TeacherStatus},
{ nameof(RB_Education_Teacher.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_Teacher.ID),
FiledValue=Convert.ToInt32(item),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Teacher.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Teacher.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
}
};
flag = educationTeacherRepository.Update(cols, wheres1, trans);
}
}
educationTeacherRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "EnableTeacherInfo");
educationTeacherRepository.DBSession.Rollback("EnableTeacherInfo");
return false;
}
return flag;
}
#endregion
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup>
</Project>
......@@ -3898,7 +3898,8 @@ namespace Mall.Module.Product
x.GuideTelephone,
x.GuideWorkYears,
x.CarId,
x.GuideId
x.GuideId,
x.OrderId
}),
model.IsApplyForCancel,
model.RejectRemark,
......
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Education
{
public class RB_Education_TeacherRepository : BaseRepository<RB_Education_Teacher>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Education_Teacher); } }
/// <summary>
/// 网课-老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Teacher_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Education_Teacher_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Education_Teacher_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.ID)}={query.ID}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Name)} like '%{query.Name}%'");
}
if (!string.IsNullOrWhiteSpace(query.Telephone))
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Telephone)} like '%{query.Telephone}%'");
}
if (query.TeacherStatus > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TeacherStatus)}={query.TeacherStatus}");
}
}
return GetPage<RB_Education_Teacher_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 网课-老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Teacher_Extend> GetTeacherList(RB_Education_Teacher_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Education_Teacher_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.ID)}={query.ID}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Name)} like '%{query.Name}%'");
}
if (!string.IsNullOrWhiteSpace(query.Telephone))
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Telephone)} like '%{query.Telephone}%'");
}
if (query.TeacherStatus > 0)
{
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TeacherStatus)}={query.TeacherStatus}");
}
}
return Get<RB_Education_Teacher_Extend>(builder.ToString()).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Mall.Module.Education;
using Mall.Common.API;
using Newtonsoft.Json;
using Mall.Model.Extend.Education;
using Newtonsoft.Json.Linq;
using Mall.Common.Plugin;
namespace Mall.WebApi.Controllers.Education
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class EducationController : BaseController
{
private readonly EducationModule educationModule = new EducationModule();
#region 教师信息
[HttpPost]
public ApiResult GetGuidePageListRepository()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Education_Teacher_Extend demodel = JsonConvert.DeserializeObject<RB_Education_Teacher_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = educationModule.GetTeacherPageListRepository(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.TeacherLogo,
x.Name,
Score = x.Score == 0 ? "暂无" : x.Score.ToString(),
x.OrderNum,
x.GoodsList,
x.GoodsNum,
CreateDateStr = x.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
x.TeacherStatus,
x.Telephone
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 上下架教师状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult EnableTeacherInfo()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
string idInfo = parmsJob.GetStringValue("Ids");
int teacherStatus = parmsJob.GetInt("TeacherStatus", 0);
if (string.IsNullOrWhiteSpace(idInfo))
{
return ApiResult.Failed("请传递参数");
}
if (teacherStatus == 0)
{
return ApiResult.Failed("请选择您要操作的类型");
}
bool flag = educationModule.EnableTeacherInfo(idInfo.Split(",").ToList(), teacherStatus, UserInfo.TenantId, parms.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
public ApiResult GetTeacherModel()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Education_Teacher_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
query.TeacherStatus = -1;
var oldLogisticsModel = educationModule.GetTeacherModel(query);
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_Education_Teacher_Extend();
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 获取全部教师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetTeacherList()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Education_Teacher_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
query.TeacherStatus = 1;
var list = educationModule.GetTeacherList(query);
var result = list.Select(x => new { x.ID, x.Name, x.TeacherLogo, x.Score });
return ApiResult.Success("", result);
}
/// <summary>
/// 保存教师信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateTeacher()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Education_Teacher_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
if (query == null)
{
return ApiResult.Failed("请传入站点信息");
}
else
{
if (string.IsNullOrWhiteSpace(query.Name))
{
return ApiResult.Failed("请输入教师名称");
}
if (string.IsNullOrWhiteSpace(query.Telephone))
{
return ApiResult.Failed("请上传教师头像");
}
if (string.IsNullOrWhiteSpace(query.Telephone))
{
return ApiResult.Failed("请输入联系电话");
}
if (string.IsNullOrWhiteSpace(query.Introduction))
{
return ApiResult.Failed("请输入简介");
}
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = educationModule.AddOrUpdateTeacher(query);
if (result)
{
return ApiResult.Success("教师信息保存成功");
}
else
{
return ApiResult.Failed("教师信息保存失败");
}
}
}
#endregion
}
}
\ No newline at end of file
......@@ -1105,6 +1105,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.CoverImage,
x.SpecificationList,
x.IsComment,
x.OrderId,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
});
return ApiResult.Success("", pagelist);
......
......@@ -33,6 +33,7 @@
<ProjectReference Include="..\Mall.DataHelper\Mall.DataHelper.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Module.BaseSetUp\Mall.Module.BaseSetUp.csproj" />
<ProjectReference Include="..\Mall.Module.Education\Mall.Module.Education.csproj" />
<ProjectReference Include="..\Mall.Module.MarketingCenter\Mall.Module.MarketingCenter.csproj" />
<ProjectReference Include="..\Mall.Module.Product\Mall.Module.Product.csproj" />
<ProjectReference Include="..\Mall.Module.Property\Mall.Module.Property.csproj" />
......
......@@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.Property", "Mal
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.AOP", "Mall.AOP\Mall.AOP.csproj", "{231B6093-D5A7-4FEB-A624-7FACE432EA86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Module.Education", "Mall.Module.Education\Mall.Module.Education.csproj", "{B076F66B-B75E-43DE-B305-764BF3638A91}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -113,6 +115,10 @@ Global
{231B6093-D5A7-4FEB-A624-7FACE432EA86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{231B6093-D5A7-4FEB-A624-7FACE432EA86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{231B6093-D5A7-4FEB-A624-7FACE432EA86}.Release|Any CPU.Build.0 = Release|Any CPU
{B076F66B-B75E-43DE-B305-764BF3638A91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B076F66B-B75E-43DE-B305-764BF3638A91}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B076F66B-B75E-43DE-B305-764BF3638A91}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B076F66B-B75E-43DE-B305-764BF3638A91}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -130,6 +136,7 @@ Global
{D0386A52-CAFD-40B3-A515-9A9241189FBA} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{339DE5B1-FA62-4B3D-80D4-0C50398D2848} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{C7DE85C9-8620-47A9-AE2F-DD1408DD886B} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
{B076F66B-B75E-43DE-B305-764BF3638A91} = {034DEA5B-083C-46EC-9D3F-C8273C59C218}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {450F460D-A6AE-4FE3-948A-34E5FB8DBD7C}
......
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