SysUserDeviceMapper.xml 3.8 KB

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