updated

This commit is contained in:
landaiqing
2024-11-14 01:58:20 +08:00
parent c95d5fc041
commit 3b8e3df27a
83 changed files with 172212 additions and 343 deletions

View File

@@ -0,0 +1,27 @@
package ip2region
import (
"os"
"path/filepath"
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
)
// NewIP2Region creates a new IP2Region searcher instance.
func NewIP2Region() *xdb.Searcher {
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
dbPath := filepath.Join(cwd, "resources/ip2region", "ip2region.xdb")
cBuff, err := xdb.LoadContentFromFile(dbPath)
if err != nil {
panic(err)
}
searcher, err := xdb.NewWithBuffer(cBuff)
if err != nil {
panic(err)
return nil
}
return searcher
}

View File

@@ -1,4 +1,4 @@
package model
package types
import "github.com/chenmingyong0423/go-mongox/v2"

View File

@@ -107,8 +107,8 @@ var schemaGraph = func() *sqlgraph.Schema {
scaauthuserdevice.FieldBrowser: {Type: field.TypeString, Column: scaauthuserdevice.FieldBrowser},
scaauthuserdevice.FieldOperatingSystem: {Type: field.TypeString, Column: scaauthuserdevice.FieldOperatingSystem},
scaauthuserdevice.FieldBrowserVersion: {Type: field.TypeString, Column: scaauthuserdevice.FieldBrowserVersion},
scaauthuserdevice.FieldMobile: {Type: field.TypeInt, Column: scaauthuserdevice.FieldMobile},
scaauthuserdevice.FieldBot: {Type: field.TypeInt, Column: scaauthuserdevice.FieldBot},
scaauthuserdevice.FieldMobile: {Type: field.TypeBool, Column: scaauthuserdevice.FieldMobile},
scaauthuserdevice.FieldBot: {Type: field.TypeBool, Column: scaauthuserdevice.FieldBot},
scaauthuserdevice.FieldMozilla: {Type: field.TypeString, Column: scaauthuserdevice.FieldMozilla},
scaauthuserdevice.FieldPlatform: {Type: field.TypeString, Column: scaauthuserdevice.FieldPlatform},
scaauthuserdevice.FieldEngineName: {Type: field.TypeString, Column: scaauthuserdevice.FieldEngineName},
@@ -622,13 +622,13 @@ func (f *ScaAuthUserDeviceFilter) WhereBrowserVersion(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldBrowserVersion))
}
// WhereMobile applies the entql int predicate on the mobile field.
func (f *ScaAuthUserDeviceFilter) WhereMobile(p entql.IntP) {
// WhereMobile applies the entql bool predicate on the mobile field.
func (f *ScaAuthUserDeviceFilter) WhereMobile(p entql.BoolP) {
f.Where(p.Field(scaauthuserdevice.FieldMobile))
}
// WhereBot applies the entql int predicate on the bot field.
func (f *ScaAuthUserDeviceFilter) WhereBot(p entql.IntP) {
// WhereBot applies the entql bool predicate on the bot field.
func (f *ScaAuthUserDeviceFilter) WhereBot(p entql.BoolP) {
f.Where(p.Field(scaauthuserdevice.FieldBot))
}

View File

@@ -109,8 +109,8 @@ var (
{Name: "browser", Type: field.TypeString, Size: 20, Comment: "浏览器"},
{Name: "operating_system", Type: field.TypeString, Size: 20, Comment: "操作系统"},
{Name: "browser_version", Type: field.TypeString, Size: 20, Comment: "浏览器版本"},
{Name: "mobile", Type: field.TypeInt, Comment: "是否为手机 0否1是"},
{Name: "bot", Type: field.TypeInt, Comment: "是否为bot 0否1是"},
{Name: "mobile", Type: field.TypeBool, Comment: "是否为手机 0否1是"},
{Name: "bot", Type: field.TypeBool, Comment: "是否为bot 0否1是"},
{Name: "mozilla", Type: field.TypeString, Size: 10, Comment: "火狐版本"},
{Name: "platform", Type: field.TypeString, Size: 20, Comment: "平台"},
{Name: "engine_name", Type: field.TypeString, Size: 20, Comment: "引擎名称"},

View File

@@ -3193,10 +3193,8 @@ type ScaAuthUserDeviceMutation struct {
browser *string
operating_system *string
browser_version *string
mobile *int
addmobile *int
bot *int
addbot *int
mobile *bool
bot *bool
mozilla *string
platform *string
engine_name *string
@@ -3708,13 +3706,12 @@ func (m *ScaAuthUserDeviceMutation) ResetBrowserVersion() {
}
// SetMobile sets the "mobile" field.
func (m *ScaAuthUserDeviceMutation) SetMobile(i int) {
m.mobile = &i
m.addmobile = nil
func (m *ScaAuthUserDeviceMutation) SetMobile(b bool) {
m.mobile = &b
}
// Mobile returns the value of the "mobile" field in the mutation.
func (m *ScaAuthUserDeviceMutation) Mobile() (r int, exists bool) {
func (m *ScaAuthUserDeviceMutation) Mobile() (r bool, exists bool) {
v := m.mobile
if v == nil {
return
@@ -3725,7 +3722,7 @@ func (m *ScaAuthUserDeviceMutation) Mobile() (r int, exists bool) {
// OldMobile returns the old "mobile" field's value of the ScaAuthUserDevice entity.
// If the ScaAuthUserDevice object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ScaAuthUserDeviceMutation) OldMobile(ctx context.Context) (v int, err error) {
func (m *ScaAuthUserDeviceMutation) OldMobile(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMobile is only allowed on UpdateOne operations")
}
@@ -3739,38 +3736,18 @@ func (m *ScaAuthUserDeviceMutation) OldMobile(ctx context.Context) (v int, err e
return oldValue.Mobile, nil
}
// AddMobile adds i to the "mobile" field.
func (m *ScaAuthUserDeviceMutation) AddMobile(i int) {
if m.addmobile != nil {
*m.addmobile += i
} else {
m.addmobile = &i
}
}
// AddedMobile returns the value that was added to the "mobile" field in this mutation.
func (m *ScaAuthUserDeviceMutation) AddedMobile() (r int, exists bool) {
v := m.addmobile
if v == nil {
return
}
return *v, true
}
// ResetMobile resets all changes to the "mobile" field.
func (m *ScaAuthUserDeviceMutation) ResetMobile() {
m.mobile = nil
m.addmobile = nil
}
// SetBot sets the "bot" field.
func (m *ScaAuthUserDeviceMutation) SetBot(i int) {
m.bot = &i
m.addbot = nil
func (m *ScaAuthUserDeviceMutation) SetBot(b bool) {
m.bot = &b
}
// Bot returns the value of the "bot" field in the mutation.
func (m *ScaAuthUserDeviceMutation) Bot() (r int, exists bool) {
func (m *ScaAuthUserDeviceMutation) Bot() (r bool, exists bool) {
v := m.bot
if v == nil {
return
@@ -3781,7 +3758,7 @@ func (m *ScaAuthUserDeviceMutation) Bot() (r int, exists bool) {
// OldBot returns the old "bot" field's value of the ScaAuthUserDevice entity.
// If the ScaAuthUserDevice object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ScaAuthUserDeviceMutation) OldBot(ctx context.Context) (v int, err error) {
func (m *ScaAuthUserDeviceMutation) OldBot(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBot is only allowed on UpdateOne operations")
}
@@ -3795,28 +3772,9 @@ func (m *ScaAuthUserDeviceMutation) OldBot(ctx context.Context) (v int, err erro
return oldValue.Bot, nil
}
// AddBot adds i to the "bot" field.
func (m *ScaAuthUserDeviceMutation) AddBot(i int) {
if m.addbot != nil {
*m.addbot += i
} else {
m.addbot = &i
}
}
// AddedBot returns the value that was added to the "bot" field in this mutation.
func (m *ScaAuthUserDeviceMutation) AddedBot() (r int, exists bool) {
v := m.addbot
if v == nil {
return
}
return *v, true
}
// ResetBot resets all changes to the "bot" field.
func (m *ScaAuthUserDeviceMutation) ResetBot() {
m.bot = nil
m.addbot = nil
}
// SetMozilla sets the "mozilla" field.
@@ -4246,14 +4204,14 @@ func (m *ScaAuthUserDeviceMutation) SetField(name string, value ent.Value) error
m.SetBrowserVersion(v)
return nil
case scaauthuserdevice.FieldMobile:
v, ok := value.(int)
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMobile(v)
return nil
case scaauthuserdevice.FieldBot:
v, ok := value.(int)
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
@@ -4298,12 +4256,6 @@ func (m *ScaAuthUserDeviceMutation) AddedFields() []string {
if m.adddeleted != nil {
fields = append(fields, scaauthuserdevice.FieldDeleted)
}
if m.addmobile != nil {
fields = append(fields, scaauthuserdevice.FieldMobile)
}
if m.addbot != nil {
fields = append(fields, scaauthuserdevice.FieldBot)
}
return fields
}
@@ -4314,10 +4266,6 @@ func (m *ScaAuthUserDeviceMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case scaauthuserdevice.FieldDeleted:
return m.AddedDeleted()
case scaauthuserdevice.FieldMobile:
return m.AddedMobile()
case scaauthuserdevice.FieldBot:
return m.AddedBot()
}
return nil, false
}
@@ -4334,20 +4282,6 @@ func (m *ScaAuthUserDeviceMutation) AddField(name string, value ent.Value) error
}
m.AddDeleted(v)
return nil
case scaauthuserdevice.FieldMobile:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMobile(v)
return nil
case scaauthuserdevice.FieldBot:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddBot(v)
return nil
}
return fmt.Errorf("unknown ScaAuthUserDevice numeric field %s", name)
}

View File

@@ -8,7 +8,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/schema"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"time"
)
@@ -16,7 +16,7 @@ import (
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
scaauthpermissionruleFields := schema.ScaAuthPermissionRule{}.Fields()
scaauthpermissionruleFields := model.ScaAuthPermissionRule{}.Fields()
_ = scaauthpermissionruleFields
// scaauthpermissionruleDescPtype is the schema descriptor for ptype field.
scaauthpermissionruleDescPtype := scaauthpermissionruleFields[1].Descriptor()
@@ -46,10 +46,10 @@ func init() {
scaauthpermissionruleDescV5 := scaauthpermissionruleFields[7].Descriptor()
// scaauthpermissionrule.V5Validator is a validator for the "v5" field. It is called by the builders before save.
scaauthpermissionrule.V5Validator = scaauthpermissionruleDescV5.Validators[0].(func(string) error)
scaauthroleMixin := schema.ScaAuthRole{}.Mixin()
scaauthroleMixin := model.ScaAuthRole{}.Mixin()
scaauthroleMixinFields0 := scaauthroleMixin[0].Fields()
_ = scaauthroleMixinFields0
scaauthroleFields := schema.ScaAuthRole{}.Fields()
scaauthroleFields := model.ScaAuthRole{}.Fields()
_ = scaauthroleFields
// scaauthroleDescCreatedAt is the schema descriptor for created_at field.
scaauthroleDescCreatedAt := scaauthroleMixinFields0[0].Descriptor()
@@ -75,10 +75,10 @@ func init() {
scaauthroleDescRoleKey := scaauthroleFields[2].Descriptor()
// scaauthrole.RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save.
scaauthrole.RoleKeyValidator = scaauthroleDescRoleKey.Validators[0].(func(string) error)
scaauthuserMixin := schema.ScaAuthUser{}.Mixin()
scaauthuserMixin := model.ScaAuthUser{}.Mixin()
scaauthuserMixinFields0 := scaauthuserMixin[0].Fields()
_ = scaauthuserMixinFields0
scaauthuserFields := schema.ScaAuthUser{}.Fields()
scaauthuserFields := model.ScaAuthUser{}.Fields()
_ = scaauthuserFields
// scaauthuserDescCreatedAt is the schema descriptor for created_at field.
scaauthuserDescCreatedAt := scaauthuserMixinFields0[0].Descriptor()
@@ -144,10 +144,10 @@ func init() {
scaauthuserDescCompany := scaauthuserFields[13].Descriptor()
// scaauthuser.CompanyValidator is a validator for the "company" field. It is called by the builders before save.
scaauthuser.CompanyValidator = scaauthuserDescCompany.Validators[0].(func(string) error)
scaauthuserdeviceMixin := schema.ScaAuthUserDevice{}.Mixin()
scaauthuserdeviceMixin := model.ScaAuthUserDevice{}.Mixin()
scaauthuserdeviceMixinFields0 := scaauthuserdeviceMixin[0].Fields()
_ = scaauthuserdeviceMixinFields0
scaauthuserdeviceFields := schema.ScaAuthUserDevice{}.Fields()
scaauthuserdeviceFields := model.ScaAuthUserDevice{}.Fields()
_ = scaauthuserdeviceFields
// scaauthuserdeviceDescCreatedAt is the schema descriptor for created_at field.
scaauthuserdeviceDescCreatedAt := scaauthuserdeviceMixinFields0[0].Descriptor()
@@ -209,10 +209,10 @@ func init() {
scaauthuserdeviceDescEngineVersion := scaauthuserdeviceFields[13].Descriptor()
// scaauthuserdevice.EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save.
scaauthuserdevice.EngineVersionValidator = scaauthuserdeviceDescEngineVersion.Validators[0].(func(string) error)
scaauthusersocialMixin := schema.ScaAuthUserSocial{}.Mixin()
scaauthusersocialMixin := model.ScaAuthUserSocial{}.Mixin()
scaauthusersocialMixinFields0 := scaauthusersocialMixin[0].Fields()
_ = scaauthusersocialMixinFields0
scaauthusersocialFields := schema.ScaAuthUserSocial{}.Fields()
scaauthusersocialFields := model.ScaAuthUserSocial{}.Fields()
_ = scaauthusersocialFields
// scaauthusersocialDescCreatedAt is the schema descriptor for created_at field.
scaauthusersocialDescCreatedAt := scaauthusersocialMixinFields0[0].Descriptor()

View File

@@ -2,7 +2,7 @@
package runtime
// The schema-stitching logic is generated in schisandra-album-cloud-microservices/app/main/api/repository/mysql/ent/runtime.go
// The schema-stitching logic is generated in schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/runtime.go
const (
Version = "v0.14.1" // Version of ent codegen.

View File

@@ -40,9 +40,9 @@ type ScaAuthUserDevice struct {
// 浏览器版本
BrowserVersion string `json:"browser_version,omitempty"`
// 是否为手机 0否1是
Mobile int `json:"mobile,omitempty"`
Mobile bool `json:"mobile,omitempty"`
// 是否为bot 0否1是
Bot int `json:"bot,omitempty"`
Bot bool `json:"bot,omitempty"`
// 火狐版本
Mozilla string `json:"mozilla,omitempty"`
// 平台
@@ -83,7 +83,9 @@ func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthuserdevice.FieldID, scaauthuserdevice.FieldDeleted, scaauthuserdevice.FieldMobile, scaauthuserdevice.FieldBot:
case scaauthuserdevice.FieldMobile, scaauthuserdevice.FieldBot:
values[i] = new(sql.NullBool)
case scaauthuserdevice.FieldID, scaauthuserdevice.FieldDeleted:
values[i] = new(sql.NullInt64)
case scaauthuserdevice.FieldUserID, scaauthuserdevice.FieldIP, scaauthuserdevice.FieldLocation, scaauthuserdevice.FieldAgent, scaauthuserdevice.FieldBrowser, scaauthuserdevice.FieldOperatingSystem, scaauthuserdevice.FieldBrowserVersion, scaauthuserdevice.FieldMozilla, scaauthuserdevice.FieldPlatform, scaauthuserdevice.FieldEngineName, scaauthuserdevice.FieldEngineVersion:
values[i] = new(sql.NullString)
@@ -173,16 +175,16 @@ func (saud *ScaAuthUserDevice) assignValues(columns []string, values []any) erro
saud.BrowserVersion = value.String
}
case scaauthuserdevice.FieldMobile:
if value, ok := values[i].(*sql.NullInt64); !ok {
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field mobile", values[i])
} else if value.Valid {
saud.Mobile = int(value.Int64)
saud.Mobile = value.Bool
}
case scaauthuserdevice.FieldBot:
if value, ok := values[i].(*sql.NullInt64); !ok {
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field bot", values[i])
} else if value.Valid {
saud.Bot = int(value.Int64)
saud.Bot = value.Bool
}
case scaauthuserdevice.FieldMozilla:
if value, ok := values[i].(*sql.NullString); !ok {

View File

@@ -106,12 +106,12 @@ func BrowserVersion(v string) predicate.ScaAuthUserDevice {
}
// Mobile applies equality check predicate on the "mobile" field. It's identical to MobileEQ.
func Mobile(v int) predicate.ScaAuthUserDevice {
func Mobile(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMobile, v))
}
// Bot applies equality check predicate on the "bot" field. It's identical to BotEQ.
func Bot(v int) predicate.ScaAuthUserDevice {
func Bot(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBot, v))
}
@@ -721,85 +721,25 @@ func BrowserVersionContainsFold(v string) predicate.ScaAuthUserDevice {
}
// MobileEQ applies the EQ predicate on the "mobile" field.
func MobileEQ(v int) predicate.ScaAuthUserDevice {
func MobileEQ(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMobile, v))
}
// MobileNEQ applies the NEQ predicate on the "mobile" field.
func MobileNEQ(v int) predicate.ScaAuthUserDevice {
func MobileNEQ(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldMobile, v))
}
// MobileIn applies the In predicate on the "mobile" field.
func MobileIn(vs ...int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldIn(FieldMobile, vs...))
}
// MobileNotIn applies the NotIn predicate on the "mobile" field.
func MobileNotIn(vs ...int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldMobile, vs...))
}
// MobileGT applies the GT predicate on the "mobile" field.
func MobileGT(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldGT(FieldMobile, v))
}
// MobileGTE applies the GTE predicate on the "mobile" field.
func MobileGTE(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldMobile, v))
}
// MobileLT applies the LT predicate on the "mobile" field.
func MobileLT(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldLT(FieldMobile, v))
}
// MobileLTE applies the LTE predicate on the "mobile" field.
func MobileLTE(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldMobile, v))
}
// BotEQ applies the EQ predicate on the "bot" field.
func BotEQ(v int) predicate.ScaAuthUserDevice {
func BotEQ(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBot, v))
}
// BotNEQ applies the NEQ predicate on the "bot" field.
func BotNEQ(v int) predicate.ScaAuthUserDevice {
func BotNEQ(v bool) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldBot, v))
}
// BotIn applies the In predicate on the "bot" field.
func BotIn(vs ...int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldIn(FieldBot, vs...))
}
// BotNotIn applies the NotIn predicate on the "bot" field.
func BotNotIn(vs ...int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldBot, vs...))
}
// BotGT applies the GT predicate on the "bot" field.
func BotGT(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldGT(FieldBot, v))
}
// BotGTE applies the GTE predicate on the "bot" field.
func BotGTE(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldBot, v))
}
// BotLT applies the LT predicate on the "bot" field.
func BotLT(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldLT(FieldBot, v))
}
// BotLTE applies the LTE predicate on the "bot" field.
func BotLTE(v int) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldBot, v))
}
// MozillaEQ applies the EQ predicate on the "mozilla" field.
func MozillaEQ(v string) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMozilla, v))

View File

@@ -106,14 +106,14 @@ func (saudc *ScaAuthUserDeviceCreate) SetBrowserVersion(s string) *ScaAuthUserDe
}
// SetMobile sets the "mobile" field.
func (saudc *ScaAuthUserDeviceCreate) SetMobile(i int) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMobile(i)
func (saudc *ScaAuthUserDeviceCreate) SetMobile(b bool) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMobile(b)
return saudc
}
// SetBot sets the "bot" field.
func (saudc *ScaAuthUserDeviceCreate) SetBot(i int) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBot(i)
func (saudc *ScaAuthUserDeviceCreate) SetBot(b bool) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBot(b)
return saudc
}
@@ -395,11 +395,11 @@ func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgrap
_node.BrowserVersion = value
}
if value, ok := saudc.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
_node.Mobile = value
}
if value, ok := saudc.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
_node.Bot = value
}
if value, ok := saudc.mutation.Mozilla(); ok {

View File

@@ -161,47 +161,33 @@ func (saudu *ScaAuthUserDeviceUpdate) SetNillableBrowserVersion(s *string) *ScaA
}
// SetMobile sets the "mobile" field.
func (saudu *ScaAuthUserDeviceUpdate) SetMobile(i int) *ScaAuthUserDeviceUpdate {
saudu.mutation.ResetMobile()
saudu.mutation.SetMobile(i)
func (saudu *ScaAuthUserDeviceUpdate) SetMobile(b bool) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetMobile(b)
return saudu
}
// SetNillableMobile sets the "mobile" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableMobile(i *int) *ScaAuthUserDeviceUpdate {
if i != nil {
saudu.SetMobile(*i)
func (saudu *ScaAuthUserDeviceUpdate) SetNillableMobile(b *bool) *ScaAuthUserDeviceUpdate {
if b != nil {
saudu.SetMobile(*b)
}
return saudu
}
// AddMobile adds i to the "mobile" field.
func (saudu *ScaAuthUserDeviceUpdate) AddMobile(i int) *ScaAuthUserDeviceUpdate {
saudu.mutation.AddMobile(i)
return saudu
}
// SetBot sets the "bot" field.
func (saudu *ScaAuthUserDeviceUpdate) SetBot(i int) *ScaAuthUserDeviceUpdate {
saudu.mutation.ResetBot()
saudu.mutation.SetBot(i)
func (saudu *ScaAuthUserDeviceUpdate) SetBot(b bool) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetBot(b)
return saudu
}
// SetNillableBot sets the "bot" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableBot(i *int) *ScaAuthUserDeviceUpdate {
if i != nil {
saudu.SetBot(*i)
func (saudu *ScaAuthUserDeviceUpdate) SetNillableBot(b *bool) *ScaAuthUserDeviceUpdate {
if b != nil {
saudu.SetBot(*b)
}
return saudu
}
// AddBot adds i to the "bot" field.
func (saudu *ScaAuthUserDeviceUpdate) AddBot(i int) *ScaAuthUserDeviceUpdate {
saudu.mutation.AddBot(i)
return saudu
}
// SetMozilla sets the "mozilla" field.
func (saudu *ScaAuthUserDeviceUpdate) SetMozilla(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetMozilla(s)
@@ -435,16 +421,10 @@ func (saudu *ScaAuthUserDeviceUpdate) sqlSave(ctx context.Context) (n int, err e
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
}
if value, ok := saudu.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
}
if value, ok := saudu.mutation.AddedMobile(); ok {
_spec.AddField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
}
if value, ok := saudu.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value)
}
if value, ok := saudu.mutation.AddedBot(); ok {
_spec.AddField(scaauthuserdevice.FieldBot, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
}
if value, ok := saudu.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)
@@ -639,47 +619,33 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBrowserVersion(s *string) *
}
// SetMobile sets the "mobile" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetMobile(i int) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.ResetMobile()
sauduo.mutation.SetMobile(i)
func (sauduo *ScaAuthUserDeviceUpdateOne) SetMobile(b bool) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetMobile(b)
return sauduo
}
// SetNillableMobile sets the "mobile" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMobile(i *int) *ScaAuthUserDeviceUpdateOne {
if i != nil {
sauduo.SetMobile(*i)
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMobile(b *bool) *ScaAuthUserDeviceUpdateOne {
if b != nil {
sauduo.SetMobile(*b)
}
return sauduo
}
// AddMobile adds i to the "mobile" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) AddMobile(i int) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.AddMobile(i)
return sauduo
}
// SetBot sets the "bot" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetBot(i int) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.ResetBot()
sauduo.mutation.SetBot(i)
func (sauduo *ScaAuthUserDeviceUpdateOne) SetBot(b bool) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetBot(b)
return sauduo
}
// SetNillableBot sets the "bot" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBot(i *int) *ScaAuthUserDeviceUpdateOne {
if i != nil {
sauduo.SetBot(*i)
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBot(b *bool) *ScaAuthUserDeviceUpdateOne {
if b != nil {
sauduo.SetBot(*b)
}
return sauduo
}
// AddBot adds i to the "bot" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) AddBot(i int) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.AddBot(i)
return sauduo
}
// SetMozilla sets the "mozilla" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetMozilla(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetMozilla(s)
@@ -943,16 +909,10 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) sqlSave(ctx context.Context) (_node *S
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
}
if value, ok := sauduo.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
}
if value, ok := sauduo.mutation.AddedMobile(); ok {
_spec.AddField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
}
if value, ok := sauduo.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value)
}
if value, ok := sauduo.mutation.AddedBot(); ok {
_spec.AddField(scaauthuserdevice.FieldBot, field.TypeInt, value)
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
}
if value, ok := sauduo.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)

View File

@@ -1,3 +1,3 @@
package mysql
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature privacy,entql --target ./ent ./schema
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature privacy,entql --target ./ent ./model

View File

@@ -29,7 +29,7 @@ func NewMySQL(url string) *ent.Client {
defer client.Close()
if err = client.Schema.Create(context.Background()); err != nil {
log.Panicf("failed creating schema resources: %v", err)
log.Panicf("failed creating model resources: %v", err)
}
return client
}

View File

@@ -1,4 +1,4 @@
package schema
package model
import (
"entgo.io/ent"
@@ -9,7 +9,7 @@ import (
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRule holds the schema definition for the ScaAuthPermissionRule entity.
// ScaAuthPermissionRule holds the model definition for the ScaAuthPermissionRule entity.
type ScaAuthPermissionRule struct {
ent.Schema
}

View File

@@ -1,4 +1,4 @@
package schema
package model
import (
"entgo.io/ent"
@@ -8,10 +8,10 @@ import (
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/schema/mixin"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
)
// ScaAuthRole holds the schema definition for the ScaAuthRole entity.
// ScaAuthRole holds the model definition for the ScaAuthRole entity.
type ScaAuthRole struct {
ent.Schema
}

View File

@@ -1,4 +1,4 @@
package schema
package model
import (
"entgo.io/ent"
@@ -9,10 +9,10 @@ import (
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/schema/mixin"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
)
// ScaAuthUser holds the schema definition for the ScaAuthUser entity.
// ScaAuthUser holds the model definition for the ScaAuthUser entity.
type ScaAuthUser struct {
ent.Schema
}

View File

@@ -1,4 +1,4 @@
package schema
package model
import (
"entgo.io/ent"
@@ -9,10 +9,10 @@ import (
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/schema/mixin"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
)
// ScaAuthUserDevice holds the schema definition for the ScaAuthUserDevice entity.
// ScaAuthUserDevice holds the model definition for the ScaAuthUserDevice entity.
type ScaAuthUserDevice struct {
ent.Schema
}
@@ -53,9 +53,9 @@ func (ScaAuthUserDevice) Fields() []ent.Field {
field.String("browser_version").
MaxLen(20).
Comment("浏览器版本"),
field.Int("mobile").
field.Bool("mobile").
Comment("是否为手机 0否1是"),
field.Int("bot").
field.Bool("bot").
Comment("是否为bot 0否1是"),
field.String("mozilla").
MaxLen(10).

View File

@@ -1,4 +1,4 @@
package schema
package model
import (
"entgo.io/ent"
@@ -9,10 +9,10 @@ import (
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/schema/mixin"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
)
// ScaAuthUserSocial holds the schema definition for the ScaAuthUserSocial entity.
// ScaAuthUserSocial holds the model definition for the ScaAuthUserSocial entity.
type ScaAuthUserSocial struct {
ent.Schema
}

View File

@@ -0,0 +1,38 @@
package redis_session
import (
"context"
"encoding/gob"
"net/http"
"github.com/gorilla/sessions"
"github.com/rbcervilla/redisstore/v9"
"github.com/redis/go-redis/v9"
"github.com/zeromicro/go-zero/core/logc"
"schisandra-album-cloud-microservices/app/core/api/common/constant"
"schisandra-album-cloud-microservices/app/core/api/repository/redis_session/types"
)
func NewRedisSession(addr string, password string) *redisstore.RedisStore {
client := redis.NewClient(&redis.Options{
Addr: addr,
Password: password,
DB: 0,
})
store, err := redisstore.NewRedisStore(context.Background(), client)
if err != nil {
logc.Error(context.Background(), err)
}
store.KeyPrefix(constant.UserSessionPrefix)
store.Options(sessions.Options{
Path: "/",
// Domain: global.CONFIG.System.Web,
MaxAge: 86400 * 7,
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
})
gob.Register(types.SessionData{})
return store
}

View File

@@ -0,0 +1,7 @@
package types
// SessionData 返回数据
type SessionData struct {
RefreshToken string `json:"refresh_token"`
UID string `json:"uid"`
}

View File

@@ -0,0 +1,12 @@
package redisx
import "github.com/redis/go-redis/v9"
func NewRedis(host, password string, db int) *redis.Client {
rdb := redis.NewClient(&redis.Options{
Addr: host,
Password: password,
DB: db,
})
return rdb
}

View File

@@ -0,0 +1,6 @@
package types
type RedisToken struct {
AccessToken string `json:"access_token"`
UID string `json:"uid"`
}