ImGroupMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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="INTEGER" 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.cooleshow.common.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="getLock" resultMap="BaseResultMap">
  36. SELECT * FROM im_group WHERE id_ = #{groupId} LIMIT 1 FOR UPDATE
  37. </select>
  38. <select id="findAll" resultMap="BaseResultMap">
  39. SELECT ig.* FROM im_group ig
  40. LEFT JOIN im_group_member igm ON igm.group_id_ = ig.id_
  41. <where>
  42. <if test="userId != null">
  43. AND igm.user_id_ = #{userId}
  44. </if>
  45. <if test="search != null and search != ''">
  46. AND (ig.id_ = #{search} OR
  47. ig.name_ LIKE CONCAT('%',#{search},'%') OR ig.introduce_ LIKE CONCAT('%',#{search},'%'))
  48. </if>
  49. </where>
  50. ORDER BY id_ DESC
  51. </select>
  52. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  53. parameterType="com.yonge.cooleshow.biz.dal.entity.ImGroup">
  54. INSERT INTO im_group(name_, introduce_, member_num_, memo_, img_, type_,create_by_,auto_pass_flag_, create_time_, update_time_)
  55. VALUES
  56. <foreach collection="entities" item="entity" separator=",">
  57. (#{entity.name}, #{entity.introduce}, #{entity.memberNum}, #{entity.memo}, #{entity.img},
  58. #{entity.type,typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler},
  59. #{entity.createBy},#{entity.autoPassFlag}, NOW(), NOW())
  60. </foreach>
  61. </insert>
  62. </mapper>