Refactor to use plain GoStyleCamelCase instead of json_style_snake_case.
This commit is contained in:
parent
931c493928
commit
051474bdc9
12 changed files with 60 additions and 61 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
)
|
||||
|
||||
func SearchTable(search string, table string, the_type reflect.Type, limit uint64, page uint64) ([]any, error) {
|
||||
|
||||
var results []any
|
||||
like := fmt.Sprint("%", search, "%")
|
||||
|
||||
|
|
@ -127,14 +126,12 @@ func Update(table string, value reflect.Value) error {
|
|||
// skip update of id to avoid replacing it
|
||||
if tag == "id" { continue }
|
||||
|
||||
fmt.Println(">>>>>>>>>>>>>>>>> field", tag, "=", field.Interface())
|
||||
builder = builder.Set(tag, field.Interface())
|
||||
}
|
||||
|
||||
builder = builder.Where(sq.Eq{"id": value.FieldByName("Id").Interface()})
|
||||
sql_query, args, err := builder.ToSql()
|
||||
|
||||
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!UPDATE QUERY", sql_query, args)
|
||||
if err != nil { return err}
|
||||
|
||||
_, err = data.DB.Exec(sql_query, args...)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,9 @@ func ReflectOnPost(typeOf reflect.Type, c *fiber.Ctx) (reflect.Value, error) {
|
|||
result_val = reflect.New(typeOf)
|
||||
result := result_val.Interface()
|
||||
|
||||
if err := c.BodyParser(result); err != nil {
|
||||
if err := c.BodyParser(result)
|
||||
|
||||
err != nil {
|
||||
log.Println(err);
|
||||
return result_val, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,38 +8,38 @@ type Login struct {
|
|||
}
|
||||
|
||||
type User struct {
|
||||
Id int `db:"id" json:"id" validate:"numeric"`
|
||||
Id int `db:"id" `
|
||||
Username string `db:"username" validate:"required,max=30"`
|
||||
Email string `db:"email" validate:"required,email,max=128"`
|
||||
Password string `db:"password" validate:"required,min=8,max=64"`
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
Id int `db:"id" json:"id" validate:"isdefault"`
|
||||
StreamId int `db:"stream_id" json:"stream_id" form:"stream_id" validate:"required,numeric"`
|
||||
Url string `db:"url" json:"url" form:"url" validate:"required,http_url,max=150"`
|
||||
Description string `db:"description" json:"description" form:"description" validate:"required,max=300"`
|
||||
Id int `db:"id" `
|
||||
StreamId int `db:"stream_id" `
|
||||
Url string `db:"url" `
|
||||
Description string `db:"description" `
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
Id int `db:"id" json:"id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description string `db:"description" json:"description"`
|
||||
Id int `db:"id" `
|
||||
Title string `db:"title" `
|
||||
Description string `db:"description" `
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
Id int `db:"id" json:"id"`
|
||||
Slug string `db:"slug" json:"slug"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description string `db:"description" json:"description"`
|
||||
Image string `db:"image" json:"image"`
|
||||
Url string `db:"url" json:"url"`
|
||||
Tags string `db:"tags" json:"tags"`
|
||||
Video string `db:"video" json:"video"`
|
||||
CurrentStatus string `db:"current_status" json:"current_status" form:"current_status"`
|
||||
PlannedWork string `db:"planned_work" json:"planned_work" form:"planned_work"`
|
||||
CodeUrl string `db:"code_url" json:"code_url" form:"code_url"`
|
||||
HeaderImage string `db:"header_image" json:"header_image" form:"header_image"`
|
||||
Id int `db:"id" `
|
||||
Slug string `db:"slug" `
|
||||
Title string `db:"title" `
|
||||
Description string `db:"description" `
|
||||
Image string `db:"image" `
|
||||
Url string `db:"url" `
|
||||
Tags string `db:"tags" `
|
||||
Video string `db:"video" `
|
||||
CurrentStatus string `db:"current_status" `
|
||||
PlannedWork string `db:"planned_work" `
|
||||
CodeUrl string `db:"code_url" `
|
||||
HeaderImage string `db:"header_image" `
|
||||
}
|
||||
|
||||
func Models() map[string]reflect.Type {
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
<block x-data="Games">
|
||||
<template x-for="item in contents">
|
||||
<grid class="two-panel">
|
||||
<a data-testid="game-link" x-bind:href="`/game/${item.id}/${item.slug}/`">
|
||||
<img x-bind:src="item.image" />
|
||||
<a data-testid="game-link" x-bind:href="`/game/${item.Id}/${item.Slug}/`">
|
||||
<img x-bind:src="item.Image" />
|
||||
</a>
|
||||
<block>
|
||||
<h3 x-text="item.title"></h3>
|
||||
<p x-text="item.description"></p>
|
||||
<h3 x-text="item.Title"></h3>
|
||||
<p x-text="item.Description"></p>
|
||||
</block>
|
||||
</grid>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
<tr class="table-header"><th>URL</th><th>Description</th></tr>
|
||||
<template x-for="item in links">
|
||||
<tr class="table-row">
|
||||
<td class="p-2"><a x-text="item.url" x-bind:href="item.url" target="_blank"></a></td>
|
||||
<td class="p-2" x-text="item.description"></td>
|
||||
<td class="p-2"><a x-text="item.Url" x-bind:href="item.Url" target="_blank"></a></td>
|
||||
<td class="p-2" x-text="item.Description"></td>
|
||||
</tr>
|
||||
</template>
|
||||
</table>
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
<card class="card">
|
||||
<top>Submit a Link</top>
|
||||
<middle>
|
||||
<input id="stream_id" name="stream_id" type="hidden" value="1">
|
||||
<input id="url" name="url" type="text" placeholder="Link Url">
|
||||
<input id="description" name="description" type="text" placeholder="Description">
|
||||
<input id="StreamId" name="StreamId" type="hidden" value="1">
|
||||
<input id="Url" name="Url" type="text" placeholder="Link Url">
|
||||
<input id="Description" name="Description" type="text" placeholder="Description">
|
||||
</middle>
|
||||
<bottom>
|
||||
<button id="submit" type="submit">Send It</button>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
<card>
|
||||
<top><h2 style="color: white">Login</h2></top>
|
||||
<middle>
|
||||
<label for="username">Username</label>
|
||||
<input id="username" name="username" placeholder="Username" type="text">
|
||||
<label for="password">Password</label>
|
||||
<input id="password" name="password" placeholder="Password" type="password">
|
||||
<label for="Username">Username</label>
|
||||
<input id="Username" name="Username" placeholder="Username" type="text">
|
||||
<label for="Password">Password</label>
|
||||
<input id="Password" name="Password" placeholder="Password" type="password">
|
||||
</middle>
|
||||
<bottom>
|
||||
<button class="hover:btn-alert" type="button">Cancel</button>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
<card>
|
||||
<top><h2 style="color: white">Register</h2></top>
|
||||
<middle>
|
||||
<label for="username">Username</label>
|
||||
<input id="username" name="username" placeholder="Username" type="text">
|
||||
<label for="email">FAKE! Email</label>
|
||||
<input id="email" name="email" placeholder="fake@faker.com" type="text">
|
||||
<label for="password">Password</label>
|
||||
<input id="password" name="password" placeholder="Password" type="password">
|
||||
<label for="Username">Username</label>
|
||||
<input id="Username" name="Username" placeholder="Username" type="text">
|
||||
<label for="Email">FAKE! Email</label>
|
||||
<input id="Email" name="Email" placeholder="fake@faker.com" type="text">
|
||||
<label for="Password">Password</label>
|
||||
<input id="Password" name="Password" placeholder="Password" type="password">
|
||||
</middle>
|
||||
<bottom>
|
||||
<button class="hover:btn-alert" type="button">Cancel</button>
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
<stream class="flex p-3 gap-4 bg-gray-300 dark:bg-gray-800">
|
||||
<shape class="xxs bg-gray-400! dark:bg-gray-300">Stream Thumbnail</shape>
|
||||
<info>
|
||||
<date x-text="item.date"></date>
|
||||
<p x-text="item.description"></p>
|
||||
<a style="text-align: right" x-bind:href="'/stream/' + item.id + '/'">View This Stream</a>
|
||||
<date x-text="item.Date"></date>
|
||||
<p x-text="item.Description"></p>
|
||||
<a style="text-align: right" x-bind:href="'/stream/' + item.Id + '/'">View This Stream</a>
|
||||
</info>
|
||||
</stream>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
<th x-text="header"></th>
|
||||
</template>
|
||||
</tr>
|
||||
<template x-for="item in contents" :key="item.id">
|
||||
<template x-for="item in contents" :key="item.Id">
|
||||
<tr class="table-row">
|
||||
<td>
|
||||
<a x-bind:href="'/admin/table/{{ .Table }}/' + item.id + '/'">
|
||||
<a x-bind:href="'/admin/table/{{ .Table }}/' + item.Id + '/'">
|
||||
#
|
||||
</a>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
</middle>
|
||||
<bottom>
|
||||
<button type="button"><a href="/admin/table/{{ .Table }}/">Back</a></button>
|
||||
<button class="hover:btn-alert" type="button" @click.prevent="ConfirmDelete('{{ .Table }}', item.id)">Delete</button>
|
||||
<button class="hover:btn-alert" type="button" @click.prevent="ConfirmDelete('{{ .Table }}', item.Id)">Delete</button>
|
||||
<button class="hover:btn-hover" type="submit">Update</button>
|
||||
</bottom>
|
||||
</card>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
x-data="{item: {}}"
|
||||
x-init="item = await GetJson('/api/game/1')">
|
||||
|
||||
<h3 x-text="item.title"></h3>
|
||||
<h3 x-text="item.Title"></h3>
|
||||
|
||||
<div class="gap-3 pb-3 flex flex-col lg:flex-row-reverse">
|
||||
<div class="!text-sm !p-0 flex flex-col md:flex-row lg:flex-col">
|
||||
<img :src="item.header_image" />
|
||||
<img :src="item.HeaderImage" />
|
||||
<block>
|
||||
<p class="m-2" x-text="item.description"></p>
|
||||
<p class="m-2" x-text="item.Description"></p>
|
||||
<table>
|
||||
<tr><th class="text-gray-400 text-left">RECENT REVIEWS:</th><td>Insanely Optimistic</td></tr>
|
||||
<tr><th class="text-gray-400 text-left">ENGLISH REVIEWS:</th><td>Probably Racist</td></tr>
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
</div>
|
||||
<div class="flex">
|
||||
<video controls>
|
||||
<template x-if="item.video">
|
||||
<source :src="item.video" type="video/mp4" />
|
||||
<template x-if="item.Video">
|
||||
<source :src="item.Video" type="video/mp4" />
|
||||
</template>
|
||||
</video>
|
||||
</div>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<bar class="!p-0 *:!p-0">
|
||||
<block>
|
||||
<table class="flex flex-col">
|
||||
<template x-for="tag in item.tags.split(' ')">
|
||||
<template x-for="tag in item.Tags.split(' ')">
|
||||
<tr>
|
||||
<td style="width: 24px; min-width: 24px; max-width: 24px" class="aspect-square bg-gray-300 p-1"><img src="/icons/baby.svg" /></td>
|
||||
<td class="p-1" x-text="tag"></td>
|
||||
|
|
@ -40,20 +40,20 @@
|
|||
|
||||
<block>
|
||||
<h4>Current Status</h4>
|
||||
<p x-text="item.current_status"></p>
|
||||
<p x-text="item.CurrentStatus"></p>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
<block>
|
||||
<block>
|
||||
<h4>Planned Work</h4>
|
||||
<p x-text="item.planned_work"></p>
|
||||
<p x-text="item.PlannedWork"></p>
|
||||
</block>
|
||||
|
||||
<block>
|
||||
<h4>Read The Code</h4>
|
||||
<p>All of the code for this project is online in my personal git repository. It's not open source, but you can read the code, run the game, and learn from it. Think of it like the programmer's version of a thirst trap on Instagram. You can look but you own nothing.</p>
|
||||
<button><a :href="item.code_url" target="_blank">View the Git</a></button>
|
||||
<button><a :href="item.CodeUrl" target="_blank">View the Git</a></button>
|
||||
</block>
|
||||
</block>
|
||||
</bar>
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
<div x-init="item = await Stream.item()" x-data="{item: {}}">
|
||||
<block style="--value: 7">
|
||||
<h1 x-text="item.title"></h1>
|
||||
<h1 x-text="item.Title"></h1>
|
||||
|
||||
<div>
|
||||
<p x-text="item.description"></p>
|
||||
<p x-text="item.Description"></p>
|
||||
</div>
|
||||
</block>
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<ul x-data="Links">
|
||||
<template x-for="item in contents">
|
||||
<li><a x-text="item.description" x-bind:href="item.url"></a></li>
|
||||
<li><a x-text="item.Description" x-bind:href="item.Url"></a></li>
|
||||
</template>
|
||||
</ul>
|
||||
</block>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue