File tree Expand file tree Collapse file tree 7 files changed +109
-0
lines changed
java/eu/pretix/libpretixsync
sqldelight/common/eu/pretix/libpretixsync/sqldelight Expand file tree Collapse file tree 7 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 1+ package eu.pretix.libpretixsync.database
2+
3+ import eu.pretix.libpretixsync.sqldelight.BadgeLayout
4+ import org.json.JSONArray
5+ import org.json.JSONObject
6+ import eu.pretix.libpretixsync.models.BadgeLayout as BadgeLayoutModel
7+
8+ fun BadgeLayout.toModel () =
9+ BadgeLayoutModel (
10+ id = this .id,
11+ backgroundFilename = this .background_filename,
12+ eventSlug = this .event_slug!! ,
13+ isDefault = this .is_default,
14+ layout = JSONObject (this .json_data!! ).optJSONArray(" layout" ) ? : JSONArray (),
15+ serverId = this .server_id!! ,
16+ )
Original file line number Diff line number Diff line change 1+ package eu.pretix.libpretixsync.database
2+
3+ import eu.pretix.libpretixsync.sqldelight.TicketLayout
4+ import org.json.JSONArray
5+ import org.json.JSONObject
6+ import eu.pretix.libpretixsync.models.TicketLayout as TicketLayoutModel
7+
8+ fun TicketLayout.toModel () =
9+ TicketLayoutModel (
10+ id = this .id,
11+ backgroundFilename = this .background_filename,
12+ eventSlug = this .event_slug!! ,
13+ isDefault = this .is_default,
14+ layout = JSONObject (this .json_data!! ).optJSONArray(" layout" ) ? : JSONArray (),
15+ serverId = this .server_id!! ,
16+ )
Original file line number Diff line number Diff line change 1+ package eu.pretix.libpretixsync.models
2+
3+ import org.json.JSONArray
4+
5+ data class BadgeLayout (
6+ val id : Long ,
7+ val backgroundFilename : String? ,
8+ val eventSlug : String ,
9+ val isDefault : Boolean ,
10+ val layout : JSONArray ,
11+ val serverId : Long ,
12+ ) {
13+ companion object {
14+ fun defaultWithLayout (layout : String ): BadgeLayout {
15+ return BadgeLayout (
16+ id = 0L ,
17+ backgroundFilename = null ,
18+ eventSlug = " " ,
19+ isDefault = true ,
20+ layout = JSONArray (layout),
21+ serverId = 0L ,
22+ )
23+ }
24+ }
25+ }
26+
Original file line number Diff line number Diff line change 1+ package eu.pretix.libpretixsync.models
2+
3+ import org.json.JSONArray
4+
5+ data class TicketLayout (
6+ val id : Long ,
7+ val backgroundFilename : String? ,
8+ val eventSlug : String ,
9+ val isDefault : Boolean ,
10+ val layout : JSONArray ,
11+ val serverId : Long ,
12+ ) {
13+ companion object {
14+ fun defaultWithLayout (layout : String ): TicketLayout {
15+ return TicketLayout (
16+ id = 0L ,
17+ backgroundFilename = null ,
18+ eventSlug = " " ,
19+ isDefault = true ,
20+ layout = JSONArray (layout),
21+ serverId = 0L ,
22+ )
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ selectById:
2+ SELECT *
3+ FROM BadgeLayout
4+ WHERE id = ?;
5+
6+ selectDefaultForEventSlug:
7+ SELECT *
8+ FROM BadgeLayout
9+ WHERE
10+ is_default = TRUE
11+ AND event_slug = ?;
Original file line number Diff line number Diff line change 1+ selectByItemId:
2+ SELECT *
3+ FROM BadgeLayoutItem
4+ WHERE item = ?;
Original file line number Diff line number Diff line change 1+ selectByServerId:
2+ SELECT *
3+ FROM TicketLayout
4+ WHERE server_id = ?;
5+
6+ selectDefaultForEventSlug:
7+ SELECT *
8+ FROM TicketLayout
9+ WHERE
10+ is_default = TRUE
11+ AND event_slug = ?;
You can’t perform that action at this time.
0 commit comments