1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.example.mapper.StoreMapper">
- <sql id="Base_Column_List">
- id,owner_id,products_ids,address_ids,product_type_ids
- </sql>
- <select id="selectAll" resultType="com.example.entity.Store">
- select
- <include refid="Base_Column_List" />
- from store
- <where>
- <if test="id != null"> and id = #{id}</if>
- <if test="ownerId != null"> and owner_id = #{ownerId}</if>
- <if test="productsIds != null"> and products_ids like concat('%', #{productsIds}, '%')</if>
- <if test="addressIds != null"> and address_ids like concat('%', #{addressIds}, '%')</if>
- <if test="productTypeIds != null"> and product_type_ids like concat('%', #{productTypeIds}, '%')</if>
- </where>
- order by id desc
- </select>
- <select id="selectById" resultType="com.example.entity.Store">
- select
- <include refid="Base_Column_List" />
- from store
- where id = #{id}
- </select>
- <delete id="deleteById">
- delete from store
- where id = #{id}
- </delete>
- <insert id="insert" parameterType="com.example.entity.Store" useGeneratedKeys="true">
- insert into store
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">id,</if>
- <if test="ownerId != null">owner_id,</if>
- <if test="productsIds != null">products_ids,</if>
- <if test="addressIds != null">address_ids,</if>
- <if test="productTypeIds != null">product_type_ids,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">#{id},</if>
- <if test="ownerId != null">#{ownerId},</if>
- <if test="productsIds != null">#{productsIds},</if>
- <if test="addressIds != null">#{addressIds},</if>
- <if test="productTypeIds != null">#{productTypeIds},</if>
- </trim>
- </insert>
- <update id="updateById" parameterType="com.example.entity.Store">
- update store
- <set>
- <if test="ownerId != null">
- owner_id = #{ownerId},
- </if>
- <if test="productsIds != null">
- products_ids = #{productsIds},
- </if>
- <if test="addressIds != null">
- address_ids = #{addressIds},
- </if>
- <if test="productTypeIds != null">
- product_type_ids = #{productTypeIds},
- </if>
- </set>
- where id = #{id}
- </update>
- </mapper>
|