Pārlūkot izejas kodu

Add project details endpoint

tags/Baseline_30082024_BACKEND_UAT
Wayne pirms 1 gada
vecāks
revīzija
758003f1d8
3 mainītis faili ar 74 papildinājumiem un 5 dzēšanām
  1. +33
    -4
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt
  2. +7
    -1
      src/main/java/com/ffii/tsms/modules/project/web/ProjectsController.kt
  3. +34
    -0
      src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt

+ 33
- 4
src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt Parādīt failu

@@ -7,12 +7,10 @@ import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo
import com.ffii.tsms.modules.data.service.CustomerService
import com.ffii.tsms.modules.data.service.GradeService
import com.ffii.tsms.modules.project.entity.*
import com.ffii.tsms.modules.project.entity.Milestone
import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo
import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo
import com.ffii.tsms.modules.project.web.models.AssignedProject
import com.ffii.tsms.modules.project.web.models.MilestoneInfo
import com.ffii.tsms.modules.project.web.models.NewProjectRequest
import com.ffii.tsms.modules.project.web.models.NewProjectResponse
import com.ffii.tsms.modules.project.web.models.*
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate
@@ -197,6 +195,37 @@ open class ProjectsService(
}
}

open fun getProjectDetails(projectId: Long): EditProjectDetails? {
val project = projectRepository.findById(projectId)

return project.getOrNull()?.let {
val customerContact = it.customer?.id?.let { customerId -> customerContactService.findAllByCustomerId(customerId) } ?: emptyList()

EditProjectDetails(
projectCode = it.code,
projectName = it.name,
projectCategoryId = it.projectCategory?.id,
projectDescription = it.description,
projectLeadId = it.teamLead?.id,
serviceTypeId = it.serviceType?.id,
fundingTypeId = it.fundingType?.id,
contractTypeId = it.contractType?.id,
locationId = it.location?.id,
buildingTypeIds = it.buildingTypes.mapNotNull { buildingType -> buildingType.id },
workNatureIds = it.workNatures.mapNotNull { workNature -> workNature.id },
clientId = it.customer?.id,
clientContactId = customerContact.find { contact -> contact.name == it.custLeadName }?.id,
clientSubsidiaryId = it.customerSubsidiary?.id,
totalManhour = it.totalManhour,
manhourPercentageByGrade = emptyMap(),
taskGroups = emptyMap(),
allocatedStaffIds = emptyList(),
milestones = emptyMap(),
expectedProjectFee = it.expectedTotalFee
)
}
}

open fun allFundingTypes(): List<FundingType> {
return fundingTypeRepository.findAll()
}


+ 7
- 1
src/main/java/com/ffii/tsms/modules/project/web/ProjectsController.kt Parādīt failu

@@ -1,11 +1,12 @@
package com.ffii.tsms.modules.project.web

import com.ffii.core.exception.NotFoundException
import com.ffii.tsms.modules.data.entity.*
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo
import com.ffii.tsms.modules.project.entity.Project
import com.ffii.tsms.modules.project.entity.ProjectCategory
import com.ffii.tsms.modules.project.service.ProjectsService
import com.ffii.tsms.modules.project.web.models.AssignedProject
import com.ffii.tsms.modules.project.web.models.EditProjectDetails
import com.ffii.tsms.modules.project.web.models.NewProjectRequest
import com.ffii.tsms.modules.project.web.models.NewProjectResponse
import jakarta.validation.Valid
@@ -34,6 +35,11 @@ class ProjectsController(private val projectsService: ProjectsService) {
return projectsService.saveProject(newProject)
}

@GetMapping("/projectDetails/{id}")
fun projectDetails(@PathVariable id: Long): EditProjectDetails {
return projectsService.getProjectDetails(id) ?: throw NotFoundException()
}

@GetMapping("/fundingTypes")
fun projectFundingTypes(): List<FundingType> {
return projectsService.allFundingTypes()


+ 34
- 0
src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt Parādīt failu

@@ -0,0 +1,34 @@
package com.ffii.tsms.modules.project.web.models

data class EditProjectDetails(
// Project details
val projectCode: String?,
val projectName: String?,
val projectCategoryId: Long?,
val projectDescription: String?,
val projectLeadId: Long?,

val serviceTypeId: Long?,
val fundingTypeId: Long?,
val contractTypeId: Long?,
val locationId: Long?,
val buildingTypeIds: List<Long>,
val workNatureIds: List<Long>,

// Client details
val clientId: Long?,
val clientContactId: Long?,
val clientSubsidiaryId: Long?,

// Allocation
val totalManhour: Double?,
val manhourPercentageByGrade: Map<Long, Double>,
val taskGroups: Map<Long, TaskGroupAllocation>,
val allocatedStaffIds: List<Long>,

// Milestones
val milestones: Map<Long, Milestone>,

// Miscellaneous
val expectedProjectFee: Double?
)

Notiek ielāde…
Atcelt
Saglabāt