|
@@ -1,14 +1,10 @@
|
|
|
-using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using AutoMapper;
|
|
|
using Dapper;
|
|
|
using Datory;
|
|
|
using GxPress.Common.AppOptions;
|
|
|
using GxPress.Common.Tools;
|
|
|
-using GxPress.Entity;
|
|
|
using GxPress.Entity.Topic;
|
|
|
using GxPress.Repository.Interface.Topic;
|
|
|
using GxPress.Request.App.Topic;
|
|
@@ -69,9 +65,31 @@ namespace GxPress.Repository.Implement.Topic
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<TopicGroup>> GetTopicGroupsAsync(int userId)
|
|
|
{
|
|
|
- var result = await _repository.GetAllAsync(Q.Where(nameof(TopicGroup.UserId), userId)
|
|
|
- .OrderByDesc(nameof(TopicGroup.Sort)));
|
|
|
- return result;
|
|
|
+ string sql = $@"SELECT
|
|
|
+ Id,
|
|
|
+ UserId,
|
|
|
+ Name,
|
|
|
+ Sort,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_user
|
|
|
+ WHERE
|
|
|
+ id IN (SELECT
|
|
|
+ UserId
|
|
|
+ FROM
|
|
|
+ tede_topic_group_user
|
|
|
+ WHERE
|
|
|
+ TopicGroupId = a.Id)) AS IncludeCount
|
|
|
+ FROM
|
|
|
+ tede_topic_group a
|
|
|
+ WHERE
|
|
|
+ a.userId = {userId}
|
|
|
+ ORDER BY a.Sort DESC";
|
|
|
+ var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ return await connection.QueryAsync<Entity.Topic.TopicGroup>(sql);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 修改分组名称
|