feat:完善项目
This commit is contained in:
@ -39,7 +39,7 @@ func initModel() {
|
||||
&synchronized{iModel: model.NewSysConfig()},
|
||||
&synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()},
|
||||
&synchronized{iModel: model.NewSysUser(), iValues: func() interface{} {
|
||||
return &model.SysUser{Account: "admin", Name: "商挈智能", Mobile: "13888888888", Password: "123456",
|
||||
return &model.SysUser{Account: "admin", Name: "超级管理员", Mobile: "13888888888", Password: "123456",
|
||||
IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"}
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysUserTenant()},
|
||||
@ -48,6 +48,8 @@ func initModel() {
|
||||
&synchronized{iModel: model.NewSysUserRole()},
|
||||
// 日志管理
|
||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||
// 功能信息
|
||||
&synchronized{iModel: model.NewManageSupplier()},
|
||||
)
|
||||
}
|
||||
func initCacheMode() {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/config"
|
||||
"ArmedPolice/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Gender struct {
|
||||
@ -51,6 +53,30 @@ func (m *Images) AnalysisSlice(domain string) []string {
|
||||
return images
|
||||
}
|
||||
|
||||
type Area struct {
|
||||
Province string `gorm:"column:province;type:varchar(8);default:null;comment:所在省" json:"province"`
|
||||
City string `gorm:"column:city;type:varchar(8);default:null;comment:所在市" json:"city"`
|
||||
District string `gorm:"column:district;type:varchar(8);default:null;comment:所在区/县" json:"district"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
}
|
||||
|
||||
func (m *Area) FormatBasic() string {
|
||||
address := make([]string, 0)
|
||||
address = append(address, config.SettingAreaInfo[config.DefaultChinaAreaCode][m.Province])
|
||||
|
||||
if m.City != "" {
|
||||
address = append(address, config.SettingAreaInfo[m.Province][m.City])
|
||||
}
|
||||
if m.District != "" {
|
||||
address = append(address, config.SettingAreaInfo[m.City][m.District])
|
||||
}
|
||||
return strings.Join(address, "-")
|
||||
}
|
||||
|
||||
func (m *Area) FormatDetail() string {
|
||||
return m.FormatBasic() + ";" + m.Address
|
||||
}
|
||||
|
||||
// Position 坐标信息
|
||||
type Position struct {
|
||||
Longitude float64 `json:"longitude"` // 经度
|
||||
|
16
app/common/model/manage_equipment.go
Normal file
16
app/common/model/manage_equipment.go
Normal file
@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
type ManageEquipment struct {
|
||||
Model
|
||||
ModelTenant
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageEquipment) TableName() string {
|
||||
return "manage_equipment"
|
||||
}
|
||||
|
||||
func NewManageEquipment() *ManageEquipment {
|
||||
return &ManageEquipment{}
|
||||
}
|
32
app/common/model/manage_supplier.go
Normal file
32
app/common/model/manage_supplier.go
Normal file
@ -0,0 +1,32 @@
|
||||
package model
|
||||
|
||||
// ManageSupplier 供应商数据模型
|
||||
type ManageSupplier struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Kind ManageSupplierKind `gorm:"column:kind;type:tinyint(1);default:1;comment:类型" json:"kind"`
|
||||
Name string `gorm:"column:name;type:varchar(100);default:null;comment:名称" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(20);default:null;comment:联系方式" json:"mobile"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:联系地址" json:"address"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息 " json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ManageSupplierKind 供应商类型
|
||||
type ManageSupplierKind int
|
||||
|
||||
const (
|
||||
// ManageSupplierKindForMaterial 材料供应商
|
||||
ManageSupplierKindForMaterial ManageSupplierKind = iota + 101
|
||||
// ManageSupplierKindForRepair 维修供应商
|
||||
ManageSupplierKindForRepair
|
||||
)
|
||||
|
||||
func (*ManageSupplier) TableName() string {
|
||||
return "manage_supplier"
|
||||
}
|
||||
|
||||
func NewManageSupplier() *ManageSupplier {
|
||||
return &ManageSupplier{}
|
||||
}
|
@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/serve/orm"
|
||||
"ArmedPolice/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -12,13 +13,14 @@ import (
|
||||
// IModel
|
||||
type IModel interface {
|
||||
GetID() uint64
|
||||
GetEncodeID() string
|
||||
TableName() string
|
||||
SetDatabase(database string, key ...string)
|
||||
}
|
||||
|
||||
// Model
|
||||
type Model struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"id" form:"id"`
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"-" form:"id"`
|
||||
|
||||
Database string `json:"-" gorm:"-"`
|
||||
}
|
||||
@ -58,14 +60,14 @@ const (
|
||||
FieldsForDeleted string = "is_deleted"
|
||||
)
|
||||
|
||||
const (
|
||||
SubDatabase string = "tenant"
|
||||
)
|
||||
|
||||
func (m *Model) GetID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
func (m *Model) GetEncodeID() string {
|
||||
return utils.HASHIDEncode(int(m.ID))
|
||||
}
|
||||
|
||||
func (m *Model) SetDatabase(database string, key ...string) {
|
||||
m.Database = database + "_" + strings.Join(key, "_")
|
||||
}
|
||||
|
@ -7,39 +7,18 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// SysTenant 租户信息数据模型
|
||||
type SysTenant struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||
Key string `gorm:"column:key;type:varchar(100);default:null;comment:租户/租户客户标识" json:"key"`
|
||||
Image
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:租户名称/租户客户名称" json:"name"`
|
||||
Config string `gorm:"column:config;type:text;comment:租户/租户客户配置信息" json:"-"`
|
||||
Deadline time.Time `gorm:"column:deadline;type:datetime;default:null;comment:租户/租户客户协议截止时间" json:"deadline"`
|
||||
Status SysTenantStatus `gorm:"column:status;type:tinyint(1);default:1;comment:租户/租户客户状态" json:"status"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:租户/租户客户备注" json:"remark"`
|
||||
Key string `gorm:"column:key;type:varchar(100);default:null;comment:标识" json:"key"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
|
||||
Area
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type SysTenantConfig struct {
|
||||
MaxDevices int `json:"max_devices"` // 最大可连接设备数
|
||||
MaxCustomer int `json:"max_customer"` // 最大可拥有的客户数
|
||||
Protocol uint `json:"protocol"` // 支持的协议模式
|
||||
}
|
||||
|
||||
type SysTenantStatus int
|
||||
|
||||
const (
|
||||
// SysTenantStatusForNormal 正常
|
||||
SysTenantStatusForNormal SysTenantStatus = iota + 1
|
||||
// SysTenantStatusForWellExpire 协议将到期
|
||||
SysTenantStatusForWellExpire
|
||||
// SysTenantStatusForExpired 协议已过期
|
||||
SysTenantStatusForExpired
|
||||
// SysTenantStatusForDisable 已禁用
|
||||
SysTenantStatusForDisable
|
||||
)
|
||||
|
||||
func (m *SysTenant) TableName() string {
|
||||
return "sys_tenant"
|
||||
}
|
||||
@ -51,19 +30,6 @@ func (m *SysTenant) BeforeCreate(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SysTenant) ConfigInfo() *SysTenantConfig {
|
||||
config := new(SysTenantConfig)
|
||||
_ = utils.FromJSON(m.Config, config)
|
||||
return config
|
||||
}
|
||||
|
||||
func (m *SysTenant) StatusTitle() string {
|
||||
if m.Status == SysTenantStatusForDisable {
|
||||
return "禁用"
|
||||
}
|
||||
return "正常"
|
||||
}
|
||||
|
||||
func NewSysTenant() *SysTenant {
|
||||
return &SysTenant{}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package model
|
||||
|
||||
type SysTenantAuth struct {
|
||||
Model
|
||||
ModelTenant
|
||||
AuthID uint64 `gorm:"column:auth_id;type:int;default:0;comment:权限ID" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *SysTenantAuth) TableName() string {
|
||||
return m.NewTableName("sys_tenant_auth")
|
||||
}
|
||||
|
||||
func NewSysTenantAuth() *SysTenantAuth {
|
||||
return &SysTenantAuth{}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package model
|
||||
|
||||
type SysTenantMenu struct {
|
||||
Model
|
||||
ModelTenant
|
||||
MenuID uint64 `gorm:"column:menu_id;type:int;default:0;comment:菜单ID" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *SysTenantMenu) TableName() string {
|
||||
return m.NewTableName("sys_tenant_menu")
|
||||
}
|
||||
|
||||
func NewSysTenantMenu() *SysTenantMenu {
|
||||
return &SysTenantMenu{}
|
||||
}
|
@ -2,7 +2,6 @@ package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/utils"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@ -10,6 +9,7 @@ import (
|
||||
|
||||
type SysUser struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_sys_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Account string `gorm:"column:account;type:varchar(50);default:null;comment:账户名" json:"account"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
@ -51,10 +51,6 @@ func (m *SysUser) Pass() {
|
||||
m.Password = utils.HashString([]byte(utils.Md5String(m.Password, m.Salt)))
|
||||
}
|
||||
|
||||
func (m *SysUser) UUIDString() string {
|
||||
return fmt.Sprintf("%d", m.UUID)
|
||||
}
|
||||
|
||||
func NewSysUser() *SysUser {
|
||||
return &SysUser{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user