package com.persagy.server.models.mappers

import com.persagy.server.models.EquipCompon
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
import org.springframework.stereotype.Repository

/**
 * 查询当前设备类型的允许的所有部件类型，设备下的部件对应数量
 *
 * @author 张维新
 */
@Mapper
@Repository
interface REquipComponMapper {
    /** 统计项目下允许创建的部件类型，以及项目下创建的部件数量 */
    @Select("SELECT code,name,(select count(1) from public.equipment where parent_id = #{projectId} AND class_code = code) FROM dict.def_class WHERE group_code = (SELECT group_code FROM dict.project WHERE id = #{projectId}) AND equipment_code = #{category} AND project_id = #{projectId}")
    fun getEquipCompon(projectId: String,category: String): List<EquipCompon>

}