MCPcopy
hub / github.com/YMFE/yapi / upTag

Method upTag

server/controllers/project.js:911–948  ·  view source on GitHub ↗

* 编辑项目 * @interface /project/up_tag * @method POST * @category project * @foldnumber 10 * @param {Number} id 项目id,不能为空 * @param {Array} [tag] 项目tag配置 * @param {String} [tag[].name] tag名称 * @param {String} [tag[].desc] tag描述 * @returns {Object} * @example

(ctx)

Source from the content-addressed store, hash-verified

909 * @example
910 */
911 async upTag(ctx) {
912 try {
913 let id = ctx.request.body.id;
914 let params = ctx.request.body;
915 if (!id) {
916 return (ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空'));
917 }
918
919 if ((await this.checkAuth(id, 'project', 'edit')) !== true) {
920 return (ctx.body = yapi.commons.resReturn(null, 405, '没有权限'));
921 }
922
923 if (!params.tag || !Array.isArray(params.tag)) {
924 return (ctx.body = yapi.commons.resReturn(null, 405, 'tag参数格式有误'));
925 }
926
927 let projectData = await this.Model.get(id);
928 let data = {
929 up_time: yapi.commons.time()
930 };
931 data.tag = params.tag;
932
933 let result = await this.Model.up(id, data);
934 let username = this.getUsername();
935 yapi.commons.saveLog({
936 content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/project/${id}/interface/api">${
937 projectData.name
938 }</a> 的tag`,
939 type: 'project',
940 uid: this.getUid(),
941 username: username,
942 typeid: id
943 });
944 ctx.body = yapi.commons.resReturn(result);
945 } catch (e) {
946 ctx.body = yapi.commons.resReturn(null, 402, e.message);
947 }
948 }
949
950 /**
951 * 获取项目的环境变量值

Callers

nothing calls this directly

Calls 5

getUsernameMethod · 0.80
checkAuthMethod · 0.45
getMethod · 0.45
upMethod · 0.45
getUidMethod · 0.45

Tested by

no test coverage detected