OrganizationMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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="level_" property="level"/>
  14. <result column="parent_organ_id_" property="parentOrganId" />
  15. <result column="parent_organ_id_tag_" property="parentOrganIdTag" />
  16. <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  17. <result column="del_flag_" property="delFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  18. <result column="share_profit_amount_" property="shareProfitAmount" />
  19. <result column="is_allow_arrange_exam_" property="isAllowArrangeExam" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. <result column="tenant_id_" property="tenantId" />
  23. <association property="sysUser" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="Organization" >
  27. SELECT * FROM organization WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="Organization">
  31. SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.keao.edu.user.entity.Organization" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  35. INSERT INTO organization (id_,name_,contact_name_,contact_phone_,level_,parent_organ_id_,parent_organ_id_tag_,settlement_type_,share_profit_amount_,is_allow_arrange_exam_,create_time_,update_time_,tenant_id_)
  36. VALUES(#{id},#{name},#{contactName},#{contactPhone},#{level},#{parentOrganId},#{parentOrganIdTag},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  37. #{shareProfitAmount},#{isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},NOW(),NOW(),#{tenantId})
  38. </insert>
  39. <!-- 根据主键查询一条记录 -->
  40. <update id="update" parameterType="com.keao.edu.user.entity.Organization">
  41. UPDATE organization
  42. <set>
  43. <if test="contactPhone != null">
  44. contact_phone_ = #{contactPhone},
  45. </if>
  46. <if test="level != null">
  47. level_ = #{level},
  48. </if>
  49. <if test="parentOrganId != null">
  50. parent_organ_id_ = #{parentOrganId},
  51. </if>
  52. <if test="parentOrganIdTag != null">
  53. parent_organ_id_tag_ = #{parentOrganIdTag},
  54. </if>
  55. <if test="settlementType != null">
  56. settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  57. </if>
  58. <if test="contactName != null">
  59. contact_name_ = #{contactName},
  60. </if>
  61. <if test="shareProfitAmount != null">
  62. share_profit_amount_ = #{shareProfitAmount},
  63. </if>
  64. <if test="name != null">
  65. name_ = #{name},
  66. </if>
  67. <if test="isAllowArrangeExam != null">
  68. is_allow_arrange_exam_ = #{isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  69. </if>
  70. <if test="delFlag != null">
  71. del_flag_ = #{delFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  72. </if>
  73. <if test="tenantId != null">
  74. tenant_id_ = #{tenantId},
  75. </if>
  76. update_time_ = NOW()
  77. </set> WHERE id_ = #{id}
  78. </update>
  79. <!-- 根据主键删除一条记录 -->
  80. <delete id="delete" >
  81. UPDATE organization SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  82. </delete>
  83. <sql id="organQueryPage">
  84. <where>
  85. del_flag_ = 0 AND tenant_id_ = #{tenantId}
  86. <if test="settlementType != null and settlementType != ''">
  87. AND settlement_type_ = #{settlementType}
  88. </if>
  89. <if test="isAllowArrangeExam != null">
  90. AND is_allow_arrange_exam_ = #{isAllowArrangeExam}
  91. </if>
  92. <if test="search != null and search != ''">
  93. AND (id_ = #{search} OR name_ LIKE CONCAT('%',#{search},'%')
  94. OR contact_name_ LIKE CONCAT('%',#{search},'%')
  95. OR contact_phone_ LIKE CONCAT('%',#{search},'%'))
  96. </if>
  97. </where>
  98. </sql>
  99. <!-- 分页查询 -->
  100. <select id="queryPage" resultMap="Organization" parameterType="map">
  101. SELECT * FROM organization
  102. <include refid="organQueryPage"/>
  103. ORDER BY update_time_ DESC <include refid="global.limit"/>
  104. </select>
  105. <!-- 查询当前表的总记录数 -->
  106. <select id="queryCount" resultType="int">
  107. SELECT COUNT(*) FROM organization
  108. <include refid="organQueryPage"/>
  109. </select>
  110. <select id="getByTenant" resultMap="Organization">
  111. SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
  112. </select>
  113. <select id="getChildOrganIds" resultType="int">
  114. SELECT id_ FROM organization WHERE parent_organ_id_tag_ LIKE CONCAT(#{parentOrganIdTag}, '%');
  115. </select>
  116. <select id="getNextLevelOrganIds" resultType="int">
  117. SELECT id_ FROM organization WHERE parent_organ_id_ =#{organId};
  118. </select>
  119. </mapper>