Skip to content

Commit

Permalink
Merge pull request #7 from antespajic/image_service_polish
Browse files Browse the repository at this point in the history
Image service polish
  • Loading branch information
hrvojebusic authored Apr 7, 2017
2 parents a6025d7 + a8725c4 commit 9edc056
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 128 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@
* **Error response:** will be elaborated at a later time

#### Image removal
* **Note:** Image name parameter is not needed when removing user's profile picture.
* **URL:** `/image/:resource/:id/:imageName`
* **Method:** `DELETE`
* **URL paramteres:** `resource = ['user','wish','story']`, `id = String`, `imageName = String`
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/hr/asc/appic/controller/ImageController.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package hr.asc.appic.controller;

import hr.asc.appic.controller.model.ImagePathModel;
import hr.asc.appic.service.image.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;

import hr.asc.appic.controller.model.ImagePathModel;
import hr.asc.appic.service.image.ImageService;

@RestController
@RequestMapping("/image")
public class ImageController {
Expand Down Expand Up @@ -45,13 +40,12 @@ public DeferredResult<ResponseEntity<ImagePathModel>> setUserPhoto(
}

@RequestMapping(
value = "/user/{id}/{imageName}",
value = "/user/{id}",
method = RequestMethod.DELETE
)
public DeferredResult<ResponseEntity> deleteUserPhoto(
@PathVariable("id") String id,
@PathVariable("imageName") String imageName) {
return imageService.deleteUserPhoto(id, imageName);
@PathVariable("id") String id) {
return imageService.deleteUserPhoto(id);
}

// ==================== WISH ==================== //
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/hr/asc/appic/controller/model/ImagePathModel.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package hr.asc.appic.controller.model;

import java.util.Collections;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Collections;
import java.util.List;

@Getter
@Setter
@AllArgsConstructor
Expand All @@ -21,6 +21,11 @@ public class ImagePathModel {

public ImagePathModel(String id, String path) {
this.id = id;
this.paths = Collections.singletonList(path);

if (path == null) {
paths = Collections.emptyList();
} else {
paths = Collections.singletonList(path);
}
}
}
Loading

0 comments on commit 9edc056

Please sign in to comment.