Merge pull request #546 from Oloodi/536-be-add-cost-center-entity-and-link-to-hubs
536 be add cost center entity and link to hubs
This commit is contained in:
3
apps/mobile/devtools_options.yaml
Normal file
3
apps/mobile/devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
description: This file stores settings for Dart & Flutter DevTools.
|
||||||
|
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||||
|
extensions:
|
||||||
@@ -1,37 +1,29 @@
|
|||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# CREATE COST CENTER
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
mutation createCostCenter(
|
mutation createCostCenter(
|
||||||
$name: String!
|
$name: String!
|
||||||
$createdBy: String
|
$businessId: UUID!
|
||||||
) @auth(level: USER) {
|
) @auth(level: USER) {
|
||||||
costCenter_insert(
|
costCenter_insert(
|
||||||
data: {
|
data: {
|
||||||
name: $name
|
name: $name
|
||||||
createdBy: $createdBy
|
businessId: $businessId
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# UPDATE COST CENTER
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
mutation updateCostCenter(
|
mutation updateCostCenter(
|
||||||
$id: UUID!
|
$id: UUID!
|
||||||
$name: String
|
$name: String
|
||||||
) @auth(level: USER) {
|
$businessId: UUID
|
||||||
|
) @auth(level: USER) {
|
||||||
costCenter_update(
|
costCenter_update(
|
||||||
id: $id
|
id: $id,
|
||||||
data: {
|
data: {
|
||||||
name: $name
|
name: $name
|
||||||
|
businessId: $businessId
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# DELETE COST CENTER
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
mutation deleteCostCenter($id: UUID!) @auth(level: USER) {
|
mutation deleteCostCenter($id: UUID!) @auth(level: USER) {
|
||||||
costCenter_delete(id: $id)
|
costCenter_delete(id: $id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,30 @@
|
|||||||
|
query listCostCenters @auth(level: USER) {
|
||||||
# ----------------------------------------------------------
|
costCenters {
|
||||||
# LIST ALL COST CENTERS
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
query listCostCenters(
|
|
||||||
$offset: Int
|
|
||||||
$limit: Int
|
|
||||||
) @auth(level: USER) {
|
|
||||||
costCenters(offset: $offset, limit: $limit) {
|
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
createdAt
|
businessId
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# GET BY ID
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
query getCostCenterById($id: UUID!) @auth(level: USER) {
|
query getCostCenterById($id: UUID!) @auth(level: USER) {
|
||||||
costCenter(id: $id) {
|
costCenter(id: $id) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
createdAt
|
businessId
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
query filterCostCenters(
|
||||||
# GET COST CENTER LINKED TO A SPECIFIC HUB
|
$name: String,
|
||||||
# ----------------------------------------------------------
|
$businessId: UUID
|
||||||
query getCostCenterByHubId($hubId: UUID!) @auth(level: USER) {
|
) @auth(level: USER) {
|
||||||
hubs(where: { id: { eq: $hubId } }) {
|
costCenters(
|
||||||
|
where: {
|
||||||
|
name: { eq: $name },
|
||||||
|
businessId: { eq: $businessId }
|
||||||
|
}) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
costCenterId
|
businessId
|
||||||
costCenter {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
mutation createHub(
|
|
||||||
$name: String!
|
|
||||||
$locationName: String
|
|
||||||
$address: String
|
|
||||||
$nfcTagId: String
|
|
||||||
$ownerId: UUID!
|
|
||||||
) @auth(level: USER) {
|
|
||||||
hub_insert(
|
|
||||||
data: {
|
|
||||||
name: $name
|
|
||||||
locationName: $locationName
|
|
||||||
address: $address
|
|
||||||
nfcTagId: $nfcTagId
|
|
||||||
ownerId: $ownerId
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation updateHub(
|
|
||||||
$id: UUID!
|
|
||||||
$name: String
|
|
||||||
$locationName: String
|
|
||||||
$address: String
|
|
||||||
$nfcTagId: String
|
|
||||||
$ownerId: UUID
|
|
||||||
) @auth(level: USER) {
|
|
||||||
hub_update(
|
|
||||||
id: $id
|
|
||||||
data: {
|
|
||||||
name: $name
|
|
||||||
locationName: $locationName
|
|
||||||
address: $address
|
|
||||||
nfcTagId: $nfcTagId
|
|
||||||
ownerId: $ownerId
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation deleteHub($id: UUID!) @auth(level: USER) {
|
|
||||||
hub_delete(id: $id)
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation assignCostCenterToHub(
|
|
||||||
$hubId: UUID!
|
|
||||||
$costCenterId: UUID!
|
|
||||||
) @auth(level: USER) {
|
|
||||||
hub_update(
|
|
||||||
id: $hubId
|
|
||||||
data: {
|
|
||||||
costCenterId: $costCenterId
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation removeCostCenterFromHub($hubId: UUID!) @auth(level: USER) {
|
|
||||||
hub_update(
|
|
||||||
id: $hubId
|
|
||||||
data: {
|
|
||||||
costCenterId: null
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
query listHubs @auth(level: USER) {
|
|
||||||
hubs {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
locationName
|
|
||||||
address
|
|
||||||
nfcTagId
|
|
||||||
ownerId
|
|
||||||
costCenterId
|
|
||||||
costCenter {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query getHubById($id: UUID!) @auth(level: USER) {
|
|
||||||
hub(id: $id) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
locationName
|
|
||||||
address
|
|
||||||
nfcTagId
|
|
||||||
ownerId
|
|
||||||
costCenterId
|
|
||||||
costCenter {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query getHubsByOwnerId($ownerId: UUID!) @auth(level: USER) {
|
|
||||||
hubs(where: { ownerId: { eq: $ownerId } }) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
locationName
|
|
||||||
address
|
|
||||||
nfcTagId
|
|
||||||
ownerId
|
|
||||||
costCenterId
|
|
||||||
costCenter {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
createdBy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query filterHubs(
|
|
||||||
$ownerId: UUID
|
|
||||||
$name: String
|
|
||||||
$nfcTagId: String
|
|
||||||
) @auth(level: USER) {
|
|
||||||
hubs(
|
|
||||||
where: {
|
|
||||||
ownerId: { eq: $ownerId }
|
|
||||||
name: { eq: $name }
|
|
||||||
nfcTagId: { eq: $nfcTagId }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
locationName
|
|
||||||
address
|
|
||||||
nfcTagId
|
|
||||||
ownerId
|
|
||||||
costCenterId
|
|
||||||
costCenter {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
mutation createTeamHub(
|
mutation createTeamHub(
|
||||||
$teamId: UUID!
|
$teamId: UUID!
|
||||||
|
$costCenterId: UUID
|
||||||
$hubName: String!
|
$hubName: String!
|
||||||
$address: String!
|
$address: String!
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ mutation createTeamHub(
|
|||||||
teamHub_insert(
|
teamHub_insert(
|
||||||
data: {
|
data: {
|
||||||
teamId: $teamId
|
teamId: $teamId
|
||||||
|
costCenterId: $costCenterId
|
||||||
hubName: $hubName
|
hubName: $hubName
|
||||||
address: $address
|
address: $address
|
||||||
|
|
||||||
@@ -45,6 +47,7 @@ mutation updateTeamHub(
|
|||||||
$id: UUID!
|
$id: UUID!
|
||||||
|
|
||||||
$teamId: UUID
|
$teamId: UUID
|
||||||
|
$costCenterId: UUID
|
||||||
$hubName: String
|
$hubName: String
|
||||||
$address: String
|
$address: String
|
||||||
|
|
||||||
@@ -67,6 +70,7 @@ mutation updateTeamHub(
|
|||||||
id: $id
|
id: $id
|
||||||
data: {
|
data: {
|
||||||
teamId: $teamId
|
teamId: $teamId
|
||||||
|
costCenterId: $costCenterId
|
||||||
hubName: $hubName
|
hubName: $hubName
|
||||||
address: $address
|
address: $address
|
||||||
|
|
||||||
@@ -91,3 +95,24 @@ mutation updateTeamHub(
|
|||||||
mutation deleteTeamHub($id: UUID!) @auth(level: USER) {
|
mutation deleteTeamHub($id: UUID!) @auth(level: USER) {
|
||||||
teamHub_delete(id: $id)
|
teamHub_delete(id: $id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutation assignCostCenterToTeamHub(
|
||||||
|
$id: UUID!
|
||||||
|
$costCenterId: UUID!
|
||||||
|
) @auth(level: USER) {
|
||||||
|
teamHub_update(
|
||||||
|
id: $id
|
||||||
|
data: {
|
||||||
|
costCenterId: $costCenterId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation removeCostCenterFromTeamHub($id: UUID!) @auth(level: USER) {
|
||||||
|
teamHub_update(
|
||||||
|
id: $id
|
||||||
|
data: {
|
||||||
|
costCenterId: null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ query listTeamHubs($offset: Int, $limit: Int) @auth(level: USER) {
|
|||||||
teamHubs(offset: $offset, limit: $limit, orderBy: { createdAt: DESC }) {
|
teamHubs(offset: $offset, limit: $limit, orderBy: { createdAt: DESC }) {
|
||||||
id
|
id
|
||||||
teamId
|
teamId
|
||||||
|
costCenterId
|
||||||
hubName
|
hubName
|
||||||
|
|
||||||
address
|
address
|
||||||
@@ -24,6 +25,11 @@ query listTeamHubs($offset: Int, $limit: Int) @auth(level: USER) {
|
|||||||
managerName
|
managerName
|
||||||
isActive
|
isActive
|
||||||
departments
|
departments
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
businessId
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +38,7 @@ query getTeamHubById($id: UUID!) @auth(level: USER) {
|
|||||||
teamHub(id: $id) {
|
teamHub(id: $id) {
|
||||||
id
|
id
|
||||||
teamId
|
teamId
|
||||||
|
costCenterId
|
||||||
hubName
|
hubName
|
||||||
|
|
||||||
address
|
address
|
||||||
@@ -48,6 +55,11 @@ query getTeamHubById($id: UUID!) @auth(level: USER) {
|
|||||||
managerName
|
managerName
|
||||||
isActive
|
isActive
|
||||||
departments
|
departments
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
businessId
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,6 +77,7 @@ query getTeamHubsByTeamId(
|
|||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
teamId
|
teamId
|
||||||
|
costCenterId
|
||||||
hubName
|
hubName
|
||||||
|
|
||||||
address
|
address
|
||||||
@@ -81,6 +94,11 @@ query getTeamHubsByTeamId(
|
|||||||
managerName
|
managerName
|
||||||
isActive
|
isActive
|
||||||
departments
|
departments
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
businessId
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,6 +123,7 @@ query listTeamHubsByOwnerId(
|
|||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
teamId
|
teamId
|
||||||
|
costCenterId
|
||||||
hubName
|
hubName
|
||||||
|
|
||||||
address
|
address
|
||||||
@@ -121,6 +140,11 @@ query listTeamHubsByOwnerId(
|
|||||||
managerName
|
managerName
|
||||||
isActive
|
isActive
|
||||||
departments
|
departments
|
||||||
|
costCenter {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
businessId
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
type CostCenter @table(name: "cost_centers") {
|
type CostCenter @table(name: "cost_centers") {
|
||||||
id: UUID! @default(expr: "uuidV4()")
|
id: UUID! @default(expr: "uuidV4()")
|
||||||
name: String!
|
name: String!
|
||||||
|
businessId: UUID!
|
||||||
|
|
||||||
createdAt: Timestamp @default(expr: "request.time")
|
createdAt: Timestamp @default(expr: "request.time")
|
||||||
updatedAt: Timestamp @default(expr: "request.time")
|
updatedAt: Timestamp @default(expr: "request.time")
|
||||||
createdBy: String
|
createdBy: String
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
type Hub @table(name: "hubs") {
|
|
||||||
id: UUID! @default(expr: "uuidV4()")
|
|
||||||
name: String!
|
|
||||||
locationName: String
|
|
||||||
address: String
|
|
||||||
nfcTagId: String
|
|
||||||
ownerId: UUID!
|
|
||||||
costCenterId: UUID
|
|
||||||
costCenter: CostCenter @ref(fields: "costCenterId", references: "id")
|
|
||||||
createdAt: Timestamp @default(expr: "request.time")
|
|
||||||
updatedAt: Timestamp @default(expr: "request.time")
|
|
||||||
createdBy: String
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,9 @@ type TeamHub @table(name: "team_hubs") {
|
|||||||
teamId: UUID!
|
teamId: UUID!
|
||||||
team: Team! @ref(fields: "teamId", references: "id")
|
team: Team! @ref(fields: "teamId", references: "id")
|
||||||
|
|
||||||
|
costCenterId: UUID
|
||||||
|
costCenter: CostCenter @ref(fields: "costCenterId", references: "id")
|
||||||
|
|
||||||
hubName: String!
|
hubName: String!
|
||||||
|
|
||||||
address: String!
|
address: String!
|
||||||
|
|||||||
Reference in New Issue
Block a user