|
|
|
@ -89,6 +89,23 @@ func (p *PhotoHandler) CreatePhoto(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
return p.PhotoService.ConvertToDTO(ctx, photo), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PhotoHandler) CreatePhotoBatch(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
photosParam := make([]*param.Photo, 0)
|
|
|
|
|
err := ctx.ShouldBindJSON(&photosParam)
|
|
|
|
|
if err != nil {
|
|
|
|
|
e := validator.ValidationErrors{}
|
|
|
|
|
if errors.As(err, &e) {
|
|
|
|
|
return nil, xerr.WithStatus(e, xerr.StatusBadRequest).WithMsg(trans.Translate(e))
|
|
|
|
|
}
|
|
|
|
|
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("parameter error")
|
|
|
|
|
}
|
|
|
|
|
photos, err := p.PhotoService.CreateBatch(ctx, photosParam)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return p.PhotoService.ConvertToDTOs(ctx, photos), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PhotoHandler) UpdatePhoto(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
id, err := util.ParamInt32(ctx, "id")
|
|
|
|
|
if err != nil {
|
|
|
|
|