Merge branch 'dev2.7.7' into main
This commit is contained in:
@@ -21,6 +21,7 @@ type ApiGroup struct {
|
||||
AutoCodePackageApi
|
||||
AutoCodeHistoryApi
|
||||
AutoCodeTemplateApi
|
||||
SysParamsApi
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -35,6 +36,7 @@ var (
|
||||
dictionaryService = service.ServiceGroupApp.SystemServiceGroup.DictionaryService
|
||||
authorityBtnService = service.ServiceGroupApp.SystemServiceGroup.AuthorityBtnService
|
||||
systemConfigService = service.ServiceGroupApp.SystemServiceGroup.SystemConfigService
|
||||
sysParamsService = service.ServiceGroupApp.SystemServiceGroup.SysParamsService
|
||||
operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
|
||||
dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService
|
||||
autoCodeService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeService
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common"
|
||||
"github.com/goccy/go-json"
|
||||
"io"
|
||||
"strings"
|
||||
@@ -105,18 +107,24 @@ func (autoApi *AutoCodeApi) GetColumn(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (autoApi *AutoCodeApi) LLMAuto(c *gin.Context) {
|
||||
prompt := c.Query("prompt")
|
||||
mode := c.Query("mode")
|
||||
params := make(map[string]string)
|
||||
params["prompt"] = prompt
|
||||
params["mode"] = mode
|
||||
path := strings.ReplaceAll(global.GVA_CONFIG.AutoCode.AiPath, "{FUNC}", "api/chat/ai")
|
||||
var llm common.JSONMap
|
||||
err := c.ShouldBindJSON(&llm)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
if global.GVA_CONFIG.AutoCode.AiPath == "" {
|
||||
response.FailWithMessage("请先前往插件市场个人中心获取AiPath并填入config.yaml中", c)
|
||||
return
|
||||
}
|
||||
|
||||
path := strings.ReplaceAll(global.GVA_CONFIG.AutoCode.AiPath, "{FUNC}", fmt.Sprintf("api/chat/%s", llm["mode"]))
|
||||
res, err := request.HttpRequest(
|
||||
path,
|
||||
"POST",
|
||||
nil,
|
||||
params,
|
||||
nil,
|
||||
llm,
|
||||
)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("大模型生成失败!", zap.Error(err))
|
||||
|
171
server/api/v1/system/sys_params.go
Normal file
171
server/api/v1/system/sys_params.go
Normal file
@@ -0,0 +1,171 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type SysParamsApi struct{}
|
||||
|
||||
// CreateSysParams 创建参数
|
||||
// @Tags SysParams
|
||||
// @Summary 创建参数
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body system.SysParams true "创建参数"
|
||||
// @Success 200 {object} response.Response{msg=string} "创建成功"
|
||||
// @Router /sysParams/createSysParams [post]
|
||||
func (sysParamsApi *SysParamsApi) CreateSysParams(c *gin.Context) {
|
||||
var sysParams system.SysParams
|
||||
err := c.ShouldBindJSON(&sysParams)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
err = sysParamsService.CreateSysParams(&sysParams)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("创建失败!", zap.Error(err))
|
||||
response.FailWithMessage("创建失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("创建成功", c)
|
||||
}
|
||||
|
||||
// DeleteSysParams 删除参数
|
||||
// @Tags SysParams
|
||||
// @Summary 删除参数
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body system.SysParams true "删除参数"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除成功"
|
||||
// @Router /sysParams/deleteSysParams [delete]
|
||||
func (sysParamsApi *SysParamsApi) DeleteSysParams(c *gin.Context) {
|
||||
ID := c.Query("ID")
|
||||
err := sysParamsService.DeleteSysParams(ID)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("删除失败!", zap.Error(err))
|
||||
response.FailWithMessage("删除失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
|
||||
// DeleteSysParamsByIds 批量删除参数
|
||||
// @Tags SysParams
|
||||
// @Summary 批量删除参数
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
|
||||
// @Router /sysParams/deleteSysParamsByIds [delete]
|
||||
func (sysParamsApi *SysParamsApi) DeleteSysParamsByIds(c *gin.Context) {
|
||||
IDs := c.QueryArray("IDs[]")
|
||||
err := sysParamsService.DeleteSysParamsByIds(IDs)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
|
||||
response.FailWithMessage("批量删除失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("批量删除成功", c)
|
||||
}
|
||||
|
||||
// UpdateSysParams 更新参数
|
||||
// @Tags SysParams
|
||||
// @Summary 更新参数
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body system.SysParams true "更新参数"
|
||||
// @Success 200 {object} response.Response{msg=string} "更新成功"
|
||||
// @Router /sysParams/updateSysParams [put]
|
||||
func (sysParamsApi *SysParamsApi) UpdateSysParams(c *gin.Context) {
|
||||
var sysParams system.SysParams
|
||||
err := c.ShouldBindJSON(&sysParams)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
err = sysParamsService.UpdateSysParams(sysParams)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("更新失败!", zap.Error(err))
|
||||
response.FailWithMessage("更新失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("更新成功", c)
|
||||
}
|
||||
|
||||
// FindSysParams 用id查询参数
|
||||
// @Tags SysParams
|
||||
// @Summary 用id查询参数
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data query system.SysParams true "用id查询参数"
|
||||
// @Success 200 {object} response.Response{data=system.SysParams,msg=string} "查询成功"
|
||||
// @Router /sysParams/findSysParams [get]
|
||||
func (sysParamsApi *SysParamsApi) FindSysParams(c *gin.Context) {
|
||||
ID := c.Query("ID")
|
||||
resysParams, err := sysParamsService.GetSysParams(ID)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("查询失败!", zap.Error(err))
|
||||
response.FailWithMessage("查询失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(resysParams, c)
|
||||
}
|
||||
|
||||
// GetSysParamsList 分页获取参数列表
|
||||
// @Tags SysParams
|
||||
// @Summary 分页获取参数列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data query systemReq.SysParamsSearch true "分页获取参数列表"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
|
||||
// @Router /sysParams/getSysParamsList [get]
|
||||
func (sysParamsApi *SysParamsApi) GetSysParamsList(c *gin.Context) {
|
||||
var pageInfo systemReq.SysParamsSearch
|
||||
err := c.ShouldBindQuery(&pageInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
list, total, err := sysParamsService.GetSysParamsInfoList(pageInfo)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
||||
response.FailWithMessage("获取失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(response.PageResult{
|
||||
List: list,
|
||||
Total: total,
|
||||
Page: pageInfo.Page,
|
||||
PageSize: pageInfo.PageSize,
|
||||
}, "获取成功", c)
|
||||
}
|
||||
|
||||
// GetSysParam 根据key获取参数value
|
||||
// @Tags SysParams
|
||||
// @Summary 根据key获取参数value
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param key query string true "key"
|
||||
// @Success 200 {object} response.Response{data=system.SysParams,msg=string} "获取成功"
|
||||
// @Router /sysParams/getSysParam [get]
|
||||
func (sysParamsApi *SysParamsApi) GetSysParam(c *gin.Context) {
|
||||
k := c.Query("key")
|
||||
params, err := sysParamsService.GetSysParam(k)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
||||
response.FailWithMessage("获取失败:"+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(params, "获取成功", c)
|
||||
}
|
@@ -2,164 +2,103 @@
|
||||
|
||||
# jwt configuration
|
||||
jwt:
|
||||
signing-key: qmPlus
|
||||
expires-time: 7d
|
||||
buffer-time: 1d
|
||||
issuer: qmPlus
|
||||
signing-key: qmPlus
|
||||
expires-time: 7d
|
||||
buffer-time: 1d
|
||||
issuer: qmPlus
|
||||
# zap logger configuration
|
||||
zap:
|
||||
level: info
|
||||
format: console
|
||||
prefix: "[github.com/flipped-aurora/gin-vue-admin/server]"
|
||||
director: log
|
||||
show-line: true
|
||||
encode-level: LowercaseColorLevelEncoder
|
||||
stacktrace-key: stacktrace
|
||||
log-in-console: true
|
||||
retention-day: -1
|
||||
level: info
|
||||
format: console
|
||||
prefix: "[github.com/flipped-aurora/gin-vue-admin/server]"
|
||||
director: log
|
||||
show-line: true
|
||||
encode-level: LowercaseColorLevelEncoder
|
||||
stacktrace-key: stacktrace
|
||||
log-in-console: true
|
||||
retention-day: -1
|
||||
|
||||
# redis configuration
|
||||
redis:
|
||||
#是否使用redis集群模式
|
||||
useCluster: false
|
||||
#使用集群模式addr和db默认无效
|
||||
addr: 127.0.0.1:6379
|
||||
password: ""
|
||||
db: 0
|
||||
clusterAddrs:
|
||||
- "172.21.0.3:7000"
|
||||
- "172.21.0.4:7001"
|
||||
- "172.21.0.2:7002"
|
||||
|
||||
# redis-list configuration
|
||||
redis-list:
|
||||
- name: cache # 数据库的名称,注意: name 需要在 redis-list 中唯一
|
||||
useCluster: false # 是否使用redis集群模式
|
||||
addr: 127.0.0.1:6379 # 使用集群模式addr和db默认无效
|
||||
#是否使用redis集群模式
|
||||
useCluster: false
|
||||
#使用集群模式addr和db默认无效
|
||||
addr: 127.0.0.1:6379
|
||||
password: ""
|
||||
db: 0
|
||||
clusterAddrs:
|
||||
- "172.21.0.3:7000"
|
||||
- "172.21.0.4:7001"
|
||||
- "172.21.0.2:7002"
|
||||
- "172.21.0.3:7000"
|
||||
- "172.21.0.4:7001"
|
||||
- "172.21.0.2:7002"
|
||||
|
||||
# redis-list configuration
|
||||
redis-list:
|
||||
- name: cache # 数据库的名称,注意: name 需要在 redis-list 中唯一
|
||||
useCluster: false # 是否使用redis集群模式
|
||||
addr: 127.0.0.1:6379 # 使用集群模式addr和db默认无效
|
||||
password: ""
|
||||
db: 0
|
||||
clusterAddrs:
|
||||
- "172.21.0.3:7000"
|
||||
- "172.21.0.4:7001"
|
||||
- "172.21.0.2:7002"
|
||||
|
||||
# mongo configuration
|
||||
mongo:
|
||||
coll: ''
|
||||
options: ''
|
||||
database: ''
|
||||
username: ''
|
||||
password: ''
|
||||
auth-source: ''
|
||||
min-pool-size: 0
|
||||
max-pool-size: 100
|
||||
socket-timeout-ms: 0
|
||||
connect-timeout-ms: 0
|
||||
is-zap: false
|
||||
hosts:
|
||||
- host: ''
|
||||
port: ''
|
||||
coll: ''
|
||||
options: ''
|
||||
database: ''
|
||||
username: ''
|
||||
password: ''
|
||||
auth-source: ''
|
||||
min-pool-size: 0
|
||||
max-pool-size: 100
|
||||
socket-timeout-ms: 0
|
||||
connect-timeout-ms: 0
|
||||
is-zap: false
|
||||
hosts:
|
||||
- host: ''
|
||||
port: ''
|
||||
|
||||
# email configuration
|
||||
email:
|
||||
to: xxx@qq.com
|
||||
port: 465
|
||||
from: xxx@163.com
|
||||
host: smtp.163.com
|
||||
is-ssl: true
|
||||
secret: xxx
|
||||
nickname: test
|
||||
to: xxx@qq.com
|
||||
port: 465
|
||||
from: xxx@163.com
|
||||
host: smtp.163.com
|
||||
is-ssl: true
|
||||
secret: xxx
|
||||
nickname: test
|
||||
|
||||
# system configuration
|
||||
system:
|
||||
env: local # 修改为public可以关闭路由日志输出
|
||||
addr: 8888
|
||||
db-type: mysql
|
||||
oss-type: local # 控制oss选择走本地还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
|
||||
use-redis: false # 使用redis
|
||||
use-mongo: false # 使用mongo
|
||||
use-multipoint: false
|
||||
# IP限制次数 一个小时15000次
|
||||
iplimit-count: 15000
|
||||
# IP限制一个小时
|
||||
iplimit-time: 3600
|
||||
# 路由全局前缀
|
||||
router-prefix: ""
|
||||
# 严格角色模式 打开后权限将会存在上下级关系
|
||||
use-strict-auth: false
|
||||
env: local # 修改为public可以关闭路由日志输出
|
||||
addr: 8888
|
||||
db-type: mysql
|
||||
oss-type: local # 控制oss选择走本地还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
|
||||
use-redis: false # 使用redis
|
||||
use-mongo: false # 使用mongo
|
||||
use-multipoint: false
|
||||
# IP限制次数 一个小时15000次
|
||||
iplimit-count: 15000
|
||||
# IP限制一个小时
|
||||
iplimit-time: 3600
|
||||
# 路由全局前缀
|
||||
router-prefix: ""
|
||||
# 严格角色模式 打开后权限将会存在上下级关系
|
||||
use-strict-auth: false
|
||||
|
||||
# captcha configuration
|
||||
captcha:
|
||||
key-long: 6
|
||||
img-width: 240
|
||||
img-height: 80
|
||||
open-captcha: 0 # 0代表一直开启,大于0代表限制次数
|
||||
open-captcha-timeout: 3600 # open-captcha大于0时才生效
|
||||
key-long: 6
|
||||
img-width: 240
|
||||
img-height: 80
|
||||
open-captcha: 0 # 0代表一直开启,大于0代表限制次数
|
||||
open-captcha-timeout: 3600 # open-captcha大于0时才生效
|
||||
|
||||
# mysql connect configuration
|
||||
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://gin-vue-admin.com/docs/first_master)
|
||||
mysql:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
|
||||
# pgsql connect configuration
|
||||
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://gin-vue-admin.com/docs/first_master)
|
||||
pgsql:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
oracle:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
mssql:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
sqlite:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
db-list:
|
||||
- disable: true # 是否禁用
|
||||
type: "" # 数据库的类型,目前支持mysql、pgsql、mssql、oracle
|
||||
alias-name: "" # 数据库的名称,注意: alias-name 需要在db-list中唯一
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
@@ -171,28 +110,89 @@ db-list:
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
|
||||
# pgsql connect configuration
|
||||
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://gin-vue-admin.com/docs/first_master)
|
||||
pgsql:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
oracle:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
mssql:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
sqlite:
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
db-list:
|
||||
- disable: true # 是否禁用
|
||||
type: "" # 数据库的类型,目前支持mysql、pgsql、mssql、oracle
|
||||
alias-name: "" # 数据库的名称,注意: alias-name 需要在db-list中唯一
|
||||
path: ""
|
||||
port: ""
|
||||
config: ""
|
||||
db-name: ""
|
||||
username: ""
|
||||
password: ""
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: ""
|
||||
log-zap: false
|
||||
|
||||
# local configuration
|
||||
local:
|
||||
path: uploads/file
|
||||
store-path: uploads/file
|
||||
path: uploads/file
|
||||
store-path: uploads/file
|
||||
|
||||
# autocode configuration
|
||||
autocode:
|
||||
web: web/src
|
||||
root: "" # root 自动适配项目根目录, 请不要手动配置,他会在项目加载的时候识别出根路径
|
||||
server: server
|
||||
module: 'github.com/flipped-aurora/gin-vue-admin/server'
|
||||
ai-path: "" # AI服务路径
|
||||
web: web/src
|
||||
root: "" # root 自动适配项目根目录, 请不要手动配置,他会在项目加载的时候识别出根路径
|
||||
server: server
|
||||
module: 'github.com/flipped-aurora/gin-vue-admin/server'
|
||||
ai-path: "" # AI服务路径
|
||||
|
||||
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址)
|
||||
qiniu:
|
||||
zone: ZoneHuaDong
|
||||
bucket: ""
|
||||
img-path: ""
|
||||
use-https: false
|
||||
access-key: ""
|
||||
secret-key: ""
|
||||
use-cdn-domains: false
|
||||
zone: ZoneHuaDong
|
||||
bucket: ""
|
||||
img-path: ""
|
||||
use-https: false
|
||||
access-key: ""
|
||||
secret-key: ""
|
||||
use-cdn-domains: false
|
||||
|
||||
# minio oss configuration
|
||||
minio:
|
||||
@@ -206,72 +206,72 @@ minio:
|
||||
|
||||
# aliyun oss configuration
|
||||
aliyun-oss:
|
||||
endpoint: yourEndpoint
|
||||
access-key-id: yourAccessKeyId
|
||||
access-key-secret: yourAccessKeySecret
|
||||
bucket-name: yourBucketName
|
||||
bucket-url: yourBucketUrl
|
||||
base-path: yourBasePath
|
||||
endpoint: yourEndpoint
|
||||
access-key-id: yourAccessKeyId
|
||||
access-key-secret: yourAccessKeySecret
|
||||
bucket-name: yourBucketName
|
||||
bucket-url: yourBucketUrl
|
||||
base-path: yourBasePath
|
||||
|
||||
# tencent cos configuration
|
||||
tencent-cos:
|
||||
bucket: xxxxx-10005608
|
||||
region: ap-shanghai
|
||||
secret-id: your-secret-id
|
||||
secret-key: your-secret-key
|
||||
base-url: https://gin.vue.admin
|
||||
path-prefix: github.com/flipped-aurora/gin-vue-admin/server
|
||||
bucket: xxxxx-10005608
|
||||
region: ap-shanghai
|
||||
secret-id: your-secret-id
|
||||
secret-key: your-secret-key
|
||||
base-url: https://gin.vue.admin
|
||||
path-prefix: github.com/flipped-aurora/gin-vue-admin/server
|
||||
|
||||
# aws s3 configuration (minio compatible)
|
||||
aws-s3:
|
||||
bucket: xxxxx-10005608
|
||||
region: ap-shanghai
|
||||
endpoint: ""
|
||||
s3-force-path-style: false
|
||||
disable-ssl: false
|
||||
secret-id: your-secret-id
|
||||
secret-key: your-secret-key
|
||||
base-url: https://gin.vue.admin
|
||||
path-prefix: github.com/flipped-aurora/gin-vue-admin/server
|
||||
bucket: xxxxx-10005608
|
||||
region: ap-shanghai
|
||||
endpoint: ""
|
||||
s3-force-path-style: false
|
||||
disable-ssl: false
|
||||
secret-id: your-secret-id
|
||||
secret-key: your-secret-key
|
||||
base-url: https://gin.vue.admin
|
||||
path-prefix: github.com/flipped-aurora/gin-vue-admin/server
|
||||
|
||||
# cloudflare r2 configuration
|
||||
cloudflare-r2:
|
||||
bucket: xxxx0bucket
|
||||
base-url: https://gin.vue.admin.com
|
||||
path: uploads
|
||||
account-id: xxx_account_id
|
||||
access-key-id: xxx_key_id
|
||||
secret-access-key: xxx_secret_key
|
||||
bucket: xxxx0bucket
|
||||
base-url: https://gin.vue.admin.com
|
||||
path: uploads
|
||||
account-id: xxx_account_id
|
||||
access-key-id: xxx_key_id
|
||||
secret-access-key: xxx_secret_key
|
||||
|
||||
# huawei obs configuration
|
||||
hua-wei-obs:
|
||||
path: you-path
|
||||
bucket: you-bucket
|
||||
endpoint: you-endpoint
|
||||
access-key: you-access-key
|
||||
secret-key: you-secret-key
|
||||
path: you-path
|
||||
bucket: you-bucket
|
||||
endpoint: you-endpoint
|
||||
access-key: you-access-key
|
||||
secret-key: you-secret-key
|
||||
|
||||
# excel configuration
|
||||
excel:
|
||||
dir: ./resource/excel/
|
||||
dir: ./resource/excel/
|
||||
|
||||
# disk usage configuration
|
||||
disk-list:
|
||||
- mount-point: "/"
|
||||
- mount-point: "/"
|
||||
|
||||
# 跨域配置
|
||||
# 需要配合 server/initialize/router.go -> `Router.Use(middleware.CorsByRules())` 使用
|
||||
cors:
|
||||
mode: strict-whitelist # 放行模式: allow-all, 放行全部; whitelist, 白名单模式, 来自白名单内域名的请求添加 cors 头; strict-whitelist 严格白名单模式, 白名单外的请求一律拒绝
|
||||
whitelist:
|
||||
- allow-origin: example1.com
|
||||
allow-headers: Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id
|
||||
allow-methods: POST, GET
|
||||
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
|
||||
mode: strict-whitelist # 放行模式: allow-all, 放行全部; whitelist, 白名单模式, 来自白名单内域名的请求添加 cors 头; strict-whitelist 严格白名单模式, 白名单外的请求一律拒绝
|
||||
whitelist:
|
||||
- allow-origin: example1.com
|
||||
allow-headers: Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id
|
||||
allow-methods: POST, GET
|
||||
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
|
||||
|
||||
allow-credentials: true # 布尔值
|
||||
- allow-origin: example2.com
|
||||
allow-headers: content-type
|
||||
allow-methods: GET, POST
|
||||
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
|
||||
allow-credentials: true # 布尔值
|
||||
allow-credentials: true # 布尔值
|
||||
- allow-origin: example2.com
|
||||
allow-headers: content-type
|
||||
allow-methods: GET, POST
|
||||
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
|
||||
allow-credentials: true # 布尔值
|
@@ -39,7 +39,7 @@ func RunWindowsServer() {
|
||||
|
||||
fmt.Printf(`
|
||||
欢迎使用 gin-vue-admin
|
||||
当前版本:v2.7.5
|
||||
当前版本:v2.7.6
|
||||
加群方式:微信号:shouzi_1994 QQ群:470239250
|
||||
项目地址:https://github.com/flipped-aurora/gin-vue-admin
|
||||
插件市场:https://plugin.gin-vue-admin.com
|
||||
|
@@ -8087,7 +8087,7 @@ const docTemplate = `{
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "v2.7.5",
|
||||
Version: "v2.7.6",
|
||||
Host: "",
|
||||
BasePath: "",
|
||||
Schemes: []string{},
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"description": "使用gin+vue进行极速开发的全栈开发基础平台",
|
||||
"title": "Gin-Vue-Admin Swagger API接口文档",
|
||||
"contact": {},
|
||||
"version": "v2.7.5"
|
||||
"version": "v2.7.6"
|
||||
},
|
||||
"paths": {
|
||||
"/api/createApi": {
|
||||
|
@@ -1634,7 +1634,7 @@ info:
|
||||
contact: {}
|
||||
description: 使用gin+vue进行极速开发的全栈开发基础平台
|
||||
title: Gin-Vue-Admin Swagger API接口文档
|
||||
version: v2.7.5
|
||||
version: v2.7.6
|
||||
paths:
|
||||
/api/createApi:
|
||||
post:
|
||||
|
@@ -19,15 +19,15 @@ require (
|
||||
github.com/gofrs/uuid/v5 v5.3.0
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||
github.com/gookit/color v1.5.4
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.24.6+incompatible
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.24.9+incompatible
|
||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
|
||||
github.com/mholt/archiver/v4 v4.0.0-alpha.8
|
||||
github.com/mojocn/base64Captcha v1.3.6
|
||||
github.com/otiai10/copy v1.14.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/qiniu/api.v7/v7 v7.8.2
|
||||
github.com/qiniu/go-sdk/v7 v7.23.0
|
||||
github.com/qiniu/qmgo v1.1.8
|
||||
github.com/redis/go-redis/v9 v9.6.1
|
||||
github.com/redis/go-redis/v9 v9.6.2
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/shirou/gopsutil/v3 v3.24.5
|
||||
github.com/songzhibin97/gkit v1.2.13
|
||||
@@ -37,15 +37,15 @@ require (
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.16.3
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.55
|
||||
github.com/unrolled/secure v1.15.0
|
||||
github.com/xuri/excelize/v2 v2.8.1
|
||||
go.mongodb.org/mongo-driver v1.17.0
|
||||
go.uber.org/automaxprocs v1.5.3
|
||||
github.com/unrolled/secure v1.16.0
|
||||
github.com/xuri/excelize/v2 v2.9.0
|
||||
go.mongodb.org/mongo-driver v1.17.1
|
||||
go.uber.org/automaxprocs v1.6.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/crypto v0.28.0
|
||||
golang.org/x/sync v0.8.0
|
||||
golang.org/x/text v0.19.0
|
||||
gorm.io/datatypes v1.2.2
|
||||
gorm.io/datatypes v1.2.3
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/driver/postgres v1.5.9
|
||||
gorm.io/driver/sqlserver v1.5.3
|
||||
@@ -56,13 +56,15 @@ require (
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
|
||||
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect
|
||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||
github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect
|
||||
github.com/bodgit/plumbing v1.3.0 // indirect
|
||||
github.com/bodgit/sevenzip v1.5.2 // indirect
|
||||
github.com/bodgit/windows v1.0.1 // indirect
|
||||
github.com/bytedance/sonic v1.12.2 // indirect
|
||||
github.com/bytedance/sonic v1.12.3 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.0 // indirect
|
||||
github.com/casbin/govaluate v1.2.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
@@ -73,7 +75,10 @@ require (
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dsnet/compress v0.0.1 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
|
||||
github.com/elastic/go-sysinfo v1.14.2 // indirect
|
||||
github.com/elastic/go-windows v1.0.2 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||
github.com/gammazero/toposort v0.1.1 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/glebarez/go-sqlite v1.22.0 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
@@ -85,6 +90,7 @@ require (
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.22.1 // indirect
|
||||
github.com/gofrs/flock v0.12.1 // indirect
|
||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
|
||||
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
@@ -102,6 +108,7 @@ require (
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
@@ -122,11 +129,12 @@ require (
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/mozillazg/go-httpheader v0.4.0 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
|
||||
github.com/nwaples/rardecode/v2 v2.0.0-beta.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.4 // indirect
|
||||
@@ -141,7 +149,7 @@ require (
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/therootcompany/xz v1.0.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
||||
github.com/tklauser/numcpus v0.8.0 // indirect
|
||||
github.com/tklauser/numcpus v0.9.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/ulikunitz/xz v0.5.12 // indirect
|
||||
@@ -155,19 +163,21 @@ require (
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
||||
golang.org/x/arch v0.10.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/image v0.20.0 // indirect
|
||||
golang.org/x/arch v0.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
|
||||
golang.org/x/image v0.21.0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/time v0.6.0 // indirect
|
||||
golang.org/x/tools v0.25.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
golang.org/x/tools v0.26.0 // indirect
|
||||
google.golang.org/protobuf v1.35.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/hints v1.1.2 // indirect
|
||||
gorm.io/plugin/dbresolver v1.5.3 // indirect
|
||||
howett.net/plist v1.0.1 // indirect
|
||||
modernc.org/fileutil v1.3.0 // indirect
|
||||
modernc.org/libc v1.61.0 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.8.0 // indirect
|
||||
|
429
server/go.sum
429
server/go.sum
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,7 @@ func (e *ensureTables) MigrateTable(ctx context.Context) (context.Context, error
|
||||
sysModel.SysExportTemplate{},
|
||||
sysModel.Condition{},
|
||||
sysModel.JoinTemplate{},
|
||||
sysModel.SysParams{},
|
||||
|
||||
adapter.CasbinRule{},
|
||||
|
||||
|
@@ -55,6 +55,7 @@ func RegisterTables() {
|
||||
system.SysExportTemplate{},
|
||||
system.Condition{},
|
||||
system.JoinTemplate{},
|
||||
system.SysParams{},
|
||||
|
||||
example.ExaFile{},
|
||||
example.ExaCustomer{},
|
||||
|
@@ -91,6 +91,7 @@ func Routers() *gin.Engine {
|
||||
systemRouter.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理
|
||||
systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup) // 按钮权限管理
|
||||
systemRouter.InitSysExportTemplateRouter(PrivateGroup) // 导出模板
|
||||
systemRouter.InitSysParamsRouter(PrivateGroup, PublicGroup) // 参数管理
|
||||
exampleRouter.InitCustomerRouter(PrivateGroup) // 客户路由
|
||||
exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
//go:generate go mod download
|
||||
|
||||
// @title Gin-Vue-Admin Swagger API接口文档
|
||||
// @version v2.7.5
|
||||
// @version v2.7.6
|
||||
// @description 使用gin+vue进行极速开发的全栈开发基础平台
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
|
@@ -3,6 +3,7 @@ package request
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"go/token"
|
||||
@@ -26,7 +27,9 @@ type AutoCode struct {
|
||||
AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu
|
||||
AutoCreateBtnAuth bool `json:"autoCreateBtnAuth" example:"false"` // 是否自动创建按钮权限
|
||||
OnlyTemplate bool `json:"onlyTemplate" example:"false"` // 是否只生成模板
|
||||
IsAdd bool `json:"isAdd" example:"false"` // 是否新增
|
||||
Fields []*AutoCodeField `json:"fields"`
|
||||
Module string `json:"-"`
|
||||
DictTypes []string `json:"-"`
|
||||
PrimaryField *AutoCodeField `json:"primaryField"`
|
||||
DataSourceMap map[string]*DataSource `json:"-"`
|
||||
@@ -110,6 +113,7 @@ func (r *AutoCode) Menu(template string) model.SysBaseMenu {
|
||||
// Pretreatment 预处理
|
||||
// Author [SliverHorn](https://github.com/SliverHorn)
|
||||
func (r *AutoCode) Pretreatment() error {
|
||||
r.Module = global.GVA_CONFIG.AutoCode.Module
|
||||
if token.IsKeyword(r.Abbreviation) {
|
||||
r.Abbreviation = r.Abbreviation + "_"
|
||||
} // go 关键字处理
|
||||
@@ -247,6 +251,7 @@ type AutoFunc struct {
|
||||
HumpPackageName string `json:"humpPackageName"` // go文件名称
|
||||
Method string `json:"method"` // 方法
|
||||
IsPlugin bool `json:"isPlugin"` // 是否插件
|
||||
IsAuth bool `json:"isAuth"` // 是否鉴权
|
||||
}
|
||||
|
||||
type InitMenu struct {
|
||||
@@ -259,3 +264,8 @@ type InitApi struct {
|
||||
PlugName string `json:"plugName"`
|
||||
APIs []uint `json:"apis"`
|
||||
}
|
||||
|
||||
type LLMAutoCode struct {
|
||||
Prompt string `json:"prompt" form:"prompt" gorm:"column:prompt;comment:提示语;type:text;"` //提示语
|
||||
Mode string `json:"mode" form:"mode" gorm:"column:mode;comment:模式;type:text;"` //模式
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
)
|
||||
|
||||
@@ -9,11 +10,13 @@ type SysAutoCodePackageCreate struct {
|
||||
Label string `json:"label" example:"展示名"`
|
||||
Template string `json:"template" example:"模版"`
|
||||
PackageName string `json:"packageName" example:"包名"`
|
||||
Module string `json:"-" example:"模块"`
|
||||
}
|
||||
|
||||
func (r *SysAutoCodePackageCreate) AutoCode() AutoCode {
|
||||
return AutoCode{
|
||||
Package: r.PackageName,
|
||||
Module: global.GVA_CONFIG.AutoCode.Module,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +26,6 @@ func (r *SysAutoCodePackageCreate) Create() model.SysAutoCodePackage {
|
||||
Label: r.Label,
|
||||
Template: r.Template,
|
||||
PackageName: r.PackageName,
|
||||
Module: global.GVA_CONFIG.AutoCode.Module,
|
||||
}
|
||||
}
|
||||
|
14
server/model/system/request/sys_params.go
Normal file
14
server/model/system/request/sys_params.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysParamsSearch struct {
|
||||
StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
Name string `json:"name" form:"name" `
|
||||
Key string `json:"key" form:"key" `
|
||||
request.PageInfo
|
||||
}
|
@@ -10,6 +10,7 @@ type SysAutoCodePackage struct {
|
||||
Label string `json:"label" gorm:"comment:展示名"`
|
||||
Template string `json:"template" gorm:"comment:模版"`
|
||||
PackageName string `json:"packageName" gorm:"comment:包名"`
|
||||
Module string `json:"-" example:"模块"`
|
||||
}
|
||||
|
||||
func (s *SysAutoCodePackage) TableName() string {
|
||||
|
20
server/model/system/sys_params.go
Normal file
20
server/model/system/sys_params.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// 自动生成模板SysParams
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// 参数 结构体 SysParams
|
||||
type SysParams struct {
|
||||
global.GVA_MODEL
|
||||
Name string `json:"name" form:"name" gorm:"column:name;comment:参数名称;" binding:"required"` //参数名称
|
||||
Key string `json:"key" form:"key" gorm:"column:key;comment:参数键;" binding:"required"` //参数键
|
||||
Value string `json:"value" form:"value" gorm:"column:value;comment:参数值;" binding:"required"` //参数值
|
||||
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:参数说明;"` //参数说明
|
||||
}
|
||||
|
||||
// TableName 参数 SysParams自定义表名 sys_params
|
||||
func (SysParams) TableName() string {
|
||||
return "sys_params"
|
||||
}
|
@@ -2,17 +2,17 @@ package {{.Package}}
|
||||
|
||||
import (
|
||||
{{if not .OnlyTemplate}}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/{{.Package}}"
|
||||
{{.Package}}Req "github.com/flipped-aurora/gin-vue-admin/server/model/{{.Package}}/request"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/model/common/response"
|
||||
"{{.Module}}/model/{{.Package}}"
|
||||
{{.Package}}Req "{{.Module}}/model/{{.Package}}/request"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
{{- if .AutoCreateResource}}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/utils"
|
||||
"{{.Module}}/utils"
|
||||
{{- end }}
|
||||
{{- else}}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"{{.Module}}/model/common/response"
|
||||
"github.com/gin-gonic/gin"
|
||||
{{- end}}
|
||||
)
|
||||
|
@@ -1,10 +1,37 @@
|
||||
{{- if .IsAdd}}
|
||||
// 在结构体中新增如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "picture" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "video" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "file" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if eq .FieldType "pictures" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if eq .FieldType "richtext" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "json" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"`
|
||||
{{- else if eq .FieldType "array" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if ne .FieldType "string" }}
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else }}
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}} {{ end }}
|
||||
{{- end }}
|
||||
|
||||
{{ else }}
|
||||
// 自动生成模板{{.StructName}}
|
||||
package {{.Package}}
|
||||
|
||||
{{- if not .OnlyTemplate}}
|
||||
import (
|
||||
{{- if .GvaModel }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"{{.Module}}/global"
|
||||
{{- end }}
|
||||
{{- if or .HasTimer }}
|
||||
"time"
|
||||
@@ -58,3 +85,6 @@ func ({{.StructName}}) TableName() string {
|
||||
return "{{.TableName}}"
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ end }}
|
@@ -1,8 +1,31 @@
|
||||
{{- if .IsAdd}}
|
||||
// 在结构体中新增如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if ne .FieldSearchType ""}}
|
||||
{{- if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
Start{{.FieldName}} *{{.FieldType}} `json:"start{{.FieldName}}" form:"start{{.FieldName}}"`
|
||||
End{{.FieldName}} *{{.FieldType}} `json:"end{{.FieldName}}" form:"end{{.FieldName}}"`
|
||||
{{- else }}
|
||||
{{- if or (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "pictures") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- else if ne .FieldType "string" }}
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- else }}
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
{{- if .NeedSort}}
|
||||
Sort string `json:"sort" form:"sort"`
|
||||
Order string `json:"order" form:"order"`
|
||||
{{- end}}
|
||||
{{- else }}
|
||||
package request
|
||||
|
||||
import (
|
||||
{{- if not .OnlyTemplate }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"{{.Module}}/model/common/request"
|
||||
{{ if or .HasSearchTimer .GvaModel}}"time"{{ end }}
|
||||
{{- end }}
|
||||
)
|
||||
@@ -36,3 +59,4 @@ type {{.StructName}}Search struct{
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
}
|
||||
{{- end }}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package {{.Package}}
|
||||
|
||||
import (
|
||||
{{if .OnlyTemplate}}// {{ end}}"github.com/flipped-aurora/gin-vue-admin/server/middleware"
|
||||
{{if .OnlyTemplate}}// {{ end}}"{{.Module}}/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
@@ -1,10 +1,66 @@
|
||||
{{- $db := "" }}
|
||||
{{- if eq .BusinessDB "" }}
|
||||
{{- $db = "global.GVA_DB" }}
|
||||
{{- else}}
|
||||
{{- $db = printf "global.MustGetGlobalDBByDBName(\"%s\")" .BusinessDB }}
|
||||
{{- end}}
|
||||
|
||||
{{- if .IsAdd}}
|
||||
|
||||
// Get{{.StructName}}InfoList 新增搜索语句
|
||||
{{- range .Fields}}
|
||||
{{- if .FieldSearchType}}
|
||||
{{- if or (eq .FieldType "string") (eq .FieldType "enum") (eq .FieldType "pictures") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
|
||||
if info.{{.FieldName}} != "" {
|
||||
{{- if or (eq .FieldType "enum") (eq .FieldType "string") }}
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
|
||||
{{- else}}
|
||||
// 数据类型为复杂类型,请根据业务需求自行实现复杂类型的查询业务
|
||||
{{- end}}
|
||||
}
|
||||
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
if info.Start{{.FieldName}} != nil && info.End{{.FieldName}} != nil {
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ? AND ? ",info.Start{{.FieldName}},info.End{{.FieldName}})
|
||||
}
|
||||
{{- else}}
|
||||
if info.{{.FieldName}} != nil {
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
// Get{{.StructName}}InfoList 新增排序语句 请自行在搜索语句中添加orderMap内容
|
||||
{{- range .Fields}}
|
||||
{{- if .Sort}}
|
||||
orderMap["{{.ColumnName}}"] = true
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// Get{{.StructName}}DataSource()方法新增关联语句
|
||||
{{range $key, $value := .DataSourceMap}}
|
||||
{{$key}} := make([]map[string]any, 0)
|
||||
{{ $dataDB := "" }}
|
||||
{{- if eq $value.DBName "" }}
|
||||
{{ $dataDB = $db }}
|
||||
{{- else}}
|
||||
{{ $dataDB = printf "global.MustGetGlobalDBByDBName(\"%s\")" $value.DBName }}
|
||||
{{- end}}
|
||||
{{$dataDB}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&{{$key}})
|
||||
res["{{$key}}"] = {{$key}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else}}
|
||||
package {{.Package}}
|
||||
|
||||
import (
|
||||
{{- if not .OnlyTemplate }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/{{.Package}}"
|
||||
{{.Package}}Req "github.com/flipped-aurora/gin-vue-admin/server/model/{{.Package}}/request"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/model/{{.Package}}"
|
||||
{{.Package}}Req "{{.Module}}/model/{{.Package}}/request"
|
||||
{{- if .AutoCreateResource }}
|
||||
"gorm.io/gorm"
|
||||
{{- end}}
|
||||
@@ -13,13 +69,6 @@ import (
|
||||
|
||||
type {{.StructName}}Service struct {}
|
||||
|
||||
{{- $db := "" }}
|
||||
{{- if eq .BusinessDB "" }}
|
||||
{{- $db = "global.GVA_DB" }}
|
||||
{{- else}}
|
||||
{{- $db = printf "global.MustGetGlobalDBByDBName(\"%s\")" .BusinessDB }}
|
||||
{{- end}}
|
||||
|
||||
{{- if not .OnlyTemplate }}
|
||||
// Create{{.StructName}} 创建{{.Description}}记录
|
||||
// Author [yourname](https://github.com/yourname)
|
||||
@@ -166,3 +215,4 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}Public(
|
||||
// 此方法为获取数据源定义的数据
|
||||
// 请自行实现
|
||||
}
|
||||
{{- end }}
|
@@ -1,3 +1,159 @@
|
||||
{{- if .IsAdd }}
|
||||
// 新增表单中增加如下代码
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
<el-switch v-model="formData.{{.FieldJson}}" active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" clearable ></el-switch>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<el-input v-model="formData.{{.FieldJson}}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
<RichEdit v-model="formData.{{.FieldJson}}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
// 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
<el-date-picker v-model="formData.{{ .FieldJson }}" type="date" style="width:100%" placeholder="选择日期" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
<el-input-number v-model="formData.{{ .FieldJson }}" style="width:100%" :precision="2" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="item in [{{.DataTypeLong}}]" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<SelectImage
|
||||
multiple
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="video"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<SelectFile v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 字典增加如下代码
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
|
||||
// 基础formData结构增加如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
{{.FieldJson}}: 0,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
{{.FieldJson}}: {},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
// 验证规则中增加如下字段
|
||||
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
message: '{{ .ErrorText }}',
|
||||
trigger: ['input','blur'],
|
||||
},
|
||||
{{- if eq .FieldType "string" }}
|
||||
{
|
||||
whitespace: true,
|
||||
message: '不能只输入空格',
|
||||
trigger: ['input', 'blur'],
|
||||
}
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
|
||||
// 获取数据源
|
||||
const dataSource = ref([])
|
||||
const getDataSourceFunc = async()=>{
|
||||
const res = await get{{.StructName}}DataSource()
|
||||
if (res.code === 0) {
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if not .OnlyTemplate }}
|
||||
<template>
|
||||
<div>
|
||||
@@ -248,3 +404,4 @@ const back = () => {
|
||||
<style>
|
||||
</style>
|
||||
{{- end }}
|
||||
{{- end }}
|
@@ -1,5 +1,349 @@
|
||||
{{- $global := . }}
|
||||
{{- $templateID := printf "%s_%s" .Package .StructName }}
|
||||
{{- if .IsAdd }}
|
||||
// 请在搜索条件中增加如下代码
|
||||
{{- range .Fields}} {{- if .FieldSearchType}} {{- if eq .FieldType "bool" }}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择">
|
||||
<el-option
|
||||
key="true"
|
||||
label="是"
|
||||
value="true">
|
||||
</el-option>
|
||||
<el-option
|
||||
key="false"
|
||||
label="否"
|
||||
value="false">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else if .DictType}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
{{- if eq .FieldType "float64" "int"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
<el-input v-model.number="searchInfo.start{{.FieldName}}" placeholder="最小值" />
|
||||
—
|
||||
<el-input v-model.number="searchInfo.end{{.FieldName}}" placeholder="最大值" />
|
||||
{{- else}}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" placeholder="请选择" style="width:100%" :clearable="true" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else}}
|
||||
<el-input v-model.number="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- else if eq .FieldType "time.Time"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
<template #label>
|
||||
<span>
|
||||
{{.FieldDesc}}
|
||||
<el-tooltip content="搜索范围是开始日期(包含)至结束日期(不包含)">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
<el-date-picker v-model="searchInfo.start{{.FieldName}}" type="datetime" placeholder="开始日期" :disabled-date="time=> searchInfo.end{{.FieldName}} ? time.getTime() > searchInfo.end{{.FieldName}}.getTime() : false"></el-date-picker>
|
||||
—
|
||||
<el-date-picker v-model="searchInfo.end{{.FieldName}}" type="datetime" placeholder="结束日期" :disabled-date="time=> searchInfo.start{{.FieldName}} ? time.getTime() < searchInfo.start{{.FieldName}}.getTime() : false"></el-date-picker>
|
||||
{{- else}}
|
||||
<el-date-picker v-model="searchInfo.{{.FieldJson}}" type="datetime" placeholder="搜索条件"></el-date-picker>
|
||||
{{- end}}
|
||||
{{- else}}
|
||||
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end}}
|
||||
</el-form-item>{{ end }}{{ end }}{{ end }}
|
||||
|
||||
|
||||
// 表格增加如下列代码
|
||||
|
||||
{{- range .Fields}}
|
||||
{{- if .Table}}
|
||||
{{- if .CheckDataSource }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{if eq .DataSource.Association 2}}
|
||||
<el-tag v-for="(item,key) in filterDataSource(dataSource.{{.FieldJson}},scope.row.{{.FieldJson}})" :key="key">
|
||||
{{ "{{ item }}" }}
|
||||
</el-tag>
|
||||
{{ else }}
|
||||
<span>{{"{{"}} filterDataSource(dataSource.{{.FieldJson}},scope.row.{{.FieldJson}}) {{"}}"}}</span>
|
||||
{{ end }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if .DictType}}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "bool" }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">{{"{{"}} formatBoolean(scope.row.{{.FieldJson}}) {{"}}"}}</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "time.Time" }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="180">
|
||||
<template #default="scope">{{"{{"}} formatDate(scope.row.{{.FieldJson}}) {{"}}"}}</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "picture" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<el-image preview-teleported style="width: 100px; height: 100px" :src="getUrl(scope.row.{{.FieldJson}})" fit="cover"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "pictures" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<div class="multiple-img-box">
|
||||
<el-image preview-teleported v-for="(item,index) in scope.row.{{.FieldJson}}" :key="index" style="width: 80px; height: 80px" :src="getUrl(item)" fit="cover"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "video" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<video
|
||||
style="width: 100px; height: 100px"
|
||||
muted
|
||||
preload="metadata"
|
||||
>
|
||||
<source :src="getUrl(scope.row.{{.FieldJson}}) + '#t=1'">
|
||||
</video>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "richtext" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
[富文本内容]
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "file" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<div class="file-list">
|
||||
<el-tag v-for="file in scope.row.{{.FieldJson}}" :key="file.uid" @click="downloadFile(file.url)">{{"{{"}}file.name{{"}}"}}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "json" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
[JSON]
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "array" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<ArrayCtrl v-model="scope.row.{{ .FieldJson }}"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 新增表单中增加如下代码
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
<el-switch v-model="formData.{{.FieldJson}}" active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" clearable ></el-switch>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<el-input v-model="formData.{{.FieldJson}}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
<RichEdit v-model="formData.{{.FieldJson}}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
// 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
<el-date-picker v-model="formData.{{ .FieldJson }}" type="date" style="width:100%" placeholder="选择日期" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
<el-input-number v-model="formData.{{ .FieldJson }}" style="width:100%" :precision="2" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="item in [{{.DataTypeLong}}]" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<SelectImage
|
||||
multiple
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="video"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<SelectFile v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 查看抽屉中增加如下代码
|
||||
|
||||
{{- range .Fields}}
|
||||
{{- if .Desc }}
|
||||
<el-descriptions-item label="{{ .FieldDesc }}">
|
||||
{{- if and (ne .FieldType "picture" ) (ne .FieldType "pictures" ) (ne .FieldType "file" ) (ne .FieldType "array" ) }}
|
||||
{{"{{"}} detailFrom.{{.FieldJson}} {{"}}"}}
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<el-image style="width: 50px; height: 50px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :src="getUrl(detailFrom.{{ .FieldJson }})" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="detailFrom.{{ .FieldJson }}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<el-image style="width: 50px; height: 50px; margin-right: 10px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :initial-index="index" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index" :src="getUrl(item)" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<div class="fileBtn" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index">
|
||||
<el-button type="primary" text bg @click="onDownloadFile(item.url)">
|
||||
<el-icon style="margin-right: 5px"><Download /></el-icon>
|
||||
{{"{{"}}item.name{{"}}"}}
|
||||
</el-button>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 字典增加如下代码
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
|
||||
// setOptions方法中增加如下调用
|
||||
|
||||
{{- range $index, $element := .DictTypes }}
|
||||
{{ $element }}Options.value = await getDictFunc('{{$element}}')
|
||||
{{- end }}
|
||||
|
||||
// 基础formData结构(变量处和关闭表单处)增加如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
{{.FieldJson}}: 0,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
{{.FieldJson}}: {},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
// 验证规则中增加如下字段
|
||||
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
message: '{{ .ErrorText }}',
|
||||
trigger: ['input','blur'],
|
||||
},
|
||||
{{- if eq .FieldType "string" }}
|
||||
{
|
||||
whitespace: true,
|
||||
message: '不能只输入空格',
|
||||
trigger: ['input', 'blur'],
|
||||
}
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
|
||||
// 获取数据源
|
||||
const dataSource = ref([])
|
||||
const getDataSourceFunc = async()=>{
|
||||
const res = await get{{.StructName}}DataSource()
|
||||
if (res.code === 0) {
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
|
||||
{{- else }}
|
||||
|
||||
{{- if not .OnlyTemplate}}
|
||||
<template>
|
||||
<div>
|
||||
@@ -76,7 +420,6 @@
|
||||
{{- else}}
|
||||
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end}}
|
||||
|
||||
</el-form-item>{{ end }}{{ end }}{{ end }}{{ end }}
|
||||
|
||||
<template v-if="showAllQuery">
|
||||
@@ -906,4 +1249,6 @@ defineOptions({
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
@@ -2,17 +2,17 @@ package api
|
||||
|
||||
import (
|
||||
{{if not .OnlyTemplate}}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{.Package}}/model"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{.Package}}/model/request"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/model/common/response"
|
||||
"{{.Module}}/plugin/{{.Package}}/model"
|
||||
"{{.Module}}/plugin/{{.Package}}/model/request"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
{{- if .AutoCreateResource}}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/utils"
|
||||
"{{.Module}}/utils"
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"{{.Module}}/model/common/response"
|
||||
"github.com/gin-gonic/gin"
|
||||
{{- end }}
|
||||
)
|
||||
|
@@ -2,8 +2,8 @@ package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/plugin-tool/utils"
|
||||
model "{{.Module}}/model/system"
|
||||
"{{.Module}}/plugin/plugin-tool/utils"
|
||||
)
|
||||
|
||||
func Api(ctx context.Context) {
|
||||
|
@@ -3,8 +3,7 @@ package initialize
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
|
||||
"{{.Module}}/global"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@@ -2,8 +2,8 @@ package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/plugin-tool/utils"
|
||||
model "{{.Module}}/model/system"
|
||||
"{{.Module}}/plugin/plugin-tool/utils"
|
||||
)
|
||||
|
||||
func Menu(ctx context.Context) {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/middleware"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
@@ -2,8 +2,8 @@ package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Package }}/plugin"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/plugin/{{ .Package }}/plugin"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@@ -1,9 +1,36 @@
|
||||
{{- if .IsAdd}}
|
||||
// 在结构体中新增如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "picture" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "video" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "file" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if eq .FieldType "pictures" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if eq .FieldType "richtext" }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else if eq .FieldType "json" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"object"`
|
||||
{{- else if eq .FieldType "array" }}
|
||||
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}type:text;" {{- if .Require }} binding:"required"{{- end -}} swaggertype:"array,object"`
|
||||
{{- else if ne .FieldType "string" }}
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- else }}
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"{{- if ne .FieldIndexType "" -}}{{ .FieldIndexType }};{{- end -}}{{- if .PrimaryKey -}}primarykey;{{- end -}}{{- if .DefaultValue -}}default:{{ .DefaultValue }};{{- end -}}column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}" {{- if .Require }} binding:"required"{{- end -}}`
|
||||
{{- end }} {{ if .FieldDesc }}//{{.FieldDesc}} {{ end }}
|
||||
{{- end }}
|
||||
|
||||
{{ else }}
|
||||
package model
|
||||
|
||||
{{- if not .OnlyTemplate}}
|
||||
import (
|
||||
{{- if .GvaModel }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"{{.Module}}/global"
|
||||
{{- end }}
|
||||
{{- if or .HasTimer }}
|
||||
"time"
|
||||
@@ -57,3 +84,4 @@ func ({{.StructName}}) TableName() string {
|
||||
return "{{.TableName}}"
|
||||
}
|
||||
{{ end }}
|
||||
{{ end }}
|
@@ -1,7 +1,30 @@
|
||||
{{- if .IsAdd}}
|
||||
// 在结构体中新增如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if ne .FieldSearchType ""}}
|
||||
{{- if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
Start{{.FieldName}} *{{.FieldType}} `json:"start{{.FieldName}}" form:"start{{.FieldName}}"`
|
||||
End{{.FieldName}} *{{.FieldType}} `json:"end{{.FieldName}}" form:"end{{.FieldName}}"`
|
||||
{{- else }}
|
||||
{{- if or (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "pictures") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
|
||||
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- else if ne .FieldType "string" }}
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- else }}
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
{{- if .NeedSort}}
|
||||
Sort string `json:"sort" form:"sort"`
|
||||
Order string `json:"order" form:"order"`
|
||||
{{- end}}
|
||||
{{- else }}
|
||||
package request
|
||||
{{- if not .OnlyTemplate}}
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"{{.Module}}/model/common/request"
|
||||
{{ if or .HasSearchTimer .GvaModel}}"time"{{ end }}
|
||||
)
|
||||
{{- end}}
|
||||
@@ -33,5 +56,6 @@ type {{.StructName}}Search struct{
|
||||
Sort string `json:"sort" form:"sort"`
|
||||
Order string `json:"order" form:"order"`
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
}
|
||||
{{- end }}
|
@@ -2,8 +2,8 @@ package {{ .Package }}
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Package }}/initialize"
|
||||
interfaces "github.com/flipped-aurora/gin-vue-admin/server/utils/plugin/v2"
|
||||
"{{.Module}}/plugin/{{ .Package }}/initialize"
|
||||
interfaces "{{.Module}}/utils/plugin/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
package plugin
|
||||
|
||||
import "github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Package }}/config"
|
||||
import "{{.Module}}/plugin/{{ .Package }}/config"
|
||||
|
||||
var Config config.Config
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
{{if .OnlyTemplate }} // {{end}}"github.com/flipped-aurora/gin-vue-admin/server/middleware"
|
||||
{{if .OnlyTemplate }} // {{end}}"{{.Module}}/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
@@ -1,10 +1,66 @@
|
||||
{{- $db := "" }}
|
||||
{{- if eq .BusinessDB "" }}
|
||||
{{- $db = "global.GVA_DB" }}
|
||||
{{- else}}
|
||||
{{- $db = printf "global.MustGetGlobalDBByDBName(\"%s\")" .BusinessDB }}
|
||||
{{- end}}
|
||||
|
||||
{{- if .IsAdd}}
|
||||
|
||||
// Get{{.StructName}}InfoList 新增搜索语句
|
||||
{{- range .Fields}}
|
||||
{{- if .FieldSearchType}}
|
||||
{{- if or (eq .FieldType "string") (eq .FieldType "enum") (eq .FieldType "pictures") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
|
||||
if info.{{.FieldName}} != "" {
|
||||
{{- if or (eq .FieldType "enum") (eq .FieldType "string") }}
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
|
||||
{{- else}}
|
||||
// 数据类型为复杂类型,请根据业务需求自行实现复杂类型的查询业务
|
||||
{{- end}}
|
||||
}
|
||||
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
if info.Start{{.FieldName}} != nil && info.End{{.FieldName}} != nil {
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ? AND ? ",info.Start{{.FieldName}},info.End{{.FieldName}})
|
||||
}
|
||||
{{- else}}
|
||||
if info.{{.FieldName}} != nil {
|
||||
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
// Get{{.StructName}}InfoList 新增排序语句 请自行在搜索语句中添加orderMap内容
|
||||
{{- range .Fields}}
|
||||
{{- if .Sort}}
|
||||
orderMap["{{.ColumnName}}"] = true
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// Get{{.StructName}}DataSource()方法新增关联语句
|
||||
{{range $key, $value := .DataSourceMap}}
|
||||
{{$key}} := make([]map[string]any, 0)
|
||||
{{ $dataDB := "" }}
|
||||
{{- if eq $value.DBName "" }}
|
||||
{{ $dataDB = $db }}
|
||||
{{- else}}
|
||||
{{ $dataDB = printf "global.MustGetGlobalDBByDBName(\"%s\")" $value.DBName }}
|
||||
{{- end}}
|
||||
{{$dataDB}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&{{$key}})
|
||||
res["{{$key}}"] = {{$key}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else}}
|
||||
package service
|
||||
|
||||
import (
|
||||
{{- if not .OnlyTemplate }}
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{.Package}}/model"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{.Package}}/model/request"
|
||||
"{{.Module}}/global"
|
||||
"{{.Module}}/plugin/{{.Package}}/model"
|
||||
"{{.Module}}/plugin/{{.Package}}/model/request"
|
||||
{{- if .AutoCreateResource }}
|
||||
"gorm.io/gorm"
|
||||
{{- end}}
|
||||
@@ -165,4 +221,5 @@ func (s *{{.Abbreviation}})Get{{.StructName}}DataSource() (res map[string][]map[
|
||||
|
||||
func (s *{{.Abbreviation}})Get{{.StructName}}Public() {
|
||||
|
||||
}
|
||||
}
|
||||
{{- end }}
|
@@ -1,3 +1,158 @@
|
||||
{{- if .IsAdd }}
|
||||
// 新增表单中增加如下代码
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
<el-switch v-model="formData.{{.FieldJson}}" active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" clearable ></el-switch>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<el-input v-model="formData.{{.FieldJson}}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
<RichEdit v-model="formData.{{.FieldJson}}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
// 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
<el-date-picker v-model="formData.{{ .FieldJson }}" type="date" style="width:100%" placeholder="选择日期" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
<el-input-number v-model="formData.{{ .FieldJson }}" style="width:100%" :precision="2" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="item in [{{.DataTypeLong}}]" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<SelectImage
|
||||
multiple
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="video"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<SelectFile v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 字典增加如下代码
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
|
||||
// 基础formData结构增加如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
{{.FieldJson}}: 0,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
{{.FieldJson}}: {},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
// 验证规则中增加如下字段
|
||||
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
message: '{{ .ErrorText }}',
|
||||
trigger: ['input','blur'],
|
||||
},
|
||||
{{- if eq .FieldType "string" }}
|
||||
{
|
||||
whitespace: true,
|
||||
message: '不能只输入空格',
|
||||
trigger: ['input', 'blur'],
|
||||
}
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
// 获取数据源
|
||||
const dataSource = ref([])
|
||||
const getDataSourceFunc = async()=>{
|
||||
const res = await get{{.StructName}}DataSource()
|
||||
if (res.code === 0) {
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if not .OnlyTemplate}}
|
||||
<template>
|
||||
<div>
|
||||
@@ -248,4 +403,5 @@ const back = () => {
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@@ -1,5 +1,346 @@
|
||||
{{- $global := . }}
|
||||
{{- $templateID := printf "%s_%s" .Package .StructName }}
|
||||
|
||||
{{- if .IsAdd }}
|
||||
// 请在搜索条件中增加如下代码
|
||||
{{- range .Fields}} {{- if .FieldSearchType}} {{- if eq .FieldType "bool" }}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择">
|
||||
<el-option
|
||||
key="true"
|
||||
label="是"
|
||||
value="true">
|
||||
</el-option>
|
||||
<el-option
|
||||
key="false"
|
||||
label="否"
|
||||
value="false">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else if .DictType}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
{{- if eq .FieldType "float64" "int"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
<el-input v-model.number="searchInfo.start{{.FieldName}}" placeholder="最小值" />
|
||||
—
|
||||
<el-input v-model.number="searchInfo.end{{.FieldName}}" placeholder="最大值" />
|
||||
{{- else}}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" placeholder="请选择" style="width:100%" :clearable="true" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else}}
|
||||
<el-input v-model.number="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- else if eq .FieldType "time.Time"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
<template #label>
|
||||
<span>
|
||||
{{.FieldDesc}}
|
||||
<el-tooltip content="搜索范围是开始日期(包含)至结束日期(不包含)">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
<el-date-picker v-model="searchInfo.start{{.FieldName}}" type="datetime" placeholder="开始日期" :disabled-date="time=> searchInfo.end{{.FieldName}} ? time.getTime() > searchInfo.end{{.FieldName}}.getTime() : false"></el-date-picker>
|
||||
—
|
||||
<el-date-picker v-model="searchInfo.end{{.FieldName}}" type="datetime" placeholder="结束日期" :disabled-date="time=> searchInfo.start{{.FieldName}} ? time.getTime() < searchInfo.start{{.FieldName}}.getTime() : false"></el-date-picker>
|
||||
{{- else}}
|
||||
<el-date-picker v-model="searchInfo.{{.FieldJson}}" type="datetime" placeholder="搜索条件"></el-date-picker>
|
||||
{{- end}}
|
||||
{{- else}}
|
||||
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end}}
|
||||
</el-form-item>{{ end }}{{ end }}{{ end }}
|
||||
|
||||
|
||||
// 表格增加如下列代码
|
||||
|
||||
{{- range .Fields}}
|
||||
{{- if .Table}}
|
||||
{{- if .CheckDataSource }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{if eq .DataSource.Association 2}}
|
||||
<el-tag v-for="(item,key) in filterDataSource(dataSource.{{.FieldJson}},scope.row.{{.FieldJson}})" :key="key">
|
||||
{{ "{{ item }}" }}
|
||||
</el-tag>
|
||||
{{ else }}
|
||||
<span>{{"{{"}} filterDataSource(dataSource.{{.FieldJson}},scope.row.{{.FieldJson}}) {{"}}"}}</span>
|
||||
{{ end }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if .DictType}}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "bool" }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">{{"{{"}} formatBoolean(scope.row.{{.FieldJson}}) {{"}}"}}</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "time.Time" }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="180">
|
||||
<template #default="scope">{{"{{"}} formatDate(scope.row.{{.FieldJson}}) {{"}}"}}</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "picture" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<el-image preview-teleported style="width: 100px; height: 100px" :src="getUrl(scope.row.{{.FieldJson}})" fit="cover"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "pictures" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<div class="multiple-img-box">
|
||||
<el-image preview-teleported v-for="(item,index) in scope.row.{{.FieldJson}}" :key="index" style="width: 80px; height: 80px" :src="getUrl(item)" fit="cover"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "video" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<video
|
||||
style="width: 100px; height: 100px"
|
||||
muted
|
||||
preload="metadata"
|
||||
>
|
||||
<source :src="getUrl(scope.row.{{.FieldJson}}) + '#t=1'">
|
||||
</video>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "richtext" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
[富文本内容]
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "file" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<div class="file-list">
|
||||
<el-tag v-for="file in scope.row.{{.FieldJson}}" :key="file.uid" @click="downloadFile(file.url)">{{"{{"}}file.name{{"}}"}}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "json" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
[JSON]
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "array" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<ArrayCtrl v-model="scope.row.{{ .FieldJson }}"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 新增表单中增加如下代码
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
<el-switch v-model="formData.{{.FieldJson}}" active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" clearable ></el-switch>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<el-input v-model="formData.{{.FieldJson}}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
<RichEdit v-model="formData.{{.FieldJson}}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
// 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
<el-date-picker v-model="formData.{{ .FieldJson }}" type="date" style="width:100%" placeholder="选择日期" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
<el-input-number v-model="formData.{{ .FieldJson }}" style="width:100%" :precision="2" :clearable="{{.Clearable}}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "enum" }}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="item in [{{.DataTypeLong}}]" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<SelectImage
|
||||
multiple
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="image"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
<SelectImage
|
||||
v-model="formData.{{ .FieldJson }}"
|
||||
file-type="video"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<SelectFile v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 查看抽屉中增加如下代码
|
||||
|
||||
{{- range .Fields}}
|
||||
{{- if .Desc }}
|
||||
<el-descriptions-item label="{{ .FieldDesc }}">
|
||||
{{- if and (ne .FieldType "picture" ) (ne .FieldType "pictures" ) (ne .FieldType "file" ) (ne .FieldType "array" ) }}
|
||||
{{"{{"}} detailFrom.{{.FieldJson}} {{"}}"}}
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<el-image style="width: 50px; height: 50px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :src="getUrl(detailFrom.{{ .FieldJson }})" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="detailFrom.{{ .FieldJson }}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<el-image style="width: 50px; height: 50px; margin-right: 10px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :initial-index="index" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index" :src="getUrl(item)" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<div class="fileBtn" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index">
|
||||
<el-button type="primary" text bg @click="onDownloadFile(item.url)">
|
||||
<el-icon style="margin-right: 5px"><Download /></el-icon>
|
||||
{{"{{"}}item.name{{"}}"}}
|
||||
</el-button>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
// 字典增加如下代码
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
// setOptions方法中增加如下调用
|
||||
|
||||
{{- range $index, $element := .DictTypes }}
|
||||
{{ $element }}Options.value = await getDictFunc('{{$element}}')
|
||||
{{- end }}
|
||||
|
||||
// 基础formData结构(变量处和关闭表单处)增加如下字段
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "richtext" }}
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
{{.FieldJson}}: 0,
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "video" }}
|
||||
{{.FieldJson}}: "",
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "json" }}
|
||||
{{.FieldJson}}: {},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
// 验证规则中增加如下字段
|
||||
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
message: '{{ .ErrorText }}',
|
||||
trigger: ['input','blur'],
|
||||
},
|
||||
{{- if eq .FieldType "string" }}
|
||||
{
|
||||
whitespace: true,
|
||||
message: '不能只输入空格',
|
||||
trigger: ['input', 'blur'],
|
||||
}
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
// 获取数据源
|
||||
const dataSource = ref([])
|
||||
const getDataSourceFunc = async()=>{
|
||||
const res = await get{{.StructName}}DataSource()
|
||||
if (res.code === 0) {
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
|
||||
{{- else }}
|
||||
|
||||
{{- if not .OnlyTemplate}}
|
||||
<template>
|
||||
<div>
|
||||
@@ -912,4 +1253,5 @@ defineOptions({
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
@@ -18,6 +18,7 @@ type RouterGroup struct {
|
||||
DictionaryDetailRouter
|
||||
AuthorityBtnRouter
|
||||
SysExportTemplateRouter
|
||||
SysParamsRouter
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -26,6 +27,7 @@ var (
|
||||
baseApi = api.ApiGroupApp.SystemApiGroup.BaseApi
|
||||
casbinApi = api.ApiGroupApp.SystemApiGroup.CasbinApi
|
||||
systemApi = api.ApiGroupApp.SystemApiGroup.SystemApi
|
||||
sysParamsApi = api.ApiGroupApp.SystemApiGroup.SysParamsApi
|
||||
autoCodeApi = api.ApiGroupApp.SystemApiGroup.AutoCodeApi
|
||||
authorityApi = api.ApiGroupApp.SystemApiGroup.AuthorityApi
|
||||
apiRouterApi = api.ApiGroupApp.SystemApiGroup.SystemApiApi
|
||||
|
25
server/router/system/sys_params.go
Normal file
25
server/router/system/sys_params.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SysParamsRouter struct{}
|
||||
|
||||
// InitSysParamsRouter 初始化 参数 路由信息
|
||||
func (s *SysParamsRouter) InitSysParamsRouter(Router *gin.RouterGroup, PublicRouter *gin.RouterGroup) {
|
||||
sysParamsRouter := Router.Group("sysParams").Use(middleware.OperationRecord())
|
||||
sysParamsRouterWithoutRecord := Router.Group("sysParams")
|
||||
{
|
||||
sysParamsRouter.POST("createSysParams", sysParamsApi.CreateSysParams) // 新建参数
|
||||
sysParamsRouter.DELETE("deleteSysParams", sysParamsApi.DeleteSysParams) // 删除参数
|
||||
sysParamsRouter.DELETE("deleteSysParamsByIds", sysParamsApi.DeleteSysParamsByIds) // 批量删除参数
|
||||
sysParamsRouter.PUT("updateSysParams", sysParamsApi.UpdateSysParams) // 更新参数
|
||||
}
|
||||
{
|
||||
sysParamsRouterWithoutRecord.GET("findSysParams", sysParamsApi.FindSysParams) // 根据ID获取参数
|
||||
sysParamsRouterWithoutRecord.GET("getSysParamsList", sysParamsApi.GetSysParamsList) // 获取参数列表
|
||||
sysParamsRouterWithoutRecord.GET("getSysParam", sysParamsApi.GetSysParam) // 根据Key获取参数
|
||||
}
|
||||
}
|
@@ -308,7 +308,13 @@ func (s *autoCodeTemplate) getTemplateStr(t string, info request.AutoFunc) (stri
|
||||
func (s *autoCodeTemplate) addTemplateToAst(t string, info request.AutoFunc) error {
|
||||
tPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "router", info.Package, info.HumpPackageName+".go")
|
||||
funcName := fmt.Sprintf("Init%sRouter", info.StructName)
|
||||
stmtStr := fmt.Sprintf("%sRouterWithoutAuth.%s(\"%s\", %sApi.%s)", info.Abbreviation, info.Method, info.Router, info.Abbreviation, info.FuncName)
|
||||
|
||||
routerStr := "RouterWithoutAuth"
|
||||
if info.IsAuth {
|
||||
routerStr = "Router"
|
||||
}
|
||||
|
||||
stmtStr := fmt.Sprintf("%s%s.%s(\"%s\", %sApi.%s)", info.Abbreviation, routerStr, info.Method, info.Router, info.Abbreviation, info.FuncName)
|
||||
if info.IsPlugin {
|
||||
tPath = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin", info.Package, "router", info.HumpPackageName+".go")
|
||||
stmtStr = fmt.Sprintf("group.%s(\"%s\", api%s.%s)", info.Method, info.Router, info.StructName, info.FuncName)
|
||||
@@ -324,13 +330,25 @@ func (s *autoCodeTemplate) addTemplateToAst(t string, info request.AutoFunc) err
|
||||
funcDecl := utilsAst.FindFunction(astFile, funcName)
|
||||
stmtNode := utilsAst.CreateStmt(stmtStr)
|
||||
|
||||
for i := len(funcDecl.Body.List) - 1; i >= 0; i-- {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
if info.IsAuth {
|
||||
for i := 0; i < len(funcDecl.Body.List); i++ {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for i := len(funcDecl.Body.List) - 1; i >= 0; i-- {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ type ServiceGroup struct {
|
||||
DictionaryDetailService
|
||||
AuthorityBtnService
|
||||
SysExportTemplateService
|
||||
|
||||
SysParamsService
|
||||
AutoCodePlugin autoCodePlugin
|
||||
AutoCodePackage autoCodePackage
|
||||
AutoCodeHistory autoCodeHistory
|
||||
|
82
server/service/system/sys_params.go
Normal file
82
server/service/system/sys_params.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
)
|
||||
|
||||
type SysParamsService struct{}
|
||||
|
||||
// CreateSysParams 创建参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) CreateSysParams(sysParams *system.SysParams) (err error) {
|
||||
err = global.GVA_DB.Create(sysParams).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteSysParams 删除参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) DeleteSysParams(ID string) (err error) {
|
||||
err = global.GVA_DB.Delete(&system.SysParams{}, "id = ?", ID).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteSysParamsByIds 批量删除参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) DeleteSysParamsByIds(IDs []string) (err error) {
|
||||
err = global.GVA_DB.Delete(&[]system.SysParams{}, "id in ?", IDs).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateSysParams 更新参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) UpdateSysParams(sysParams system.SysParams) (err error) {
|
||||
err = global.GVA_DB.Model(&system.SysParams{}).Where("id = ?", sysParams.ID).Updates(&sysParams).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// GetSysParams 根据ID获取参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParams(ID string) (sysParams system.SysParams, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", ID).First(&sysParams).Error
|
||||
return
|
||||
}
|
||||
|
||||
// GetSysParamsInfoList 分页获取参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParamsInfoList(info systemReq.SysParamsSearch) (list []system.SysParams, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
db := global.GVA_DB.Model(&system.SysParams{})
|
||||
var sysParamss []system.SysParams
|
||||
// 如果有条件搜索 下方会自动创建搜索语句
|
||||
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
|
||||
db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
|
||||
}
|
||||
if info.Name != "" {
|
||||
db = db.Where("name LIKE ?", "%"+info.Name+"%")
|
||||
}
|
||||
if info.Key != "" {
|
||||
db = db.Where("key LIKE ?", "%"+info.Key+"%")
|
||||
}
|
||||
err = db.Count(&total).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if limit != 0 {
|
||||
db = db.Limit(limit).Offset(offset)
|
||||
}
|
||||
|
||||
err = db.Find(&sysParamss).Error
|
||||
return sysParamss, total, err
|
||||
}
|
||||
|
||||
// GetSysParam 根据key获取参数value
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParam(key string) (param system.SysParams, err error) {
|
||||
err = global.GVA_DB.Where(system.SysParams{Key: key}).First(¶m).Error
|
||||
return
|
||||
}
|
@@ -174,6 +174,14 @@ func (i *initApi) InitializeData(ctx context.Context) (context.Context, error) {
|
||||
{ApiGroup: "公告", Method: "PUT", Path: "/info/updateInfo", Description: "更新公告"},
|
||||
{ApiGroup: "公告", Method: "GET", Path: "/info/findInfo", Description: "根据ID获取公告"},
|
||||
{ApiGroup: "公告", Method: "GET", Path: "/info/getInfoList", Description: "获取公告列表"},
|
||||
|
||||
{ApiGroup: "参数管理", Method: "POST", Path: "/sysParams/createSysParams", Description: "新建参数"},
|
||||
{ApiGroup: "参数管理", Method: "DELETE", Path: "/sysParams/deleteSysParams", Description: "删除参数"},
|
||||
{ApiGroup: "参数管理", Method: "DELETE", Path: "/sysParams/deleteSysParamsByIds", Description: "批量删除参数"},
|
||||
{ApiGroup: "参数管理", Method: "PUT", Path: "/sysParams/updateSysParams", Description: "更新参数"},
|
||||
{ApiGroup: "参数管理", Method: "GET", Path: "/sysParams/findSysParams", Description: "根据ID获取参数"},
|
||||
{ApiGroup: "参数管理", Method: "GET", Path: "/sysParams/getSysParamsList", Description: "获取参数列表"},
|
||||
{ApiGroup: "参数管理", Method: "GET", Path: "/sysParams/getSysParam", Description: "获取参数列表"},
|
||||
}
|
||||
if err := db.Create(&entities).Error; err != nil {
|
||||
return ctx, errors.Wrap(err, sysModel.SysApi{}.TableName()+"表数据初始化失败!")
|
||||
|
@@ -178,6 +178,14 @@ func (i *initCasbin) InitializeData(ctx context.Context) (context.Context, error
|
||||
{Ptype: "p", V0: "888", V1: "/info/findInfo", V2: "GET"},
|
||||
{Ptype: "p", V0: "888", V1: "/info/getInfoList", V2: "GET"},
|
||||
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/createSysParams", V2: "POST"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/deleteSysParams", V2: "DELETE"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/deleteSysParamsByIds", V2: "DELETE"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/updateSysParams", V2: "PUT"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/findSysParams", V2: "GET"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/getSysParamsList", V2: "GET"},
|
||||
{Ptype: "p", V0: "888", V1: "/sysParams/getSysParam", V2: "GET"},
|
||||
|
||||
{Ptype: "p", V0: "8881", V1: "/user/admin_register", V2: "POST"},
|
||||
{Ptype: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
|
||||
{Ptype: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
|
||||
|
@@ -81,6 +81,7 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er
|
||||
{MenuLevel: 0, Hidden: false, ParentId: 24, Path: "plugin-email", Name: "plugin-email", Component: "plugin/email/view/index.vue", Sort: 4, Meta: Meta{Title: "邮件插件", Icon: "message"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: 15, Path: "exportTemplate", Name: "exportTemplate", Component: "view/systemTools/exportTemplate/exportTemplate.vue", Sort: 5, Meta: Meta{Title: "表格模板", Icon: "reading"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: 24, Path: "anInfo", Name: "anInfo", Component: "plugin/announcement/view/info.vue", Sort: 5, Meta: Meta{Title: "公告管理[示例]", Icon: "scaleToOriginal"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: 3, Path: "sysParams", Name: "sysParams", Component: "view/superAdmin/params/sysParams.vue", Sort: 7, Meta: Meta{Title: "参数管理", Icon: "compass"}},
|
||||
}
|
||||
if err = db.Create(&entities).Error; err != nil {
|
||||
return ctx, errors.Wrap(err, SysBaseMenu{}.TableName()+"表数据初始化失败!")
|
||||
|
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/qiniu/api.v7/v7/auth/qbox"
|
||||
"github.com/qiniu/api.v7/v7/storage"
|
||||
"github.com/qiniu/go-sdk/v7/auth/qbox"
|
||||
"github.com/qiniu/go-sdk/v7/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user