好友:拉黑
This commit is contained in:
+10
-2
@@ -69,16 +69,24 @@ export default class FriendShip extends BaseModel {
|
||||
public static async createFriendShip(roleIdList: string[]) {
|
||||
if (roleIdList.length != 2) return false;
|
||||
let { roleIdA, roleIdB, roleIds } = this.getRoleIds(roleIdList);
|
||||
console.log(roleIdA, roleIdB, roleIds)
|
||||
|
||||
const doc = new FriendShipModel();
|
||||
const update = Object.assign(doc.toJSON(), { roleIdA, roleIdB, roleIds });
|
||||
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, update, { upsert: true, new: true }).lean();
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $setOnInsert: update }, { upsert: true, new: true }).lean();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 清空亲密度
|
||||
public static async clearValue(roleIdList: string[]) {
|
||||
if (roleIdList.length != 2) return false;
|
||||
let { roleIds } = this.getRoleIds(roleIdList);
|
||||
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $set: { friendValue: 0 } }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
// 查询关系
|
||||
public static async deleteAccount(roleId: string) {
|
||||
let result = await FriendShipModel.deleteMany({ $or: [{ roleIdA: roleId }, { roleIdB: roleId }] });
|
||||
|
||||
Reference in New Issue
Block a user