You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.5 KiB

2 months ago
2 months ago
1 month ago
1 month ago
  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.example.demo.mapper.coin.PermissionMapper">
  4. <insert id="addPermission" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  5. insert into admin(admin_name, machine_id, account, password, market, postiton, remark, admin_status, role_id)
  6. values (#{adminName}, #{machineId}, #{account}, #{password}, #{market[0]}, #{postiton}, #{remark}, 1 ,#{roleId})
  7. </insert>
  8. <!-- <insert id="addadminRole">-->
  9. <!-- insert into admin_role(admin_id, role_id)-->
  10. <!-- values (#{adminId}, #{roleId})-->
  11. <!-- </insert>-->
  12. <update id="updatePermission">
  13. update admin
  14. <set>
  15. <if test="adminStatus!=null">
  16. admin_status= #{adminStatus},
  17. </if>
  18. </set>
  19. where id=#{id}
  20. </update>
  21. <update id="updateAdminRole">
  22. update admin
  23. <set>
  24. <if test="roleId!=null">
  25. role_id= #{roleId},
  26. </if>
  27. </set>
  28. where id= #{adminId}
  29. </update>
  30. <update id="updateAdmin">
  31. update admin
  32. <set>
  33. <if test="adminName!=null">
  34. admin_name= #{adminName},
  35. </if>
  36. <if test="machineId!=null">
  37. machine_id= #{machineId},
  38. </if>
  39. <if test="postiton!=null">
  40. postiton= #{postiton},
  41. </if>
  42. <if test="remark!=null">
  43. remark= #{remark},
  44. </if>
  45. <if test="roleId!=null">
  46. role_id= #{roleId},
  47. </if>
  48. market= #{market[0]}
  49. </set>
  50. where account= #{account}
  51. </update>
  52. <delete id="deleteAdmin">
  53. delete
  54. from admin
  55. where id = #{id}
  56. </delete>
  57. <!-- <delete id="deleteAdminRole">-->
  58. <!-- delete-->
  59. <!-- from admin_role-->
  60. <!-- where admin_id = #{id}-->
  61. <!-- </delete>-->
  62. <select id="getposition" resultType="java.lang.String">
  63. select distinct postiton
  64. from admin
  65. </select>
  66. <select id="getmarket" resultType="java.lang.String">
  67. select distinct market
  68. from admin
  69. </select>
  70. <select id="getPermission" resultType="com.example.demo.domain.vo.coin.Permission">
  71. select admin.id as id,admin.machine_id,admin.admin_name as
  72. name,admin.account,admin.market,admin.postiton,admin.remark,admin.admin_status as adminStatus,admin.role_id,role.role_name
  73. from admin
  74. LEFT JOIN role on admin.role_id=role.id
  75. <where>
  76. <if test="account!=null and account.length>0">
  77. and admin.account=#{account}
  78. </if>
  79. <if test="market!=null and market.length>0">
  80. and admin.market LIKE CONCAT('%', #{market}, '%')
  81. </if>
  82. <if test="postiton!=null and postiton.length>0">
  83. and admin.postiton=#{postiton}
  84. </if>
  85. <if test="markets != null and markets.size() > 0 and '1' not in markets">
  86. AND (
  87. <foreach collection="markets" item="market" open="" close="" separator=" OR ">
  88. admin.market LIKE CONCAT('%', #{market}, '%')
  89. </foreach>
  90. )
  91. </if>
  92. </where>
  93. order by admin.admin_status desc ,admin.update_time desc
  94. </select>
  95. <select id="getRole" resultType="com.example.demo.domain.entity.Role">
  96. select *
  97. from role
  98. </select>
  99. </mapper>