GroupRepository.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using AutoMapper;
  4. using Dapper;
  5. using GxPress.Common.AppOptions;
  6. using GxPress.Common.Exceptions;
  7. using GxPress.Common.Page;
  8. using GxPress.Common.Tools;
  9. using GxPress.Entity;
  10. using GxPress.EnumConst;
  11. using GxPress.Repository.Interface;
  12. using GxPress.Request.App.Group;
  13. using GxPress.Result.App.Group;
  14. using GxPress.Result.App.GroupUser;
  15. using Microsoft.AspNetCore.Hosting;
  16. using Microsoft.Extensions.Options;
  17. using Newtonsoft.Json;
  18. using Datory;
  19. using GxPress.Request.App.Topic;
  20. using SqlKata;
  21. using GxPress.Result.Job;
  22. using System.Linq;
  23. namespace GxPress.Repository.Implement
  24. {
  25. public class GroupRepository : IGroupRepository
  26. {
  27. private readonly Repository<Entity.Group> _repository;
  28. private readonly IMapper _mapper;
  29. private readonly IWebHostEnvironment _environment;
  30. private readonly string _connectionString;
  31. private readonly string _databaseTypeStr;
  32. private readonly Repository<GroupUser> _groupUserRepository;
  33. public GroupRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper,
  34. IWebHostEnvironment environment)
  35. {
  36. _databaseTypeStr = dbOptionsAccessor.CurrentValue.DatabaseType;
  37. _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
  38. var databaseType =
  39. StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
  40. var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
  41. _repository = new Repository<Entity.Group>(database);
  42. _groupUserRepository = new Repository<GroupUser>(database);
  43. _environment = environment;
  44. _mapper = mapper;
  45. }
  46. public IDatabase Database => _repository.Database;
  47. public string TableName => _repository.TableName;
  48. public List<TableColumn> TableColumns => _repository.TableColumns;
  49. public async Task<int> InsertAsync(GroupInRequest request)
  50. {
  51. if (string.IsNullOrEmpty(request.Name))
  52. throw new BusinessException("小组名称不能为空");
  53. var group = new Entity.Group
  54. {
  55. Name = request.Name,
  56. AvatarUrl = request.AvatarUrl,
  57. Introduce = request.Introduce,
  58. IsAdmin = false,
  59. IsUDisturb = false,
  60. QRCoder = request.QRCoder,
  61. IsWords = false,
  62. UserId = request.UserId,
  63. GroupCategroyId = request.GroupCategroyId,
  64. LabelName = request.LabelName,
  65. IsShow = request.IsShow
  66. };
  67. if (!string.IsNullOrEmpty(group.AvatarUrl))
  68. group.AvatarUrl = StringUtils.RemoveDomain(group.AvatarUrl);
  69. var id = await _repository.InsertAsync(group);
  70. //生成二维码
  71. var groupDto = await _repository.GetAsync(id);
  72. var qrCodeData = new { key = QRCodeTypeConst.GroupInfo, value = groupDto.Guid };
  73. var resultPath =
  74. FileHelper.SaveQRCodeFile(StringUtils.GetWebRootPath(_environment.WebRootPath),
  75. JsonConvert.SerializeObject(qrCodeData));
  76. groupDto.QRCoder = resultPath.RelativePath;
  77. await _repository.UpdateAsync(groupDto);
  78. return id;
  79. }
  80. public async Task<IEnumerable<GroupUser>> GetAllAsync(SqlKata.Query query)
  81. {
  82. return await _groupUserRepository.GetAllAsync(query);
  83. }
  84. /// <summary>
  85. /// 修改小组
  86. /// </summary>
  87. /// <param name="request"></param>
  88. /// <returns></returns>
  89. public async Task<bool> UpdateAsync(GroupUpRequest request)
  90. {
  91. var group = await _repository.GetAsync(request.Id);
  92. if (!string.IsNullOrEmpty(request.Name))
  93. group.Name = request.Name;
  94. if (!string.IsNullOrEmpty(request.AvatarUrl))
  95. {
  96. group.HistoryAvatarUrl = group.AvatarUrl;
  97. group.AvatarUrl = StringUtils.RemoveDomain(request.AvatarUrl);
  98. }
  99. if (!string.IsNullOrEmpty(request.Introduce))
  100. group.Introduce = request.Introduce;
  101. if (!string.IsNullOrEmpty(request.LabelName))
  102. group.LabelName = request.LabelName;
  103. if (request.IsShow > 0)
  104. group.IsShow = request.IsShow == 1;
  105. if (request.IsAdmin > 0)
  106. group.IsAdmin = request.IsAdmin == 1;
  107. if (request.IsWords > 0)
  108. group.IsWords = request.IsWords == 1;
  109. return await _repository.UpdateAsync(group);
  110. }
  111. /// <summary>
  112. /// 删除小组
  113. /// </summary>
  114. /// <param name="id"></param>
  115. /// <returns></returns>
  116. public async Task<bool> DeleteAsync(int id)
  117. {
  118. return await _repository.DeleteAsync(id);
  119. }
  120. public async Task<bool> DeleteAsync(Query query)
  121. {
  122. return await _repository.DeleteAsync(query) > 0;
  123. }
  124. /// <summary>
  125. /// 查询小组
  126. /// </summary>
  127. /// <param name="request"></param>
  128. /// <returns></returns>
  129. public async Task<PagedList<GroupUserFindResult>> FindGroupByGroupFolderId(GroupSearchRequest request)
  130. {
  131. var pagedList = new PagedList<GroupUserFindResult>();
  132. var groupConst = AllTypeConst.Group.GetHashCode();
  133. //根据文件夹ID查询成员
  134. var sqlValue = "";
  135. // if (!string.IsNullOrEmpty(request.Key))
  136. // sqlValue += $"and b.Name like '%{request.Key}%'";
  137. //共享数量
  138. var topicSharingCount = "(select count(1) from tede_group_user where GroupId=a.MiddleId) as TopicSharingCount";
  139. //总话题数量
  140. var topicAllCount = "(select count(1) from tede_topic where GroupId=a.MiddleId) as TopicAllCount";
  141. //未读话题数量
  142. var uReadTopicCount = $"(select count(1) from tede_topic_addressee where TopicId in (select Id from tede_topic where GroupId=a.MiddleId) and UserId={request.UserId} and IsRead=0) as UReadTopicCount";
  143. var categoryName = "(select FolderName from tede_middle where id=a.ParentId) as CategoryName";
  144. var sql =
  145. $@"SELECT a.*,{topicSharingCount},{topicAllCount},{uReadTopicCount},{categoryName},
  146. (SELECT
  147. COUNT(1)
  148. FROM
  149. tede_group
  150. WHERE
  151. id IN (SELECT
  152. MiddleId
  153. FROM
  154. tede_middle
  155. WHERE
  156. ParentId = a.Id)) AS FileCount,b.Id, b.AvatarUrl, b.Name FROM tede_Middle a LEFT JOIN tede_group b ON a.MiddleId = b.Id WHERE 1=1 ";
  157. if (request.GroupFolderId == 0 && string.IsNullOrEmpty(request.Key))
  158. sql += $"and a.ParentId = @groupFolderId ";
  159. else if (request.GroupFolderId > 0 && !string.IsNullOrEmpty(request.Key))
  160. sql += $"and a.ParentId = @groupFolderId and (a.FolderName like '%{request.Key}%' or b.Name like '%{request.Key}%')";
  161. else if (request.GroupFolderId > 0 && string.IsNullOrEmpty(request.Key))
  162. sql += $"and a.ParentId = @groupFolderId ";
  163. else
  164. sql += $" and (a.FolderName like '%{request.Key}%' or b.Name like '%{request.Key}%')";
  165. sql +=
  166. $@" and a.UserId=@userId and a.FolderType={groupConst} and a.IsDelete=0 {sqlValue} and (b.id>0 or a.AttributeValue=2) ORDER BY a.IsTop DESC, a.LastModifiedDate DESC ,a.AttributeValue DESC LIMIT @page , @pageSize";
  167. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  168. var database = new Database(databaseType, _connectionString);
  169. var connection = database.GetConnection();
  170. var result =
  171. await connection
  172. .QueryAsync<GroupUserFindResult, Entity.Group, GroupUserFindResult>(sql,
  173. (groupUserFindResult, group) =>
  174. {
  175. groupUserFindResult.GroupName = group == null ? "" : group.Name;
  176. groupUserFindResult.AvatarUrl = group == null ? "" : StringUtils.AddDomainMin(group.AvatarUrl);
  177. groupUserFindResult.GroupId = group?.Id ?? 0;
  178. return groupUserFindResult;
  179. },
  180. new
  181. {
  182. groupFolderId = request.GroupFolderId,
  183. userId = request.UserId,
  184. page = (request.Page - 1) * request.PerPage,
  185. pageSize = request.PerPage * request.Page
  186. }, splitOn: "Id");
  187. pagedList.Items = result;
  188. var sqlCount =
  189. @"SELECT count(1) FROM tede_Middle a LEFT JOIN tede_group b ON a.MiddleId = b.Id WHERE 1=1 ";
  190. if (request.GroupFolderId == 0 && string.IsNullOrEmpty(request.Key))
  191. sqlCount += $"and a.ParentId = {request.GroupFolderId} ";
  192. else if (request.GroupFolderId > 0 && !string.IsNullOrEmpty(request.Key))
  193. sqlCount += $"and a.ParentId = {request.GroupFolderId} and (a.FolderName like '%{request.Key}%' or b.Name like '%{request.Key}%')";
  194. else if (request.GroupFolderId > 0 && string.IsNullOrEmpty(request.Key))
  195. sqlCount += $"and a.ParentId = {request.GroupFolderId} ";
  196. else
  197. sql += $" and (a.FolderName like '%{request.Key}%' or b.Name like '%{request.Key}%')";
  198. sqlCount +=
  199. $" and a.UserId={request.UserId} and a.FolderType={groupConst} and a.IsDelete=0 {sqlValue} and (b.id>0 or a.AttributeValue=2)";
  200. pagedList.Total = await FindGroupByGroupFolderIdCountAsync(sqlCount);
  201. return pagedList;
  202. }
  203. /// <summary>
  204. /// 条数
  205. /// </summary>
  206. /// <param name="sql"></param>
  207. /// <returns></returns>
  208. public async Task<int> FindGroupByGroupFolderIdCountAsync(string sql)
  209. {
  210. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  211. var database = new Database(databaseType, _connectionString);
  212. var connection = database.GetConnection();
  213. var result = await connection.ExecuteScalarAsync<int>(sql);
  214. return result;
  215. }
  216. /// <summary>
  217. /// 获取小组详情
  218. /// </summary>
  219. /// <param name="request"></param>
  220. /// <returns></returns>
  221. public async Task<GroupDetailResult> GroupDetailAsync(GroupDetailRequest request)
  222. {
  223. var groupDetail = await _repository.GetAsync(request.GroupId);
  224. if (groupDetail == null)
  225. throw new BusinessException("小组不存在");
  226. if (!string.IsNullOrEmpty(groupDetail.AvatarUrl))
  227. groupDetail.AvatarUrl = StringUtils.AddDomain(groupDetail.AvatarUrl);
  228. if (!string.IsNullOrEmpty(groupDetail.AvatarUrl))
  229. groupDetail.AvatarUrl = StringUtils.AddDomain(groupDetail.AvatarUrl);
  230. if (!string.IsNullOrEmpty(groupDetail.HistoryAvatarUrl))
  231. groupDetail.HistoryAvatarUrl = StringUtils.AddDomain(groupDetail.HistoryAvatarUrl);
  232. var sql =
  233. "SELECT a.*,b.Name,b.AvatarUrl,c.Name FROM tede_group_user a inner join tede_user b on a.UserId=b.Id inner join tede_department c on b.DepartmentId=c.Id where a.GroupId=@groupId order by a.GroupUserRoleId";
  234. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  235. var database = new Database(databaseType, _connectionString);
  236. var connection = database.GetConnection();
  237. var result =
  238. await connection
  239. .QueryAsync<GroupUserListResult, User, Department, GroupUserListResult>(sql,
  240. (groupUserListResult, user, department) =>
  241. {
  242. groupUserListResult.DepartmentName = department.Name;
  243. groupUserListResult.Name = user.Name;
  244. groupUserListResult.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
  245. return groupUserListResult;
  246. }, new { groupId = request.GroupId }, splitOn: "Name");
  247. var groupDetailResult = _mapper.Map<GroupDetailResult>(groupDetail);
  248. groupDetailResult.GroupUserListResult = result;
  249. var groupUser = await _groupUserRepository.GetAsync(Q.Where(nameof(GroupUser.UserId), request.UserId)
  250. .Where(nameof(GroupUser.GroupId), request.GroupId));
  251. //获取当前用户的权限
  252. groupDetailResult.GroupUserRoleId = groupUser != null ? groupUser.GroupUserRoleId : 0;
  253. groupDetailResult.IsUDisturb = groupUser != null ? groupUser.IsUDisturb : false;
  254. //groupDetailResult.IsAdmin = groupUser != null ? groupUser.UserId == groupDetailResult.UserId : false;
  255. groupDetailResult.IsUser = groupUser != null ? groupUser.UserId == request.UserId : false;
  256. groupDetailResult.CreatedDate = groupDetail.CreatedDate;
  257. return groupDetailResult;
  258. }
  259. /// <summary>
  260. /// 搜索小组成员
  261. /// </summary>
  262. /// <param name="request"></param>
  263. /// <returns></returns>
  264. public async Task<IEnumerable<GroupUserListResult>> SearchGroupUserAsync(TopicDetailListRequest request)
  265. {
  266. string sql =
  267. $@"SELECT a.*, b.Name, b.AvatarUrl, c.Name FROM tede_group_user a INNER JOIN tede_user b ON a.UserId = b.Id INNER JOIN
  268. tede_department c ON b.DepartmentId = c.Id
  269. WHERE a.GroupId = {request.GroupId} and b.Name like '%{request.Key}%'";
  270. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  271. var database = new Database(databaseType, _connectionString);
  272. var connection = database.GetConnection();
  273. var result =
  274. await connection
  275. .QueryAsync<GroupUserListResult, User, Department, GroupUserListResult>(sql,
  276. (groupUserListResult, user, department) =>
  277. {
  278. groupUserListResult.DepartmentName = department.Name;
  279. groupUserListResult.Name = user.Name;
  280. groupUserListResult.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
  281. return groupUserListResult;
  282. }, splitOn: "Name");
  283. return result;
  284. }
  285. /// <summary>
  286. /// 获取小组详情
  287. /// </summary>
  288. /// <param name="guId"></param>
  289. /// <param name="userId"></param>
  290. /// <returns></returns>
  291. public async Task<GroupDetailResult> GroupDetailByGuIdAsync(string guId, int userId)
  292. {
  293. var groupDetail = await _repository.GetAsync(Q.Where(nameof(Entity.Group.Guid), guId));
  294. if (groupDetail == null)
  295. throw new BusinessException("小组不存在");
  296. if (!string.IsNullOrEmpty(groupDetail.AvatarUrl))
  297. groupDetail.AvatarUrl = StringUtils.AddDomainMin(groupDetail.AvatarUrl);
  298. if (!string.IsNullOrEmpty(groupDetail.QRCoder))
  299. groupDetail.QRCoder = StringUtils.AddDomain(groupDetail.QRCoder);
  300. var sql =
  301. "SELECT a.*,b.Name,b.AvatarUrl,c.Name FROM tede_group_user a inner join tede_user b on a.UserId=b.Id inner join tede_department c on b.DepartmentId=c.Id where a.GroupId=@groupId";
  302. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  303. var database = new Database(databaseType, _connectionString);
  304. var connection = database.GetConnection();
  305. var result =
  306. await connection
  307. .QueryAsync<GroupUserListResult, User, Department, GroupUserListResult>(sql,
  308. (groupUserListResult, user, department) =>
  309. {
  310. groupUserListResult.DepartmentName = department.Name;
  311. groupUserListResult.Name = user.Name;
  312. groupUserListResult.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
  313. return groupUserListResult;
  314. }, new { groupId = groupDetail.Id }, splitOn: "Name");
  315. var groupDetailResult = _mapper.Map<GroupDetailResult>(groupDetail);
  316. groupDetailResult.GroupUserListResult = result;
  317. var groupUser = await _groupUserRepository.GetAsync(Q.Where(nameof(GroupUser.UserId), userId)
  318. .Where(nameof(GroupUser.Guid), guId));
  319. groupDetailResult.GroupUserRoleId = groupUser?.GroupUserRoleId ?? GroupUserRoleTyeConst.General;
  320. //获取当前用户的权限
  321. return groupDetailResult;
  322. }
  323. /// <summary>
  324. /// 获取用户未读取话题数量
  325. /// </summary>
  326. /// <param name="userId"></param>
  327. /// <param name="groupId"></param>
  328. /// <returns></returns>
  329. public async Task<int> GetUReadCountAsync(int userId, int groupId)
  330. {
  331. string sql =
  332. @"select count(1) from tede_topic a inner join tede_topic_addressee b on a.Id=b.TopicId where b.UserId=@userId and b.IsRead=0 and a.GroupId=@groupId";
  333. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  334. var database = new Database(databaseType, _connectionString);
  335. var connection = database.GetConnection();
  336. var result = await connection.ExecuteScalarAsync<int>(sql, new { userId, groupId });
  337. return result;
  338. }
  339. /// <summary>
  340. /// 获取小组的共享话题数量
  341. /// </summary>
  342. /// <param name="groupId"></param>
  343. /// <returns></returns>
  344. public async Task<int> SharingCountAsync(int groupId)
  345. {
  346. var sql =
  347. $"select count(1) from tede_group_user where GroupId={groupId}";
  348. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  349. var database = new Database(databaseType, _connectionString);
  350. var connection = database.GetConnection();
  351. var result = await connection.ExecuteScalarAsync<int>(sql, new { GroupId = groupId });
  352. return result;
  353. }
  354. public async Task<Entity.Group> GetAsync(int id)
  355. {
  356. return await _repository.GetAsync(id);
  357. }
  358. /// <summary>
  359. /// 是开启管理员同意加入
  360. /// </summary>
  361. /// <param name="groupId"></param>
  362. /// <returns></returns>
  363. public async Task<bool> SetGroupIsAdminAsync(int groupId)
  364. {
  365. var group = await GetAsync(groupId);
  366. return await _repository.UpdateAsync(Q.Set(nameof(Entity.Group.IsAdmin), !group.IsAdmin)
  367. .Where(nameof(Entity.Group.Id), groupId)) > 0;
  368. }
  369. /// <summary>
  370. /// 是否禁言
  371. /// </summary>
  372. /// <param name="groupId"></param>
  373. /// <returns></returns>
  374. public async Task<bool> SetGroupIsWordsAsync(int groupId)
  375. {
  376. var group = await GetAsync(groupId);
  377. return await _repository.UpdateAsync(Q.Set(nameof(Entity.Group.IsWords), !group.IsWords)
  378. .Where(nameof(Entity.Group.Id), groupId)) > 0;
  379. }
  380. public async Task<List<JobGroupResult>> ElasticSearchGroup()
  381. {
  382. var sql = "select a.Id,a.GuId,a.UserId,b.Id,b.Name,b.AvatarUrl,b.CreatedDate,c.Name from tede_middle a inner join tede_group b on a.MiddleId=b.Id inner join tede_user c on c.Id=b.UserId where a.FolderType=7 and a.IsUpload=0 order by a.CreatedDate desc limit 0,100";
  383. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  384. var database = new Database(databaseType, _connectionString);
  385. var connection = database.GetConnection();
  386. var items = await connection
  387. .QueryAsync<JobGroupResult, Entity.Group, User, JobGroupResult>(sql,
  388. (jobGroupResult, group, user) =>
  389. {
  390. jobGroupResult.MiddleId = jobGroupResult.Id;
  391. jobGroupResult.Id = group.Id;
  392. jobGroupResult.Name = group != null ? group.Name : "";
  393. jobGroupResult.AvatarUrl = group != null ? group.AvatarUrl : "";
  394. return jobGroupResult;
  395. },
  396. splitOn: "Id,Id,Name");
  397. return items.ToList();
  398. }
  399. /// <summary>
  400. /// 根据广场类别查询小组
  401. /// </summary>
  402. /// <param name="categoryId"></param>
  403. /// <returns></returns>
  404. public async Task<IEnumerable<Entity.Group>> GetAllAsync(int categoryId)
  405. {
  406. var sql = $@"SELECT
  407. *,
  408. (SELECT
  409. COUNT(1)
  410. FROM
  411. tede_group_user
  412. WHERE
  413. GroupId = a.Id) AS UserCount,
  414. (SELECT
  415. COUNT(1)
  416. FROM
  417. tede_topic
  418. WHERE
  419. GroupId = a.Id) AS GroupArticleCount
  420. FROM
  421. tede_group a
  422. WHERE
  423. a.GroupCategroyId = {categoryId} and a.IsShow=1";
  424. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  425. var database = new Database(databaseType, _connectionString);
  426. var connection = database.GetConnection();
  427. var result = await connection.QueryAsync<Entity.Group>(sql);
  428. //return await _repository.GetAllAsync(Q.Where(nameof(Entity.Group.GroupCategroyId), categoryId));
  429. return result;
  430. }
  431. /// <summary>
  432. /// 用户小组列表
  433. /// </summary>
  434. /// <param name="userId"></param>
  435. /// <returns></returns>
  436. public async Task<IEnumerable<UserGroupList>> GetAllByUserIdAsync(int userId)
  437. {
  438. string sql = $@"SELECT
  439. Id,
  440. Name,
  441. AvatarUrl,
  442. (SELECT
  443. COUNT(1)
  444. FROM
  445. tede_group_user
  446. WHERE
  447. GroupId = a.Id) AS UserCount
  448. FROM
  449. tede_group a
  450. WHERE
  451. a.id IN (SELECT
  452. GroupId
  453. FROM
  454. ccpph_tede.tede_group_user
  455. WHERE
  456. UserId = {userId})";
  457. var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
  458. var database = new Database(databaseType, _connectionString);
  459. var connection = database.GetConnection();
  460. var items = await connection
  461. .QueryAsync<UserGroupList>(sql);
  462. foreach (var item in items)
  463. {
  464. item.AvatarUrl = StringUtils.AddDomain(item.AvatarUrl);
  465. }
  466. return items;
  467. }
  468. }
  469. }