Commit 7dc6fa7b authored by Imalka L.A.'s avatar Imalka L.A.

Get solution list using image

parent e4408473
package com.ceyloneagro.ceyloneagrobackendservice.controller; package com.ceyloneagro.ceyloneagrobackendservice.controller;
import org.springframework.web.bind.annotation.CrossOrigin; import com.ceyloneagro.ceyloneagrobackendservice.dto.response.BaseResponse;
import org.springframework.web.bind.annotation.RequestMapping; import com.ceyloneagro.ceyloneagrobackendservice.dto.response.SolutionsResponse;
import org.springframework.web.bind.annotation.RestController; import com.ceyloneagro.ceyloneagrobackendservice.enumeration.ApplicationStatus;
import com.ceyloneagro.ceyloneagrobackendservice.service.SolutionService;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
...@@ -12,5 +21,24 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -12,5 +21,24 @@ import org.springframework.web.bind.annotation.RestController;
public class DiseaseIdentifyController { public class DiseaseIdentifyController {
private final SolutionService solutionService;
public DiseaseIdentifyController(SolutionService solutionService) {
this.solutionService = solutionService;
}
@PostMapping (value = "/disease-solutions", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<BaseResponse<SolutionsResponse>> getSolutionList(HttpServletRequest request,@RequestParam
(value = "page", defaultValue = "0") int page, @RequestParam(value = "limit", defaultValue = "25") int limit,
@RequestBody MultipartFile file) {
SolutionsResponse response=solutionService.getSolutionList(page,limit,"blight");
BaseResponse<SolutionsResponse> baseResponse = new BaseResponse<>(ApplicationStatus.TOKEN_GENERATION_SUCCESS, response);
return new ResponseEntity<>(baseResponse, HttpStatus.OK);
}
} }
...@@ -6,11 +6,8 @@ import lombok.Getter; ...@@ -6,11 +6,8 @@ import lombok.Getter;
public enum ApplicationStatus { public enum ApplicationStatus {
TOKEN_GENERATION_SUCCESS("S-000", "New user token generated."), TOKEN_GENERATION_SUCCESS("S-000", "Solution List Fetched Succesfully."),
TOKEN_GENERATION_FAILED("F-000", "User token generation failed."), TOKEN_GENERATION_FAILED("F-000", "Solution List Fetched Failed.");
USER_REGISTRATION_SUCCESS("S-001", "New user has been successfully created."),
USER_REGISTRATION_FAILED("F-001", "User registration failed.");
private String code; private String code;
private String message; private String message;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment