2020-07-19 10:27:28 +00:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
2020-05-10 06:35:32 +00:00
|
|
|
module Types.Role where
|
|
|
|
|
|
|
|
import qualified Data.Text as T
|
2020-07-19 10:27:28 +00:00
|
|
|
import Data.Aeson
|
|
|
|
|
|
|
|
import GHC.Generics
|
2020-05-10 06:35:32 +00:00
|
|
|
|
|
|
|
data Role = Role
|
|
|
|
{ roleID :: Int
|
|
|
|
, roleName :: T.Text
|
|
|
|
, roleCanRefillStock :: Bool
|
2020-07-31 21:01:57 +00:00
|
|
|
-- , roleCanAddProduct :: Bool
|
2020-05-10 06:35:32 +00:00
|
|
|
, roleCanViewJournal :: Bool
|
|
|
|
, roleCanPayInvoice :: Bool
|
|
|
|
, roleCanPayOut :: Bool
|
|
|
|
, roleCanManageProducts :: Bool
|
|
|
|
, roleCanManageJournal :: Bool
|
2020-07-31 21:01:57 +00:00
|
|
|
-- , roleCanManageUsers :: Bool
|
2020-05-10 06:35:32 +00:00
|
|
|
, roleCanManageRoles :: Bool
|
|
|
|
, roleCanManageSuppliers :: Bool
|
|
|
|
, roleCanManageSettings :: Bool
|
|
|
|
}
|
2020-07-19 10:27:28 +00:00
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON Role where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON Role
|
2020-07-19 06:27:15 +00:00
|
|
|
|
|
|
|
data RoleSubmit = RoleSubmit
|
|
|
|
{ roleSubmitName :: T.Text
|
|
|
|
, roleSubmitCanRefillStock :: Bool
|
2020-07-31 21:01:57 +00:00
|
|
|
-- , roleSubmitCanAddProduct :: Bool
|
2020-07-19 06:27:15 +00:00
|
|
|
, roleSubmitCanViewJournal :: Bool
|
|
|
|
, roleSubmitCanPayInvoice :: Bool
|
|
|
|
, roleSubmitCanPayOut :: Bool
|
|
|
|
, roleSubmitCanManageProducts :: Bool
|
|
|
|
, roleSubmitCanManageJournal :: Bool
|
2020-07-31 21:01:57 +00:00
|
|
|
-- , roleSubmitCanManageUsers :: Bool
|
2020-07-19 06:27:15 +00:00
|
|
|
, roleSubmitCanManageRoles :: Bool
|
|
|
|
, roleSubmitCanManageSuppliers :: Bool
|
|
|
|
, roleSubmitCanManageSettings :: Bool
|
|
|
|
}
|
2020-07-19 10:27:28 +00:00
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON RoleSubmit where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON RoleSubmit
|
2020-07-19 06:27:15 +00:00
|
|
|
|
|
|
|
data RoleAssociation = RoleAssociation
|
2020-07-19 10:58:25 +00:00
|
|
|
{ roleAssociationUser :: Int
|
2020-07-19 06:27:15 +00:00
|
|
|
, roleAssociationRole :: Int
|
|
|
|
}
|
2020-07-19 10:27:28 +00:00
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON RoleAssociation where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON RoleAssociation
|
2020-07-19 06:27:15 +00:00
|
|
|
|
|
|
|
data RoleAssociationSubmit = RoleAssociationSubmit
|
|
|
|
{ roleAssociationSubmitUser :: Int
|
|
|
|
, roleAssociationSubmitRole :: Int
|
|
|
|
}
|
2020-07-19 10:27:28 +00:00
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON RoleAssociationSubmit where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON RoleAssociationSubmit
|