Explorar el Código

土地核验与规划核实

gushoubang hace 2 meses
padre
commit
14f546729c

+ 61 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/TdhyhsController.java

@@ -0,0 +1,61 @@
+package com.siwei.apply.controller;
+
+import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.service.TdhyhsService;
+import com.siwei.common.core.domain.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 土地核验与规划核实 控制器
+ */
+@RestController
+@RequestMapping("/tdhyhs")
+public class TdhyhsController {
+    @Autowired
+    private TdhyhsService tdhyhsService;
+
+    /**
+     * 添加土地核验与规划核实信息
+     */
+    @PostMapping()
+    public R<Map> add(@RequestBody Tdhyhs tdhyhs) {
+        try {
+            String id = tdhyhsService.add(tdhyhs);
+            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<Tdhyhs> get(@PathVariable("id") String id) {
+        try {
+            Tdhyhs tdhyhs = tdhyhsService.get(id);
+            return R.ok(tdhyhs);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 更新土地核验与规划核实信息(按非空字段更新)
+     */
+    @PutMapping()
+    public R<Void> update(@RequestBody Tdhyhs tdhyhs) {
+        try {
+            tdhyhsService.update(tdhyhs);
+            return R.ok();
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+}

+ 37 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/Tdhyhs.java

@@ -0,0 +1,37 @@
+package com.siwei.apply.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 土地核验与规划核实
+ */
+@Data
+public class Tdhyhs implements Serializable {
+    private String id;                  // 主键ID
+    private String projectId;           // 项目ID
+    private String ydwz;                // 用地位置
+    private String hgzh;                // 合格证号
+    private String fzjg;                // 发证机关
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date fzDate;                // 发证日期
+
+    private Map<String, Object> attachment; // 附件
+    private Boolean hasOnchain;         // 是否上链
+    private String creatorId;           // 创建人ID
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createdAt;             // 创建时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updatedAt;             // 更新时间
+
+    public void generateId() {
+        this.id = UUID.randomUUID().toString();
+    }
+}

+ 33 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/TdhyhsMapper.java

@@ -0,0 +1,33 @@
+package com.siwei.apply.mapper;
+
+import com.siwei.apply.domain.Tdhyhs;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface TdhyhsMapper {
+
+    /**
+     * 添加记录
+     *
+     * @param tdhyhs 实体
+     * @return 插入成功条数
+     */
+    String add(Tdhyhs tdhyhs);
+
+    /**
+     * 根据ID获取记录
+     *
+     * @param id 主键ID
+     * @return Tdhyhs 对象
+     */
+    Tdhyhs get(@Param("id") String id);
+
+    /**
+     * 更新记录
+     *
+     * @param tdhyhs 实体
+     * @return 更新成功条数
+     */
+    void update(Tdhyhs tdhyhs);
+}

+ 29 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/TdhyhsService.java

@@ -0,0 +1,29 @@
+package com.siwei.apply.service;
+
+import com.siwei.apply.domain.Tdhyhs;
+
+public interface TdhyhsService {
+    /**
+     * 添加一条土地核验与规划核实记录
+     *
+     * @param tdhyhs Tdhyhs 对象
+     * @return 插入是否成功
+     */
+    String add(Tdhyhs tdhyhs);
+
+    /**
+     * 根据 ID 获取土地核验与规划核实信息
+     *
+     * @param id 主键
+     * @return Tdhyhs 对象
+     */
+    Tdhyhs get(String id);
+
+    /**
+     * 更新土地核验与规划核实信息
+     *
+     * @param tdhyhs Tdhyhs 对象
+     * @return 更新是否成功
+     */
+    void update(Tdhyhs tdhyhs);
+}

+ 36 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/TdhyhsImpl.java

@@ -0,0 +1,36 @@
+package com.siwei.apply.service.impl;
+
+import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.mapper.TdhyhsMapper;
+import com.siwei.apply.service.TdhyhsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import static com.siwei.apply.common.Common.UserId;
+
+/**
+ * 土地核验与规划核实 服务实现类
+ */
+@Service
+public class TdhyhsImpl implements TdhyhsService {
+    @Autowired
+    private TdhyhsMapper tdhyhsMapper;
+
+    @Override
+    public String add(Tdhyhs tdhyhs) {
+        tdhyhs.generateId();
+        tdhyhs.setCreatorId(UserId);
+        tdhyhsMapper.add(tdhyhs);
+        return tdhyhs.getId();
+    }
+
+    @Override
+    public Tdhyhs get(String id) {
+        return tdhyhsMapper.get(id);
+    }
+
+    @Override
+    public void update(Tdhyhs tdhyhs) {
+        tdhyhsMapper.update(tdhyhs);
+    }
+}

+ 55 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/TdhyhsMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.siwei.apply.mapper.TdhyhsMapper">
+
+    <resultMap id="BaseResultMap" type="com.siwei.apply.domain.Tdhyhs">
+        <id property="id" column="id"/>
+        <result property="projectId" column="project_id"/>
+        <result property="ydwz" column="ydwz"/>
+        <result property="hgzh" column="hgzh"/>
+        <result property="fzjg" column="fzjg"/>
+        <result property="fzDate" column="fz_date"/>
+        <result property="attachment" column="attachment" typeHandler="com.siwei.apply.handler.JsonbTypeHandler"/>
+        <result property="hasOnchain" column="has_onchain"/>
+        <result property="creatorId" column="creator_id"/>
+        <result property="createdAt" column="created_at"/>
+        <result property="updatedAt" column="updated_at"/>
+    </resultMap>
+
+    <!-- 添加记录 -->
+    <insert id="add" parameterType="com.siwei.apply.domain.Tdhyhs">
+        INSERT INTO t_tdhyhs (id, project_id, ydwz, hgzh, fzjg, fz_date,
+                               has_onchain, creator_id,
+                              created_at, updated_at)
+        VALUES (#{id}, #{projectId}, #{ydwz}, #{hgzh}, #{fzjg}, #{fzDate},
+                 false, #{creatorId},
+                now(), now())
+    </insert>
+
+    <!-- 根据ID获取记录 -->
+    <select id="get" resultMap="BaseResultMap" parameterType="String">
+        SELECT *
+        FROM t_tdhyhs
+        WHERE id = #{id}
+    </select>
+
+    <!-- 根据ID更新记录 -->
+    <update id="update" parameterType="com.siwei.apply.domain.Tdhyhs">
+        UPDATE t_tdhyhs
+        <set>
+            <if test="projectId != null">project_id = #{projectId},</if>
+            <if test="ydwz != null">ydwz = #{ydwz},</if>
+            <if test="hgzh != null">hgzh = #{hgzh},</if>
+            <if test="fzjg != null">fzjg = #{fzjg},</if>
+            <if test="fzDate != null">fz_date = #{fzDate},</if>
+            <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
+            <if test="creatorId != null">creator_id = #{creatorId},</if>
+            updated_at = now()
+        </set>
+        WHERE id = #{id}
+    </update>
+
+</mapper>