mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(wip): site category
This commit is contained in:
parent
ed3c02fc6f
commit
7ad5cac3b8
73 changed files with 713 additions and 235 deletions
0
.db
Normal file
0
.db
Normal file
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func GetAcmeUser(c *gin.Context) {
|
||||
u := query.AcmeUser
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
user, err := u.FirstByID(id)
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
|
@ -79,7 +79,7 @@ func RecoverAcmeUser(c *gin.Context) {
|
|||
}
|
||||
|
||||
func RegisterAcmeUser(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
u := query.AcmeUser
|
||||
user, err := u.FirstByID(id)
|
||||
if err != nil {
|
||||
|
|
|
@ -71,7 +71,7 @@ func GetCertList(c *gin.Context) {
|
|||
func GetCert(c *gin.Context) {
|
||||
q := query.Cert
|
||||
|
||||
certModel, err := q.FirstByID(cast.ToInt(c.Param("id")))
|
||||
certModel, err := q.FirstByID(cast.ToUint64(c.Param("id")))
|
||||
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
|
@ -89,9 +89,9 @@ type certJson struct {
|
|||
SSLCertificateKey string `json:"ssl_certificate_key" binding:"omitempty,privatekey"`
|
||||
KeyType certcrypto.KeyType `json:"key_type" binding:"omitempty,auto_cert_key_type"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DnsCredentialID int `json:"dns_credential_id"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
SyncNodeIds []int `json:"sync_node_ids"`
|
||||
DnsCredentialID uint64 `json:"dns_credential_id"`
|
||||
ACMEUserID uint64 `json:"acme_user_id"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids"`
|
||||
}
|
||||
|
||||
func AddCert(c *gin.Context) {
|
||||
|
@ -141,7 +141,7 @@ func AddCert(c *gin.Context) {
|
|||
}
|
||||
|
||||
func ModifyCert(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
var json certJson
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func GetDnsCredential(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
d := query.DnsCredential
|
||||
|
||||
|
@ -70,7 +70,7 @@ func AddDnsCredential(c *gin.Context) {
|
|||
}
|
||||
|
||||
func EditDnsCredential(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
var json DnsCredentialManageJson
|
||||
if !api.BindAndValid(c, &json) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func GetEnvironment(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
envQuery := query.Environment
|
||||
|
||||
|
@ -67,7 +67,7 @@ func EditEnvironment(c *gin.Context) {
|
|||
}
|
||||
|
||||
func DeleteEnvironment(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
envQuery := query.Environment
|
||||
|
||||
env, err := envQuery.FirstByID(id)
|
||||
|
|
|
@ -6,7 +6,7 @@ func InitRouter(r *gin.RouterGroup) {
|
|||
// Environment
|
||||
r.GET("environments", GetEnvironmentList)
|
||||
r.POST("environments/load_from_settings", LoadEnvironmentFromSettings)
|
||||
envGroup := r.Group("environment")
|
||||
envGroup := r.Group("environments")
|
||||
{
|
||||
envGroup.GET("/:id", GetEnvironment)
|
||||
envGroup.POST("", AddEnvironment)
|
||||
|
|
|
@ -21,7 +21,7 @@ func AddConfig(c *gin.Context) {
|
|||
NewFilepath string `json:"new_filepath" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
SyncNodeIds []int `json:"sync_node_ids"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids"`
|
||||
}
|
||||
|
||||
if !api.BindAndValid(c, &json) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
type APIConfigResp struct {
|
||||
config.Config
|
||||
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncOverwrite bool `json:"sync_overwrite"`
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ func EditConfig(c *gin.Context) {
|
|||
NewFilepath string `json:"new_filepath" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
SyncOverwrite bool `json:"sync_overwrite"`
|
||||
SyncNodeIds []int `json:"sync_node_ids"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids"`
|
||||
}
|
||||
if !api.BindAndValid(c, &json) {
|
||||
return
|
||||
|
|
|
@ -17,7 +17,7 @@ func Rename(c *gin.Context) {
|
|||
BasePath string `json:"base_path"`
|
||||
OrigName string `json:"orig_name"`
|
||||
NewName string `json:"new_name"`
|
||||
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
}
|
||||
if !api.BindAndValid(c, &json) {
|
||||
return
|
||||
|
|
|
@ -9,9 +9,9 @@ func InitRouter(r *gin.RouterGroup) {
|
|||
r.GET("config_base_path", GetBasePath)
|
||||
|
||||
r.GET("configs", GetConfigs)
|
||||
r.GET("config/*name", GetConfig)
|
||||
r.POST("config", AddConfig)
|
||||
r.POST("config/*name", EditConfig)
|
||||
r.GET("configs/*name", GetConfig)
|
||||
r.POST("configs", AddConfig)
|
||||
r.POST("configs/*name", EditConfig)
|
||||
|
||||
o := r.Group("", middleware.RequireSecureSession())
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
func Get(c *gin.Context) {
|
||||
n := query.Notification
|
||||
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
data, err := n.FirstByID(id)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import "github.com/gin-gonic/gin"
|
|||
|
||||
func InitRouter(r *gin.RouterGroup) {
|
||||
r.GET("notifications", GetList)
|
||||
r.GET("notification/:id", Get)
|
||||
r.DELETE("notification/:id", Destroy)
|
||||
r.GET("notifications/:id", Get)
|
||||
r.DELETE("notifications/:id", Destroy)
|
||||
r.DELETE("notifications", DestroyAll)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ func AddDomainToAutoCert(c *gin.Context) {
|
|||
name := c.Param("name")
|
||||
|
||||
var json struct {
|
||||
DnsCredentialID int `json:"dns_credential_id"`
|
||||
DnsCredentialID uint64 `json:"dns_credential_id"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
Domains []string `json:"domains"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func GetCategory(c *gin.Context) {
|
||||
|
||||
cosy.Core[model.SiteCategory](c).Get()
|
||||
}
|
||||
|
||||
func GetCategoryList(c *gin.Context) {
|
||||
|
|
|
@ -4,22 +4,22 @@ import "github.com/gin-gonic/gin"
|
|||
|
||||
func InitRouter(r *gin.RouterGroup) {
|
||||
r.GET("domains", GetSiteList)
|
||||
r.GET("domain/:name", GetSite)
|
||||
r.POST("domain/:name", SaveSite)
|
||||
r.POST("domain/:name/enable", EnableSite)
|
||||
r.POST("domain/:name/disable", DisableSite)
|
||||
r.POST("domain/:name/advance", DomainEditByAdvancedMode)
|
||||
r.DELETE("domain/:name", DeleteSite)
|
||||
r.POST("domain/:name/duplicate", DuplicateSite)
|
||||
r.GET("domains/:name", GetSite)
|
||||
r.POST("domains/:name", SaveSite)
|
||||
r.POST("domains/:name/enable", EnableSite)
|
||||
r.POST("domains/:name/disable", DisableSite)
|
||||
r.POST("domains/:name/advance", DomainEditByAdvancedMode)
|
||||
r.DELETE("domains/:name", DeleteSite)
|
||||
r.POST("domains/:name/duplicate", DuplicateSite)
|
||||
r.POST("auto_cert/:name", AddDomainToAutoCert)
|
||||
r.DELETE("auto_cert/:name", RemoveDomainFromAutoCert)
|
||||
}
|
||||
|
||||
func InitCategoryRouter(r *gin.RouterGroup) {
|
||||
r.GET("site_categories", GetCategoryList)
|
||||
r.GET("site_category/:id", GetCategory)
|
||||
r.POST("site_category", AddCategory)
|
||||
r.PUT("site_category/:id", ModifyCategory)
|
||||
r.DELETE("site_category/:id", DeleteCategory)
|
||||
r.POST("site_category/:id/recover", RecoverCategory)
|
||||
r.GET("site_categories/:id", GetCategory)
|
||||
r.POST("site_categories", AddCategory)
|
||||
r.POST("site_categories/:id", ModifyCategory)
|
||||
r.DELETE("site_categories/:id", DeleteCategory)
|
||||
r.POST("site_categories/:id/recover", RecoverCategory)
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ import "github.com/gin-gonic/gin"
|
|||
|
||||
func InitRouter(r *gin.RouterGroup) {
|
||||
r.GET("streams", GetStreams)
|
||||
r.GET("stream/:name", GetStream)
|
||||
r.POST("stream/:name", SaveStream)
|
||||
r.POST("stream/:name/enable", EnableStream)
|
||||
r.POST("stream/:name/disable", DisableStream)
|
||||
r.POST("stream/:name/advance", AdvancedEdit)
|
||||
r.DELETE("stream/:name", DeleteStream)
|
||||
r.POST("stream/:name/duplicate", Duplicate)
|
||||
r.GET("streams/:name", GetStream)
|
||||
r.POST("streams/:name", SaveStream)
|
||||
r.POST("streams/:name/enable", EnableStream)
|
||||
r.POST("streams/:name/disable", DisableStream)
|
||||
r.POST("streams/:name/advance", AdvancedEdit)
|
||||
r.DELETE("streams/:name", DeleteStream)
|
||||
r.POST("streams/:name/duplicate", Duplicate)
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package template
|
|||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func InitRouter(r *gin.RouterGroup) {
|
||||
r.GET("template", GetTemplate)
|
||||
r.GET("template/configs", GetTemplateConfList)
|
||||
r.GET("template/blocks", GetTemplateBlockList)
|
||||
r.GET("template/block/:name", GetTemplateBlock)
|
||||
r.POST("template/block/:name", GetTemplateBlock)
|
||||
r.GET("templates", GetTemplate)
|
||||
r.GET("templates/configs", GetTemplateConfList)
|
||||
r.GET("templates/blocks", GetTemplateBlockList)
|
||||
r.GET("templates/block/:name", GetTemplateBlock)
|
||||
r.POST("templates/block/:name", GetTemplateBlock)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
const passkeyTimeout = 30 * time.Second
|
||||
|
||||
func buildCachePasskeyRegKey(id int) string {
|
||||
func buildCachePasskeyRegKey(id uint64) string {
|
||||
return fmt.Sprintf("passkey-reg-%d", id)
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func FinishPasskeyLogin(c *gin.Context) {
|
|||
LastUsedAt: time.Now().Unix(),
|
||||
})
|
||||
|
||||
outUser, err = u.FirstByID(cast.ToInt(string(userHandle)))
|
||||
outUser, err = u.FirstByID(cast.ToUint64(string(userHandle)))
|
||||
return outUser, err
|
||||
}, *sessionData, c.Request)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,11 +19,11 @@ func InitAuthRouter(r *gin.RouterGroup) {
|
|||
|
||||
func InitManageUserRouter(r *gin.RouterGroup) {
|
||||
r.GET("users", GetUsers)
|
||||
r.GET("user/:id", GetUser)
|
||||
r.POST("user", AddUser)
|
||||
r.POST("user/:id", EditUser)
|
||||
r.DELETE("user/:id", DeleteUser)
|
||||
r.PATCH("user/:id", RecoverUser)
|
||||
r.GET("users/:id", GetUser)
|
||||
r.POST("users", AddUser)
|
||||
r.POST("users/:id", EditUser)
|
||||
r.DELETE("users/:id", DeleteUser)
|
||||
r.PATCH("users/:id", RecoverUser)
|
||||
}
|
||||
|
||||
func InitUserRouter(r *gin.RouterGroup) {
|
||||
|
|
|
@ -17,7 +17,7 @@ func GetUsers(c *gin.Context) {
|
|||
}
|
||||
|
||||
func GetUser(c *gin.Context) {
|
||||
id := cast.ToInt(c.Param("id"))
|
||||
id := cast.ToUint64(c.Param("id"))
|
||||
|
||||
u := query.User
|
||||
|
||||
|
@ -69,7 +69,7 @@ func AddUser(c *gin.Context) {
|
|||
}
|
||||
|
||||
func EditUser(c *gin.Context) {
|
||||
userId := cast.ToInt(c.Param("id"))
|
||||
userId := cast.ToUint64(c.Param("id"))
|
||||
|
||||
if settings.NodeSettings.Demo && userId == 1 {
|
||||
c.JSON(http.StatusNotAcceptable, gin.H{
|
||||
|
|
|
@ -11,7 +11,7 @@ export interface AcmeUser extends ModelBase {
|
|||
|
||||
class ACMEUserCurd extends Curd<AcmeUser> {
|
||||
constructor() {
|
||||
super('acme_user', 'acme_users')
|
||||
super('acme_users')
|
||||
}
|
||||
|
||||
public async register(id: number) {
|
||||
|
|
|
@ -37,6 +37,6 @@ export interface CertificateResult {
|
|||
key_type: PrivateKeyType
|
||||
}
|
||||
|
||||
const cert: Curd<Cert> = new Curd('/cert')
|
||||
const cert: Curd<Cert> = new Curd('/certs')
|
||||
|
||||
export default cert
|
||||
|
|
|
@ -14,7 +14,7 @@ export interface Config {
|
|||
|
||||
class ConfigCurd extends Curd<Config> {
|
||||
constructor() {
|
||||
super('/config')
|
||||
super('/configs')
|
||||
}
|
||||
|
||||
get_base_path() {
|
||||
|
|
|
@ -15,28 +15,31 @@ export interface Pagination {
|
|||
|
||||
export interface GetListResponse<T> {
|
||||
data: T[]
|
||||
pagination: Pagination
|
||||
pagination?: Pagination
|
||||
}
|
||||
|
||||
class Curd<T> {
|
||||
protected readonly baseUrl: string
|
||||
protected readonly plural: string
|
||||
|
||||
get_list = this._get_list.bind(this)
|
||||
get = this._get.bind(this)
|
||||
save = this._save.bind(this)
|
||||
import = this._import.bind(this)
|
||||
import_check = this._import_check.bind(this)
|
||||
destroy = this._destroy.bind(this)
|
||||
recover = this._recover.bind(this)
|
||||
update_order = this._update_order.bind(this)
|
||||
batch_save = this._batch_save.bind(this)
|
||||
batch_destroy = this._batch_destroy.bind(this)
|
||||
batch_recover = this._batch_recover.bind(this)
|
||||
|
||||
constructor(baseUrl: string, plural: string | null = null) {
|
||||
constructor(baseUrl: string) {
|
||||
this.baseUrl = baseUrl
|
||||
this.plural = plural ?? `${this.baseUrl}s`
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_get_list(params: any = null): Promise<GetListResponse<T>> {
|
||||
return http.get(this.plural, { params })
|
||||
return http.get(this.baseUrl, { params })
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
|
@ -45,10 +48,25 @@ class Curd<T> {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_save(id: any = null, data: any = undefined, config: any = undefined): Promise<T> {
|
||||
_save(id: any = null, data: any = {}, config: any = undefined): Promise<T> {
|
||||
return http.post(this.baseUrl + (id ? `/${id}` : ''), data, config)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_import_check(formData: FormData, config: any = {}): Promise<T> {
|
||||
return http.post(`${this.baseUrl}/import_check`, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data;charset=UTF-8',
|
||||
},
|
||||
...config,
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_import(data: any, config: any = {}): Promise<T> {
|
||||
return http.post(`${this.baseUrl}/import`, data, config)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_destroy(id: any = null, params: any = {}) {
|
||||
return http.delete(`${this.baseUrl}/${id}`, { params })
|
||||
|
@ -59,12 +77,34 @@ class Curd<T> {
|
|||
return http.patch(`${this.baseUrl}/${id}`)
|
||||
}
|
||||
|
||||
_update_order(data: {
|
||||
target_id: number
|
||||
direction: number
|
||||
affected_ids: number[]
|
||||
}) {
|
||||
return http.post(`${this.plural}/order`, data)
|
||||
_update_order(data: { target_id: number, direction: number, affected_ids: number[] }) {
|
||||
return http.post(`${this.baseUrl}/order`, data)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_batch_save(ids: any, data: any) {
|
||||
return http.put(this.baseUrl, {
|
||||
ids,
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
_batch_destroy(ids?: (string | number)[], params: any = {}) {
|
||||
return http.delete(this.baseUrl, {
|
||||
params,
|
||||
data: {
|
||||
ids,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
_batch_recover(ids?: (string | number)[]) {
|
||||
return http.patch(this.baseUrl, {
|
||||
data: {
|
||||
ids,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,6 @@ export interface DnsCredential extends ModelBase {
|
|||
}
|
||||
}
|
||||
|
||||
const dns_credential: Curd<DnsCredential> = new Curd('/dns_credential')
|
||||
const dns_credential: Curd<DnsCredential> = new Curd('/dns_credentials')
|
||||
|
||||
export default dns_credential
|
||||
|
|
|
@ -56,6 +56,6 @@ class Domain extends Curd<Site> {
|
|||
}
|
||||
}
|
||||
|
||||
const domain = new Domain('/domain')
|
||||
const domain = new Domain('/domains')
|
||||
|
||||
export default domain
|
||||
|
|
|
@ -18,11 +18,11 @@ export interface Node {
|
|||
|
||||
class EnvironmentCurd extends Curd<Environment> {
|
||||
constructor() {
|
||||
super('/environment')
|
||||
super('/environments')
|
||||
}
|
||||
|
||||
load_from_settings() {
|
||||
return http.post(`${this.plural}/load_from_settings`)
|
||||
return http.post(`${this.baseUrl}/load_from_settings`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ export interface Notification extends ModelBase {
|
|||
|
||||
class NotificationCurd extends Curd<Notification> {
|
||||
public clear() {
|
||||
return http.delete(this.plural)
|
||||
return http.delete(this.baseUrl)
|
||||
}
|
||||
}
|
||||
|
||||
const notification = new NotificationCurd('/notification')
|
||||
const notification = new NotificationCurd('/notifications')
|
||||
|
||||
export default notification
|
||||
|
|
11
app/src/api/site_category.ts
Normal file
11
app/src/api/site_category.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import type { ModelBase } from '@/api/curd'
|
||||
import Curd from '@/api/curd'
|
||||
|
||||
export interface SiteCategory extends ModelBase {
|
||||
name: string
|
||||
sync_node_ids: number[]
|
||||
}
|
||||
|
||||
const site_category = new Curd<SiteCategory>('site_categories')
|
||||
|
||||
export default site_category
|
|
@ -33,6 +33,6 @@ class StreamCurd extends Curd<Stream> {
|
|||
}
|
||||
}
|
||||
|
||||
const stream = new StreamCurd('/stream')
|
||||
const stream = new StreamCurd('/streams')
|
||||
|
||||
export default stream
|
||||
|
|
|
@ -23,26 +23,26 @@ export interface Template extends NgxServer {
|
|||
|
||||
class TemplateApi extends Curd<Template> {
|
||||
get_config_list() {
|
||||
return http.get('template/configs')
|
||||
return http.get('templates/configs')
|
||||
}
|
||||
|
||||
get_block_list() {
|
||||
return http.get('template/blocks')
|
||||
return http.get('templates/blocks')
|
||||
}
|
||||
|
||||
get_config(name: string) {
|
||||
return http.get(`template/config/${name}`)
|
||||
return http.get(`templates/config/${name}`)
|
||||
}
|
||||
|
||||
get_block(name: string) {
|
||||
return http.get(`template/block/${name}`)
|
||||
return http.get(`templates/block/${name}`)
|
||||
}
|
||||
|
||||
build_block(name: string, data: Variable) {
|
||||
return http.post(`template/block/${name}`, data)
|
||||
return http.post(`templates/block/${name}`, data)
|
||||
}
|
||||
}
|
||||
|
||||
const template = new TemplateApi('/template')
|
||||
const template = new TemplateApi('/templates')
|
||||
|
||||
export default template
|
||||
|
|
|
@ -6,6 +6,6 @@ export interface User extends ModelBase {
|
|||
password: string
|
||||
}
|
||||
|
||||
const user: Curd<User> = new Curd('user')
|
||||
const user: Curd<User> = new Curd('users')
|
||||
|
||||
export default user
|
||||
|
|
|
@ -22,7 +22,7 @@ onMounted(async () => {
|
|||
r.data?.forEach(node => {
|
||||
data_map.value[node.id] = node
|
||||
})
|
||||
hasMore = r.data.length === r.pagination.per_page
|
||||
hasMore = r.data.length === r.pagination?.per_page
|
||||
page++
|
||||
}).catch(() => {
|
||||
hasMore = false
|
||||
|
@ -35,7 +35,6 @@ const value = computed({
|
|||
return target.value
|
||||
},
|
||||
set(v: number[]) {
|
||||
console.log(v)
|
||||
if (typeof map.value === 'object') {
|
||||
const _map = {}
|
||||
|
||||
|
@ -70,7 +69,7 @@ const noData = computed(() => {
|
|||
<ACheckbox :value="0">
|
||||
{{ $gettext('Local') }}
|
||||
</ACheckbox>
|
||||
<ATag color="blue">
|
||||
<ATag color="green">
|
||||
{{ $gettext('Online') }}
|
||||
</ATag>
|
||||
</ACol>
|
||||
|
@ -83,7 +82,7 @@ const noData = computed(() => {
|
|||
</ACheckbox>
|
||||
<ATag
|
||||
v-if="node.status"
|
||||
color="blue"
|
||||
color="green"
|
||||
>
|
||||
{{ $gettext('Online') }}
|
||||
</ATag>
|
||||
|
|
|
@ -18,7 +18,7 @@ function init() {
|
|||
loading.value = true
|
||||
notification.get_list().then(r => {
|
||||
data.value = r.data
|
||||
unreadCount.value = r.pagination.total
|
||||
unreadCount.value = r.pagination?.total || 0
|
||||
}).catch(e => {
|
||||
message.error($gettext(e?.message ?? 'Server error'))
|
||||
}).finally(() => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { GetListResponse } from '@/api/curd'
|
||||
import type { StdTableProps } from '@/components/StdDesign/StdDataDisplay/StdTable.vue'
|
||||
import type { Column, StdTableResponse } from '@/components/StdDesign/types'
|
||||
import type { Column } from '@/components/StdDesign/types'
|
||||
import type { ComputedRef } from 'vue'
|
||||
import { downloadCsv } from '@/lib/helper'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
@ -33,7 +34,8 @@ async function exportCsv(props: StdTableProps, pithyColumns: ComputedRef<Column[
|
|||
while (hasMore) {
|
||||
// 准备 DataSource
|
||||
await props
|
||||
.api!.get_list({ page }).then((r: StdTableResponse) => {
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
.api!.get_list({ page }).then((r: GetListResponse<any>) => {
|
||||
if (r.data.length === 0) {
|
||||
hasMore = false
|
||||
|
||||
|
|
6
app/src/components/StdDesign/types.d.ts
vendored
6
app/src/components/StdDesign/types.d.ts
vendored
|
@ -1,4 +1,3 @@
|
|||
import type { Pagination } from '@/api/curd'
|
||||
import type Curd from '@/api/curd'
|
||||
import type { TableColumnType } from 'ant-design-vue'
|
||||
import type { Ref } from 'vue'
|
||||
|
@ -104,8 +103,3 @@ export interface Column extends TableColumnType {
|
|||
dataSourceValueIndex?: any // relative to dataSource
|
||||
}
|
||||
}
|
||||
|
||||
export interface StdTableResponse {
|
||||
data: any[]
|
||||
pagination: Pagination
|
||||
}
|
||||
|
|
|
@ -64,6 +64,13 @@ export const routes: RouteRecordRaw[] = [
|
|||
name: () => $gettext('Add Site'),
|
||||
lastRouteName: 'Sites List',
|
||||
},
|
||||
}, {
|
||||
path: 'categories',
|
||||
name: 'Site Categories',
|
||||
component: () => import('@/views/site/site_category/SiteCategory.vue'),
|
||||
meta: {
|
||||
name: () => $gettext('Site Categories'),
|
||||
},
|
||||
}, {
|
||||
path: ':name',
|
||||
name: 'Edit Site',
|
||||
|
|
|
@ -47,7 +47,7 @@ onMounted(async () => {
|
|||
const r = await acme_user.get_list({ page })
|
||||
|
||||
users.value.push(...r.data)
|
||||
if (r?.data?.length < r?.pagination?.per_page)
|
||||
if (r?.data?.length < (r?.pagination?.per_page ?? 0))
|
||||
break
|
||||
page++
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ onMounted(async () => {
|
|||
while (hasMore) {
|
||||
await environment.get_list({ page, enabled: true }).then(r => {
|
||||
data.value.push(...r.data)
|
||||
hasMore = r.data.length === r.pagination.per_page
|
||||
hasMore = r.data.length === r.pagination?.per_page
|
||||
page++
|
||||
}).catch(() => {
|
||||
hasMore = false
|
||||
|
|
28
app/src/views/site/site_category/SiteCategory.vue
Normal file
28
app/src/views/site/site_category/SiteCategory.vue
Normal file
|
@ -0,0 +1,28 @@
|
|||
<script setup lang="ts">
|
||||
import site_category from '@/api/site_category'
|
||||
import NodeSelector from '@/components/NodeSelector/NodeSelector.vue'
|
||||
import { StdCurd } from '@/components/StdDesign/StdDataDisplay'
|
||||
import columns from '@/views/site/site_category/columns'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<StdCurd
|
||||
:title="$gettext('Site Categories')"
|
||||
:api="site_category"
|
||||
:columns="columns"
|
||||
>
|
||||
<template #edit="{ data }">
|
||||
<div class="mb-2">
|
||||
{{ $gettext('Sync Nodes') }}
|
||||
</div>
|
||||
<NodeSelector
|
||||
v-model:target="data.sync_node_ids"
|
||||
hidden-local
|
||||
/>
|
||||
</template>
|
||||
</StdCurd>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
</style>
|
30
app/src/views/site/site_category/columns.ts
Normal file
30
app/src/views/site/site_category/columns.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import type { Column } from '@/components/StdDesign/types'
|
||||
import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
|
||||
import { input } from '@/components/StdDesign/StdDataEntry'
|
||||
|
||||
const columns: Column[] = [{
|
||||
dataIndex: 'name',
|
||||
title: () => $gettext('Name'),
|
||||
search: true,
|
||||
edit: {
|
||||
type: input,
|
||||
},
|
||||
pithy: true,
|
||||
}, {
|
||||
title: () => $gettext('Created at'),
|
||||
dataIndex: 'created_at',
|
||||
customRender: datetime,
|
||||
sorter: true,
|
||||
pithy: true,
|
||||
}, {
|
||||
title: () => $gettext('Updated at'),
|
||||
dataIndex: 'updated_at',
|
||||
customRender: datetime,
|
||||
sorter: true,
|
||||
pithy: true,
|
||||
}, {
|
||||
title: () => $gettext('Action'),
|
||||
dataIndex: 'action',
|
||||
}]
|
||||
|
||||
export default columns
|
2
go.sum
2
go.sum
|
@ -812,8 +812,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/ristretto v0.2.0 h1:XAfl+7cmoUDWW/2Lx8TGZQjjxIQ2Ley9DSf52dru4WE=
|
||||
github.com/dgraph-io/ristretto v0.2.0/go.mod h1:8uBHCU/PBV4Ag0CJrP47b9Ofby5dqWNh4FicAdoqFNU=
|
||||
github.com/dgraph-io/ristretto/v2 v2.0.0-alpha h1:JBy5Mm/z1HBj3hyDLFBS2uHalL971q3yjUaKcia0Sgo=
|
||||
github.com/dgraph-io/ristretto/v2 v2.0.0-alpha/go.mod h1:7bFGBdXzLfFFjKCN8YDQ7+98m/AEYcrdqH7s0En96Qg=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
|
|
|
@ -42,7 +42,7 @@ type Node struct {
|
|||
|
||||
var mutex sync.Mutex
|
||||
|
||||
type TNodeMap map[int]*Node
|
||||
type TNodeMap map[uint64]*Node
|
||||
|
||||
var NodeMap TNodeMap
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import (
|
|||
)
|
||||
|
||||
type ConfigPayload struct {
|
||||
CertID int `json:"cert_id"`
|
||||
CertID uint64 `json:"cert_id"`
|
||||
ServerName []string `json:"server_name"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DNSCredentialID int `json:"dns_credential_id"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
DNSCredentialID uint64 `json:"dns_credential_id"`
|
||||
ACMEUserID uint64 `json:"acme_user_id"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
Resource *model.CertificateResource `json:"resource,omitempty"`
|
||||
MustStaple bool `json:"must_staple"`
|
||||
|
|
|
@ -80,7 +80,7 @@ func SyncToRemoteServer(c *model.Config, newFilepath string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func SyncRenameOnRemoteServer(origPath, newPath string, syncNodeIds []int) (err error) {
|
||||
func SyncRenameOnRemoteServer(origPath, newPath string, syncNodeIds []uint64) (err error) {
|
||||
if origPath == "" || newPath == "" || len(syncNodeIds) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func Proxy() gin.HandlerFunc {
|
|||
c.Next()
|
||||
return
|
||||
}
|
||||
id := cast.ToInt(nodeID)
|
||||
id := cast.ToUint64(nodeID)
|
||||
if id == 0 {
|
||||
c.Next()
|
||||
return
|
||||
|
|
|
@ -16,7 +16,7 @@ func ProxyWs() gin.HandlerFunc {
|
|||
c.Next()
|
||||
return
|
||||
}
|
||||
id := cast.ToInt(nodeID)
|
||||
id := cast.ToUint64(nodeID)
|
||||
if id == 0 {
|
||||
c.Next()
|
||||
return
|
||||
|
|
|
@ -46,16 +46,16 @@ func secureSessionIDCacheKey(sessionId string) string {
|
|||
return fmt.Sprintf("2fa_secure_session:_%s", sessionId)
|
||||
}
|
||||
|
||||
func SetSecureSessionID(userId int) (sessionId string) {
|
||||
func SetSecureSessionID(userId uint64) (sessionId string) {
|
||||
sessionId = uuid.NewString()
|
||||
cache.Set(secureSessionIDCacheKey(sessionId), userId, 5*time.Minute)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func VerifySecureSessionID(sessionId string, userId int) bool {
|
||||
func VerifySecureSessionID(sessionId string, userId uint64) bool {
|
||||
if v, ok := cache.Get(secureSessionIDCacheKey(sessionId)); ok {
|
||||
if v.(int) == userId {
|
||||
if v.(uint64) == userId {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const ExpiredTime = 24 * time.Hour
|
|||
|
||||
type JWTClaims struct {
|
||||
Name string `json:"name"`
|
||||
UserID int `json:"user_id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ type Cert struct {
|
|||
SSLCertificateKeyPath string `json:"ssl_certificate_key_path"`
|
||||
AutoCert int `json:"auto_cert"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DnsCredentialID int `json:"dns_credential_id"`
|
||||
DnsCredentialID uint64 `json:"dns_credential_id"`
|
||||
DnsCredential *DnsCredential `json:"dns_credential,omitempty"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
ACMEUserID uint64 `json:"acme_user_id"`
|
||||
ACMEUser *AcmeUser `json:"acme_user,omitempty"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
Log string `json:"log"`
|
||||
Resource *CertificateResource `json:"-" gorm:"serializer:json"`
|
||||
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
MustStaple bool `json:"must_staple"`
|
||||
LegoDisableCNAMESupport bool `json:"lego_disable_cname_support"`
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ type Config struct {
|
|||
Model
|
||||
Name string `json:"name"`
|
||||
Filepath string `json:"filepath"`
|
||||
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
|
||||
SyncOverwrite bool `json:"sync_overwrite"`
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ type Environment struct {
|
|||
URL string `json:"url"`
|
||||
Token string `json:"token"`
|
||||
Enabled bool `json:"enabled" gorm:"default:true"`
|
||||
OperationSync bool `json:"operation_sync"`
|
||||
SyncApiRegex string `json:"sync_api_regex"`
|
||||
}
|
||||
|
||||
func (e *Environment) GetUrl(uri string) (decodedUri string, err error) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
var db *gorm.DB
|
||||
|
||||
type Model struct {
|
||||
ID int `gorm:"primary_key" json:"id"`
|
||||
ID uint64 `gorm:"primary_key" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt *gorm.DeletedAt `gorm:"index" json:"deleted_at"`
|
||||
|
@ -57,7 +57,7 @@ type DataList struct {
|
|||
|
||||
type Method interface {
|
||||
// FirstByID Where("id=@id")
|
||||
FirstByID(id int) (*gen.T, error)
|
||||
FirstByID(id uint64) (*gen.T, error)
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
DeleteByID(id int) error
|
||||
DeleteByID(id uint64) error
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ type Passkey struct {
|
|||
Model
|
||||
|
||||
Name string `json:"name"`
|
||||
UserID int `json:"user_id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
RawID string `json:"raw_id"`
|
||||
Credential *webauthn.Credential `json:"-" gorm:"serializer:json"`
|
||||
LastUsedAt int64 `json:"last_used_at" gorm:"default:0"`
|
||||
|
|
|
@ -17,7 +17,7 @@ type User struct {
|
|||
}
|
||||
|
||||
type AuthToken struct {
|
||||
UserID int `json:"user_id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
Token string `json:"token"`
|
||||
ExpiredAt int64 `json:"expired_at" gorm:"default:0"`
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func newAcmeUser(db *gorm.DB, opts ...gen.DOOption) acmeUser {
|
|||
|
||||
tableName := _acmeUser.acmeUserDo.TableName()
|
||||
_acmeUser.ALL = field.NewAsterisk(tableName)
|
||||
_acmeUser.ID = field.NewInt(tableName, "id")
|
||||
_acmeUser.ID = field.NewUint64(tableName, "id")
|
||||
_acmeUser.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_acmeUser.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_acmeUser.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -49,7 +49,7 @@ type acmeUser struct {
|
|||
acmeUserDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -76,7 +76,7 @@ func (a acmeUser) As(alias string) *acmeUser {
|
|||
|
||||
func (a *acmeUser) updateTableName(table string) *acmeUser {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt(table, "id")
|
||||
a.ID = field.NewUint64(table, "id")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -130,7 +130,7 @@ func (a acmeUser) replaceDB(db *gorm.DB) acmeUser {
|
|||
type acmeUserDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (a acmeUserDo) FirstByID(id int) (result *model.AcmeUser, err error) {
|
||||
func (a acmeUserDo) FirstByID(id uint64) (result *model.AcmeUser, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -145,7 +145,7 @@ func (a acmeUserDo) FirstByID(id int) (result *model.AcmeUser, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (a acmeUserDo) DeleteByID(id int) (err error) {
|
||||
func (a acmeUserDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newAuthToken(db *gorm.DB, opts ...gen.DOOption) authToken {
|
|||
|
||||
tableName := _authToken.authTokenDo.TableName()
|
||||
_authToken.ALL = field.NewAsterisk(tableName)
|
||||
_authToken.UserID = field.NewInt(tableName, "user_id")
|
||||
_authToken.UserID = field.NewUint64(tableName, "user_id")
|
||||
_authToken.Token = field.NewString(tableName, "token")
|
||||
_authToken.ExpiredAt = field.NewInt64(tableName, "expired_at")
|
||||
|
||||
|
@ -41,7 +41,7 @@ type authToken struct {
|
|||
authTokenDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserID field.Int
|
||||
UserID field.Uint64
|
||||
Token field.String
|
||||
ExpiredAt field.Int64
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (a authToken) As(alias string) *authToken {
|
|||
|
||||
func (a *authToken) updateTableName(table string) *authToken {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.UserID = field.NewInt(table, "user_id")
|
||||
a.UserID = field.NewUint64(table, "user_id")
|
||||
a.Token = field.NewString(table, "token")
|
||||
a.ExpiredAt = field.NewInt64(table, "expired_at")
|
||||
|
||||
|
@ -98,7 +98,7 @@ func (a authToken) replaceDB(db *gorm.DB) authToken {
|
|||
type authTokenDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (a authTokenDo) FirstByID(id int) (result *model.AuthToken, err error) {
|
||||
func (a authTokenDo) FirstByID(id uint64) (result *model.AuthToken, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -113,7 +113,7 @@ func (a authTokenDo) FirstByID(id int) (result *model.AuthToken, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (a authTokenDo) DeleteByID(id int) (err error) {
|
||||
func (a authTokenDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
|
||||
tableName := _user.userDo.TableName()
|
||||
_user.ALL = field.NewAsterisk(tableName)
|
||||
_user.ID = field.NewInt(tableName, "id")
|
||||
_user.ID = field.NewUint64(tableName, "id")
|
||||
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_user.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -46,7 +46,7 @@ type user struct {
|
|||
userDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -70,7 +70,7 @@ func (u user) As(alias string) *user {
|
|||
|
||||
func (u *user) updateTableName(table string) *user {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt(table, "id")
|
||||
u.ID = field.NewUint64(table, "id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -118,7 +118,7 @@ func (u user) replaceDB(db *gorm.DB) user {
|
|||
type userDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (u userDo) FirstByID(id int) (result *model.User, err error) {
|
||||
func (u userDo) FirstByID(id uint64) (result *model.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -133,7 +133,7 @@ func (u userDo) FirstByID(id int) (result *model.User, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (u userDo) DeleteByID(id int) (err error) {
|
||||
func (u userDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -98,7 +98,7 @@ func (b banIP) replaceDB(db *gorm.DB) banIP {
|
|||
type banIPDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (b banIPDo) FirstByID(id int) (result *model.BanIP, err error) {
|
||||
func (b banIPDo) FirstByID(id uint64) (result *model.BanIP, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -113,7 +113,7 @@ func (b banIPDo) FirstByID(id int) (result *model.BanIP, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (b banIPDo) DeleteByID(id int) (err error) {
|
||||
func (b banIPDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newCert(db *gorm.DB, opts ...gen.DOOption) cert {
|
|||
|
||||
tableName := _cert.certDo.TableName()
|
||||
_cert.ALL = field.NewAsterisk(tableName)
|
||||
_cert.ID = field.NewInt(tableName, "id")
|
||||
_cert.ID = field.NewUint64(tableName, "id")
|
||||
_cert.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_cert.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_cert.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -39,8 +39,8 @@ func newCert(db *gorm.DB, opts ...gen.DOOption) cert {
|
|||
_cert.SSLCertificateKeyPath = field.NewString(tableName, "ssl_certificate_key_path")
|
||||
_cert.AutoCert = field.NewInt(tableName, "auto_cert")
|
||||
_cert.ChallengeMethod = field.NewString(tableName, "challenge_method")
|
||||
_cert.DnsCredentialID = field.NewInt(tableName, "dns_credential_id")
|
||||
_cert.ACMEUserID = field.NewInt(tableName, "acme_user_id")
|
||||
_cert.DnsCredentialID = field.NewUint64(tableName, "dns_credential_id")
|
||||
_cert.ACMEUserID = field.NewUint64(tableName, "acme_user_id")
|
||||
_cert.KeyType = field.NewString(tableName, "key_type")
|
||||
_cert.Log = field.NewString(tableName, "log")
|
||||
_cert.Resource = field.NewField(tableName, "resource")
|
||||
|
@ -68,7 +68,7 @@ type cert struct {
|
|||
certDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -79,8 +79,8 @@ type cert struct {
|
|||
SSLCertificateKeyPath field.String
|
||||
AutoCert field.Int
|
||||
ChallengeMethod field.String
|
||||
DnsCredentialID field.Int
|
||||
ACMEUserID field.Int
|
||||
DnsCredentialID field.Uint64
|
||||
ACMEUserID field.Uint64
|
||||
KeyType field.String
|
||||
Log field.String
|
||||
Resource field.Field
|
||||
|
@ -106,7 +106,7 @@ func (c cert) As(alias string) *cert {
|
|||
|
||||
func (c *cert) updateTableName(table string) *cert {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -117,8 +117,8 @@ func (c *cert) updateTableName(table string) *cert {
|
|||
c.SSLCertificateKeyPath = field.NewString(table, "ssl_certificate_key_path")
|
||||
c.AutoCert = field.NewInt(table, "auto_cert")
|
||||
c.ChallengeMethod = field.NewString(table, "challenge_method")
|
||||
c.DnsCredentialID = field.NewInt(table, "dns_credential_id")
|
||||
c.ACMEUserID = field.NewInt(table, "acme_user_id")
|
||||
c.DnsCredentialID = field.NewUint64(table, "dns_credential_id")
|
||||
c.ACMEUserID = field.NewUint64(table, "acme_user_id")
|
||||
c.KeyType = field.NewString(table, "key_type")
|
||||
c.Log = field.NewString(table, "log")
|
||||
c.Resource = field.NewField(table, "resource")
|
||||
|
@ -319,7 +319,7 @@ func (a certBelongsToACMEUserTx) Count() int64 {
|
|||
type certDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c certDo) FirstByID(id int) (result *model.Cert, err error) {
|
||||
func (c certDo) FirstByID(id uint64) (result *model.Cert, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -334,7 +334,7 @@ func (c certDo) FirstByID(id int) (result *model.Cert, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c certDo) DeleteByID(id int) (err error) {
|
||||
func (c certDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -94,7 +94,7 @@ func (c chatGPTLog) replaceDB(db *gorm.DB) chatGPTLog {
|
|||
type chatGPTLogDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c chatGPTLogDo) FirstByID(id int) (result *model.ChatGPTLog, err error) {
|
||||
func (c chatGPTLogDo) FirstByID(id uint64) (result *model.ChatGPTLog, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -109,7 +109,7 @@ func (c chatGPTLogDo) FirstByID(id int) (result *model.ChatGPTLog, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c chatGPTLogDo) DeleteByID(id int) (err error) {
|
||||
func (c chatGPTLogDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newConfigBackup(db *gorm.DB, opts ...gen.DOOption) configBackup {
|
|||
|
||||
tableName := _configBackup.configBackupDo.TableName()
|
||||
_configBackup.ALL = field.NewAsterisk(tableName)
|
||||
_configBackup.ID = field.NewInt(tableName, "id")
|
||||
_configBackup.ID = field.NewUint64(tableName, "id")
|
||||
_configBackup.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_configBackup.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_configBackup.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type configBackup struct {
|
|||
configBackupDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (c configBackup) As(alias string) *configBackup {
|
|||
|
||||
func (c *configBackup) updateTableName(table string) *configBackup {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (c configBackup) replaceDB(db *gorm.DB) configBackup {
|
|||
type configBackupDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c configBackupDo) FirstByID(id int) (result *model.ConfigBackup, err error) {
|
||||
func (c configBackupDo) FirstByID(id uint64) (result *model.ConfigBackup, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (c configBackupDo) FirstByID(id int) (result *model.ConfigBackup, err error
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c configBackupDo) DeleteByID(id int) (err error) {
|
||||
func (c configBackupDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newConfig(db *gorm.DB, opts ...gen.DOOption) config {
|
|||
|
||||
tableName := _config.configDo.TableName()
|
||||
_config.ALL = field.NewAsterisk(tableName)
|
||||
_config.ID = field.NewInt(tableName, "id")
|
||||
_config.ID = field.NewUint64(tableName, "id")
|
||||
_config.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_config.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_config.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -46,7 +46,7 @@ type config struct {
|
|||
configDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -70,7 +70,7 @@ func (c config) As(alias string) *config {
|
|||
|
||||
func (c *config) updateTableName(table string) *config {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -118,7 +118,7 @@ func (c config) replaceDB(db *gorm.DB) config {
|
|||
type configDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c configDo) FirstByID(id int) (result *model.Config, err error) {
|
||||
func (c configDo) FirstByID(id uint64) (result *model.Config, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -133,7 +133,7 @@ func (c configDo) FirstByID(id int) (result *model.Config, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c configDo) DeleteByID(id int) (err error) {
|
||||
func (c configDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newDnsCredential(db *gorm.DB, opts ...gen.DOOption) dnsCredential {
|
|||
|
||||
tableName := _dnsCredential.dnsCredentialDo.TableName()
|
||||
_dnsCredential.ALL = field.NewAsterisk(tableName)
|
||||
_dnsCredential.ID = field.NewInt(tableName, "id")
|
||||
_dnsCredential.ID = field.NewUint64(tableName, "id")
|
||||
_dnsCredential.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_dnsCredential.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_dnsCredential.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type dnsCredential struct {
|
|||
dnsCredentialDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (d dnsCredential) As(alias string) *dnsCredential {
|
|||
|
||||
func (d *dnsCredential) updateTableName(table string) *dnsCredential {
|
||||
d.ALL = field.NewAsterisk(table)
|
||||
d.ID = field.NewInt(table, "id")
|
||||
d.ID = field.NewUint64(table, "id")
|
||||
d.CreatedAt = field.NewTime(table, "created_at")
|
||||
d.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
d.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (d dnsCredential) replaceDB(db *gorm.DB) dnsCredential {
|
|||
type dnsCredentialDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (d dnsCredentialDo) FirstByID(id int) (result *model.DnsCredential, err error) {
|
||||
func (d dnsCredentialDo) FirstByID(id uint64) (result *model.DnsCredential, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (d dnsCredentialDo) FirstByID(id int) (result *model.DnsCredential, err err
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (d dnsCredentialDo) DeleteByID(id int) (err error) {
|
||||
func (d dnsCredentialDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment {
|
|||
|
||||
tableName := _environment.environmentDo.TableName()
|
||||
_environment.ALL = field.NewAsterisk(tableName)
|
||||
_environment.ID = field.NewInt(tableName, "id")
|
||||
_environment.ID = field.NewUint64(tableName, "id")
|
||||
_environment.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_environment.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_environment.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -36,8 +36,6 @@ func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment {
|
|||
_environment.URL = field.NewString(tableName, "url")
|
||||
_environment.Token = field.NewString(tableName, "token")
|
||||
_environment.Enabled = field.NewBool(tableName, "enabled")
|
||||
_environment.OperationSync = field.NewBool(tableName, "operation_sync")
|
||||
_environment.SyncApiRegex = field.NewString(tableName, "sync_api_regex")
|
||||
|
||||
_environment.fillFieldMap()
|
||||
|
||||
|
@ -48,7 +46,7 @@ type environment struct {
|
|||
environmentDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -56,8 +54,6 @@ type environment struct {
|
|||
URL field.String
|
||||
Token field.String
|
||||
Enabled field.Bool
|
||||
OperationSync field.Bool
|
||||
SyncApiRegex field.String
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
@ -74,7 +70,7 @@ func (e environment) As(alias string) *environment {
|
|||
|
||||
func (e *environment) updateTableName(table string) *environment {
|
||||
e.ALL = field.NewAsterisk(table)
|
||||
e.ID = field.NewInt(table, "id")
|
||||
e.ID = field.NewUint64(table, "id")
|
||||
e.CreatedAt = field.NewTime(table, "created_at")
|
||||
e.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
e.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -82,8 +78,6 @@ func (e *environment) updateTableName(table string) *environment {
|
|||
e.URL = field.NewString(table, "url")
|
||||
e.Token = field.NewString(table, "token")
|
||||
e.Enabled = field.NewBool(table, "enabled")
|
||||
e.OperationSync = field.NewBool(table, "operation_sync")
|
||||
e.SyncApiRegex = field.NewString(table, "sync_api_regex")
|
||||
|
||||
e.fillFieldMap()
|
||||
|
||||
|
@ -100,7 +94,7 @@ func (e *environment) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||
}
|
||||
|
||||
func (e *environment) fillFieldMap() {
|
||||
e.fieldMap = make(map[string]field.Expr, 10)
|
||||
e.fieldMap = make(map[string]field.Expr, 8)
|
||||
e.fieldMap["id"] = e.ID
|
||||
e.fieldMap["created_at"] = e.CreatedAt
|
||||
e.fieldMap["updated_at"] = e.UpdatedAt
|
||||
|
@ -109,8 +103,6 @@ func (e *environment) fillFieldMap() {
|
|||
e.fieldMap["url"] = e.URL
|
||||
e.fieldMap["token"] = e.Token
|
||||
e.fieldMap["enabled"] = e.Enabled
|
||||
e.fieldMap["operation_sync"] = e.OperationSync
|
||||
e.fieldMap["sync_api_regex"] = e.SyncApiRegex
|
||||
}
|
||||
|
||||
func (e environment) clone(db *gorm.DB) environment {
|
||||
|
@ -126,7 +118,7 @@ func (e environment) replaceDB(db *gorm.DB) environment {
|
|||
type environmentDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (e environmentDo) FirstByID(id int) (result *model.Environment, err error) {
|
||||
func (e environmentDo) FirstByID(id uint64) (result *model.Environment, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -141,7 +133,7 @@ func (e environmentDo) FirstByID(id int) (result *model.Environment, err error)
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (e environmentDo) DeleteByID(id int) (err error) {
|
||||
func (e environmentDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -29,6 +29,7 @@ var (
|
|||
Notification *notification
|
||||
Passkey *passkey
|
||||
Site *site
|
||||
SiteCategory *siteCategory
|
||||
Stream *stream
|
||||
User *user
|
||||
)
|
||||
|
@ -47,6 +48,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
|||
Notification = &Q.Notification
|
||||
Passkey = &Q.Passkey
|
||||
Site = &Q.Site
|
||||
SiteCategory = &Q.SiteCategory
|
||||
Stream = &Q.Stream
|
||||
User = &Q.User
|
||||
}
|
||||
|
@ -66,6 +68,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
|||
Notification: newNotification(db, opts...),
|
||||
Passkey: newPasskey(db, opts...),
|
||||
Site: newSite(db, opts...),
|
||||
SiteCategory: newSiteCategory(db, opts...),
|
||||
Stream: newStream(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
}
|
||||
|
@ -86,6 +89,7 @@ type Query struct {
|
|||
Notification notification
|
||||
Passkey passkey
|
||||
Site site
|
||||
SiteCategory siteCategory
|
||||
Stream stream
|
||||
User user
|
||||
}
|
||||
|
@ -107,6 +111,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
|||
Notification: q.Notification.clone(db),
|
||||
Passkey: q.Passkey.clone(db),
|
||||
Site: q.Site.clone(db),
|
||||
SiteCategory: q.SiteCategory.clone(db),
|
||||
Stream: q.Stream.clone(db),
|
||||
User: q.User.clone(db),
|
||||
}
|
||||
|
@ -135,6 +140,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
|||
Notification: q.Notification.replaceDB(db),
|
||||
Passkey: q.Passkey.replaceDB(db),
|
||||
Site: q.Site.replaceDB(db),
|
||||
SiteCategory: q.SiteCategory.replaceDB(db),
|
||||
Stream: q.Stream.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
}
|
||||
|
@ -153,6 +159,7 @@ type queryCtx struct {
|
|||
Notification *notificationDo
|
||||
Passkey *passkeyDo
|
||||
Site *siteDo
|
||||
SiteCategory *siteCategoryDo
|
||||
Stream *streamDo
|
||||
User *userDo
|
||||
}
|
||||
|
@ -171,6 +178,7 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
|||
Notification: q.Notification.WithContext(ctx),
|
||||
Passkey: q.Passkey.WithContext(ctx),
|
||||
Site: q.Site.WithContext(ctx),
|
||||
SiteCategory: q.SiteCategory.WithContext(ctx),
|
||||
Stream: q.Stream.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
|
||||
tableName := _notification.notificationDo.TableName()
|
||||
_notification.ALL = field.NewAsterisk(tableName)
|
||||
_notification.ID = field.NewInt(tableName, "id")
|
||||
_notification.ID = field.NewUint64(tableName, "id")
|
||||
_notification.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_notification.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_notification.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type notification struct {
|
|||
notificationDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (n notification) As(alias string) *notification {
|
|||
|
||||
func (n *notification) updateTableName(table string) *notification {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewInt(table, "id")
|
||||
n.ID = field.NewUint64(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
n.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (n notification) replaceDB(db *gorm.DB) notification {
|
|||
type notificationDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (n notificationDo) FirstByID(id int) (result *model.Notification, err error) {
|
||||
func (n notificationDo) FirstByID(id uint64) (result *model.Notification, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (n notificationDo) FirstByID(id int) (result *model.Notification, err error
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (n notificationDo) DeleteByID(id int) (err error) {
|
||||
func (n notificationDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,12 +28,12 @@ func newPasskey(db *gorm.DB, opts ...gen.DOOption) passkey {
|
|||
|
||||
tableName := _passkey.passkeyDo.TableName()
|
||||
_passkey.ALL = field.NewAsterisk(tableName)
|
||||
_passkey.ID = field.NewInt(tableName, "id")
|
||||
_passkey.ID = field.NewUint64(tableName, "id")
|
||||
_passkey.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_passkey.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_passkey.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_passkey.Name = field.NewString(tableName, "name")
|
||||
_passkey.UserID = field.NewInt(tableName, "user_id")
|
||||
_passkey.UserID = field.NewUint64(tableName, "user_id")
|
||||
_passkey.RawID = field.NewString(tableName, "raw_id")
|
||||
_passkey.Credential = field.NewField(tableName, "credential")
|
||||
_passkey.LastUsedAt = field.NewInt64(tableName, "last_used_at")
|
||||
|
@ -47,12 +47,12 @@ type passkey struct {
|
|||
passkeyDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
UserID field.Int
|
||||
UserID field.Uint64
|
||||
RawID field.String
|
||||
Credential field.Field
|
||||
LastUsedAt field.Int64
|
||||
|
@ -72,12 +72,12 @@ func (p passkey) As(alias string) *passkey {
|
|||
|
||||
func (p *passkey) updateTableName(table string) *passkey {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt(table, "id")
|
||||
p.ID = field.NewUint64(table, "id")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.DeletedAt = field.NewField(table, "deleted_at")
|
||||
p.Name = field.NewString(table, "name")
|
||||
p.UserID = field.NewInt(table, "user_id")
|
||||
p.UserID = field.NewUint64(table, "user_id")
|
||||
p.RawID = field.NewString(table, "raw_id")
|
||||
p.Credential = field.NewField(table, "credential")
|
||||
p.LastUsedAt = field.NewInt64(table, "last_used_at")
|
||||
|
@ -122,7 +122,7 @@ func (p passkey) replaceDB(db *gorm.DB) passkey {
|
|||
type passkeyDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (p passkeyDo) FirstByID(id int) (result *model.Passkey, err error) {
|
||||
func (p passkeyDo) FirstByID(id uint64) (result *model.Passkey, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -137,7 +137,7 @@ func (p passkeyDo) FirstByID(id int) (result *model.Passkey, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (p passkeyDo) DeleteByID(id int) (err error) {
|
||||
func (p passkeyDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
370
query/site_categories.gen.go
Normal file
370
query/site_categories.gen.go
Normal file
|
@ -0,0 +1,370 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
)
|
||||
|
||||
func newSiteCategory(db *gorm.DB, opts ...gen.DOOption) siteCategory {
|
||||
_siteCategory := siteCategory{}
|
||||
|
||||
_siteCategory.siteCategoryDo.UseDB(db, opts...)
|
||||
_siteCategory.siteCategoryDo.UseModel(&model.SiteCategory{})
|
||||
|
||||
tableName := _siteCategory.siteCategoryDo.TableName()
|
||||
_siteCategory.ALL = field.NewAsterisk(tableName)
|
||||
_siteCategory.ID = field.NewUint64(tableName, "id")
|
||||
_siteCategory.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_siteCategory.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_siteCategory.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_siteCategory.Name = field.NewString(tableName, "name")
|
||||
_siteCategory.SyncNodeIds = field.NewField(tableName, "sync_node_ids")
|
||||
|
||||
_siteCategory.fillFieldMap()
|
||||
|
||||
return _siteCategory
|
||||
}
|
||||
|
||||
type siteCategory struct {
|
||||
siteCategoryDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
SyncNodeIds field.Field
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (s siteCategory) Table(newTableName string) *siteCategory {
|
||||
s.siteCategoryDo.UseTable(newTableName)
|
||||
return s.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (s siteCategory) As(alias string) *siteCategory {
|
||||
s.siteCategoryDo.DO = *(s.siteCategoryDo.As(alias).(*gen.DO))
|
||||
return s.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (s *siteCategory) updateTableName(table string) *siteCategory {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
s.Name = field.NewString(table, "name")
|
||||
s.SyncNodeIds = field.NewField(table, "sync_node_ids")
|
||||
|
||||
s.fillFieldMap()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *siteCategory) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := s.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (s *siteCategory) fillFieldMap() {
|
||||
s.fieldMap = make(map[string]field.Expr, 6)
|
||||
s.fieldMap["id"] = s.ID
|
||||
s.fieldMap["created_at"] = s.CreatedAt
|
||||
s.fieldMap["updated_at"] = s.UpdatedAt
|
||||
s.fieldMap["deleted_at"] = s.DeletedAt
|
||||
s.fieldMap["name"] = s.Name
|
||||
s.fieldMap["sync_node_ids"] = s.SyncNodeIds
|
||||
}
|
||||
|
||||
func (s siteCategory) clone(db *gorm.DB) siteCategory {
|
||||
s.siteCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s siteCategory) replaceDB(db *gorm.DB) siteCategory {
|
||||
s.siteCategoryDo.ReplaceDB(db)
|
||||
return s
|
||||
}
|
||||
|
||||
type siteCategoryDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s siteCategoryDo) FirstByID(id uint64) (result *model.SiteCategory, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, id)
|
||||
generateSQL.WriteString("id=? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = s.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s siteCategoryDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, id)
|
||||
generateSQL.WriteString("update site_categories set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = s.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Debug() *siteCategoryDo {
|
||||
return s.withDO(s.DO.Debug())
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) WithContext(ctx context.Context) *siteCategoryDo {
|
||||
return s.withDO(s.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) ReadDB() *siteCategoryDo {
|
||||
return s.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) WriteDB() *siteCategoryDo {
|
||||
return s.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Session(config *gorm.Session) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Session(config))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Clauses(conds ...clause.Expression) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Returning(value interface{}, columns ...string) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Not(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Or(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Select(conds ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Where(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Order(conds ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Distinct(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Omit(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Join(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Group(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Having(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Limit(limit int) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Offset(offset int) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Unscoped() *siteCategoryDo {
|
||||
return s.withDO(s.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Create(values ...*model.SiteCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Create(values)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) CreateInBatches(values []*model.SiteCategory, batchSize int) error {
|
||||
return s.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (s siteCategoryDo) Save(values ...*model.SiteCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Save(values)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) First() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Take() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Last() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Find() ([]*model.SiteCategory, error) {
|
||||
result, err := s.DO.Find()
|
||||
return result.([]*model.SiteCategory), err
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SiteCategory, err error) {
|
||||
buf := make([]*model.SiteCategory, 0, batchSize)
|
||||
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindInBatches(result *[]*model.SiteCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return s.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Attrs(attrs ...field.AssignExpr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Assign(attrs ...field.AssignExpr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Joins(fields ...field.RelationField) *siteCategoryDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Joins(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Preload(fields ...field.RelationField) *siteCategoryDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Preload(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FirstOrInit() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FirstOrCreate() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindByPage(offset int, limit int) (result []*model.SiteCategory, count int64, err error) {
|
||||
result, err = s.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = s.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = s.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Scan(result interface{}) (err error) {
|
||||
return s.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Delete(models ...*model.SiteCategory) (result gen.ResultInfo, err error) {
|
||||
return s.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (s *siteCategoryDo) withDO(do gen.Dao) *siteCategoryDo {
|
||||
s.DO = *do.(*gen.DO)
|
||||
return s
|
||||
}
|
|
@ -28,7 +28,7 @@ func newSite(db *gorm.DB, opts ...gen.DOOption) site {
|
|||
|
||||
tableName := _site.siteDo.TableName()
|
||||
_site.ALL = field.NewAsterisk(tableName)
|
||||
_site.ID = field.NewInt(tableName, "id")
|
||||
_site.ID = field.NewUint64(tableName, "id")
|
||||
_site.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_site.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_site.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -44,7 +44,7 @@ type site struct {
|
|||
siteDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -66,7 +66,7 @@ func (s site) As(alias string) *site {
|
|||
|
||||
func (s *site) updateTableName(table string) *site {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt(table, "id")
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -110,7 +110,7 @@ func (s site) replaceDB(db *gorm.DB) site {
|
|||
type siteDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s siteDo) FirstByID(id int) (result *model.Site, err error) {
|
||||
func (s siteDo) FirstByID(id uint64) (result *model.Site, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -125,7 +125,7 @@ func (s siteDo) FirstByID(id int) (result *model.Site, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s siteDo) DeleteByID(id int) (err error) {
|
||||
func (s siteDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newStream(db *gorm.DB, opts ...gen.DOOption) stream {
|
|||
|
||||
tableName := _stream.streamDo.TableName()
|
||||
_stream.ALL = field.NewAsterisk(tableName)
|
||||
_stream.ID = field.NewInt(tableName, "id")
|
||||
_stream.ID = field.NewUint64(tableName, "id")
|
||||
_stream.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_stream.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_stream.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -44,7 +44,7 @@ type stream struct {
|
|||
streamDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -66,7 +66,7 @@ func (s stream) As(alias string) *stream {
|
|||
|
||||
func (s *stream) updateTableName(table string) *stream {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt(table, "id")
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -110,7 +110,7 @@ func (s stream) replaceDB(db *gorm.DB) stream {
|
|||
type streamDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s streamDo) FirstByID(id int) (result *model.Stream, err error) {
|
||||
func (s streamDo) FirstByID(id uint64) (result *model.Stream, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -125,7 +125,7 @@ func (s streamDo) FirstByID(id int) (result *model.Stream, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s streamDo) DeleteByID(id int) (err error) {
|
||||
func (s streamDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -49,6 +49,7 @@ func InitRouter() {
|
|||
analytic.InitRouter(g)
|
||||
user.InitManageUserRouter(g)
|
||||
nginx.InitRouter(g)
|
||||
sites.InitCategoryRouter(g)
|
||||
sites.InitRouter(g)
|
||||
streams.InitRouter(g)
|
||||
config.InitRouter(g)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue