ImGroupMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.ImGroupDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.ImGroup">
  5. <id column="id_" jdbcType="VARCHAR" property="id"/>
  6. <result column="name_" jdbcType="VARCHAR" property="name"/>
  7. <result column="introduce_" jdbcType="VARCHAR" property="introduce"/>
  8. <result column="member_num_" jdbcType="INTEGER" property="memberNum"/>
  9. <result column="memo_" jdbcType="VARCHAR" property="memo"/>
  10. <result column="img_" jdbcType="VARCHAR" property="img"/>
  11. <result column="type_" jdbcType="VARCHAR" property="type" typeHandler="com.yonge.toolset.mybatis.dal.CustomEnumTypeHandler"/>
  12. <result column="create_by_" property="createBy"/>
  13. <result column="auto_pass_flag_" property="autoPassFlag"/>
  14. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  15. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  16. </resultMap>
  17. <sql id="Base_Column_List">
  18. id_, name_, introduce_, member_num_, memo_, img_, type_,create_by_, create_time_, update_time_
  19. </sql>
  20. <update id="updateById" parameterType="com.yonge.cooleshow.biz.dal.entity.ImGroup">
  21. update im_group
  22. <set>
  23. <if test="et.name != null">
  24. name_ = #{et.name},
  25. </if>
  26. <if test="et.autoPassFlag != null">
  27. auto_pass_flag_ = #{et.autoPassFlag},
  28. </if>
  29. introduce_ = #{et.introduce},
  30. memo_ = #{et.memo},
  31. update_time_ = NOW()
  32. </set>
  33. where id_ = #{et.id}
  34. </update>
  35. <select id="findAll" resultMap="BaseResultMap">
  36. SELECT ig.* FROM im_group ig
  37. LEFT JOIN im_group_member igm ON igm.group_id_ = ig.id_
  38. <where>
  39. <if test="imGroupDto.type != null and imGroupDto.type != ''">
  40. AND ig.type_ = #{imGroupDto.type}
  41. </if>
  42. <if test="imGroupDto.createUserId != null">
  43. AND ig.create_by_ = #{imGroupDto.createUserId}
  44. </if>
  45. <if test="imGroupDto.userId != null">
  46. AND igm.user_id_ = #{imGroupDto.userId}
  47. </if>
  48. <if test="imGroupDto.search != null and imGroupDto.search != ''">
  49. AND (ig.id_ = #{imGroupDto.search} OR
  50. ig.name_ LIKE CONCAT('%',#{imGroupDto.search},'%') OR ig.introduce_ LIKE CONCAT('%',#{imGroupDto.search},'%'))
  51. </if>
  52. </where>
  53. ORDER BY id_ DESC
  54. </select>
  55. <resultMap id="ImGroupResultDto" type="com.yonge.cooleshow.biz.dal.dto.ImGroupResultDto" extends="BaseResultMap">
  56. <result property="existFlag" column="existFlag"/>
  57. <result property="hasWaitAuditFlag" column="hasWaitAuditFlag"/>
  58. </resultMap>
  59. <select id="queryTeacherFun" resultMap="ImGroupResultDto">
  60. SELECT ig.*,
  61. CASE WHEN igm.id_ IS NULL THEN 0 ELSE 1 END existFlag,
  62. CASE WHEN igma.id_ IS NULL THEN 0 ELSE 1 END hasWaitAuditFlag
  63. FROM im_group ig
  64. LEFT JOIN im_group_member igm ON ig.id_ = igm.group_id_ AND igm.user_id_ = #{imGroupDto.userId}
  65. LEFT JOIN im_group_member_audit igma ON igma.group_id_ = ig.id_ AND igma.audit_status_ = 'AUDITING'
  66. WHERE ig.create_by_ = #{imGroupDto.createUserId}
  67. <if test="imGroupDto.type != null and imGroupDto.type != ''">
  68. AND ig.type_ = #{imGroupDto.type}
  69. </if>
  70. <if test="imGroupDto.search != null and imGroupDto.search != ''">
  71. AND (ig.id_ = #{imGroupDto.search} OR
  72. ig.name_ LIKE CONCAT('%',#{imGroupDto.search},'%') OR ig.introduce_ LIKE CONCAT('%',#{imGroupDto.search},'%'))
  73. </if>
  74. GROUP BY ig.id_
  75. </select>
  76. </mapper>