package cn.sagacloud.server.algorithm.controllers.modelEntity

import cn.sagacloud.server.algorithm.models.entities.Project
import cn.sagacloud.server.algorithm.models.group.GroupProjectDTO
import cn.sagacloud.server.algorithm.models.request.BaseProjectRequest
import cn.sagacloud.server.algorithm.services.group.GroupProjectService
import com.sybotan.mybatis.SMybatisDao
import com.sybotan.service.SObjectService
import com.sybotan.service.models.responses.SQueryResponse
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController

/**
 *
 * @author  Cainga
 * @date  2021/1/26 16:39
 */
@Api(tags = ["集团项目配置接口"])
@RestController
class GroupProjectController {

    companion object {
        // 日志
        private val logger = LoggerFactory.getLogger(GroupProjectController::class.java)
    } // Companion object
    
    val projectService = SObjectService(SMybatisDao(Project::class.java))  // 项目
    @Autowired
    lateinit var groupProjectService:GroupProjectService  // 项目

    /**
     * 查询集团拥有的项目
     *
     * @param   request     查询请求
     * @return  查询结果应答信息
     */
    @ApiOperation(value = "查询集团拥有的项目", notes = "")
    @PostMapping(value = ["/rwd/groupAndSchema/admin/queryGroupProjectList"])
    fun queryGroupProjectList(@RequestBody request: BaseProjectRequest): SQueryResponse<GroupProjectDTO> {
        val list:List<GroupProjectDTO> = groupProjectService.queryGroupProjectList(request)
        val response = SQueryResponse<GroupProjectDTO>()
        response.content=list
        return response
    } // Function queryGroupProjectList()
}