guhongwei 4 年之前
父节点
当前提交
7d645d8fd1
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      app/service/user.js

+ 7 - 4
app/service/user.js

@@ -180,11 +180,14 @@ class UserService extends CrudService {
    * @param {Object} {id} 只接收id,不过需要解构,因为是object形式过来的
    */
   async delete({ id }) {
-    const data = await this.model.findById(id);
-    if (!data) {
-      throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
+    const res = await this.model.update({ _id: ObjectId(id) }, { isdel: '1' });
+    if (res) {
+      const url = this.ctx.app.config.axios.product;
+      const arr = await url.model.updateMany({ userid: ObjectId(id) }, { isdel: '1' });
+      if (arr) {
+        return arr;
+      }
     }
-    const res = await data.update({ isdel: '1' });
     return res;
   }
 }