1
0

TdhyhsMapper.xml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. <result property="jsdw" column="jsdw"/>
  14. <result property="gljsgcghxkh" column="gljsgcghxkh"/>
  15. <result property="hasOnchain" column="has_onchain"/>
  16. <result property="creatorId" column="creator_id"/>
  17. <result property="createdAt" column="created_at"/>
  18. <result property="updatedAt" column="updated_at"/>
  19. <result property="hyyj" column="hyyj"/>
  20. <result property="sourceId" column="source_id"/>
  21. <result property="bz" column="bz"/>
  22. </resultMap>
  23. <select id="isExit" resultType="Boolean">
  24. SELECT COUNT(1) > 0
  25. FROM t_tdhyhs
  26. WHERE project_id = #{projectId}
  27. </select>
  28. <!-- 添加记录 -->
  29. <insert id="add" parameterType="com.siwei.apply.domain.Tdhyhs">
  30. INSERT INTO t_tdhyhs (id, project_id, ydwz, hgzh, fzjg, fz_date,
  31. jsdw, gljsgcghxkh,hyyj,
  32. bz, has_onchain, creator_id,
  33. created_at, updated_at, source_id)
  34. VALUES (#{id}, #{projectId}, #{ydwz}, #{hgzh}, #{fzjg}, #{fzDate},
  35. #{jsdw}, #{gljsgcghxkh},#{hyyj},
  36. #{bz}, false, #{creatorId},
  37. now(), now(), #{sourceId})
  38. </insert>
  39. <!-- 根据项目ID获取记录(返回全部,按创建时间升序) -->
  40. <select id="get" resultMap="BaseResultMap" parameterType="String">
  41. SELECT *
  42. FROM t_tdhyhs
  43. WHERE project_id = #{projectId}
  44. ORDER BY created_at ASC
  45. </select>
  46. <!-- 新增:根据主键ID获取单条记录 -->
  47. <select id="getById" resultMap="BaseResultMap" parameterType="String">
  48. SELECT *
  49. FROM t_tdhyhs
  50. WHERE id = #{id}
  51. </select>
  52. <!-- 更新记录 -->
  53. <update id="update" parameterType="com.siwei.apply.domain.vo.TdhyhsUpdateVo">
  54. UPDATE t_tdhyhs
  55. <set>
  56. <if test="projectId != null">project_id = #{projectId},</if>
  57. <if test="ydwz != null">ydwz = #{ydwz},</if>
  58. <if test="hgzh != null">hgzh = #{hgzh},</if>
  59. <if test="fzjg != null">fzjg = #{fzjg},</if>
  60. <if test="fzDate != null">fz_date = #{fzDate},</if>
  61. <if test="jsdw != null">jsdw = #{jsdw},</if>
  62. <if test="gljsgcghxkh != null">gljsgcghxkh = #{gljsgcghxkh},</if>
  63. <if test="hyyj != null">hyyj = #{hyyj},</if>
  64. <if test="bz != null">bz = #{bz},</if>
  65. <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
  66. <if test="sourceId != null">source_id = #{sourceId},</if>
  67. updated_at = now()
  68. </set>
  69. WHERE id = #{id}
  70. </update>
  71. <!-- 更新has_onchain字段 -->
  72. <update id="updateHasOnchain">
  73. UPDATE t_tdhyhs
  74. SET has_onchain = #{hasOnchain}, updated_at = now()
  75. WHERE id = #{id}
  76. </update>
  77. </mapper>