Skip to content

Commit

Permalink
feat: 创建应用时检查 name 冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Nov 25, 2023
1 parent b93adc9 commit 1f58c5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/api/callback/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var (
}
ErrAppNameExist = &Msg{
Code: cErrAppNameExist,
Msg: "名称已被占用",
Msg: "应用名称已被占用",
HttpStatus: 409,
}
ErrGroupNotFound = &Msg{
Expand Down
9 changes: 9 additions & 0 deletions internal/api/controllers/user/dev/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ func ApplyApp(c *gin.Context) {
}
defer appSrv.Rollback()

exist, err := appSrv.NameExist(f.Name, daoUtil.LockForUpdate)
if err != nil {
callback.Error(c, callback.ErrDBOperation, err)
return
} else if exist {
callback.Error(c, callback.ErrAppNameExist)
return
}

uid := tools.GetUserInfo(c).ID
newApp, err := appSrv.New(uid, f.Name, f.Callback, f.PermitAll)
if err != nil {
Expand Down

0 comments on commit 1f58c5e

Please sign in to comment.