CropLandController.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.sysu.admin.controller.geo;
  2. import com.sysu.admin.controller.crop.CropLand;
  3. import com.sysu.admin.controller.crop.CropLandService;
  4. import com.sysu.admin.controller.crop.CropLandVo;
  5. import com.sysu.admin.controller.geo.land.LandTaskStatus;
  6. import com.sysu.admin.support.shiro.ShiroService;
  7. import com.sysu.admin.utils.shape.GeoCastUtil;
  8. import com.xiesx.fastboot.base.result.BaseResult;
  9. import com.xiesx.fastboot.base.result.R;
  10. import com.xiesx.fastboot.utils.CopyUtils;
  11. import org.springframework.beans.BeanUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.ResponseBody;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import java.util.Date;
  17. /**
  18. * 读取地图数据信息
  19. */
  20. @RequestMapping("/crop")
  21. @RestController
  22. public class CropLandController {
  23. @Autowired
  24. CropLandService cityLandService;
  25. @Autowired
  26. ShiroService shiroService;
  27. @RequestMapping("/getInfo")
  28. public BaseResult getInfo(Double x, Double y){
  29. CropLand cityLand = cityLandService.findByPoint(x,y);
  30. if(cityLand == null){
  31. return R.fail();
  32. }
  33. cityLand.setWkt(GeoCastUtil.geomToWkt(cityLand.getGeom()));
  34. return R.succ(cityLand);
  35. }
  36. @RequestMapping("/save")
  37. @ResponseBody
  38. public BaseResult save(CropLandVo vo){
  39. CropLand bean = cityLandService.findOne(vo.getId());
  40. if(bean.getStatus().intValue() == LandTaskStatus.unpublished.ordinal()){
  41. bean.setCreator(shiroService.getPrincipalId());
  42. bean.setCreateDate(new Date());
  43. }
  44. BeanUtils.copyProperties(vo, bean, CopyUtils.nullNames(vo));
  45. bean.setWkt(GeoCastUtil.geomToWkt(bean.getGeom()));
  46. cityLandService.save(bean);
  47. return R.succ(bean);
  48. }
  49. }