|
@@ -5,9 +5,11 @@ import com.swagger.rest.repositories.MemberRepository
|
|
import com.swagger.rest.repositories.PlatformRepository
|
|
import com.swagger.rest.repositories.PlatformRepository
|
|
import com.swagger.rest.repositories.ProjectRepository
|
|
import com.swagger.rest.repositories.ProjectRepository
|
|
import com.swagger.rest.repositories.UserRepository
|
|
import com.swagger.rest.repositories.UserRepository
|
|
|
|
+import jakarta.persistence.criteria.Predicate
|
|
import org.springframework.data.domain.PageRequest
|
|
import org.springframework.data.domain.PageRequest
|
|
import org.springframework.data.domain.Pageable
|
|
import org.springframework.data.domain.Pageable
|
|
import org.springframework.data.domain.Sort
|
|
import org.springframework.data.domain.Sort
|
|
|
|
+import org.springframework.data.jpa.domain.Specification
|
|
import org.springframework.http.HttpStatus
|
|
import org.springframework.http.HttpStatus
|
|
import org.springframework.http.ResponseEntity
|
|
import org.springframework.http.ResponseEntity
|
|
import org.springframework.security.core.context.SecurityContextHolder
|
|
import org.springframework.security.core.context.SecurityContextHolder
|
|
@@ -35,11 +37,12 @@ class ProjectController(
|
|
fun getProject(
|
|
fun getProject(
|
|
@RequestParam(defaultValue = 0.toString()) page: Int,
|
|
@RequestParam(defaultValue = 0.toString()) page: Int,
|
|
@RequestParam(defaultValue = 3.toString()) limit: Int,
|
|
@RequestParam(defaultValue = 3.toString()) limit: Int,
|
|
- @RequestParam(defaultValue = "id, desc") sort: Array<String>
|
|
|
|
|
|
+ @RequestParam(defaultValue = "project_id, desc") sort: Array<String>
|
|
): Any {
|
|
): Any {
|
|
|
|
+ val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
return try {
|
|
return try {
|
|
val orders: MutableList<Sort.Order> = ArrayList()
|
|
val orders: MutableList<Sort.Order> = ArrayList()
|
|
- val column = listOf("id", "name", "description", "owner")
|
|
|
|
|
|
+ val column = listOf("project_id", "name", "description", "owner")
|
|
val sort2 = if (!sort.contains(",")) {
|
|
val sort2 = if (!sort.contains(",")) {
|
|
sort + ",desc"
|
|
sort + ",desc"
|
|
} else {
|
|
} else {
|
|
@@ -60,7 +63,7 @@ class ProjectController(
|
|
orders.add(Sort.Order(getSortDirection(sort2[1]), sort2[0]))
|
|
orders.add(Sort.Order(getSortDirection(sort2[1]), sort2[0]))
|
|
}
|
|
}
|
|
val pagingSort: Pageable = PageRequest.of(page, limit, Sort.by(orders))
|
|
val pagingSort: Pageable = PageRequest.of(page, limit, Sort.by(orders))
|
|
- val projects = projectRepository.findAll(pagingSort)
|
|
|
|
|
|
+ val projects = projectRepository.findOwnerOrMember(userId.id.toString(), pagingSort)
|
|
val ret = projects.content
|
|
val ret = projects.content
|
|
val response: MutableMap<String, Any> = HashMap()
|
|
val response: MutableMap<String, Any> = HashMap()
|
|
response["currentPage"] = projects.number
|
|
response["currentPage"] = projects.number
|