| | |
| | | import org.springblade.modules.farm.vo.FarmVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 农场控制器 |
| | |
| | | @ApiOperation(value = "详情", notes = "传入farm") |
| | | public R<Farm> detail(Farm farm) { |
| | | Farm detail = farmService.getOne(Condition.getQueryWrapper(farm)); |
| | | return R.data(detail); |
| | | } |
| | | |
| | | /** |
| | | * 详情信息(自定义查询) |
| | | */ |
| | | @GetMapping("/details") |
| | | public R<Farm> details(FarmVO farm) { |
| | | Farm detail = farmService.getFarmInfo(farm); |
| | | return R.data(detail); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入farm") |
| | | public R save(@Valid @RequestBody Farm farm) { |
| | | farm.setCreateTime(new Date()); |
| | | farm.setUpdateTime(new Date()); |
| | | return R.status(farmService.save(farm)); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入farm") |
| | | public R update(@Valid @RequestBody Farm farm) { |
| | | return R.status(farmService.updateById(farm)); |
| | | farm.setUpdateTime(new Date()); |
| | | //坐标转换 |
| | | if (null!=farm.getPosition() && !farm.getPosition().equals("")) { |
| | | //替换逗号为空格 |
| | | String sNull = farm.getPosition().replaceAll(",", " "); |
| | | //替换分号为逗号 |
| | | String replaceAll = sNull.replaceAll(";", ","); |
| | | farm.setPosition("'POLYGON((" + replaceAll + "))'"); |
| | | } |
| | | //更新并返回 |
| | | return R.status(farmService.updateFarmById(farm)); |
| | | } |
| | | |
| | | /** |