Digital Office Automation System Backend
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.

BaseDataMapper.xml 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.ruoyi.tjfx.mapper.BaseDataMapper">
  4. <!-- 根据商品编号和分类ID查询基准数据 -->
  5. <select id="selectByProductCodeAndCategoryId" resultType="com.ruoyi.tjfx.entity.BaseData">
  6. SELECT bd.*, c.name as category_name
  7. FROM zs_tjfx_base_data bd
  8. LEFT JOIN zs_tjfx_categories c ON bd.category_id = c.id
  9. WHERE bd.product_code = #{productCode}
  10. <if test="categoryId != null">
  11. AND bd.category_id = #{categoryId}
  12. </if>
  13. LIMIT 1
  14. </select>
  15. <select id="findByCategoryId" resultType="com.ruoyi.tjfx.entity.BaseDataVO">
  16. SELECT bd.*, c.name as category_name
  17. FROM zs_tjfx_base_data bd
  18. LEFT JOIN zs_tjfx_categories c ON bd.category_id = c.id
  19. WHERE 1=1
  20. <if test="categoryId != null">
  21. AND bd.category_id = #{categoryId}
  22. </if>
  23. </select>
  24. <select id="selectByProductCode" resultType="com.ruoyi.tjfx.entity.BaseDataVO">
  25. SELECT bd.*, c.name as category_name
  26. FROM zs_tjfx_base_data bd
  27. LEFT JOIN zs_tjfx_categories c ON bd.category_id = c.id
  28. WHERE bd.product_code = #{productCode}
  29. LIMIT 1
  30. </select>
  31. <select id="selectExistingProductCodes" resultType="string">
  32. SELECT product_code
  33. FROM zs_tjfx_base_data
  34. WHERE product_code IN
  35. <foreach collection="codes" item="code" open="(" separator="," close=")">
  36. #{code}
  37. </foreach>
  38. </select>
  39. <select id="selectPageWithJoin" resultType="com.ruoyi.tjfx.entity.BaseDataVO">
  40. SELECT
  41. bd.id, bd.product_code, bd.product_name, bd.brand,
  42. bd.category_id, c.name AS category_name,
  43. bd.category_specs, bd.created_at, bd.updated_at
  44. FROM zs_tjfx_base_data bd
  45. LEFT JOIN zs_tjfx_categories c ON bd.category_id = c.id
  46. <where>
  47. <if test="productCode != null and productCode != ''">
  48. AND bd.product_code LIKE CONCAT('%', #{productCode}, '%')
  49. </if>
  50. <if test="productName != null and productName != ''">
  51. AND bd.product_name LIKE CONCAT('%', #{productName}, '%')
  52. </if>
  53. <if test="categoryId != null">
  54. AND bd.category_id = #{categoryId}
  55. </if>
  56. </where>
  57. ORDER BY bd.created_at DESC
  58. </select>
  59. <insert id="insertBatch">
  60. INSERT INTO zs_tjfx_base_data (
  61. product_code, product_name, brand,
  62. category_id, category_specs,
  63. created_at, updated_at
  64. )
  65. VALUES
  66. <foreach collection="list" item="item" separator=",">
  67. (
  68. #{item.productCode},
  69. #{item.productName},
  70. #{item.brand},
  71. #{item.categoryId},
  72. #{item.categorySpecs},
  73. #{item.createdAt},
  74. #{item.updatedAt}
  75. )
  76. </foreach>
  77. </insert>
  78. </mapper>