Refine panic framework.

This commit is contained in:
zicla
2018-11-30 19:38:46 +08:00
parent b55a993b35
commit 84703a8971
10 changed files with 88 additions and 113 deletions

View File

@ -48,7 +48,7 @@ func (this *ImageCacheController) Detail(writer http.ResponseWriter, request *ht
uuid := request.FormValue("uuid")
if uuid == "" {
return this.Error("图片缓存的uuid必填")
this.PanicBadRequest("图片缓存的uuid必填")
}
imageCache := this.imageCacheService.Detail(uuid)
@ -115,7 +115,7 @@ func (this *ImageCacheController) Delete(writer http.ResponseWriter, request *ht
uuid := request.FormValue("uuid")
if uuid == "" {
return this.Error("图片缓存的uuid必填")
this.PanicBadRequest("图片缓存的uuid必填")
}
imageCache := this.imageCacheDao.FindByUuid(uuid)
@ -123,7 +123,7 @@ func (this *ImageCacheController) Delete(writer http.ResponseWriter, request *ht
//判断图片缓存的所属人是否正确
user := this.checkUser(writer, request)
if user.Role != USER_ROLE_ADMINISTRATOR && imageCache.UserUuid != user.Uuid {
return this.Error(CODE_WRAPPER_UNAUTHORIZED)
this.PanicUnauthorized("没有权限")
}
this.imageCacheDao.Delete(imageCache)
@ -136,7 +136,7 @@ func (this *ImageCacheController) DeleteBatch(writer http.ResponseWriter, reques
uuids := request.FormValue("uuids")
if uuids == "" {
return this.Error("图片缓存的uuids必填")
this.PanicBadRequest("图片缓存的uuids必填")
}
uuidArray := strings.Split(uuids, ",")
@ -148,7 +148,7 @@ func (this *ImageCacheController) DeleteBatch(writer http.ResponseWriter, reques
//判断图片缓存的所属人是否正确
user := this.checkUser(writer, request)
if user.Role != USER_ROLE_ADMINISTRATOR && imageCache.UserUuid != user.Uuid {
return this.Error(CODE_WRAPPER_UNAUTHORIZED)
this.PanicUnauthorized("没有权限")
}
this.imageCacheDao.Delete(imageCache)