59eb34976a
iotlcm-admin-svr:管理后台服务。 - Go module:iotlcm → git.5iot.com/iotlcm-public/iotlcm-admin-svr(729 文件) - 凭据与地址脱敏:JWT signingKey(含代码里的 MustGet 默认值)、 MySQL DSN、Redis 口令、告警邮件发件人邮箱全部改为占位; 私网 IP → 文档地址段;库名 xiujie_admin → iotlcm - 真实手机号/邮箱 → 合法 11 位编造号 / example.com - 移除内部资产:CI 触发器、过时 DDL(sql/db_iotlcm.sql)、 私有依赖 go get 行、明文 registry 登录口令 - 启动 banner 统一 IOTLCM 方块字 + 社区惯例署名 - Dockerfile 改用公共基础镜像 - 拼错的 RADEME.md → README.md,README 重写 - 需要真实数据库的用例改为可用 IOTLCM_TEST_WITH_DB=1 显式启用 - 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes 数据库 schema 不随本仓发布(生产 DDL 已过时),README 已说明。
127 lines
4.3 KiB
Go
127 lines
4.3 KiB
Go
// package genmodel
|
|
// @Link https://github.com/xiujiecn/xiu-admin
|
|
// @Copyright Copyright (c) 2025 LiXiujie
|
|
// @Author Lxj <li@xiujie.cn>
|
|
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
|
package genmodel
|
|
|
|
import (
|
|
genconsts "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgen/gen_consts"
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
// 模板配置 config/config.yaml xgen.application.crud.templates
|
|
type GenCodesConfigCrudTemplate struct {
|
|
Group string `name:"group" json:"group"`
|
|
IsAddon bool `name:"isAddon" json:"isAddon"`
|
|
MasterPackage string `name:"masterPackage" json:"masterPackage"`
|
|
TemplatePath string `name:"templatePath" json:"templatePath"`
|
|
ApiPath string `name:"apiPath" json:"apiPath"`
|
|
InputPath string `name:"inputPath" json:"inputPath"`
|
|
ControllerPath string `name:"controllerPath" json:"controllerPath"`
|
|
LogicPath string `name:"logicPath" json:"logicPath"`
|
|
RouterPath string `name:"routerPath" json:"routerPath"`
|
|
SqlPath string `name:"sqlPath" json:"sqlPath"`
|
|
WebApiPath string `name:"webApiPath" json:"webApiPath"`
|
|
WebViewsPath string `name:"webViewsPath" json:"webViewsPath"`
|
|
}
|
|
type GenCodesConfigTreeTemplate struct {
|
|
Group string `json:"group"`
|
|
TemplatePath string `json:"templatePath"`
|
|
}
|
|
|
|
type GenCodesConfigBuildAddon struct {
|
|
SrcPath string `json:"srcPath"`
|
|
WebApiPath string `json:"webApiPath"`
|
|
WebViewsPath string `json:"webViewsPath"`
|
|
}
|
|
|
|
// 工具生成配置 hack/config.yaml gfcli.gen.dao
|
|
type GenDaoConfig struct {
|
|
Group string `name:"group" json:"group"`
|
|
Link string `name:"link" json:"link"`
|
|
DbName string `name:"dbName" json:"dbName"`
|
|
TableName string `name:"tableName" json:"tableName"`
|
|
JsonCase string `name:"jsonCase" json:"jsonCase"`
|
|
StdTime bool `name:"stdTime" json:"stdTime"`
|
|
GJsonSupport bool `name:"gJsonSupport" json:"gJsonSupport"`
|
|
}
|
|
|
|
// 工具生成配置 hack/config.yaml gfcli.gen.service
|
|
type GenServiceConfig struct {
|
|
SrcFolder string `name:"srcFolder"`
|
|
DstFolder string `name:"dstFolder"`
|
|
DstFileNameCase string `name:"dstFileNameCase"`
|
|
WatchFile string `name:"watchFile" `
|
|
StPattern string `name:"stPattern" `
|
|
Packages []string `name:"packages" `
|
|
ImportPrefix string `name:"importPrefix" `
|
|
Clear bool `name:"clear" `
|
|
}
|
|
|
|
// 模板配置 config/config.yaml xgen
|
|
type GenCodesConfig struct {
|
|
AllowedIPs []string `json:"allowedIPs"`
|
|
Application struct {
|
|
Crud struct {
|
|
Templates []*GenCodesConfigCrudTemplate `json:"templates"`
|
|
} `json:"crud"`
|
|
Tree struct {
|
|
Templates []*GenCodesConfigTreeTemplate `json:"templates"`
|
|
} `json:"tree"`
|
|
} `json:"application"`
|
|
Delimiters []string `json:"delimiters"`
|
|
DevPath string `json:"devPath"`
|
|
DisableTables []string `json:"disableTables"`
|
|
SelectDbs []string `json:"selectDbs"`
|
|
Addon *GenCodesConfigBuildAddon `json:"addon"`
|
|
}
|
|
|
|
// ConvType 类型转换
|
|
func ConvType(val interface{}, t string) interface{} {
|
|
switch t {
|
|
case genconsts.ConfigTypeString:
|
|
val = gconv.String(val)
|
|
case genconsts.ConfigTypeInt:
|
|
val = gconv.Int(val)
|
|
case genconsts.ConfigTypeInt8:
|
|
val = gconv.Int8(val)
|
|
case genconsts.ConfigTypeInt16:
|
|
val = gconv.Int16(val)
|
|
case genconsts.ConfigTypeInt32:
|
|
val = gconv.Int32(val)
|
|
case genconsts.ConfigTypeInt64:
|
|
val = gconv.Int64(val)
|
|
case genconsts.ConfigTypeUint:
|
|
val = gconv.Uint(val)
|
|
case genconsts.ConfigTypeUint8:
|
|
val = gconv.Uint8(val)
|
|
case genconsts.ConfigTypeUint16:
|
|
val = gconv.Uint16(val)
|
|
case genconsts.ConfigTypeUint32:
|
|
val = gconv.Uint32(val)
|
|
case genconsts.ConfigTypeUint64:
|
|
val = gconv.Uint64(val)
|
|
case genconsts.ConfigTypeFloat32:
|
|
val = gconv.Float32(val)
|
|
case genconsts.ConfigTypeFloat64:
|
|
val = gconv.Float64(val)
|
|
case genconsts.ConfigTypeBool:
|
|
val = gconv.Bool(val)
|
|
case genconsts.ConfigTypeDate:
|
|
val = gconv.Time(val, "Y-m-d")
|
|
case genconsts.ConfigTypeDateTime:
|
|
val = gconv.Time(val, "Y-m-d H:i:s")
|
|
case genconsts.ConfigTypeSliceInt:
|
|
val = gconv.SliceInt(val)
|
|
case genconsts.ConfigTypeSliceInt64:
|
|
val = gconv.SliceInt64(val)
|
|
case genconsts.ConfigTypeSliceString:
|
|
val = gconv.SliceStr(val)
|
|
default:
|
|
val = gconv.String(val)
|
|
}
|
|
return val
|
|
}
|