(ctx)
| 934 | } |
| 935 | |
| 936 | async upCat(ctx) { |
| 937 | try { |
| 938 | let params = ctx.request.body; |
| 939 | |
| 940 | let username = this.getUsername(); |
| 941 | let cate = await this.catModel.get(params.catid); |
| 942 | |
| 943 | let auth = await this.checkAuth(cate.project_id, 'project', 'edit'); |
| 944 | if (!auth) { |
| 945 | return (ctx.body = yapi.commons.resReturn(null, 400, '没有权限')); |
| 946 | } |
| 947 | |
| 948 | let result = await this.catModel.up(params.catid, { |
| 949 | name: params.name, |
| 950 | desc: params.desc, |
| 951 | up_time: yapi.commons.time() |
| 952 | }); |
| 953 | |
| 954 | yapi.commons.saveLog({ |
| 955 | content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了分类 <a href="/project/${ |
| 956 | cate.project_id |
| 957 | }/interface/api/cat_${params.catid}">${cate.name}</a>`, |
| 958 | type: 'project', |
| 959 | uid: this.getUid(), |
| 960 | username: username, |
| 961 | typeid: cate.project_id |
| 962 | }); |
| 963 | |
| 964 | ctx.body = yapi.commons.resReturn(result); |
| 965 | } catch (e) { |
| 966 | ctx.body = yapi.commons.resReturn(null, 400, e.message); |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | async delCat(ctx) { |
| 971 | try { |
nothing calls this directly
no test coverage detected