package com.persagy.server.service.base

import com.persagy.database.SAbstractDao
import com.persagy.server.datacenter.models.entities.base.RBaseInfo
import com.persagy.server.synchronize.MessageHandler
import com.persagy.service.SObjectService
import com.persagy.service.utils.SSpringContextUtil
import org.slf4j.LoggerFactory

/**
 * 关系处理服务基类
 *
 * @author 张维新
 */
open class RService<ENTITY : RBaseInfo>(daoClass: SAbstractDao<ENTITY>) : SObjectService<ENTITY>(daoClass) {
    companion object {
        /** 日志 */
        private val logger = LoggerFactory.getLogger(RService::class.java)

        /** MQ消息对象 */
        private val messageHandler by lazy {
            SSpringContextUtil.getBean(MessageHandler::class.java) as MessageHandler
        }
    } // Companion object

    /**
     * 创建关系
     *
     * @param   ENTITY   关系对象
     */
//    fun create(ENTITY: ENTITY): SCreateResponse<ENTITY> {
//        return try {
//            ENTITY.id = IdUtils.uuidCreate()
//            val isInsert = insert(ENTITY)
//            if (isInsert){
//                SCreateResponse(SResponseType.success)
//            }else{
//                SCreateResponse(SResponseType.failure)
//            }
//        } catch (e: Exception) {
//            e.printStackTrace()
//            SCreateResponse(SResponseType.failure,e.message.toString())
//        }
//    } // Function create()


} // Class Service
