| package com.moral.api.controller; | 
|   | 
|   | 
| 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") | 
| public class ManageCoordinateController { | 
|   | 
|     @Autowired | 
|     private ManageCoordinateService manageCoordinateService; | 
|   | 
|   | 
|   | 
|     /** | 
|      * 添加路段信息 | 
|      * | 
|      * @param params | 
|      * @return | 
|      */ | 
|     @PostMapping("interCruiserRoad") | 
|     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) { | 
|             return ResultMessage.ok("路段已存在"); | 
|         } | 
|         return ResultMessage.ok(); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 修改路段信息 | 
|      * | 
|      * @param coordinateCode | 
|      * @return | 
|      */ | 
|     @PostMapping("updateCruiserRoad") | 
|     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(coordinateCode); | 
|         return ResultMessage.ok(); | 
|     } | 
|   | 
|     /** | 
|      * 删除路段信息 | 
|      * | 
|      * @param id | 
|      * @return | 
|      */ | 
|     @GetMapping("deleteCruiserRoad") | 
|     public ResultMessage deleteCruiser(Integer id) { | 
|         if (id == null) { | 
|             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|                     ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|         } | 
|         manageCoordinateService.deleteCoordinate(id); | 
|         return ResultMessage.ok(); | 
|     } | 
|   | 
|     /** | 
|      * 查询路段信息 | 
|      * | 
|      * @return | 
|      */ | 
|     @GetMapping("selectCruiserRoad") | 
|     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(manageCoordinate); | 
|     } | 
|   | 
|   | 
|   | 
| } |