@@ -61,7 +61,7 @@ func (repositoryCtl RepositoryController) ListRepositoryOfAuthenticatedUser(ctx
6161 return
6262 }
6363
64- repositories , err := repositoryCtl .Repo .RepositoryRepo ().List (ctx , models .NewListRepoParams ().SetOwnerID (operator .ID ))
64+ repositories , err := repositoryCtl .Repo .RepositoryRepo ().List (ctx , models .NewListRepoParams ().SetOwnerID (operator .ID )) //operator is owner
6565 if err != nil {
6666 w .Error (err )
6767 return
@@ -131,7 +131,7 @@ func (repositoryCtl RepositoryController) CreateRepository(ctx context.Context,
131131 Name : body .Name ,
132132 Description : body .Description ,
133133 HEAD : defaultRef .Name ,
134- OwnerID : operator .ID ,
134+ OwnerID : operator .ID , // this api only create repo for operator
135135 CreatorID : operator .ID ,
136136 CreatedAt : time .Now (),
137137 UpdatedAt : time .Now (),
@@ -174,17 +174,22 @@ func (repositoryCtl RepositoryController) DeleteRepository(ctx context.Context,
174174 return
175175 }
176176
177- repo , err := repositoryCtl .Repo .RepositoryRepo ().Get (ctx , models .NewGetRepoParams ().SetName (repositoryName ).SetOwnerID (operator .ID ))
177+ repo , err := repositoryCtl .Repo .RepositoryRepo ().Get (ctx , models .NewGetRepoParams ().SetName (repositoryName ).SetOwnerID (owner .ID ))
178178 if err != nil {
179179 w .Error (err )
180180 return
181181 }
182182
183- err = repositoryCtl .Repo .RepositoryRepo ().Delete (ctx , models .NewDeleteRepoParams ().SetID (repo .ID ))
183+ affectRows , err : = repositoryCtl .Repo .RepositoryRepo ().Delete (ctx , models .NewDeleteRepoParams ().SetID (repo .ID ))
184184 if err != nil {
185185 w .Error (err )
186186 return
187187 }
188+
189+ if affectRows == 0 {
190+ w .NotFound ()
191+ return
192+ }
188193 w .OK ()
189194}
190195
@@ -247,7 +252,7 @@ func (repositoryCtl RepositoryController) UpdateRepository(ctx context.Context,
247252}
248253
249254func (repositoryCtl RepositoryController ) GetCommitsInRepository (ctx context.Context , w * api.JiaozifsResponse , _ * http.Request , ownerName string , repositoryName string , params api.GetCommitsInRepositoryParams ) {
250- user , err := auth .GetOperator (ctx )
255+ operator , err := auth .GetOperator (ctx )
251256 if err != nil {
252257 w .Error (err )
253258 return
@@ -259,7 +264,7 @@ func (repositoryCtl RepositoryController) GetCommitsInRepository(ctx context.Con
259264 return
260265 }
261266
262- if user .Name != ownerName { //todo check public or private
267+ if operator .Name != ownerName { //todo check public or private
263268 w .Forbidden ()
264269 return
265270 }
0 commit comments