|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import javafx.scene.input.Mnemonic; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.ibatis.annotations.Update; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.CrossOrigin; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | 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.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | 
|---|
|  |  |  | import com.moral.api.entity.ManageCoordinate; | 
|---|
|  |  |  | import com.moral.api.mapper.ManageCoordinateMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.form.coordinate.CoordinateCode; | 
|---|
|  |  |  | import com.moral.api.service.ManageCoordinateService; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @Api(tags = {"添加路段模块"}) | 
|---|
|  |  |  | @RequestMapping("coordinate") | 
|---|
|  |  |  | @CrossOrigin(origins = "*", maxAge = 3600) | 
|---|
|  |  |  | public class ManageCoordinateController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 添加路段信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param params | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("interCruiserRoad") | 
|---|
|  |  |  | public ResultMessage interCruiserRoad(@RequestBody Map<String,Object> params){ | 
|---|
|  |  |  | if (!params.containsKey("startPoint") || !params.containsKey("endPoint")) { | 
|---|
|  |  |  | public ResultMessage interCruiserRoad(@RequestBody Map<String, Object> params) { | 
|---|
|  |  |  | if (!params.containsKey("startPoint") || !params.containsKey("mac")) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer integer = manageCoordinateService.interCoordinate(params); | 
|---|
|  |  |  | if (integer==null){ | 
|---|
|  |  |  | if (integer == null) { | 
|---|
|  |  |  | return ResultMessage.ok("路段已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改路段信息 | 
|---|
|  |  |  | * @param manageCoordinate | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param coordinateCode | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("updateCruiserRoad") | 
|---|
|  |  |  | public ResultMessage updateCruiserRoad(@RequestBody ManageCoordinate manageCoordinate){ | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(manageCoordinate)){ | 
|---|
|  |  |  | public ResultMessage updateCruiserRoad(@RequestBody CoordinateCode coordinateCode) { | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(coordinateCode)) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | manageCoordinateService.updateCoordinate(manageCoordinate); | 
|---|
|  |  |  | manageCoordinateService.updateCoordinate(coordinateCode); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除路段信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("deleteCruiserRoad") | 
|---|
|  |  |  | public ResultMessage deleteCruiser(Integer id){ | 
|---|
|  |  |  | if (id==null){ | 
|---|
|  |  |  | public ResultMessage deleteCruiser(Integer id) { | 
|---|
|  |  |  | if (id == null) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("selectCruiserRoad") | 
|---|
|  |  |  | public ResultMessage selectCruiser(){ | 
|---|
|  |  |  | List<ManageCoordinate> manageCoordinates = manageCoordinateService.selectCoordinate(); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(manageCoordinates)){ | 
|---|
|  |  |  | public ResultMessage selectCruiser(String name, String mac) { | 
|---|
|  |  |  | List<ManageCoordinate> manageCoordinates = manageCoordinateService.selectCoordinate(name, mac); | 
|---|
|  |  |  | return ResultMessage.ok(manageCoordinates); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据id查询路段信息 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("query") | 
|---|
|  |  |  | public ResultMessage query(Integer id){ | 
|---|
|  |  |  | ManageCoordinate manageCoordinate = manageCoordinateService.query(id); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(manageCoordinate)){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.TARGET_IS_NULL.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(manageCoordinates); | 
|---|
|  |  |  | return ResultMessage.ok(manageCoordinate); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|