好友:拉黑

This commit is contained in:
luying
2021-02-03 11:49:46 +08:00
parent 585a741be5
commit 2d2c9907ab
7 changed files with 194 additions and 14 deletions
+10 -2
View File
@@ -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 }] });