package gaf3.core.services.bff

import gaf3.core.data.PagedData
import gaf3.core.services.bff.service.BffUserDeptService
import gaf3.core.services.bff.service.BffUserRoleService
import gaf3.core.services.role.entity.GafRoleItem
import gaf3.core.services.user.domain.UserInfo
import gaf3.core.services.user.entity.GafUserInfo
import org.springframework.web.bind.annotation.*

@RestController("gafBffServiceController")
class BffServiceController(val deptUser: BffUserDeptService, val roleUser: BffUserRoleService) {
//    companion object {
//        val log: Logger = LoggerFactory.getLogger(BffDeptUserService::class.java)
//    }

    @GetMapping(path = ["/gaf/bff/dept/users"])
    fun findDeptUsers(deptId: String?, filter: GafUserInfo, skip: Int? = 0, limit: Int? = 100, exact: Boolean?): PagedData<UserInfo>{
        return deptUser.find(filter, deptId, skip?:0, limit?: 100, exact ?: true )
    }

    @GetMapping(path = ["/gaf/bff/role/users"])
    fun findRoleUsers(roleId: String?, filter: GafUserInfo, skip: Int? = 0, limit: Int? = 100, exact: Boolean?): PagedData<UserInfo>{
        return roleUser.find(filter, roleId, skip?:0, limit?: 100, exact ?: true )
    }

    @GetMapping(path = ["/gaf/bff/user/roles"])
    fun findUserRoles(userId: String?, filter: GafRoleItem, skip: Int? = 0, limit: Int? = 100): PagedData<GafRoleItem>{
        return roleUser.find(filter, userId, skip?:0, limit?: 100 )
    }
}