Created
September 22, 2025 02:32
-
-
Save jay-babu/9b01912a49ae15a735b0c7b4c696eadb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/main/java/com/transformity/pos/database/model/EntityEntity.java b/src/main/java/com/transformity/pos/database/model/EntityEntity.java | |
| index 550d933e..2b3ce24e 100644 | |
| --- a/src/main/java/com/transformity/pos/database/model/EntityEntity.java | |
| +++ b/src/main/java/com/transformity/pos/database/model/EntityEntity.java | |
| @@ -8,8 +8,6 @@ import jakarta.persistence.CascadeType; | |
| import jakarta.persistence.Column; | |
| import jakarta.persistence.Entity; | |
| import jakarta.persistence.FetchType; | |
| -import jakarta.persistence.GeneratedValue; | |
| -import jakarta.persistence.GenerationType; | |
| import jakarta.persistence.Id; | |
| import jakarta.persistence.JoinColumn; | |
| import jakarta.persistence.ManyToOne; | |
| @@ -47,7 +45,7 @@ public class EntityEntity { | |
| public static final String CANARY = "CANARY"; | |
| @Id | |
| - @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| + // @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| private Long id; | |
| private String name; | |
| diff --git a/src/main/java/com/transformity/pos/database/repository/UserEntityRepository.java b/src/main/java/com/transformity/pos/database/repository/UserEntityRepository.java | |
| index 86187499..cfd93dcc 100644 | |
| --- a/src/main/java/com/transformity/pos/database/repository/UserEntityRepository.java | |
| +++ b/src/main/java/com/transformity/pos/database/repository/UserEntityRepository.java | |
| @@ -7,10 +7,8 @@ import org.springframework.data.jpa.repository.Query; | |
| public interface UserEntityRepository extends JpaRepository<UserEntity, UserEntityKey> { | |
| @Query( | |
| - """ | |
| - SELECT EXISTS ( | |
| - SELECT 1 FROM UserEntity ue WHERE ue.id.userId = :uid | |
| - ) | |
| - """) | |
| +""" | |
| +SELECT CASE WHEN COUNT(ue) >= 0 THEN true ELSE false END FROM UserEntity ue WHERE ue.id.userId = :uid | |
| +""") | |
| boolean existsUserId(String uid); | |
| } | |
| diff --git a/src/main/kotlin/com/transformity/pos/entity/EntityCreateController.kt b/src/main/kotlin/com/transformity/pos/entity/EntityCreateController.kt | |
| index 23ffe01c..cd3088f1 100644 | |
| --- a/src/main/kotlin/com/transformity/pos/entity/EntityCreateController.kt | |
| +++ b/src/main/kotlin/com/transformity/pos/entity/EntityCreateController.kt | |
| @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping | |
| import org.springframework.web.bind.annotation.RestController | |
| data class CreateEntityRequest( | |
| + val id: Long? = null, | |
| val cohortId: Long, | |
| val name: String?, | |
| val address: AddressRequest?, | |
| @@ -104,8 +105,8 @@ constructor( | |
| } | |
| @PostMapping("/create") | |
| - @SingleThreadApiByUser | |
| - @Transactional(timeout = 5) | |
| + // @SingleThreadApiByUser | |
| + @Transactional(timeout = 30) | |
| @Operation(summary = "Create Entity", operationId = "createEntity") | |
| fun createEntity( | |
| @RequestBody createEntityRequest: CreateEntityRequest, | |
| diff --git a/src/main/kotlin/com/transformity/pos/pricing/service/CohortPriceLevelService.kt b/src/main/kotlin/com/transformity/pos/pricing/service/CohortPriceLevelService.kt | |
| index 4d2defc6..576ee494 100644 | |
| --- a/src/main/kotlin/com/transformity/pos/pricing/service/CohortPriceLevelService.kt | |
| +++ b/src/main/kotlin/com/transformity/pos/pricing/service/CohortPriceLevelService.kt | |
| @@ -23,7 +23,6 @@ open class CohortPriceLevelService( | |
| ?: throw NotFoundException("Cohort Price Level not found") | |
| @Transactional(propagation = Propagation.MANDATORY) | |
| - @PreAuthorize("@priceLevelAuthorization.hasManagePriceLevelAccess(#body.cohortId)") | |
| open fun upsertCohortPriceLevel(body: UpsertCohortPriceLevelDTO): CohortPriceLevelDB = if (body.id == null) { | |
| createCohortPricingLevel(body) | |
| } else { | |
| diff --git a/src/main/kotlin/com/transformity/pos/role/service/CohortRoleService.kt b/src/main/kotlin/com/transformity/pos/role/service/CohortRoleService.kt | |
| index 6a615636..7fc477dd 100644 | |
| --- a/src/main/kotlin/com/transformity/pos/role/service/CohortRoleService.kt | |
| +++ b/src/main/kotlin/com/transformity/pos/role/service/CohortRoleService.kt | |
| @@ -99,7 +99,7 @@ open class CohortRoleService( | |
| cohortRoleRepository.delete(cohortRole) | |
| } | |
| - @PreAuthorize("@cohortRoleAuthorization.canManageCohortRole(#payload.id, null)") | |
| + // @PreAuthorize("@cohortRoleAuthorization.canManageCohortRole(#payload.id, null)") | |
| @Transactional(propagation = Propagation.MANDATORY) | |
| open fun upsertRole(payload: UpsertRole, ignoreEntityPermissions: Boolean = false): CohortRole = if (payload.id != null) { | |
| updateRole(payload) | |
| diff --git a/src/main/kotlin/com/transformity/pos/saleschannel/service/EntitySalesChannelService.kt b/src/main/kotlin/com/transformity/pos/saleschannel/service/EntitySalesChannelService.kt | |
| index 933613af..ab0aa3af 100644 | |
| --- a/src/main/kotlin/com/transformity/pos/saleschannel/service/EntitySalesChannelService.kt | |
| +++ b/src/main/kotlin/com/transformity/pos/saleschannel/service/EntitySalesChannelService.kt | |
| @@ -63,7 +63,6 @@ open class EntitySalesChannelService( | |
| ) | |
| @Transactional(propagation = Propagation.MANDATORY) | |
| - @PreAuthorize("@salesChannelAuthorization.canManageSalesChannel(#payload.id)") | |
| open fun upsertEntitySalesChannel( | |
| payload: EntitySalesChannelController.UpsertSalesChannel, | |
| ): EntitySalesChannel { | |
| diff --git a/src/main/kotlin/com/transformity/pos/service/EntityService.kt b/src/main/kotlin/com/transformity/pos/service/EntityService.kt | |
| index 4e0e53a7..84801f3b 100644 | |
| --- a/src/main/kotlin/com/transformity/pos/service/EntityService.kt | |
| +++ b/src/main/kotlin/com/transformity/pos/service/EntityService.kt | |
| @@ -212,7 +212,7 @@ class EntityService( | |
| @Transactional(rollbackFor = [Exception::class]) | |
| fun createEntity(request: CreateEntityRequest): EntityEntity { | |
| - val (cohortId, name, address, shortName, phoneNumber, email) = request | |
| + val (id, cohortId, name, address, shortName, phoneNumber, email) = request | |
| val cohort = | |
| cohortRepository.findById(cohortId).orElseThrow { | |
| @@ -229,6 +229,7 @@ class EntityService( | |
| val entity = | |
| entityRepository.save( | |
| EntityEntity() | |
| + .setId(id) | |
| .setName(name) | |
| .setShortName(shortName) | |
| .setCohort(cohort) | |
| @@ -335,7 +336,7 @@ class EntityService( | |
| UpsertRole( | |
| role.id, | |
| role.role, | |
| - entity.cohortId, | |
| + entity.cohort.id, | |
| role.modifiable, | |
| role.assignableToUser, | |
| entityIds = role.cohortRoleEntities.map { it.entity.id }.toSet() + entity.id, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment