using System.Collections.Generic; using System.Threading.Tasks; using Dapper; using Datory; using GxPress.Common.Tools; using GxPress.EnumConst; using GxPress.Request.Reply; using GxPress.Result.Reply; namespace GxPress.Service.Implement.Reply { /// /// 点赞 /// public partial class ReplyService { /// /// 获取话题本赞 /// /// /// public async Task> GetNotePraiseAsync(ReplyRequest request) { var noteConstValue = AllTypeConst.Note.GetHashCode(); string sqlStr = string.Empty; if (!string.IsNullOrEmpty(request.KeyWord)) { sqlStr = $@" AND ( b.Title LIKE '%{request.KeyWord}%' OR b.Content LIKE '%{request.KeyWord}%' or c.Name like '%{request.KeyWord}%')"; } string sql = $@" SELECT a.Id, a.SourceId, a.TypeValue, a.IsRead, b.Title, b.Content, c.Name, c.AvatarUrl, b.CreatedDate, a.UserId, b.IsTopic, d.Name FROM tede_analyze a INNER JOIN tede_note b ON a.SourceId = b.Id INNER JOIN tede_user c ON c.Id = a.UserId INNER JOIN tede_user d ON d.Id = b.UserId INNER JOIN tede_middle e ON e.MiddleId = b.Id WHERE a.TypeValue = 4 AND e.IsDelete = 0 AND a.CommentId = 0 AND e.UserId = b.UserId AND a.AnalyzeType = 1 AND b.UserId ={request.UserId} {sqlStr} ORDER BY a.CreatedDate DESC "; var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString")); var connection = database.GetConnection(); var result = await connection.QueryAsync(sql); foreach (var item in result) { item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl); item.CommentContent = "点赞了你的" + ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Title = string.IsNullOrEmpty(item.Title) ? GetTitleText(item.Content) : item.Title; item.Remark = ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Content = string.Empty; } return result; } /// /// 获取评论点赞 /// /// /// public async Task> GetCommentPraiseAsync(ReplyRequest request) { var sqlStr = string.Empty; if (!string.IsNullOrEmpty(request.KeyWord)) { sqlStr = $@" AND (a.Content LIKE '%{request.KeyWord}%' OR c.Name LIKE '%{request.KeyWord}%')"; } string sql = $@" SELECT a.Id, a.Content, a.TypeValue, a.IsRead, b.UserId, c.Name AS UserName, c.AvatarUrl, c.Id AS UserId, d.Name, b.CreatedDate FROM tede_comment a INNER JOIN tede_analyze b ON a.Id = b.CommentId INNER JOIN tede_user c ON c.Id = b.UserId INNER JOIN tede_user d ON d.Id = a.UserId WHERE a.TypeValue IN ({AllTypeConst.Topic.GetHashCode()},{AllTypeConst.Notice.GetHashCode()},{AllTypeConst.Note.GetHashCode()}) AND a.UserId = {request.UserId} {sqlStr} AND b.AnalyzeType = 2 ORDER BY a.CreatedDate DESC"; var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString")); var connection = database.GetConnection(); var result = await connection.QueryAsync(sql); foreach (var item in result) { item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl); item.CommentContent = "点赞了你的" + ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Title = item.Content; item.IsComment = true; item.Remark = ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); } return result; } /// /// 获取通知点赞 /// /// /// public async Task> GetNoticePraiseAsync(ReplyRequest request) { var sqlStr = string.Empty; if (!string.IsNullOrEmpty(request.KeyWord)) { sqlStr = $@" AND (b.Title LIKE '%{request.KeyWord}%' OR b.Content LIKE '%{request.KeyWord}%' OR c.Name LIKE '%{request.KeyWord}%')"; } string sql = $@" SELECT a.Id, a.SourceId, a.TypeValue, a.IsRead, b.Title, b.Content, c.Name, c.AvatarUrl, b.CreatedDate, a.UserId, d.Name AS UserName FROM tede_analyze a INNER JOIN tede_notice b ON a.SourceId = b.Id INNER JOIN tede_user c ON c.Id = a.UserId INNER JOIN tede_user d ON d.Id = b.UserId INNER JOIN tede_middle e ON e.MiddleId = b.Id WHERE b.UserId = {request.UserId} AND e.UserId = b.UserId AND a.TypeValue ={AllTypeConst.Notice.GetHashCode()} AND e.IsDelete = 0 AND a.CommentId = 0 AND a.AnalyzeType = 1 {sqlStr} ORDER BY a.CreatedDate DESC"; var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString")); var connection = database.GetConnection(); var result = await connection.QueryAsync(sql); foreach (var item in result) { item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl); item.CommentContent = "点赞了你的" + ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Title = string.IsNullOrEmpty(item.Title) ? GetTitleText(item.Content) : item.Title; item.Remark = ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Content = string.Empty; } return result; } /// /// 获取话题点赞 /// /// /// public async Task> GetTopicPraiseAsync(ReplyRequest request) { var sqlStr = string.Empty; if (!string.IsNullOrEmpty(request.KeyWord)) { sqlStr = $@" AND ( b.Title LIKE '%{request.KeyWord}%' OR b.Content LIKE '%{request.KeyWord}%' OR c.Name LIKE '%{request.KeyWord}%')"; } string sql = $@" SELECT a.Id, a.SourceId, a.TypeValue, a.IsRead, b.Title, b.Content, c.Name as UserName, c.AvatarUrl, b.CreatedDate, a.UserId, d.Name, g.Id as GroupId, g.Name as GroupName FROM tede_analyze a INNER JOIN tede_topic b ON a.SourceId = b.Id INNER JOIN tede_user c ON c.Id = a.UserId INNER JOIN tede_user d ON d.Id = b.UserId INNER JOIN tede_middle e ON e.MiddleId = b.Id INNER JOIN tede_group g ON g.Id = b.GroupId WHERE a.TypeValue ={AllTypeConst.Topic.GetHashCode()} AND e.IsDelete = 0 AND a.CommentId = 0 AND e.UserId = b.UserId AND a.AnalyzeType = 1 AND b.UserId = {request.UserId} {sqlStr} ORDER BY a.CreatedDate DESC"; var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString")); var connection = database.GetConnection(); var result = await connection.QueryAsync(sql); foreach (var item in result) { item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl); item.CommentContent = "点赞了你的" + ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.Title = string.IsNullOrEmpty(item.Title) ? GetTitleText(item.Content) : item.Title; item.Remark = ((AllTypeConst)item.TypeValue).GetDescriptionOriginal(); item.IsGroup = true; item.Content = string.Empty; } return result; } } }