* * @param {*} ctx
(ctx)
| 817 | */ |
| 818 | |
| 819 | async delCase(ctx) { |
| 820 | try { |
| 821 | let caseid = ctx.query.caseid; |
| 822 | let caseData = await this.caseModel.get(caseid); |
| 823 | if (!caseData) { |
| 824 | ctx.body = yapi.commons.resReturn(null, 400, '不存在的caseid'); |
| 825 | } |
| 826 | |
| 827 | if (caseData.uid !== this.getUid()) { |
| 828 | let auth = await this.checkAuth(caseData.project_id, 'project', 'danger'); |
| 829 | if (!auth) { |
| 830 | return (ctx.body = yapi.commons.resReturn(null, 400, '没有权限')); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | let result = await this.caseModel.del(caseid); |
| 835 | |
| 836 | let username = this.getUsername(); |
| 837 | this.colModel.get(caseData.col_id).then(col => { |
| 838 | yapi.commons.saveLog({ |
| 839 | content: `<a href="/user/profile/${this.getUid()}">${username}</a> 删除了接口集 <a href="/project/${ |
| 840 | caseData.project_id |
| 841 | }/interface/col/${caseData.col_id}">${col.name}</a> 下的接口 ${caseData.casename}`, |
| 842 | type: 'project', |
| 843 | uid: this.getUid(), |
| 844 | username: username, |
| 845 | typeid: caseData.project_id |
| 846 | }); |
| 847 | }); |
| 848 | |
| 849 | this.projectModel.up(caseData.project_id, { up_time: new Date().getTime() }).then(); |
| 850 | return (ctx.body = yapi.commons.resReturn(result)); |
| 851 | } catch (e) { |
| 852 | yapi.commons.resReturn(null, 400, e.message); |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | async runCaseScript(ctx) { |
| 857 | let params = ctx.request.body; |