AdminstoreMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.example.mapper.AdminstoreMapper">
  6. <sql id="Base_Column_List">
  7. id,store_id,username,password,name,avatar,role,phone,email,address
  8. </sql>
  9. <select id="selectAll" resultType="com.example.entity.Adminstore">
  10. select
  11. <include refid="Base_Column_List" />
  12. from adminstore
  13. <where>
  14. <if test="id != null"> and id = #{id}</if>
  15. <if test="store_id != null"> and store_id = #{store_id}</if>"
  16. <if test="username != null"> and username like concat('%', #{username}, '%')</if>
  17. <if test="password != null"> and password like concat('%', #{password}, '%')</if>
  18. <if test="name != null"> and name like concat('%', #{name}, '%')</if>
  19. <if test="avatar != null"> and avatar like concat('%', #{avatar}, '%')</if>
  20. <if test="role != null"> and role like concat('%', #{role}, '%')</if>
  21. <if test="phone != null"> and phone like concat('%', #{phone}, '%')</if>
  22. <if test="email != null"> and email like concat('%', #{email}, '%')</if>
  23. <if test="address != null"> and address = #{address}</if>
  24. </where>
  25. order by id desc
  26. </select>
  27. <select id="selectById" resultType="com.example.entity.Adminstore">
  28. select
  29. <include refid="Base_Column_List" />
  30. from adminstore
  31. where id = #{id}
  32. </select>
  33. <delete id="deleteById">
  34. delete from adminstore
  35. where id = #{id}
  36. </delete>
  37. <insert id="insert" parameterType="com.example.entity.Adminstore" useGeneratedKeys="true">
  38. insert into adminstore
  39. <trim prefix="(" suffix=")" suffixOverrides=",">
  40. <if test="id != null">id,</if>
  41. <if test="storeId!=null">store_id,</if>
  42. <if test="username != null">username,</if>
  43. <if test="password != null">password,</if>
  44. <if test="name != null">name,</if>
  45. <if test="avatar != null">avatar,</if>
  46. <if test="role != null">role,</if>
  47. <if test="phone != null">phone,</if>
  48. <if test="email != null">email,</if>
  49. <if test="address != null">address,</if>
  50. </trim>
  51. <trim prefix="values (" suffix=")" suffixOverrides=",">
  52. <if test="id != null">#{id},</if>
  53. <if test="storeId!=null">#{storeId},</if>
  54. <if test="username != null">#{username},</if>
  55. <if test="password != null">#{password},</if>
  56. <if test="name != null">#{name},</if>
  57. <if test="avatar != null">#{avatar},</if>
  58. <if test="role != null">#{role},</if>
  59. <if test="phone != null">#{phone},</if>
  60. <if test="email != null">#{email},</if>
  61. <if test="address != null">#{address},</if>
  62. </trim>
  63. </insert>
  64. <update id="updateById" parameterType="com.example.entity.Adminstore">
  65. update adminstore
  66. <set>
  67. <if test="storeId != null">store_id = #{storeId},</if>
  68. <if test="username != null">
  69. username = #{username},
  70. </if>
  71. <if test="password != null">
  72. password = #{password},
  73. </if>
  74. <if test="name != null">
  75. name = #{name},
  76. </if>
  77. <if test="avatar != null">
  78. avatar = #{avatar},
  79. </if>
  80. <if test="role != null">
  81. role = #{role},
  82. </if>
  83. <if test="phone != null">
  84. phone = #{phone},
  85. </if>
  86. <if test="email != null">
  87. email = #{email},
  88. </if>
  89. <if test="address != null">
  90. address = #{address},
  91. </if>
  92. </set>
  93. where id = #{id}
  94. </update>
  95. </mapper>