MCPcopy Index your code
hub / github.com/YMFE/yapi / checkProjectName

Method checkProjectName

server/controllers/project.js:154–172  ·  view source on GitHub ↗

* 判断分组名称是否重复 * @interface /project/check_project_name * @method get

(ctx)

Source from the content-addressed store, hash-verified

152 */
153
154 async checkProjectName(ctx) {
155 try {
156 let name = ctx.request.query.name;
157 let group_id = ctx.request.query.group_id;
158
159 if (!name) {
160 return (ctx.body = yapi.commons.resReturn(null, 401, '项目名不能为空'));
161 }
162 let checkRepeat = await this.Model.checkNameRepeat(name, group_id);
163
164 if (checkRepeat > 0) {
165 return (ctx.body = yapi.commons.resReturn(null, 401, '已存在的项目名'));
166 }
167
168 ctx.body = yapi.commons.resReturn({});
169 } catch (err) {
170 ctx.body = yapi.commons.resReturn(null, 402, err.message);
171 }
172 }
173
174 /**
175 * 添加项目分组

Callers 2

ProjectCard.jsFile · 0.80
tFunction · 0.80

Calls 1

checkNameRepeatMethod · 0.80

Tested by

no test coverage detected