diff --git a/.gitignore b/.gitignore index 2784f52b1..a25df7bb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.idea/ /web/node_modules /web/dist @@ -33,4 +32,11 @@ server/uploads/ *.iml web/.pnpm-debug.log web/pnpm-lock.yaml -*.dccache \ No newline at end of file + +# binary files +*.exe + +# SQLite database files +*.db +*.sqlite +*.sqlite3 diff --git a/Makefile b/Makefile index 4b193fc6d..9135c9ad9 100644 --- a/Makefile +++ b/Makefile @@ -13,16 +13,9 @@ CONFIG_FILE = config.yaml IMAGE_NAME = gva #镜像地址 REPOSITORY = registry.cn-hangzhou.aliyuncs.com/${IMAGE_NAME} - -ifeq ($(TAGS_OPT),) -TAGS_OPT = latest -else -endif - -ifeq ($(PLUGIN),) -PLUGIN = email -else -endif +#镜像版本 +TAGS_OPT ?= latest +PLUGIN ?= email #容器环境前后端共同打包 build: build-web build-server @@ -48,7 +41,7 @@ build-image-server: build-local: if [ -d "build" ];then rm -rf build; else echo "OK!"; fi \ && if [ -f "/.dockerenv" ];then echo "OK!"; else make build-web-local && make build-server-local; fi \ - && mkdir build && cp -r web/dist build/ && cp server/server build/ && cp -r server/resource build/resource + && mkdir build && cp -r web/dist build/ && cp server/server build/ && cp -r server/resource build/resource #本地环境打包前端 build-web-local: @@ -63,13 +56,17 @@ build-server-local: && go build -ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${TAGS_OPT}" -v #打包前后端二合一镜像 -image: build +image: build docker build -t ${REPOSITORY}/gin-vue-admin:${TAGS_OPT} -f deploy/docker/Dockerfile . #尝鲜版 images: build build-image-web build-image-server docker build -t ${REPOSITORY}/all:${TAGS_OPT} -f deploy/docker/Dockerfile . - + +#swagger 文档生成 +doc: + @cd server && swag init + #插件快捷打包: make plugin PLUGIN="这里是插件文件夹名称,默认为email" plugin: if [ -d ".plugin" ];then rm -rf .plugin ; else echo "OK!"; fi && mkdir -p .plugin/${PLUGIN}/{server/plugin,web/plugin} \ diff --git a/README.md b/README.md index be26426fa..cf8d59a0a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,25 @@ [English](./README-en.md) | 简体中文 +## ✨一分钟生成前后端基础代码 + + + + + + +
+

📄 创建基础模板

+

🤖 AI生成结构

+

⏰ 生成代码

+

🏷️ 分配权限

+

🎉 基础CURD生成完成

+
+ +
+ + # 项目文档 [在线文档](https://www.gin-vue-admin.com) : https://www.gin-vue-admin.com diff --git a/deploy/docker-compose/docker-compose-dev.yaml b/deploy/docker-compose/docker-compose-dev.yaml deleted file mode 100644 index fd0a3b661..000000000 --- a/deploy/docker-compose/docker-compose-dev.yaml +++ /dev/null @@ -1,99 +0,0 @@ -version: "3" - -# 声明一个名为network的networks,subnet为network的子网地址,默认网关是177.7.0.1 -networks: - network: - ipam: - driver: default - config: - - subnet: '177.7.0.0/16' - -# 设置mysql,redis持久化保存 -volumes: - mysql: - redis: - -services: - web: - image: node:20 - container_name: gva-web - hostname: gva-web #可以通过容器名访问 - restart: always - ports: - - '8080:8080' - depends_on: - - server - working_dir: /web # 如果docker 设置了workdir 则此处不需要设置 - #若网络不太好,请自行换源,如下 - #command: bash -c "yarn config set registry https://registry.npmmirror.com --global && yarn install && yarn serve" - command: bash -c "yarn install && yarn serve" - volumes: - - ../../web:/web - networks: - network: - ipv4_address: 177.7.0.11 - - server: - image: golang:1.22 - container_name: gva-server - hostname: gva-server - restart: always - ports: - - '8888:8888' - depends_on: - mysql: - condition: service_healthy - redis: - condition: service_healthy - volumes: - - ../../server:/server - working_dir: /server # 如果docker 设置了workdir 则此处不需要设置 - command: bash -c "go env -w GOPROXY=https://goproxy.cn,direct && go mod tidy && go run main.go" - links: - - mysql - - redis - networks: - network: - ipv4_address: 177.7.0.12 - - mysql: - image: mysql:8.0.21 # 如果您是 arm64 架构:如 MacOS 的 M1,请修改镜像为 image: mysql/mysql-server:8.0.21 - container_name: gva-mysql - hostname: gva-mysql - command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集 - restart: always - ports: - - "13306:3306" # host物理直接映射端口为13306 - environment: - #MYSQL_ROOT_PASSWORD: 'Aa@6447985' # root管理员用户密码 - MYSQL_DATABASE: 'qmPlus' # 初始化启动时要创建的数据库的名称 - MYSQL_USER: 'gva' - MYSQL_PASSWORD: 'Aa@6447985' - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "gva", "-pAa@6447985"] - interval: 10s - timeout: 5s - retries: 3 - volumes: - - mysql:/var/lib/mysql - networks: - network: - ipv4_address: 177.7.0.13 - - redis: - image: redis:6.0.6 - container_name: gva-redis # 容器名 - hostname: gva-redis - restart: always - ports: - - '16379:6379' - healthcheck: - test: ["CMD-SHELL", "redis-cli ping | grep PONG || exit 1"] - interval: 10s - timeout: 5s - retries: 3 - volumes: - - redis:/data - networks: - network: - ipv4_address: 177.7.0.14 diff --git a/server/api/v1/system/auto_code_plugin.go b/server/api/v1/system/auto_code_plugin.go index 59b65c233..bb7e18da1 100644 --- a/server/api/v1/system/auto_code_plugin.go +++ b/server/api/v1/system/auto_code_plugin.go @@ -70,7 +70,7 @@ func (a *AutoCodePluginApi) Packaged(c *gin.Context) { response.OkWithMessage(fmt.Sprintf(global.Translate("system.messages.packSuccess"), zipPath), c) } -// Packaged +// InitMenu // @Tags AutoCodePlugin // @Summary 打包插件 // @Security ApiKeyAuth @@ -94,7 +94,7 @@ func (a *AutoCodePluginApi) InitMenu(c *gin.Context) { response.OkWithMessage(global.Translate("sys_auto_code.fileChangeSuccess"), c) } -// Packaged +// InitAPI // @Tags AutoCodePlugin // @Summary 打包插件 // @Security ApiKeyAuth diff --git a/server/api/v1/system/auto_code_template.go b/server/api/v1/system/auto_code_template.go index f551c12e0..5bc6e97d4 100644 --- a/server/api/v1/system/auto_code_template.go +++ b/server/api/v1/system/auto_code_template.go @@ -40,8 +40,8 @@ func (a *AutoCodeTemplateApi) Preview(c *gin.Context) { info.PackageT = utils.FirstUpper(info.Package) autoCode, err := autoCodeTemplateService.Preview(c.Request.Context(), info) if err != nil { - global.GVA_LOG.Error(global.Translate("sys_auto_code.previewFailErr"), zap.Error(err)) - response.FailWithMessage(global.Translate("sys_auto_code.previewFailErr"), c) + global.GVA_LOG.Error(err.Error(), zap.Error(err)) + response.FailWithMessage(global.Translate("sys_auto_code.previewFailErr")+": "+err.Error(), c) } else { response.OkWithDetailed(gin.H{"autoCode": autoCode}, global.Translate("sys_auto_code.previewSuccess"), c) } @@ -82,7 +82,7 @@ func (a *AutoCodeTemplateApi) Create(c *gin.Context) { } } -// Create +// AddFunc // @Tags AddFunc // @Summary 增加方法 // @Security ApiKeyAuth diff --git a/server/api/v1/system/sys_export_template.go b/server/api/v1/system/sys_export_template.go index b5ba0f709..7eec37883 100644 --- a/server/api/v1/system/sys_export_template.go +++ b/server/api/v1/system/sys_export_template.go @@ -213,7 +213,7 @@ func (sysExportTemplateApi *SysExportTemplateApi) ExportExcel(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Router /sysExportTemplate/exportExcel [get] +// @Router /sysExportTemplate/ExportTemplate [get] func (sysExportTemplateApi *SysExportTemplateApi) ExportTemplate(c *gin.Context) { templateID := c.Query("templateID") if templateID == "" { diff --git a/server/core/server.go b/server/core/server.go index 18e43ddc1..c2d60ead4 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -2,6 +2,7 @@ package core import ( "fmt" + "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/initialize" "github.com/flipped-aurora/gin-vue-admin/server/service/system" @@ -39,7 +40,7 @@ func RunWindowsServer() { fmt.Printf(` %s gin-vue-admin - %s: v2.7.7 + %s: v2.7.8-beta1 %s %s: https://github.com/flipped-aurora/gin-vue-admin %s: https://plugin.gin-vue-admin.com diff --git a/server/docs/docs.go b/server/docs/docs.go index caf962a6b..4ae77cef9 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -1,4 +1,5 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -331,7 +332,7 @@ const docTemplate = `{ } }, "/api/getApiGroups": { - "post": { + "get": { "security": [ { "ApiKeyAuth": [] @@ -810,7 +811,7 @@ const docTemplate = `{ } }, "/authority/updateAuthority": { - "post": { + "put": { "security": [ { "ApiKeyAuth": [] @@ -1281,7 +1282,7 @@ const docTemplate = `{ } } }, - "/autoCode/getDatabase": { + "/autoCode/getDB": { "get": { "security": [ { @@ -1560,6 +1561,92 @@ const docTemplate = `{ } } }, + "/autoCode/initAPI": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodePlugin" + ], + "summary": "打包插件", + "responses": { + "200": { + "description": "打包插件成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/autoCode/initMenu": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodePlugin" + ], + "summary": "打包插件", + "responses": { + "200": { + "description": "打包插件成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/autoCode/installPlugin": { "post": { "security": [ @@ -1669,7 +1756,7 @@ const docTemplate = `{ } }, "/autoCode/pubPlug": { - "get": { + "post": { "security": [ { "ApiKeyAuth": [] @@ -2407,6 +2494,55 @@ const docTemplate = `{ } }, "/fileUploadAndDownload/findFile": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ExaFileUploadAndDownload" + ], + "summary": "查找文件", + "parameters": [ + { + "type": "file", + "description": "Find the file, 查找文件", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "查找文件,返回包括文件详情", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/response.FileResponse" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + }, "post": { "security": [ { @@ -2510,6 +2646,53 @@ const docTemplate = `{ } } }, + "/fileUploadAndDownload/importURL": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "ExaFileUploadAndDownload" + ], + "summary": "导入URL", + "parameters": [ + { + "description": "对象", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/example.ExaFileUploadAndDownload" + } + } + ], + "responses": { + "200": { + "description": "导入URL", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/fileUploadAndDownload/removeChunk": { "post": { "security": [ @@ -5081,6 +5264,417 @@ const docTemplate = `{ } } }, + "/sysParams/createSysParams": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "创建参数", + "parameters": [ + { + "description": "创建参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/deleteSysParams": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "删除参数", + "parameters": [ + { + "description": "删除参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/deleteSysParamsByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "批量删除参数", + "responses": { + "200": { + "description": "批量删除成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/findSysParams": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "用id查询参数", + "parameters": [ + { + "type": "integer", + "description": "主键ID", + "name": "ID", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "参数说明", + "name": "desc", + "in": "query" + }, + { + "type": "string", + "description": "参数键", + "name": "key", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "参数名称", + "name": "name", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "string", + "description": "参数值", + "name": "value", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "查询成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/system.SysParams" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/getSysParam": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "根据key获取参数value", + "parameters": [ + { + "type": "string", + "description": "key", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/system.SysParams" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/getSysParamsList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "分页获取参数列表", + "parameters": [ + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "key", + "in": "query" + }, + { + "type": "string", + "description": "关键字", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/response.PageResult" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/updateSysParams": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "更新参数", + "parameters": [ + { + "description": "更新参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/system/getServerInfo": { "post": { "security": [ @@ -5297,6 +5891,61 @@ const docTemplate = `{ } } }, + "/user/SetSelfSetting": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "设置用户配置", + "parameters": [ + { + "description": "用户配置数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "additionalProperties": true + } + } + ], + "responses": { + "200": { + "description": "设置用户配置", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/user/admin_register": { "post": { "produces": [ @@ -5506,7 +6155,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.PageInfo" + "$ref": "#/definitions/request.GetUserList" } } ], @@ -5738,6 +6387,10 @@ const docTemplate = `{ } }, "definitions": { + "common.JSONMap": { + "type": "object", + "additionalProperties": true + }, "config.AliyunOSS": { "type": "object", "properties": { @@ -5965,6 +6618,32 @@ const docTemplate = `{ } } }, + "config.Minio": { + "type": "object", + "properties": { + "access-key-id": { + "type": "string" + }, + "access-key-secret": { + "type": "string" + }, + "base-path": { + "type": "string" + }, + "bucket-name": { + "type": "string" + }, + "bucket-url": { + "type": "string" + }, + "endpoint": { + "type": "string" + }, + "use-ssl": { + "type": "boolean" + } + } + }, "config.Mongo": { "type": "object", "properties": { @@ -6317,6 +6996,10 @@ const docTemplate = `{ "description": "单实例模式下redis的哪个数据库", "type": "integer" }, + "name": { + "description": "代表当前实例的名字", + "type": "string" + }, "password": { "description": "密码", "type": "string" @@ -6390,6 +7073,9 @@ const docTemplate = `{ } ] }, + "minio": { + "$ref": "#/definitions/config.Minio" + }, "mongo": { "$ref": "#/definitions/config.Mongo" }, @@ -6416,6 +7102,12 @@ const docTemplate = `{ "redis": { "$ref": "#/definitions/config.Redis" }, + "redis-list": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Redis" + } + }, "sqlite": { "$ref": "#/definitions/config.Sqlite" }, @@ -6590,6 +7282,10 @@ const docTemplate = `{ "use-redis": { "description": "使用redis", "type": "boolean" + }, + "use-strict-auth": { + "description": "使用树形角色分配模式", + "type": "boolean" } } }, @@ -6880,7 +7576,207 @@ const docTemplate = `{ } }, "request.AutoCode": { - "type": "object" + "type": "object", + "properties": { + "abbreviation": { + "description": "Struct简称", + "type": "string", + "example": "Struct简称" + }, + "autoCreateApiToSql": { + "description": "是否自动创建api", + "type": "boolean", + "example": false + }, + "autoCreateBtnAuth": { + "description": "是否自动创建按钮权限", + "type": "boolean", + "example": false + }, + "autoCreateMenuToSql": { + "description": "是否自动创建menu", + "type": "boolean", + "example": false + }, + "autoCreateResource": { + "description": "是否自动创建资源标识", + "type": "boolean", + "example": false + }, + "autoMigrate": { + "description": "是否自动迁移表结构", + "type": "boolean", + "example": false + }, + "businessDB": { + "description": "业务数据库", + "type": "string", + "example": "业务数据库" + }, + "description": { + "description": "Struct中文名称", + "type": "string", + "example": "Struct中文名称" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/request.AutoCodeField" + } + }, + "gvaModel": { + "description": "是否使用gva默认Model", + "type": "boolean", + "example": false + }, + "humpPackageName": { + "description": "go文件名称", + "type": "string", + "example": "go文件名称" + }, + "isAdd": { + "description": "是否新增", + "type": "boolean", + "example": false + }, + "isTree": { + "description": "是否树形结构", + "type": "boolean", + "example": false + }, + "onlyTemplate": { + "description": "是否只生成模板", + "type": "boolean", + "example": false + }, + "package": { + "type": "string" + }, + "packageName": { + "description": "文件名称", + "type": "string", + "example": "文件名称" + }, + "primaryField": { + "$ref": "#/definitions/request.AutoCodeField" + }, + "structName": { + "description": "Struct名称", + "type": "string", + "example": "Struct名称" + }, + "tableName": { + "description": "表名", + "type": "string", + "example": "表名" + }, + "treeJson": { + "description": "展示的树json字段", + "type": "string", + "example": "展示的树json字段" + } + } + }, + "request.AutoCodeField": { + "type": "object", + "properties": { + "checkDataSource": { + "description": "是否检查数据源", + "type": "boolean" + }, + "clearable": { + "description": "是否可清空", + "type": "boolean" + }, + "columnName": { + "description": "数据库字段", + "type": "string" + }, + "comment": { + "description": "数据库字段描述", + "type": "string" + }, + "dataSource": { + "description": "数据源", + "allOf": [ + { + "$ref": "#/definitions/request.DataSource" + } + ] + }, + "dataTypeLong": { + "description": "数据库字段长度", + "type": "string" + }, + "defaultValue": { + "description": "是否必填", + "type": "string" + }, + "desc": { + "description": "是否前端详情", + "type": "boolean" + }, + "dictType": { + "description": "字典", + "type": "string" + }, + "errorText": { + "description": "校验失败文字", + "type": "string" + }, + "excel": { + "description": "是否导入/导出", + "type": "boolean" + }, + "fieldDesc": { + "description": "中文名", + "type": "string" + }, + "fieldIndexType": { + "description": "索引类型", + "type": "string" + }, + "fieldJson": { + "description": "FieldJson", + "type": "string" + }, + "fieldName": { + "description": "Field名", + "type": "string" + }, + "fieldSearchHide": { + "description": "是否隐藏查询条件", + "type": "boolean" + }, + "fieldSearchType": { + "description": "搜索条件", + "type": "string" + }, + "fieldType": { + "description": "Field数据类型", + "type": "string" + }, + "form": { + "description": "Front bool ` + "`" + `json:\"front\"` + "`" + ` // 是否前端可见", + "type": "boolean" + }, + "primaryKey": { + "description": "是否主键", + "type": "boolean" + }, + "require": { + "description": "是否必填", + "type": "boolean" + }, + "sort": { + "description": "是否增加排序", + "type": "boolean" + }, + "table": { + "description": "是否前端表格列", + "type": "boolean" + } + } }, "request.CasbinInReceive": { "type": "object", @@ -6923,6 +7819,30 @@ const docTemplate = `{ } } }, + "request.DataSource": { + "type": "object", + "properties": { + "association": { + "description": "关联关系 1 一对一 2 一对多", + "type": "integer" + }, + "dbName": { + "type": "string" + }, + "hasDeletedAt": { + "type": "boolean" + }, + "label": { + "type": "string" + }, + "table": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "request.Empty": { "type": "object" }, @@ -6944,6 +7864,35 @@ const docTemplate = `{ } } }, + "request.GetUserList": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "nickName": { + "type": "string" + }, + "page": { + "description": "页码", + "type": "integer" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "phone": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "request.IdsReq": { "type": "object", "properties": { @@ -8001,6 +8950,44 @@ const docTemplate = `{ } } }, + "system.SysParams": { + "type": "object", + "required": [ + "key", + "name", + "value" + ], + "properties": { + "ID": { + "description": "主键ID", + "type": "integer" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "desc": { + "description": "参数说明", + "type": "string" + }, + "key": { + "description": "参数键", + "type": "string" + }, + "name": { + "description": "参数名称", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "value": { + "description": "参数值", + "type": "string" + } + } + }, "system.SysUser": { "type": "object", "properties": { @@ -8009,22 +8996,24 @@ const docTemplate = `{ "type": "integer" }, "authorities": { + "description": "多用户角色", "type": "array", "items": { "$ref": "#/definitions/system.SysAuthority" } }, "authority": { - "$ref": "#/definitions/system.SysAuthority" + "description": "用户角色", + "allOf": [ + { + "$ref": "#/definitions/system.SysAuthority" + } + ] }, "authorityId": { "description": "用户角色ID", "type": "integer" }, - "baseColor": { - "description": "基础颜色", - "type": "string" - }, "createdAt": { "description": "创建时间", "type": "string" @@ -8045,14 +9034,18 @@ const docTemplate = `{ "description": "用户昵称", "type": "string" }, + "originSetting": { + "description": "配置", + "allOf": [ + { + "$ref": "#/definitions/common.JSONMap" + } + ] + }, "phone": { "description": "用户手机号", "type": "string" }, - "sideMode": { - "description": "用户侧边主题", - "type": "string" - }, "updatedAt": { "description": "更新时间", "type": "string" @@ -8087,7 +9080,7 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ - Version: "v2.7.7", + Version: "v2.7.8-beta1", Host: "", BasePath: "", Schemes: []string{}, @@ -8095,8 +9088,6 @@ var SwaggerInfo = &swag.Spec{ Description: "使用gin+vue进行极速开发的全栈开发基础平台", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", } func init() { diff --git a/server/docs/swagger.json b/server/docs/swagger.json index 80aa541c9..e857454e6 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -4,7 +4,7 @@ "description": "使用gin+vue进行极速开发的全栈开发基础平台", "title": "Gin-Vue-Admin Swagger API接口文档", "contact": {}, - "version": "v2.7.7" + "version": "v2.7.8-beta1" }, "paths": { "/api/createApi": { @@ -323,7 +323,7 @@ } }, "/api/getApiGroups": { - "post": { + "get": { "security": [ { "ApiKeyAuth": [] @@ -802,7 +802,7 @@ } }, "/authority/updateAuthority": { - "post": { + "put": { "security": [ { "ApiKeyAuth": [] @@ -1273,7 +1273,7 @@ } } }, - "/autoCode/getDatabase": { + "/autoCode/getDB": { "get": { "security": [ { @@ -1552,6 +1552,92 @@ } } }, + "/autoCode/initAPI": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodePlugin" + ], + "summary": "打包插件", + "responses": { + "200": { + "description": "打包插件成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/autoCode/initMenu": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodePlugin" + ], + "summary": "打包插件", + "responses": { + "200": { + "description": "打包插件成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/autoCode/installPlugin": { "post": { "security": [ @@ -1661,7 +1747,7 @@ } }, "/autoCode/pubPlug": { - "get": { + "post": { "security": [ { "ApiKeyAuth": [] @@ -2399,6 +2485,55 @@ } }, "/fileUploadAndDownload/findFile": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ExaFileUploadAndDownload" + ], + "summary": "查找文件", + "parameters": [ + { + "type": "file", + "description": "Find the file, 查找文件", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "查找文件,返回包括文件详情", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/response.FileResponse" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + }, "post": { "security": [ { @@ -2502,6 +2637,53 @@ } } }, + "/fileUploadAndDownload/importURL": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "ExaFileUploadAndDownload" + ], + "summary": "导入URL", + "parameters": [ + { + "description": "对象", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/example.ExaFileUploadAndDownload" + } + } + ], + "responses": { + "200": { + "description": "导入URL", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/fileUploadAndDownload/removeChunk": { "post": { "security": [ @@ -5073,6 +5255,417 @@ } } }, + "/sysParams/createSysParams": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "创建参数", + "parameters": [ + { + "description": "创建参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/deleteSysParams": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "删除参数", + "parameters": [ + { + "description": "删除参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/deleteSysParamsByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "批量删除参数", + "responses": { + "200": { + "description": "批量删除成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/findSysParams": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "用id查询参数", + "parameters": [ + { + "type": "integer", + "description": "主键ID", + "name": "ID", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "参数说明", + "name": "desc", + "in": "query" + }, + { + "type": "string", + "description": "参数键", + "name": "key", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "参数名称", + "name": "name", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "string", + "description": "参数值", + "name": "value", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "查询成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/system.SysParams" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/getSysParam": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "根据key获取参数value", + "parameters": [ + { + "type": "string", + "description": "key", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/system.SysParams" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/getSysParamsList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "分页获取参数列表", + "parameters": [ + { + "type": "string", + "name": "endCreatedAt", + "in": "query" + }, + { + "type": "string", + "name": "key", + "in": "query" + }, + { + "type": "string", + "description": "关键字", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "startCreatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/response.PageResult" + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/sysParams/updateSysParams": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysParams" + ], + "summary": "更新参数", + "parameters": [ + { + "description": "更新参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/system.SysParams" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/system/getServerInfo": { "post": { "security": [ @@ -5289,6 +5882,61 @@ } } }, + "/user/SetSelfSetting": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "设置用户配置", + "parameters": [ + { + "description": "用户配置数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "additionalProperties": true + } + } + ], + "responses": { + "200": { + "description": "设置用户配置", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "object", + "additionalProperties": true + }, + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/user/admin_register": { "post": { "produces": [ @@ -5498,7 +6146,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.PageInfo" + "$ref": "#/definitions/request.GetUserList" } } ], @@ -5730,6 +6378,10 @@ } }, "definitions": { + "common.JSONMap": { + "type": "object", + "additionalProperties": true + }, "config.AliyunOSS": { "type": "object", "properties": { @@ -5957,6 +6609,32 @@ } } }, + "config.Minio": { + "type": "object", + "properties": { + "access-key-id": { + "type": "string" + }, + "access-key-secret": { + "type": "string" + }, + "base-path": { + "type": "string" + }, + "bucket-name": { + "type": "string" + }, + "bucket-url": { + "type": "string" + }, + "endpoint": { + "type": "string" + }, + "use-ssl": { + "type": "boolean" + } + } + }, "config.Mongo": { "type": "object", "properties": { @@ -6309,6 +6987,10 @@ "description": "单实例模式下redis的哪个数据库", "type": "integer" }, + "name": { + "description": "代表当前实例的名字", + "type": "string" + }, "password": { "description": "密码", "type": "string" @@ -6382,6 +7064,9 @@ } ] }, + "minio": { + "$ref": "#/definitions/config.Minio" + }, "mongo": { "$ref": "#/definitions/config.Mongo" }, @@ -6408,6 +7093,12 @@ "redis": { "$ref": "#/definitions/config.Redis" }, + "redis-list": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Redis" + } + }, "sqlite": { "$ref": "#/definitions/config.Sqlite" }, @@ -6582,6 +7273,10 @@ "use-redis": { "description": "使用redis", "type": "boolean" + }, + "use-strict-auth": { + "description": "使用树形角色分配模式", + "type": "boolean" } } }, @@ -6872,7 +7567,207 @@ } }, "request.AutoCode": { - "type": "object" + "type": "object", + "properties": { + "abbreviation": { + "description": "Struct简称", + "type": "string", + "example": "Struct简称" + }, + "autoCreateApiToSql": { + "description": "是否自动创建api", + "type": "boolean", + "example": false + }, + "autoCreateBtnAuth": { + "description": "是否自动创建按钮权限", + "type": "boolean", + "example": false + }, + "autoCreateMenuToSql": { + "description": "是否自动创建menu", + "type": "boolean", + "example": false + }, + "autoCreateResource": { + "description": "是否自动创建资源标识", + "type": "boolean", + "example": false + }, + "autoMigrate": { + "description": "是否自动迁移表结构", + "type": "boolean", + "example": false + }, + "businessDB": { + "description": "业务数据库", + "type": "string", + "example": "业务数据库" + }, + "description": { + "description": "Struct中文名称", + "type": "string", + "example": "Struct中文名称" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/request.AutoCodeField" + } + }, + "gvaModel": { + "description": "是否使用gva默认Model", + "type": "boolean", + "example": false + }, + "humpPackageName": { + "description": "go文件名称", + "type": "string", + "example": "go文件名称" + }, + "isAdd": { + "description": "是否新增", + "type": "boolean", + "example": false + }, + "isTree": { + "description": "是否树形结构", + "type": "boolean", + "example": false + }, + "onlyTemplate": { + "description": "是否只生成模板", + "type": "boolean", + "example": false + }, + "package": { + "type": "string" + }, + "packageName": { + "description": "文件名称", + "type": "string", + "example": "文件名称" + }, + "primaryField": { + "$ref": "#/definitions/request.AutoCodeField" + }, + "structName": { + "description": "Struct名称", + "type": "string", + "example": "Struct名称" + }, + "tableName": { + "description": "表名", + "type": "string", + "example": "表名" + }, + "treeJson": { + "description": "展示的树json字段", + "type": "string", + "example": "展示的树json字段" + } + } + }, + "request.AutoCodeField": { + "type": "object", + "properties": { + "checkDataSource": { + "description": "是否检查数据源", + "type": "boolean" + }, + "clearable": { + "description": "是否可清空", + "type": "boolean" + }, + "columnName": { + "description": "数据库字段", + "type": "string" + }, + "comment": { + "description": "数据库字段描述", + "type": "string" + }, + "dataSource": { + "description": "数据源", + "allOf": [ + { + "$ref": "#/definitions/request.DataSource" + } + ] + }, + "dataTypeLong": { + "description": "数据库字段长度", + "type": "string" + }, + "defaultValue": { + "description": "是否必填", + "type": "string" + }, + "desc": { + "description": "是否前端详情", + "type": "boolean" + }, + "dictType": { + "description": "字典", + "type": "string" + }, + "errorText": { + "description": "校验失败文字", + "type": "string" + }, + "excel": { + "description": "是否导入/导出", + "type": "boolean" + }, + "fieldDesc": { + "description": "中文名", + "type": "string" + }, + "fieldIndexType": { + "description": "索引类型", + "type": "string" + }, + "fieldJson": { + "description": "FieldJson", + "type": "string" + }, + "fieldName": { + "description": "Field名", + "type": "string" + }, + "fieldSearchHide": { + "description": "是否隐藏查询条件", + "type": "boolean" + }, + "fieldSearchType": { + "description": "搜索条件", + "type": "string" + }, + "fieldType": { + "description": "Field数据类型", + "type": "string" + }, + "form": { + "description": "Front bool `json:\"front\"` // 是否前端可见", + "type": "boolean" + }, + "primaryKey": { + "description": "是否主键", + "type": "boolean" + }, + "require": { + "description": "是否必填", + "type": "boolean" + }, + "sort": { + "description": "是否增加排序", + "type": "boolean" + }, + "table": { + "description": "是否前端表格列", + "type": "boolean" + } + } }, "request.CasbinInReceive": { "type": "object", @@ -6915,6 +7810,30 @@ } } }, + "request.DataSource": { + "type": "object", + "properties": { + "association": { + "description": "关联关系 1 一对一 2 一对多", + "type": "integer" + }, + "dbName": { + "type": "string" + }, + "hasDeletedAt": { + "type": "boolean" + }, + "label": { + "type": "string" + }, + "table": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "request.Empty": { "type": "object" }, @@ -6936,6 +7855,35 @@ } } }, + "request.GetUserList": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "keyword": { + "description": "关键字", + "type": "string" + }, + "nickName": { + "type": "string" + }, + "page": { + "description": "页码", + "type": "integer" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + }, + "phone": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "request.IdsReq": { "type": "object", "properties": { @@ -7993,6 +8941,44 @@ } } }, + "system.SysParams": { + "type": "object", + "required": [ + "key", + "name", + "value" + ], + "properties": { + "ID": { + "description": "主键ID", + "type": "integer" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "desc": { + "description": "参数说明", + "type": "string" + }, + "key": { + "description": "参数键", + "type": "string" + }, + "name": { + "description": "参数名称", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "value": { + "description": "参数值", + "type": "string" + } + } + }, "system.SysUser": { "type": "object", "properties": { @@ -8001,22 +8987,24 @@ "type": "integer" }, "authorities": { + "description": "多用户角色", "type": "array", "items": { "$ref": "#/definitions/system.SysAuthority" } }, "authority": { - "$ref": "#/definitions/system.SysAuthority" + "description": "用户角色", + "allOf": [ + { + "$ref": "#/definitions/system.SysAuthority" + } + ] }, "authorityId": { "description": "用户角色ID", "type": "integer" }, - "baseColor": { - "description": "基础颜色", - "type": "string" - }, "createdAt": { "description": "创建时间", "type": "string" @@ -8037,14 +9025,18 @@ "description": "用户昵称", "type": "string" }, + "originSetting": { + "description": "配置", + "allOf": [ + { + "$ref": "#/definitions/common.JSONMap" + } + ] + }, "phone": { "description": "用户手机号", "type": "string" }, - "sideMode": { - "description": "用户侧边主题", - "type": "string" - }, "updatedAt": { "description": "更新时间", "type": "string" @@ -8075,4 +9067,4 @@ "in": "header" } } -} \ No newline at end of file +} diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index 430abdb26..1fac6d252 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1,4 +1,7 @@ definitions: + common.JSONMap: + additionalProperties: true + type: object config.AliyunOSS: properties: access-key-id: @@ -150,6 +153,23 @@ definitions: description: 本地文件存储路径 type: string type: object + config.Minio: + properties: + access-key-id: + type: string + access-key-secret: + type: string + base-path: + type: string + bucket-name: + type: string + bucket-url: + type: string + endpoint: + type: string + use-ssl: + type: boolean + type: object config.Mongo: properties: auth-source: @@ -409,6 +429,9 @@ definitions: db: description: 单实例模式下redis的哪个数据库 type: integer + name: + description: 代表当前实例的名字 + type: string password: description: 密码 type: string @@ -454,6 +477,8 @@ definitions: allOf: - $ref: '#/definitions/config.Local' description: oss + minio: + $ref: '#/definitions/config.Minio' mongo: $ref: '#/definitions/config.Mongo' mssql: @@ -470,6 +495,10 @@ definitions: $ref: '#/definitions/config.Qiniu' redis: $ref: '#/definitions/config.Redis' + redis-list: + items: + $ref: '#/definitions/config.Redis' + type: array sqlite: $ref: '#/definitions/config.Sqlite' system: @@ -597,6 +626,9 @@ definitions: use-redis: description: 使用redis type: boolean + use-strict-auth: + description: 使用树形角色分配模式 + type: boolean type: object config.TencentCOS: properties: @@ -800,6 +832,156 @@ definitions: type: array type: object request.AutoCode: + properties: + abbreviation: + description: Struct简称 + example: Struct简称 + type: string + autoCreateApiToSql: + description: 是否自动创建api + example: false + type: boolean + autoCreateBtnAuth: + description: 是否自动创建按钮权限 + example: false + type: boolean + autoCreateMenuToSql: + description: 是否自动创建menu + example: false + type: boolean + autoCreateResource: + description: 是否自动创建资源标识 + example: false + type: boolean + autoMigrate: + description: 是否自动迁移表结构 + example: false + type: boolean + businessDB: + description: 业务数据库 + example: 业务数据库 + type: string + description: + description: Struct中文名称 + example: Struct中文名称 + type: string + fields: + items: + $ref: '#/definitions/request.AutoCodeField' + type: array + gvaModel: + description: 是否使用gva默认Model + example: false + type: boolean + humpPackageName: + description: go文件名称 + example: go文件名称 + type: string + isAdd: + description: 是否新增 + example: false + type: boolean + isTree: + description: 是否树形结构 + example: false + type: boolean + onlyTemplate: + description: 是否只生成模板 + example: false + type: boolean + package: + type: string + packageName: + description: 文件名称 + example: 文件名称 + type: string + primaryField: + $ref: '#/definitions/request.AutoCodeField' + structName: + description: Struct名称 + example: Struct名称 + type: string + tableName: + description: 表名 + example: 表名 + type: string + treeJson: + description: 展示的树json字段 + example: 展示的树json字段 + type: string + type: object + request.AutoCodeField: + properties: + checkDataSource: + description: 是否检查数据源 + type: boolean + clearable: + description: 是否可清空 + type: boolean + columnName: + description: 数据库字段 + type: string + comment: + description: 数据库字段描述 + type: string + dataSource: + allOf: + - $ref: '#/definitions/request.DataSource' + description: 数据源 + dataTypeLong: + description: 数据库字段长度 + type: string + defaultValue: + description: 是否必填 + type: string + desc: + description: 是否前端详情 + type: boolean + dictType: + description: 字典 + type: string + errorText: + description: 校验失败文字 + type: string + excel: + description: 是否导入/导出 + type: boolean + fieldDesc: + description: 中文名 + type: string + fieldIndexType: + description: 索引类型 + type: string + fieldJson: + description: FieldJson + type: string + fieldName: + description: Field名 + type: string + fieldSearchHide: + description: 是否隐藏查询条件 + type: boolean + fieldSearchType: + description: 搜索条件 + type: string + fieldType: + description: Field数据类型 + type: string + form: + description: Front bool `json:"front"` // 是否前端可见 + type: boolean + primaryKey: + description: 是否主键 + type: boolean + require: + description: 是否必填 + type: boolean + sort: + description: 是否增加排序 + type: boolean + table: + description: 是否前端表格列 + type: boolean type: object request.CasbinInReceive: properties: @@ -829,6 +1011,22 @@ definitions: description: 密码 type: string type: object + request.DataSource: + properties: + association: + description: 关联关系 1 一对一 2 一对多 + type: integer + dbName: + type: string + hasDeletedAt: + type: boolean + label: + type: string + table: + type: string + value: + type: string + type: object request.Empty: type: object request.GetAuthorityId: @@ -843,6 +1041,26 @@ definitions: description: 主键ID type: integer type: object + request.GetUserList: + properties: + email: + type: string + keyword: + description: 关键字 + type: string + nickName: + type: string + page: + description: 页码 + type: integer + pageSize: + description: 每页大小 + type: integer + phone: + type: string + username: + type: string + type: object request.IdsReq: properties: ids: @@ -1577,23 +1795,51 @@ definitions: description: 用户id type: integer type: object + system.SysParams: + properties: + ID: + description: 主键ID + type: integer + createdAt: + description: 创建时间 + type: string + desc: + description: 参数说明 + type: string + key: + description: 参数键 + type: string + name: + description: 参数名称 + type: string + updatedAt: + description: 更新时间 + type: string + value: + description: 参数值 + type: string + required: + - key + - name + - value + type: object system.SysUser: properties: ID: description: 主键ID type: integer authorities: + description: 多用户角色 items: $ref: '#/definitions/system.SysAuthority' type: array authority: - $ref: '#/definitions/system.SysAuthority' + allOf: + - $ref: '#/definitions/system.SysAuthority' + description: 用户角色 authorityId: description: 用户角色ID type: integer - baseColor: - description: 基础颜色 - type: string createdAt: description: 创建时间 type: string @@ -1609,12 +1855,13 @@ definitions: nickName: description: 用户昵称 type: string + originSetting: + allOf: + - $ref: '#/definitions/common.JSONMap' + description: 配置 phone: description: 用户手机号 type: string - sideMode: - description: 用户侧边主题 - type: string updatedAt: description: 更新时间 type: string @@ -1634,7 +1881,7 @@ info: contact: {} description: 使用gin+vue进行极速开发的全栈开发基础平台 title: Gin-Vue-Admin Swagger API接口文档 - version: v2.7.7 + version: v2.7.8-beta1 paths: /api/createApi: post: @@ -1812,7 +2059,7 @@ paths: tags: - SysApi /api/getApiGroups: - post: + get: consumes: - application/json produces: @@ -2079,7 +2326,7 @@ paths: tags: - Authority /authority/updateAuthority: - post: + put: consumes: - application/json parameters: @@ -2347,7 +2594,7 @@ paths: summary: 获取当前表所有字段 tags: - AutoCode - /autoCode/getDatabase: + /autoCode/getDB: get: consumes: - application/json @@ -2504,6 +2751,54 @@ paths: summary: 获取package tags: - AutoCodePackage + /autoCode/initAPI: + post: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: 打包插件成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + additionalProperties: true + type: object + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 打包插件 + tags: + - AutoCodePlugin + /autoCode/initMenu: + post: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: 打包插件成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + additionalProperties: true + type: object + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 打包插件 + tags: + - AutoCodePlugin /autoCode/installPlugin: post: consumes: @@ -2567,7 +2862,7 @@ paths: tags: - AutoCodeTemplate /autoCode/pubPlug: - get: + post: consumes: - application/json parameters: @@ -2989,6 +3284,34 @@ paths: tags: - ExaFileUploadAndDownload /fileUploadAndDownload/findFile: + get: + consumes: + - multipart/form-data + parameters: + - description: Find the file, 查找文件 + in: formData + name: file + required: true + type: file + produces: + - application/json + responses: + "200": + description: 查找文件,返回包括文件详情 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + $ref: '#/definitions/response.FileResponse' + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 查找文件 + tags: + - ExaFileUploadAndDownload post: consumes: - multipart/form-data @@ -3047,6 +3370,32 @@ paths: summary: 分页文件列表 tags: - ExaFileUploadAndDownload + /fileUploadAndDownload/importURL: + post: + parameters: + - description: 对象 + in: body + name: data + required: true + schema: + $ref: '#/definitions/example.ExaFileUploadAndDownload' + produces: + - application/json + responses: + "200": + description: 导入URL + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 导入URL + tags: + - ExaFileUploadAndDownload /fileUploadAndDownload/removeChunk: post: consumes: @@ -4553,6 +4902,243 @@ paths: summary: 分页获取SysOperationRecord列表 tags: - SysOperationRecord + /sysParams/createSysParams: + post: + consumes: + - application/json + parameters: + - description: 创建参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/system.SysParams' + produces: + - application/json + responses: + "200": + description: 创建成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 创建参数 + tags: + - SysParams + /sysParams/deleteSysParams: + delete: + consumes: + - application/json + parameters: + - description: 删除参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/system.SysParams' + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 删除参数 + tags: + - SysParams + /sysParams/deleteSysParamsByIds: + delete: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: 批量删除成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 批量删除参数 + tags: + - SysParams + /sysParams/findSysParams: + get: + consumes: + - application/json + parameters: + - description: 主键ID + in: query + name: ID + type: integer + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 参数说明 + in: query + name: desc + type: string + - description: 参数键 + in: query + name: key + required: true + type: string + - description: 参数名称 + in: query + name: name + required: true + type: string + - description: 更新时间 + in: query + name: updatedAt + type: string + - description: 参数值 + in: query + name: value + required: true + type: string + produces: + - application/json + responses: + "200": + description: 查询成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + $ref: '#/definitions/system.SysParams' + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 用id查询参数 + tags: + - SysParams + /sysParams/getSysParam: + get: + consumes: + - application/json + parameters: + - description: key + in: query + name: key + required: true + type: string + produces: + - application/json + responses: + "200": + description: 获取成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + $ref: '#/definitions/system.SysParams' + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 根据key获取参数value + tags: + - SysParams + /sysParams/getSysParamsList: + get: + consumes: + - application/json + parameters: + - in: query + name: endCreatedAt + type: string + - in: query + name: key + type: string + - description: 关键字 + in: query + name: keyword + type: string + - in: query + name: name + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - in: query + name: startCreatedAt + type: string + produces: + - application/json + responses: + "200": + description: 获取成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + $ref: '#/definitions/response.PageResult' + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 分页获取参数列表 + tags: + - SysParams + /sysParams/updateSysParams: + put: + consumes: + - application/json + parameters: + - description: 更新参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/system.SysParams' + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 更新参数 + tags: + - SysParams /system/getServerInfo: post: produces: @@ -4672,6 +5258,38 @@ paths: summary: 设置用户信息 tags: - SysUser + /user/SetSelfSetting: + put: + consumes: + - application/json + parameters: + - description: 用户配置数据 + in: body + name: data + required: true + schema: + additionalProperties: true + type: object + produces: + - application/json + responses: + "200": + description: 设置用户配置 + schema: + allOf: + - $ref: '#/definitions/response.Response' + - properties: + data: + additionalProperties: true + type: object + msg: + type: string + type: object + security: + - ApiKeyAuth: [] + summary: 设置用户配置 + tags: + - SysUser /user/admin_register: post: parameters: @@ -4786,7 +5404,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/request.PageInfo' + $ref: '#/definitions/request.GetUserList' produces: - application/json responses: diff --git a/server/initialize/ensure_tables.go b/server/initialize/ensure_tables.go index daa79f353..3ef33490f 100644 --- a/server/initialize/ensure_tables.go +++ b/server/initialize/ensure_tables.go @@ -18,7 +18,7 @@ func init() { system.RegisterInit(initOrderEnsureTables, &ensureTables{}) } -func (ensureTables) InitializerName() string { +func (e *ensureTables) InitializerName() string { return "ensure_tables_created" } func (e *ensureTables) InitializeData(ctx context.Context) (next context.Context, err error) { diff --git a/server/initialize/gorm_mssql.go b/server/initialize/gorm_mssql.go index 0ec25a7f5..e1478ea41 100644 --- a/server/initialize/gorm_mssql.go +++ b/server/initialize/gorm_mssql.go @@ -1,3 +1,5 @@ +package initialize + /* * @Author: 逆光飞翔 191180776@qq.com * @Date: 2022-12-08 17:25:49 @@ -6,7 +8,6 @@ * @FilePath: \server\initialize\gorm_mssql.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ -package initialize import ( "github.com/flipped-aurora/gin-vue-admin/server/config" @@ -44,8 +45,8 @@ func GormMssqlByConfig(m config.Mssql) *gorm.DB { return nil } mssqlConfig := sqlserver.Config{ - DSN: m.Dsn(), // DSN data source name - DefaultStringSize: 191, // string 类型字段的默认长度 + DSN: m.Dsn(), // DSN data source name + DefaultStringSize: 191, // string 类型字段的默认长度 } if db, err := gorm.Open(sqlserver.New(mssqlConfig), internal.Gorm.Config(m.Prefix, m.Singular)); err != nil { panic(err) diff --git a/server/main.go b/server/main.go index 2bfab92f4..b4875a87a 100644 --- a/server/main.go +++ b/server/main.go @@ -14,8 +14,15 @@ import ( //go:generate go mod tidy //go:generate go mod download +// 这部分 @Tag 设置用于排序, 需要排序的接口请按照下面的格式添加 +// swag init 对 @Tag 只会从入口文件解析, 默认 main.go +// 也可通过 --generalInfo flag 指定其他文件 +// @Tag.Name Base +// @Tag.Name SysUser +// @Tag.Description 用户 + // @title Gin-Vue-Admin Swagger API接口文档 -// @version v2.7.7 +// @version v2.7.8-beta1 // @description 使用gin+vue进行极速开发的全栈开发基础平台 // @securityDefinitions.apikey ApiKeyAuth // @in header diff --git a/server/middleware/limit_ip.go b/server/middleware/limit_ip.go index 315010b22..acc6e98b6 100644 --- a/server/middleware/limit_ip.go +++ b/server/middleware/limit_ip.go @@ -27,7 +27,7 @@ type LimitConfig struct { func (l LimitConfig) LimitWithTime() gin.HandlerFunc { return func(c *gin.Context) { if err := l.CheckOrMark(l.GenerationKey(c), l.Expire, l.Limit); err != nil { - c.JSON(http.StatusOK, gin.H{"code": response.ERROR, "msg": err}) + c.JSON(http.StatusOK, gin.H{"code": response.ERROR, "msg": err.Error()}) c.Abort() return } else { diff --git a/server/model/common/basetypes.go b/server/model/common/basetypes.go index 870d975c6..1a133d5ad 100644 --- a/server/model/common/basetypes.go +++ b/server/model/common/basetypes.go @@ -34,3 +34,10 @@ func (m *JSONMap) Scan(value interface{}) error { } return nil } + +type TreeNode[T any] interface { + GetChildren() []T + SetChildren(children T) + GetID() int + GetParentID() int +} diff --git a/server/model/system/request/sys_auto_code.go b/server/model/system/request/sys_auto_code.go index 44de979b2..df7cdfcad 100644 --- a/server/model/system/request/sys_auto_code.go +++ b/server/model/system/request/sys_auto_code.go @@ -27,6 +27,8 @@ type AutoCode struct { AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu AutoCreateBtnAuth bool `json:"autoCreateBtnAuth" example:"false"` // 是否自动创建按钮权限 OnlyTemplate bool `json:"onlyTemplate" example:"false"` // 是否只生成模板 + IsTree bool `json:"isTree" example:"false"` // 是否树形结构 + TreeJson string `json:"treeJson" example:"展示的树json字段"` // 展示的树json字段 IsAdd bool `json:"isAdd" example:"false"` // 是否新增 Fields []*AutoCodeField `json:"fields"` Module string `json:"-"` diff --git a/server/model/system/request/sys_auto_history.go b/server/model/system/request/sys_auto_history.go index fb50a7944..e9e3243ed 100644 --- a/server/model/system/request/sys_auto_history.go +++ b/server/model/system/request/sys_auto_history.go @@ -25,6 +25,7 @@ func (r *SysAutoHistoryCreate) Create() model.SysAutoCodeHistory { Request: r.Request, Table: r.Table, StructName: r.StructName, + Abbreviation: r.StructName, BusinessDB: r.BusinessDB, Description: r.Description, Injections: r.Injections, diff --git a/server/model/system/request/sys_casbin.go b/server/model/system/request/sys_casbin.go index ef8c823cb..3ca421276 100644 --- a/server/model/system/request/sys_casbin.go +++ b/server/model/system/request/sys_casbin.go @@ -1,12 +1,12 @@ package request -// Casbin info structure +// CasbinInfo Casbin info structure type CasbinInfo struct { Path string `json:"path"` // 路径 Method string `json:"method"` // 方法 } -// Casbin structure for input parameters +// CasbinInReceive Casbin structure for input parameters type CasbinInReceive struct { AuthorityId uint `json:"authorityId"` // 权限id CasbinInfos []CasbinInfo `json:"casbinInfos"` diff --git a/server/model/system/request/sys_init.go b/server/model/system/request/sys_init.go index cc9f254a5..4edb51345 100644 --- a/server/model/system/request/sys_init.go +++ b/server/model/system/request/sys_init.go @@ -16,7 +16,8 @@ type InitDB struct { Password string `json:"password"` // 数据库密码 DBName string `json:"dbName" binding:"required"` // 数据库名 DBPath string `json:"dbPath"` // sqlite数据库文件路径 - Language string `json:"language",omitempty` // DB initial langauge // added by mohamed hassan to support multilanguage + Template string `json:"template"` // postgresql指定template + Language string `json:"language",omitempty` // DB initial language // added by mohamed hassan to support multilingual } // MysqlEmptyDsn msyql 空数据库 建库链接 diff --git a/server/model/system/request/sys_menu.go b/server/model/system/request/sys_menu.go index 2f5c7c46e..275f037bc 100644 --- a/server/model/system/request/sys_menu.go +++ b/server/model/system/request/sys_menu.go @@ -5,7 +5,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/model/system" ) -// Add menu authority info structure +// AddMenuAuthorityInfo Add menu authority info structure type AddMenuAuthorityInfo struct { Menus []system.SysBaseMenu `json:"menus"` AuthorityId uint `json:"authorityId"` // 角色ID diff --git a/server/model/system/request/sys_user.go b/server/model/system/request/sys_user.go index 2e698d440..45e478769 100644 --- a/server/model/system/request/sys_user.go +++ b/server/model/system/request/sys_user.go @@ -18,7 +18,7 @@ type Register struct { Email string `json:"email" example:"电子邮箱"` } -// User login structure +// Login User login structure type Login struct { Username string `json:"username"` // 用户名 Password string `json:"password"` // 密码 @@ -26,19 +26,19 @@ type Login struct { CaptchaId string `json:"captchaId"` // 验证码ID } -// Modify password structure +// ChangePasswordReq Modify password structure type ChangePasswordReq struct { ID uint `json:"-"` // 从 JWT 中提取 user id,避免越权 Password string `json:"password"` // 密码 NewPassword string `json:"newPassword"` // 新密码 } -// Modify user's auth structure +// SetUserAuth Modify user's auth structure type SetUserAuth struct { AuthorityId uint `json:"authorityId"` // 角色ID } -// Modify user's auth structure +// SetUserAuthorities Modify user's auth structure type SetUserAuthorities struct { ID uint AuthorityIds []uint `json:"authorityIds"` // 角色ID diff --git a/server/model/system/sys_auto_code_history.go b/server/model/system/sys_auto_code_history.go index c36787ddb..e41d5532b 100644 --- a/server/model/system/sys_auto_code_history.go +++ b/server/model/system/sys_auto_code_history.go @@ -16,6 +16,7 @@ type SysAutoCodeHistory struct { Package string `json:"package" gorm:"column:package;comment:模块名/插件名"` Request string `json:"request" gorm:"type:text;column:request;comment:前端传入的结构化信息"` StructName string `json:"structName" gorm:"column:struct_name;comment:结构体名称"` + Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;comment:结构体名称缩写"` BusinessDB string `json:"businessDb" gorm:"column:business_db;comment:业务库"` Description string `json:"description" gorm:"column:description;comment:Struct中文名称"` Templates map[string]string `json:"template" gorm:"serializer:json;type:text;column:templates;comment:模板信息"` diff --git a/server/plugin/announcement/model/info.go b/server/plugin/announcement/model/info.go index fcaa11f59..42d62fe0a 100644 --- a/server/plugin/announcement/model/info.go +++ b/server/plugin/announcement/model/info.go @@ -8,10 +8,10 @@ import ( // Info 公告 结构体 type Info struct { global.GVA_MODEL - Title string `json:"title" form:"title" gorm:"column:title;comment:公告标题;"` //标题 - Content string `json:"content" form:"content" gorm:"column:content;comment:公告内容;type:text;"` //内容 - UserID *int `json:"userID" form:"userID" gorm:"column:user_id;comment:发布者;"` //作者 - Attachments datatypes.JSON `json:"attachments" form:"attachments" gorm:"column:attachments;comment:相关附件;"swaggertype:"array,object"` //附件 + Title string `json:"title" form:"title" gorm:"column:title;comment:公告标题;"` //标题 + Content string `json:"content" form:"content" gorm:"column:content;comment:公告内容;type:text;"` //内容 + UserID *int `json:"userID" form:"userID" gorm:"column:user_id;comment:发布者;"` //作者 + Attachments datatypes.JSON `json:"attachments" form:"attachments" gorm:"column:attachments;comment:相关附件;" swaggertype:"array,object"` //附件 } // TableName 公告 Info自定义表名 gva_announcements_info diff --git a/server/resource/function/api.go.tpl b/server/resource/function/api.go.tpl index 1d276cff6..4b5bd666a 100644 --- a/server/resource/function/api.go.tpl +++ b/server/resource/function/api.go.tpl @@ -2,7 +2,7 @@ // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -22,7 +22,7 @@ func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) { // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "成功" // @Success 200 {object} response.Response{data=object,msg=string} "成功" @@ -37,4 +37,4 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api){{.FuncName}}(c *gin.Context) { } response.OkWithData("返回数据",c) } -{{end}} \ No newline at end of file +{{end}} diff --git a/server/resource/function/api.js.tpl b/server/resource/function/api.js.tpl index 5cc491fe3..a07b10230 100644 --- a/server/resource/function/api.js.tpl +++ b/server/resource/function/api.js.tpl @@ -2,7 +2,7 @@ // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -18,7 +18,7 @@ export const {{.Router}} = () => { // {{.FuncName}} {{.FuncDesc}} // @Tags {{.StructName}} // @Summary {{.FuncDesc}} -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "成功" // @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}] @@ -29,4 +29,4 @@ export const {{.Router}} = () => { }) } -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/server/resource/package/server/api/api.go.tpl b/server/resource/package/server/api/api.go.tpl index 42ae67a0d..26d65d909 100644 --- a/server/resource/package/server/api/api.go.tpl +++ b/server/resource/package/server/api/api.go.tpl @@ -5,7 +5,9 @@ import ( "{{.Module}}/global" "{{.Module}}/model/common/response" "{{.Module}}/model/{{.Package}}" + {{- if not .IsTree}} {{.Package}}Req "{{.Module}}/model/{{.Package}}/request" + {{- end }} "github.com/gin-gonic/gin" "go.uber.org/zap" {{- if .AutoCreateResource}} @@ -25,7 +27,7 @@ type {{.StructName}}Api struct {} // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "创建{{.Description}}" // @Success 200 {object} response.Response{msg=string} "创建成功" @@ -53,7 +55,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Create{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "删除{{.Description}}" // @Success 200 {object} response.Response{msg=string} "删除成功" @@ -76,7 +78,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{msg=string} "批量删除成功" // @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete] @@ -98,7 +100,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}ByIds(c *gi // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body {{.Package}}.{{.StructName}} true "更新{{.Description}}" // @Success 200 {object} response.Response{msg=string} "更新成功" @@ -126,9 +128,9 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Con // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json -// @Param data query {{.Package}}.{{.StructName}} true "用id查询{{.Description}}" +// @Param data query {{.PrimaryField.FieldType}} true "用id查询{{.Description}}" // @Success 200 {object} response.Response{data={{.Package}}.{{.StructName}},msg=string} "查询成功" // @Router /{{.Abbreviation}}/find{{.StructName}} [get] func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Context) { @@ -142,11 +144,30 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Conte response.OkWithData(re{{.Abbreviation}}, c) } +{{- if .IsTree }} +// Get{{.StructName}}List 分页获取{{.Description}}列表,Tree模式下不接受参数 +// @Tags {{.StructName}} +// @Summary 分页获取{{.Description}}列表 +// @Security ApiKeyAuth +// @Accept application/json +// @Produce application/json +// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" +// @Router /{{.Abbreviation}}/get{{.StructName}}List [get] +func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Context) { + list, err := {{.Abbreviation}}Service.Get{{.StructName}}InfoList() + if err != nil { + global.GVA_LOG.Error("获取失败!", zap.Error(err)) + response.FailWithMessage("获取失败:" + err.Error(), c) + return + } + response.OkWithDetailed(list, "获取成功", c) +} +{{- else }} // Get{{.StructName}}List 分页获取{{.Description}}列表 // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功" @@ -171,12 +192,13 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Co PageSize: pageInfo.PageSize, }, global.Translate("general.getDataSuccess"), c) } +{{- end }} {{- if .HasDataSource }} // Get{{.StructName}}DataSource 获取{{.StructName}}的数据源 // @Tags {{.StructName}} // @Summary 获取{{.StructName}}的数据源 -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {object} response.Response{data=object,msg=string} "查询成功" // @Router /{{.Abbreviation}}/get{{.StructName}}DataSource [get] @@ -197,9 +219,8 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}DataSource(c * // Get{{.StructName}}Public 不需要鉴权的{{.Description}}接口 // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json -// @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" // @Router /{{.Abbreviation}}/get{{.StructName}}Public [get] func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}Public(c *gin.Context) { diff --git a/server/resource/package/server/model/model.go.tpl b/server/resource/package/server/model/model.go.tpl index 28cacaed1..0330057c6 100644 --- a/server/resource/package/server/model/model.go.tpl +++ b/server/resource/package/server/model/model.go.tpl @@ -8,18 +8,18 @@ {{- 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"` +{{.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"` +{{.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"` +{{.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"` +{{.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 }} {{.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 }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} {{- end }} {{ else }} @@ -54,24 +54,28 @@ type {{.StructName}} struct { {{- 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"` + {{.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"` + {{.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"` + {{.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"` + {{.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 }} {{.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 }} {{ if .FieldDesc }}//{{.FieldDesc}}{{ end }} {{- end }} {{- if .AutoCreateResource }} CreatedBy uint `gorm:"column:created_by;comment:创建者"` UpdatedBy uint `gorm:"column:updated_by;comment:更新者"` DeletedBy uint `gorm:"column:deleted_by;comment:删除者"` {{- end }} + {{- if .IsTree }} + Children []*{{.StructName}} `json:"children" gorm:"-"` //子节点 + ParentID int `json:"parentID" gorm:"column:parent_id;comment:父节点"` + {{- end }} {{- end }} } @@ -82,4 +86,27 @@ func ({{.StructName}}) TableName() string { } {{ end }} + +{{if .IsTree }} +// GetChildren 实现TreeNode接口 +func (s *{{.StructName}}) GetChildren() []*{{.StructName}} { + return s.Children +} + +// SetChildren 实现TreeNode接口 +func (s *{{.StructName}}) SetChildren(children *{{.StructName}}) { + s.Children = append(s.Children, children) +} + +// GetID 实现TreeNode接口 +func (s *{{.StructName}}) GetID() int { + return int({{if not .GvaModel}}*{{- end }}s.{{.PrimaryField.FieldName}}) +} + +// GetParentID 实现TreeNode接口 +func (s *{{.StructName}}) GetParentID() int { + return s.ParentID +} +{{ end }} + {{ end }} diff --git a/server/resource/package/server/service/service.go.tpl b/server/resource/package/server/service/service.go.tpl index ff42b4ee3..0d6e6a83c 100644 --- a/server/resource/package/server/service/service.go.tpl +++ b/server/resource/package/server/service/service.go.tpl @@ -60,7 +60,12 @@ import ( {{- if not .OnlyTemplate }} "{{.Module}}/global" "{{.Module}}/model/{{.Package}}" + {{- if not .IsTree}} {{.Package}}Req "{{.Module}}/model/{{.Package}}/request" + {{- else }} + "{{.Module}}/utils" + "errors" + {{- end }} {{- if .AutoCreateResource }} "gorm.io/gorm" {{- end}} @@ -80,6 +85,17 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service) Create{{.StructName}}({{ // Delete{{.StructName}} 删除{{.Description}}记录 // Author [yourname](https://github.com/yourname) func ({{.Abbreviation}}Service *{{.StructName}}Service)Delete{{.StructName}}({{.PrimaryField.FieldJson}} string{{- if .AutoCreateResource -}},userID uint{{- end -}}) (err error) { + {{- if .IsTree }} + var count int64 + err = {{$db}}.Find(&{{.Package}}.{{.StructName}}{},"parent_id = ?",{{.PrimaryField.FieldJson}}).Count(&count).Error + if count > 0 { + return errors.New("此节点存在子节点不允许删除") + } + if err != nil { + return err + } + {{- end }} + {{- if .AutoCreateResource }} err = {{$db}}.Transaction(func(tx *gorm.DB) error { if err := tx.Model(&{{.Package}}.{{.StructName}}{}).Where("{{.PrimaryField.ColumnName}} = ?", {{.PrimaryField.FieldJson}}).Update("deleted_by", userID).Error; err != nil { @@ -129,6 +145,20 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}({{.Pri return } + +{{- if .IsTree }} +// Get{{.StructName}}InfoList 分页获取{{.Description}}记录,Tree模式下不添加分页和搜索 +// Author [yourname](https://github.com/yourname) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoList() (list []*{{.Package}}.{{.StructName}},err error) { + // 创建db + db := {{$db}}.Model(&{{.Package}}.{{.StructName}}{}) + var {{.Abbreviation}}s []*{{.Package}}.{{.StructName}} + + err = db.Find(&{{.Abbreviation}}s).Error + + return utils.BuildTree({{.Abbreviation}}s), err +} +{{- else }} // Get{{.StructName}}InfoList 分页获取{{.Description}}记录 // Author [yourname](https://github.com/yourname) func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoList(info {{.Package}}Req.{{.StructName}}Search) (list []{{.Package}}.{{.StructName}}, total int64, err error) { @@ -193,6 +223,8 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis return {{.Abbreviation}}s, total, err } +{{- end }} + {{- if .HasDataSource }} func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}DataSource() (res map[string][]map[string]any, err error) { res = make(map[string][]map[string]any) @@ -215,4 +247,4 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}Public( // 此方法为获取数据源定义的数据 // 请自行实现 } -{{- end }} \ No newline at end of file +{{- end }} diff --git a/server/resource/package/web/api/api.js.tpl b/server/resource/package/web/api/api.js.tpl index 94085baa1..a41ef6f27 100644 --- a/server/resource/package/web/api/api.js.tpl +++ b/server/resource/package/web/api/api.js.tpl @@ -4,7 +4,7 @@ import service from '@/utils/request' // @Tags {{.StructName}} // @Summary 创建{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "创建{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" @@ -20,7 +20,7 @@ export const create{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -36,7 +36,7 @@ export const delete{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 批量删除{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body request.IdsReq true "批量删除{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" @@ -52,7 +52,7 @@ export const delete{{.StructName}}ByIds = (params) => { // @Tags {{.StructName}} // @Summary 更新{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data body model.{{.StructName}} true "更新{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" @@ -68,7 +68,7 @@ export const update{{.StructName}} = (data) => { // @Tags {{.StructName}} // @Summary 用id查询{{.Description}} // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query model.{{.StructName}} true "用id查询{{.Description}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" @@ -84,7 +84,7 @@ export const find{{.StructName}} = (params) => { // @Tags {{.StructName}} // @Summary 分页获取{{.Description}}列表 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query request.PageInfo true "分页获取{{.Description}}列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" @@ -101,7 +101,7 @@ export const get{{.StructName}}List = (params) => { // @Tags {{.StructName}} // @Summary 获取数据源 // @Security ApiKeyAuth -// @accept application/json +// @Accept application/json // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /{{.Abbreviation}}/find{{.StructName}}DataSource [get] @@ -117,7 +117,7 @@ export const get{{.StructName}}DataSource = () => { // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 -// @accept application/json +// @Accept application/json // @Produce application/json // @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表" // @Success 200 {object} response.Response{data=object,msg=string} "获取成功" diff --git a/server/resource/package/web/view/form.vue.tpl b/server/resource/package/web/view/form.vue.tpl index 1f2f9c1c8..3f9bf6b98 100644 --- a/server/resource/package/web/view/form.vue.tpl +++ b/server/resource/package/web/view/form.vue.tpl @@ -3,61 +3,71 @@ // 新增表单中增加如下代码 {{- range .Fields}} {{- if .Form}} - - {{- if .CheckDataSource}} - - - - {{- else }} - {{- if eq .FieldType "bool" }} - - {{- end }} - {{- if eq .FieldType "string" }} - {{- if .DictType}} - - - - {{- else }} - - {{- end }} - {{- end }} - {{- if eq .FieldType "richtext" }} - - {{- end }} - {{- if eq .FieldType "int" }} - - {{- end }} - {{- if eq .FieldType "time.Time" }} - - {{- end }} - {{- if eq .FieldType "float64" }} - - {{- end }} - {{- if eq .FieldType "enum" }} - - - - {{- end }} - {{- if eq .FieldType "picture" }} - - {{- end }} - {{- if eq .FieldType "video" }} - - {{- end }} - {{- if eq .FieldType "pictures" }} - - {{- end }} - {{- if eq .FieldType "file" }} - - {{- end }} - {{- if eq .FieldType "json" }} - // 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取 - {{"{{"}} formData.{{.FieldJson}} {{"}}"}} - {{- end }} - {{- if eq .FieldType "array" }} - - {{- end }} - {{- end }} + + {{- if .CheckDataSource}} + + + + {{- else }} + {{- if eq .FieldType "bool" }} + + {{- end }} + {{- if eq .FieldType "string" }} + {{- if .DictType}} + + + + {{- else }} + + {{- end }} + {{- end }} + {{- if eq .FieldType "richtext" }} + + {{- end }} + {{- if eq .FieldType "json" }} + // 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取 + {{"{{"}} formData.{{.FieldJson}} {{"}}"}} + {{- end }} + {{- if eq .FieldType "array" }} + + {{- end }} + {{- if eq .FieldType "int" }} + + {{- end }} + {{- if eq .FieldType "time.Time" }} + + {{- end }} + {{- if eq .FieldType "float64" }} + + {{- end }} + {{- if eq .FieldType "enum" }} + + + + {{- end }} + {{- if eq .FieldType "picture" }} + + {{- end }} + {{- if eq .FieldType "pictures" }} + + {{- end }} + {{- if eq .FieldType "video" }} + + {{- end }} + {{- if eq .FieldType "file" }} + + {{- end }} + {{- end }} {{- end }} {{- end }} @@ -86,7 +96,7 @@ const {{ $element }}Options = ref([]) {{.FieldJson}}: '', {{- end }} {{- if eq .FieldType "int" }} -{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }}, +{{.FieldJson}}: {{- if or .DataSource}} undefined{{ else }} 0{{- end }}, {{- end }} {{- if eq .FieldType "time.Time" }} {{.FieldJson}}: new Date(), @@ -151,15 +161,25 @@ const getDataSourceFunc = async()=>{ getDataSourceFunc() {{- end }} {{- else }} -<<<<<<< HEAD -======= - ->>>>>>> 51490a7e2c2d02f1a32e81180eb7a48ada0956a2 {{- if not .OnlyTemplate }}