package com.tuoheng.admin.controller; | package com.tuoheng.admin.controller; | ||||
import com.tuoheng.admin.entity.domain.Camera; | |||||
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | ||||
import com.tuoheng.admin.service.camera.ICameraService; | import com.tuoheng.admin.service.camera.ICameraService; | ||||
import com.tuoheng.common.common.OperationEnum; | |||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import com.tuoheng.system.utils.ShiroUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.PathVariable; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import org.springframework.web.bind.annotation.*; | |||||
/** | /** | ||||
* @desc: 摄像头 前端控制器 | * @desc: 摄像头 前端控制器 | ||||
return cameraService.getOneById(id); | return cameraService.getOneById(id); | ||||
} | } | ||||
/** | |||||
* 添加摄像头 | |||||
* | |||||
* @param entity 实体对象 | |||||
* @return | |||||
*/ | |||||
@PostMapping("/add") | |||||
public JsonResult add(@RequestBody Camera entity) { | |||||
return cameraService.editInfo(entity); | |||||
} | |||||
/** | |||||
* 编辑摄像头 | |||||
* | |||||
* @param entity 实体对象 | |||||
* @return | |||||
*/ | |||||
@PutMapping("/edit") | |||||
public JsonResult edit(@RequestBody Camera entity) { | |||||
return cameraService.editInfo(entity); | |||||
} | |||||
/** | |||||
* 删除摄像头 | |||||
* | |||||
* @param ids 摄像头ID | |||||
* @return | |||||
*/ | |||||
@DeleteMapping("/delete/{ids}") | |||||
public JsonResult delete(@PathVariable("ids") Integer[] ids) { | |||||
return cameraService.deleteByIds(ids); | |||||
} | |||||
} | } |
package com.tuoheng.admin.service.camera; | package com.tuoheng.admin.service.camera; | ||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.tuoheng.admin.entity.domain.Camera; | |||||
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | ||||
import com.tuoheng.admin.mapper.CameraMapper; | |||||
import com.tuoheng.admin.service.camera.query.QueryCameraListService; | import com.tuoheng.admin.service.camera.query.QueryCameraListService; | ||||
import com.tuoheng.admin.utils.GaodeUtil; | |||||
import com.tuoheng.common.common.BaseServiceImpl; | |||||
import com.tuoheng.common.common.OperationEnum; | |||||
import com.tuoheng.common.exception.ServiceException; | |||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import com.tuoheng.common.utils.StringUtils; | |||||
import com.tuoheng.system.utils.ShiroUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
* @date 2023-02-06 | * @date 2023-02-06 | ||||
*/ | */ | ||||
@Service | @Service | ||||
public class CameraServiceImpl implements ICameraService { | |||||
public class CameraServiceImpl extends BaseServiceImpl<CameraMapper, Camera> implements ICameraService { | |||||
@Autowired | @Autowired | ||||
private QueryCameraListService queryCameraListService; | private QueryCameraListService queryCameraListService; | ||||
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public JsonResult editInfo(Camera entity) { | |||||
//新增 | |||||
if (StringUtils.isNull(entity.getId())) { | |||||
if (StringUtils.isEmpty(entity.getCameraName())) { | |||||
throw new ServiceException(0, "摄像头名称不能为空"); | |||||
} | |||||
if (ObjectUtil.isEmpty(entity.getCameraType())) { | |||||
throw new ServiceException(0, "设备类型不能为空"); | |||||
} | |||||
if (StringUtils.isEmpty(entity.getLongitude())) { | |||||
throw new ServiceException(0, "经度不能为空"); | |||||
} | |||||
if (StringUtils.isEmpty(entity.getLatitude())) { | |||||
throw new ServiceException(0, "纬度不能为空"); | |||||
} | |||||
if (StringUtils.isEmpty(entity.getFlvUrl())) { | |||||
throw new ServiceException(0, "摄像头地址不能为空"); | |||||
} | |||||
} | |||||
if(StringUtils.isNotEmpty(entity.getLongitude()) && StringUtils.isNotEmpty(entity.getLatitude())){ | |||||
String gaodeAddress = GaodeUtil.getGaodeAddress(entity.getLongitude(), entity.getLatitude()); | |||||
entity.setLocation(gaodeAddress); | |||||
} | |||||
super.edit(entity); | |||||
return JsonResult.success(); | |||||
} | |||||
} | } |
package com.tuoheng.admin.service.camera; | package com.tuoheng.admin.service.camera; | ||||
import com.tuoheng.admin.entity.domain.Camera; | |||||
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | ||||
import com.tuoheng.common.common.IBaseService; | |||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
/** | /** | ||||
* @author wanjing | * @author wanjing | ||||
* @date 2023-02-06 | * @date 2023-02-06 | ||||
*/ | */ | ||||
public interface ICameraService { | |||||
public interface ICameraService extends IBaseService<Camera> { | |||||
/** | /** | ||||
* 查询摄像头列表 | * 查询摄像头列表 | ||||
* @return 摄像头 | * @return 摄像头 | ||||
*/ | */ | ||||
JsonResult getOneById(Integer id); | JsonResult getOneById(Integer id); | ||||
/** | |||||
* 新增或编辑摄像头 | |||||
* @param entity | |||||
* @return | |||||
*/ | |||||
JsonResult editInfo(Camera entity); | |||||
} | } |