Commit c14a3191 authored by 吴春's avatar 吴春

提交代码

parent 1208acac
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_FollowTeacher
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 会员id
/// </summary>
public int UserId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 老师编号
/// </summary>
public int TeacherId { 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_FollowTeacher_Extend : Entity.Education.RB_Education_FollowTeacher
{
/// <summary>
/// 标签
/// </summary>
public List<string> LableNameList { get; set; }
/// <summary>
/// 头像
/// </summary>
public string TeacherLogo { get; set; }
public string LableName { get; set; }
public string Name { get; set; }
/// <summary>
/// 专业
/// </summary>
public string Major { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// 简介
/// </summary>
public string Introduction { get; set; }
/// <summary>
/// 用户评分
/// </summary>
public decimal Score { get; set; }
/// <summary>
/// 从业年限
/// </summary>
public decimal WorkYears { get; set; }
}
}
......@@ -2239,7 +2239,7 @@ namespace Mall.Model.Extend.MarketingCenter
/// <summary>
/// 显示进度
/// </summary>
public bool showProgress { get; set; }
public decimal showProgress { get; set; }
......
......@@ -29,6 +29,12 @@ namespace Mall.Module.Education
/// 教师仓储
/// </summary>
private readonly RB_Education_TeacherRepository educationTeacherRepository = new RB_Education_TeacherRepository();
/// <summary>
/// 我关注的教师仓储
/// </summary>
private readonly RB_Education_FollowTeacherRepository followTeacherRepository = new RB_Education_FollowTeacherRepository();
/// <summary>
/// 小程序
/// </summary>
......@@ -2545,7 +2551,7 @@ namespace Mall.Module.Education
}
}
model.DetailList = dlist;
//是否可以申请售后
model.IsCanApplyForAfterSale = 2;
......@@ -2607,5 +2613,86 @@ namespace Mall.Module.Education
}
#endregion
#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_FollowTeacher_Extend> GetFollowTeacherPageList(int pageIndex, int pageSize, out long rowCount, RB_Education_FollowTeacher_Extend query)
{
List<RB_Education_FollowTeacher_Extend> list = followTeacherRepository.GetFollowPageList(pageIndex, pageSize, out rowCount, query);
return list;
}
/// <summary>
/// 我关注的教师
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Education_FollowTeacher_Extend GetFollowTeacherModel(RB_Education_FollowTeacher_Extend query)
{
RB_Education_FollowTeacher_Extend model = followTeacherRepository.GetFollowTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
/// 我关注的教师
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
{
return followTeacherRepository.GetFollowTeacherList(query);
}
/// <summary>
/// 新增/修改我关注的教师配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateFollowTeacher(RB_Education_FollowTeacher model)
{
bool flag = false;
try
{
if (model.ID == 0)
{
flag = followTeacherRepository.Insert(model) > 0;
}
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now},
{ nameof(RB_Education_FollowTeacher.Status),1}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_FollowTeacher.ID),
FiledValue=model.ID,
OperatorEnum=OperatorEnum.Equal
}
};
flag = followTeacherRepository.Update(keyValues, wheres);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateFollowTeacher");
return false;
}
return flag;
}
#endregion
}
}
......@@ -448,7 +448,7 @@ namespace Mall.Module.MarketingCenter
{
educationModel.Cover = driveData?.Cover ?? "";
educationModel.Name = driveData?.Name ?? "";
educationModel.showProgress = driveData?.showProgress ?? false;
educationModel.showProgress = driveData?.showProgress ?? 0;
educationModel.BtnPosition = driveData?.BtnPosition ?? "left";
educationModel.PaddingTop = driveData?.PaddingTop ?? "0";
educationModel.PaddingBottom = driveData?.PaddingBottom ?? "0";
......
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_FollowTeacherRepository : BaseRepository<RB_Education_FollowTeacher>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Education_FollowTeacher); } }
/// <summary>
/// 网课-我关注的老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowPageList(int pageIndex, int pageSize, out long rowCount, RB_Education_FollowTeacher_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@$" SELECT a.*,b.Introduction,b.Major,b.LableName,b.`Name`,b.Score,b.TeacherLogo,b.Telephone FROM rb_education_followteacher as a LEFT JOIN rb_education_teacher as b
on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}=1");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.ID)}={query.ID}");
}
if (query.UserId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.UserId)}={query.UserId}");
}
if (query.TeacherId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TeacherId)}={query.TeacherId}");
}
}
return GetPage<RB_Education_FollowTeacher_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_FollowTeacher_Extend> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@$" SELECT a.*,b.Introduction,b.Major,b.LableName,b.`Name`,b.Score,b.TeacherLogo,b.Telephone FROM rb_education_followteacher as a LEFT JOIN rb_education_teacher as b
on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}=1");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.ID)}={query.ID}");
}
if (query.UserId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.UserId)}={query.UserId}");
}
if (query.TeacherId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TeacherId)}={query.TeacherId}");
}
}
return Get<RB_Education_FollowTeacher_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -19,6 +19,7 @@ using Mall.CacheManager.User;
using Microsoft.AspNetCore.Authorization;
using Mall.Module.Education;
using Mall.Model.Extend.Education;
using Mall.Model.Entity.Education;
namespace Mall.WebApi.Controllers.Education
{
......@@ -270,7 +271,7 @@ namespace Mall.WebApi.Controllers.Education
var userInfo = AppletUserInfo;
JObject prams = JObject.Parse(req.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Education_Coupon_Extend>(RequestParm.msg.ToString());
query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId;
query.UserId = userInfo.UserId;
......@@ -342,7 +343,7 @@ namespace Mall.WebApi.Controllers.Education
deleted_at = "0000-00-00 00:00:00",
receive_type = "",
discount_limit = x.MaxDiscountsPrice,
usehexiao= x.HeXiao- x.UseHeXiao,
usehexiao = x.HeXiao - x.UseHeXiao,
couponIco = x.CouponIco,
coupon_data = new
{
......@@ -594,6 +595,113 @@ namespace Mall.WebApi.Controllers.Education
#endregion
#region 我关注的老师
/// <summary>
/// 我关注的老师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFollowTeacherPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Education_FollowTeacher_Extend demodel = JsonConvert.DeserializeObject<RB_Education_FollowTeacher_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = educationModule.GetFollowTeacherPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
foreach (var item in list)
{
if (!string.IsNullOrWhiteSpace(item.LableName))
{
item.LableNameList = JsonConvert.DeserializeObject<List<string>>(item.LableName);
}
}
pagelist.pageData = list.Select(x => new
{
x.ID,
x.TeacherLogo,
x.Telephone,
x.Major,
x.LableNameList,
x.Name,
CreateDate = x.CreateDate.ToString("yyyy-MM-dd HH:ss:mm"),
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 关注老师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult FollowTeacher()
{
var parms = RequestParm;
var userInfo = AppletUserInfo;
var query = JsonConvert.DeserializeObject<RB_Education_FollowTeacher>(RequestParm.msg.ToString());
query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId;
query.UserId = userInfo.UserId;
if (query == null)
{
return ApiResult.Failed("请传入我关注的老师信息");
}
else
{
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
query.UpdateDate = System.DateTime.Now;
if (query.TeacherId <= 0)
{
return ApiResult.Failed("请传入我关注的老师信息");
}
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { UserId = query.UserId, TeacherId = query.TeacherId, MallBaseId = query.MallBaseId, TenantId = query.TenantId });
if (oldList != null && oldList.Any())
{
return ApiResult.Failed("您已关注,请勿重复操作");
}
}
bool result = educationModule.AddOrUpdateFollowTeacher(query);
if (query.ID > 0)
{
if (result)
{
return ApiResult.Success("取消关注成功");
}
else
{
return ApiResult.Failed("取消关注成功");
}
}
else
{
if (result)
{
return ApiResult.Success("关注成功");
}
else
{
return 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