AccountInfoMapper.xml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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.fuzamei.mapperInterface.AccountInfoInterface">
  4. <select id="getAllAccount" resultType="com.fuzamei.entity.AccountInfo">
  5. select * from account_info;
  6. </select>
  7. <insert id="insertAccountInfo" parameterType="java.util.List">
  8. insert into account_info(account_id,account_name,account_type)values
  9. <foreach collection="list" item="item" index="index" separator=",">
  10. (#{item.account_id},
  11. #{item.account_name},
  12. #{item.account_type})
  13. </foreach>
  14. </insert>
  15. <select id="getAccountInfoByUser" parameterType="java.lang.String" resultType="com.fuzamei.entity.AccountInfo">
  16. select account_id,account_name from account_info where account_id in(
  17. select account_id from user_account where user_id = #{userId}
  18. );
  19. </select>
  20. <update id="updateBatchAccountById">
  21. update
  22. account_info
  23. set
  24. <foreach collection="cloumn" item = "cloumnItem" index = "cloumnIndex" separator=",">
  25. ${cloumnItem} =
  26. <foreach collection="parameter.keys" item="item" index="index" open="case account_id" close="end" separator=" ">
  27. when ${item} then #{parameter.[${item}].[${cloumnItem}]}
  28. </foreach>
  29. </foreach>
  30. where
  31. account_id in
  32. <foreach collection="parameter.keys" item="key" open="(" close=")" separator=",">
  33. #{key}
  34. </foreach>
  35. </update>
  36. </mapper>