Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mycompany.geocoordinate.controller; import com.fasterxml.jackson.databind.ObjectMapper; import com.mycompany.geocoordinate.mappers.CoordinateMapper; import com.mycompany.geocoordinate.model.GeoObject; import com.mycompany.geocoordinate.model.GeoType; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; /** * * @author andrey */ @Controller @RequestMapping("/") @Configuration public class LineController { @Autowired private CoordinateMapper coordinateMapper; @ResponseStatus(HttpStatus.CREATED) @PostMapping(value = "/line", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResponseEntity<List<Integer>> line(@RequestBody GeoObject geoObject) { boolean check = coordinateMapper.isThereGeoObjectFromLinetype(GeoType.GEOLINE) != null & coordinateMapper.selectCoordinateForLineorCircle(geoObject.getCoordinate()) != null; coordinateMapper.insertCoordinateForLine(GeoObject.getGEOLINE(), geoObject.getCoordinate()); List<Integer> responseType = coordinateMapper.selectIdGeo(geoObject.getCoordinate()); return ResponseEntity.status(HttpStatus.CREATED).body(responseType); } }