guhongwei 4 years ago
parent
commit
7d645d8fd1
1 changed files with 7 additions and 4 deletions
  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;
   }
 }