李昊 4 年之前
父節點
當前提交
df25d8815c

+ 11 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/ReplyController.cs

@@ -35,5 +35,16 @@ namespace GxPress.Api.AppControllers
             request.UserId = _loginContext.AccountId;
             return await replyService.GetReplyNoteOrTopicResults(request);
         }
+        /// <summary>
+        /// 获取我收到的赞
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("praise")]
+        public async Task<IEnumerable<ReplyResult>> GetPraiseAsync(ReplyRequest request)
+        {
+            request.UserId = _loginContext.AccountId;
+            return await replyService.GetPraiseAsync(request);
+        }
     }
 }

+ 1 - 1
gx_api/GxPress/Model/GxPress.Result/Reply/ReplyResult.cs

@@ -13,7 +13,7 @@ namespace GxPress.Result.Reply
         /// 话题或者笔记ID
         /// </summary>
         /// <value></value>
-        public int ArticleId { get; set; }
+        public int SourceId { get; set; }
         /// <summary>
         /// 评论内容
         /// </summary>

+ 1 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Reply/ReplyService.Note.Topic.cs

@@ -38,7 +38,7 @@ namespace GxPress.Service.Implement.Reply
                                 SELECT 
                                         a.Id,
                                         a.UserId,
-                                        a.ArticleId,
+                                        a.ArticleId as SourceId,
                                         a.Content as CommentContent,
                                         a.Pid,
                                         a.TypeValue,

+ 75 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Reply/ReplyService.Praise.cs

@@ -0,0 +1,75 @@
+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
+{
+    /// <summary>
+    /// 点赞
+    /// </summary>
+    public partial class ReplyService
+    {
+        /// <summary>
+        /// 获取我收到的赞
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<ReplyResult>> GetPraiseAsync(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,
+                                        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
+                                    WHERE
+                                        b.UserId = {request.UserId} AND a.TypeValue ={noteConstValue}
+                                            AND b.IsDelete = 0 and a.AnalyzeType in(1,2) {sqlStr}
+                                    ORDER BY a.CreatedDate DESC
+                                            ";
+            var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString"));
+            var connection = database.GetConnection();
+            return await connection.QueryAsync<ReplyResult, Entity.Note.Note, Entity.User, Entity.User, ReplyResult>(sql,
+                        (result, note, user, userModel) =>
+                        {
+                            result.UserName = user != null ? user.Name : "";
+                            result.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
+                            result.IsTopic = note.IsTop;
+                            result.Title = string.IsNullOrEmpty(note.Title) ? GetTitleText(note.Content) : note.Title;
+                            //result.Content = note.Content;
+                            result.CreatedDate = note.CreatedDate;
+                            result.Name = userModel.Name;
+                            result.Remark = result.IsTopic ? AllTypeConst.Topic.GetDescriptionOriginal() : AllTypeConst.Note.GetDescriptionOriginal();
+                            return result;
+                        }, splitOn: "Id,Title,Name,Name");
+        }
+    }
+}

+ 8 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Reply/ReplyService.cs

@@ -1,3 +1,7 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.Request.Reply;
+using GxPress.Result.Reply;
 using GxPress.Service.Interface.Reply;
 
 namespace GxPress.Service.Implement.Reply
@@ -7,6 +11,9 @@ namespace GxPress.Service.Implement.Reply
     /// </summary>
     public partial class ReplyService : IReplyService
     {
-    
+        public ReplyService()
+        {
+
+        }
     }
 }

+ 7 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/Reply/IReplyService.cs

@@ -13,5 +13,12 @@ namespace GxPress.Service.Interface.Reply
         /// <param name="request"></param>
         /// <returns></returns>
         Task<IEnumerable<ReplyResult>> GetReplyNoteOrTopicResults(ReplyRequest request);
+        string GetTitleText(string content);
+        /// <summary>
+        /// 获取我收到的赞
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<IEnumerable<ReplyResult>> GetPraiseAsync(ReplyRequest request);
     }
 }