Refactor to use plain GoStyleCamelCase instead of json_style_snake_case.

This commit is contained in:
Zed A. Shaw 2025-09-18 15:44:53 -04:00
parent 931c493928
commit 051474bdc9
12 changed files with 60 additions and 61 deletions

View file

@ -9,7 +9,6 @@ import (
) )
func SearchTable(search string, table string, the_type reflect.Type, limit uint64, page uint64) ([]any, error) { func SearchTable(search string, table string, the_type reflect.Type, limit uint64, page uint64) ([]any, error) {
var results []any var results []any
like := fmt.Sprint("%", search, "%") like := fmt.Sprint("%", search, "%")
@ -127,14 +126,12 @@ func Update(table string, value reflect.Value) error {
// skip update of id to avoid replacing it // skip update of id to avoid replacing it
if tag == "id" { continue } if tag == "id" { continue }
fmt.Println(">>>>>>>>>>>>>>>>> field", tag, "=", field.Interface())
builder = builder.Set(tag, field.Interface()) builder = builder.Set(tag, field.Interface())
} }
builder = builder.Where(sq.Eq{"id": value.FieldByName("Id").Interface()}) builder = builder.Where(sq.Eq{"id": value.FieldByName("Id").Interface()})
sql_query, args, err := builder.ToSql() sql_query, args, err := builder.ToSql()
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!UPDATE QUERY", sql_query, args)
if err != nil { return err} if err != nil { return err}
_, err = data.DB.Exec(sql_query, args...) _, err = data.DB.Exec(sql_query, args...)

View file

@ -48,7 +48,9 @@ func ReflectOnPost(typeOf reflect.Type, c *fiber.Ctx) (reflect.Value, error) {
result_val = reflect.New(typeOf) result_val = reflect.New(typeOf)
result := result_val.Interface() result := result_val.Interface()
if err := c.BodyParser(result); err != nil { if err := c.BodyParser(result)
err != nil {
log.Println(err); log.Println(err);
return result_val, err return result_val, err
} }

View file

@ -8,38 +8,38 @@ type Login struct {
} }
type User struct { type User struct {
Id int `db:"id" json:"id" validate:"numeric"` Id int `db:"id" `
Username string `db:"username" validate:"required,max=30"` Username string `db:"username" validate:"required,max=30"`
Email string `db:"email" validate:"required,email,max=128"` Email string `db:"email" validate:"required,email,max=128"`
Password string `db:"password" validate:"required,min=8,max=64"` Password string `db:"password" validate:"required,min=8,max=64"`
} }
type Link struct { type Link struct {
Id int `db:"id" json:"id" validate:"isdefault"` Id int `db:"id" `
StreamId int `db:"stream_id" json:"stream_id" form:"stream_id" validate:"required,numeric"` StreamId int `db:"stream_id" `
Url string `db:"url" json:"url" form:"url" validate:"required,http_url,max=150"` Url string `db:"url" `
Description string `db:"description" json:"description" form:"description" validate:"required,max=300"` Description string `db:"description" `
} }
type Stream struct { type Stream struct {
Id int `db:"id" json:"id"` Id int `db:"id" `
Title string `db:"title" json:"title"` Title string `db:"title" `
Description string `db:"description" json:"description"` Description string `db:"description" `
} }
type Game struct { type Game struct {
Id int `db:"id" json:"id"` Id int `db:"id" `
Slug string `db:"slug" json:"slug"` Slug string `db:"slug" `
Title string `db:"title" json:"title"` Title string `db:"title" `
Description string `db:"description" json:"description"` Description string `db:"description" `
Image string `db:"image" json:"image"` Image string `db:"image" `
Url string `db:"url" json:"url"` Url string `db:"url" `
Tags string `db:"tags" json:"tags"` Tags string `db:"tags" `
Video string `db:"video" json:"video"` Video string `db:"video" `
CurrentStatus string `db:"current_status" json:"current_status" form:"current_status"` CurrentStatus string `db:"current_status" `
PlannedWork string `db:"planned_work" json:"planned_work" form:"planned_work"` PlannedWork string `db:"planned_work" `
CodeUrl string `db:"code_url" json:"code_url" form:"code_url"` CodeUrl string `db:"code_url" `
HeaderImage string `db:"header_image" json:"header_image" form:"header_image"` HeaderImage string `db:"header_image" `
} }
func Models() map[string]reflect.Type { func Models() map[string]reflect.Type {

View file

@ -11,12 +11,12 @@
<block x-data="Games"> <block x-data="Games">
<template x-for="item in contents"> <template x-for="item in contents">
<grid class="two-panel"> <grid class="two-panel">
<a data-testid="game-link" x-bind:href="`/game/${item.id}/${item.slug}/`"> <a data-testid="game-link" x-bind:href="`/game/${item.Id}/${item.Slug}/`">
<img x-bind:src="item.image" /> <img x-bind:src="item.Image" />
</a> </a>
<block> <block>
<h3 x-text="item.title"></h3> <h3 x-text="item.Title"></h3>
<p x-text="item.description"></p> <p x-text="item.Description"></p>
</block> </block>
</grid> </grid>
</template> </template>

View file

@ -14,8 +14,8 @@
<tr class="table-header"><th>URL</th><th>Description</th></tr> <tr class="table-header"><th>URL</th><th>Description</th></tr>
<template x-for="item in links"> <template x-for="item in links">
<tr class="table-row"> <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"><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" x-text="item.Description"></td>
</tr> </tr>
</template> </template>
</table> </table>
@ -29,9 +29,9 @@
<card class="card"> <card class="card">
<top>Submit a Link</top> <top>Submit a Link</top>
<middle> <middle>
<input id="stream_id" name="stream_id" type="hidden" value="1"> <input id="StreamId" name="StreamId" type="hidden" value="1">
<input id="url" name="url" type="text" placeholder="Link Url"> <input id="Url" name="Url" type="text" placeholder="Link Url">
<input id="description" name="description" type="text" placeholder="Description"> <input id="Description" name="Description" type="text" placeholder="Description">
</middle> </middle>
<bottom> <bottom>
<button id="submit" type="submit">Send It</button> <button id="submit" type="submit">Send It</button>

View file

@ -3,10 +3,10 @@
<card> <card>
<top><h2 style="color: white">Login</h2></top> <top><h2 style="color: white">Login</h2></top>
<middle> <middle>
<label for="username">Username</label> <label for="Username">Username</label>
<input id="username" name="username" placeholder="Username" type="text"> <input id="Username" name="Username" placeholder="Username" type="text">
<label for="password">Password</label> <label for="Password">Password</label>
<input id="password" name="password" placeholder="Password" type="password"> <input id="Password" name="Password" placeholder="Password" type="password">
</middle> </middle>
<bottom> <bottom>
<button class="hover:btn-alert" type="button">Cancel</button> <button class="hover:btn-alert" type="button">Cancel</button>

View file

@ -3,12 +3,12 @@
<card> <card>
<top><h2 style="color: white">Register</h2></top> <top><h2 style="color: white">Register</h2></top>
<middle> <middle>
<label for="username">Username</label> <label for="Username">Username</label>
<input id="username" name="username" placeholder="Username" type="text"> <input id="Username" name="Username" placeholder="Username" type="text">
<label for="email">FAKE! Email</label> <label for="Email">FAKE! Email</label>
<input id="email" name="email" placeholder="fake@faker.com" type="text"> <input id="Email" name="Email" placeholder="fake@faker.com" type="text">
<label for="password">Password</label> <label for="Password">Password</label>
<input id="password" name="password" placeholder="Password" type="password"> <input id="Password" name="Password" placeholder="Password" type="password">
</middle> </middle>
<bottom> <bottom>
<button class="hover:btn-alert" type="button">Cancel</button> <button class="hover:btn-alert" type="button">Cancel</button>

View file

@ -12,9 +12,9 @@
<stream class="flex p-3 gap-4 bg-gray-300 dark:bg-gray-800"> <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> <shape class="xxs bg-gray-400! dark:bg-gray-300">Stream Thumbnail</shape>
<info> <info>
<date x-text="item.date"></date> <date x-text="item.Date"></date>
<p x-text="item.description"></p> <p x-text="item.Description"></p>
<a style="text-align: right" x-bind:href="'/stream/' + item.id + '/'">View This Stream</a> <a style="text-align: right" x-bind:href="'/stream/' + item.Id + '/'">View This Stream</a>
</info> </info>
</stream> </stream>
</template> </template>

View file

@ -19,10 +19,10 @@
<th x-text="header"></th> <th x-text="header"></th>
</template> </template>
</tr> </tr>
<template x-for="item in contents" :key="item.id"> <template x-for="item in contents" :key="item.Id">
<tr class="table-row"> <tr class="table-row">
<td> <td>
<a x-bind:href="'/admin/table/{{ .Table }}/' + item.id + '/'"> <a x-bind:href="'/admin/table/{{ .Table }}/' + item.Id + '/'">
# #
</a> </a>
</td> </td>

View file

@ -16,7 +16,7 @@
</middle> </middle>
<bottom> <bottom>
<button type="button"><a href="/admin/table/{{ .Table }}/">Back</a></button> <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> <button class="hover:btn-hover" type="submit">Update</button>
</bottom> </bottom>
</card> </card>

View file

@ -2,13 +2,13 @@
x-data="{item: {}}" x-data="{item: {}}"
x-init="item = await GetJson('/api/game/1')"> 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="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"> <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> <block>
<p class="m-2" x-text="item.description"></p> <p class="m-2" x-text="item.Description"></p>
<table> <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">RECENT REVIEWS:</th><td>Insanely Optimistic</td></tr>
<tr><th class="text-gray-400 text-left">ENGLISH REVIEWS:</th><td>Probably Racist</td></tr> <tr><th class="text-gray-400 text-left">ENGLISH REVIEWS:</th><td>Probably Racist</td></tr>
@ -20,8 +20,8 @@
</div> </div>
<div class="flex"> <div class="flex">
<video controls> <video controls>
<template x-if="item.video"> <template x-if="item.Video">
<source :src="item.video" type="video/mp4" /> <source :src="item.Video" type="video/mp4" />
</template> </template>
</video> </video>
</div> </div>
@ -30,7 +30,7 @@
<bar class="!p-0 *:!p-0"> <bar class="!p-0 *:!p-0">
<block> <block>
<table class="flex flex-col"> <table class="flex flex-col">
<template x-for="tag in item.tags.split(' ')"> <template x-for="tag in item.Tags.split(' ')">
<tr> <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 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> <td class="p-1" x-text="tag"></td>
@ -40,20 +40,20 @@
<block> <block>
<h4>Current Status</h4> <h4>Current Status</h4>
<p x-text="item.current_status"></p> <p x-text="item.CurrentStatus"></p>
</block> </block>
</block> </block>
<block> <block>
<block> <block>
<h4>Planned Work</h4> <h4>Planned Work</h4>
<p x-text="item.planned_work"></p> <p x-text="item.PlannedWork"></p>
</block> </block>
<block> <block>
<h4>Read The Code</h4> <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> <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>
</block> </block>
</bar> </bar>

View file

@ -5,10 +5,10 @@
<div x-init="item = await Stream.item()" x-data="{item: {}}"> <div x-init="item = await Stream.item()" x-data="{item: {}}">
<block style="--value: 7"> <block style="--value: 7">
<h1 x-text="item.title"></h1> <h1 x-text="item.Title"></h1>
<div> <div>
<p x-text="item.description"></p> <p x-text="item.Description"></p>
</div> </div>
</block> </block>
@ -17,7 +17,7 @@
<ul x-data="Links"> <ul x-data="Links">
<template x-for="item in contents"> <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> </template>
</ul> </ul>
</block> </block>