|
package org.springblade.modules.electronrail.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.ApiParam;
|
import lombok.AllArgsConstructor;
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.modules.electronrail.entity.ElectronRail;
|
import org.springblade.modules.electronrail.service.ElectronRailService;
|
import org.springblade.modules.electronrail.vo.ElectronRailVO;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
|
/**
|
* 电子围栏控制器
|
* @author zhongrj
|
* @since 2022-03-03
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/electronRail")
|
public class ElectronRailController extends BladeController {
|
|
private final ElectronRailService electronRailService;
|
|
/**
|
* 详情
|
*/
|
@GetMapping("/detail")
|
public R<ElectronRail> detail(ElectronRail electronRail) {
|
ElectronRail detail = electronRailService.getOne(Condition.getQueryWrapper(electronRail));
|
return R.data(detail);
|
}
|
|
/**
|
* 分页
|
*/
|
@GetMapping("/list")
|
public R<IPage<ElectronRail>> list(ElectronRail electronRail, Query query) {
|
IPage<ElectronRail> pages = electronRailService.page(Condition.getPage(query), Condition.getQueryWrapper(electronRail));
|
return R.data(pages);
|
}
|
|
/**
|
* 自定义分页
|
*/
|
@GetMapping("/page")
|
public R<IPage<ElectronRailVO>> page(ElectronRailVO electronRail, Query query) {
|
IPage<ElectronRailVO> pages = electronRailService.selectElectronRailPage(Condition.getPage(query), electronRail);
|
return R.data(pages);
|
}
|
|
/**
|
* 新增
|
*/
|
@PostMapping("/save")
|
public R save(@RequestBody ElectronRail electronRail) {
|
//设置时间
|
electronRail.setCreateTime(new Date());
|
electronRail.setUpdateTime(new Date());
|
if (null!=electronRail.getCoordinate() && !electronRail.getCoordinate().equals("")) {
|
//替换逗号为空格
|
String sNull = electronRail.getCoordinate().replaceAll(",", " ");
|
//替换分号为逗号
|
String replaceAll = sNull.replaceAll(";", ",");
|
electronRail.setCoordinate("'POLYGON((" + replaceAll + "))'");
|
}
|
//自定义新增
|
return R.data(electronRailService.saveElectRailInfo(electronRail));
|
}
|
|
|
/**
|
* 修改
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody ElectronRail electronRail) {
|
//设置更新时间
|
electronRail.setUpdateTime(new Date());
|
if (null!=electronRail.getCoordinate() && !electronRail.getCoordinate().equals("")) {
|
//替换逗号为空格
|
String sNull = electronRail.getCoordinate().replaceAll(",", " ");
|
//替换分号为逗号
|
String replaceAll = sNull.replaceAll(";", ",");
|
electronRail.setCoordinate("'POLYGON((" + replaceAll + "))'");
|
}
|
//自定义修改并返回
|
return R.data(electronRailService.updateElectronRailInfo(electronRail));
|
}
|
|
/**
|
* 新增或修改
|
*/
|
@PostMapping("/submit")
|
public R submit(@RequestBody ElectronRail electronRail) {
|
return R.status(electronRailService.saveOrUpdate(electronRail));
|
}
|
|
|
/**
|
* 删除
|
*/
|
@PostMapping("/remove")
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
return R.status(electronRailService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 判断一个点是否在区域内
|
* @param electronRail
|
* @return
|
*/
|
@GetMapping("/isOnArea")
|
public R isOnArea(ElectronRailVO electronRail){
|
return R.data(electronRailService.isOnArea(electronRail));
|
}
|
|
|
}
|