* 删除一个接口集 * @interface /col/del_col * @method GET * @category col * @foldnumber 10 * @param {String} * @returns {Object} * @example
(ctx)
| 780 | */ |
| 781 | |
| 782 | async delCol(ctx) { |
| 783 | try { |
| 784 | let id = ctx.query.col_id; |
| 785 | let colData = await this.colModel.get(id); |
| 786 | if (!colData) { |
| 787 | ctx.body = yapi.commons.resReturn(null, 400, '不存在的id'); |
| 788 | } |
| 789 | |
| 790 | if (colData.uid !== this.getUid()) { |
| 791 | let auth = await this.checkAuth(colData.project_id, 'project', 'danger'); |
| 792 | if (!auth) { |
| 793 | return (ctx.body = yapi.commons.resReturn(null, 400, '没有权限')); |
| 794 | } |
| 795 | } |
| 796 | let result = await this.colModel.del(id); |
| 797 | await this.caseModel.delByCol(id); |
| 798 | let username = this.getUsername(); |
| 799 | yapi.commons.saveLog({ |
| 800 | content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了接口集 ${ |
| 801 | colData.name |
| 802 | } 及其下面的接口`, |
| 803 | type: 'project', |
| 804 | uid: this.getUid(), |
| 805 | username: username, |
| 806 | typeid: colData.project_id |
| 807 | }); |
| 808 | return (ctx.body = yapi.commons.resReturn(result)); |
| 809 | } catch (e) { |
| 810 | yapi.commons.resReturn(null, 400, e.message); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * |