Commit b9624b04 authored by 吴春's avatar 吴春

提交代码

parent 9b9a7d1c
...@@ -3186,7 +3186,7 @@ namespace Mall.Module.Education ...@@ -3186,7 +3186,7 @@ namespace Mall.Module.Education
{ {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now}, { nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now},
{ nameof(RB_Education_FollowTeacher.Status),1} { nameof(RB_Education_FollowTeacher.Status),model.Status}
}; };
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
......
...@@ -65,7 +65,7 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}= ...@@ -65,7 +65,7 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=
{ {
StringBuilder builder = new StringBuilder(); 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 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"); on a.TeacherId=b.ID WHERE 1=1 and b.{nameof(RB_Education_Teacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}=1");
if (query != null) if (query != null)
{ {
if (query.TenantId > 0) if (query.TenantId > 0)
...@@ -76,6 +76,10 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}= ...@@ -76,6 +76,10 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=
{ {
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.MallBaseId)}={query.MallBaseId}"); builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.MallBaseId)}={query.MallBaseId}");
} }
if (query.Status >= 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.Status)}={query.Status}");
}
if (query.ID > 0) if (query.ID > 0)
{ {
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.ID)}={query.ID}"); builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.ID)}={query.ID}");
......
...@@ -100,7 +100,7 @@ namespace Mall.Repository.Education ...@@ -100,7 +100,7 @@ namespace Mall.Repository.Education
if (model.UserId > 0) if (model.UserId > 0)
{ {
likeWhere += $@" and l.UserId = {model.UserId} "; likeWhere += $@" and l.UserId = {model.UserId} ";
followWhere += $@" and b.UserId = {model.UserId} "; followWhere += $@" and b.UserId = {model.UserId} and b.`Status`=0 ";
} }
} }
string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto
...@@ -198,6 +198,10 @@ union all SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content ...@@ -198,6 +198,10 @@ union all SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content
where += $@" and a.UserTeacher = {model.UserTeacher} "; where += $@" and a.UserTeacher = {model.UserTeacher} ";
} }
if (model.CreateBy > 0) if (model.CreateBy > 0)
{
where += $@" and a.CreateBy = {model.CreateBy} ";
}
if (model.CreateBy > 0)
{ {
// where += $@" and a.CreateBy = {model.CreateBy} "; // where += $@" and a.CreateBy = {model.CreateBy} ";
likeWhere += $@" and l.UserId = {model.CreateBy} "; likeWhere += $@" and l.UserId = {model.CreateBy} ";
......
...@@ -948,7 +948,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -948,7 +948,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ApiResult FollowTeacher() public ApiResult GetFollowTeacher()
{ {
var parms = RequestParm; var parms = RequestParm;
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
...@@ -965,6 +965,8 @@ namespace Mall.WebApi.Controllers.Education ...@@ -965,6 +965,8 @@ namespace Mall.WebApi.Controllers.Education
} }
else else
{ {
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { Status = -1, UserId = query.UserId, TeacherId = query.TeacherId, MallBaseId = query.MallBaseId, TenantId = query.TenantId }); ;
if (query.ID == 0) if (query.ID == 0)
{ {
isUpdate = false; isUpdate = false;
...@@ -974,14 +976,24 @@ namespace Mall.WebApi.Controllers.Education ...@@ -974,14 +976,24 @@ namespace Mall.WebApi.Controllers.Education
{ {
return ApiResult.Failed("请传入我关注的老师信息"); 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(x => x.Status == 0))
if (oldList != null && oldList.Any())
{ {
return ApiResult.Failed("您已关注,请勿重复操作"); return ApiResult.Failed("您已关注,请勿重复操作");
} }
else
{
if (oldList != null && oldList.Any())
{
query.ID = oldList.OrderByDescending(x => x.CreateDate).FirstOrDefault().ID;
}
query.Status = 0;
}
}
else
{
query.Status = 1;
} }
bool result = educationModule.AddOrUpdateFollowTeacher(query); bool result = educationModule.AddOrUpdateFollowTeacher(query);
if (isUpdate) if (isUpdate)
...@@ -1419,7 +1431,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -1419,7 +1431,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary> /// </summary>
/// <param name="article">动态内容</param> /// <param name="article">动态内容</param>
/// <returns></returns> /// <returns></returns>
public object DecoratorDynameicResult(Rb_Education_Dynamic_Extend article) public object DecoratorDynameicResult(Rb_Education_Dynamic_Extend article)
{ {
List<string> fileList = new List<string>(); List<string> fileList = new List<string>();
......
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