* 项目头像设置 * @interface /project/upset * @method POST * @category project * @foldnumber 10 * @param {Number} id 项目id,不能为空 * @param {String} icon 项目icon * @param {Array} color 项目color * @returns {Object} * @example ./api/project/upset
(ctx)
| 727 | * @example ./api/project/upset |
| 728 | */ |
| 729 | async upSet(ctx) { |
| 730 | let id = ctx.request.body.id; |
| 731 | let data = {}; |
| 732 | if ((await this.checkAuth(id, 'project', 'danger')) !== true) { |
| 733 | return (ctx.body = yapi.commons.resReturn(null, 405, '没有权限')); |
| 734 | } |
| 735 | data.color = ctx.request.body.color; |
| 736 | data.icon = ctx.request.body.icon; |
| 737 | if (!id) { |
| 738 | return (ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空')); |
| 739 | } |
| 740 | try { |
| 741 | let result = await this.Model.up(id, data); |
| 742 | ctx.body = yapi.commons.resReturn(result); |
| 743 | } catch (e) { |
| 744 | ctx.body = yapi.commons.resReturn(null, 402, e.message); |
| 745 | } |
| 746 | try { |
| 747 | this.followModel.updateById(this.getUid(), id, data).then(() => { |
| 748 | let username = this.getUsername(); |
| 749 | yapi.commons.saveLog({ |
| 750 | content: `<a href="/user/profile/${this.getUid()}">${username}</a> 修改了项目图标、颜色`, |
| 751 | type: 'project', |
| 752 | uid: this.getUid(), |
| 753 | username: username, |
| 754 | typeid: id |
| 755 | }); |
| 756 | }); |
| 757 | } catch (e) { |
| 758 | yapi.commons.log(e, 'error'); // eslint-disable-line |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * 编辑项目 |
nothing calls this directly
no test coverage detected