1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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<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());
- }
- }
- }
|