Переглянути джерело

feat: 添加设备地图表及系统设置表gen文件

HeWang 8 місяців тому
батько
коміт
8e04caa920

+ 474 - 0
biz/dal/query/device_map.gen.go

@@ -0,0 +1,474 @@
+// 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"
+
+	"gorm.io/gorm"
+	"gorm.io/gorm/clause"
+	"gorm.io/gorm/schema"
+
+	"gorm.io/gen"
+	"gorm.io/gen/field"
+
+	"gorm.io/plugin/dbresolver"
+
+	"pji_desktop_http/biz/model"
+)
+
+func newDeviceMap(db *gorm.DB, opts ...gen.DOOption) deviceMap {
+	_deviceMap := deviceMap{}
+
+	_deviceMap.deviceMapDo.UseDB(db, opts...)
+	_deviceMap.deviceMapDo.UseModel(&model.DeviceMap{})
+
+	tableName := _deviceMap.deviceMapDo.TableName()
+	_deviceMap.ALL = field.NewAsterisk(tableName)
+	_deviceMap.ID = field.NewString(tableName, "id")
+	_deviceMap.DeviceID = field.NewString(tableName, "device_id")
+	_deviceMap.DeviceNo = field.NewString(tableName, "device_no")
+	_deviceMap.DeviceName = field.NewString(tableName, "device_name")
+	_deviceMap.DeviceType = field.NewString(tableName, "device_type")
+	_deviceMap.MapID = field.NewString(tableName, "map_id")
+	_deviceMap.MapType = field.NewString(tableName, "map_type")
+	_deviceMap.MapName = field.NewString(tableName, "map_name")
+	_deviceMap.FloorID = field.NewString(tableName, "floor_id")
+	_deviceMap.Floor = field.NewString(tableName, "floor")
+	_deviceMap.BuildID = field.NewString(tableName, "build_id")
+	_deviceMap.BuildName = field.NewString(tableName, "build_name")
+	_deviceMap.MapCreateTime = field.NewString(tableName, "map_create_time")
+	_deviceMap.MapUpdateTime = field.NewString(tableName, "map_update_time")
+	_deviceMap.MapVersion = field.NewInt32(tableName, "map_version")
+	_deviceMap.MapValidFlag = field.NewInt32(tableName, "map_valid_flag")
+	_deviceMap.PjiMapZipURL = field.NewString(tableName, "pji_map_zip_url")
+	_deviceMap.CicvMapZipURL = field.NewString(tableName, "cicv_map_zip_url")
+	_deviceMap.CustomAreaID = field.NewInt32(tableName, "custom_area_id")
+	_deviceMap.CreatedAt = field.NewTime(tableName, "created_at")
+	_deviceMap.UpdatedAt = field.NewTime(tableName, "updated_at")
+	_deviceMap.DeletedAt = field.NewField(tableName, "deleted_at")
+
+	_deviceMap.fillFieldMap()
+
+	return _deviceMap
+}
+
+type deviceMap struct {
+	deviceMapDo deviceMapDo
+
+	ALL           field.Asterisk
+	ID            field.String
+	DeviceID      field.String
+	DeviceNo      field.String
+	DeviceName    field.String
+	DeviceType    field.String
+	MapID         field.String
+	MapType       field.String
+	MapName       field.String
+	FloorID       field.String
+	Floor         field.String
+	BuildID       field.String
+	BuildName     field.String
+	MapCreateTime field.String
+	MapUpdateTime field.String
+	MapVersion    field.Int32
+	MapValidFlag  field.Int32
+	PjiMapZipURL  field.String
+	CicvMapZipURL field.String
+	CustomAreaID  field.Int32
+	CreatedAt     field.Time
+	UpdatedAt     field.Time
+	DeletedAt     field.Field
+
+	fieldMap map[string]field.Expr
+}
+
+func (d deviceMap) Table(newTableName string) *deviceMap {
+	d.deviceMapDo.UseTable(newTableName)
+	return d.updateTableName(newTableName)
+}
+
+func (d deviceMap) As(alias string) *deviceMap {
+	d.deviceMapDo.DO = *(d.deviceMapDo.As(alias).(*gen.DO))
+	return d.updateTableName(alias)
+}
+
+func (d *deviceMap) updateTableName(table string) *deviceMap {
+	d.ALL = field.NewAsterisk(table)
+	d.ID = field.NewString(table, "id")
+	d.DeviceID = field.NewString(table, "device_id")
+	d.DeviceNo = field.NewString(table, "device_no")
+	d.DeviceName = field.NewString(table, "device_name")
+	d.DeviceType = field.NewString(table, "device_type")
+	d.MapID = field.NewString(table, "map_id")
+	d.MapType = field.NewString(table, "map_type")
+	d.MapName = field.NewString(table, "map_name")
+	d.FloorID = field.NewString(table, "floor_id")
+	d.Floor = field.NewString(table, "floor")
+	d.BuildID = field.NewString(table, "build_id")
+	d.BuildName = field.NewString(table, "build_name")
+	d.MapCreateTime = field.NewString(table, "map_create_time")
+	d.MapUpdateTime = field.NewString(table, "map_update_time")
+	d.MapVersion = field.NewInt32(table, "map_version")
+	d.MapValidFlag = field.NewInt32(table, "map_valid_flag")
+	d.PjiMapZipURL = field.NewString(table, "pji_map_zip_url")
+	d.CicvMapZipURL = field.NewString(table, "cicv_map_zip_url")
+	d.CustomAreaID = field.NewInt32(table, "custom_area_id")
+	d.CreatedAt = field.NewTime(table, "created_at")
+	d.UpdatedAt = field.NewTime(table, "updated_at")
+	d.DeletedAt = field.NewField(table, "deleted_at")
+
+	d.fillFieldMap()
+
+	return d
+}
+
+func (d *deviceMap) WithContext(ctx context.Context) IDeviceMapDo {
+	return d.deviceMapDo.WithContext(ctx)
+}
+
+func (d deviceMap) TableName() string { return d.deviceMapDo.TableName() }
+
+func (d deviceMap) Alias() string { return d.deviceMapDo.Alias() }
+
+func (d deviceMap) Columns(cols ...field.Expr) gen.Columns { return d.deviceMapDo.Columns(cols...) }
+
+func (d *deviceMap) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+	_f, ok := d.fieldMap[fieldName]
+	if !ok || _f == nil {
+		return nil, false
+	}
+	_oe, ok := _f.(field.OrderExpr)
+	return _oe, ok
+}
+
+func (d *deviceMap) fillFieldMap() {
+	d.fieldMap = make(map[string]field.Expr, 22)
+	d.fieldMap["id"] = d.ID
+	d.fieldMap["device_id"] = d.DeviceID
+	d.fieldMap["device_no"] = d.DeviceNo
+	d.fieldMap["device_name"] = d.DeviceName
+	d.fieldMap["device_type"] = d.DeviceType
+	d.fieldMap["map_id"] = d.MapID
+	d.fieldMap["map_type"] = d.MapType
+	d.fieldMap["map_name"] = d.MapName
+	d.fieldMap["floor_id"] = d.FloorID
+	d.fieldMap["floor"] = d.Floor
+	d.fieldMap["build_id"] = d.BuildID
+	d.fieldMap["build_name"] = d.BuildName
+	d.fieldMap["map_create_time"] = d.MapCreateTime
+	d.fieldMap["map_update_time"] = d.MapUpdateTime
+	d.fieldMap["map_version"] = d.MapVersion
+	d.fieldMap["map_valid_flag"] = d.MapValidFlag
+	d.fieldMap["pji_map_zip_url"] = d.PjiMapZipURL
+	d.fieldMap["cicv_map_zip_url"] = d.CicvMapZipURL
+	d.fieldMap["custom_area_id"] = d.CustomAreaID
+	d.fieldMap["created_at"] = d.CreatedAt
+	d.fieldMap["updated_at"] = d.UpdatedAt
+	d.fieldMap["deleted_at"] = d.DeletedAt
+}
+
+func (d deviceMap) clone(db *gorm.DB) deviceMap {
+	d.deviceMapDo.ReplaceConnPool(db.Statement.ConnPool)
+	return d
+}
+
+func (d deviceMap) replaceDB(db *gorm.DB) deviceMap {
+	d.deviceMapDo.ReplaceDB(db)
+	return d
+}
+
+type deviceMapDo struct{ gen.DO }
+
+type IDeviceMapDo interface {
+	gen.SubQuery
+	Debug() IDeviceMapDo
+	WithContext(ctx context.Context) IDeviceMapDo
+	WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+	ReplaceDB(db *gorm.DB)
+	ReadDB() IDeviceMapDo
+	WriteDB() IDeviceMapDo
+	As(alias string) gen.Dao
+	Session(config *gorm.Session) IDeviceMapDo
+	Columns(cols ...field.Expr) gen.Columns
+	Clauses(conds ...clause.Expression) IDeviceMapDo
+	Not(conds ...gen.Condition) IDeviceMapDo
+	Or(conds ...gen.Condition) IDeviceMapDo
+	Select(conds ...field.Expr) IDeviceMapDo
+	Where(conds ...gen.Condition) IDeviceMapDo
+	Order(conds ...field.Expr) IDeviceMapDo
+	Distinct(cols ...field.Expr) IDeviceMapDo
+	Omit(cols ...field.Expr) IDeviceMapDo
+	Join(table schema.Tabler, on ...field.Expr) IDeviceMapDo
+	LeftJoin(table schema.Tabler, on ...field.Expr) IDeviceMapDo
+	RightJoin(table schema.Tabler, on ...field.Expr) IDeviceMapDo
+	Group(cols ...field.Expr) IDeviceMapDo
+	Having(conds ...gen.Condition) IDeviceMapDo
+	Limit(limit int) IDeviceMapDo
+	Offset(offset int) IDeviceMapDo
+	Count() (count int64, err error)
+	Scopes(funcs ...func(gen.Dao) gen.Dao) IDeviceMapDo
+	Unscoped() IDeviceMapDo
+	Create(values ...*model.DeviceMap) error
+	CreateInBatches(values []*model.DeviceMap, batchSize int) error
+	Save(values ...*model.DeviceMap) error
+	First() (*model.DeviceMap, error)
+	Take() (*model.DeviceMap, error)
+	Last() (*model.DeviceMap, error)
+	Find() ([]*model.DeviceMap, error)
+	FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DeviceMap, err error)
+	FindInBatches(result *[]*model.DeviceMap, batchSize int, fc func(tx gen.Dao, batch int) error) error
+	Pluck(column field.Expr, dest interface{}) error
+	Delete(...*model.DeviceMap) (info gen.ResultInfo, err error)
+	Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+	UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+	Updates(value interface{}) (info gen.ResultInfo, err error)
+	UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+	UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+	UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+	UpdateFrom(q gen.SubQuery) gen.Dao
+	Attrs(attrs ...field.AssignExpr) IDeviceMapDo
+	Assign(attrs ...field.AssignExpr) IDeviceMapDo
+	Joins(fields ...field.RelationField) IDeviceMapDo
+	Preload(fields ...field.RelationField) IDeviceMapDo
+	FirstOrInit() (*model.DeviceMap, error)
+	FirstOrCreate() (*model.DeviceMap, error)
+	FindByPage(offset int, limit int) (result []*model.DeviceMap, count int64, err error)
+	ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+	Scan(result interface{}) (err error)
+	Returning(value interface{}, columns ...string) IDeviceMapDo
+	UnderlyingDB() *gorm.DB
+	schema.Tabler
+}
+
+func (d deviceMapDo) Debug() IDeviceMapDo {
+	return d.withDO(d.DO.Debug())
+}
+
+func (d deviceMapDo) WithContext(ctx context.Context) IDeviceMapDo {
+	return d.withDO(d.DO.WithContext(ctx))
+}
+
+func (d deviceMapDo) ReadDB() IDeviceMapDo {
+	return d.Clauses(dbresolver.Read)
+}
+
+func (d deviceMapDo) WriteDB() IDeviceMapDo {
+	return d.Clauses(dbresolver.Write)
+}
+
+func (d deviceMapDo) Session(config *gorm.Session) IDeviceMapDo {
+	return d.withDO(d.DO.Session(config))
+}
+
+func (d deviceMapDo) Clauses(conds ...clause.Expression) IDeviceMapDo {
+	return d.withDO(d.DO.Clauses(conds...))
+}
+
+func (d deviceMapDo) Returning(value interface{}, columns ...string) IDeviceMapDo {
+	return d.withDO(d.DO.Returning(value, columns...))
+}
+
+func (d deviceMapDo) Not(conds ...gen.Condition) IDeviceMapDo {
+	return d.withDO(d.DO.Not(conds...))
+}
+
+func (d deviceMapDo) Or(conds ...gen.Condition) IDeviceMapDo {
+	return d.withDO(d.DO.Or(conds...))
+}
+
+func (d deviceMapDo) Select(conds ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Select(conds...))
+}
+
+func (d deviceMapDo) Where(conds ...gen.Condition) IDeviceMapDo {
+	return d.withDO(d.DO.Where(conds...))
+}
+
+func (d deviceMapDo) Order(conds ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Order(conds...))
+}
+
+func (d deviceMapDo) Distinct(cols ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Distinct(cols...))
+}
+
+func (d deviceMapDo) Omit(cols ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Omit(cols...))
+}
+
+func (d deviceMapDo) Join(table schema.Tabler, on ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Join(table, on...))
+}
+
+func (d deviceMapDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.LeftJoin(table, on...))
+}
+
+func (d deviceMapDo) RightJoin(table schema.Tabler, on ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.RightJoin(table, on...))
+}
+
+func (d deviceMapDo) Group(cols ...field.Expr) IDeviceMapDo {
+	return d.withDO(d.DO.Group(cols...))
+}
+
+func (d deviceMapDo) Having(conds ...gen.Condition) IDeviceMapDo {
+	return d.withDO(d.DO.Having(conds...))
+}
+
+func (d deviceMapDo) Limit(limit int) IDeviceMapDo {
+	return d.withDO(d.DO.Limit(limit))
+}
+
+func (d deviceMapDo) Offset(offset int) IDeviceMapDo {
+	return d.withDO(d.DO.Offset(offset))
+}
+
+func (d deviceMapDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDeviceMapDo {
+	return d.withDO(d.DO.Scopes(funcs...))
+}
+
+func (d deviceMapDo) Unscoped() IDeviceMapDo {
+	return d.withDO(d.DO.Unscoped())
+}
+
+func (d deviceMapDo) Create(values ...*model.DeviceMap) error {
+	if len(values) == 0 {
+		return nil
+	}
+	return d.DO.Create(values)
+}
+
+func (d deviceMapDo) CreateInBatches(values []*model.DeviceMap, batchSize int) error {
+	return d.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 (d deviceMapDo) Save(values ...*model.DeviceMap) error {
+	if len(values) == 0 {
+		return nil
+	}
+	return d.DO.Save(values)
+}
+
+func (d deviceMapDo) First() (*model.DeviceMap, error) {
+	if result, err := d.DO.First(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.DeviceMap), nil
+	}
+}
+
+func (d deviceMapDo) Take() (*model.DeviceMap, error) {
+	if result, err := d.DO.Take(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.DeviceMap), nil
+	}
+}
+
+func (d deviceMapDo) Last() (*model.DeviceMap, error) {
+	if result, err := d.DO.Last(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.DeviceMap), nil
+	}
+}
+
+func (d deviceMapDo) Find() ([]*model.DeviceMap, error) {
+	result, err := d.DO.Find()
+	return result.([]*model.DeviceMap), err
+}
+
+func (d deviceMapDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DeviceMap, err error) {
+	buf := make([]*model.DeviceMap, 0, batchSize)
+	err = d.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 (d deviceMapDo) FindInBatches(result *[]*model.DeviceMap, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+	return d.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (d deviceMapDo) Attrs(attrs ...field.AssignExpr) IDeviceMapDo {
+	return d.withDO(d.DO.Attrs(attrs...))
+}
+
+func (d deviceMapDo) Assign(attrs ...field.AssignExpr) IDeviceMapDo {
+	return d.withDO(d.DO.Assign(attrs...))
+}
+
+func (d deviceMapDo) Joins(fields ...field.RelationField) IDeviceMapDo {
+	for _, _f := range fields {
+		d = *d.withDO(d.DO.Joins(_f))
+	}
+	return &d
+}
+
+func (d deviceMapDo) Preload(fields ...field.RelationField) IDeviceMapDo {
+	for _, _f := range fields {
+		d = *d.withDO(d.DO.Preload(_f))
+	}
+	return &d
+}
+
+func (d deviceMapDo) FirstOrInit() (*model.DeviceMap, error) {
+	if result, err := d.DO.FirstOrInit(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.DeviceMap), nil
+	}
+}
+
+func (d deviceMapDo) FirstOrCreate() (*model.DeviceMap, error) {
+	if result, err := d.DO.FirstOrCreate(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.DeviceMap), nil
+	}
+}
+
+func (d deviceMapDo) FindByPage(offset int, limit int) (result []*model.DeviceMap, count int64, err error) {
+	result, err = d.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 = d.Offset(-1).Limit(-1).Count()
+	return
+}
+
+func (d deviceMapDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+	count, err = d.Count()
+	if err != nil {
+		return
+	}
+
+	err = d.Offset(offset).Limit(limit).Scan(result)
+	return
+}
+
+func (d deviceMapDo) Scan(result interface{}) (err error) {
+	return d.DO.Scan(result)
+}
+
+func (d deviceMapDo) Delete(models ...*model.DeviceMap) (result gen.ResultInfo, err error) {
+	return d.DO.Delete(models)
+}
+
+func (d *deviceMapDo) withDO(do gen.Dao) *deviceMapDo {
+	d.DO = *do.(*gen.DO)
+	return d
+}

+ 16 - 0
biz/dal/query/gen.go

@@ -17,23 +17,29 @@ import (
 
 var (
 	Q                    = new(Query)
+	DeviceMap            *deviceMap
 	MapUpdate            *mapUpdate
 	SimulationTestRecord *simulationTestRecord
+	SystemConfig         *systemConfig
 	World                *world
 )
 
 func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
 	*Q = *Use(db, opts...)
+	DeviceMap = &Q.DeviceMap
 	MapUpdate = &Q.MapUpdate
 	SimulationTestRecord = &Q.SimulationTestRecord
+	SystemConfig = &Q.SystemConfig
 	World = &Q.World
 }
 
 func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
 	return &Query{
 		db:                   db,
+		DeviceMap:            newDeviceMap(db, opts...),
 		MapUpdate:            newMapUpdate(db, opts...),
 		SimulationTestRecord: newSimulationTestRecord(db, opts...),
+		SystemConfig:         newSystemConfig(db, opts...),
 		World:                newWorld(db, opts...),
 	}
 }
@@ -41,8 +47,10 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
 type Query struct {
 	db *gorm.DB
 
+	DeviceMap            deviceMap
 	MapUpdate            mapUpdate
 	SimulationTestRecord simulationTestRecord
+	SystemConfig         systemConfig
 	World                world
 }
 
@@ -51,8 +59,10 @@ func (q *Query) Available() bool { return q.db != nil }
 func (q *Query) clone(db *gorm.DB) *Query {
 	return &Query{
 		db:                   db,
+		DeviceMap:            q.DeviceMap.clone(db),
 		MapUpdate:            q.MapUpdate.clone(db),
 		SimulationTestRecord: q.SimulationTestRecord.clone(db),
+		SystemConfig:         q.SystemConfig.clone(db),
 		World:                q.World.clone(db),
 	}
 }
@@ -68,22 +78,28 @@ func (q *Query) WriteDB() *Query {
 func (q *Query) ReplaceDB(db *gorm.DB) *Query {
 	return &Query{
 		db:                   db,
+		DeviceMap:            q.DeviceMap.replaceDB(db),
 		MapUpdate:            q.MapUpdate.replaceDB(db),
 		SimulationTestRecord: q.SimulationTestRecord.replaceDB(db),
+		SystemConfig:         q.SystemConfig.replaceDB(db),
 		World:                q.World.replaceDB(db),
 	}
 }
 
 type queryCtx struct {
+	DeviceMap            IDeviceMapDo
 	MapUpdate            IMapUpdateDo
 	SimulationTestRecord ISimulationTestRecordDo
+	SystemConfig         ISystemConfigDo
 	World                IWorldDo
 }
 
 func (q *Query) WithContext(ctx context.Context) *queryCtx {
 	return &queryCtx{
+		DeviceMap:            q.DeviceMap.WithContext(ctx),
 		MapUpdate:            q.MapUpdate.WithContext(ctx),
 		SimulationTestRecord: q.SimulationTestRecord.WithContext(ctx),
+		SystemConfig:         q.SystemConfig.WithContext(ctx),
 		World:                q.World.WithContext(ctx),
 	}
 }

+ 404 - 0
biz/dal/query/system_config.gen.go

@@ -0,0 +1,404 @@
+// 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"
+
+	"gorm.io/gorm"
+	"gorm.io/gorm/clause"
+	"gorm.io/gorm/schema"
+
+	"gorm.io/gen"
+	"gorm.io/gen/field"
+
+	"gorm.io/plugin/dbresolver"
+
+	"pji_desktop_http/biz/model"
+)
+
+func newSystemConfig(db *gorm.DB, opts ...gen.DOOption) systemConfig {
+	_systemConfig := systemConfig{}
+
+	_systemConfig.systemConfigDo.UseDB(db, opts...)
+	_systemConfig.systemConfigDo.UseModel(&model.SystemConfig{})
+
+	tableName := _systemConfig.systemConfigDo.TableName()
+	_systemConfig.ALL = field.NewAsterisk(tableName)
+	_systemConfig.RescanReminderThreshold = field.NewFloat32(tableName, "rescan_reminder_threshold")
+	_systemConfig.CreatedAt = field.NewTime(tableName, "created_at")
+	_systemConfig.UpdatedAt = field.NewTime(tableName, "updated_at")
+	_systemConfig.DeletedAt = field.NewField(tableName, "deleted_at")
+
+	_systemConfig.fillFieldMap()
+
+	return _systemConfig
+}
+
+type systemConfig struct {
+	systemConfigDo systemConfigDo
+
+	ALL                     field.Asterisk
+	RescanReminderThreshold field.Float32
+	CreatedAt               field.Time
+	UpdatedAt               field.Time
+	DeletedAt               field.Field
+
+	fieldMap map[string]field.Expr
+}
+
+func (s systemConfig) Table(newTableName string) *systemConfig {
+	s.systemConfigDo.UseTable(newTableName)
+	return s.updateTableName(newTableName)
+}
+
+func (s systemConfig) As(alias string) *systemConfig {
+	s.systemConfigDo.DO = *(s.systemConfigDo.As(alias).(*gen.DO))
+	return s.updateTableName(alias)
+}
+
+func (s *systemConfig) updateTableName(table string) *systemConfig {
+	s.ALL = field.NewAsterisk(table)
+	s.RescanReminderThreshold = field.NewFloat32(table, "rescan_reminder_threshold")
+	s.CreatedAt = field.NewTime(table, "created_at")
+	s.UpdatedAt = field.NewTime(table, "updated_at")
+	s.DeletedAt = field.NewField(table, "deleted_at")
+
+	s.fillFieldMap()
+
+	return s
+}
+
+func (s *systemConfig) WithContext(ctx context.Context) ISystemConfigDo {
+	return s.systemConfigDo.WithContext(ctx)
+}
+
+func (s systemConfig) TableName() string { return s.systemConfigDo.TableName() }
+
+func (s systemConfig) Alias() string { return s.systemConfigDo.Alias() }
+
+func (s systemConfig) Columns(cols ...field.Expr) gen.Columns {
+	return s.systemConfigDo.Columns(cols...)
+}
+
+func (s *systemConfig) 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 *systemConfig) fillFieldMap() {
+	s.fieldMap = make(map[string]field.Expr, 4)
+	s.fieldMap["rescan_reminder_threshold"] = s.RescanReminderThreshold
+	s.fieldMap["created_at"] = s.CreatedAt
+	s.fieldMap["updated_at"] = s.UpdatedAt
+	s.fieldMap["deleted_at"] = s.DeletedAt
+}
+
+func (s systemConfig) clone(db *gorm.DB) systemConfig {
+	s.systemConfigDo.ReplaceConnPool(db.Statement.ConnPool)
+	return s
+}
+
+func (s systemConfig) replaceDB(db *gorm.DB) systemConfig {
+	s.systemConfigDo.ReplaceDB(db)
+	return s
+}
+
+type systemConfigDo struct{ gen.DO }
+
+type ISystemConfigDo interface {
+	gen.SubQuery
+	Debug() ISystemConfigDo
+	WithContext(ctx context.Context) ISystemConfigDo
+	WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+	ReplaceDB(db *gorm.DB)
+	ReadDB() ISystemConfigDo
+	WriteDB() ISystemConfigDo
+	As(alias string) gen.Dao
+	Session(config *gorm.Session) ISystemConfigDo
+	Columns(cols ...field.Expr) gen.Columns
+	Clauses(conds ...clause.Expression) ISystemConfigDo
+	Not(conds ...gen.Condition) ISystemConfigDo
+	Or(conds ...gen.Condition) ISystemConfigDo
+	Select(conds ...field.Expr) ISystemConfigDo
+	Where(conds ...gen.Condition) ISystemConfigDo
+	Order(conds ...field.Expr) ISystemConfigDo
+	Distinct(cols ...field.Expr) ISystemConfigDo
+	Omit(cols ...field.Expr) ISystemConfigDo
+	Join(table schema.Tabler, on ...field.Expr) ISystemConfigDo
+	LeftJoin(table schema.Tabler, on ...field.Expr) ISystemConfigDo
+	RightJoin(table schema.Tabler, on ...field.Expr) ISystemConfigDo
+	Group(cols ...field.Expr) ISystemConfigDo
+	Having(conds ...gen.Condition) ISystemConfigDo
+	Limit(limit int) ISystemConfigDo
+	Offset(offset int) ISystemConfigDo
+	Count() (count int64, err error)
+	Scopes(funcs ...func(gen.Dao) gen.Dao) ISystemConfigDo
+	Unscoped() ISystemConfigDo
+	Create(values ...*model.SystemConfig) error
+	CreateInBatches(values []*model.SystemConfig, batchSize int) error
+	Save(values ...*model.SystemConfig) error
+	First() (*model.SystemConfig, error)
+	Take() (*model.SystemConfig, error)
+	Last() (*model.SystemConfig, error)
+	Find() ([]*model.SystemConfig, error)
+	FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SystemConfig, err error)
+	FindInBatches(result *[]*model.SystemConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error
+	Pluck(column field.Expr, dest interface{}) error
+	Delete(...*model.SystemConfig) (info gen.ResultInfo, err error)
+	Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+	UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+	Updates(value interface{}) (info gen.ResultInfo, err error)
+	UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+	UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+	UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+	UpdateFrom(q gen.SubQuery) gen.Dao
+	Attrs(attrs ...field.AssignExpr) ISystemConfigDo
+	Assign(attrs ...field.AssignExpr) ISystemConfigDo
+	Joins(fields ...field.RelationField) ISystemConfigDo
+	Preload(fields ...field.RelationField) ISystemConfigDo
+	FirstOrInit() (*model.SystemConfig, error)
+	FirstOrCreate() (*model.SystemConfig, error)
+	FindByPage(offset int, limit int) (result []*model.SystemConfig, count int64, err error)
+	ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+	Scan(result interface{}) (err error)
+	Returning(value interface{}, columns ...string) ISystemConfigDo
+	UnderlyingDB() *gorm.DB
+	schema.Tabler
+}
+
+func (s systemConfigDo) Debug() ISystemConfigDo {
+	return s.withDO(s.DO.Debug())
+}
+
+func (s systemConfigDo) WithContext(ctx context.Context) ISystemConfigDo {
+	return s.withDO(s.DO.WithContext(ctx))
+}
+
+func (s systemConfigDo) ReadDB() ISystemConfigDo {
+	return s.Clauses(dbresolver.Read)
+}
+
+func (s systemConfigDo) WriteDB() ISystemConfigDo {
+	return s.Clauses(dbresolver.Write)
+}
+
+func (s systemConfigDo) Session(config *gorm.Session) ISystemConfigDo {
+	return s.withDO(s.DO.Session(config))
+}
+
+func (s systemConfigDo) Clauses(conds ...clause.Expression) ISystemConfigDo {
+	return s.withDO(s.DO.Clauses(conds...))
+}
+
+func (s systemConfigDo) Returning(value interface{}, columns ...string) ISystemConfigDo {
+	return s.withDO(s.DO.Returning(value, columns...))
+}
+
+func (s systemConfigDo) Not(conds ...gen.Condition) ISystemConfigDo {
+	return s.withDO(s.DO.Not(conds...))
+}
+
+func (s systemConfigDo) Or(conds ...gen.Condition) ISystemConfigDo {
+	return s.withDO(s.DO.Or(conds...))
+}
+
+func (s systemConfigDo) Select(conds ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Select(conds...))
+}
+
+func (s systemConfigDo) Where(conds ...gen.Condition) ISystemConfigDo {
+	return s.withDO(s.DO.Where(conds...))
+}
+
+func (s systemConfigDo) Order(conds ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Order(conds...))
+}
+
+func (s systemConfigDo) Distinct(cols ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Distinct(cols...))
+}
+
+func (s systemConfigDo) Omit(cols ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Omit(cols...))
+}
+
+func (s systemConfigDo) Join(table schema.Tabler, on ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Join(table, on...))
+}
+
+func (s systemConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.LeftJoin(table, on...))
+}
+
+func (s systemConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.RightJoin(table, on...))
+}
+
+func (s systemConfigDo) Group(cols ...field.Expr) ISystemConfigDo {
+	return s.withDO(s.DO.Group(cols...))
+}
+
+func (s systemConfigDo) Having(conds ...gen.Condition) ISystemConfigDo {
+	return s.withDO(s.DO.Having(conds...))
+}
+
+func (s systemConfigDo) Limit(limit int) ISystemConfigDo {
+	return s.withDO(s.DO.Limit(limit))
+}
+
+func (s systemConfigDo) Offset(offset int) ISystemConfigDo {
+	return s.withDO(s.DO.Offset(offset))
+}
+
+func (s systemConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ISystemConfigDo {
+	return s.withDO(s.DO.Scopes(funcs...))
+}
+
+func (s systemConfigDo) Unscoped() ISystemConfigDo {
+	return s.withDO(s.DO.Unscoped())
+}
+
+func (s systemConfigDo) Create(values ...*model.SystemConfig) error {
+	if len(values) == 0 {
+		return nil
+	}
+	return s.DO.Create(values)
+}
+
+func (s systemConfigDo) CreateInBatches(values []*model.SystemConfig, 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 systemConfigDo) Save(values ...*model.SystemConfig) error {
+	if len(values) == 0 {
+		return nil
+	}
+	return s.DO.Save(values)
+}
+
+func (s systemConfigDo) First() (*model.SystemConfig, error) {
+	if result, err := s.DO.First(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.SystemConfig), nil
+	}
+}
+
+func (s systemConfigDo) Take() (*model.SystemConfig, error) {
+	if result, err := s.DO.Take(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.SystemConfig), nil
+	}
+}
+
+func (s systemConfigDo) Last() (*model.SystemConfig, error) {
+	if result, err := s.DO.Last(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.SystemConfig), nil
+	}
+}
+
+func (s systemConfigDo) Find() ([]*model.SystemConfig, error) {
+	result, err := s.DO.Find()
+	return result.([]*model.SystemConfig), err
+}
+
+func (s systemConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SystemConfig, err error) {
+	buf := make([]*model.SystemConfig, 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 systemConfigDo) FindInBatches(result *[]*model.SystemConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+	return s.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (s systemConfigDo) Attrs(attrs ...field.AssignExpr) ISystemConfigDo {
+	return s.withDO(s.DO.Attrs(attrs...))
+}
+
+func (s systemConfigDo) Assign(attrs ...field.AssignExpr) ISystemConfigDo {
+	return s.withDO(s.DO.Assign(attrs...))
+}
+
+func (s systemConfigDo) Joins(fields ...field.RelationField) ISystemConfigDo {
+	for _, _f := range fields {
+		s = *s.withDO(s.DO.Joins(_f))
+	}
+	return &s
+}
+
+func (s systemConfigDo) Preload(fields ...field.RelationField) ISystemConfigDo {
+	for _, _f := range fields {
+		s = *s.withDO(s.DO.Preload(_f))
+	}
+	return &s
+}
+
+func (s systemConfigDo) FirstOrInit() (*model.SystemConfig, error) {
+	if result, err := s.DO.FirstOrInit(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.SystemConfig), nil
+	}
+}
+
+func (s systemConfigDo) FirstOrCreate() (*model.SystemConfig, error) {
+	if result, err := s.DO.FirstOrCreate(); err != nil {
+		return nil, err
+	} else {
+		return result.(*model.SystemConfig), nil
+	}
+}
+
+func (s systemConfigDo) FindByPage(offset int, limit int) (result []*model.SystemConfig, 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 systemConfigDo) 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 systemConfigDo) Scan(result interface{}) (err error) {
+	return s.DO.Scan(result)
+}
+
+func (s systemConfigDo) Delete(models ...*model.SystemConfig) (result gen.ResultInfo, err error) {
+	return s.DO.Delete(models)
+}
+
+func (s *systemConfigDo) withDO(do gen.Dao) *systemConfigDo {
+	s.DO = *do.(*gen.DO)
+	return s
+}

+ 44 - 0
biz/model/device_map..go

@@ -0,0 +1,44 @@
+// 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 model
+
+import (
+	"time"
+
+	"gorm.io/gorm"
+)
+
+const TableNameDeviceMap = "device_map"
+
+// DeviceMap mapped from table <device_map>
+type DeviceMap struct {
+	ID            string         `gorm:"column:id;type:varchar(100);primaryKey" json:"id"`
+	DeviceID      string         `gorm:"column:device_id;type:varchar(100);not null" json:"device_id"`
+	DeviceNo      string         `gorm:"column:device_no;type:varchar(100);not null" json:"device_no"`
+	DeviceName    string         `gorm:"column:device_name;type:varchar(100);not null" json:"device_name"`
+	DeviceType    string         `gorm:"column:device_type;type:varchar(100);not null" json:"device_type"`
+	MapID         string         `gorm:"column:map_id;type:varchar(100);not null" json:"map_id"`
+	MapType       string         `gorm:"column:map_type;type:varchar(50);not null" json:"map_type"`
+	MapName       string         `gorm:"column:map_name;type:varchar(255);not null" json:"map_name"`
+	FloorID       string         `gorm:"column:floor_id;type:varchar(100);not null" json:"floor_id"`
+	Floor         string         `gorm:"column:floor;type:varchar(100);not null" json:"floor"`
+	BuildID       string         `gorm:"column:build_id;type:varchar(100);not null" json:"build_id"`
+	BuildName     string         `gorm:"column:build_name;type:varchar(100);not null" json:"build_name"`
+	MapCreateTime string         `gorm:"column:map_create_time;type:varchar(100);not null" json:"map_create_time"`
+	MapUpdateTime string         `gorm:"column:map_update_time;type:varchar(100);not null" json:"map_update_time"`
+	MapVersion    int32          `gorm:"column:map_version;type:int(11);not null" json:"map_version"`
+	MapValidFlag  int32          `gorm:"column:map_valid_flag;type:int(11);not null;default:1" json:"map_valid_flag"`
+	PjiMapZipURL  string         `gorm:"column:pji_map_zip_url;type:varchar(255);not null" json:"pji_map_zip_url"`
+	CicvMapZipURL string         `gorm:"column:cicv_map_zip_url;type:varchar(255);not null" json:"cicv_map_zip_url"`
+	CustomAreaID  int32          `gorm:"column:custom_area_id;type:int(11);not null" json:"custom_area_id"`
+	CreatedAt     time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
+	UpdatedAt     *time.Time     `gorm:"column:updated_at;type:datetime" json:"updated_at"`
+	DeletedAt     gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
+}
+
+// TableName DeviceMap's table name
+func (*DeviceMap) TableName() string {
+	return TableNameDeviceMap
+}

+ 26 - 0
biz/model/system_config.go

@@ -0,0 +1,26 @@
+// 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 model
+
+import (
+	"time"
+
+	"gorm.io/gorm"
+)
+
+const TableNameSystemConfig = "system_config"
+
+// SystemConfig mapped from table <system_config>
+type SystemConfig struct {
+	RescanReminderThreshold float32        `gorm:"column:rescan_reminder_threshold;type:float(6,2);primaryKey" json:"rescan_reminder_threshold"`
+	CreatedAt               time.Time      `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
+	UpdatedAt               *time.Time     `gorm:"column:updated_at;type:datetime" json:"updated_at"`
+	DeletedAt               gorm.DeletedAt `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
+}
+
+// TableName SystemConfig's table name
+func (*SystemConfig) TableName() string {
+	return TableNameSystemConfig
+}

+ 3 - 1
gen/main.go

@@ -50,9 +50,11 @@ func main() {
 	MapUpdate := g.GenerateModel("map_update")
 	World := g.GenerateModel("world")
 	SimulationTestRecord := g.GenerateModel("simulation_test_record")
+	DeviceMap := g.GenerateModel("device_map")
+	SystemConfig := g.GenerateModel("system_config")
 
 	// 创建模型的方法,生成文件在 query 目录; 先创建结果不会被后创建的覆盖
-	g.ApplyBasic(MapUpdate, World, SimulationTestRecord)
+	g.ApplyBasic(MapUpdate, World, SimulationTestRecord, DeviceMap, SystemConfig)
 	//g.ApplyBasic(World)
 
 	g.Execute()