package com.persagy.labsl.services.mappers

import com.persagy.labsl.models.entities.auxiliary.CategoryCode
import com.persagy.labsl.models.entities.tpt.Graph
import com.persagy.labsl.models.entities.tpt.pub.GraphPub
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select
import org.springframework.stereotype.Repository

/**
 * 自定义SQL
 *
 * @author  wx
 * @date  2020/9/17 12:01
 */
@Repository
@Mapper
interface CustomMapper {
    /** 未发布 */
    @Select("SELECT category_id as categoryId FROM labsl.graph  WHERE project_id = #{projectId} AND state =1 GROUP BY category_id")
    fun calcAffected(@Param("projectId") projectId: String) : ArrayList<CategoryCode>?

    /** 已发布 */
    @Select("SELECT category_id as categoryId FROM labsl.graph_pub  WHERE project_id = #{projectId} AND state =0 GROUP BY category_id")
    fun pubCategory(@Param("projectId") projectId: String) : ArrayList<CategoryCode>?

    @Select("SELECT * FROM graph WHERE project_id = #{projectId} and label::text like  '%#{label}%'")
    fun containLabel(@Param("projectId") projectId: String,@Param("label") label: String): ArrayList<Graph>?

    @Select("SELECT * FROM graph_pub WHERE project_id = #{projectId} and label::text like  '%#{label}%'")
    fun containLabelPub(@Param("projectId") projectId: String,@Param("label") label: String): ArrayList<GraphPub>?

} // Interface CustomMapper