File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
src/main/kotlin/be/sgl/backend Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ enum class SettingId {
55 REPRESENTATIVE_TITLE ,
66 REPRESENTATIVE_USERNAME ,
77 REPRESENTATIVE_SIGNATURE ,
8- CALENDAR_NAME
8+ CALENDAR_NAME ,
9+ STAFF_VISIBLE
910}
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package be.sgl.backend.service
33import be.sgl.backend.dto.BranchBaseDTO
44import be.sgl.backend.dto.BranchDTO
55import be.sgl.backend.entity.branch.Branch
6+ import be.sgl.backend.entity.branch.BranchStatus
7+ import be.sgl.backend.entity.setting.SettingId
68import be.sgl.backend.repository.BranchRepository
79import be.sgl.backend.repository.user.UserRepository
810import be.sgl.backend.service.exception.BranchNotFoundException
@@ -22,10 +24,14 @@ class BranchService {
2224 private lateinit var mapper: BranchMapper
2325 @Autowired
2426 private lateinit var imageService: ImageService
27+ @Autowired
28+ private lateinit var settingService: SettingService
2529
2630 fun getBranchDTOById (id : Int ): BranchDTO {
2731 val branch = getBranchById(id)
28- branch.staff = userRepository.getStaffForBranch(branch)
32+ if (branch.status != BranchStatus .ACTIVE || settingService.getOrDefault(SettingId .STAFF_VISIBLE , true )) {
33+ branch.staff = userRepository.getStaffForBranch(branch)
34+ }
2935 return mapper.toDto(branch)
3036 }
3137
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ class SettingService {
2525 return get(id)?.toDouble() ? : default
2626 }
2727
28+ fun getOrDefault (id : SettingId , default : Boolean ): Boolean {
29+ return get(id)?.toBoolean() ? : default
30+ }
31+
2832 fun update (id : SettingId , value : Any? ) {
2933 value ? : return settingRepository.deleteById(id.name)
3034 val setting = settingRepository.findByIdOrNull(id.name) ? : Setting (id, value)
You can’t perform that action at this time.
0 commit comments