SysUserDeviceMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. <mapper namespace="com.ym.mec.auth.dal.dao.SysUserDeviceDao">
  5. <resultMap type="com.ym.mec.auth.api.entity.SysUserDevice" id="SysUserDevice">
  6. <result column="id_" property="id" />
  7. <result column="user_id_" property="userId" />
  8. <result column="device_num_" property="deviceNum" />
  9. <result column="bind_time_" property="bindTime" />
  10. <result column="device_type_" property="deviceType" />
  11. <result column="client_id_" property="clientId" />
  12. <result column="del_flag_" property="delFlag" />
  13. <result column="update_time_" property="updateTime" />
  14. <result column="phone_" property="user.phone" />
  15. <result column="real_name_" property="user.realName" />
  16. </resultMap>
  17. <!-- 根据主键查询一条记录 -->
  18. <select id="get" resultMap="SysUserDevice">
  19. SELECT * FROM
  20. sys_user_device WHERE id_ = #{id}
  21. </select>
  22. <!-- 全查询 -->
  23. <select id="findAll" resultMap="SysUserDevice">
  24. SELECT * FROM sys_user_device
  25. ORDER BY id_
  26. </select>
  27. <!-- 向数据库增加一条记录 -->
  28. <insert id="insert" parameterType="com.ym.mec.auth.api.entity.SysUserDevice"
  29. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  30. <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
  31. AS ID FROM DUAL </selectKey> -->
  32. INSERT INTO sys_user_device
  33. (id_,user_id_,device_num_,bind_time_,device_type_,client_id_,del_flag_)
  34. VALUES(#{id},#{userId},#{deviceNum},#{bindTime},#{deviceType},#{clientId},0)
  35. </insert>
  36. <!-- 根据主键查询一条记录 -->
  37. <update id="update" parameterType="com.ym.mec.auth.api.entity.SysUserDevice">
  38. UPDATE sys_user_device
  39. <set>
  40. <if test="deviceType != null">
  41. device_type_ = #{deviceType},
  42. </if>
  43. <if test="userId != null">
  44. user_id_ = #{userId},
  45. </if>
  46. <if test="deviceNum != null">
  47. device_num_ = #{deviceNum},
  48. </if>
  49. <if test="id != null">
  50. id_ = #{id},
  51. </if>
  52. <if test="bindTime != null">
  53. bind_time_ = #{bindTime},
  54. </if>
  55. <if test="clientId != null">
  56. client_id_ = #{clientId},
  57. </if>
  58. <if test="delFlag != null">
  59. del_flag_ = #{delFlag},
  60. </if>
  61. update_time_ = now()
  62. </set>
  63. WHERE id_ = #{id}
  64. </update>
  65. <!-- 根据主键删除一条记录 -->
  66. <delete id="delete">
  67. DELETE FROM sys_user_device WHERE id_ = #{id}
  68. </delete>
  69. <!-- 分页查询 -->
  70. <select id="queryPage" resultMap="SysUserDevice" parameterType="map">
  71. SELECT ud.*,u.phone_,u.real_name_ FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_
  72. where del_flag_ = 0
  73. <if test="search != null and search != ''">
  74. and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
  75. </if>
  76. <if test="deviceNum != null">
  77. and device_num_ = #{deviceNum}
  78. </if>
  79. <if test="bindStartTime != null">
  80. and date(bind_time_) &gt;= #{bindStartTime}
  81. </if>
  82. <if test="bindEndTime != null">
  83. and date(bind_time_) &lt;= #{bindEndTime}
  84. </if>
  85. ORDER BY id_
  86. <include refid="global.limit" />
  87. </select>
  88. <!-- 查询当前表的总记录数 -->
  89. <select id="queryCount" resultType="int">
  90. SELECT COUNT(ud.user_id_) FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_
  91. where del_flag_ = 0
  92. <if test="search != null and search != ''">
  93. and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
  94. </if>
  95. <if test="deviceNum != null">
  96. and device_num_ = #{deviceNum}
  97. </if>
  98. <if test="bindStartTime != null">
  99. and date(bind_time_) &gt;= #{bindStartTime}
  100. </if>
  101. <if test="bindEndTime != null">
  102. and date(bind_time_) &lt;= #{bindEndTime}
  103. </if>
  104. </select>
  105. <select id="queryByUserId" resultMap="SysUserDevice" parameterType="map">
  106. SELECT * FROM sys_user_device WHERE user_id_ = #{userId} and del_flag_ = 0
  107. <if test="clientId != null">
  108. and client_id_ = #{clientId}
  109. </if>
  110. </select>
  111. <select id="queryByDeviceNum" resultMap="SysUserDevice" parameterType="map">
  112. SELECT * FROM sys_user_device WHERE device_num_ = #{deviceNum} and del_flag_ = 0
  113. <if test="clientId != null">
  114. and client_id_ = #{clientId}
  115. </if>
  116. </select>
  117. </mapper>