✨ Init
This commit is contained in:
21
model/system/request/jwt.go
Normal file
21
model/system/request/jwt.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/gofrs/uuid/v5"
|
||||
jwt "github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
// Custom claims structure
|
||||
type CustomClaims struct {
|
||||
BaseClaims
|
||||
BufferTime int64
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
type BaseClaims struct {
|
||||
UUID uuid.UUID
|
||||
ID uint
|
||||
Username string
|
||||
NickName string
|
||||
AuthorityId uint
|
||||
}
|
14
model/system/request/sys_api.go
Normal file
14
model/system/request/sys_api.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/common/request"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
// api分页条件查询及排序结构体
|
||||
type SearchApiParams struct {
|
||||
system.SysApi
|
||||
request.PageInfo
|
||||
OrderKey string `json:"orderKey"` // 排序
|
||||
Desc bool `json:"desc"` // 排序方式:升序false(默认)|降序true
|
||||
}
|
7
model/system/request/sys_authority_btn.go
Normal file
7
model/system/request/sys_authority_btn.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package request
|
||||
|
||||
type SysAuthorityBtnReq struct {
|
||||
MenuID uint `json:"menuID"`
|
||||
AuthorityId uint `json:"authorityId"`
|
||||
Selected []uint `json:"selected"`
|
||||
}
|
13
model/system/request/sys_auto_history.go
Normal file
13
model/system/request/sys_auto_history.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package request
|
||||
|
||||
import "miniapp/model/common/request"
|
||||
|
||||
type SysAutoHistory struct {
|
||||
request.PageInfo
|
||||
}
|
||||
|
||||
// GetById Find by id structure
|
||||
type RollBack struct {
|
||||
ID int `json:"id" form:"id"` // 主键ID
|
||||
DeleteTable bool `json:"deleteTable" form:"deleteTable"` // 是否删除表
|
||||
}
|
26
model/system/request/sys_casbin.go
Normal file
26
model/system/request/sys_casbin.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package request
|
||||
|
||||
// Casbin info structure
|
||||
type CasbinInfo struct {
|
||||
Path string `json:"path"` // 路径
|
||||
Method string `json:"method"` // 方法
|
||||
}
|
||||
|
||||
// Casbin structure for input parameters
|
||||
type CasbinInReceive struct {
|
||||
AuthorityId uint `json:"authorityId"` // 权限id
|
||||
CasbinInfos []CasbinInfo `json:"casbinInfos"`
|
||||
}
|
||||
|
||||
func DefaultCasbin() []CasbinInfo {
|
||||
return []CasbinInfo{
|
||||
{Path: "/menu/getMenu", Method: "POST"},
|
||||
{Path: "/jwt/jsonInBlacklist", Method: "POST"},
|
||||
{Path: "/base/login", Method: "POST"},
|
||||
{Path: "/user/admin_register", Method: "POST"},
|
||||
{Path: "/user/changePassword", Method: "POST"},
|
||||
{Path: "/user/setUserAuthority", Method: "POST"},
|
||||
{Path: "/user/setUserInfo", Method: "PUT"},
|
||||
{Path: "/user/getUserInfo", Method: "GET"},
|
||||
}
|
||||
}
|
11
model/system/request/sys_chatgpt.go
Normal file
11
model/system/request/sys_chatgpt.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/common/request"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
type ChatGptRequest struct {
|
||||
system.ChatGpt
|
||||
request.PageInfo
|
||||
}
|
11
model/system/request/sys_dictionary.go
Normal file
11
model/system/request/sys_dictionary.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/common/request"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
type SysDictionarySearch struct {
|
||||
system.SysDictionary
|
||||
request.PageInfo
|
||||
}
|
11
model/system/request/sys_dictionary_detail.go
Normal file
11
model/system/request/sys_dictionary_detail.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/common/request"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
type SysDictionaryDetailSearch struct {
|
||||
system.SysDictionaryDetail
|
||||
request.PageInfo
|
||||
}
|
102
model/system/request/sys_init.go
Normal file
102
model/system/request/sys_init.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"miniapp/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
type InitDB struct {
|
||||
DBType string `json:"dbType"` // 数据库类型
|
||||
Host string `json:"host"` // 服务器地址
|
||||
Port string `json:"port"` // 数据库连接端口
|
||||
UserName string `json:"userName"` // 数据库用户名
|
||||
Password string `json:"password"` // 数据库密码
|
||||
DBName string `json:"dbName" binding:"required"` // 数据库名
|
||||
DBPath string `json:"dbPath"` // sqlite数据库文件路径
|
||||
}
|
||||
|
||||
// MysqlEmptyDsn msyql 空数据库 建库链接
|
||||
// Author SliverHorn
|
||||
func (i *InitDB) MysqlEmptyDsn() string {
|
||||
if i.Host == "" {
|
||||
i.Host = "127.0.0.1"
|
||||
}
|
||||
if i.Port == "" {
|
||||
i.Port = "3306"
|
||||
}
|
||||
return fmt.Sprintf("%s:%s@tcp(%s:%s)/", i.UserName, i.Password, i.Host, i.Port)
|
||||
}
|
||||
|
||||
// PgsqlEmptyDsn pgsql 空数据库 建库链接
|
||||
// Author SliverHorn
|
||||
func (i *InitDB) PgsqlEmptyDsn() string {
|
||||
if i.Host == "" {
|
||||
i.Host = "127.0.0.1"
|
||||
}
|
||||
if i.Port == "" {
|
||||
i.Port = "5432"
|
||||
}
|
||||
return "host=" + i.Host + " user=" + i.UserName + " password=" + i.Password + " port=" + i.Port + " dbname=" + "postgres" + " " + "sslmode=disable TimeZone=Asia/Shanghai"
|
||||
}
|
||||
|
||||
// SqliteEmptyDsn sqlite 空数据库 建库链接
|
||||
// Author Kafumio
|
||||
func (i *InitDB) SqliteEmptyDsn() string {
|
||||
separator := string(os.PathSeparator)
|
||||
return i.DBPath + separator + i.DBName + ".db"
|
||||
}
|
||||
|
||||
// ToMysqlConfig 转换 config.Mysql
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (i *InitDB) ToMysqlConfig() config.Mysql {
|
||||
return config.Mysql{
|
||||
GeneralDB: config.GeneralDB{
|
||||
Path: i.Host,
|
||||
Port: i.Port,
|
||||
Dbname: i.DBName,
|
||||
Username: i.UserName,
|
||||
Password: i.Password,
|
||||
MaxIdleConns: 10,
|
||||
MaxOpenConns: 100,
|
||||
LogMode: "error",
|
||||
Config: "charset=utf8mb4&parseTime=True&loc=Local",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ToPgsqlConfig 转换 config.Pgsql
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (i *InitDB) ToPgsqlConfig() config.Pgsql {
|
||||
return config.Pgsql{
|
||||
GeneralDB: config.GeneralDB{
|
||||
Path: i.Host,
|
||||
Port: i.Port,
|
||||
Dbname: i.DBName,
|
||||
Username: i.UserName,
|
||||
Password: i.Password,
|
||||
MaxIdleConns: 10,
|
||||
MaxOpenConns: 100,
|
||||
LogMode: "error",
|
||||
Config: "sslmode=disable TimeZone=Asia/Shanghai",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ToSqliteConfig 转换 config.Sqlite
|
||||
// Author [Kafumio](https://github.com/Kafumio)
|
||||
func (i *InitDB) ToSqliteConfig() config.Sqlite {
|
||||
return config.Sqlite{
|
||||
GeneralDB: config.GeneralDB{
|
||||
Path: i.DBPath,
|
||||
Port: i.Port,
|
||||
Dbname: i.DBName,
|
||||
Username: i.UserName,
|
||||
Password: i.Password,
|
||||
MaxIdleConns: 10,
|
||||
MaxOpenConns: 100,
|
||||
LogMode: "error",
|
||||
Config: "",
|
||||
},
|
||||
}
|
||||
}
|
27
model/system/request/sys_menu.go
Normal file
27
model/system/request/sys_menu.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
// Add menu authority info structure
|
||||
type AddMenuAuthorityInfo struct {
|
||||
Menus []system.SysBaseMenu `json:"menus"`
|
||||
AuthorityId uint `json:"authorityId"` // 角色ID
|
||||
}
|
||||
|
||||
func DefaultMenu() []system.SysBaseMenu {
|
||||
return []system.SysBaseMenu{{
|
||||
GVA_MODEL: global.GVA_MODEL{ID: 1},
|
||||
ParentId: "0",
|
||||
Path: "dashboard",
|
||||
Name: "dashboard",
|
||||
Component: "view/dashboard/index.vue",
|
||||
Sort: 1,
|
||||
Meta: system.Meta{
|
||||
Title: "仪表盘",
|
||||
Icon: "setting",
|
||||
},
|
||||
}}
|
||||
}
|
11
model/system/request/sys_operation_record.go
Normal file
11
model/system/request/sys_operation_record.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/common/request"
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
type SysOperationRecordSearch struct {
|
||||
system.SysOperationRecord
|
||||
request.PageInfo
|
||||
}
|
56
model/system/request/sys_user.go
Normal file
56
model/system/request/sys_user.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
// Register User register structure
|
||||
type Register struct {
|
||||
Username string `json:"userName" example:"用户名"`
|
||||
Password string `json:"passWord" example:"密码"`
|
||||
NickName string `json:"nickName" example:"昵称"`
|
||||
HeaderImg string `json:"headerImg" example:"头像链接"`
|
||||
AuthorityId uint `json:"authorityId" swaggertype:"string" example:"int 角色id"`
|
||||
Enable int `json:"enable" swaggertype:"string" example:"int 是否启用"`
|
||||
AuthorityIds []uint `json:"authorityIds" swaggertype:"string" example:"[]uint 角色id"`
|
||||
Phone string `json:"phone" example:"电话号码"`
|
||||
Email string `json:"email" example:"电子邮箱"`
|
||||
}
|
||||
|
||||
// User login structure
|
||||
type Login struct {
|
||||
Username string `json:"username"` // 用户名
|
||||
Password string `json:"password"` // 密码
|
||||
Captcha string `json:"captcha"` // 验证码
|
||||
CaptchaId string `json:"captchaId"` // 验证码ID
|
||||
}
|
||||
|
||||
// Modify password structure
|
||||
type ChangePasswordReq struct {
|
||||
ID uint `json:"-"` // 从 JWT 中提取 user id,避免越权
|
||||
Password string `json:"password"` // 密码
|
||||
NewPassword string `json:"newPassword"` // 新密码
|
||||
}
|
||||
|
||||
// Modify user's auth structure
|
||||
type SetUserAuth struct {
|
||||
AuthorityId uint `json:"authorityId"` // 角色ID
|
||||
}
|
||||
|
||||
// Modify user's auth structure
|
||||
type SetUserAuthorities struct {
|
||||
ID uint
|
||||
AuthorityIds []uint `json:"authorityIds"` // 角色ID
|
||||
}
|
||||
|
||||
type ChangeUserInfo struct {
|
||||
ID uint `gorm:"primarykey"` // 主键ID
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
AuthorityIds []uint `json:"authorityIds" gorm:"-"` // 角色ID
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
|
||||
SideMode string `json:"sideMode" gorm:"comment:用户侧边主题"` // 用户侧边主题
|
||||
Enable int `json:"enable" gorm:"comment:冻结用户"` //冻结用户
|
||||
Authorities []system.SysAuthority `json:"-" gorm:"many2many:sys_user_authority;"`
|
||||
}
|
11
model/system/response/sys_api.go
Normal file
11
model/system/response/sys_api.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package response
|
||||
|
||||
import "miniapp/model/system"
|
||||
|
||||
type SysAPIResponse struct {
|
||||
Api system.SysApi `json:"api"`
|
||||
}
|
||||
|
||||
type SysAPIListResponse struct {
|
||||
Apis []system.SysApi `json:"apis"`
|
||||
}
|
12
model/system/response/sys_authority.go
Normal file
12
model/system/response/sys_authority.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package response
|
||||
|
||||
import "miniapp/model/system"
|
||||
|
||||
type SysAuthorityResponse struct {
|
||||
Authority system.SysAuthority `json:"authority"`
|
||||
}
|
||||
|
||||
type SysAuthorityCopyResponse struct {
|
||||
Authority system.SysAuthority `json:"authority"`
|
||||
OldAuthorityId uint `json:"oldAuthorityId"` // 旧角色ID
|
||||
}
|
5
model/system/response/sys_authority_btn.go
Normal file
5
model/system/response/sys_authority_btn.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package response
|
||||
|
||||
type SysAuthorityBtnRes struct {
|
||||
Selected []uint `json:"selected"`
|
||||
}
|
16
model/system/response/sys_auto_code.go
Normal file
16
model/system/response/sys_auto_code.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package response
|
||||
|
||||
type Db struct {
|
||||
Database string `json:"database" gorm:"column:database"`
|
||||
}
|
||||
|
||||
type Table struct {
|
||||
TableName string `json:"tableName" gorm:"column:table_name"`
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
DataType string `json:"dataType" gorm:"column:data_type"`
|
||||
ColumnName string `json:"columnName" gorm:"column:column_name"`
|
||||
DataTypeLong string `json:"dataTypeLong" gorm:"column:data_type_long"`
|
||||
ColumnComment string `json:"columnComment" gorm:"column:column_comment"`
|
||||
}
|
14
model/system/response/sys_auto_code_history.go
Normal file
14
model/system/response/sys_auto_code_history.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package response
|
||||
|
||||
import "time"
|
||||
|
||||
type AutoCodeHistory struct {
|
||||
ID uint `json:"ID" gorm:"column:id"`
|
||||
CreatedAt time.Time `json:"CreatedAt" gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `json:"UpdatedAt" gorm:"column:updated_at"`
|
||||
BusinessDB string `json:"businessDB" gorm:"column:business_db"`
|
||||
TableName string `json:"tableName" gorm:"column:table_name"`
|
||||
StructName string `json:"structName" gorm:"column:struct_name"`
|
||||
StructCNName string `json:"structCNName" gorm:"column:struct_cn_name"`
|
||||
Flag int `json:"flag" gorm:"column:flag"`
|
||||
}
|
8
model/system/response/sys_captcha.go
Normal file
8
model/system/response/sys_captcha.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package response
|
||||
|
||||
type SysCaptchaResponse struct {
|
||||
CaptchaId string `json:"captchaId"`
|
||||
PicPath string `json:"picPath"`
|
||||
CaptchaLength int `json:"captchaLength"`
|
||||
OpenCaptcha bool `json:"openCaptcha"`
|
||||
}
|
9
model/system/response/sys_casbin.go
Normal file
9
model/system/response/sys_casbin.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"miniapp/model/system/request"
|
||||
)
|
||||
|
||||
type PolicyPathResponse struct {
|
||||
Paths []request.CasbinInfo `json:"paths"`
|
||||
}
|
4
model/system/response/sys_chatgpt.go
Normal file
4
model/system/response/sys_chatgpt.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package response
|
||||
|
||||
type ChatGptResponse struct {
|
||||
}
|
15
model/system/response/sys_menu.go
Normal file
15
model/system/response/sys_menu.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package response
|
||||
|
||||
import "miniapp/model/system"
|
||||
|
||||
type SysMenusResponse struct {
|
||||
Menus []system.SysMenu `json:"menus"`
|
||||
}
|
||||
|
||||
type SysBaseMenusResponse struct {
|
||||
Menus []system.SysBaseMenu `json:"menus"`
|
||||
}
|
||||
|
||||
type SysBaseMenuResponse struct {
|
||||
Menu system.SysBaseMenu `json:"menu"`
|
||||
}
|
7
model/system/response/sys_system.go
Normal file
7
model/system/response/sys_system.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package response
|
||||
|
||||
import "miniapp/config"
|
||||
|
||||
type SysConfigResponse struct {
|
||||
Config config.Server `json:"config"`
|
||||
}
|
15
model/system/response/sys_user.go
Normal file
15
model/system/response/sys_user.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"miniapp/model/system"
|
||||
)
|
||||
|
||||
type SysUserResponse struct {
|
||||
User system.SysUser `json:"user"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
User system.SysUser `json:"user"`
|
||||
Token string `json:"token"`
|
||||
ExpiresAt int64 `json:"expiresAt"`
|
||||
}
|
17
model/system/sys_api.go
Normal file
17
model/system/sys_api.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
type SysApi struct {
|
||||
global.GVA_MODEL
|
||||
Path string `json:"path" gorm:"comment:api路径"` // api路径
|
||||
Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述
|
||||
ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组
|
||||
Method string `json:"method" gorm:"default:POST;comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE
|
||||
}
|
||||
|
||||
func (SysApi) TableName() string {
|
||||
return "sys_apis"
|
||||
}
|
23
model/system/sys_authority.go
Normal file
23
model/system/sys_authority.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysAuthority struct {
|
||||
CreatedAt time.Time // 创建时间
|
||||
UpdatedAt time.Time // 更新时间
|
||||
DeletedAt *time.Time `sql:"index"`
|
||||
AuthorityId uint `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID
|
||||
AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名
|
||||
ParentId *uint `json:"parentId" gorm:"comment:父角色ID"` // 父角色ID
|
||||
DataAuthorityId []*SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;"`
|
||||
Children []SysAuthority `json:"children" gorm:"-"`
|
||||
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
|
||||
Users []SysUser `json:"-" gorm:"many2many:sys_user_authority;"`
|
||||
DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard)
|
||||
}
|
||||
|
||||
func (SysAuthority) TableName() string {
|
||||
return "sys_authorities"
|
||||
}
|
8
model/system/sys_authority_btn.go
Normal file
8
model/system/sys_authority_btn.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package system
|
||||
|
||||
type SysAuthorityBtn struct {
|
||||
AuthorityId uint `gorm:"comment:角色ID"`
|
||||
SysMenuID uint `gorm:"comment:菜单ID"`
|
||||
SysBaseMenuBtnID uint `gorm:"comment:菜单按钮ID"`
|
||||
SysBaseMenuBtn SysBaseMenuBtn ` gorm:"comment:按钮详情"`
|
||||
}
|
19
model/system/sys_authority_menu.go
Normal file
19
model/system/sys_authority_menu.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package system
|
||||
|
||||
type SysMenu struct {
|
||||
SysBaseMenu
|
||||
MenuId string `json:"menuId" gorm:"comment:菜单ID"`
|
||||
AuthorityId uint `json:"-" gorm:"comment:角色ID"`
|
||||
Children []SysMenu `json:"children" gorm:"-"`
|
||||
Parameters []SysBaseMenuParameter `json:"parameters" gorm:"foreignKey:SysBaseMenuID;references:MenuId"`
|
||||
Btns map[string]uint `json:"btns" gorm:"-"`
|
||||
}
|
||||
|
||||
type SysAuthorityMenu struct {
|
||||
MenuId string `json:"menuId" gorm:"comment:菜单ID;column:sys_base_menu_id"`
|
||||
AuthorityId string `json:"-" gorm:"comment:角色ID;column:sys_authority_authority_id"`
|
||||
}
|
||||
|
||||
func (s SysAuthorityMenu) TableName() string {
|
||||
return "sys_authority_menus"
|
||||
}
|
119
model/system/sys_auto_code.go
Normal file
119
model/system/sys_auto_code.go
Normal file
@@ -0,0 +1,119 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go/token"
|
||||
"strings"
|
||||
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
// AutoCodeStruct 初始版本自动化代码工具
|
||||
type AutoCodeStruct struct {
|
||||
StructName string `json:"structName"` // Struct名称
|
||||
TableName string `json:"tableName"` // 表名
|
||||
PackageName string `json:"packageName"` // 文件名称
|
||||
HumpPackageName string `json:"humpPackageName"` // go文件名称
|
||||
Abbreviation string `json:"abbreviation"` // Struct简称
|
||||
Description string `json:"description"` // Struct中文名称
|
||||
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
|
||||
AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
|
||||
AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
|
||||
BusinessDB string `json:"businessDB"` // 业务数据库
|
||||
Fields []*Field `json:"fields,omitempty"`
|
||||
HasTimer bool
|
||||
DictTypes []string `json:"-"`
|
||||
Package string `json:"package"`
|
||||
PackageT string `json:"-"`
|
||||
NeedValid bool `json:"-"`
|
||||
NeedSort bool `json:"-"`
|
||||
HasPic bool `json:"-"`
|
||||
HasRichText bool `json:"-"`
|
||||
HasFile bool `json:"-"`
|
||||
NeedJSON bool `json:"-"`
|
||||
}
|
||||
|
||||
func (a *AutoCodeStruct) Pretreatment() {
|
||||
a.KeyWord()
|
||||
a.SuffixTest()
|
||||
}
|
||||
|
||||
// KeyWord 是go关键字的处理加上 _ ,防止编译报错
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (a *AutoCodeStruct) KeyWord() {
|
||||
if token.IsKeyword(a.Abbreviation) {
|
||||
a.Abbreviation = a.Abbreviation + "_"
|
||||
}
|
||||
}
|
||||
|
||||
// SuffixTest 处理_test 后缀
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (a *AutoCodeStruct) SuffixTest() {
|
||||
if strings.HasSuffix(a.HumpPackageName, "test") {
|
||||
a.HumpPackageName = a.HumpPackageName + "_"
|
||||
}
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
FieldName string `json:"fieldName"` // Field名
|
||||
FieldDesc string `json:"fieldDesc"` // 中文名
|
||||
FieldType string `json:"fieldType"` // Field数据类型
|
||||
FieldJson string `json:"fieldJson"` // FieldJson
|
||||
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
|
||||
Comment string `json:"comment"` // 数据库字段描述
|
||||
ColumnName string `json:"columnName"` // 数据库字段
|
||||
FieldSearchType string `json:"fieldSearchType"` // 搜索条件
|
||||
DictType string `json:"dictType"` // 字典
|
||||
Require bool `json:"require"` // 是否必填
|
||||
ErrorText string `json:"errorText"` // 校验失败文字
|
||||
Clearable bool `json:"clearable"` // 是否可清空
|
||||
Sort bool `json:"sort"` // 是否增加排序
|
||||
}
|
||||
|
||||
var ErrAutoMove error = errors.New("创建代码成功并移动文件成功")
|
||||
|
||||
type SysAutoCode struct {
|
||||
global.GVA_MODEL
|
||||
PackageName string `json:"packageName" gorm:"comment:包名"`
|
||||
Label string `json:"label" gorm:"comment:展示名"`
|
||||
Desc string `json:"desc" gorm:"comment:描述"`
|
||||
}
|
||||
|
||||
type AutoPlugReq struct {
|
||||
PlugName string `json:"plugName"` // 必然大写开头
|
||||
Snake string `json:"snake"` // 后端自动转为 snake
|
||||
RouterGroup string `json:"routerGroup"`
|
||||
HasGlobal bool `json:"hasGlobal"`
|
||||
HasRequest bool `json:"hasRequest"`
|
||||
HasResponse bool `json:"hasResponse"`
|
||||
NeedModel bool `json:"needModel"`
|
||||
Global []AutoPlugInfo `json:"global,omitempty"`
|
||||
Request []AutoPlugInfo `json:"request,omitempty"`
|
||||
Response []AutoPlugInfo `json:"response,omitempty"`
|
||||
}
|
||||
|
||||
func (a *AutoPlugReq) CheckList() {
|
||||
a.Global = bind(a.Global)
|
||||
a.Request = bind(a.Request)
|
||||
a.Response = bind(a.Response)
|
||||
|
||||
}
|
||||
func bind(req []AutoPlugInfo) []AutoPlugInfo {
|
||||
var r []AutoPlugInfo
|
||||
for _, info := range req {
|
||||
if info.Effective() {
|
||||
r = append(r, info)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type AutoPlugInfo struct {
|
||||
Key string `json:"key"`
|
||||
Type string `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
||||
func (a AutoPlugInfo) Effective() bool {
|
||||
return a.Key != "" && a.Type != "" && a.Desc != ""
|
||||
}
|
40
model/system/sys_autocode_history.go
Normal file
40
model/system/sys_autocode_history.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"miniapp/global"
|
||||
"miniapp/model/common/request"
|
||||
)
|
||||
|
||||
// SysAutoCodeHistory 自动迁移代码记录,用于回滚,重放使用
|
||||
type SysAutoCodeHistory struct {
|
||||
global.GVA_MODEL
|
||||
Package string `json:"package"`
|
||||
BusinessDB string `json:"businessDB"`
|
||||
TableName string `json:"tableName"`
|
||||
RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息
|
||||
AutoCodePath string `gorm:"type:text" json:"autoCodePath,omitempty"` // 其他meta信息 path;path
|
||||
InjectionMeta string `gorm:"type:text" json:"injectionMeta,omitempty"` // 注入的内容 RouterPath@functionName@RouterString;
|
||||
StructName string `json:"structName"`
|
||||
StructCNName string `json:"structCNName"`
|
||||
ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容
|
||||
Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ...
|
||||
}
|
||||
|
||||
// ToRequestIds ApiIDs 转换 request.IdsReq
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (m *SysAutoCodeHistory) ToRequestIds() request.IdsReq {
|
||||
if m.ApiIDs == "" {
|
||||
return request.IdsReq{}
|
||||
}
|
||||
slice := strings.Split(m.ApiIDs, ";")
|
||||
ids := make([]int, 0, len(slice))
|
||||
length := len(slice)
|
||||
for i := 0; i < length; i++ {
|
||||
id, _ := strconv.ParseInt(slice[i], 10, 32)
|
||||
ids = append(ids, int(id))
|
||||
}
|
||||
return request.IdsReq{Ids: ids}
|
||||
}
|
42
model/system/sys_base_menu.go
Normal file
42
model/system/sys_base_menu.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
type SysBaseMenu struct {
|
||||
global.GVA_MODEL
|
||||
MenuLevel uint `json:"-"`
|
||||
ParentId string `json:"parentId" gorm:"comment:父菜单ID"` // 父菜单ID
|
||||
Path string `json:"path" gorm:"comment:路由path"` // 路由path
|
||||
Name string `json:"name" gorm:"comment:路由name"` // 路由name
|
||||
Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"` // 是否在列表隐藏
|
||||
Component string `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径
|
||||
Sort int `json:"sort" gorm:"comment:排序标记"` // 排序标记
|
||||
Meta `json:"meta" gorm:"embedded;comment:附加属性"` // 附加属性
|
||||
SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
|
||||
Children []SysBaseMenu `json:"children" gorm:"-"`
|
||||
Parameters []SysBaseMenuParameter `json:"parameters"`
|
||||
MenuBtn []SysBaseMenuBtn `json:"menuBtn"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
ActiveName string `json:"activeName" gorm:"comment:高亮菜单"`
|
||||
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"` // 是否缓存
|
||||
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中)
|
||||
Title string `json:"title" gorm:"comment:菜单名"` // 菜单名
|
||||
Icon string `json:"icon" gorm:"comment:菜单图标"` // 菜单图标
|
||||
CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"` // 自动关闭tab
|
||||
}
|
||||
|
||||
type SysBaseMenuParameter struct {
|
||||
global.GVA_MODEL
|
||||
SysBaseMenuID uint
|
||||
Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"` // 地址栏携带参数为params还是query
|
||||
Key string `json:"key" gorm:"comment:地址栏携带参数的key"` // 地址栏携带参数的key
|
||||
Value string `json:"value" gorm:"comment:地址栏携带参数的值"` // 地址栏携带参数的值
|
||||
}
|
||||
|
||||
func (SysBaseMenu) TableName() string {
|
||||
return "sys_base_menus"
|
||||
}
|
22
model/system/sys_chatgpt.go
Normal file
22
model/system/sys_chatgpt.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package system
|
||||
|
||||
type ChatGpt struct {
|
||||
DBName string `json:"dbname,omitempty"`
|
||||
Chat string `json:"chat,omitempty"`
|
||||
ChatID string `json:"chatID,omitempty"`
|
||||
}
|
||||
|
||||
type SysChatGptOption struct {
|
||||
SK string `json:"sk"`
|
||||
}
|
||||
|
||||
type ChatField struct {
|
||||
TABLE_NAME string
|
||||
COLUMN_NAME string
|
||||
COLUMN_COMMENT string
|
||||
}
|
||||
|
||||
type ChatFieldNoTable struct {
|
||||
COLUMN_NAME string
|
||||
COLUMN_COMMENT string
|
||||
}
|
20
model/system/sys_dictionary.go
Normal file
20
model/system/sys_dictionary.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// 自动生成模板SysDictionary
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysDictionary struct {
|
||||
global.GVA_MODEL
|
||||
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中)
|
||||
Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"` // 字典名(英)
|
||||
Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"` // 状态
|
||||
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"` // 描述
|
||||
SysDictionaryDetails []SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"`
|
||||
}
|
||||
|
||||
func (SysDictionary) TableName() string {
|
||||
return "sys_dictionaries"
|
||||
}
|
21
model/system/sys_dictionary_detail.go
Normal file
21
model/system/sys_dictionary_detail.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// 自动生成模板SysDictionaryDetail
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysDictionaryDetail struct {
|
||||
global.GVA_MODEL
|
||||
Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"` // 展示值
|
||||
Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"` // 字典值
|
||||
Extend string `json:"extend" form:"extend" gorm:"column:extend;comment:扩展值"` // 扩展值
|
||||
Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"` // 启用状态
|
||||
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"` // 排序标记
|
||||
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"` // 关联标记
|
||||
}
|
||||
|
||||
func (SysDictionaryDetail) TableName() string {
|
||||
return "sys_dictionary_details"
|
||||
}
|
10
model/system/sys_jwt_blacklist.go
Normal file
10
model/system/sys_jwt_blacklist.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
type JwtBlacklist struct {
|
||||
global.GVA_MODEL
|
||||
Jwt string `gorm:"type:text;comment:jwt"`
|
||||
}
|
10
model/system/sys_menu_btn.go
Normal file
10
model/system/sys_menu_btn.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package system
|
||||
|
||||
import "miniapp/global"
|
||||
|
||||
type SysBaseMenuBtn struct {
|
||||
global.GVA_MODEL
|
||||
Name string `json:"name" gorm:"comment:按钮关键key"`
|
||||
Desc string `json:"desc" gorm:"按钮备注"`
|
||||
SysBaseMenuID uint `json:"sysBaseMenuID" gorm:"comment:菜单ID"`
|
||||
}
|
24
model/system/sys_operation_record.go
Normal file
24
model/system/sys_operation_record.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// 自动生成模板SysOperationRecord
|
||||
package system
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysOperationRecord struct {
|
||||
global.GVA_MODEL
|
||||
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip
|
||||
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法
|
||||
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径
|
||||
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态
|
||||
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
|
||||
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"` // 代理
|
||||
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息
|
||||
Body string `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"` // 请求Body
|
||||
Resp string `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"` // 响应Body
|
||||
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id
|
||||
User SysUser `json:"user"`
|
||||
}
|
10
model/system/sys_system.go
Normal file
10
model/system/sys_system.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"miniapp/config"
|
||||
)
|
||||
|
||||
// 配置文件结构体
|
||||
type System struct {
|
||||
Config config.Server `json:"config"`
|
||||
}
|
28
model/system/sys_user.go
Normal file
28
model/system/sys_user.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/gofrs/uuid/v5"
|
||||
"miniapp/global"
|
||||
)
|
||||
|
||||
type SysUser struct {
|
||||
global.GVA_MODEL
|
||||
UUID uuid.UUID `json:"uuid" gorm:"index;comment:用户UUID"` // 用户UUID
|
||||
Username string `json:"userName" gorm:"index;comment:用户登录名"` // 用户登录名
|
||||
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
SideMode string `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"` // 用户侧边主题
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
|
||||
BaseColor string `json:"baseColor" gorm:"default:#fff;comment:基础颜色"` // 基础颜色
|
||||
ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"` // 活跃颜色
|
||||
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
|
||||
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"`
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
Enable int `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
|
||||
}
|
||||
|
||||
func (SysUser) TableName() string {
|
||||
return "sys_users"
|
||||
}
|
11
model/system/sys_user_authority.go
Normal file
11
model/system/sys_user_authority.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package system
|
||||
|
||||
// SysUserAuthority 是 sysUser 和 sysAuthority 的连接表
|
||||
type SysUserAuthority struct {
|
||||
SysUserId uint `gorm:"column:sys_user_id"`
|
||||
SysAuthorityAuthorityId uint `gorm:"column:sys_authority_authority_id"`
|
||||
}
|
||||
|
||||
func (s *SysUserAuthority) TableName() string {
|
||||
return "sys_user_authority"
|
||||
}
|
Reference in New Issue
Block a user