|
@@ -406,7 +406,30 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<Entity.Group>> GetAllAsync(int categoryId)
|
|
|
{
|
|
|
- return await _repository.GetAllAsync(Q.Where(nameof(Entity.Group.GroupCategroyId), categoryId));
|
|
|
+ var sql = $@"SELECT
|
|
|
+ *,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_group_user
|
|
|
+ WHERE
|
|
|
+ GroupId = a.Id) AS UserCount,
|
|
|
+ (SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM
|
|
|
+ tede_topic
|
|
|
+ WHERE
|
|
|
+ GroupId = a.Id) AS GroupArticleCount
|
|
|
+ FROM
|
|
|
+ tede_group a
|
|
|
+ WHERE
|
|
|
+ a.GroupCategroyId = {categoryId}";
|
|
|
+ var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ var result = await connection.QueryAsync<Entity.Group>(sql);
|
|
|
+ //return await _repository.GetAllAsync(Q.Where(nameof(Entity.Group.GroupCategroyId), categoryId));
|
|
|
+ return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 用户小组列表
|