ページURLが他と重複してたらエラーを投げるように (#5354)
* [Page]nameが重複したときの処理を追加 * page-editor側のerr.idにuuidを適用 * refactor * uuidをわけた
This commit is contained in:
@ -76,6 +76,11 @@ export const meta = {
|
||||
code: 'NO_SUCH_FILE',
|
||||
id: 'b7b97489-0f66-4b12-a5ff-b21bd63f6e1c'
|
||||
},
|
||||
nameAlreadyExists: {
|
||||
message: 'Specified name already exists.',
|
||||
code: 'NAME_ALREADY_EXISTS',
|
||||
id: '4650348e-301c-499a-83c9-6aa988c66bc1'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -92,6 +97,15 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
}
|
||||
|
||||
await Pages.find({
|
||||
userId: user.id,
|
||||
name: ps.name
|
||||
}).then(result => {
|
||||
if (result.length > 0) {
|
||||
throw new ApiError(meta.errors.nameAlreadyExists);
|
||||
}
|
||||
});
|
||||
|
||||
const page = await Pages.save(new Page({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
|
Reference in New Issue
Block a user