package com.siwei.apply.controller; import com.siwei.apply.domain.LandOneCode; 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.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; /** * 土地统一编码 控制器 * 提供基础的增删改查接口 */ @RestController @RequestMapping("/landOneCode") @RequiredArgsConstructor public class LandOneCodeController extends BaseController { private final LandOneCodeService service; /** * 新增 */ @PostMapping() public R> add(@RequestBody LandOneCode body) { try { String id = service.add(body); Map map = new HashMap<>(); map.put("id", id); return R.ok(map); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 按ID查询 */ @GetMapping("/{id}") public R getById(@PathVariable String id) { try { return R.ok(service.getById(id)); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 更新(按ID) */ @PutMapping() public R update(@RequestBody LandOneCode body) { try { service.update(body); return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 删除(按ID) */ @DeleteMapping("/{id}") public R delete(@PathVariable String id) { try { service.deleteById(id); return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } @PostMapping("/addEntity") public R addEntity(@RequestBody LandOneCode body) { try { service.addOrUpdateLandOneCodeInfo(body.getProjectWorkflowId()); return R.ok(body.getProjectWorkflowId()); } catch (Exception e) { return R.fail(e.getMessage()); } } }