feat(models): add new models for public API, event log, hook, session, user, and whatsapp account
* Introduced ModelPublicAPIKey, ModelPublicEventLog, ModelPublicHook, ModelPublicSession, ModelPublicUser, and ModelPublicWhatsappAccount * Removed deprecated ModelPublicUsers * Updated database schema definitions to reflect new model structure * Adjusted seed data to use correct types for timestamps
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelPublicAPIKeys struct {
|
type ModelPublicAPIKey struct {
|
||||||
bun.BaseModel `bun:"table:public.api_keys,alias:api_keys"`
|
bun.BaseModel `bun:"table:public.api_key,alias:api_key"`
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
||||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||||
@@ -21,50 +21,49 @@ type ModelPublicAPIKeys struct {
|
|||||||
Permissions resolvespec_common.SqlString `bun:"permissions,type:text,nullzero," json:"permissions"` // JSON array of permissions
|
Permissions resolvespec_common.SqlString `bun:"permissions,type:text,nullzero," json:"permissions"` // JSON array of permissions
|
||||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
||||||
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicAPIKeys
|
// TableName returns the table name for ModelPublicAPIKey
|
||||||
func (m ModelPublicAPIKeys) TableName() string {
|
func (m ModelPublicAPIKey) TableName() string {
|
||||||
return "public.api_keys"
|
return "public.api_key"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicAPIKeys
|
// TableNameOnly returns the table name without schema for ModelPublicAPIKey
|
||||||
func (m ModelPublicAPIKeys) TableNameOnly() string {
|
func (m ModelPublicAPIKey) TableNameOnly() string {
|
||||||
return "api_keys"
|
return "api_key"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicAPIKeys
|
// SchemaName returns the schema name for ModelPublicAPIKey
|
||||||
func (m ModelPublicAPIKeys) SchemaName() string {
|
func (m ModelPublicAPIKey) SchemaName() string {
|
||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the primary key value
|
// GetID returns the primary key value
|
||||||
func (m ModelPublicAPIKeys) GetID() int64 {
|
func (m ModelPublicAPIKey) GetID() int64 {
|
||||||
return m.ID.Int64()
|
return m.ID.Int64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
// GetIDStr returns the primary key as a string
|
||||||
func (m ModelPublicAPIKeys) GetIDStr() string {
|
func (m ModelPublicAPIKey) GetIDStr() string {
|
||||||
return fmt.Sprintf("%d", m.ID)
|
return fmt.Sprintf("%d", m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the primary key value
|
// SetID sets the primary key value
|
||||||
func (m ModelPublicAPIKeys) SetID(newid int64) {
|
func (m ModelPublicAPIKey) SetID(newid int64) {
|
||||||
m.UpdateID(newid)
|
m.UpdateID(newid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
// UpdateID updates the primary key value
|
||||||
func (m *ModelPublicAPIKeys) UpdateID(newid int64) {
|
func (m *ModelPublicAPIKey) UpdateID(newid int64) {
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
// GetIDName returns the name of the primary key column
|
||||||
func (m ModelPublicAPIKeys) GetIDName() string {
|
func (m ModelPublicAPIKey) GetIDName() string {
|
||||||
return "id"
|
return "id"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
// GetPrefix returns the table prefix
|
||||||
func (m ModelPublicAPIKeys) GetPrefix() string {
|
func (m ModelPublicAPIKey) GetPrefix() string {
|
||||||
return "AKP"
|
return "AKP"
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelPublicEventLogs struct {
|
type ModelPublicEventLog struct {
|
||||||
bun.BaseModel `bun:"table:public.event_logs,alias:event_logs"`
|
bun.BaseModel `bun:"table:public.event_log,alias:event_log"`
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create
|
Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create
|
||||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||||
@@ -20,51 +20,50 @@ type ModelPublicEventLogs struct {
|
|||||||
IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"`
|
IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"`
|
||||||
Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"`
|
Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"`
|
||||||
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
||||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference
|
||||||
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicEventLogs
|
// TableName returns the table name for ModelPublicEventLog
|
||||||
func (m ModelPublicEventLogs) TableName() string {
|
func (m ModelPublicEventLog) TableName() string {
|
||||||
return "public.event_logs"
|
return "public.event_log"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicEventLogs
|
// TableNameOnly returns the table name without schema for ModelPublicEventLog
|
||||||
func (m ModelPublicEventLogs) TableNameOnly() string {
|
func (m ModelPublicEventLog) TableNameOnly() string {
|
||||||
return "event_logs"
|
return "event_log"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicEventLogs
|
// SchemaName returns the schema name for ModelPublicEventLog
|
||||||
func (m ModelPublicEventLogs) SchemaName() string {
|
func (m ModelPublicEventLog) SchemaName() string {
|
||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the primary key value
|
// GetID returns the primary key value
|
||||||
func (m ModelPublicEventLogs) GetID() int64 {
|
func (m ModelPublicEventLog) GetID() int64 {
|
||||||
return m.ID.Int64()
|
return m.ID.Int64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
// GetIDStr returns the primary key as a string
|
||||||
func (m ModelPublicEventLogs) GetIDStr() string {
|
func (m ModelPublicEventLog) GetIDStr() string {
|
||||||
return fmt.Sprintf("%d", m.ID)
|
return fmt.Sprintf("%d", m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the primary key value
|
// SetID sets the primary key value
|
||||||
func (m ModelPublicEventLogs) SetID(newid int64) {
|
func (m ModelPublicEventLog) SetID(newid int64) {
|
||||||
m.UpdateID(newid)
|
m.UpdateID(newid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
// UpdateID updates the primary key value
|
||||||
func (m *ModelPublicEventLogs) UpdateID(newid int64) {
|
func (m *ModelPublicEventLog) UpdateID(newid int64) {
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
// GetIDName returns the name of the primary key column
|
||||||
func (m ModelPublicEventLogs) GetIDName() string {
|
func (m ModelPublicEventLog) GetIDName() string {
|
||||||
return "id"
|
return "id"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
// GetPrefix returns the table prefix
|
||||||
func (m ModelPublicEventLogs) GetPrefix() string {
|
func (m ModelPublicEventLog) GetPrefix() string {
|
||||||
return "ELV"
|
return "ELV"
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelPublicHooks struct {
|
type ModelPublicHook struct {
|
||||||
bun.BaseModel `bun:"table:public.hooks,alias:hooks"`
|
bun.BaseModel `bun:"table:public.hook,alias:hook"`
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
||||||
AllowInsecure bool `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification
|
AllowInsecure bool `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification
|
||||||
@@ -25,50 +25,49 @@ type ModelPublicHooks struct {
|
|||||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||||
URL resolvespec_common.SqlString `bun:"url,type:text,notnull," json:"url"`
|
URL resolvespec_common.SqlString `bun:"url,type:text,notnull," json:"url"`
|
||||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
||||||
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicHooks
|
// TableName returns the table name for ModelPublicHook
|
||||||
func (m ModelPublicHooks) TableName() string {
|
func (m ModelPublicHook) TableName() string {
|
||||||
return "public.hooks"
|
return "public.hook"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicHooks
|
// TableNameOnly returns the table name without schema for ModelPublicHook
|
||||||
func (m ModelPublicHooks) TableNameOnly() string {
|
func (m ModelPublicHook) TableNameOnly() string {
|
||||||
return "hooks"
|
return "hook"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicHooks
|
// SchemaName returns the schema name for ModelPublicHook
|
||||||
func (m ModelPublicHooks) SchemaName() string {
|
func (m ModelPublicHook) SchemaName() string {
|
||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the primary key value
|
// GetID returns the primary key value
|
||||||
func (m ModelPublicHooks) GetID() int64 {
|
func (m ModelPublicHook) GetID() int64 {
|
||||||
return m.ID.Int64()
|
return m.ID.Int64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
// GetIDStr returns the primary key as a string
|
||||||
func (m ModelPublicHooks) GetIDStr() string {
|
func (m ModelPublicHook) GetIDStr() string {
|
||||||
return fmt.Sprintf("%d", m.ID)
|
return fmt.Sprintf("%d", m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the primary key value
|
// SetID sets the primary key value
|
||||||
func (m ModelPublicHooks) SetID(newid int64) {
|
func (m ModelPublicHook) SetID(newid int64) {
|
||||||
m.UpdateID(newid)
|
m.UpdateID(newid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
// UpdateID updates the primary key value
|
||||||
func (m *ModelPublicHooks) UpdateID(newid int64) {
|
func (m *ModelPublicHook) UpdateID(newid int64) {
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
// GetIDName returns the name of the primary key column
|
||||||
func (m ModelPublicHooks) GetIDName() string {
|
func (m ModelPublicHook) GetIDName() string {
|
||||||
return "id"
|
return "id"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
// GetPrefix returns the table prefix
|
||||||
func (m ModelPublicHooks) GetPrefix() string {
|
func (m ModelPublicHook) GetPrefix() string {
|
||||||
return "HOO"
|
return "HOO"
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelPublicSessions struct {
|
type ModelPublicSession struct {
|
||||||
bun.BaseModel `bun:"table:public.sessions,alias:sessions"`
|
bun.BaseModel `bun:"table:public.session,alias:session"`
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||||
ExpiresAt resolvespec_common.SqlTimeStamp `bun:"expires_at,type:timestamp,notnull," json:"expires_at"`
|
ExpiresAt resolvespec_common.SqlTimeStamp `bun:"expires_at,type:timestamp,notnull," json:"expires_at"`
|
||||||
@@ -17,50 +17,49 @@ type ModelPublicSessions struct {
|
|||||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||||
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
||||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
||||||
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicSessions
|
// TableName returns the table name for ModelPublicSession
|
||||||
func (m ModelPublicSessions) TableName() string {
|
func (m ModelPublicSession) TableName() string {
|
||||||
return "public.sessions"
|
return "public.session"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicSessions
|
// TableNameOnly returns the table name without schema for ModelPublicSession
|
||||||
func (m ModelPublicSessions) TableNameOnly() string {
|
func (m ModelPublicSession) TableNameOnly() string {
|
||||||
return "sessions"
|
return "session"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicSessions
|
// SchemaName returns the schema name for ModelPublicSession
|
||||||
func (m ModelPublicSessions) SchemaName() string {
|
func (m ModelPublicSession) SchemaName() string {
|
||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the primary key value
|
// GetID returns the primary key value
|
||||||
func (m ModelPublicSessions) GetID() int64 {
|
func (m ModelPublicSession) GetID() int64 {
|
||||||
return m.ID.Int64()
|
return m.ID.Int64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
// GetIDStr returns the primary key as a string
|
||||||
func (m ModelPublicSessions) GetIDStr() string {
|
func (m ModelPublicSession) GetIDStr() string {
|
||||||
return fmt.Sprintf("%d", m.ID)
|
return fmt.Sprintf("%d", m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the primary key value
|
// SetID sets the primary key value
|
||||||
func (m ModelPublicSessions) SetID(newid int64) {
|
func (m ModelPublicSession) SetID(newid int64) {
|
||||||
m.UpdateID(newid)
|
m.UpdateID(newid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
// UpdateID updates the primary key value
|
||||||
func (m *ModelPublicSessions) UpdateID(newid int64) {
|
func (m *ModelPublicSession) UpdateID(newid int64) {
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
// GetIDName returns the name of the primary key column
|
||||||
func (m ModelPublicSessions) GetIDName() string {
|
func (m ModelPublicSession) GetIDName() string {
|
||||||
return "id"
|
return "id"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
// GetPrefix returns the table prefix
|
||||||
func (m ModelPublicSessions) GetPrefix() string {
|
func (m ModelPublicSession) GetPrefix() string {
|
||||||
return "SES"
|
return "SES"
|
||||||
}
|
}
|
||||||
67
pkg/models/sql_public_user.go
Normal file
67
pkg/models/sql_public_user.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
// Code generated by relspecgo. DO NOT EDIT.
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModelPublicUser struct {
|
||||||
|
bun.BaseModel `bun:"table:public.user,alias:user"`
|
||||||
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
|
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
||||||
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||||
|
DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` // Soft delete
|
||||||
|
Email resolvespec_common.SqlString `bun:"email,type:varchar(255),notnull," json:"email"`
|
||||||
|
FullName resolvespec_common.SqlString `bun:"full_name,type:varchar(255),nullzero," json:"full_name"`
|
||||||
|
Password resolvespec_common.SqlString `bun:"password,type:varchar(255),notnull," json:"password"` // Bcrypt hashed password
|
||||||
|
Role resolvespec_common.SqlString `bun:"role,type:varchar(50),default:'user',notnull," json:"role"` // admin
|
||||||
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||||
|
Username resolvespec_common.SqlString `bun:"username,type:varchar(255),notnull," json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName returns the table name for ModelPublicUser
|
||||||
|
func (m ModelPublicUser) TableName() string {
|
||||||
|
return "public.user"
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableNameOnly returns the table name without schema for ModelPublicUser
|
||||||
|
func (m ModelPublicUser) TableNameOnly() string {
|
||||||
|
return "user"
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaName returns the schema name for ModelPublicUser
|
||||||
|
func (m ModelPublicUser) SchemaName() string {
|
||||||
|
return "public"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetID returns the primary key value
|
||||||
|
func (m ModelPublicUser) GetID() int64 {
|
||||||
|
return m.ID.Int64()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIDStr returns the primary key as a string
|
||||||
|
func (m ModelPublicUser) GetIDStr() string {
|
||||||
|
return fmt.Sprintf("%d", m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the primary key value
|
||||||
|
func (m ModelPublicUser) SetID(newid int64) {
|
||||||
|
m.UpdateID(newid)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateID updates the primary key value
|
||||||
|
func (m *ModelPublicUser) UpdateID(newid int64) {
|
||||||
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIDName returns the name of the primary key column
|
||||||
|
func (m ModelPublicUser) GetIDName() string {
|
||||||
|
return "id"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPrefix returns the table prefix
|
||||||
|
func (m ModelPublicUser) GetPrefix() string {
|
||||||
|
return "USE"
|
||||||
|
}
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
// Code generated by relspecgo. DO NOT EDIT.
|
|
||||||
package models
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
|
|
||||||
"github.com/uptrace/bun"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ModelPublicUsers struct {
|
|
||||||
bun.BaseModel `bun:"table:public.users,alias:users"`
|
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
|
||||||
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
|
||||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
|
||||||
DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` // Soft delete
|
|
||||||
Email resolvespec_common.SqlString `bun:"email,type:varchar(255),notnull," json:"email"`
|
|
||||||
FullName resolvespec_common.SqlString `bun:"full_name,type:varchar(255),nullzero," json:"full_name"`
|
|
||||||
Password resolvespec_common.SqlString `bun:"password,type:varchar(255),notnull," json:"password"` // Bcrypt hashed password
|
|
||||||
Role resolvespec_common.SqlString `bun:"role,type:varchar(50),default:'user',notnull," json:"role"` // admin
|
|
||||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
|
||||||
Username resolvespec_common.SqlString `bun:"username,type:varchar(255),notnull," json:"username"`
|
|
||||||
RelUserIDPublicAPIKeys []*ModelPublicAPIKeys `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicapikeys,omitempty"` // Has many ModelPublicAPIKeys
|
|
||||||
RelUserIDPublicHooks []*ModelPublicHooks `bun:"rel:has-many,join:id=user_id" json:"reluseridpublichooks,omitempty"` // Has many ModelPublicHooks
|
|
||||||
RelUserIDPublicWhatsappAccounts []*ModelPublicWhatsappAccounts `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicwhatsappaccounts,omitempty"` // Has many ModelPublicWhatsappAccounts
|
|
||||||
RelUserIDPublicEventLogs []*ModelPublicEventLogs `bun:"rel:has-many,join:id=user_id" json:"reluseridpubliceventlogs,omitempty"` // Has many ModelPublicEventLogs
|
|
||||||
RelUserIDPublicSessions []*ModelPublicSessions `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicsessions,omitempty"` // Has many ModelPublicSessions
|
|
||||||
}
|
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicUsers
|
|
||||||
func (m ModelPublicUsers) TableName() string {
|
|
||||||
return "public.users"
|
|
||||||
}
|
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicUsers
|
|
||||||
func (m ModelPublicUsers) TableNameOnly() string {
|
|
||||||
return "users"
|
|
||||||
}
|
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicUsers
|
|
||||||
func (m ModelPublicUsers) SchemaName() string {
|
|
||||||
return "public"
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetID returns the primary key value
|
|
||||||
func (m ModelPublicUsers) GetID() int64 {
|
|
||||||
return m.ID.Int64()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
|
||||||
func (m ModelPublicUsers) GetIDStr() string {
|
|
||||||
return fmt.Sprintf("%d", m.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets the primary key value
|
|
||||||
func (m ModelPublicUsers) SetID(newid int64) {
|
|
||||||
m.UpdateID(newid)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
|
||||||
func (m *ModelPublicUsers) UpdateID(newid int64) {
|
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
|
||||||
func (m ModelPublicUsers) GetIDName() string {
|
|
||||||
return "id"
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
|
||||||
func (m ModelPublicUsers) GetPrefix() string {
|
|
||||||
return "USE"
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/uptrace/bun"
|
"github.com/uptrace/bun"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelPublicWhatsappAccounts struct {
|
type ModelPublicWhatsappAccount struct {
|
||||||
bun.BaseModel `bun:"table:public.whatsapp_accounts,alias:whatsapp_accounts"`
|
bun.BaseModel `bun:"table:public.whatsapp_account,alias:whatsapp_account"`
|
||||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||||
AccountType resolvespec_common.SqlString `bun:"account_type,type:varchar(50),notnull," json:"account_type"` // whatsmeow or business-api
|
AccountType resolvespec_common.SqlString `bun:"account_type,type:varchar(50),notnull," json:"account_type"` // whatsmeow or business-api
|
||||||
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
||||||
@@ -22,50 +22,49 @@ type ModelPublicWhatsappAccounts struct {
|
|||||||
Status resolvespec_common.SqlString `bun:"status,type:varchar(50),default:'disconnected',notnull," json:"status"` // connected
|
Status resolvespec_common.SqlString `bun:"status,type:varchar(50),default:'disconnected',notnull," json:"status"` // connected
|
||||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
||||||
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName returns the table name for ModelPublicWhatsappAccounts
|
// TableName returns the table name for ModelPublicWhatsappAccount
|
||||||
func (m ModelPublicWhatsappAccounts) TableName() string {
|
func (m ModelPublicWhatsappAccount) TableName() string {
|
||||||
return "public.whatsapp_accounts"
|
return "public.whatsapp_account"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableNameOnly returns the table name without schema for ModelPublicWhatsappAccounts
|
// TableNameOnly returns the table name without schema for ModelPublicWhatsappAccount
|
||||||
func (m ModelPublicWhatsappAccounts) TableNameOnly() string {
|
func (m ModelPublicWhatsappAccount) TableNameOnly() string {
|
||||||
return "whatsapp_accounts"
|
return "whatsapp_account"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SchemaName returns the schema name for ModelPublicWhatsappAccounts
|
// SchemaName returns the schema name for ModelPublicWhatsappAccount
|
||||||
func (m ModelPublicWhatsappAccounts) SchemaName() string {
|
func (m ModelPublicWhatsappAccount) SchemaName() string {
|
||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the primary key value
|
// GetID returns the primary key value
|
||||||
func (m ModelPublicWhatsappAccounts) GetID() int64 {
|
func (m ModelPublicWhatsappAccount) GetID() int64 {
|
||||||
return m.ID.Int64()
|
return m.ID.Int64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDStr returns the primary key as a string
|
// GetIDStr returns the primary key as a string
|
||||||
func (m ModelPublicWhatsappAccounts) GetIDStr() string {
|
func (m ModelPublicWhatsappAccount) GetIDStr() string {
|
||||||
return fmt.Sprintf("%d", m.ID)
|
return fmt.Sprintf("%d", m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the primary key value
|
// SetID sets the primary key value
|
||||||
func (m ModelPublicWhatsappAccounts) SetID(newid int64) {
|
func (m ModelPublicWhatsappAccount) SetID(newid int64) {
|
||||||
m.UpdateID(newid)
|
m.UpdateID(newid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateID updates the primary key value
|
// UpdateID updates the primary key value
|
||||||
func (m *ModelPublicWhatsappAccounts) UpdateID(newid int64) {
|
func (m *ModelPublicWhatsappAccount) UpdateID(newid int64) {
|
||||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIDName returns the name of the primary key column
|
// GetIDName returns the name of the primary key column
|
||||||
func (m ModelPublicWhatsappAccounts) GetIDName() string {
|
func (m ModelPublicWhatsappAccount) GetIDName() string {
|
||||||
return "id"
|
return "id"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrefix returns the table prefix
|
// GetPrefix returns the table prefix
|
||||||
func (m ModelPublicWhatsappAccounts) GetPrefix() string {
|
func (m ModelPublicWhatsappAccount) GetPrefix() string {
|
||||||
return "WAH"
|
return "WAH"
|
||||||
}
|
}
|
||||||
@@ -40,8 +40,8 @@ func SeedData(ctx context.Context) error {
|
|||||||
FullName: resolvespec_common.NewSqlString("System Administrator"),
|
FullName: resolvespec_common.NewSqlString("System Administrator"),
|
||||||
Role: resolvespec_common.NewSqlString("admin"),
|
Role: resolvespec_common.NewSqlString("admin"),
|
||||||
Active: true,
|
Active: true,
|
||||||
CreatedAt: resolvespec_common.NewSqlTime(now),
|
CreatedAt: resolvespec_common.NewSqlTimeStamp(now),
|
||||||
UpdatedAt: resolvespec_common.NewSqlTime(now),
|
UpdatedAt: resolvespec_common.NewSqlTimeStamp(now),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := userRepo.Create(ctx, adminUser); err != nil {
|
if err := userRepo.Create(ctx, adminUser); err != nil {
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ func (wh *WhatsHooked) connectFromDatabase(ctx context.Context) error {
|
|||||||
|
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
// Skip if account_id is not set
|
// Skip if account_id is not set
|
||||||
accountID := account.AccountID.String()
|
accountID := account.ID.String()
|
||||||
if accountID == "" {
|
if accountID == "" {
|
||||||
accountID = account.ID.String() // Fall back to UUID if account_id not set
|
accountID = account.ID.String() // Fall back to UUID if account_id not set
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// WhatsHooked Database Schema
|
// WhatsHooked Database Schema
|
||||||
// This file defines the database schema for WhatsHooked Phase 2
|
// This file defines the database schema for WhatsHooked Phase 2
|
||||||
|
|
||||||
Table users {
|
Table user {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
username varchar(255) [unique, not null]
|
username varchar(255) [unique, not null]
|
||||||
email varchar(255) [unique, not null]
|
email varchar(255) [unique, not null]
|
||||||
@@ -18,7 +18,7 @@ Table users {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table api_keys {
|
Table api_key {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
user_id varchar(36) [not null, ref: > users.id]
|
user_id varchar(36) [not null, ref: > users.id]
|
||||||
name varchar(255) [not null, note: 'Friendly name for the API key']
|
name varchar(255) [not null, note: 'Friendly name for the API key']
|
||||||
@@ -38,7 +38,7 @@ Table api_keys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table hooks {
|
Table hook {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
user_id varchar(36) [not null, ref: > users.id]
|
user_id varchar(36) [not null, ref: > users.id]
|
||||||
name varchar(255) [not null]
|
name varchar(255) [not null]
|
||||||
@@ -62,7 +62,7 @@ Table hooks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table whatsapp_accounts {
|
Table whatsapp_account {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
user_id varchar(36) [not null, ref: > users.id]
|
user_id varchar(36) [not null, ref: > users.id]
|
||||||
account_type varchar(50) [not null, note: 'whatsmeow or business-api']
|
account_type varchar(50) [not null, note: 'whatsmeow or business-api']
|
||||||
@@ -83,7 +83,7 @@ Table whatsapp_accounts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table event_logs {
|
Table event_log {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
user_id varchar(36) [ref: > users.id, note: 'Optional user reference']
|
user_id varchar(36) [ref: > users.id, note: 'Optional user reference']
|
||||||
event_type varchar(100) [not null]
|
event_type varchar(100) [not null]
|
||||||
@@ -106,7 +106,7 @@ Table event_logs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table sessions {
|
Table session {
|
||||||
id varchar(36) [primary key, note: 'UUID']
|
id varchar(36) [primary key, note: 'UUID']
|
||||||
user_id varchar(36) [not null, ref: > users.id]
|
user_id varchar(36) [not null, ref: > users.id]
|
||||||
token varchar(255) [unique, not null, note: 'Session token hash']
|
token varchar(255) [unique, not null, note: 'Session token hash']
|
||||||
|
|||||||
Reference in New Issue
Block a user