OrganizationMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.keao.edu.user.dao.OrganizationDao">
  8. <resultMap type="com.keao.edu.user.entity.Organization" id="Organization">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name" />
  11. <result column="contact_name_" property="contactName" />
  12. <result column="contact_phone_" property="contactPhone" />
  13. <result column="parent_organ_id_" property="parentOrganId" />
  14. <result column="parent_organ_id_tag_" property="parentOrganIdTag" />
  15. <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  16. <result column="share_profit_amount_" property="shareProfitAmount" />
  17. <result column="is_allow_arrange_exam_" property="isAllowArrangeExam" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. <association property="sysUser" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  22. </resultMap>
  23. <!-- 根据主键查询一条记录 -->
  24. <select id="get" resultMap="Organization" >
  25. SELECT * FROM organization WHERE id_ = #{id}
  26. </select>
  27. <!-- 全查询 -->
  28. <select id="findAll" resultMap="Organization">
  29. SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
  30. </select>
  31. <!-- 向数据库增加一条记录 -->
  32. <insert id="insert" parameterType="com.keao.edu.user.entity.Organization" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  33. INSERT INTO organization (id_,name_,contact_name_,contact_phone_,parent_organ_id_,parent_organ_id_tag_,settlement_type_,share_profit_amount_,is_allow_arrange_exam_,create_time_,update_time_,tenant_id_)
  34. VALUES(#{id},#{name},#{contactName},#{contactPhone},#{parentOrganId},#{parentOrganIdTag},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  35. #{shareProfitAmount},#{isAllowArrangeExam},NOW(),NOW(),#{tenantId})
  36. </insert>
  37. <!-- 根据主键查询一条记录 -->
  38. <update id="update" parameterType="com.keao.edu.user.entity.Organization">
  39. UPDATE organization
  40. <set>
  41. <if test="updateTime != null">
  42. update_time_ = #{updateTime},
  43. </if>
  44. <if test="contactPhone != null">
  45. contact_phone_ = #{contactPhone},
  46. </if>
  47. <if test="parentOrganId != null">
  48. parent_organ_id_ = #{parentOrganId},
  49. </if>
  50. <if test="parentOrganIdTag != null">
  51. parent_organ_id_tag_ = #{parentOrganIdTag},
  52. </if>
  53. <if test="settlementType != null">
  54. settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  55. </if>
  56. <if test="contactName != null">
  57. contact_name_ = #{contactName},
  58. </if>
  59. <if test="shareProfitAmount != null">
  60. share_profit_amount_ = #{shareProfitAmount},
  61. </if>
  62. <if test="name != null">
  63. name_ = #{name},
  64. </if>
  65. <if test="isAllowArrangeExam != null">
  66. is_allow_arrange_exam_ = #{isAllowArrangeExam},
  67. </if>
  68. <if test="tenantId != null">
  69. tenant_id_ = #{tenantId},
  70. </if>
  71. </set> WHERE id_ = #{id}
  72. </update>
  73. <!-- 根据主键删除一条记录 -->
  74. <delete id="delete" >
  75. UPDATE organization SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  76. </delete>
  77. <sql id="organQueryPage">
  78. <where>
  79. del_flag_ = 0 AND tenant_id_ = #{tenantId}
  80. <if test="settlementType">
  81. AND settlement_type_ = #{settlementType}
  82. </if>
  83. <if test="search">
  84. AND (id_ = #{search} OR name_ LIKE CONCAT('%',#{search},'%')
  85. OR contact_name_ LIKE CONCAT('%',#{search},'%')
  86. OR contact_phone_ LIKE CONCAT('%',#{search},'%'))
  87. </if>
  88. </where>
  89. </sql>
  90. <!-- 分页查询 -->
  91. <select id="queryPage" resultMap="Organization" parameterType="map">
  92. SELECT * FROM organization
  93. <include refid="organQueryPage"/>
  94. ORDER BY update_time_ DESC <include refid="global.limit"/>
  95. </select>
  96. <!-- 查询当前表的总记录数 -->
  97. <select id="queryCount" resultType="int">
  98. SELECT COUNT(*) FROM organization
  99. <include refid="organQueryPage"/>
  100. </select>
  101. <select id="getByTenant" resultMap="Organization">
  102. SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
  103. </select>
  104. </mapper>