|
@@ -1133,5 +1133,38 @@ namespace GxPress.Repository.Implement
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取小组用户
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<IEnumerable<GroupUserListResult>> GetGroupUsersAsync(GroupUserFindRequest request)
|
|
|
+ {
|
|
|
+ var userCount = new SqlKata.Query("tede_user");
|
|
|
+ userCount.Where("Id", ">", 0).AsCount("Id");
|
|
|
+ var query = new SqlKata.Query("tede_user");
|
|
|
+ query.Join("tede_department as a", "a.Id", "tede_user.DepartmentId");
|
|
|
+ query.Join("tede_group_user as b", "b.UserId", "tede_user.Id");
|
|
|
+ query.Where("b.GroupId", "=", request.GroupId);
|
|
|
+ if (!string.IsNullOrEmpty(request.KeyWord))
|
|
|
+ query.Where(n => n.OrWhereLike("tede_user.Name", $"%{request.KeyWord}").OrWhereLike("tede_user.Phone", $"%{request.KeyWord}").OrWhereLike("tede_user.Email", $"%{request.KeyWord}"));
|
|
|
+ if (request.TypeId == 1)
|
|
|
+ query.WhereIn("b.GroupUserRoleId", new List<int> { 1, 2 });
|
|
|
+ if (request.TypeId == 2)
|
|
|
+ query.Where("b.GroupUserRoleId", 3);
|
|
|
+ query.Select(
|
|
|
+ "b.{Id, GroupUserRoleId, CreatedDate,GroupId}",
|
|
|
+ "tede_user.{Id AS UserId, Name, AvatarUrl,Email,ImId}",
|
|
|
+ "a.{Name AS DepartmentName}");
|
|
|
+ query.Select(userCount, "UserCount");
|
|
|
+ var result = await _repository.GetAllAsync<GroupUserListResult>(query);
|
|
|
+ foreach (var item in result)
|
|
|
+ {
|
|
|
+ item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
|
|
|
+ item.Email = string.IsNullOrEmpty(item.Email) ? string.Empty : item.Email;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
}
|