BrandMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.fms.system.mapper.BrandMapper">
  6. <resultMap type="Brand" id="BrandResult">
  7. <result property="brandId" column="brand_id" />
  8. <result property="brandName" column="brand_name" />
  9. <result property="createBy" column="create_by" />
  10. <result property="createTime" column="create_time" />
  11. <result property="updateBy" column="update_by" />
  12. <result property="updateTime" column="update_time" />
  13. </resultMap>
  14. <resultMap id="BrandAircraftTypeResult" type="Brand" extends="BrandResult">
  15. <collection property="aircraftTypeList" notNullColumn="sub_aircraft_type_id" javaType="java.util.List" resultMap="AircraftTypeResult" />
  16. </resultMap>
  17. <resultMap type="AircraftType" id="AircraftTypeResult">
  18. <result property="aircraftTypeId" column="sub_aircraft_type_id" />
  19. <result property="brandId" column="sub_brand_id" />
  20. <result property="aircraftTypeName" column="sub_aircraft_type_name" />
  21. <result property="createBy" column="sub_create_by" />
  22. <result property="createTime" column="sub_create_time" />
  23. <result property="updateBy" column="sub_update_by" />
  24. <result property="updateTime" column="sub_update_time" />
  25. </resultMap>
  26. <sql id="selectBrandVo">
  27. select brand_id, brand_name, create_by, create_time, update_by, update_time from brand_t
  28. </sql>
  29. <select id="selectBrandList" parameterType="Brand" resultMap="BrandResult">
  30. <include refid="selectBrandVo"/>
  31. <where>
  32. <if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
  33. </where>
  34. </select>
  35. <select id="selectBrandByBrandId" parameterType="Long" resultMap="BrandAircraftTypeResult">
  36. select a.brand_id, a.brand_name, a.create_by, a.create_time, a.update_by, a.update_time,
  37. b.aircraft_type_id as sub_aircraft_type_id, b.brand_id as sub_brand_id, b.aircraft_type_name as sub_aircraft_type_name, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time
  38. from brand_t a
  39. left join aircraft_type_t b on b.brand_id = a.brand_id
  40. where a.brand_id = #{brandId}
  41. </select>
  42. <insert id="insertBrand" parameterType="Brand" useGeneratedKeys="true" keyProperty="brandId">
  43. insert into brand_t
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="brandName != null">brand_name,</if>
  46. <if test="createBy != null">create_by,</if>
  47. <if test="createTime != null">create_time,</if>
  48. <if test="updateBy != null">update_by,</if>
  49. <if test="updateTime != null">update_time,</if>
  50. </trim>
  51. <trim prefix="values (" suffix=")" suffixOverrides=",">
  52. <if test="brandName != null">#{brandName},</if>
  53. <if test="createBy != null">#{createBy},</if>
  54. <if test="createTime != null">#{createTime},</if>
  55. <if test="updateBy != null">#{updateBy},</if>
  56. <if test="updateTime != null">#{updateTime},</if>
  57. </trim>
  58. </insert>
  59. <update id="updateBrand" parameterType="Brand">
  60. update brand_t
  61. <trim prefix="SET" suffixOverrides=",">
  62. <if test="brandName != null">brand_name = #{brandName},</if>
  63. <if test="createBy != null">create_by = #{createBy},</if>
  64. <if test="createTime != null">create_time = #{createTime},</if>
  65. <if test="updateBy != null">update_by = #{updateBy},</if>
  66. <if test="updateTime != null">update_time = #{updateTime},</if>
  67. </trim>
  68. where brand_id = #{brandId}
  69. </update>
  70. <delete id="deleteBrandByBrandId" parameterType="Long">
  71. delete from brand_t where brand_id = #{brandId}
  72. </delete>
  73. <delete id="deleteBrandByBrandIds" parameterType="String">
  74. delete from brand_t where brand_id in
  75. <foreach item="brandId" collection="array" open="(" separator="," close=")">
  76. #{brandId}
  77. </foreach>
  78. </delete>
  79. <delete id="deleteAircraftTypeByBrandIds" parameterType="String">
  80. delete from aircraft_type_t where brand_id in
  81. <foreach item="brandId" collection="array" open="(" separator="," close=")">
  82. #{brandId}
  83. </foreach>
  84. </delete>
  85. <delete id="deleteAircraftTypeByBrandId" parameterType="Long">
  86. delete from aircraft_type_t where brand_id = #{brandId}
  87. </delete>
  88. <insert id="batchAircraftType">
  89. insert into aircraft_type_t( aircraft_type_id, brand_id, aircraft_type_name, create_by, create_time, update_by, update_time) values
  90. <foreach item="item" index="index" collection="list" separator=",">
  91. ( #{item.aircraftTypeId}, #{item.brandId}, #{item.aircraftTypeName}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
  92. </foreach>
  93. </insert>
  94. </mapper>