|
@@ -9,7 +9,9 @@ using GxPress.Common.Tools;
|
|
|
using GxPress.Entity;
|
|
|
using GxPress.Repository.Interface.Note;
|
|
|
using GxPress.Request.App.Note;
|
|
|
+using GxPress.Request.Web;
|
|
|
using GxPress.Result.App.Note;
|
|
|
+using GxPress.Result.Web;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
namespace GxPress.Repository.Implement.Note
|
|
@@ -326,6 +328,94 @@ namespace GxPress.Repository.Implement.Note
|
|
|
/// <param name="id"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<bool> DeleteAsync(int id) => await _repository.DeleteAsync(id);
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///查询个人摘录
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<PagedList<NoteUserExtractResult>> GetAllByUserId(NoteUserRequest request)
|
|
|
+ {
|
|
|
+ var result = new PagedList<NoteUserExtractResult>();
|
|
|
+ var sql = $@"SELECT
|
|
|
+ a.Id,
|
|
|
+ a.CreatedDate,
|
|
|
+ a.Title,
|
|
|
+ a.Content,
|
|
|
+ a.UserId,
|
|
|
+ a.ReadCount,
|
|
|
+ a.HtmlContent,
|
|
|
+ a.MediaId,
|
|
|
+ a.CatalogId,
|
|
|
+ a.ChapterId,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_analyze
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId} AND TypeValue = 3
|
|
|
+ AND SourceId = a.Id
|
|
|
+ AND AnalyzeType = 1) AS PraiseCount,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_analyze
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId} AND TypeValue = 3
|
|
|
+ AND SourceId = a.Id
|
|
|
+ AND AnalyzeType = 1
|
|
|
+ LIMIT 0 , 1) AS IsPraise,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_comment
|
|
|
+ WHERE
|
|
|
+ ArticleId = a.Id AND pid = 0
|
|
|
+ AND TypeValue = 3) AS CommentCount,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_analyze
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId} AND TypeValue = 3
|
|
|
+ AND SourceId = a.Id
|
|
|
+ AND AnalyzeType = 4) AS RetransmissionCount,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_analyze
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId} AND TypeValue = 3
|
|
|
+ AND SourceId = a.Id
|
|
|
+ AND AnalyzeType = 4
|
|
|
+ LIMIT 0 , 1) AS IsRetransmission,
|
|
|
+ b.Name,b.AvatarUrl
|
|
|
+ FROM
|
|
|
+ tede_note a
|
|
|
+ INNER JOIN
|
|
|
+ tede_user b ON a.UserId = b.Id
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId}
|
|
|
+ ORDER BY CreatedDate DESC";
|
|
|
+
|
|
|
+ var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypestr, DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ result.Items =
|
|
|
+ await connection
|
|
|
+ .QueryAsync<NoteUserExtractResult>(sql);
|
|
|
+ sql = $@"SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ tede_note a
|
|
|
+ INNER JOIN
|
|
|
+ tede_user b ON a.UserId = b.Id
|
|
|
+ WHERE
|
|
|
+ UserId = {request.UserId}";
|
|
|
+ result.Total =
|
|
|
+ await connection.ExecuteScalarAsync<int>(sql);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|