make adding roles possible

This commit is contained in:
nek0 2020-07-19 20:48:58 +02:00
parent 28063cfffe
commit 3efb59766d
2 changed files with 46 additions and 1 deletions

View File

@ -21,7 +21,12 @@ roleList = do
conn <- asks rsConnection
selectAllRoles conn
roleNew _ _ = notImplemented
roleNew
:: Maybe (Int, AuthMethod)
-> RoleSubmit
-> MateHandler Int
roleNew (Just (_, auth)) (RoleSubmit name c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11) =
insertRole name c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 =<< asks rsConnection
roleUpdate _ _ = notImplemented

View File

@ -194,6 +194,46 @@ selectAllRoles conn = do
rawRoles
insertRole
:: T.Text
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> PGS.Connection
-> MateHandler Int
insertRole name c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 conn = do
head <$> liftIO (runInsert_ conn $ Insert
{ iTable = roleTable
, iRows =
[
( C.constant (Nothing :: Maybe Int)
, C.constant name
, C.constant c1
, C.constant c2
, C.constant c3
, C.constant c4
, C.constant c5
, C.constant c6
, C.constant c7
, C.constant c8
, C.constant c9
, C.constant c10
, C.constant c11
)
]
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_ )
, iOnConflict = Nothing
})
queryRoleIdByName
:: T.Text
-> PGS.Connection