1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package com.sysu.admin.controller.geo;
- import com.sysu.admin.controller.crop.CropLand;
- import com.sysu.admin.controller.crop.CropLandService;
- import com.sysu.admin.controller.crop.CropLandVo;
- import com.sysu.admin.controller.geo.land.LandTaskStatus;
- import com.sysu.admin.support.shiro.ShiroService;
- import com.sysu.admin.utils.shape.GeoCastUtil;
- import com.xiesx.fastboot.base.result.BaseResult;
- import com.xiesx.fastboot.base.result.R;
- import com.xiesx.fastboot.utils.CopyUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.Date;
- /**
- * 读取地图数据信息
- */
- @RequestMapping("/crop")
- @RestController
- public class CropLandController {
- @Autowired
- CropLandService cityLandService;
- @Autowired
- ShiroService shiroService;
- @RequestMapping("/getInfo")
- public BaseResult getInfo(Double x, Double y){
- CropLand cityLand = cityLandService.findByPoint(x,y);
- if(cityLand == null){
- return R.fail();
- }
- cityLand.setWkt(GeoCastUtil.geomToWkt(cityLand.getGeom()));
- return R.succ(cityLand);
- }
- @RequestMapping("/save")
- @ResponseBody
- public BaseResult save(CropLandVo vo){
- CropLand bean = cityLandService.findOne(vo.getId());
- if(bean.getStatus().intValue() == LandTaskStatus.unpublished.ordinal()){
- bean.setCreator(shiroService.getPrincipalId());
- bean.setCreateDate(new Date());
- }
- BeanUtils.copyProperties(vo, bean, CopyUtils.nullNames(vo));
- bean.setWkt(GeoCastUtil.geomToWkt(bean.getGeom()));
- cityLandService.save(bean);
- return R.succ(bean);
- }
- }
|