|
@@ -0,0 +1,143 @@
|
|
|
+package com.zjugis.yzt.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.zjugis.yzt.service.TempLandService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.zjugis.yzt.beans.vo.TempLandVO;
|
|
|
+import com.zjugis.yzt.beans.entity.TempLand;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Date;
|
|
|
+import org.springframework.format.annotation.DateTimeFormat;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/templand")
|
|
|
+public class TempLandController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TempLandService tempLandService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取临时用地信息(分页)
|
|
|
+ * @param current 当前页码
|
|
|
+ * @param size 每页大小
|
|
|
+ * @param xmmc 项目名称
|
|
|
+ * @param pzwh 批复文号
|
|
|
+ * @param yddw 用地单位
|
|
|
+ * @param pzmj 批准面积
|
|
|
+ * @param pzdw 批准单位
|
|
|
+ * @param zlwz 坐落位置
|
|
|
+ * @param dqsjStart 到期时间开始
|
|
|
+ * @param dqsjEnd 到期时间结束
|
|
|
+ * @return 分页结果
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public IPage<TempLandVO> getTempLandList(
|
|
|
+ @RequestParam(defaultValue = "1") Integer current,
|
|
|
+ @RequestParam(defaultValue = "10") Integer size,
|
|
|
+ @RequestParam(required = false) String xmmc,
|
|
|
+ @RequestParam(required = false) String pzwh,
|
|
|
+ @RequestParam(required = false) String yddw,
|
|
|
+ @RequestParam(required = false) Double pzmj,
|
|
|
+ @RequestParam(required = false) String pzdw,
|
|
|
+ @RequestParam(required = false) String zlwz,
|
|
|
+ @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date dqsjStart,
|
|
|
+ @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date dqsjEnd) {
|
|
|
+
|
|
|
+ QueryWrapper<TempLand> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (xmmc != null && !xmmc.isEmpty()) {
|
|
|
+ queryWrapper.like("xmmc", xmmc);
|
|
|
+ }
|
|
|
+ if (pzwh != null && !pzwh.isEmpty()) {
|
|
|
+ queryWrapper.like("pzwh", pzwh);
|
|
|
+ }
|
|
|
+ if (yddw != null && !yddw.isEmpty()) {
|
|
|
+ queryWrapper.like("yddw", yddw);
|
|
|
+ }
|
|
|
+ if (pzmj != null) {
|
|
|
+ queryWrapper.eq("pzmj", pzmj);
|
|
|
+ }
|
|
|
+ if (pzdw != null && !pzdw.isEmpty()) {
|
|
|
+ queryWrapper.like("pzdw", pzdw);
|
|
|
+ }
|
|
|
+ if (zlwz != null && !zlwz.isEmpty()) {
|
|
|
+ queryWrapper.like("zlwz", zlwz);
|
|
|
+ }
|
|
|
+ // 到期时间区间查询
|
|
|
+ if (dqsjStart != null) {
|
|
|
+ queryWrapper.ge("dqsj", dqsjStart);
|
|
|
+ }
|
|
|
+ if (dqsjEnd != null) {
|
|
|
+ queryWrapper.le("dqsj", dqsjEnd);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<TempLand> page = new Page<>(current, size);
|
|
|
+ IPage<TempLand> tempLandPage = tempLandService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return tempLandPage.convert(this::convertToVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID获取临时用地信息
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public TempLandVO getTempLandById(@PathVariable Integer id) {
|
|
|
+ TempLand tempLand = tempLandService.getById(id);
|
|
|
+ return convertToVO(tempLand);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增临时用地
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public boolean addTempLand(@RequestBody TempLandVO tempLandVO) {
|
|
|
+ TempLand tempLand = new TempLand();
|
|
|
+ BeanUtils.copyProperties(tempLandVO, tempLand);
|
|
|
+ return tempLandService.save(tempLand);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新临时用地
|
|
|
+ */
|
|
|
+ @PutMapping("/update")
|
|
|
+ public boolean updateTempLand(@RequestBody TempLandVO tempLandVO) {
|
|
|
+ if (tempLandVO.getObjectid() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ TempLand tempLand = new TempLand();
|
|
|
+ BeanUtils.copyProperties(tempLandVO, tempLand);
|
|
|
+ return tempLandService.updateById(tempLand);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除临时用地
|
|
|
+ */
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ public boolean deleteTempLand(@PathVariable Integer id) {
|
|
|
+ return tempLandService.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除临时用地
|
|
|
+ */
|
|
|
+ @DeleteMapping("/batch")
|
|
|
+ public boolean batchDeleteTempLand(@RequestBody List<Integer> ids) {
|
|
|
+ return tempLandService.removeByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将实体对象转换为VO对象
|
|
|
+ */
|
|
|
+ private TempLandVO convertToVO(TempLand tempLand) {
|
|
|
+ if (tempLand == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ TempLandVO vo = new TempLandVO();
|
|
|
+ BeanUtils.copyProperties(tempLand, vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+}
|