diff --git a/src/Control/Role.hs b/src/Control/Role.hs index 7f12985..611b419 100644 --- a/src/Control/Role.hs +++ b/src/Control/Role.hs @@ -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 diff --git a/src/Model/Role.hs b/src/Model/Role.hs index 796f1fb..e822291 100644 --- a/src/Model/Role.hs +++ b/src/Model/Role.hs @@ -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