Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE RankNTypes #-}
- {-# LANGUAGE FlexibleInstances #-}
- {-# LANGUAGE OverloadedStrings #-}
- {-# LANGUAGE ExistentialQuantification #-}
- {-# LANGUAGE TemplateHaskell #-}
- {-# LANGUAGE QuasiQuotes #-}
- {-# LANGUAGE TypeFamilies #-}
- {-# LANGUAGE FlexibleContexts #-}
- {-# LANGUAGE DeriveDataTypeable #-}
- {-# LANGUAGE GADTs #-}
- {-# LANGUAGE ConstraintKinds #-}
- {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
- {-# OPTIONS_GHC -fno-warn-orphans #-}
- {-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
- module Handler.Generated.Internal where
- import Handler.Generated.Enums
- import Prelude
- import Database.Esqueleto
- import Database.Esqueleto.Internal.Sql (unsafeSqlBinOp)
- import qualified Database.Persist as P
- import Database.Persist.TH
- import Yesod.Auth (requireAuthId, YesodAuth, AuthId, YesodAuthPersist)
- import Yesod.Core
- import Yesod.Persist (runDB, YesodPersist, YesodPersistBackend)
- import Data.Aeson ((.:), (.:?), (.!=), FromJSON, parseJSON, decode)
- import Data.Aeson.TH
- import Data.Int
- import Data.Word
- import Data.Time
- import Data.Text.Encoding (encodeUtf8)
- import Data.Typeable (Typeable)
- import qualified Data.Attoparsec as AP
- import qualified Data.Aeson as A
- import qualified Data.ByteString.Lazy as LBS
- import Data.Maybe
- import qualified Data.Text.Read
- import qualified Data.Text as T
- import Data.Text (Text)
- import qualified Data.List as DL
- import Control.Monad (mzero)
- import Control.Monad.Trans.Resource (runResourceT)
- import qualified Data.ByteString as B
- import qualified Data.ByteString.Lazy as L
- import qualified Network.HTTP.Conduit as C
- import qualified Network.Wai as W
- import Data.Conduit.Lazy (lazyConsume)
- import Network.HTTP.Types (status200, status400, status404)
- import Blaze.ByteString.Builder.ByteString (fromByteString)
- import Control.Applicative ((<$>), (<*>))
- import qualified Data.HashMap.Lazy as HML
- data FilterJsonMsg = FilterJsonMsg {
- filterJsonMsg_type :: Text,
- filterJsonMsg_value :: Text,
- filterJsonMsg_field :: Text,
- filterJsonMsg_property :: Text,
- filterJsonMsg_comparison :: Text
- }
- instance FromJSON FilterJsonMsg where
- parseJSON (A.Object v) = FilterJsonMsg <$>
- v .:? "type" .!= "string" <*>
- v .: "value" <*>
- v .:? "field" .!= "" <*>
- v .:? "property" .!= "" <*>
- v .:? "comparison" .!= "eq"
- parseJSON _ = mzero
- data SortJsonMsg = SortJsonMsg {
- sortJsonMsg_property :: Text,
- sortJsonMsg_direction :: Text
- }
- $(deriveJSON (drop 12) ''SortJsonMsg)
- -- defaultFilterOp :: forall v typ. PersistField typ => Text -> EntityField v typ -> typ -> Filter v
- defaultFilterOp "eq" = (==.)
- defaultFilterOp "neq" = (!=.)
- defaultFilterOp "lt" = (<.)
- defaultFilterOp "gt" = (>.)
- defaultFilterOp "le" = (<=.)
- defaultFilterOp "ge" = (>=.)
- defaultFilterOp _ = (==.)
- ilike = unsafeSqlBinOp " ILIKE "
- safeRead :: forall a. Read a => Text -> Maybe a
- safeRead s = case (reads $ T.unpack s) of
- [(v,_)] -> Just v
- _ -> Nothing
- instance PathPiece Int32 where
- fromPathPiece s =
- case Data.Text.Read.decimal s of
- Right (i, _) -> Just i
- Left _ -> Nothing
- toPathPiece = T.pack . show
- instance PathPiece Word32 where
- fromPathPiece s =
- case Data.Text.Read.decimal s of
- Right (i, _) -> Just i
- Left _ -> Nothing
- toPathPiece = T.pack . show
- instance PathPiece Word64 where
- fromPathPiece s =
- case Data.Text.Read.decimal s of
- Right (i, _) -> Just i
- Left _ -> Nothing
- toPathPiece = T.pack . show
- instance PathPiece Double where
- fromPathPiece s =
- case Data.Text.Read.double s of
- Right (i, _) -> Just i
- Left _ -> Nothing
- toPathPiece = T.pack . show
- instance PathPiece Bool where
- fromPathPiece "true" = Just True
- fromPathPiece "false" = Just False
- fromPathPiece "True" = Just True
- fromPathPiece "False" = Just False
- fromPathPiece _ = Nothing
- toPathPiece = T.pack . show
- instance PathPiece TimeOfDay where
- fromPathPiece = safeRead
- toPathPiece = T.pack . show
- instance PathPiece UTCTime where
- fromPathPiece = safeRead
- toPathPiece = T.pack . show
- instance PathPiece ZonedTime where
- fromPathPiece = safeRead
- toPathPiece = T.pack . show
- instance (PathPiece a, Show a) => PathPiece [a] where
- fromPathPiece s = do
- parts <- safeRead s
- values <- mapM fromPathPiece parts
- return values
- toPathPiece = T.pack . show
- getDefaultFilter maybeGetParam defaultFilterJson p = do
- f <- maybe maybeGetParam Just getFilter
- fromPathPiece f
- where
- getFilter = do
- j <- defaultFilterJson
- v <- DL.find (\fjm -> filterJsonMsg_property fjm == p) j
- return (filterJsonMsg_value v)
- share [mkPersist sqlOnlySettings, mkMigrate "migrateGenerated" ] [persistLowerCase|
- E3 json
- ownerId UserId
- e313 Text
- e314 UTCTime
- E4 json
- userId UserId
- e24Id E3Id Maybe
- message Text
- e314 UTCTime
- E5 json
- e314 UTCTime
- userId UserId
- E6 json
- f1 Text
- f2 Text
- f3 Text
- f4 E5Id
- userE7EId UserE7Id Maybe
- userE7E27EId UserE7E27Id Maybe
- userEId UserId Maybe
- e10EId E10Id Maybe
- e10E18EId E10E18Id Maybe
- e11PieceEId E11PieceId Maybe
- e11E18EId E11E18Id Maybe
- e25E18EId E25E18Id Maybe
- e21E18EId E21E18Id Maybe
- e16EId E16Id Maybe
- e16E8EId E16E8Id Maybe
- e13EId E13Id Maybe
- e13E18EId E13E18Id Maybe
- e14EId E14Id Maybe
- e26EId E26Id Maybe
- e26E7EId E26E7Id Maybe
- e28EId E28Id Maybe
- e19EId E19Id Maybe
- e20EId E20Id Maybe
- e20NumberEId E20NumberId Maybe
- UserE7 json
- name Text
- version E5Id Maybe
- e30d Bool
- UniqueE7 name !force
- UserE7E8 json
- groupId UserE7Id
- userId UserId
- e30d Bool
- UserE7E27 json
- groupId UserE7Id
- e10EntityId E10Id Maybe
- e11PieceEntityId E11PieceId Maybe
- e11E18EntityId E11E18Id Maybe
- e25E18EntityId E25E18Id Maybe
- e21E18EntityId E21E18Id Maybe
- e16EntityId E16Id Maybe
- e13EntityId E13Id Maybe
- e14EntityId E14Id Maybe
- e28EntityId E28Id Maybe
- e19EntityId E19Id Maybe
- e20EntityId E20Id Maybe
- e30d Bool
- version E5Id Maybe
- User json
- firstName Text
- lastName Text
- email Text
- password Text
- salt Text
- admin Bool default='false'
- name Text
- version E5Id Maybe
- e30d Bool
- UniqueUser name !force
- deriving Typeable
- E9 json
- fs Word64
- l Word32
- E10 json
- e31 Text
- aaaId E9Id
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- e312 UTCTime
- e313 UserId Maybe
- UniqueE10E231 e311 !force
- E10E18 json
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE10E18E231 e311 !force
- E10E18E8 json
- e10Id E10Id
- e10E18Id E10E18Id
- e30d Bool
- e311 Text Maybe
- UniqueE10E18E8E231 e311 !force
- E11Piece json
- a Text
- c Text
- dc Text
- t Int32
- aaaId E9Id
- mS Bool
- fS Bool
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- e312 UTCTime
- e313 UserId Maybe
- UniqueE11PieceE231 e311 !force
- E11E18 json
- e31 Text
- readOnly Bool
- lf Bool
- smallE18 Bool
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE11E18E231 e311 !force
- E11E18E8 json
- e11PieceId E11PieceId
- e11E18Id E11E18Id
- e30d Bool
- e311 Text Maybe
- UniqueE11E18E8E231 e311 !force
- E25E18 json
- e31 Text
- op SO
- e11E18Id E11E18Id
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE25E18E231 e311 !force
- E25E18E8 json
- e11E18Id E11E18Id
- e30d Bool
- e311 Text Maybe
- UniqueE25E18E8E231 e311 !force
- E21E18 json
- e31 Text
- e32 E21E18E23
- op SBO
- value Text
- valueType E21E18Value
- e11E18Id E11E18Id
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE21E18E231 e311 !force
- E16 json
- e31 Text
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE16E231 e311 !force
- E16E8 json
- e16Id E16Id
- e11E18Id E11E18Id
- amount Int32
- e30d Bool
- version E5Id Maybe
- e311 Text Maybe
- UniqueE16E8E231 e311 !force
- E13 json
- aaaId E9Id
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE13E231 e311 !force
- E13E18 json
- e31 Text
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE13E18E231 e311 !force
- E13E18E8 json
- e13Id E13Id
- e13E18Id E13E18Id
- e30d Bool
- e311 Text Maybe
- UniqueE13E18E8E231 e311 !force
- E14 json
- e31 Text
- author Text
- e29Date UTCTime
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE14E231 e311 !force
- E14E8 json
- e11PieceE14ContentId E11PieceId Maybe
- e11E18E14ContentId E11E18Id Maybe
- e13E14ContentId E13Id Maybe
- e13E18E14ContentId E13E18Id Maybe
- e14Id E14Id
- order Int32
- e30d Bool
- e311 Text Maybe
- UniqueE14E8E231 e311 !force
- E26 json
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE26E231 e311 !force
- E26E7 json
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE26E7E231 e311 !force
- E26E7E8 json
- e26Id E26Id
- e26E7Id E26E7Id
- e30d Bool
- e311 Text Maybe
- UniqueE26E7E8E231 e311 !force
- E26BannedE9 json
- e26Id E26Id
- aaaId E9Id
- E28 json
- place Text
- address Text
- technicalE27 Text
- lastConnectionE11 UTCTime
- lastTransferOKE11 UTCTime
- lastE11RecyclingE11 UTCTime
- diskSpace Int32
- diskUsage Int32
- rebootCount Int32
- lastReboot UTCTime
- lastE27Updated UTCTime
- active Bool
- gramexType E28Type
- restaurantIncome Int32
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE28E231 e311 !force
- E26Contract json
- startDate UTCTime
- endDate UTCTime
- ends Bool
- e31 Text
- e28Id E28Id
- E12 json
- e10Id E10Id
- e26Id E26Id
- day Day
- startE11 TimeOfDay
- e314Window Int32
- accurate Bool
- count Int32
- E12E12 json
- e10Id E10Id
- e26Id E26Id
- wday Enum1
- e314 TimeOfDay
- E12E12E34 json
- e26Id E26Id
- day Day
- UniqueE12E12E34 e26Id day !force
- E19 json
- e31 Text
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE19E231 e311 !force
- E19E8 json
- e19Id E19Id
- aaaId E9Id Maybe
- order Int32
- e30d Bool
- e311 Text Maybe
- UniqueE19E8E231 e311 !force
- E20 json
- title Text
- address Text
- email Text
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE20E231 e311 !force
- E20Number json
- e31Id E20Id
- number Text
- name Text
- version E5Id Maybe
- e30d Bool
- e311 Text Maybe
- UniqueE20NumberE231 e311 !force
- E16E12 json
- e16Id E16Id
- e26Id E26Id
- day Day
- startE11 TimeOfDay
- e314Window Int32
- E12E16E12 json
- e16Id E16Id
- e26Id E26Id
- wday Enum1
- e314 TimeOfDay
- E10E11 json
- e26Id E26Id
- day Day
- startE11 TimeOfDay
- e314Window Int32
- active Bool
- E12E10E11 json
- e26Id E26Id
- wday Enum1
- startE11 TimeOfDay
- e314Window Int32
- |]
- class Named a where
- namedName :: a -> Text
- instance Named UserE7 where
- namedName = userE7Name
- instance Named User where
- namedName = userName
- instance Named E10 where
- namedName = e10Name
- instance Named E10E18 where
- namedName = e10E18Name
- instance Named E11Piece where
- namedName = e11PieceName
- instance Named E11E18 where
- namedName = e11E18Name
- instance Named E25E18 where
- namedName = e25E18Name
- instance Named E21E18 where
- namedName = e21E18Name
- instance Named E16 where
- namedName = e16Name
- instance Named E13 where
- namedName = e13Name
- instance Named E13E18 where
- namedName = e13E18Name
- instance Named E14 where
- namedName = e14Name
- instance Named E26 where
- namedName = e26Name
- instance Named E26E7 where
- namedName = e26E7Name
- instance Named E28 where
- namedName = e28Name
- instance Named E19 where
- namedName = e19Name
- instance Named E20 where
- namedName = e20Name
- instance Named E20Number where
- namedName = e20NumberName
- class C1 a where
- c1E311 :: a -> Maybe Text
- instance C1 E10 where
- c1E311 = e10E311
- instance C1 E10E18 where
- c1E311 = e10E18E311
- instance C1 E10E18E8 where
- c1E311 = e10E18E8E311
- instance C1 E11Piece where
- c1E311 = e11PieceE311
- instance C1 E11E18 where
- c1E311 = e11E18E311
- instance C1 E11E18E8 where
- c1E311 = e11E18E8E311
- instance C1 E25E18 where
- c1E311 = e25E18E311
- instance C1 E25E18E8 where
- c1E311 = e25E18E8E311
- instance C1 E21E18 where
- c1E311 = e21E18E311
- instance C1 E16 where
- c1E311 = e16E311
- instance C1 E16E8 where
- c1E311 = e16E8E311
- instance C1 E13 where
- c1E311 = e13E311
- instance C1 E13E18 where
- c1E311 = e13E18E311
- instance C1 E13E18E8 where
- c1E311 = e13E18E8E311
- instance C1 E14 where
- c1E311 = e14E311
- instance C1 E14E8 where
- c1E311 = e14E8E311
- instance C1 E26 where
- c1E311 = e26E311
- instance C1 E26E7 where
- c1E311 = e26E7E311
- instance C1 E26E7E8 where
- c1E311 = e26E7E8E311
- instance C1 E28 where
- c1E311 = e28E311
- instance C1 E19 where
- c1E311 = e19E311
- instance C1 E19E8 where
- c1E311 = e19E8E311
- instance C1 E20 where
- c1E311 = e20E311
- instance C1 E20Number where
- c1E311 = e20NumberE311
- class C2 a where
- c2E312 :: a -> UTCTime
- c2E313 :: a -> Maybe UserId
- instance C2 E10 where
- c2E312 = e10E312
- c2E313 = e10E313
- instance C2 E11Piece where
- c2E312 = e11PieceE312
- c2E313 = e11PieceE313
- class C3 a where
- c3Version :: a -> Maybe E5Id
- instance C3 UserE7 where
- c3Version = userE7Version
- instance C3 UserE7E27 where
- c3Version = userE7E27Version
- instance C3 User where
- c3Version = userVersion
- instance C3 E10 where
- c3Version = e10Version
- instance C3 E10E18 where
- c3Version = e10E18Version
- instance C3 E11Piece where
- c3Version = e11PieceVersion
- instance C3 E11E18 where
- c3Version = e11E18Version
- instance C3 E25E18 where
- c3Version = e25E18Version
- instance C3 E21E18 where
- c3Version = e21E18Version
- instance C3 E16 where
- c3Version = e16Version
- instance C3 E16E8 where
- c3Version = e16E8Version
- instance C3 E13 where
- c3Version = e13Version
- instance C3 E13E18 where
- c3Version = e13E18Version
- instance C3 E14 where
- c3Version = e14Version
- instance C3 E26 where
- c3Version = e26Version
- instance C3 E26E7 where
- c3Version = e26E7Version
- instance C3 E28 where
- c3Version = e28Version
- instance C3 E19 where
- c3Version = e19Version
- instance C3 E20 where
- c3Version = e20Version
- instance C3 E20Number where
- c3Version = e20NumberVersion
- class C4 a where
- c4E30d :: a -> Bool
- instance C4 UserE7 where
- c4E30d = userE7E30d
- instance C4 UserE7E8 where
- c4E30d = userE7E8E30d
- instance C4 UserE7E27 where
- c4E30d = userE7E27E30d
- instance C4 User where
- c4E30d = userE30d
- instance C4 E10 where
- c4E30d = e10E30d
- instance C4 E10E18 where
- c4E30d = e10E18E30d
- instance C4 E10E18E8 where
- c4E30d = e10E18E8E30d
- instance C4 E11Piece where
- c4E30d = e11PieceE30d
- instance C4 E11E18 where
- c4E30d = e11E18E30d
- instance C4 E11E18E8 where
- c4E30d = e11E18E8E30d
- instance C4 E25E18 where
- c4E30d = e25E18E30d
- instance C4 E25E18E8 where
- c4E30d = e25E18E8E30d
- instance C4 E21E18 where
- c4E30d = e21E18E30d
- instance C4 E16 where
- c4E30d = e16E30d
- instance C4 E16E8 where
- c4E30d = e16E8E30d
- instance C4 E13 where
- c4E30d = e13E30d
- instance C4 E13E18 where
- c4E30d = e13E18E30d
- instance C4 E13E18E8 where
- c4E30d = e13E18E8E30d
- instance C4 E14 where
- c4E30d = e14E30d
- instance C4 E14E8 where
- c4E30d = e14E8E30d
- instance C4 E26 where
- c4E30d = e26E30d
- instance C4 E26E7 where
- c4E30d = e26E7E30d
- instance C4 E26E7E8 where
- c4E30d = e26E7E8E30d
- instance C4 E28 where
- c4E30d = e28E30d
- instance C4 E19 where
- c4E30d = e19E30d
- instance C4 E19E8 where
- c4E30d = e19E8E30d
- instance C4 E20 where
- c4E30d = e20E30d
- instance C4 E20Number where
- c4E30d = e20NumberE30d
- class C6 a where
- instance C6 E10 where
- instance C6 E11Piece where
- instance C6 E11E18 where
- instance C6 E25E18 where
- instance C6 E21E18 where
- instance C6 E16 where
- instance C6 E13 where
- instance C6 E14 where
- instance C6 E28 where
- instance C6 E19 where
- instance C6 E20 where
- class E14Content a where
- instance E14Content E11Piece where
- instance E14Content E11E18 where
- instance E14Content E13 where
- instance E14Content E13E18 where
- checkResult :: forall (m :: * -> *). (Monad m) => Text -> m Bool -> m (Maybe Text)
- checkResult msg f = do
- result <- f
- return $ if result then Nothing else (Just msg)
- class Validatable a where
- validate :: forall master b. (P.PersistMonadBackend (b (HandlerT master IO)) ~ P.PersistEntityBackend a,
- b ~ YesodPersistBackend master,
- P.PersistQuery (b (HandlerT master IO)),
- P.PersistUnique (b (HandlerT master IO)),
- YesodPersist master,
- GeneratedValidation master)
- => a -> HandlerT master IO [Text]
- class Yesod master => GeneratedValidation master where
- nonEmpty :: (YesodPersist master) => Text -> HandlerT master IO Bool
- instance Validatable E3 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E4 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E5 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E6 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable UserE7 where
- validate v = do
- results <- sequence [
- checkResult "UserE7.name nonEmpty" (nonEmpty $ userE7Name v) ]
- return $ catMaybes results
- instance Validatable UserE7E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable UserE7E27 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable User where
- validate v = do
- results <- sequence [
- checkResult "User.name nonEmpty" (nonEmpty $ userName v) ]
- return $ catMaybes results
- instance Validatable E9 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E10 where
- validate v = do
- results <- sequence [
- checkResult "E10.name nonEmpty" (nonEmpty $ e10Name v) ]
- return $ catMaybes results
- instance Validatable E10E18 where
- validate v = do
- results <- sequence [
- checkResult "E10E18.name nonEmpty" (nonEmpty $ e10E18Name v) ]
- return $ catMaybes results
- instance Validatable E10E18E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E11Piece where
- validate v = do
- results <- sequence [
- checkResult "E11Piece.name nonEmpty" (nonEmpty $ e11PieceName v) ]
- return $ catMaybes results
- instance Validatable E11E18 where
- validate v = do
- results <- sequence [
- checkResult "E11E18.name nonEmpty" (nonEmpty $ e11E18Name v) ]
- return $ catMaybes results
- instance Validatable E11E18E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E25E18 where
- validate v = do
- results <- sequence [
- checkResult "E25E18.name nonEmpty" (nonEmpty $ e25E18Name v) ]
- return $ catMaybes results
- instance Validatable E25E18E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E21E18 where
- validate v = do
- results <- sequence [
- checkResult "E21E18.name nonEmpty" (nonEmpty $ e21E18Name v) ]
- return $ catMaybes results
- instance Validatable E16 where
- validate v = do
- results <- sequence [
- checkResult "E16.name nonEmpty" (nonEmpty $ e16Name v) ]
- return $ catMaybes results
- instance Validatable E16E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E13 where
- validate v = do
- results <- sequence [
- checkResult "E13.name nonEmpty" (nonEmpty $ e13Name v) ]
- return $ catMaybes results
- instance Validatable E13E18 where
- validate v = do
- results <- sequence [
- checkResult "E13E18.name nonEmpty" (nonEmpty $ e13E18Name v) ]
- return $ catMaybes results
- instance Validatable E13E18E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E14 where
- validate v = do
- results <- sequence [
- checkResult "E14.name nonEmpty" (nonEmpty $ e14Name v) ]
- return $ catMaybes results
- instance Validatable E14E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E26 where
- validate v = do
- results <- sequence [
- checkResult "E26.name nonEmpty" (nonEmpty $ e26Name v) ]
- return $ catMaybes results
- instance Validatable E26E7 where
- validate v = do
- results <- sequence [
- checkResult "E26E7.name nonEmpty" (nonEmpty $ e26E7Name v) ]
- return $ catMaybes results
- instance Validatable E26E7E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E26BannedE9 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E28 where
- validate v = do
- results <- sequence [
- checkResult "E28.name nonEmpty" (nonEmpty $ e28Name v) ]
- return $ catMaybes results
- instance Validatable E26Contract where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E12 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E12E12 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E12E12E34 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E19 where
- validate v = do
- results <- sequence [
- checkResult "E19.name nonEmpty" (nonEmpty $ e19Name v) ]
- return $ catMaybes results
- instance Validatable E19E8 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E20 where
- validate v = do
- results <- sequence [
- checkResult "E20.name nonEmpty" (nonEmpty $ e20Name v) ]
- return $ catMaybes results
- instance Validatable E20Number where
- validate v = do
- results <- sequence [
- checkResult "E20Number.name nonEmpty" (nonEmpty $ e20NumberName v) ]
- return $ catMaybes results
- instance Validatable E16E12 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E12E16E12 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E10E11 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance Validatable E12E10E11 where
- validate v = do
- results <- sequence [
- ]
- return $ catMaybes results
- instance ToJSON Day where
- toJSON = toJSON . show
- instance FromJSON Day where
- parseJSON x = do
- s <- parseJSON x
- case reads s of
- (d, _):_ -> return d
- [] -> mzero
- instance ToJSON TimeOfDay where
- toJSON = toJSON . show
- instance FromJSON TimeOfDay where
- parseJSON x = do
- s <- parseJSON x
- case reads s of
- (d, _):_ -> return d
- [] -> mzero
- getE10sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE10sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e10E18Id <- lookupGetParam "e10E18Id"
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(s ) -> do
- let sId' = s ^. E10Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 1000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E31) ]
- "DESC" -> orderBy [ desc (s ^. E10E31) ]
- _ -> return ()
- "aaaId" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10AaaId) ]
- "DESC" -> orderBy [ desc (s ^. E10AaaId) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10Name) ]
- "DESC" -> orderBy [ desc (s ^. E10Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10Version) ]
- "DESC" -> orderBy [ desc (s ^. E10Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E30d) ]
- "DESC" -> orderBy [ desc (s ^. E10E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E311) ]
- "DESC" -> orderBy [ desc (s ^. E10E311) ]
- _ -> return ()
- "e312" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E312) ]
- "DESC" -> orderBy [ desc (s ^. E10E312) ]
- _ -> return ()
- "e313" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E313) ]
- "DESC" -> orderBy [ desc (s ^. E10E313) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (s ^. E10Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
- _ -> return ()
- "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
- _ -> return ()
- "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
- _ -> return ()
- "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e10E18Id defaultFilterJson "e10E18Id" of
- Just localParam -> from $ \(sci) -> do
- where_ ((s ^. E10Id) ==. (sci ^. E10E18E8E10Id))
- where_ $ (sci ^. E10E18E8E10E18Id) ==. ((val localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (s ^. E10Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (s ^. E10Id, s ^. E10E31, s ^. E10AaaId, s ^. E10Name, s ^. E10Version, s ^. E10E30d, s ^. E10E311, s ^. E10E312, s ^. E10E313)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "aaaId" .= toJSON f3,
- "name" .= toJSON f4,
- "version" .= toJSON f5,
- "e30d" .= toJSON f6,
- "e311" .= toJSON f7,
- "e312" .= toJSON f8,
- "e313" .= toJSON f9
- ]
- _ -> A.object []
- ) results)
- ]
- postE10sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- postE10sR = do
- authId <- lift $ requireAuthId
- yReq <- getRequest
- let wReq = reqWaiRequest yReq
- bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
- jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
- Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
- Right o -> return o
- jsonBodyObj <- case jsonBody of
- A.Object o -> return o
- v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
- e1 <- case A.fromJSON jsonBody of
- A.Success e -> return e
- A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E10 from JSON object in the request body : " ++ err )
- _ <- lift $ runDB $ do
- vErrors <- lift $ validate e1
- case vErrors of
- xs@(_:_) -> sendResponseStatus status400 (A.object [
- "message" .= ("Entity validation failed" :: Text),
- "errors" .= toJSON xs
- ])
- _ -> P.insert (e1 :: E10)
- return $ A.Null
- getE10sE10IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
- getE10sE10IdR p1 = do
- authId <- lift $ requireAuthId
- let baseQuery limitOffsetOrder = from $ \(s ) -> do
- let sId' = s ^. E10Id
- where_ ((s ^. E10Id) ==. ((val p1)))
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- else return ()
- return (s ^. E10E31, s ^. E10AaaId, s ^. E10Name, s ^. E10Version, s ^. E10E30d, s ^. E10E311, s ^. E10E312, s ^. E10E313)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
- "e31" .= toJSON f1,
- "aaaId" .= toJSON f2,
- "name" .= toJSON f3,
- "version" .= toJSON f4,
- "e30d" .= toJSON f5,
- "e311" .= toJSON f6,
- "e312" .= toJSON f7,
- "e313" .= toJSON f8
- ]
- _ -> A.object []
- ) results)
- ]
- putE10sE10IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
- putE10sE10IdR p1 = do
- authId <- lift $ requireAuthId
- yReq <- getRequest
- let wReq = reqWaiRequest yReq
- bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
- jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
- Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
- Right o -> return o
- jsonBodyObj <- case jsonBody of
- A.Object o -> return o
- v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
- e1 <- case A.fromJSON jsonBody of
- A.Success e -> return e
- A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E10 from JSON object in the request body : " ++ err )
- _ <- lift $ runDB $ do
- vErrors <- lift $ validate e1
- case vErrors of
- xs@(_:_) -> sendResponseStatus status400 (A.object [
- "message" .= ("Entity validation failed" :: Text),
- "errors" .= toJSON xs
- ])
- _ -> P.repsert p1 (e1 :: E10)
- return $ A.Null
- deleteE10sE10IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE10sE10IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\s -> where_ $ (s ^. E10Id) ==. ((val p1)))
- return $ A.Null
- getE10e33R :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE10e33R = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(s ) -> do
- let sId' = s ^. E10E18Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E18Name) ]
- "DESC" -> orderBy [ desc (s ^. E10E18Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E18Version) ]
- "DESC" -> orderBy [ desc (s ^. E10E18Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E18E30d) ]
- "DESC" -> orderBy [ desc (s ^. E10E18E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10E18E311) ]
- "DESC" -> orderBy [ desc (s ^. E10E18E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (s ^. E10E18Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (s ^. E10E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (s ^. E10E18Id, s ^. E10E18Name, s ^. E10E18Version, s ^. E10E18E30d, s ^. E10E18E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "name" .= toJSON f2,
- "version" .= toJSON f3,
- "e30d" .= toJSON f4,
- "e311" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- getE11piecesR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE11piecesR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e11E18Id <- lookupGetParam "e11E18Id"
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(m ) -> do
- let mId' = m ^. E11PieceId
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "a" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceA) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceA) ]
- _ -> return ()
- "c" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceC) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceC) ]
- _ -> return ()
- "dc" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceDc) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceDc) ]
- _ -> return ()
- "t" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceT) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceT) ]
- _ -> return ()
- "aaaId" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceAaaId) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceAaaId) ]
- _ -> return ()
- "mS" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceMS) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceMS) ]
- _ -> return ()
- "fS" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceFS) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceFS) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceName) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceName) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceVersion) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceVersion) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceE30d) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceE30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceE311) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceE311) ]
- _ -> return ()
- "e312" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceE312) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceE312) ]
- _ -> return ()
- "e313" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (m ^. E11PieceE313) ]
- "DESC" -> orderBy [ desc (m ^. E11PieceE313) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (m ^. E11PieceName) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "a" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceA) (val v)
- _ -> return ()
- "c" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceC) (val v)
- _ -> return ()
- "dc" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceDc) (val v)
- _ -> return ()
- "t" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceT) (val v)
- _ -> return ()
- "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceAaaId) (val v)
- _ -> return ()
- "mS" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceMS) (val v)
- _ -> return ()
- "fS" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceFS) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceName) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceVersion) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE311) (val (Just v))
- _ -> return ()
- "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE312) (val v)
- _ -> return ()
- "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE313) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e11E18Id defaultFilterJson "e11E18Id" of
- Just localParam -> from $ \(mci) -> do
- where_ ((m ^. E11PieceId) ==. (mci ^. E11E18E8E11PieceId))
- where_ $ (mci ^. E11E18E8E11E18Id) ==. ((val localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (m ^. E11PieceName) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (m ^. E11PieceId, m ^. E11PieceA, m ^. E11PieceC, m ^. E11PieceDc, m ^. E11PieceT, m ^. E11PieceAaaId, m ^. E11PieceMS, m ^. E11PieceFS, m ^. E11PieceName, m ^. E11PieceVersion, m ^. E11PieceE30d, m ^. E11PieceE311, m ^. E11PieceE312, m ^. E11PieceE313)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9), (Database.Esqueleto.Value f10), (Database.Esqueleto.Value f11), (Database.Esqueleto.Value f12), (Database.Esqueleto.Value f13), (Database.Esqueleto.Value f14)) -> A.object [
- "id" .= toJSON f1,
- "a" .= toJSON f2,
- "c" .= toJSON f3,
- "dc" .= toJSON f4,
- "t" .= toJSON f5,
- "aaaId" .= toJSON f6,
- "mS" .= toJSON f7,
- "fS" .= toJSON f8,
- "name" .= toJSON f9,
- "version" .= toJSON f10,
- "e30d" .= toJSON f11,
- "e311" .= toJSON f12,
- "e312" .= toJSON f13,
- "e313" .= toJSON f14
- ]
- _ -> A.object []
- ) results)
- ]
- getE11e33R :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE11e33R = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(c ) -> do
- let cId' = c ^. E11E18Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18E31) ]
- "DESC" -> orderBy [ desc (c ^. E11E18E31) ]
- _ -> return ()
- "readOnly" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18ReadOnly) ]
- "DESC" -> orderBy [ desc (c ^. E11E18ReadOnly) ]
- _ -> return ()
- "lf" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18Lf) ]
- "DESC" -> orderBy [ desc (c ^. E11E18Lf) ]
- _ -> return ()
- "smallE18" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18SmallE18) ]
- "DESC" -> orderBy [ desc (c ^. E11E18SmallE18) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18Name) ]
- "DESC" -> orderBy [ desc (c ^. E11E18Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18Version) ]
- "DESC" -> orderBy [ desc (c ^. E11E18Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18E30d) ]
- "DESC" -> orderBy [ desc (c ^. E11E18E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E11E18E311) ]
- "DESC" -> orderBy [ desc (c ^. E11E18E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (c ^. E11E18Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E31) (val v)
- _ -> return ()
- "readOnly" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18ReadOnly) (val v)
- _ -> return ()
- "lf" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Lf) (val v)
- _ -> return ()
- "smallE18" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18SmallE18) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (c ^. E11E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (c ^. E11E18Id, c ^. E11E18E31, c ^. E11E18ReadOnly, c ^. E11E18Lf, c ^. E11E18SmallE18, c ^. E11E18Name, c ^. E11E18Version, c ^. E11E18E30d, c ^. E11E18E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "readOnly" .= toJSON f3,
- "lf" .= toJSON f4,
- "smallE18" .= toJSON f5,
- "name" .= toJSON f6,
- "version" .= toJSON f7,
- "e30d" .= toJSON f8,
- "e311" .= toJSON f9
- ]
- _ -> A.object []
- ) results)
- ]
- getE16sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE16sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(mf ) -> do
- let mfId' = mf ^. E16Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (mf ^. E16E31) ]
- "DESC" -> orderBy [ desc (mf ^. E16E31) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (mf ^. E16Name) ]
- "DESC" -> orderBy [ desc (mf ^. E16Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (mf ^. E16Version) ]
- "DESC" -> orderBy [ desc (mf ^. E16Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (mf ^. E16E30d) ]
- "DESC" -> orderBy [ desc (mf ^. E16E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (mf ^. E16E311) ]
- "DESC" -> orderBy [ desc (mf ^. E16E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (mf ^. E16Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E31) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (mf ^. E16Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (mf ^. E16Id, mf ^. E16E31, mf ^. E16Name, mf ^. E16Version, mf ^. E16E30d, mf ^. E16E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "name" .= toJSON f3,
- "version" .= toJSON f4,
- "e30d" .= toJSON f5,
- "e311" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- getE13sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE13sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e13E18Id <- lookupGetParam "e13E18Id"
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(a ) -> do
- let aId' = a ^. E13Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "aaaId" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (a ^. E13AaaId) ]
- "DESC" -> orderBy [ desc (a ^. E13AaaId) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (a ^. E13Name) ]
- "DESC" -> orderBy [ desc (a ^. E13Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (a ^. E13Version) ]
- "DESC" -> orderBy [ desc (a ^. E13Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (a ^. E13E30d) ]
- "DESC" -> orderBy [ desc (a ^. E13E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (a ^. E13E311) ]
- "DESC" -> orderBy [ desc (a ^. E13E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (a ^. E13Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13AaaId) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e13E18Id defaultFilterJson "e13E18Id" of
- Just localParam -> from $ \(apci) -> do
- where_ ((a ^. E13Id) ==. (apci ^. E13E18E8E13Id))
- where_ $ (apci ^. E13E18E8E13E18Id) ==. ((val localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (a ^. E13Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (a ^. E13Id, a ^. E13AaaId, a ^. E13Name, a ^. E13Version, a ^. E13E30d, a ^. E13E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "aaaId" .= toJSON f2,
- "name" .= toJSON f3,
- "version" .= toJSON f4,
- "e30d" .= toJSON f5,
- "e311" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- getE13e33R :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE13e33R = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(c ) -> do
- let cId' = c ^. E13E18Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E13E18E31) ]
- "DESC" -> orderBy [ desc (c ^. E13E18E31) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E13E18Name) ]
- "DESC" -> orderBy [ desc (c ^. E13E18Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E13E18Version) ]
- "DESC" -> orderBy [ desc (c ^. E13E18Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E13E18E30d) ]
- "DESC" -> orderBy [ desc (c ^. E13E18E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E13E18E311) ]
- "DESC" -> orderBy [ desc (c ^. E13E18E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (c ^. E13E18Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E31) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (c ^. E13E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (c ^. E13E18Id, c ^. E13E18E31, c ^. E13E18Name, c ^. E13E18Version, c ^. E13E18E30d, c ^. E13E18E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "name" .= toJSON f3,
- "version" .= toJSON f4,
- "e30d" .= toJSON f5,
- "e311" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- getE14sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE14sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- let baseQuery limitOffsetOrder = from $ \(r ) -> do
- let rId' = r ^. E14Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14E31) ]
- "DESC" -> orderBy [ desc (r ^. E14E31) ]
- _ -> return ()
- "author" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14Author) ]
- "DESC" -> orderBy [ desc (r ^. E14Author) ]
- _ -> return ()
- "e29Date" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14E29Date) ]
- "DESC" -> orderBy [ desc (r ^. E14E29Date) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14Name) ]
- "DESC" -> orderBy [ desc (r ^. E14Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14Version) ]
- "DESC" -> orderBy [ desc (r ^. E14Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14E30d) ]
- "DESC" -> orderBy [ desc (r ^. E14E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (r ^. E14E311) ]
- "DESC" -> orderBy [ desc (r ^. E14E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (r ^. E14Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E31) (val v)
- _ -> return ()
- "author" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Author) (val v)
- _ -> return ()
- "e29Date" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E29Date) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- return (r ^. E14Id, r ^. E14E31, r ^. E14Author, r ^. E14E29Date, r ^. E14Name, r ^. E14Version, r ^. E14E30d, r ^. E14E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "author" .= toJSON f3,
- "e29Date" .= toJSON f4,
- "name" .= toJSON f5,
- "version" .= toJSON f6,
- "e30d" .= toJSON f7,
- "e311" .= toJSON f8
- ]
- _ -> A.object []
- ) results)
- ]
- getE14sE14IdContentR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E14Id -> HandlerT Generated (HandlerT master IO) A.Value
- getE14sE14IdContentR p1 = do
- authId <- lift $ requireAuthId
- let baseQuery limitOffsetOrder = from $ \(ri ) -> do
- let riId' = ri ^. E14E8Id
- where_ ((ri ^. E14E8E14Id) ==. ((val p1)))
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- else return ()
- return (ri ^. E14E8Id, ri ^. E14E8E11PieceE14ContentId, ri ^. E14E8E11E18E14ContentId, ri ^. E14E8E13E14ContentId, ri ^. E14E8E13E18E14ContentId, ri ^. E14E8E14Id, ri ^. E14E8Order, ri ^. E14E8E30d, ri ^. E14E8E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
- "id" .= toJSON f1,
- "e11PieceE14ContentId" .= toJSON f2,
- "e11E18E14ContentId" .= toJSON f3,
- "e13E14ContentId" .= toJSON f4,
- "e13E18E14ContentId" .= toJSON f5,
- "e14Id" .= toJSON f6,
- "order" .= toJSON f7,
- "e30d" .= toJSON f8,
- "e311" .= toJSON f9
- ]
- _ -> A.object []
- ) results)
- ]
- getE26sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE26sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26E7Id <- lookupGetParam "e26E7Id"
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(c ) -> do
- let cId' = c ^. E26Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Version) ]
- "DESC" -> orderBy [ desc (c ^. E26Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26E30d) ]
- "DESC" -> orderBy [ desc (c ^. E26E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26E311) ]
- "DESC" -> orderBy [ desc (c ^. E26E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (c ^. E26Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26E7Id defaultFilterJson "e26E7Id" of
- Just localParam -> from $ \(cgi) -> do
- where_ ((c ^. E26Id) ==. (cgi ^. E26E7E8E26Id))
- where_ $ (cgi ^. E26E7E8E26E7Id) ==. ((val localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (c ^. E26Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (c ^. E26Id, c ^. E26Name, c ^. E26Version, c ^. E26E30d, c ^. E26E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "name" .= toJSON f2,
- "version" .= toJSON f3,
- "e30d" .= toJSON f4,
- "e311" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- getE26groupsR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE26groupsR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(cg ) -> do
- let cgId' = cg ^. E26E7Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (cg ^. E26E7Name) ]
- "DESC" -> orderBy [ desc (cg ^. E26E7Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (cg ^. E26E7Version) ]
- "DESC" -> orderBy [ desc (cg ^. E26E7Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (cg ^. E26E7E30d) ]
- "DESC" -> orderBy [ desc (cg ^. E26E7E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (cg ^. E26E7E311) ]
- "DESC" -> orderBy [ desc (cg ^. E26E7E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (cg ^. E26E7Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (cg ^. E26E7Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (cg ^. E26E7Id, cg ^. E26E7Name, cg ^. E26E7Version, cg ^. E26E7E30d, cg ^. E26E7E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "name" .= toJSON f2,
- "version" .= toJSON f3,
- "e30d" .= toJSON f4,
- "e311" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- getE12sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE12sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_e10IdList <- lookupGetParam "e10IdList"
- filterParam_dayList <- lookupGetParam "dayList"
- filterParam_startE11List <- lookupGetParam "startE11List"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c `InnerJoin` s) -> do
- on ((t ^. E12E10Id) ==. (s ^. E10Id))
- on ((t ^. E12E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E12Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "e10Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10Name) ]
- "DESC" -> orderBy [ desc (s ^. E10Name) ]
- _ -> return ()
- "day" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12Day) ]
- "DESC" -> orderBy [ desc (t ^. E12Day) ]
- _ -> return ()
- "startE11" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12StartE11) ]
- "DESC" -> orderBy [ desc (t ^. E12StartE11) ]
- _ -> return ()
- "e314Window" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E314Window) ]
- "DESC" -> orderBy [ desc (t ^. E12E314Window) ]
- _ -> return ()
- "accurate" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12Accurate) ]
- "DESC" -> orderBy [ desc (t ^. E12Accurate) ]
- _ -> return ()
- "count" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12Count) ]
- "DESC" -> orderBy [ desc (t ^. E12Count) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E12StartE11), asc (c ^. E26Name), asc (s ^. E10Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
- _ -> return ()
- "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
- _ -> return ()
- "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
- _ -> return ()
- "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e10Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10Id) (val v)
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E26Id) (val v)
- _ -> return ()
- "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Day) (val v)
- _ -> return ()
- "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12StartE11) (val v)
- _ -> return ()
- "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E314Window) (val v)
- _ -> return ()
- "accurate" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Accurate) (val v)
- _ -> return ()
- "count" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Count) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_e10IdList defaultFilterJson "e10IdList" of
- Just localParam -> do
- where_ $ (s ^. E10Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
- Just localParam -> do
- where_ $ (t ^. E12Day) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
- Just localParam -> do
- where_ $ (t ^. E12StartE11) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E12Id, c ^. E26Name, s ^. E10Name, t ^. E12Day, t ^. E12StartE11, t ^. E12E314Window, t ^. E12Accurate, t ^. E12Count)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "e10Name" .= toJSON f3,
- "day" .= toJSON f4,
- "startE11" .= toJSON f5,
- "e314Window" .= toJSON f6,
- "accurate" .= toJSON f7,
- "count" .= toJSON f8
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE12sE12IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE12sE12IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\t -> where_ $ (t ^. E12Id) ==. ((val p1)))
- return $ A.Null
- getE17e12sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE17e12sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_e10IdList <- lookupGetParam "e10IdList"
- filterParam_wdayList <- lookupGetParam "wdayList"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c `InnerJoin` s) -> do
- on ((t ^. E12E12E10Id) ==. (s ^. E10Id))
- on ((t ^. E12E12E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E12E12Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "e10Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (s ^. E10Name) ]
- "DESC" -> orderBy [ desc (s ^. E10Name) ]
- _ -> return ()
- "wday" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E12Wday) ]
- "DESC" -> orderBy [ desc (t ^. E12E12Wday) ]
- _ -> return ()
- "e314" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E12E314) ]
- "DESC" -> orderBy [ desc (t ^. E12E12E314) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E12E12E314), asc (c ^. E26Name), asc (s ^. E10Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
- _ -> return ()
- "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
- _ -> return ()
- "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
- _ -> return ()
- "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e10Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E10Id) (val v)
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E26Id) (val v)
- _ -> return ()
- "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12Wday) (val v)
- _ -> return ()
- "e314" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E314) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_e10IdList defaultFilterJson "e10IdList" of
- Just localParam -> do
- where_ $ (s ^. E10Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
- Just localParam -> do
- where_ $ (t ^. E12E12Wday) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E12E12Id, c ^. E26Name, s ^. E10Name, t ^. E12E12Wday, t ^. E12E12E314)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "e10Name" .= toJSON f3,
- "wday" .= toJSON f4,
- "e314" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE17e12sE12E12IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12E12Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE17e12sE12E12IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\t -> where_ $ (t ^. E12E12Id) ==. ((val p1)))
- return $ A.Null
- postE17e12sE12E12IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12E12Id -> HandlerT Generated (HandlerT master IO) A.Value
- postE17e12sE12E12IdR p1 = do
- authId <- lift $ requireAuthId
- yReq <- getRequest
- let wReq = reqWaiRequest yReq
- bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
- jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
- Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
- Right o -> return o
- jsonBodyObj <- case jsonBody of
- A.Object o -> return o
- v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
- e1 <- case A.fromJSON jsonBody of
- A.Success e -> return e
- A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E12E12 from JSON object in the request body : " ++ err )
- _ <- lift $ runDB $ do
- vErrors <- lift $ validate e1
- case vErrors of
- xs@(_:_) -> sendResponseStatus status400 (A.object [
- "message" .= ("Entity validation failed" :: Text),
- "errors" .= toJSON xs
- ])
- _ -> P.insert (e1 :: E12E12)
- return $ A.Null
- getE17e12e34sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE17e12e34sR = do
- authId <- lift $ requireAuthId
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_firstDay <- lookupGetParam "firstDay"
- filterParam_lastDay <- lookupGetParam "lastDay"
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- let baseQuery limitOffsetOrder = from $ \(e `InnerJoin` c) -> do
- on ((e ^. E12E12E34E26Id) ==. (c ^. E26Id))
- let eId' = e ^. E12E12E34Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "day" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (e ^. E12E12E34Day) ]
- "DESC" -> orderBy [ desc (e ^. E12E12E34Day) ]
- _ -> return ()
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (e ^. E12E12E34Day), asc (e ^. E12E12E34E26Id) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (e ^. E12E12E34E26Id) (val v)
- _ -> return ()
- "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (e ^. E12E12E34Day) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (e ^. E12E12E34E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_firstDay defaultFilterJson "firstDay" of
- Just localParam -> do
- where_ $ (e ^. E12E12E34Day) >=. ((val localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_lastDay defaultFilterJson "lastDay" of
- Just localParam -> do
- where_ $ (e ^. E12E12E34Day) <=. ((val localParam))
- Nothing -> return ()
- return (e ^. E12E12E34Id, e ^. E12E12E34Day, c ^. E26Name)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3)) -> A.object [
- "id" .= toJSON f1,
- "day" .= toJSON f2,
- "e26Name" .= toJSON f3
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE17e12e34sE12E12E34IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12E12E34Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE17e12e34sE12E12E34IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\e -> where_ $ (e ^. E12E12E34Id) ==. ((val p1)))
- return $ A.Null
- getE19sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE19sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_query <- lookupGetParam "query"
- let baseQuery limitOffsetOrder = from $ \(p ) -> do
- let pId' = p ^. E19Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e31" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (p ^. E19E31) ]
- "DESC" -> orderBy [ desc (p ^. E19E31) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (p ^. E19Name) ]
- "DESC" -> orderBy [ desc (p ^. E19Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (p ^. E19Version) ]
- "DESC" -> orderBy [ desc (p ^. E19Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (p ^. E19E30d) ]
- "DESC" -> orderBy [ desc (p ^. E19E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (p ^. E19E311) ]
- "DESC" -> orderBy [ desc (p ^. E19E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (p ^. E19Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E31) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_query defaultFilterJson "query" of
- Just localParam -> do
- where_ $ (p ^. E19Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
- Nothing -> return ()
- return (p ^. E19Id, p ^. E19E31, p ^. E19Name, p ^. E19Version, p ^. E19E30d, p ^. E19E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "e31" .= toJSON f2,
- "name" .= toJSON f3,
- "version" .= toJSON f4,
- "e30d" .= toJSON f5,
- "e311" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- getE31sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE31sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- let baseQuery limitOffsetOrder = from $ \(c ) -> do
- let cId' = c ^. E20Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 1000
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "title" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20Title) ]
- "DESC" -> orderBy [ desc (c ^. E20Title) ]
- _ -> return ()
- "address" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20Address) ]
- "DESC" -> orderBy [ desc (c ^. E20Address) ]
- _ -> return ()
- "email" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20Email) ]
- "DESC" -> orderBy [ desc (c ^. E20Email) ]
- _ -> return ()
- "name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20Name) ]
- "DESC" -> orderBy [ desc (c ^. E20Name) ]
- _ -> return ()
- "version" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20Version) ]
- "DESC" -> orderBy [ desc (c ^. E20Version) ]
- _ -> return ()
- "e30d" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20E30d) ]
- "DESC" -> orderBy [ desc (c ^. E20E30d) ]
- _ -> return ()
- "e311" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E20E311) ]
- "DESC" -> orderBy [ desc (c ^. E20E311) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (c ^. E20Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "title" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Title) (val v)
- _ -> return ()
- "address" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Address) (val v)
- _ -> return ()
- "email" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Email) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20E311) (val (Just v))
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- return (c ^. E20Id, c ^. E20Title, c ^. E20Address, c ^. E20Email, c ^. E20Name, c ^. E20Version, c ^. E20E30d, c ^. E20E311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
- "id" .= toJSON f1,
- "title" .= toJSON f2,
- "address" .= toJSON f3,
- "email" .= toJSON f4,
- "name" .= toJSON f5,
- "version" .= toJSON f6,
- "e30d" .= toJSON f7,
- "e311" .= toJSON f8
- ]
- _ -> A.object []
- ) results)
- ]
- getE31E20IdNumbersR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E20Id -> HandlerT Generated (HandlerT master IO) A.Value
- getE31E20IdNumbersR p1 = do
- authId <- lift $ requireAuthId
- let baseQuery limitOffsetOrder = from $ \(c `InnerJoin` cn) -> do
- on ((cn ^. E20NumberE31Id) ==. (c ^. E20Id))
- let cId' = c ^. E20Id
- where_ ((c ^. E20Id) ==. ((val p1)))
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 10000
- else return ()
- return (cn ^. E20NumberId, cn ^. E20NumberE31Id, cn ^. E20NumberNumber, cn ^. E20NumberName, cn ^. E20NumberVersion, cn ^. E20NumberE30d, cn ^. E20NumberE311)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7)) -> A.object [
- "id" .= toJSON f1,
- "e31Id" .= toJSON f2,
- "number" .= toJSON f3,
- "name" .= toJSON f4,
- "version" .= toJSON f5,
- "e30d" .= toJSON f6,
- "e311" .= toJSON f7
- ]
- _ -> A.object []
- ) results)
- ]
- getE16e12sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE16e12sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_E16IdList <- lookupGetParam "E16IdList"
- filterParam_dayList <- lookupGetParam "dayList"
- filterParam_startE11List <- lookupGetParam "startE11List"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c `InnerJoin` f) -> do
- on ((t ^. E16E12E16Id) ==. (f ^. E16Id))
- on ((t ^. E16E12E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E16E12Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "e16Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (f ^. E16Name) ]
- "DESC" -> orderBy [ desc (f ^. E16Name) ]
- _ -> return ()
- "day" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E16E12Day) ]
- "DESC" -> orderBy [ desc (t ^. E16E12Day) ]
- _ -> return ()
- "startE11" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E16E12StartE11) ]
- "DESC" -> orderBy [ desc (t ^. E16E12StartE11) ]
- _ -> return ()
- "e314Window" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E16E12E314Window) ]
- "DESC" -> orderBy [ desc (t ^. E16E12E314Window) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E16E12StartE11), asc (c ^. E26Name), asc (f ^. E16Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E31) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E311) (val (Just v))
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e16Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E16Id) (val v)
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E26Id) (val v)
- _ -> return ()
- "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12Day) (val v)
- _ -> return ()
- "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12StartE11) (val v)
- _ -> return ()
- "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E314Window) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_E16IdList defaultFilterJson "E16IdList" of
- Just localParam -> do
- where_ $ (f ^. E16Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
- Just localParam -> do
- where_ $ (t ^. E16E12Day) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
- Just localParam -> do
- where_ $ (t ^. E16E12StartE11) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E16E12Id, c ^. E26Name, f ^. E16Name, t ^. E16E12Day, t ^. E16E12StartE11, t ^. E16E12E314Window)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "e16Name" .= toJSON f3,
- "day" .= toJSON f4,
- "startE11" .= toJSON f5,
- "e314Window" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE16e12sE16E12IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E16E12Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE16e12sE16E12IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\t -> where_ $ (t ^. E16E12Id) ==. ((val p1)))
- return $ A.Null
- getE17E16e12sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE17E16e12sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_e16IdList <- lookupGetParam "e16IdList"
- filterParam_wdayList <- lookupGetParam "wdayList"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c `InnerJoin` f) -> do
- on ((t ^. E12E16E12E16Id) ==. (f ^. E16Id))
- on ((t ^. E12E16E12E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E12E16E12Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "e16Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (f ^. E16Name) ]
- "DESC" -> orderBy [ desc (f ^. E16Name) ]
- _ -> return ()
- "wday" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E16E12Wday) ]
- "DESC" -> orderBy [ desc (t ^. E12E16E12Wday) ]
- _ -> return ()
- "e314" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E16E12E314) ]
- "DESC" -> orderBy [ desc (t ^. E12E16E12E314) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E12E16E12E314), asc (c ^. E26Name), asc (f ^. E16Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E31) (val v)
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E311) (val (Just v))
- _ -> return ()
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e16Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E16Id) (val v)
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E26Id) (val v)
- _ -> return ()
- "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12Wday) (val v)
- _ -> return ()
- "e314" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E314) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_e16IdList defaultFilterJson "e16IdList" of
- Just localParam -> do
- where_ $ (f ^. E16Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
- Just localParam -> do
- where_ $ (t ^. E12E16E12Wday) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E12E16E12Id, c ^. E26Name, f ^. E16Name, t ^. E12E16E12Wday, t ^. E12E16E12E314)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "e16Name" .= toJSON f3,
- "wday" .= toJSON f4,
- "e314" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE17E16e12sE12E16E12IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12E16E12Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE17E16e12sE12E16E12IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\t -> where_ $ (t ^. E12E16E12Id) ==. ((val p1)))
- return $ A.Null
- getE10e314sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE10e314sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_dayList <- lookupGetParam "dayList"
- filterParam_startE11List <- lookupGetParam "startE11List"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c) -> do
- on ((t ^. E10E11E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E10E11Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "day" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E10E11Day) ]
- "DESC" -> orderBy [ desc (t ^. E10E11Day) ]
- _ -> return ()
- "startE11" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E10E11StartE11) ]
- "DESC" -> orderBy [ desc (t ^. E10E11StartE11) ]
- _ -> return ()
- "e314Window" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E10E11E314Window) ]
- "DESC" -> orderBy [ desc (t ^. E10E11E314Window) ]
- _ -> return ()
- "active" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E10E11Active) ]
- "DESC" -> orderBy [ desc (t ^. E10E11Active) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E10E11StartE11), asc (c ^. E26Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11E26Id) (val v)
- _ -> return ()
- "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11Day) (val v)
- _ -> return ()
- "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11StartE11) (val v)
- _ -> return ()
- "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11E314Window) (val v)
- _ -> return ()
- "active" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11Active) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
- Just localParam -> do
- where_ $ (t ^. E10E11Day) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
- Just localParam -> do
- where_ $ (t ^. E10E11StartE11) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E10E11Id, c ^. E26Name, t ^. E10E11Day, t ^. E10E11StartE11, t ^. E10E11E314Window, t ^. E10E11Active)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "day" .= toJSON f3,
- "startE11" .= toJSON f4,
- "e314Window" .= toJSON f5,
- "active" .= toJSON f6
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE10e314sE10E11IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E10E11Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE10e314sE10E11IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\s -> where_ $ (s ^. E10E11Id) ==. ((val p1)))
- return $ A.Null
- getE17e10e314sR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => HandlerT Generated (HandlerT master IO) A.Value
- getE17e10e314sR = do
- authId <- lift $ requireAuthId
- defaultFilterParam <- lookupGetParam "filter"
- let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
- defaultSortParam <- lookupGetParam "sort"
- let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
- defaultOffsetParam <- lookupGetParam "start"
- defaultLimitParam <- lookupGetParam "limit"
- let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
- let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
- filterParam_e26IdList <- lookupGetParam "e26IdList"
- filterParam_wdayList <- lookupGetParam "wdayList"
- filterParam_startE11List <- lookupGetParam "startE11List"
- let baseQuery limitOffsetOrder = from $ \(t `InnerJoin` c) -> do
- on ((t ^. E12E10E11E26Id) ==. (c ^. E26Id))
- let tId' = t ^. E12E10E11Id
- _ <- if limitOffsetOrder
- then do
- offset 0
- limit 100
- case defaultSortJson of
- Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
- "e26Name" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (c ^. E26Name) ]
- "DESC" -> orderBy [ desc (c ^. E26Name) ]
- _ -> return ()
- "wday" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E10E11Wday) ]
- "DESC" -> orderBy [ desc (t ^. E12E10E11Wday) ]
- _ -> return ()
- "startE11" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E10E11StartE11) ]
- "DESC" -> orderBy [ desc (t ^. E12E10E11StartE11) ]
- _ -> return ()
- "e314Window" -> case (sortJsonMsg_direction sjm) of
- "ASC" -> orderBy [ asc (t ^. E12E10E11E314Window) ]
- "DESC" -> orderBy [ desc (t ^. E12E10E11E314Window) ]
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> orderBy [ asc (t ^. E12E10E11StartE11), asc (c ^. E26Name) ]
- case defaultOffset of
- Just o -> offset o
- Nothing -> return ()
- case defaultLimit of
- Just l -> limit (min 10000 l)
- Nothing -> return ()
- else return ()
- case defaultFilterJson of
- Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
- "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
- _ -> return ()
- "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
- _ -> return ()
- "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
- _ -> return ()
- "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
- _ -> return ()
- "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11E26Id) (val v)
- _ -> return ()
- "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11Wday) (val v)
- _ -> return ()
- "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11StartE11) (val v)
- _ -> return ()
- "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
- (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11E314Window) (val v)
- _ -> return ()
- _ -> return ()
- ) xs
- Nothing -> return ()
- case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
- Just localParam -> do
- where_ $ (c ^. E26Id) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
- Just localParam -> do
- where_ $ (t ^. E12E10E11Wday) `in_` ((valList localParam))
- Nothing -> return ()
- case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
- Just localParam -> do
- where_ $ (t ^. E12E10E11StartE11) `in_` ((valList localParam))
- Nothing -> return ()
- return (t ^. E12E10E11Id, c ^. E26Name, t ^. E12E10E11Wday, t ^. E12E10E11StartE11, t ^. E12E10E11E314Window)
- count <- lift $ runDB $ select $ do
- baseQuery False
- let countRows' = countRows
- orderBy []
- return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
- results <- lift $ runDB $ select $ baseQuery True
- return $ A.object [
- "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
- "result" .= (toJSON $ map (\row -> case row of
- ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
- "id" .= toJSON f1,
- "e26Name" .= toJSON f2,
- "wday" .= toJSON f3,
- "startE11" .= toJSON f4,
- "e314Window" .= toJSON f5
- ]
- _ -> A.object []
- ) results)
- ]
- deleteE17e10e314sE12E10E11IdR :: forall master. (GeneratedValidation master,
- YesodAuthPersist master,
- YesodPersistBackend master ~ SqlPersistT)
- => E12E10E11Id -> HandlerT Generated (HandlerT master IO) A.Value
- deleteE17e10e314sE12E10E11IdR p1 = do
- authId <- lift $ requireAuthId
- _ <- lift $ runDB $ do
- delete $ from $ (\t -> where_ $ (t ^. E12E10E11Id) ==. ((val p1)))
- return $ A.Null
- data Generated = Generated
- getGenerated :: a -> Generated
- getGenerated = const Generated
- mkYesodSubData "Generated" [parseRoutes|
- /e10s E10sR GET POST
- /e10s/#E10Id E10sE10IdR GET PUT DELETE
- /e10e33 E10e33R GET
- /e11pieces E11piecesR GET
- /e11e33 E11e33R GET
- /e16s E16sR GET
- /e13s E13sR GET
- /e13e33 E13e33R GET
- /e14s E14sR GET
- /e14s/#E14Id/content E14sE14IdContentR GET
- /e26s E26sR GET
- /e26groups E26groupsR GET
- /e12s E12sR GET
- /e12s/#E12Id E12sE12IdR DELETE
- /e17e12s E17e12sR GET
- /e17e12s/#E12E12Id E17e12sE12E12IdR DELETE POST
- /e17e12e34s E17e12e34sR GET
- /e17e12e34s/#E12E12E34Id E17e12e34sE12E12E34IdR DELETE
- /e19s E19sR GET
- /e31s E31sR GET
- /e31/#E20Id/numbers E31E20IdNumbersR GET
- /e16e12s E16e12sR GET
- /e16e12s/#E16E12Id E16e12sE16E12IdR DELETE
- /e17E16e12s E17E16e12sR GET
- /e17E16e12s/#E12E16E12Id E17E16e12sE12E16E12IdR DELETE
- /e10e314s E10e314sR GET
- /e10e314s/#E10E11Id E10e314sE10E11IdR DELETE
- /e17e10e314s E17e10e314sR GET
- /e17e10e314s/#E12E10E11Id E17e10e314sE12E10E11IdR DELETE
- |]
Advertisement
Add Comment
Please, Sign In to add comment