<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.archives.mapper.TCompleteMonitorSetBaseInfoMapper">

  <resultMap id="tCompleteMonitorSetBaseInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TCompleteMonitorSetBaseInfo">
    <id property="id" column="ID"/>
    <result property="baseType" column="BASE_TYPE"/>
    <result property="baseNum" column="BASE_NUM"/>
    <result property="baseName" column="BASE_NAME"/>
    <result property="baseRemark" column="BASE_REMARK"/>
    <result property="isMonitor" column="IS_MONITOR"/>
    <result property="baseColumn" column="BASE_COLUMN"/>
    <result property="baseTable" column="BASE_TABLE"/>
    <result property="baseField" column="BASE_FIELD"/>
  </resultMap>

	<!--获取ids对应的所有的配置字段-->
    <select id="getBaseInfoByIds" resultMap="tCompleteMonitorSetBaseInfoMap">
		SELECT a.BASE_TABLE,GROUP_CONCAT(a.BASE_COLUMN SEPARATOR '*') BASE_COLUMN
		FROM t_complete_monitor_set_base_info a
		where a.id in (${ids})
		GROUP BY a.BASE_TABLE
    </select>

	<!-- 获取属性字段 -->
    <select id="getIdByType" resultType="java.lang.String">
		select s.BASE_ID from t_complete_monitor_set s where s.CONTRACT_TYPE_NAME like concat('%', #{typeName},'%') limit 1
    </select>
	<!-- 获取属性字段 -->
    <select id="getIdByOne" resultType="java.lang.String">
		select s.BASE_ID from t_complete_monitor_set s where s.id = '1'
    </select>

	<!-- 获取属性字段 -->
    <select id="getBaseFieldByIdArr" resultType="java.lang.String">
		SELECT BASE_FIELD
		FROM t_complete_monitor_set_base_info a
		where a.id in
		<foreach item="idStr" index="index" collection="idArr" open="("
				 separator="," close=")">
			#{idStr}
		</foreach>
    </select>
</mapper>
