| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package com.siwei.apply.controller;
- import com.siwei.apply.domain.LandOneCode;
- import com.siwei.apply.domain.ProjectWorkflow;
- import com.siwei.apply.domain.vo.LandOneCodeVo;
- import com.siwei.apply.mapper.ProjectWorkflowMapper;
- import com.siwei.apply.service.LandOneCodeService;
- import com.siwei.common.core.domain.R;
- import com.siwei.common.core.web.controller.BaseController;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Objects;
- /**
- * 土地统一编码 控制器
- * 提供基础的增删改查接口
- */
- @RestController
- @RequestMapping("/landOneCode")
- @RequiredArgsConstructor
- public class LandOneCodeController extends BaseController {
- private final LandOneCodeService service;
- /**
- * 新增
- */
- @PostMapping()
- public R<Map<String, String>> add(@RequestBody LandOneCode body) {
- try {
- String id = service.add(body);
- Map<String, String> map = new HashMap<>();
- map.put("id", id);
- return R.ok(map);
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 按ID查询
- */
- @GetMapping("/{id}")
- public R<LandOneCode> getById(@PathVariable String id) {
- try {
- return R.ok(service.getById(id));
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 更新(按ID)
- */
- @PutMapping()
- public R<Void> update(@RequestBody LandOneCode body) {
- try {
- service.update(body);
- return R.ok();
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 删除(按ID)
- */
- @DeleteMapping("/{id}")
- public R<Void> delete(@PathVariable String id) {
- try {
- service.deleteById(id);
- return R.ok();
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- @PostMapping("/addEntity")
- public R<String> addEntity(@RequestBody LandOneCode body) {
- try {
- service.addOrUpdateLandOneCodeInfo(body.getProjectWorkflowId());
- return R.ok(body.getProjectWorkflowId());
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- @GetMapping("/getResourceCode")
- public R<LandOneCodeVo> getResourceCode(@RequestParam String projectId,@RequestParam String projectWorkflowId) {
- try {
- LandOneCodeVo landOneCodeVo = null;
- // projectWorkflowId 这里为节点id,前端兼容
- ProjectWorkflow projectWorkflow= service.getProjectWorkflowByNodeId(projectWorkflowId);
- if(Objects.nonNull(projectWorkflow)){
- projectWorkflowId=projectWorkflow.getId();
- landOneCodeVo = service.getLandOneCodeByWorkflowId(projectWorkflowId);
- }
- return R.ok(landOneCodeVo);
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- }
|