package com.persagy.server.services.dict

import com.persagy.mybatis.SMybatisDao
import com.persagy.server.datacenter.models.entities.dict.EquipFamily
import com.persagy.server.datacenter.models.entities.dict.Family
import com.persagy.server.services.base.Service
import com.persagy.service.SBaseService
import com.persagy.service.models.enums.SResponseType
import com.persagy.service.models.responses.SQueryResponse

/**
 * 设备和族的关系
 *
 * @author 张维新
 */
object EquipFamilyService : Service<EquipFamily>(SMybatisDao(EquipFamily::class.java)) {

    /** 设备族服务 */
    val familyService = SBaseService(SMybatisDao(Family::class.java))

    /**
     * 查询所有设备族
     */
    fun familyAll(): SQueryResponse<Family> {
        return try {
            val queryBuilder = familyService.selectAll()
            val pageInfo = queryBuilder.pageQuery(1, 1000)
            SQueryResponse(pageInfo)
        } catch (e: Exception) {
            e.printStackTrace()
            SQueryResponse(SResponseType.failure, e.message!!)
        }
    }  // Function familyAll()

} // Object EquipFamilyService
