2020-03-23 16:46:27 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2020-03-17 11:41:38 +08:00
|
|
|
|
using System.Collections;
|
2020-03-27 15:52:34 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2020-03-17 11:41:38 +08:00
|
|
|
|
using LeanCloud.Storage.Internal.Query;
|
|
|
|
|
|
2020-03-12 16:23:21 +08:00
|
|
|
|
namespace LeanCloud.Realtime {
|
|
|
|
|
public class LCIMConversationQuery {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
internal LCCompositionalCondition Condition {
|
|
|
|
|
get; private set;
|
|
|
|
|
}
|
2020-03-17 11:41:38 +08:00
|
|
|
|
|
|
|
|
|
private LCIMClient client;
|
|
|
|
|
|
|
|
|
|
public LCIMConversationQuery(LCIMClient client) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition = new LCCompositionalCondition();
|
2020-03-17 11:41:38 +08:00
|
|
|
|
this.client = client;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 等于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereEqualTo(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereEqualTo(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 不等于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereNotEqualTo(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereNotEqualTo(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包含
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="values"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereContainedIn(string key,
|
|
|
|
|
IEnumerable values) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereContainedIn(key, values);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包含全部
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="values"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereContainsAll(string key,
|
|
|
|
|
IEnumerable values) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereContainsAll(key, values);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery WhereExists(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereExists(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 不存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery WhereDoesNotExist(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereDoesNotExist(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 长度等于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="size"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereSizeEqualTo(string key,
|
|
|
|
|
int size) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereSizeEqualTo(key, size);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 大于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereGreaterThan(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereGreaterThan(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 大于等于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereGreaterThanOrEqualTo(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereGreaterThanOrEqualTo(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 小于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereLessThan(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereLessThan(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 小于等于
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereLessThanOrEqualTo(string key,
|
|
|
|
|
object value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereLessThanOrEqualTo(key, value);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 前缀
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="prefix"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public LCIMConversationQuery WhereStartsWith(string key,
|
|
|
|
|
string prefix) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereStartsWith(key, prefix);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 后缀
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="suffix"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery WhereEndsWith(string key, string suffix) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereEndsWith(key, suffix);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字符串包含
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="subString"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery WhereContains(string key, string subString) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.WhereContains(key, subString);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按 key 升序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery OrderBy(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.OrderBy(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按 key 降序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery OrderByDescending(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.OrderByDescending(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 拉取 key 的完整对象
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery Include(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.Include(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包含 key
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery Select(string key) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.Select(key);
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 跳过
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery Skip(int value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.Skip = value;
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 限制数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public LCIMConversationQuery Limit(int value) {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
Condition.Limit = value;
|
2020-03-17 11:41:38 +08:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WithLastMessageRefreshed {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 16:42:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查找
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2020-03-27 15:52:34 +08:00
|
|
|
|
public async Task<ReadOnlyCollection<LCIMConversation>> Find() {
|
2020-03-26 16:08:35 +08:00
|
|
|
|
return await client.ConversationController.Find(this);
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|