JujaLabs / juja-platform

0 stars 7 forks source link

Add 'Remove' link endpoint #56

Open ivshapovalov opened 6 years ago

ivshapovalov commented 6 years ago
Task 'As a user I want to hide my link in the storage using link id'
Microservice - LINKS
Subtask 'Add 'hide' link endpoint' from milestone
https://github.com/JujaLabs/juja-platform/milestones/2

1) What is this feature/fix provided for?
    Microservice obtain from external service request to hide particular link of particular owner.
    Microservice respond hidden link entity in json or message "You have no link with id '...'"

2) List the objects you want to add or change, use appropriate API annotations
    Controller 
        Add method
            @ApiOperation(value = "Hide user's link", notes = "Returns a hidden Link entity or Exception message", response = Link.class, tags={  })
            @ApiResponses(value = {
                    @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Successfully hide new link"),
                    @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad request"),
                    @ApiResponse(code = HttpURLConnection.HTTP_BAD_METHOD, message = "Bad method"),
                    @ApiResponse(code = HttpURLConnection.HTTP_UNSUPPORTED_TYPE, message = "Unsupported request media type")
            })
            @PutMapping(consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
            public ResponseEntity hideLink(@Valid @RequestBody HideLinkRequest request) throws Exception {
            }
    Model
              Add class HideLinkRequest
               @ApiModel 
               public class HideLinkRequest

              @ApiModelProperty(value = "A person who saves this link, used to identify while changing/archiving", required = true)
              public String owner   

              @ApiModelProperty(value = "A unique id of the link, used to identify", required = true)
              public String id  

             Update class Link
                  @ApiModelProperty(value = "Flag means link is hidden or active, ", required = false)
              public boolean hidden 

    Service
        Add method Link hideLink(HideLinkRequest request);
    Repository
        Add method List getLinkByOwnerAndId(String owner, String id);
3) Are there any special requirements or constraints?
    Service check existing link with certain id and owner:
        If link exists - mark boolean 'hidden', and return hidden link entity
        Otherwise  - Throw new NotFoundException 'You have no link with id '...'
    Exception handler:
        Handle NotFoundException and return message with Exception message to external service.

Benkoff commented 6 years ago

The task has been changed. Old text marked with strike-out.

Benkoff commented 6 years ago

Original text restored. The task has to be changed to fit the actual code