MiniAppUserMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.miniapp.basics.mapper.MiniAppUserMapper">
  6. <resultMap type="com.miniapp.common.core.domain.entity.miniapp.MiniAppUser" id="MiniAppUserResult">
  7. <result property="id" column="id" />
  8. <result property="nickName" column="nick_name" />
  9. <result property="avatar" column="avatar" />
  10. <result property="openId" column="open_id" />
  11. <result property="sex" column="sex" />
  12. <result property="miniAppId" column="mini_app_id" />
  13. <result property="remark" column="remark" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. </resultMap>
  17. <sql id="selectMiniAppUserVo">
  18. select id, nick_name, avatar, open_id, sex, mini_app_id, remark, create_time, update_time from t_mini_app_user
  19. </sql>
  20. <select id="selectMiniAppUserList" parameterType="MiniAppUser" resultMap="MiniAppUserResult">
  21. <include refid="selectMiniAppUserVo"/>
  22. <where>
  23. <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
  24. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  25. <if test="openId != null and openId != ''"> and open_id = #{openId}</if>
  26. <if test="sex != null and sex != ''"> and sex = #{sex}</if>
  27. <if test="miniAppId != null "> and mini_app_id = #{miniAppId}</if>
  28. </where>
  29. </select>
  30. <select id="selectMiniAppUserById" parameterType="Long" resultMap="MiniAppUserResult">
  31. <include refid="selectMiniAppUserVo"/>
  32. where id = #{id}
  33. </select>
  34. <insert id="insertMiniAppUser" parameterType="MiniAppUser" useGeneratedKeys="true" keyProperty="id">
  35. insert into t_mini_app_user
  36. <trim prefix="(" suffix=")" suffixOverrides=",">
  37. <if test="nickName != null">nick_name,</if>
  38. <if test="avatar != null">avatar,</if>
  39. <if test="openId != null">open_id,</if>
  40. <if test="sex != null">sex,</if>
  41. <if test="miniAppId != null">mini_app_id,</if>
  42. <if test="remark != null">remark,</if>
  43. <if test="createTime != null">create_time,</if>
  44. <if test="updateTime != null">update_time,</if>
  45. </trim>
  46. <trim prefix="values (" suffix=")" suffixOverrides=",">
  47. <if test="nickName != null">#{nickName},</if>
  48. <if test="avatar != null">#{avatar},</if>
  49. <if test="openId != null">#{openId},</if>
  50. <if test="sex != null">#{sex},</if>
  51. <if test="miniAppId != null">#{miniAppId},</if>
  52. <if test="remark != null">#{remark},</if>
  53. <if test="createTime != null">#{createTime},</if>
  54. <if test="updateTime != null">#{updateTime},</if>
  55. </trim>
  56. </insert>
  57. <update id="updateMiniAppUser" parameterType="MiniAppUser">
  58. update t_mini_app_user
  59. <trim prefix="SET" suffixOverrides=",">
  60. <if test="nickName != null">nick_name = #{nickName},</if>
  61. <if test="avatar != null">avatar = #{avatar},</if>
  62. <if test="openId != null">open_id = #{openId},</if>
  63. <if test="sex != null">sex = #{sex},</if>
  64. <if test="miniAppId != null">mini_app_id = #{miniAppId},</if>
  65. <if test="remark != null">remark = #{remark},</if>
  66. <if test="createTime != null">create_time = #{createTime},</if>
  67. <if test="updateTime != null">update_time = #{updateTime},</if>
  68. </trim>
  69. where id = #{id}
  70. </update>
  71. <delete id="deleteMiniAppUserById" parameterType="Long">
  72. delete from t_mini_app_user where id = #{id}
  73. </delete>
  74. <delete id="deleteMiniAppUserByIds" parameterType="String">
  75. delete from t_mini_app_user where id in
  76. <foreach item="id" collection="array" open="(" separator="," close=")">
  77. #{id}
  78. </foreach>
  79. </delete>
  80. <select id="selectMiniAppUserByOpenIdAndMiniAppId" resultMap="MiniAppUserResult">
  81. <include refid="selectMiniAppUserVo"/>
  82. where open_id = #{openId} and mini_app_id = #{miniAppId}
  83. </select>
  84. <select id="selectMiniAppUserInnerJoinMiniAppList" parameterType="MiniAppUser" resultMap="MiniAppUserResult">
  85. select
  86. mau.id,
  87. mau.nick_name,
  88. mau.avatar,
  89. mau.open_id,
  90. mau.sex,
  91. mau.mini_app_id,
  92. mau.remark,
  93. mau.create_time,
  94. mau.update_time,
  95. ma.name as miniAppName
  96. from t_mini_app_user mau inner join t_mini_app ma on mau.mini_app_id = ma.id
  97. <where>
  98. <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
  99. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  100. <if test="openId != null and openId != ''"> and open_id = #{openId}</if>
  101. <if test="sex != null and sex != ''"> and sex = #{sex}</if>
  102. <if test="miniAppId != null "> and mini_app_id = #{miniAppId}</if>
  103. </where>
  104. </select>
  105. </mapper>