2. Invoice Search 3. Invoice Project Detailtags/Baseline_30082024_BACKEND_UAT
@@ -8,4 +8,6 @@ import java.util.List; | |||||
public interface PositionRepository extends AbstractRepository<Position, Long> { | public interface PositionRepository extends AbstractRepository<Position, Long> { | ||||
List<PositionSearchInfo> findPositionSearchInfoByDeletedFalse(); | List<PositionSearchInfo> findPositionSearchInfoByDeletedFalse(); | ||||
List<PositionSearchInfo> findPositionSearchInfoByIdAndDeletedFalse(Long id); | |||||
} | } |
@@ -22,6 +22,10 @@ open class PositionService( | |||||
return positionRepository.findPositionSearchInfoByDeletedFalse() | return positionRepository.findPositionSearchInfoByDeletedFalse() | ||||
} | } | ||||
open fun getPositionById(id: Long): List<PositionSearchInfo>{ | |||||
return positionRepository.findPositionSearchInfoByIdAndDeletedFalse(id) | |||||
} | |||||
open fun savePosition(request: NewPositionRequest): Position { | open fun savePosition(request: NewPositionRequest): Position { | ||||
val position = | val position = | ||||
Position().apply { | Position().apply { | ||||
@@ -26,6 +26,11 @@ class PositionController(private val positionService: PositionService | |||||
return positionService.allPositions() | return positionService.allPositions() | ||||
} | } | ||||
@GetMapping("/{id}") | |||||
fun getPositionById(@PathVariable id: Long): List<PositionSearchInfo>{ | |||||
return positionService.getPositionById(id) | |||||
} | |||||
@PostMapping("/new") | @PostMapping("/new") | ||||
fun saveProject(@Valid @RequestBody newPosition: NewPositionRequest): Position { | fun saveProject(@Valid @RequestBody newPosition: NewPositionRequest): Position { | ||||
return positionService.savePosition(newPosition) | return positionService.savePosition(newPosition) | ||||
@@ -3,9 +3,12 @@ package com.ffii.tsms.modules.data.web.models | |||||
import jakarta.validation.constraints.NotBlank | import jakarta.validation.constraints.NotBlank | ||||
data class NewPositionRequest ( | data class NewPositionRequest ( | ||||
@field: NotBlank(message = "Department code cannot be empty") | |||||
val id: Long, | |||||
@field: NotBlank(message = "Position code cannot be empty") | |||||
val positionCode: String, | val positionCode: String, | ||||
@field:NotBlank(message = "Department name cannot be empty") | |||||
@field:NotBlank(message = "Position name cannot be empty") | |||||
val positionName: String, | val positionName: String, | ||||
val description: String | val description: String | ||||
@@ -1,8 +1,16 @@ | |||||
package com.ffii.tsms.modules.project.entity; | package com.ffii.tsms.modules.project.entity; | ||||
import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | ||||
interface ProjectRepository : AbstractRepository<Project, Long> { | interface ProjectRepository : AbstractRepository<Project, Long> { | ||||
fun findProjectSearchInfoBy(): List<ProjectSearchInfo> | fun findProjectSearchInfoBy(): List<ProjectSearchInfo> | ||||
fun findInvoiceSearchInfoBy(): List<InvoiceSearchInfo> | |||||
fun findInvoiceSearchInfoById(id: Long): List<InvoiceSearchInfo> | |||||
fun findInvoiceInfoSearchInfoById(id: Long): List<InvoiceInfoSearchInfo> | |||||
} | } |
@@ -0,0 +1,17 @@ | |||||
package com.ffii.tsms.modules.project.entity.projections | |||||
import org.springframework.beans.factory.annotation.Value | |||||
interface InvoiceInfoSearchInfo { | |||||
val id: Long? | |||||
@get:Value("#{target.customer.code} - #{target.customer.name }") | |||||
val client: String? | |||||
@get:Value("#{target.custLeadName}") | |||||
val attention: String? | |||||
@get:Value("#{target.customer.address}") | |||||
val address: String? | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package com.ffii.tsms.modules.project.entity.projections | |||||
import org.springframework.beans.factory.annotation.Value | |||||
interface InvoiceSearchInfo { | |||||
val id: Long? | |||||
@get:Value("#{target.name}") | |||||
val projectName: String? | |||||
@get:Value("#{target.code}") | |||||
val projectCode: String? | |||||
} |
@@ -5,6 +5,8 @@ import com.ffii.tsms.modules.data.service.CustomerContactService | |||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | ||||
import com.ffii.tsms.modules.data.service.CustomerService | import com.ffii.tsms.modules.data.service.CustomerService | ||||
import com.ffii.tsms.modules.project.entity.* | import com.ffii.tsms.modules.project.entity.* | ||||
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.NewProjectRequest | import com.ffii.tsms.modules.project.web.models.NewProjectRequest | ||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||
@@ -28,6 +30,18 @@ open class ProjectsService( | |||||
return projectRepository.findProjectSearchInfoBy() | return projectRepository.findProjectSearchInfoBy() | ||||
} | } | ||||
open fun allInvoices(): List<InvoiceSearchInfo> { | |||||
return projectRepository.findInvoiceSearchInfoBy() | |||||
} | |||||
open fun getProjectDetailById(id: Long): List<InvoiceSearchInfo> { | |||||
return projectRepository.findInvoiceSearchInfoById(id) | |||||
} | |||||
open fun getInvoiceInfoById(id: Long): List<InvoiceInfoSearchInfo> { | |||||
return projectRepository.findInvoiceInfoSearchInfoById(id) | |||||
} | |||||
open fun allProjectCategories(): List<ProjectCategory> { | open fun allProjectCategories(): List<ProjectCategory> { | ||||
return projectCategoryRepository.findAll() | return projectCategoryRepository.findAll() | ||||
} | } | ||||
@@ -0,0 +1,32 @@ | |||||
package com.ffii.tsms.modules.project.web | |||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | |||||
import com.ffii.tsms.modules.project.service.ProjectsService | |||||
import org.springframework.web.bind.annotation.GetMapping | |||||
import org.springframework.web.bind.annotation.RequestMapping | |||||
import org.springframework.web.bind.annotation.RequestParam | |||||
import org.springframework.web.bind.annotation.RestController | |||||
@RestController | |||||
@RequestMapping("/invoices") | |||||
class InvoiceController( | |||||
private val projectsService: ProjectsService | |||||
) { | |||||
@GetMapping | |||||
fun allInvoice(): List<InvoiceSearchInfo> { | |||||
return projectsService.allInvoices() | |||||
} | |||||
@GetMapping("/getProjectDetailById") | |||||
fun getInvoiceById(@RequestParam("id") id: Long): List<InvoiceSearchInfo> { | |||||
return projectsService.getProjectDetailById(id) | |||||
} | |||||
@GetMapping("/getInvoiceInfoById") | |||||
fun getInvoiceInfoById(@RequestParam("id") id: Long): List<InvoiceInfoSearchInfo> { | |||||
return projectsService.getInvoiceInfoById(id) | |||||
} | |||||
} |