<?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.mzl.flower.mapper.flower.FlowerParamMapper">
|
|
<update id="createTable" parameterType="String">
|
CREATE TABLE ${table.name} (
|
<foreach collection="table.fields" item="field" open="" separator="," close="">
|
${field.column} ${field.type}
|
<choose>
|
<when test="field.primaryKey">
|
NOT NULL primary key
|
</when>
|
<otherwise>
|
DEFAULT NULL
|
</otherwise>
|
</choose>
|
<if test="field.comment != null and field.comment != ''">
|
COMMENT #{field.comment}
|
</if>
|
</foreach>
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=#{table.label}
|
</update>
|
|
<select id="selectParamList" resultType="com.mzl.flower.dto.response.flower.FlowerParamListDTO">
|
SELECT q.*
|
, (SELECT GROUP_CONCAT(fc.name) FROM t_flower_category fc WHERE fc.param_id = q.id) categories
|
FROM t_flower_param q
|
WHERE q.deleted = 0
|
<if test="condition.name != null and condition.name != ''">
|
AND q.name LIKE concat('%', #{condition.name},'%')
|
</if>
|
<if test="condition.categoryId != null and condition.categoryId != ''">
|
AND exists (
|
select 1 from t_flower_category fc where fc.id = #{condition.categoryId} and fc.param_id = q.id
|
)
|
</if>
|
ORDER BY q.sort_by, q.create_time Desc
|
</select>
|
|
<update id="insertTableData">
|
insert into ${tableName}
|
<foreach collection="columnList" item="column" open="(" separator="," close=")">
|
${column}
|
</foreach>
|
values
|
<foreach collection="valueList" item="value" open="(" separator="," close=")">
|
#{value}
|
</foreach>
|
</update>
|
|
<update id="updateTableDataById">
|
update ${tableName}
|
SET
|
<foreach collection="valueMapList" item="map" open="" separator="," close="">
|
${map.column} = #{map.value}
|
</foreach>
|
where ${idColumn} = #{idValue}
|
</update>
|
|
<select id="getTableDataById" resultType="java.util.Map">
|
SELECT *
|
FROM ${tableName}
|
where id = #{id}
|
</select>
|
</mapper>
|