TdhyhsMapper.xml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.siwei.apply.mapper.TdhyhsMapper">
  6. <resultMap id="BaseResultMap" type="com.siwei.apply.domain.Tdhyhs">
  7. <id property="id" column="id"/>
  8. <result property="projectId" column="project_id"/>
  9. <result property="ydwz" column="ydwz"/>
  10. <result property="hgzh" column="hgzh"/>
  11. <result property="fzjg" column="fzjg"/>
  12. <result property="fzDate" column="fz_date"/>
  13. <!-- 新增字段映射 -->
  14. <result property="jsdw" column="jsdw"/>
  15. <result property="gljsgcghxkh" column="gljsgcghxkh"/>
  16. <result property="hasOnchain" column="has_onchain"/>
  17. <result property="creatorId" column="creator_id"/>
  18. <result property="createdAt" column="created_at"/>
  19. <result property="updatedAt" column="updated_at"/>
  20. </resultMap>
  21. <select id="isExit" resultType="Boolean">
  22. SELECT COUNT(1) > 0
  23. FROM t_tdhyhs
  24. WHERE project_id = #{projectId}
  25. </select>
  26. <!-- 添加记录 -->
  27. <insert id="add" parameterType="com.siwei.apply.domain.Tdhyhs">
  28. INSERT INTO t_tdhyhs (id, project_id, ydwz, hgzh, fzjg, fz_date,
  29. jsdw, gljsgcghxkh,
  30. has_onchain, creator_id,
  31. created_at, updated_at)
  32. VALUES (#{id}, #{projectId}, #{ydwz}, #{hgzh}, #{fzjg}, #{fzDate},
  33. #{jsdw}, #{gljsgcghxkh},
  34. false, #{creatorId},
  35. now(), now())
  36. </insert>
  37. <!-- 根据项目ID获取记录 -->
  38. <select id="get" resultMap="BaseResultMap" parameterType="String">
  39. SELECT *
  40. FROM t_tdhyhs
  41. WHERE project_id = #{projectId}
  42. </select>
  43. <!-- 更新记录 -->
  44. <update id="update" parameterType="com.siwei.apply.domain.vo.TdhyhsUpdateVo">
  45. UPDATE t_tdhyhs
  46. <set>
  47. <if test="projectId != null">project_id = #{projectId},</if>
  48. <if test="ydwz != null">ydwz = #{ydwz},</if>
  49. <if test="hgzh != null">hgzh = #{hgzh},</if>
  50. <if test="fzjg != null">fzjg = #{fzjg},</if>
  51. <if test="fzDate != null">fz_date = #{fzDate},</if>
  52. <!-- 新增字段可更新 -->
  53. <if test="jsdw != null">jsdw = #{jsdw},</if>
  54. <if test="gljsgcghxkh != null">gljsgcghxkh = #{gljsgcghxkh},</if>
  55. <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
  56. updated_at = now()
  57. </set>
  58. WHERE id = #{id}
  59. </update>
  60. <!-- 更新has_onchain字段 -->
  61. <update id="updateHasOnchain">
  62. UPDATE t_tdhyhs
  63. SET has_onchain = #{hasOnchain}, updated_at = now()
  64. WHERE id = #{id}
  65. </update>
  66. </mapper>