UserConfigMapper.xml 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.api.games.dao.UserConfigMapper">
  4. <resultMap id="BaseResultMap" type="com.api.games.model.UserConfig">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="id" jdbcType="BIGINT" property="id" />
  9. <result column="user_id" jdbcType="BIGINT" property="userId" />
  10. <result column="scale_end" jdbcType="VARCHAR" property="scaleEnd" />
  11. <result column="scale_start" jdbcType="VARCHAR" property="scaleStart" />
  12. <result column="scale_time" jdbcType="VARCHAR" property="scaleTime" />
  13. <result column="show_time" jdbcType="INTEGER" property="showTime" />
  14. <result column="hide_time" jdbcType="INTEGER" property="hideTime" />
  15. <result column="correct" jdbcType="INTEGER" property="correct" />
  16. <result column="supporting" jdbcType="INTEGER" property="supporting" />
  17. <result column="practice" jdbcType="INTEGER" property="practice" />
  18. <result column="game_count" jdbcType="INTEGER" property="gameCount" />
  19. <result column="version" jdbcType="VARCHAR" property="version" />
  20. <result column="exercise_right" jdbcType="INTEGER" property="exerciseRight" />
  21. <result column="exercise" jdbcType="INTEGER" property="exercise" />
  22. <result column="login_out" jdbcType="INTEGER" property="loginOut" />
  23. </resultMap>
  24. <select id="list" resultType="com.api.common.mybatis.ResultMap">
  25. select u.nickname,u.password,u.create_time,u.enable,u.type,u.id,u.status,u.gender,u.openId , c.id as
  26. configId,c.user_id,c.scale_end ,c.scale_start,
  27. c.scale_time,c.show_time,c.hide_time,c.correct,c.supporting,c.practice,c.game_count,c.version,c.exercise_right,c.exercise,c.login_out
  28. from (select * from sys_user where type = 1) u
  29. left join user_config c on (u.id = c.user_id ) where 1=1
  30. <if test="params.nickname !=null and params.nickname !=''">
  31. and u.nickname = #{params.nickname}
  32. </if>
  33. <if test="params.status !=null and params.status == 0">
  34. and now() &lt;= date(scale_start)
  35. </if>
  36. <if test="params.status !=null and params.status == 1">
  37. and now() &gt;= date(scale_start) and now() &lt;= date(scale_end)
  38. </if>
  39. <if test="params.status !=null and params.status == 2">
  40. and now() &gt;= date(scale_end)
  41. </if>
  42. <if test="params.scaleStart !=null and params.scaleStart !=''">
  43. and date(scale_start) = #{params.scaleStart}
  44. </if>
  45. <if test="params.gameCount !=null and params.gameCount !=''">
  46. and game_count = #{params.gameCount}
  47. </if>
  48. <if test="params.versions !=null and params.versions !=''">
  49. and version = #{params.versions}
  50. </if>
  51. <if test="order!=null and order.size &gt; 0">
  52. order by 1
  53. </if>
  54. <if test="order.createTime != null ">
  55. ,create_time ${order.createTime}
  56. </if>
  57. <if test="order.nickname != null ">
  58. ,nickname ${order.nickname}
  59. </if>
  60. <if test="order.scaleStart != null ">
  61. ,scale_start ${order.scaleStart}
  62. </if>
  63. <if test="order.scaleEnd != null ">
  64. ,scale_end ${order.scaleEnd}
  65. </if>
  66. <if test="order.showTime != null ">
  67. ,show_time ${order.showTime}
  68. </if>
  69. <if test="order.hideTime != null ">
  70. ,hide_time ${order.hideTime}
  71. </if>
  72. <if test="order.correct != null ">
  73. ,correct ${order.correct}
  74. </if>
  75. <if test="order.practice != null ">
  76. ,practice ${order.practice}
  77. </if>
  78. <if test="order.gameCount != null ">
  79. ,game_count ${order.gameCount}
  80. </if>
  81. </select>
  82. <delete id="deleteByUid">
  83. delete from user_config where user_id = #{uid}
  84. </delete>
  85. <update id="expired">
  86. update sys_user u inner join user_config c on u.id = c.user_id
  87. set u.status = 2 where date(c.scale_end) = date(date_sub(now(),interval -1 day));
  88. </update>
  89. <update id="start">
  90. update sys_user u inner join user_config c on u.id = c.user_id
  91. set u.status = 1 where date(c.scale_start) = date(now());
  92. </update>
  93. <select id="findByUid" resultMap="BaseResultMap">
  94. select * from user_config where user_id = #{uid}
  95. </select>
  96. </mapper>