<?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.qianwen.smartman.modules.system.mapper.CustomTemplateFieldRelationMapper">
|
|
<select id="getConditionFields" parameterType="long"
|
resultType="com.qianwen.smartman.modules.system.vo.CustomConditionFieldInfoVO">
|
SELECT tf.id fieldId,
|
tf.field_name fieldName,
|
tf.field_description fieldDescription,
|
tf.field_code fieldCode,
|
tfr.id relationId,
|
<if test="_databaseId == 'mysql' ">
|
IF
|
(tfr.id IS NULL, 0, 1) querySupport,
|
</if>
|
<if test="_databaseId == 'dm' ">
|
IF
|
(tfr.id IS NULL, 0, 1) querySupport,
|
</if>
|
<if test="_databaseId == 'oracle' ">
|
CASE
|
WHEN
|
tfr.id IS NULL THEN
|
0 ELSE 1
|
END ,
|
</if>
|
tfr.sort querySort,
|
tf.system_field systemField
|
FROM
|
blade_custom_template_field tf
|
LEFT JOIN blade_custom_field_relation tfr ON tfr.field_id = tf.id
|
AND tfr.is_deleted = 0
|
AND tfr.config_type = 5
|
AND tfr.template_id = #{templateId}
|
WHERE
|
tf.is_deleted = 0
|
AND tf.support_query = 1
|
and tf.business_type = #{businessType}
|
ORDER BY
|
tf.id
|
</select>
|
|
|
<select id="getInsertField" parameterType="long"
|
resultType="com.qianwen.smartman.modules.system.vo.CustomTemplateFieldRelationVO">
|
SELECT tf.id fieldId,
|
tf.field_name fieldName,
|
tf.field_code fieldCode,
|
tf.field_type fieldType,
|
tfr.id relationId,
|
tfr.sort import_sort,
|
tf.system_field systemField
|
FROM blade_custom_field_relation tfr
|
LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
|
AND tf.id IS NOT NULL
|
WHERE tfr.is_deleted = 0
|
AND tfr.config_type = 1
|
AND tfr.template_id = #{query.templateId}
|
<if test="query.fieldNames != null and query.fieldNames.size > 0">
|
AND tf.field_name IN
|
<foreach collection="query.fieldNames" separator="," item="item" open="(" close=")" index="">
|
#{item}
|
</foreach>
|
</if>
|
<if test="query.relationIds != null and query.relationIds.size > 0">
|
AND tfr.id IN
|
<foreach collection="query.relationIds" separator="," item="item" open="(" close=")" index="">
|
#{item}
|
</foreach>
|
</if>
|
order by tfr.sort
|
</select>
|
|
|
<select id="getSystemFieldMaxSort" resultType="int">
|
SELECT max(sort)
|
FROM blade_custom_field_relation tfr
|
left join blade_custom_template_field tf on tfr.field_id = tf.id
|
WHERE tfr.is_deleted = 0
|
and tfr.template_id = #{templateId}
|
and tfr.config_type = #{configType}
|
and tf.system_field = 1
|
</select>
|
|
<select id="getImportFieldsByBusinessType"
|
resultType="com.qianwen.smartman.modules.system.vo.CustomImportFieldInfoVO">
|
SELECT tf.id fieldId,
|
tf.field_name fieldName,
|
tf.field_code fieldCode,
|
tf.system_field systemField,
|
tf.must_import mustField,
|
tf.must_import importField,
|
tf.import_sort importSort
|
FROM blade_custom_template_field tf
|
WHERE tf.is_deleted = 0
|
AND tf.support_import = 1
|
and tf.add_show = 1
|
AND tf.business_type = #{businessType}
|
order by tf.import_sort asc
|
</select>
|
<select id="getImportFields"
|
resultType="com.qianwen.smartman.modules.system.dto.CustomTemplateFieldRelationDTO">
|
SELECT
|
tf.field_name fieldName,
|
tf.field_code fieldCode,
|
tfr.id id,
|
tf.system_field systemField,
|
tfr.must_field mustField,
|
tfr.template_id templateId,
|
ct.template_name templateName,
|
tf.must_import mustImport
|
FROM blade_custom_field_relation tfr
|
LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
|
LEFT JOIN blade_custom_template ct ON tfr.template_id = ct.id
|
WHERE tf.is_deleted = 0
|
AND tfr.is_deleted = 0
|
AND tfr.config_type = 1
|
and tf.add_show = 1
|
AND tfr.template_id in
|
<foreach collection="templateIds" separator="," item="item" open="(" close=")" index="index">
|
#{item}
|
</foreach>
|
order by tf.import_sort asc
|
</select>
|
<select id="getOldstRelation"
|
resultType="com.qianwen.smartman.modules.system.vo.CustomImportFieldInfoVO">
|
SELECT tf.id fieldId,
|
tf.field_name fieldName,
|
tf.field_code fieldCode,
|
tfr.id id,
|
tf.system_field systemField,
|
tfr.must_field mustField,
|
tfr.template_id templateId,
|
ct.template_name templateName,
|
tf.must_import mustImport,
|
tfr.sort sort
|
FROM blade_custom_field_relation tfr
|
LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
|
LEFT JOIN blade_custom_template ct ON tfr.template_id = ct.id
|
WHERE tf.system_field = 1
|
AND tfr.config_type = #{configType}
|
AND tfr.template_id = #{templateId}
|
order by tfr.create_time asc
|
</select>
|
|
</mapper>
|