package com.persagy.server.mappers

import org.apache.ibatis.annotations.*
import org.springframework.stereotype.Repository

/**
 * 关系计算-建筑
 *
 * @author 邓婷婷
 */
@Mapper
@Repository
interface IRelationCountMapper {

    /**
     * 建筑下的业务空间
     *@param projectId 项目id
     *@param tables 参与计算的表的全名称, 带schema名, 以英文逗号隔开
     */
    @SelectProvider(type = IRelationCountProvider::class , method = "getSql")
    fun relationCount(@Param("tableName") tableName: String, @Param("projectId") projectId: String): Int

    /**
     * 更新计算状态
     */
    @Update("update graphtype.relation_type_project set computational_state = #{computationalState} where id = #{id}")
    fun updateState(@Param("id") id: String,@Param("computationalState")computationalState: Long): Boolean

    /**
     * 更新计算状态和最后计算时间
     */
    @Update("update graphtype.relation_type_project set computational_state = #{computationalState},computing_time = now() where id = #{id}")
    fun updateStateAndLastTime(@Param("id") id: String,@Param("computationalState")computationalState: Long): Boolean

} // Interface IRelationCountMapper