diff --git a/.docker-compose/shell/server-handle.sh b/.docker-compose/shell/server-handle.sh deleted file mode 100644 index 46cec0fc..00000000 --- a/.docker-compose/shell/server-handle.sh +++ /dev/null @@ -1,88 +0,0 @@ -#! /bin/bash - -rm -f ./config.yaml -# 生成config.yaml文件, 用于docker-compose的使用 -touch ./config.yaml -filename="./config.yaml" -cat>"${filename}"< /etc/timezone && \ - date && \ - apk del tzdata - -COPY docker/etc/nginx/nginx.conf.tpl /etc/nginx/nginx.conf.tpl -WORKDIR /app -#copy web -COPY --from=builder /web/dist/ /var/www/ -#copy go app -COPY --from=builder /go/src/gin-vue-admin/gvadmin ./ -COPY --from=builder /go/src/gin-vue-admin/db.db ./ -COPY --from=builder /go/src/gin-vue-admin/config.yaml ./ -COPY --from=builder /go/src/gin-vue-admin/resource ./resource -COPY docker/docker-start.sh ./ - -ENV API_SERVER="http://localhost:8888/" -EXPOSE 80 - -ENTRYPOINT ["./docker-start.sh"] diff --git a/README-en.md b/README-en.md index fdc1bd81..7a107c0e 100644 --- a/README-en.md +++ b/README-en.md @@ -3,36 +3,43 @@
- - + + - +
English | [简体中文](./README.md) +[gitee](https://gitee.com/pixelmax/gin-vue-admin): https://gitee.com/pixelmax/gin-vue-admin + +[github](https://github.com/flipped-aurora/gin-vue-admin): https://github.com/flipped-aurora/gin-vue-admin + +[Vue3 version branch address](https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop): https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop + +[Approval flow branch](https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow): https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow + # Project Guidelines [Online Documentation](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/ - +[From the environment to the deployment of teaching videos](https://www.bilibili.com/video/BV1fV411y7dT) [Development Steps](https://www.gin-vue-admin.com/docs/help) (Contributor: LLemonGreen And Fann) -- Web UI Framework:[element-ui](https://github.com/ElemeFE/element) -- Server Framework:[gin](https://github.com/gin-gonic/gin) ## 1. Basic Introduction ### 1.1 Project Introduction -[Online Demo](http://demo.gin-vue-admin.com/) +> Gin-vue-admin is a backstage management system based on [vue](https://vuejs.org) and [gin](https://gin-gonic.com), which separates the front and rear of the full stack. It integrates jwt authentication, dynamic routing, dynamic menu, casbin authentication, form generator, code generator and other functions. It provides a variety of sample files, allowing you to focus more time on business development. + +[Online Demo](http://demo.gin-vue-admin.com): http://demo.gin-vue-admin.com username:admin password:123456 -> Gin-vue-admin is a full-stack (frontend and backend separation) framework designed for management system. -> It integrates multiple functions, such as JWT authentication, dynamic routing, dynamic menu, casbin authentication, form generator, code generator, etc. So that you can focus more time on your business Requirements. +### 1.2 Contributing Guide Hi! Thank you for choosing gin-vue-admin. @@ -40,7 +47,6 @@ Gin-vue-admin is a full-stack (frontend and backend separation) framework for de We are excited that you are interested in contributing to gin-vue-admin. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines. -### 1.2 Contributing Guide #### 1.2.1 Issue Guidelines - Issues are exclusively for bug reports, feature requests and design-related topics. Other questions may be closed directly. If any questions come up when you are using Element, please hit [Gitter](https://gitter.im/element-en/Lobby) for help. @@ -72,81 +78,34 @@ We are excited that you are interested in contributing to gin-vue-admin. Before - node version > v8.6.0 - golang version >= v1.14 - IDE recommendation: Goland -- We recommend you to apply for your own cloud service in QINIU. Replace the public key, private key, warehouse name and default url address with your own, so as not to mess up the test database. +- initialization project: different versions of the database are not initialized. See synonyms at initialization https://www.gin-vue-admin.com/docs/first +- Replace the Qiniuyun public key, private key, warehouse name and default url address in the project to avoid data confusion in the test file. ``` -> Use docker-compose to experience this project -- Installation docker-compose [Official document](https://docs.docker.com/compose/install/) - - ```shell script - # Install on Linux - # 1.1 Run this command to download the current stable version of Docker Compose - sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - # 1.2 Apply executable permissions to binary files - sudo chmod +x /usr/local/bin/docker-compose - ``` - - ```shell script - # Use Python's pip installation - pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple - ``` - - Use Docker Desktop - - Windows: https://hub.docker.com/editions/community/docker-ce-desktop-windows - - Mac: https://hub.docker.com/editions/community/docker-ce-desktop-mac/ +### 2.1 server project -- Use git to clone this project - - ```git - git clone https://github.com/flipped-aurora/gin-vue-admin.git - ``` - -- Use docker-compose up to start the startup project with one click - - ```shell script - # Use docker-compose to start four containers - docker-compose up - # If you modify some configuration options, you can use this command to repackage the image - docker-compose up --build - # Use docker-compose to start in the background - docker-compose up -d - ``` - - - Web project preview [http://127.0.0.1:8000](http://127.0.0.1:8000) - - - swagger APIs [http://127.0.0.1:8888/swagger/index.html](http://127.0.0.1:8888/swagger/index.html) - -- If the internal ip of the server's 177.7.0.12 container is occupied, the place to be modified is - - - Replace 177.7.0.12 on line 39 of [docker-compose.yaml](./docker-compose.yaml) with the ip you want - - Replace 177.7.0.12 in line 20 of [.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf) with the ip you want - -- docker-compose uses a custom docker network - - - ```dockerfile - networks: - network: - ipam: - driver: default - config: - - subnet: '177.7.0.0/16' - ``` - - - Subnet address, the default gateway is 177.7.0.1 (docker-compose V2 needs to write, V3 does not need),For specific information, see the [official document](https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address) - - - The default network name is gin-vue-admin_network, and the default is bridge mode - - - If the subnet is modified, the ipv4_address of each service needs to be modified, and the ip of the server on line 20 of [.docker-compose/nginx/conf.d/my.conf](.docker-compose/nginx/conf.d/my.conf) also needs to be modified - -> **Use docker-compose to deploy this project need attention** - -- For mysql database, please use a local database installed on the server disk. - - Avoid using mysql in the docker container, there may be write problems, io is lower than the host machine, docker's persistence mechanism problem -- [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) is for docker-compose ==experience this project==, prohibit the use of [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize project data, Database initialization[Please use this method](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96) - - Use [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize all problems, please bear it yourself, and have nothing to do with this project -- When deploying using docker-compose of this project,Please modify the [nginx configuration](.docker-compose/nginx/conf.d/my.conf), mysql configuration, networks configuration, redis configuration corresponding to [docker-compose.yaml](./docker-compose.yaml), and make changes as needed. - -### 2.1 Web +use `Goland` And other editing tools,open server catalogue,You can't open it. `gin-vue-admin` root directory ```bash # clone the project -git clone https://github.com/piexlmax/gin-vue-admin.git +git clone https://github.com/flipped-aurora/gin-vue-admin.git +# open server catalogue +cd server + +# use go mod And install the go dependency package +go generate + +# Compile +go build -o server main.go (windows the compile command is go build -o server.exe main.go ) + +# Run binary +./server (windows The run command is server.exe) +``` + +### 2.1 web project + +```bash # enter the project directory cd web @@ -169,47 +128,6 @@ go list (go mod tidy) go build ``` -> Zap log library usage guide && configuration guide - -The configuration of the Zap log library selects zap under [config.yaml](./server/config.yaml) - -```yaml -# zap logger configuration -zap: - level: 'debug' - format: 'console' - prefix: '[GIN-VUE-ADMIN]' - director: 'log' - link_name: 'latest_log' - show_line: true - encode_level: 'LowercaseColorLevelEncoder' - stacktrace_key: 'stacktrace' - log_in_console: true -``` - -| Configuration Name | Type Of Configuration | Description | -| ------------------ | --------------------- | ------------------------------------------------------------ | -| level | string | For a detailed description of the level mode, please see the official [zap documentation](https://pkg.go.dev/go.uber.org/zap?tab=doc#pkg-constants)
info: info mode, stack information without errors, only output information
debug: debug mode, stack details with errors
warn:warn mode
error: error mode, stack details with error
dpanic: dpanic mode
panic: panic mode
fatal: fatal mode
| -| format | string | console: Output log in console format
json: json format output log | -| prefix | string | Log prefix | -| director | string | The folder to store the log can be modified, no need to create it manually | -| link_name | string | [A soft connection file](https://baike.baidu.com/item/%E8%BD%AF%E9%93%BE%E6%8E%A5) of link_name will be generated in the server directory, and the link is the latest log file of the director configuration item | -| show_line | bool | Display the line number, the default is true, it is not recommended to modify | -| encode_level | string | LowercaseLevelEncoder: lowercase
LowercaseColorLevelEncoder: lowercase with color
CapitalLevelEncoder: uppercase
CapitalColorLevelEncoder: uppercase with color | -| stacktrace_key | string | The name of the stack, that is, the key of josn when outputting the log in json format | -| log_in_console | bool | Whether to output to the console, the default is true | - -- Development environment || Debug environment configuration recommendations - - `level:debug` - - `format:console` - - `encode_level:LowercaseColorLevelEncoder`或者`encode_leve:CapitalColorLevelEncoder` -- Deployment environment configuration recommendations - - `level:error` - - `format:json` - - `encode_level: LowercaseLevelEncoder `或者 `encode_level:CapitalLevelEncoder` - - `log_in_console: false` -- Suggestions are only suggestions, you can proceed according to your own needs, and suggestions are for reference only - ### 2.3 API docs auto-generation using swagger #### 2.3.1 install swagger @@ -221,19 +139,20 @@ go get -u github.com/swaggo/swag/cmd/swag ##### (2) In mainland China -In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/) +In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/) or [goproxy.cn](https://goproxy.cn) ````bash -If you are using Go version 1.13 and above (recommended) -# Enable Go Modules function +# If you are using a version of Go 1.13 - 1.15 Need to set up manually GO111MODULE=on, The opening mode is as follows, If your Go version is 1.16 ~ Latest edition You can ignore the following step one +# Step one、Enable Go Modules Function go env -w GO111MODULE=on -# Configure GOPROXY environment variables -go env -w GOPROXY=https://goproxy.io,direct -If you are using Go version 1.12 and below -go env -w GO111MODULE=on -go env -w GOPROXY=https://goproxy.io +# Step two、Configuration GOPROXY Environment variable +go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct -# Use the following command to download swag +# If you dislike trouble,You can use the go generate Automatically execute code before compilation, But this can't be used command line terminal of `Goland` or `Vscode` +cd server +go generate -run "go env -w .*?" + +# 使用如下命令下载swag go get -u github.com/swaggo/swag/cmd/swag ```` @@ -243,18 +162,19 @@ go get -u github.com/swaggo/swag/cmd/swag cd server swag init ```` -After executing the above command,`docs` will show in `server/`,then open your browser, jump into `http://localhost:8888/swagger/index.html` to see the swagger APIs. + +> After executing the above command,server directory will appear in the docs folder `docs.go`, `swagger.json`, `swagger.yaml` Three file updates,After starting the go service, type in the browser [http://localhost:8888/swagger/index.html](http://localhost:8888/swagger/index.html) You can view swagger document ## 3. Technical selection -- Frontend: using `Element-UI` based on vue,to code the page. -- Backend: using `Gin` to quickly build basic RESTful API. `Gin` is a web framework written in Go (Golang). -- DB: `MySql`(5.6.44),using `gorm` to implement data manipulation, added support for SQLite databases. +- Frontend: using [Element](https://github.com/ElemeFE/element) based on [Vue](https://vuejs.org),to code the page. +- Backend: using [Gin](https://gin-gonic.com/) to quickly build basic RESTful API. [Gin](https://gin-gonic.com/)is a web framework written in Go (Golang). +- DB: `MySql`(5.6.44),using [gorm](http://gorm.io)` to implement data manipulation, added support for SQLite databases. - Cache: using `Redis` to implement the recording of the JWT token of the currently active user and implement the multi-login restriction. - API: using Swagger to auto generate APIs docs。 -- Config: using `fsnotify` and `viper` to implement `yaml` config file。 -- Log: using `go-logging` record logs。 +- Config: using [fsnotify](https://github.com/fsnotify/fsnotify) and [viper](https://github.com/spf13/viper) to implement `yaml` config file。 +- Log: using [zap](https://github.com/uber-go/zap) record logs。 ## 4. Project Architecture @@ -269,19 +189,31 @@ After executing the above command,`docs` will show in `server/`,then open yo ### 4.3 Project Layout ``` - ├─server (backend) - │ ├─api (API entrance) - │ ├─config (config file) - │ ├─core (core code) - │ ├─docs (swagger APIs docs) - │ ├─global (global objet) - │ ├─initialiaze (initialiazation) - │ ├─middleware (middle ware) - │ ├─model (model and services) - │ ├─resource (resources, such as static pages, templates) - │ ├─router (routers) - │ ├─service (services) - │ └─utils (common utilities) + ├── server + ├── api (api entrance) + │ └── v1 (v1 version interface) + ├── config (configuration package) + ├── core (core document) + ├── docs (swagger document directory) + ├── global (global object) + ├── initialize (initialization) + │ └── internal (initialize internal function) + ├── middleware (middleware layer) + ├── model (model layer) + │ ├── request (input parameter structure) + │ └── response (out-of-parameter structure) + ├── packfile (static file packaging) + ├── resource (static resource folder) + │ ├── excel (excel import and export default path) + │ ├── page (form generator) + │ └── template (template) + ├── router (routing layer) + ├── service (service layer) + ├── source (source layer) + └── utils (tool kit) + ├── timer (timer interface encapsulation) + └── upload (oss interface encapsulation) + └─web (frontend) ├─public (deploy templates) └─src (source code) @@ -299,58 +231,59 @@ After executing the above command,`docs` will show in `server/`,then open yo ## 5. Features - Authority management: Authority management based on `jwt` and `casbin`. -- File upload & download: File upload operation based on Qiniu Cloud (In order to make it easier for everyone to test, I have provided various important tokens of my Qiniu test number, and I urge you not to make things a mess). -- Pagination Encapsulation:The frontend uses mixins to encapsulate paging, and the paging method can call mixins +- File upload and download: implement file upload operations based on `Qiniuyun', `Aliyun 'and `Tencent Cloud` (please develop your own application for each platform corresponding to `token` or `key` ). +- Pagination Encapsulation:The frontend uses `mixins` to encapsulate paging, and the paging method can call `mixins` . - User management: The system administrator assigns user roles and role permissions. - Role management: Create the main object of permission control, and then assign different API permissions and menu permissions to the role. - Menu management: User dynamic menu configuration implementation, assigning different menus to different roles. - API management: Different users can call different API permissions. -- Configuration management: The configuration file can be modified in the web page (the test environment does not provide this function). -- Rich text editor: Embed MarkDown editor function. +- Configuration management: the configuration file can be modified in the foreground (this feature is not available in the online experience site). - Conditional search: Add an example of conditional search. - Restful example: You can see sample APIs in user management module. - -``` -fontend code file: src\view\superAdmin\api\api.vue -backend code file: model\dnModel\api.go -``` -- Multi-login restriction: Change `userMultipoint` to true in `system` in `config.yaml` (You need to configure redis and redis parameters yourself. During the test period, please report in time if there is a bug). + - Front-end file reference: [web/src/view/superAdmin/api/api.vue](https://github.com/flipped-aurora/gin-vue-admin/blob/master/web/src/view/superAdmin/api/api.vue). + - Stage reference: [server/router/sys_api.go](https://github.com/flipped-aurora/gin-vue-admin/blob/master/server/router/sys_api.go). +- Multi-login restriction: Change `user-multipoint` to true in `system` in `config.yaml` (You need to configure redis and redis parameters yourself. During the test period, please report in time if there is a bug). - Upload file by chunk:Provides examples of file upload and large file upload by chunk. - Form Builder:With the help of [@form-generator](https://github.com/JakHuang/form-generator). - Code generator: Providing backend with basic logic and simple curd code generator. -## 6. To-do list +## 6. Knowledge base -- [ ] upload & export Excel -- [ ] e-chart -- [ ] workflow, task transfer function -- [ ] frontend independent mode, mock - -## 7. Knowledge base - -### 7.1 Team blog +### 6.1 Team blog > https://www.yuque.com/flipped-aurora > >There are video courses about frontend framework in our blo. If you think the project is helpful to you, you can add my personal WeChat:shouzi_1994,your comments is welcomed。 -### 7.2 Video courses +### 6.2 Video courses (1) Development environment course + > Bilibili:https://www.bilibili.com/video/BV1Fg4y187Bw/ (2) Template course + > Bilibili:https://www.bilibili.com/video/BV16K4y1r7BD/ -(3)2.0 version introduction and development experience +(3) 2.0 version introduction and development experience + > Bilibili:https://www.bilibili.com/video/BV1aV411d7Gm#reply2831798461 -(4) Golang basic course (coming soon) +(4) Golang basic course > https://space.bilibili.com/322210472/channel/detail?cid=108884 -## 8. Contacts -### 8.1 Groups +(5) gin frame basic teaching + +> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=126418&ctype=0 + +(6) gin-vue-admin version update introduction video +> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=126418&ctype=0 + +## 7.Contacts + +### 7.1 Groups + #### QQ group: 622360840 | QQ group |d @@ -366,11 +299,11 @@ backend code file: model\dnModel\api.go #### [About Us](https://www.gin-vue-admin.com/about/) -## 9. Donate +## 8. Donate If you find this project useful, you can buy author a glass of juice :tropical_drink: [here](https://www.gin-vue-admin.com/docs/coffee) -## 10. Commercial considerations +## 9. Commercial considerations If you use this project for commercial purposes, please comply with the Apache2.0 agreement and retain the author's technical support statement. diff --git a/README.md b/README.md index 32213fc0..23bb7cff 100644 --- a/README.md +++ b/README.md @@ -3,44 +3,42 @@
- - + + - +
[English](./README-en.md) | 简体中文 -[gitee地址:https://gitee.com/pixelmax/gin-vue-admin](https://gitee.com/pixelmax/gin-vue-admin) +[gitee地址](https://gitee.com/pixelmax/gin-vue-admin): https://gitee.com/pixelmax/gin-vue-admin -[github地址:https://github.com/flipped-aurora/gin-vue-admin](https://github.com/flipped-aurora/gin-vue-admin) +[github地址](https://github.com/flipped-aurora/gin-vue-admin): https://github.com/flipped-aurora/gin-vue-admin -[vue3版本分支地址:https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop](https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop) +[vue3版本分支地址](https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop): https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop -[审批流分支:https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow](https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow) +[审批流分支](https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow): https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow # 项目文档 -[在线文档](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/ +[在线文档](https://www.gin-vue-admin.com) : https://www.gin-vue-admin.com [从环境到部署教学视频](https://www.bilibili.com/video/BV1fV411y7dT) [开发教学](https://www.gin-vue-admin.com/docs/help) (贡献者: LLemonGreen And Fann) -- 前端UI框架:[element-ui](https://github.com/ElemeFE/element) -- 后台框架:[gin](https://github.com/gin-gonic/gin) ## 1. 基本介绍 ### 1.1 项目介绍 -[在线预览](http://demo.gin-vue-admin.com/) +> Gin-vue-admin是一个基于 [vue](https://vuejs.org) 和 [gin](https://gin-gonic.com) 开发的全栈前后端分离的后台管理系统,集成jwt鉴权,动态路由,动态菜单,casbin鉴权,表单生成器,代码生成器等功能,提供多种示例文件,让您把更多时间专注在业务开发上。 + +[在线预览](http://demo.gin-vue-admin.com): http://demo.gin-vue-admin.com 测试用户名:admin 测试密码:123456 -> Gin-vue-admin是一个基于vue和gin开发的全栈前后端分离的后台管理系统,集成jwt鉴权,动态路由,动态菜单,casbin鉴权,表单生成器,代码生成器等功能,提供多种示例文件,让您把更多时间专注在业务开发上。 - ### 1.2 贡献指南 Hi! 首先感谢你使用 gin-vue-admin。 @@ -77,167 +75,68 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm - node版本 > v8.6.0 - golang版本 >= v1.14 - IDE推荐:Goland -- 初始化项目: 不同版本数据库初始化不通 参见https://www.gin-vue-admin.com/docs/server#1-%E5%88%9D%E5%A7%8B%E5%8C%96server%E9%A1%B9%E7%9B%AE +- 初始化项目: 不同版本数据库初始化不通 参见 https://www.gin-vue-admin.com/docs/first - 替换掉项目中的七牛云公钥,私钥,仓名和默认url地址,以免发生测试文件数据错乱 ``` -> 使用docker-compose体验本项目 -- 安装 docker-compose [官方文档](https://docs.docker.com/compose/install/) - - ```shell script - # 在Linux安装 - # 1.1 运行此命令以下载Docker Compose的当前稳定版本 - sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - # 1.2 将可执行权限应用于二进制文件 - sudo chmod +x /usr/local/bin/docker-compose - ``` - - ```shell script - # 使用Python的pip安装 - pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple - ``` - - 使用 Docker Desktop - - Windows: https://hub.docker.com/editions/community/docker-ce-desktop-windows - - Mac: https://hub.docker.com/editions/community/docker-ce-desktop-mac/ +### 2.1 server项目 -- 使用git克隆本项目 - - ```git - git clone https://github.com/flipped-aurora/gin-vue-admin.git - ``` - -- 使用docker-compose up一键启动启动项目 - - ```shell script - # 使用docker-compose启动四个容器 - docker-compose up - # 如果您修改了某些配置选项,可以使用此命令重新打包镜像 - docker-compose up --build - # 使用docker-compose 后台启动 - docker-compose up -d - ``` - - - web项目预览 [http://127.0.0.1:8000](http://127.0.0.1:8000) - - - swagger文档 [http://127.0.0.1:8888/swagger/index.html](http://127.0.0.1:8888/swagger/index.html) - -- 如果server的177.7.0.12这个容器内部ip被占用了,需要修改地方为 - - - [docker-compose.yaml](./docker-compose.yaml)的第39行的177.7.0.12更换为你想要的ip - - [.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf)的第20行的177.7.0.12更换为你想要的ip - -- docker-compose使用自定义的一个docker网络 - - - ```dockerfile - networks: - network: - ipam: - driver: default - config: - - subnet: '177.7.0.0/16' - ``` - - - 子网地址, 默认网关是177.7.0.1(docker-compose V2需要写,V3则不需要),具体信息看[官方文档](https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address) - - - 默认的network名为gin-vue-admin_network,默认是bridge模式 - - - 如果修改了子网,对应的每个service的ipv4_address都需要修改,还有[.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf)的第20行的server的ip也需要修改 - -> **使用docker-compose进行部署本项目需注意的问题** - -- dockerfile_server使用了多阶段构建,这是docker 17.05后引入的,因此安装的docker版本需要高于17.05 -- mysql数据库请使用装在服务器磁盘的本地数据库. - - 避免使用docker容器内的mysql,可能会出现写入的问题, io比宿主机低 docker的持久化机制问题 -- [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)是给docker-compose进行体验本项目的, 禁止[init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)使用进行项目数据的初始化, 数据库初始化[请使用此方法](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96) - - 使用[init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)进行初始化出现的所有问题,请自行承担,与本项目无关 -- 使用本项目的docker-compose进行部署时,请修改[docker-compose.yaml](./docker-compose.yaml)对应的[nginx配置](.docker-compose/nginx/conf.d/my.conf),mysql配置,networks配置,redis配置,按需自行更改. - -### 2.1 web端 +使用 `Goland` 等编辑工具,打开server目录,不可以打开 gin-vue-admin 根目录 ```bash -# clone the project -git clone https://github.com/piexlmax/gin-vue-admin.git -# enter the project directory +# 克隆项目 +git clone https://github.com/flipped-aurora/gin-vue-admin.git +# 进入server文件夹 +cd server + +# 使用 go mod 并安装go依赖包 +go generate + +# 编译 +go build -o server main.go (windows编译命令为go build -o server.exe main.go ) + +# 运行二进制 +./server (windows运行命令为 server.exe) +``` + +### 2.2 web项目 + +```bash +# 进入web文件夹 cd web -# install dependency -npm install +# 安装依赖 +cnpm install || npm install -# develop +# 启动web项目 npm run serve ``` -### 2.2 server端 - -使用 goland等编辑工具,打开server目录,不可以打开 gin-vue-admin 根目录 - -```bash -# 使用 go.mod - -# 安装go依赖包 -go list (go mod tidy) - -# 编译 -go build -``` - -> Zap日志库使用指南&&配置指南 - -Zap日志库的配置选择在[config.yaml](./server/config.yaml)下的zap - -```yaml -# zap logger configuration -zap: - level: 'debug' - format: 'console' - prefix: '[GIN-VUE-ADMIN]' - director: 'log' - link_name: 'latest_log' - show_line: true - encode_level: 'LowercaseColorLevelEncoder' - stacktrace_key: 'stacktrace' - log_in_console: true -``` - -| 配置名 | 配置的类型 | 说明 | -| -------------- | ---------- | ------------------------------------------------------------ | -| level | string | level的模式的详细说明,请看[zap官方文档](https://pkg.go.dev/go.uber.org/zap?tab=doc#pkg-constants)
info: info模式,无错误的堆栈信息,只输出信息
debug:debug模式,有错误的堆栈详细信息
warn:warn模式
error: error模式,有错误的堆栈详细信息
dpanic: dpanic模式
panic: panic模式
fatal: fatal模式
| -| format | string | console: 控制台形式输出日志
json: json格式输出日志 | -| prefix | string | 日志的前缀 | -| director | string | 存放日志的文件夹,修改即可,不需要手动创建 | -| link_name | string | 在server目录下会生成一个link_name的[软连接文件](https://baike.baidu.com/item/%E8%BD%AF%E9%93%BE%E6%8E%A5),链接的是director配置项的最新日志文件 | -| show_line | bool | 显示行号, 默认为true,不建议修改 | -| encode_level | string | LowercaseLevelEncoder:小写
LowercaseColorLevelEncoder:小写带颜色
CapitalLevelEncoder: 大写
CapitalColorLevelEncoder: 大写带颜色 | -| stacktrace_key | string | 堆栈的名称,即在json格式输出日志时的josn的key | -| log_in_console | bool | 是否输出到控制台,默认为true | - -- 开发环境 || 调试环境配置建议 - - `level:debug` - - `format:console` - - `encode_level:LowercaseColorLevelEncoder`或者`encode_leve:CapitalColorLevelEncoder` -- 部署环境配置建议 - - `level:error` - - `format:json` - - `encode_level: LowercaseLevelEncoder `或者 `encode_level:CapitalLevelEncoder` - - `log_in_console: false` -- 建议只是建议,按照自己的需求进行即可,给出建议仅供参考 - ### 2.3 swagger自动化API文档 #### 2.3.1 安装 swagger ##### (1)可以访问外国网站 + ```` go get -u github.com/swaggo/swag/cmd/swag ```` ##### (2)无法访问外国网站 -由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/) +由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.cn](https://goproxy.cn) 或者 [goproxy.io](https://goproxy.io/zh/) ```bash -如果您使用的 Go 版本是 1.13 及以上(推荐) -# 启用 Go Modules 功能 +# 如果您使用的 Go 版本是 1.13 - 1.15 需要手动设置GO111MODULE=on, 开启方式如下命令, 如果你的 Go 版本 是 1.16 ~ 最新版 可以忽略以下步骤一 +# 步骤一、启用 Go Modules 功能 go env -w GO111MODULE=on -# 配置 GOPROXY 环境变量 -go env -w GOPROXY=https://goproxy.io,direct +# 步骤二、配置 GOPROXY 环境变量 +go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct + +# 如果嫌弃麻烦,可以使用go generate 编译前自动执行代码, 不过这个不能使用 `Goland` 或者 `Vscode` 的 命令行终端 +cd server +go generate -run "go env -w .*?" # 使用如下命令下载swag go get -u github.com/swaggo/swag/cmd/swag @@ -245,25 +144,26 @@ go get -u github.com/swaggo/swag/cmd/swag #### 2.3.2 生成API文档 -```` +```` shell cd server swag init ```` -执行上面的命令后,server目录下会出现docs文件夹,登录 http://localhost:8888/swagger/index.html ,即可查看swagger文档 + +> 执行上面的命令后,server目录下会出现docs文件夹里的 `docs.go`, `swagger.json`, `swagger.yaml` 三个文件更新,启动go服务之后, 在浏览器输入 [http://localhost:8888/swagger/index.html](http://localhost:8888/swagger/index.html) 即可查看swagger文档 ## 3. 技术选型 -- 前端:用基于`vue`的`Element-UI`构建基础页面。 -- 后端:用`Gin`快速搭建基础restful风格API,`Gin`是一个go语言编写的Web框架。 -- 数据库:采用`MySql`(5.6.44)版本,使用`gorm`实现对数据库的基本操作,已添加对sqlite数据库的支持。 +- 前端:用基于 [Vue](https://vuejs.org) 的 [Element](https://github.com/ElemeFE/element) 构建基础页面。 +- 后端:用 [Gin](https://gin-gonic.com/) 快速搭建基础restful风格API,[Gin](https://gin-gonic.com/) 是一个go语言编写的Web框架。 +- 数据库:采用`MySql`(5.6.44)版本,使用 [gorm](http://gorm.cn) 实现对数据库的基本操作。 - 缓存:使用`Redis`实现记录当前活跃用户的`jwt`令牌并实现多点登录限制。 - API文档:使用`Swagger`构建自动化文档。 -- 配置文件:使用`fsnotify`和`viper`实现`yaml`格式的配置文件。 -- 日志:使用`go-logging`实现日志记录。 - +- 配置文件:使用 [fsnotify](https://github.com/fsnotify/fsnotify) 和 [viper](https://github.com/spf13/viper) 实现`yaml`格式的配置文件。 +- 日志:使用 [zap](https://github.com/uber-go/zap) 实现日志记录。 ## 4. 项目架构 + ### 4.1 系统架构图 ![系统架构图](http://qmplusimg.henrongyi.top/gva/gin-vue-admin.png) @@ -275,19 +175,31 @@ swag init ### 4.3 目录结构 ``` - ├─server (后端文件夹) - │ ├─api (API) - │ ├─config (配置包) - │ ├─core (內核) - │ ├─docs (swagger文档目录) - │ ├─global (全局对象) - │ ├─initialiaze (初始化) - │ ├─middleware (中间件) - │ ├─model (结构体层) - │ ├─resource (资源) - │ ├─router (路由) - │ ├─service (服务) - │ └─utils (公共功能) + ├── server + ├── api (api层) + │ └── v1 (v1版本接口) + ├── config (配置包) + ├── core (核心文件) + ├── docs (swagger文档目录) + ├── global (全局对象) + ├── initialize (初始化) + │ └── internal (初始化内部函数) + ├── middleware (中间件层) + ├── model (模型层) + │ ├── request (入参结构体) + │ └── response (出参结构体) + ├── packfile (静态文件打包) + ├── resource (静态资源文件夹) + │ ├── excel (excel导入导出默认路径) + │ ├── page (表单生成器) + │ └── template (模板) + ├── router (路由层) + ├── service (service层) + ├── source (source层) + └── utils (工具包) + ├── timer (定时器接口封装) + └── upload (oss接口封装) + └─web (前端文件) ├─public (发布模板) └─src (源码包) @@ -304,56 +216,60 @@ swag init ## 5. 主要功能 -- 权限管理:基于`jwt`和`casbin`实现的权限管理 -- 文件上传下载:实现基于七牛云的文件上传操作(为了方便大家测试,我公开了自己的七牛测试号的各种重要token,恳请大家不要乱传东西) -- 分页封装:前端使用mixins封装分页,分页方法调用mixins即可 +- 权限管理:基于`jwt`和`casbin`实现的权限管理。 +- 文件上传下载:实现基于`七牛云`, `阿里云`, `腾讯云` 的文件上传操作(请开发自己去各个平台的申请对应 `token` 或者对应`key`)。 +- 分页封装:前端使用 `mixins` 封装分页,分页方法调用 `mixins` 即可。 - 用户管理:系统管理员分配用户角色和角色权限。 - 角色管理:创建权限控制的主要对象,可以给角色分配不同api权限和菜单权限。 - 菜单管理:实现用户动态菜单配置,实现不同角色不同菜单。 - api管理:不同用户可调用的api接口的权限不同。 -- 配置管理:配置文件可前台修改(测试环境不开放此功能)。 -- 富文本编辑器:MarkDown编辑器功能嵌入。 +- 配置管理:配置文件可前台修改(在线体验站点不开放此功能)。 - 条件搜索:增加条件搜索示例。 -- restful示例:可以参考用户管理模块中的示例API。 -``` -前端文件参考: src\view\superAdmin\api\api.vue -后台文件参考: model\dnModel\api.go -``` -- 多点登录限制:需要在`config.yaml`中把`system`中的`useMultipoint`修改为true(需要自行配置Redis和Config中的Redis参数,测试阶段,有bug请及时反馈)。 +- restful示例:可以参考用户管理模块中的示例API。 + - 前端文件参考: [web/src/view/superAdmin/api/api.vue](https://github.com/flipped-aurora/gin-vue-admin/blob/master/web/src/view/superAdmin/api/api.vue) + - 后台文件参考: [server/router/sys_api.go](https://github.com/flipped-aurora/gin-vue-admin/blob/master/server/router/sys_api.go) +- 多点登录限制:需要在`config.yaml`中把`system`中的`use-multipoint`修改为true(需要自行配置Redis和Config中的Redis参数,测试阶段,有bug请及时反馈)。 - 分片长传:提供文件分片上传和大文件分片上传功能示例。 -- 表单生成器:表单生成器借助 [@form-generator](https://github.com/JakHuang/form-generator)。 -- 代码生成器:后台基础逻辑以及简单curd的代码生成器。 +- 表单生成器:表单生成器借助 [@form-generator](https://github.com/JakHuang/form-generator) 。 +- 代码生成器:后台基础逻辑以及简单curd的代码生成器。 -## 6. 计划任务 +## 6. 知识库 -- [ ] 导入,导出Excel -- [ ] Echart图表支持 -- [ ] 单独前端使用模式以及数据模拟 - -## 7. 知识库 -## 7.1 团队博客 +## 6.1 团队博客 > https://www.yuque.com/flipped-aurora > >内有前端框架教学视频。如果觉得项目对您有所帮助可以添加我的个人微信:shouzi_1994,欢迎您提出宝贵的需求。 -## 7.2 教学视频 +## 6.2 教学视频 (1)环境搭建 -> Bilibili:https://www.bilibili.com/video/BV1Fg4y187Bw/ (v1.0版本视频,v2.0操作相同目录不同) + +> bilibili:https://www.bilibili.com/video/BV1Fg4y187Bw/ (v1.0版本视频,v2.0操作相同目录不同) (2)模板使用 -> Bilibili:https://www.bilibili.com/video/BV16K4y1r7BD/ (v1.0版本视频,v2.0操作相同目录不同) + +> bilibili:https://www.bilibili.com/video/BV16K4y1r7BD/ (v1.0版本视频,v2.0操作相同目录不同) (3)2.0目录以及开发体验 -> Bilibili:https://www.bilibili.com/video/BV1aV411d7Gm#reply2831798461 -(4)golang基础教学视频录制中... -> https://space.bilibili.com/322210472/channel/detail?cid=108884 +> bilibili:https://www.bilibili.com/video/BV1aV411d7Gm#reply2831798461 -## 8. 联系方式 +(4)golang基础教学视频 -### 8.1 技术群 +> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=108884 + +(5)gin框架基础教学 + +> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=126418&ctype=0 + +(6)gin-vue-admin 版本更新介绍视频 + +> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=126418&ctype=0 + +## 7. 联系方式 + +### 7.1 技术群 ### QQ交流群:622360840 | QQ 群 | @@ -369,10 +285,10 @@ swag init ### [关于我们](https://www.gin-vue-admin.com/about/) -## 9. 捐赠 +## 8. 捐赠 如果你觉得这个项目对你有帮助,你可以请作者喝饮料 :tropical_drink: [点我](https://www.gin-vue-admin.com/docs/coffee) -## 10. 商用注意事项 +## 9. 商用注意事项 如果您将此项目用于商业用途,请遵守Apache2.0协议并保留作者技术支持声明。 diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..db76aea0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report security issues to qimiaojiangjizhao@gmail.com diff --git a/docker-compose.yaml b/docker-compose.yaml index d997d799..4f3a204d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,8 +10,8 @@ networks: services: web: build: - context: ./ - dockerfile: ./dockerfile_web + context: ./web + dockerfile: ./Dockerfile container_name: gva-web restart: always ports: @@ -25,8 +25,8 @@ services: server: build: - context: ./ - dockerfile: ./dockerfile_server + context: ./server + dockerfile: ./Dockerfile container_name: gva-server restart: always ports: diff --git a/docker/docker-start.sh b/docker/docker-start.sh deleted file mode 100644 index df7e2e76..00000000 --- a/docker/docker-start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -envsubst '$API_SERVER' < /etc/nginx/nginx.conf.tpl > /etc/nginx/nginx.conf -env nginx -./gvadmin diff --git a/docker/etc/nginx/nginx.conf.tpl b/docker/etc/nginx/nginx.conf.tpl deleted file mode 100644 index c96973cb..00000000 --- a/docker/etc/nginx/nginx.conf.tpl +++ /dev/null @@ -1,56 +0,0 @@ -daemon on; -worker_processes 50; -#error_log /dev/stdout warn; -error_log /var/log/nginx/error.log error; - - -events { - worker_connections 1024; -} - - -http { - include mime.types; - default_type application/octet-stream; - # See http://licson.net/post/optimizing-nginx-for-large-file-delivery/ for more detail - # This optimizes the server for HLS fragment delivery - sendfile off; - #tcp_nopush on; - keepalive_timeout 65; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - #access_log /dev/stdout combined; - -# ssl_ciphers HIGH:!aNULL:!MD5; -# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; -# ssl_session_cache shared:SSL:10m; -# ssl_session_timeout 10m; - -server { - listen 80; - - # Uncomment these lines to enable SSL. - # Update the ssl paths with your own certificate and private key. - # listen 443 ssl; - # ssl_certificate /opt/certs/example.com.crt; - # ssl_certificate_key /opt/certs/example.com.key; - location / { - root /var/www; - try_files $uri $uri/ /index.html; - index index.html; - } - - location /v1/ { - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_pass ${API_SERVER} ; - } - -} - -} diff --git a/dockerfile_server b/dockerfile_server deleted file mode 100644 index 17cc2372..00000000 --- a/dockerfile_server +++ /dev/null @@ -1,28 +0,0 @@ -FROM golang:alpine - -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.io,direct -WORKDIR /go/src/gin-vue-admin -COPY server/ ./ - -RUN cat ./config.yaml -COPY .docker-compose/shell/server-handle.sh . -RUN ls -al -RUN sh ./server-handle.sh -RUN rm -f server-handle.sh -RUN cat ./config.yaml - -RUN go env && go mod tidy && go build -o server . - -FROM alpine:latest -LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com" - -WORKDIR /go/src/gin-vue-admin - -COPY --from=0 /go/src/gin-vue-admin/server ./ -COPY --from=0 /go/src/gin-vue-admin/config.yaml ./ -COPY --from=0 /go/src/gin-vue-admin/resource ./resource - -EXPOSE 8888 - -ENTRYPOINT ./server diff --git a/package-lock.json b/package-lock.json index 48e341a0..8b28c9bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,3 +1,6 @@ { - "lockfileVersion": 1 + "name": "gin-vue-admin", + "lockfileVersion": 2, + "requires": true, + "packages": {} } diff --git a/package.json b/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{} diff --git a/server/Dockerfile b/server/Dockerfile index 75e85f1a..8be43216 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,20 +1,17 @@ FROM golang:alpine -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.io,direct - WORKDIR /go/src/gin-vue-admin COPY . . -RUN go env && go build -o server . + +RUN go generate && go env && go build -o server . FROM alpine:latest LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com" WORKDIR /go/src/gin-vue-admin -COPY --from=0 /go/src/gin-vue-admin/server ./ -COPY --from=0 /go/src/gin-vue-admin/config.yaml ./ -COPY --from=0 /go/src/gin-vue-admin/resource ./resource + +COPY --from=0 /go/src/gin-vue-admin ./ EXPOSE 8888 -ENTRYPOINT ./server +ENTRYPOINT ./server -c config.docker.yaml diff --git a/server/README.md b/server/README.md index 2305e494..9a34870b 100644 --- a/server/README.md +++ b/server/README.md @@ -1,44 +1,54 @@ +## server项目结构 + +```shell +├── api +│   └── v1 +├── config +├── core +├── docs +├── global +├── initialize +│   └── internal +├── middleware +├── model +│   ├── request +│   └── response +├── packfile +├── resource +│   ├── excel +│   ├── page +│   └── template +├── router +├── service +├── source +└── utils + ├── timer + └── upload +``` + +| 文件夹 | 说明 | 描述 | +| ------------ | ----------------------- | --------------------------- | +| `api` | api层 | api层 | +| `--v1` | v1版本接口 | v1版本接口 | +| `config` | 配置包 | config.yaml对应的配置结构体 | +| `core` | 核心文件 | 核心组件(zap, viper, server)的初始化 | +| `docs` | swagger文档目录 | swagger文档目录 | +| `global` | 全局对象 | 全局对象 | +| `initialize` | 初始化 | router,redis,gorm,validator, timer的初始化 | +| `--internal` | 初始化内部函数 | gorm 的 longger 自定义,在此文件夹的函数只能由 `initialize` 层进行调用 | +| `middleware` | 中间件层 | 用于存放 `gin` 中间件代码 | +| `model` | 模型层 | 模型对应数据表 | +| `--request` | 入参结构体 | 接收前端发送到后端的数据。 | +| `--response` | 出参结构体 | 返回给前端的数据结构体 | +| `packfile` | 静态文件打包 | 静态文件打包 | +| `resource` | 静态资源文件夹 | 负责存放静态文件 | +| `--excel` | excel导入导出默认路径 | excel导入导出默认路径 | +| `--page` | 表单生成器 | 表单生成器 打包后的dist | +| `--template` | 模板 | 模板文件夹,存放的是代码生成器的模板 | +| `router` | 路由层 | 路由层 | +| `service` | service层 | 存放业务逻辑问题 | +| `source` | source层 | 存放初始化数据的函数 | +| `utils` | 工具包 | 工具函数封装 | +| `--timer` | timer | 定时器接口封装 | +| `--upload` | oss | oss接口封装 | -整理代码结构 -``` lua -web -├── api/v1 -- 主要API -| ├── sys_initdb.go -- ico -| └── sys_user.go -- -├── config -- 配置文件 设定操作的结构体 -| ├── auto_code.go -- ico captcha.go -| ├── ... -- ico captcha.go -| └── zap.go -- core -├── core -- 主要结构代码 -| ├── server_other.go -- ico captcha.go -| ├── ... -- ico captcha.go -| └── zap.go -- -├── docs -- 文档系统 -| ├── docs.go -- ico captcha.go -| ├── swagger.json -- json -| └── swagger.yaml -- yaml -├── global -- global -├── initialize -- initialize -├── middleware -- 中间键 -├── model -- global -│ ├── request -- 所有请求model结构体 -| | ├── common.go -| | ├── ... -| | └── sys_user.go -- yaml -| ├── response -- 返回数据 -| | ├── common.go -| | ├── ... -| | └── sys_user.go -- yaml -├── packfile -- 文件写入 -├── resource -- 资源文件 -├── router -- 路由 -├── service -- service层 -├── source -- 文件目录操作 -├── utils -├── config.yaml -- -├── Dockerfile -- docker配置 -├── go.mod -- mod 配置 -├── go.sum -- sum -├── latest_log -- vue-cli 配置 -└── main.go -- package.json -``` \ No newline at end of file diff --git a/server/api/v1/autocode/autocodeExample.go b/server/api/v1/autocode/autocodeExample.go new file mode 100644 index 00000000..10024831 --- /dev/null +++ b/server/api/v1/autocode/autocodeExample.go @@ -0,0 +1,121 @@ +package autocode + +import ( + "gin-vue-admin/global" + "gin-vue-admin/model/autocode" + autocodeReq "gin-vue-admin/model/autocode/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/service" + "gin-vue-admin/utils" + "github.com/gin-gonic/gin" + "go.uber.org/zap" +) + +type AutoCodeExampleApi struct { +} + +var autoCodeExampleService = service.ServiceGroupApp.AutoCodeServiceGroup.AutoCodeExampleService + +// @Tags AutoCodeExample +// @Summary 创建AutoCodeExample +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body autocode.AutoCodeExample true "AutoCodeExample模型" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" +// @Router /autoCodeExample/createAutoCodeExample [post] +func (autoCodeExampleApi *AutoCodeExampleApi) CreateAutoCodeExample(c *gin.Context) { + var autoCodeExample autocode.AutoCodeExample + _ = c.ShouldBindJSON(&autoCodeExample) + if err := autoCodeExampleService.CreateAutoCodeExample(autoCodeExample); err != nil { + global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) + response.FailWithMessage("创建失败", c) + } else { + response.OkWithMessage("创建成功", c) + } +} + +// @Tags AutoCodeExample +// @Summary 删除AutoCodeExample +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body autocode.AutoCodeExample true "AutoCodeExample模型" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /autoCodeExample/deleteAutoCodeExample [delete] +func (autoCodeExampleApi *AutoCodeExampleApi) DeleteAutoCodeExample(c *gin.Context) { + var autoCodeExample autocode.AutoCodeExample + _ = c.ShouldBindJSON(&autoCodeExample) + if err := autoCodeExampleService.DeleteAutoCodeExample(autoCodeExample); err != nil { + global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) + response.FailWithMessage("删除失败", c) + } else { + response.OkWithMessage("删除成功", c) + } +} + +// @Tags AutoCodeExample +// @Summary 更新AutoCodeExample +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body autocode.AutoCodeExample true "更新AutoCodeExample" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" +// @Router /autoCodeExample/updateAutoCodeExample [put] +func (autoCodeExampleApi *AutoCodeExampleApi) UpdateAutoCodeExample(c *gin.Context) { + var autoCodeExample autocode.AutoCodeExample + _ = c.ShouldBindJSON(&autoCodeExample) + if err := autoCodeExampleService.UpdateAutoCodeExample(&autoCodeExample); err != nil { + global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) + response.FailWithMessage("更新失败", c) + } else { + response.OkWithMessage("更新成功", c) + } +} + +// @Tags AutoCodeExample +// @Summary 用id查询AutoCodeExample +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query autocode.AutoCodeExample true "用id查询AutoCodeExample" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" +// @Router /autoCodeExample/findAutoCodeExample [get] +func (autoCodeExampleApi *AutoCodeExampleApi) FindAutoCodeExample(c *gin.Context) { + var autoCodeExample autocode.AutoCodeExample + _ = c.ShouldBindQuery(&autoCodeExample) + if err := utils.Verify(autoCodeExample, utils.IdVerify); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + if err, reAutoCodeExample := autoCodeExampleService.GetAutoCodeExample(autoCodeExample.ID); err != nil { + global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) + response.FailWithMessage("查询失败", c) + } else { + response.OkWithDetailed(gin.H{"reAutoCodeExample": reAutoCodeExample}, "查询成功", c) + } +} + +// @Tags AutoCodeExample +// @Summary 分页获取AutoCodeExample列表 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query autocodeReq.AutoCodeExampleSearch true "页码, 每页大小, 搜索条件" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCodeExample/getAutoCodeExampleList [get] +func (autoCodeExampleApi *AutoCodeExampleApi) GetAutoCodeExampleList(c *gin.Context) { + var pageInfo autocodeReq.AutoCodeExampleSearch + _ = c.ShouldBindQuery(&pageInfo) + if err, list, total := autoCodeExampleService.GetAutoCodeExampleInfoList(pageInfo); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } else { + response.OkWithDetailed(response.PageResult{ + List: list, + Total: total, + Page: pageInfo.Page, + PageSize: pageInfo.PageSize, + }, "获取成功", c) + } +} diff --git a/server/api/v1/autocode/enter.go b/server/api/v1/autocode/enter.go new file mode 100644 index 00000000..f391196c --- /dev/null +++ b/server/api/v1/autocode/enter.go @@ -0,0 +1,7 @@ +package autocode + +type ApiGroup struct { + // Code generated by gin-vue-admin Begin; DO NOT EDIT. + AutoCodeExampleApi + // Code generated by gin-vue-admin End; DO NOT EDIT. +} diff --git a/server/api/v1/enter.go b/server/api/v1/enter.go new file mode 100644 index 00000000..b2517198 --- /dev/null +++ b/server/api/v1/enter.go @@ -0,0 +1,15 @@ +package v1 + +import ( + "gin-vue-admin/api/v1/autocode" + "gin-vue-admin/api/v1/example" + "gin-vue-admin/api/v1/system" +) + +type ApiGroup struct { + ExampleApiGroup example.ApiGroup + SystemApiGroup system.ApiGroup + AutoCodeApiGroup autocode.ApiGroup +} + +var ApiGroupApp = new(ApiGroup) diff --git a/server/api/v1/example/enter.go b/server/api/v1/example/enter.go new file mode 100644 index 00000000..d68423bf --- /dev/null +++ b/server/api/v1/example/enter.go @@ -0,0 +1,15 @@ +package example + +import "gin-vue-admin/service" + +type ApiGroup struct { + CustomerApi + ExcelApi + FileUploadAndDownloadApi + SimpleUploaderApi +} + +var fileUploadAndDownloadService = service.ServiceGroupApp.ExampleServiceGroup.FileUploadAndDownloadService +var customerService = service.ServiceGroupApp.ExampleServiceGroup.CustomerService +var excelService = service.ServiceGroupApp.ExampleServiceGroup.ExcelService +var simpleUploaderService = service.ServiceGroupApp.ExampleServiceGroup.SimpleUploaderService diff --git a/server/api/v1/exa_breakpoint_continue.go b/server/api/v1/example/exa_breakpoint_continue.go similarity index 74% rename from server/api/v1/exa_breakpoint_continue.go rename to server/api/v1/example/exa_breakpoint_continue.go index 91f5d55f..03a04c15 100644 --- a/server/api/v1/exa_breakpoint_continue.go +++ b/server/api/v1/example/exa_breakpoint_continue.go @@ -1,9 +1,9 @@ -package v1 +package example import ( "gin-vue-admin/global" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + exampleRes "gin-vue-admin/model/example/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" @@ -19,7 +19,7 @@ import ( // @Param file formData file true "an example for breakpoint resume, 断点续传示例" // @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}" // @Router /fileUploadAndDownload/breakpointContinue [post] -func BreakpointContinue(c *gin.Context) { +func (u *FileUploadAndDownloadApi) BreakpointContinue(c *gin.Context) { fileMd5 := c.Request.FormValue("fileMd5") fileName := c.Request.FormValue("fileName") chunkMd5 := c.Request.FormValue("chunkMd5") @@ -44,7 +44,7 @@ func BreakpointContinue(c *gin.Context) { response.FailWithMessage("检查md5失败", c) return } - err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal) + err, file := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal) if err != nil { global.GVA_LOG.Error("查找或创建记录失败!", zap.Any("err", err)) response.FailWithMessage("查找或创建记录失败", c) @@ -57,7 +57,7 @@ func BreakpointContinue(c *gin.Context) { return } - if err = service.CreateFileChunk(file.ID, pathc, chunkNumber); err != nil { + if err = fileUploadAndDownloadService.CreateFileChunk(file.ID, pathc, chunkNumber); err != nil { global.GVA_LOG.Error("创建文件记录失败!", zap.Any("err", err)) response.FailWithMessage("创建文件记录失败", c) return @@ -73,16 +73,16 @@ func BreakpointContinue(c *gin.Context) { // @Param file formData file true "Find the file, 查找文件" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}" // @Router /fileUploadAndDownload/findFile [post] -func FindFile(c *gin.Context) { +func (u *FileUploadAndDownloadApi) FindFile(c *gin.Context) { fileMd5 := c.Query("fileMd5") fileName := c.Query("fileName") chunkTotal, _ := strconv.Atoi(c.Query("chunkTotal")) - err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal) + err, file := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal) if err != nil { global.GVA_LOG.Error("查找失败!", zap.Any("err", err)) response.FailWithMessage("查找失败", c) } else { - response.OkWithDetailed(response.FileResponse{File: file}, "查找成功", c) + response.OkWithDetailed(exampleRes.FileResponse{File: file}, "查找成功", c) } } @@ -94,15 +94,15 @@ func FindFile(c *gin.Context) { // @Param file formData file true "上传文件完成" // @Success 200 {string} string "{"success":true,"data":{},"msg":"file uploaded, 文件创建成功"}" // @Router /fileUploadAndDownload/findFile [post] -func BreakpointContinueFinish(c *gin.Context) { +func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) { fileMd5 := c.Query("fileMd5") fileName := c.Query("fileName") err, filePath := utils.MakeFile(fileName, fileMd5) if err != nil { global.GVA_LOG.Error("文件创建失败!", zap.Any("err", err)) - response.FailWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建失败", c) + response.FailWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "文件创建失败", c) } else { - response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建成功", c) + response.OkWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "文件创建成功", c) } } @@ -114,16 +114,16 @@ func BreakpointContinueFinish(c *gin.Context) { // @Param file formData file true "删除缓存切片" // @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}" // @Router /fileUploadAndDownload/removeChunk [post] -func RemoveChunk(c *gin.Context) { +func (u *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) { fileMd5 := c.Query("fileMd5") fileName := c.Query("fileName") filePath := c.Query("filePath") err := utils.RemoveChunk(fileMd5) - err = service.DeleteFileChunk(fileMd5, fileName, filePath) + err = fileUploadAndDownloadService.DeleteFileChunk(fileMd5, fileName, filePath) if err != nil { global.GVA_LOG.Error("缓存切片删除失败!", zap.Any("err", err)) - response.FailWithDetailed(response.FilePathResponse{FilePath: filePath}, "缓存切片删除失败", c) + response.FailWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "缓存切片删除失败", c) } else { - response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c) + response.OkWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c) } } diff --git a/server/api/v1/exa_customer.go b/server/api/v1/example/exa_customer.go similarity index 66% rename from server/api/v1/exa_customer.go rename to server/api/v1/example/exa_customer.go index c6721ba2..01ede414 100644 --- a/server/api/v1/exa_customer.go +++ b/server/api/v1/example/exa_customer.go @@ -1,35 +1,37 @@ -package v1 +package example import ( - "fmt" "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/example" + exampleRes "gin-vue-admin/model/example/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type CustomerApi struct { +} + // @Tags ExaCustomer // @Summary 创建客户 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.ExaCustomer true "客户用户名, 客户手机号码" +// @Param data body example.ExaCustomer true "客户用户名, 客户手机号码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /customer/customer [post] -func CreateExaCustomer(c *gin.Context) { - var customer model.ExaCustomer +func (e *CustomerApi) CreateExaCustomer(c *gin.Context) { + var customer example.ExaCustomer _ = c.ShouldBindJSON(&customer) if err := utils.Verify(customer, utils.CustomerVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - customer.SysUserID = getUserID(c) - customer.SysUserAuthorityID = getUserAuthorityId(c) - if err := service.CreateExaCustomer(customer); err != nil { + customer.SysUserID = utils.GetUserID(c) + customer.SysUserAuthorityID = utils.GetUserAuthorityId(c) + if err := customerService.CreateExaCustomer(customer); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -42,17 +44,17 @@ func CreateExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.ExaCustomer true "客户ID" +// @Param data body example.ExaCustomer true "客户ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /customer/customer [delete] -func DeleteExaCustomer(c *gin.Context) { - var customer model.ExaCustomer +func (e *CustomerApi) DeleteExaCustomer(c *gin.Context) { + var customer example.ExaCustomer _ = c.ShouldBindJSON(&customer) if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.DeleteExaCustomer(customer); err != nil { + if err := customerService.DeleteExaCustomer(customer); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -65,11 +67,11 @@ func DeleteExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.ExaCustomer true "客户ID, 客户信息" +// @Param data body example.ExaCustomer true "客户ID, 客户信息" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /customer/customer [put] -func UpdateExaCustomer(c *gin.Context) { - var customer model.ExaCustomer +func (e *CustomerApi) UpdateExaCustomer(c *gin.Context) { + var customer example.ExaCustomer _ = c.ShouldBindJSON(&customer) if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) @@ -79,9 +81,9 @@ func UpdateExaCustomer(c *gin.Context) { response.FailWithMessage(err.Error(), c) return } - if err := service.UpdateExaCustomer(&customer); err != nil { + if err := customerService.UpdateExaCustomer(&customer); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) - response.FailWithMessage("更新失败!", c) + response.FailWithMessage("更新失败", c) } else { response.OkWithMessage("更新成功", c) } @@ -92,22 +94,22 @@ func UpdateExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.ExaCustomer true "客户ID" +// @Param data query example.ExaCustomer true "客户ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customer [get] -func GetExaCustomer(c *gin.Context) { - var customer model.ExaCustomer +func (e *CustomerApi) GetExaCustomer(c *gin.Context) { + var customer example.ExaCustomer _ = c.ShouldBindQuery(&customer) if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - err, data := service.GetExaCustomer(customer.ID) + err, data := customerService.GetExaCustomer(customer.ID) if err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.ExaCustomerResponse{Customer: data}, "获取成功", c) + response.OkWithDetailed(exampleRes.ExaCustomerResponse{Customer: data}, "获取成功", c) } } @@ -116,20 +118,20 @@ func GetExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.PageInfo true "页码, 每页大小" +// @Param data query request.PageInfo true "页码, 每页大小" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customerList [get] -func GetExaCustomerList(c *gin.Context) { +func (e *CustomerApi) GetExaCustomerList(c *gin.Context) { var pageInfo request.PageInfo _ = c.ShouldBindQuery(&pageInfo) if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - err, customerList, total := service.GetCustomerInfoList(getUserAuthorityId(c), pageInfo) + err, customerList, total := customerService.GetCustomerInfoList(utils.GetUserAuthorityId(c), pageInfo) if err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) - response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c) + response.FailWithMessage("获取失败"+err.Error(), c) } else { response.OkWithDetailed(response.PageResult{ List: customerList, diff --git a/server/api/v1/exa_excel.go b/server/api/v1/example/exa_excel.go similarity index 80% rename from server/api/v1/exa_excel.go rename to server/api/v1/example/exa_excel.go index 62807817..dc2a0c66 100644 --- a/server/api/v1/exa_excel.go +++ b/server/api/v1/example/exa_excel.go @@ -1,15 +1,17 @@ -package v1 +package example import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/example" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type ExcelApi struct { +} + // /excel/importExcel 接口,与upload接口作用类似,只是把文件存到resource/excel目录下,用于导入Excel时存放Excel文件(ExcelImport.xlsx) // /excel/loadExcel接口,用于读取resource/excel目录下的文件((ExcelImport.xlsx)并加载为[]model.SysBaseMenu类型的示例数据 // /excel/exportExcel 接口,用于读取前端传来的tableData,生成Excel文件并返回 @@ -20,14 +22,14 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/octet-stream -// @Param data body model.ExcelInfo true "导出Excel文件信息" +// @Param data body example.ExcelInfo true "导出Excel文件信息" // @Success 200 // @Router /excel/exportExcel [post] -func ExportExcel(c *gin.Context) { - var excelInfo model.ExcelInfo +func (e *ExcelApi) ExportExcel(c *gin.Context) { + var excelInfo example.ExcelInfo _ = c.ShouldBindJSON(&excelInfo) filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName - err := service.ParseInfoList2Excel(excelInfo.InfoList, filePath) + err := excelService.ParseInfoList2Excel(excelInfo.InfoList, filePath) if err != nil { global.GVA_LOG.Error("转换Excel失败!", zap.Any("err", err)) response.FailWithMessage("转换Excel失败", c) @@ -45,7 +47,7 @@ func ExportExcel(c *gin.Context) { // @Param file formData file true "导入Excel文件" // @Success 200 {string} string "{"success":true,"data":{},"msg":"导入成功"}" // @Router /excel/importExcel [post] -func ImportExcel(c *gin.Context) { +func (e *ExcelApi) ImportExcel(c *gin.Context) { _, header, err := c.Request.FormFile("file") if err != nil { global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err)) @@ -62,10 +64,10 @@ func ImportExcel(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"加载数据成功"}" // @Router /excel/loadExcel [get] -func LoadExcel(c *gin.Context) { - menus, err := service.ParseExcel2InfoList() +func (e *ExcelApi) LoadExcel(c *gin.Context) { + menus, err := excelService.ParseExcel2InfoList() if err != nil { - global.GVA_LOG.Error("加载数据失败", zap.Any("err", err)) + global.GVA_LOG.Error("加载数据失败!", zap.Any("err", err)) response.FailWithMessage("加载数据失败", c) return } @@ -85,12 +87,12 @@ func LoadExcel(c *gin.Context) { // @Param fileName query string true "模板名称" // @Success 200 // @Router /excel/downloadTemplate [get] -func DownloadTemplate(c *gin.Context) { +func (e *ExcelApi) DownloadTemplate(c *gin.Context) { fileName := c.Query("fileName") filePath := global.GVA_CONFIG.Excel.Dir + fileName ok, err := utils.PathExists(filePath) if !ok || err != nil { - global.GVA_LOG.Error("文件不存在", zap.Any("err", err)) + global.GVA_LOG.Error("文件不存在!", zap.Any("err", err)) response.FailWithMessage("文件不存在", c) return } diff --git a/server/api/v1/exa_file_upload_download.go b/server/api/v1/example/exa_file_upload_download.go similarity index 68% rename from server/api/v1/exa_file_upload_download.go rename to server/api/v1/example/exa_file_upload_download.go index ab007488..7c4dbe71 100644 --- a/server/api/v1/exa_file_upload_download.go +++ b/server/api/v1/example/exa_file_upload_download.go @@ -1,15 +1,18 @@ -package v1 +package example import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/example" + exampleRes "gin-vue-admin/model/example/response" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type FileUploadAndDownloadApi struct { +} + // @Tags ExaFileUploadAndDownload // @Summary 上传文件示例 // @Security ApiKeyAuth @@ -18,8 +21,8 @@ import ( // @Param file formData file true "上传文件示例" // @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}" // @Router /fileUploadAndDownload/upload [post] -func UploadFile(c *gin.Context) { - var file model.ExaFileUploadAndDownload +func (u *FileUploadAndDownloadApi) UploadFile(c *gin.Context) { + var file example.ExaFileUploadAndDownload noSave := c.DefaultQuery("noSave", "0") _, header, err := c.Request.FormFile("file") if err != nil { @@ -27,26 +30,26 @@ func UploadFile(c *gin.Context) { response.FailWithMessage("接收文件失败", c) return } - err, file = service.UploadFile(header, noSave) // 文件上传后拿到文件路径 + err, file = fileUploadAndDownloadService.UploadFile(header, noSave) // 文件上传后拿到文件路径 if err != nil { global.GVA_LOG.Error("修改数据库链接失败!", zap.Any("err", err)) response.FailWithMessage("修改数据库链接失败", c) return } - response.OkWithDetailed(response.ExaFileResponse{File: file}, "上传成功", c) + response.OkWithDetailed(exampleRes.ExaFileResponse{File: file}, "上传成功", c) } // @Tags ExaFileUploadAndDownload // @Summary 删除文件 // @Security ApiKeyAuth // @Produce application/json -// @Param data body model.ExaFileUploadAndDownload true "传入文件里面id即可" +// @Param data body example.ExaFileUploadAndDownload true "传入文件里面id即可" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /fileUploadAndDownload/deleteFile [post] -func DeleteFile(c *gin.Context) { - var file model.ExaFileUploadAndDownload +func (u *FileUploadAndDownloadApi) DeleteFile(c *gin.Context) { + var file example.ExaFileUploadAndDownload _ = c.ShouldBindJSON(&file) - if err := service.DeleteFile(file); err != nil { + if err := fileUploadAndDownloadService.DeleteFile(file); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) return @@ -62,10 +65,10 @@ func DeleteFile(c *gin.Context) { // @Param data body request.PageInfo true "页码, 每页大小" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /fileUploadAndDownload/getFileList [post] -func GetFileList(c *gin.Context) { +func (u *FileUploadAndDownloadApi) GetFileList(c *gin.Context) { var pageInfo request.PageInfo _ = c.ShouldBindJSON(&pageInfo) - err, list, total := service.GetFileRecordInfoList(pageInfo) + err, list, total := fileUploadAndDownloadService.GetFileRecordInfoList(pageInfo) if err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) diff --git a/server/api/v1/exa_simple_uploader.go b/server/api/v1/example/exa_simple_uploader.go similarity index 78% rename from server/api/v1/exa_simple_uploader.go rename to server/api/v1/example/exa_simple_uploader.go index cf86477c..566df369 100644 --- a/server/api/v1/exa_simple_uploader.go +++ b/server/api/v1/example/exa_simple_uploader.go @@ -1,15 +1,17 @@ -package v1 +package example import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/example" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type SimpleUploaderApi struct { +} + // @Tags SimpleUploader // @Summary 断点续传插件版示例 // @Security ApiKeyAuth @@ -17,9 +19,9 @@ import ( // @Produce application/json // @Param file formData file true "断点续传插件版示例" // @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}" -// @Router /simpleUploader/upload [post] -func SimpleUploaderUpload(c *gin.Context) { - var chunk model.ExaSimpleUploader +// @Router /SimpleUploaderApi/upload [post] +func (s *SimpleUploaderApi) SimpleUploaderUpload(c *gin.Context) { + var chunk example.ExaSimpleUploader _, header, err := c.Request.FormFile("file") chunk.Filename = c.PostForm("filename") chunk.ChunkNumber = c.PostForm("chunkNumber") @@ -42,7 +44,7 @@ func SimpleUploaderUpload(c *gin.Context) { return } chunk.CurrentChunkPath = chunkPath - err = service.SaveChunk(chunk) + err = simpleUploaderService.SaveChunk(chunk) if err != nil { global.GVA_LOG.Error("切片创建失败!", zap.Any("err", err)) response.FailWithMessage("切片创建失败", c) @@ -58,10 +60,10 @@ func SimpleUploaderUpload(c *gin.Context) { // @Produce application/json // @Param md5 query string true "md5" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" -// @Router /simpleUploader/checkFileMd5 [get] -func CheckFileMd5(c *gin.Context) { +// @Router /SimpleUploaderApi/checkFileMd5 [get] +func (s *SimpleUploaderApi) CheckFileMd5(c *gin.Context) { md5 := c.Query("md5") - err, chunks, isDone := service.CheckFileMd5(md5) + err, chunks, isDone := simpleUploaderService.CheckFileMd5(md5) if err != nil { global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err)) response.FailWithMessage("md5读取失败", c) @@ -79,11 +81,11 @@ func CheckFileMd5(c *gin.Context) { // @Produce application/json // @Param md5 query string true "md5" // @Success 200 {string} string "{"success":true,"data":{},"msg":"合并成功"}" -// @Router /simpleUploader/mergeFileMd5 [get] -func MergeFileMd5(c *gin.Context) { +// @Router /SimpleUploaderApi/mergeFileMd5 [get] +func (s *SimpleUploaderApi) MergeFileMd5(c *gin.Context) { md5 := c.Query("md5") fileName := c.Query("fileName") - err := service.MergeFileMd5(md5, fileName) + err := simpleUploaderService.MergeFileMd5(md5, fileName) if err != nil { global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err)) response.FailWithMessage("md5读取失败", c) diff --git a/server/api/v1/sys_auto_code.go b/server/api/v1/sys_auto_code.go deleted file mode 100644 index 435e9bf2..00000000 --- a/server/api/v1/sys_auto_code.go +++ /dev/null @@ -1,136 +0,0 @@ -package v1 - -import ( - "errors" - "fmt" - "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/response" - "gin-vue-admin/service" - "gin-vue-admin/utils" - "net/url" - "os" - - "github.com/gin-gonic/gin" - "go.uber.org/zap" -) - -// @Tags AutoCode -// @Summary 预览创建后的代码 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param data body model.AutoCodeStruct true "预览创建代码" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" -// @Router /autoCode/preview [post] -func PreviewTemp(c *gin.Context) { - var a model.AutoCodeStruct - _ = c.ShouldBindJSON(&a) - if err := utils.Verify(a, utils.AutoCodeVerify); err != nil { - response.FailWithMessage(err.Error(), c) - return - } - autoCode, err := service.PreviewTemp(a) - if err != nil { - global.GVA_LOG.Error("预览失败!", zap.Any("err", err)) - response.FailWithMessage("预览失败", c) - } else { - response.OkWithDetailed(gin.H{"autoCode": autoCode}, "预览成功", c) - } -} - -// @Tags AutoCode -// @Summary 自动代码模板 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param data body model.AutoCodeStruct true "创建自动代码" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" -// @Router /autoCode/createTemp [post] -func CreateTemp(c *gin.Context) { - var a model.AutoCodeStruct - _ = c.ShouldBindJSON(&a) - if err := utils.Verify(a, utils.AutoCodeVerify); err != nil { - response.FailWithMessage(err.Error(), c) - return - } - if a.AutoCreateApiToSql { - if err := service.AutoCreateApi(&a); err != nil { - global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err)) - c.Writer.Header().Add("success", "false") - c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!")) - return - } - } - err := service.CreateTemp(a) - if err != nil { - if errors.Is(err, model.AutoMoveErr) { - c.Writer.Header().Add("success", "false") - c.Writer.Header().Add("msgtype", "success") - c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) - } else { - c.Writer.Header().Add("success", "false") - c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) - _ = os.Remove("./ginvueadmin.zip") - } - - } else { - c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) // fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名 - c.Writer.Header().Add("Content-Type", "application/json") - c.Writer.Header().Add("success", "true") - c.File("./ginvueadmin.zip") - _ = os.Remove("./ginvueadmin.zip") - } -} - -// @Tags AutoCode -// @Summary 获取当前数据库所有表 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /autoCode/getTables [get] -func GetTables(c *gin.Context) { - dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname) - err, tables := service.GetTables(dbName) - if err != nil { - global.GVA_LOG.Error("查询table失败!", zap.Any("err", err)) - response.FailWithMessage("查询table失败", c) - } else { - response.OkWithDetailed(gin.H{"tables": tables}, "获取成功", c) - } -} - -// @Tags AutoCode -// @Summary 获取当前所有数据库 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /autoCode/getDatabase [get] -func GetDB(c *gin.Context) { - if err, dbs := service.GetDB(); err != nil { - global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) - response.FailWithMessage("获取失败", c) - } else { - response.OkWithDetailed(gin.H{"dbs": dbs}, "获取成功", c) - } -} - -// @Tags AutoCode -// @Summary 获取当前表所有字段 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /autoCode/getColumn [get] -func GetColumn(c *gin.Context) { - dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname) - tableName := c.Query("tableName") - if err, columns := service.GetColumn(tableName, dbName); err != nil { - global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) - response.FailWithMessage("获取失败", c) - } else { - response.OkWithDetailed(gin.H{"columns": columns}, "获取成功", c) - } -} diff --git a/server/api/v1/system/enter.go b/server/api/v1/system/enter.go new file mode 100644 index 00000000..aa4eb730 --- /dev/null +++ b/server/api/v1/system/enter.go @@ -0,0 +1,34 @@ +package system + +import "gin-vue-admin/service" + +type ApiGroup struct { + SystemApiApi + AuthorityApi + AutoCodeApi + BaseApi + CasbinApi + DictionaryApi + DictionaryDetailApi + SystemApi + DBApi + JwtApi + OperationRecordApi + AuthorityMenuApi +} + +var authorityService = service.ServiceGroupApp.SystemServiceGroup.AuthorityService +var apiService = service.ServiceGroupApp.SystemServiceGroup.ApiService +var menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService +var casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService +var autoCodeService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeService +var autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistoryService +var dictionaryService = service.ServiceGroupApp.SystemServiceGroup.DictionaryService +var dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService +var emailService = service.ServiceGroupApp.SystemServiceGroup.EmailService +var initDBService = service.ServiceGroupApp.SystemServiceGroup.InitDBService +var jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService +var baseMenuService = service.ServiceGroupApp.SystemServiceGroup.BaseMenuService +var operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService +var userService = service.ServiceGroupApp.SystemServiceGroup.UserService +var systemConfigService = service.ServiceGroupApp.SystemServiceGroup.SystemConfigService diff --git a/server/api/v1/sys_api.go b/server/api/v1/system/sys_api.go similarity index 71% rename from server/api/v1/sys_api.go rename to server/api/v1/system/sys_api.go index 32573644..cae0eb55 100644 --- a/server/api/v1/sys_api.go +++ b/server/api/v1/system/sys_api.go @@ -1,33 +1,37 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type SystemApiApi struct { +} + // @Tags SysApi // @Summary 创建基础api // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法" +// @Param data body system.SysApi true "api路径, api中文描述, api组, 方法" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /api/createApi [post] -func CreateApi(c *gin.Context) { - var api model.SysApi +func (s *SystemApiApi) CreateApi(c *gin.Context) { + var api system.SysApi _ = c.ShouldBindJSON(&api) if err := utils.Verify(api, utils.ApiVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.CreateApi(api); err != nil { + if err := apiService.CreateApi(api); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -40,17 +44,17 @@ func CreateApi(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysApi true "ID" +// @Param data body system.SysApi true "ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /api/deleteApi [post] -func DeleteApi(c *gin.Context) { - var api model.SysApi +func (s *SystemApiApi) DeleteApi(c *gin.Context) { + var api system.SysApi _ = c.ShouldBindJSON(&api) if err := utils.Verify(api.GVA_MODEL, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.DeleteApi(api); err != nil { + if err := apiService.DeleteApi(api); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -63,17 +67,17 @@ func DeleteApi(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.SearchApiParams true "分页获取API列表" +// @Param data body systemReq.SearchApiParams true "分页获取API列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getApiList [post] -func GetApiList(c *gin.Context) { - var pageInfo request.SearchApiParams +func (s *SystemApiApi) GetApiList(c *gin.Context) { + var pageInfo systemReq.SearchApiParams _ = c.ShouldBindJSON(&pageInfo) if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, list, total := service.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); err != nil { + if err, list, total := apiService.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { @@ -94,19 +98,19 @@ func GetApiList(c *gin.Context) { // @Param data body request.GetById true "根据id获取api" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getApiById [post] -func GetApiById(c *gin.Context) { +func (s *SystemApiApi) GetApiById(c *gin.Context) { var idInfo request.GetById _ = c.ShouldBindJSON(&idInfo) if err := utils.Verify(idInfo, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - err, api := service.GetApiById(idInfo.ID) + err, api := apiService.GetApiById(idInfo.ID) if err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithData(response.SysAPIResponse{Api: api}, c) + response.OkWithData(systemRes.SysAPIResponse{Api: api}, c) } } @@ -115,17 +119,17 @@ func GetApiById(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法" +// @Param data body system.SysApi true "api路径, api中文描述, api组, 方法" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /api/updateApi [post] -func UpdateApi(c *gin.Context) { - var api model.SysApi +func (s *SystemApiApi) UpdateApi(c *gin.Context) { + var api system.SysApi _ = c.ShouldBindJSON(&api) if err := utils.Verify(api, utils.ApiVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.UpdateApi(api); err != nil { + if err := apiService.UpdateApi(api); err != nil { global.GVA_LOG.Error("修改失败!", zap.Any("err", err)) response.FailWithMessage("修改失败", c) } else { @@ -140,12 +144,12 @@ func UpdateApi(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getAllApis [post] -func GetAllApis(c *gin.Context) { - if err, apis := service.GetAllApis(); err != nil { +func (s *SystemApiApi) GetAllApis(c *gin.Context) { + if err, apis := apiService.GetAllApis(); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.SysAPIListResponse{Apis: apis}, "获取成功", c) + response.OkWithDetailed(systemRes.SysAPIListResponse{Apis: apis}, "获取成功", c) } } @@ -157,10 +161,10 @@ func GetAllApis(c *gin.Context) { // @Param data body request.IdsReq true "ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /api/deleteApisByIds [delete] -func DeleteApisByIds(c *gin.Context) { +func (s *SystemApiApi) DeleteApisByIds(c *gin.Context) { var ids request.IdsReq _ = c.ShouldBindJSON(&ids) - if err := service.DeleteApisByIds(ids); err != nil { + if err := apiService.DeleteApisByIds(ids); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { diff --git a/server/api/v1/sys_authority.go b/server/api/v1/system/sys_authority.go similarity index 66% rename from server/api/v1/sys_authority.go rename to server/api/v1/system/sys_authority.go index 4b3f7149..e8f28f22 100644 --- a/server/api/v1/sys_authority.go +++ b/server/api/v1/system/sys_authority.go @@ -1,36 +1,43 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" + "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type AuthorityApi struct { +} + // @Tags Authority // @Summary 创建角色 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id" +// @Param data body system.SysAuthority true "权限id, 权限名, 父角色id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /authority/createAuthority [post] -func CreateAuthority(c *gin.Context) { - var authority model.SysAuthority +func (a *AuthorityApi) CreateAuthority(c *gin.Context) { + var authority system.SysAuthority _ = c.ShouldBindJSON(&authority) if err := utils.Verify(authority, utils.AuthorityVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, authBack := service.CreateAuthority(authority); err != nil { + if err, authBack := authorityService.CreateAuthority(authority); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败"+err.Error(), c) } else { - response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c) + _ = menuService.AddMenuAuthority(systemReq.DefaultMenu(), authority.AuthorityId) + _ = casbinService.UpdateCasbin(authority.AuthorityId, systemReq.DefaultCasbin()) + response.OkWithDetailed(systemRes.SysAuthorityResponse{Authority: authBack}, "创建成功", c) } } @@ -42,8 +49,8 @@ func CreateAuthority(c *gin.Context) { // @Param data body response.SysAuthorityCopyResponse true "旧角色id, 新权限id, 新权限名, 新父角色id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"拷贝成功"}" // @Router /authority/copyAuthority [post] -func CopyAuthority(c *gin.Context) { - var copyInfo response.SysAuthorityCopyResponse +func (a *AuthorityApi) CopyAuthority(c *gin.Context) { + var copyInfo systemRes.SysAuthorityCopyResponse _ = c.ShouldBindJSON(©Info) if err := utils.Verify(copyInfo, utils.OldAuthorityVerify); err != nil { response.FailWithMessage(err.Error(), c) @@ -53,11 +60,11 @@ func CopyAuthority(c *gin.Context) { response.FailWithMessage(err.Error(), c) return } - if err, authBack := service.CopyAuthority(copyInfo); err != nil { + if err, authBack := authorityService.CopyAuthority(copyInfo); err != nil { global.GVA_LOG.Error("拷贝失败!", zap.Any("err", err)) response.FailWithMessage("拷贝失败"+err.Error(), c) } else { - response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "拷贝成功", c) + response.OkWithDetailed(systemRes.SysAuthorityResponse{Authority: authBack}, "拷贝成功", c) } } @@ -66,17 +73,17 @@ func CopyAuthority(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysAuthority true "删除角色" +// @Param data body system.SysAuthority true "删除角色" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /authority/deleteAuthority [post] -func DeleteAuthority(c *gin.Context) { - var authority model.SysAuthority +func (a *AuthorityApi) DeleteAuthority(c *gin.Context) { + var authority system.SysAuthority _ = c.ShouldBindJSON(&authority) if err := utils.Verify(authority, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.DeleteAuthority(&authority); err != nil { // 删除角色之前需要判断是否有用户正在使用此角色 + if err := authorityService.DeleteAuthority(&authority); err != nil { // 删除角色之前需要判断是否有用户正在使用此角色 global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败"+err.Error(), c) } else { @@ -89,21 +96,21 @@ func DeleteAuthority(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id" +// @Param data body system.SysAuthority true "权限id, 权限名, 父角色id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /authority/updateAuthority [post] -func UpdateAuthority(c *gin.Context) { - var auth model.SysAuthority +func (a *AuthorityApi) UpdateAuthority(c *gin.Context) { + var auth system.SysAuthority _ = c.ShouldBindJSON(&auth) if err := utils.Verify(auth, utils.AuthorityVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, authority := service.UpdateAuthority(auth); err != nil { + if err, authority := authorityService.UpdateAuthority(auth); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败"+err.Error(), c) } else { - response.OkWithDetailed(response.SysAuthorityResponse{Authority: authority}, "更新成功", c) + response.OkWithDetailed(systemRes.SysAuthorityResponse{Authority: authority}, "更新成功", c) } } @@ -115,14 +122,14 @@ func UpdateAuthority(c *gin.Context) { // @Param data body request.PageInfo true "页码, 每页大小" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /authority/getAuthorityList [post] -func GetAuthorityList(c *gin.Context) { +func (a *AuthorityApi) GetAuthorityList(c *gin.Context) { var pageInfo request.PageInfo _ = c.ShouldBindJSON(&pageInfo) if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, list, total := service.GetAuthorityInfoList(pageInfo); err != nil { + if err, list, total := authorityService.GetAuthorityInfoList(pageInfo); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败"+err.Error(), c) } else { @@ -140,17 +147,17 @@ func GetAuthorityList(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysAuthority true "设置角色资源权限" +// @Param data body system.SysAuthority true "设置角色资源权限" // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /authority/setDataAuthority [post] -func SetDataAuthority(c *gin.Context) { - var auth model.SysAuthority +func (a *AuthorityApi) SetDataAuthority(c *gin.Context) { + var auth system.SysAuthority _ = c.ShouldBindJSON(&auth) if err := utils.Verify(auth, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.SetDataAuthority(auth); err != nil { + if err := authorityService.SetDataAuthority(auth); err != nil { global.GVA_LOG.Error("设置失败!", zap.Any("err", err)) response.FailWithMessage("设置失败"+err.Error(), c) } else { diff --git a/server/api/v1/system/sys_auto_code.go b/server/api/v1/system/sys_auto_code.go new file mode 100644 index 00000000..c7efd0ea --- /dev/null +++ b/server/api/v1/system/sys_auto_code.go @@ -0,0 +1,224 @@ +package system + +import ( + "errors" + "fmt" + "gin-vue-admin/global" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" + "gin-vue-admin/utils" + "net/url" + "os" + + "github.com/gin-gonic/gin" + "go.uber.org/zap" +) + +type AutoCodeApi struct { +} + +// @Tags AutoCode +// @Summary 删除回滚记录 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body systemReq.AutoHistoryByID true "删除回滚记录" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /autoCode/delSysHistory [post] +func (autoApi *AutoCodeApi) DelSysHistory(c *gin.Context) { + var id systemReq.AutoHistoryByID + _ = c.ShouldBindJSON(&id) + err := autoCodeHistoryService.DeletePage(id.ID) + if err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } + response.OkWithMessage("删除成功", c) + +} + +// @Tags AutoCode +// @Summary 查询回滚记录 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body systemReq.SysAutoHistory true "查询回滚记录" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCode/getSysHistory [post] +func (autoApi *AutoCodeApi) GetSysHistory(c *gin.Context) { + var search systemReq.SysAutoHistory + _ = c.ShouldBindJSON(&search) + err, list, total := autoCodeHistoryService.GetSysHistoryPage(search.PageInfo) + if err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } else { + response.OkWithDetailed(response.PageResult{ + List: list, + Total: total, + Page: search.Page, + PageSize: search.PageSize, + }, "获取成功", c) + } +} + +// @Tags AutoCode +// @Summary 回滚 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body systemReq.AutoHistoryByID true "回滚自动生成代码" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"回滚成功"}" +// @Router /autoCode/rollback [post] +func (autoApi *AutoCodeApi) RollBack(c *gin.Context) { + var id systemReq.AutoHistoryByID + _ = c.ShouldBindJSON(&id) + if err := autoCodeHistoryService.RollBack(id.ID); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + response.OkWithMessage("回滚成功", c) +} + +// @Tags AutoCode +// @Summary 回滚 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body systemReq.AutoHistoryByID true "获取meta信息" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCode/getMeta [post] +func (autoApi *AutoCodeApi) GetMeta(c *gin.Context) { + var id systemReq.AutoHistoryByID + _ = c.ShouldBindJSON(&id) + if v, err := autoCodeHistoryService.GetMeta(id.ID); err != nil { + response.FailWithMessage(err.Error(), c) + return + } else { + response.OkWithDetailed(gin.H{"meta": v}, "获取成功", c) + } + +} + +// @Tags AutoCode +// @Summary 预览创建后的代码 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body system.AutoCodeStruct true "预览创建代码" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" +// @Router /autoCode/preview [post] +func (autoApi *AutoCodeApi) PreviewTemp(c *gin.Context) { + var a system.AutoCodeStruct + _ = c.ShouldBindJSON(&a) + if err := utils.Verify(a, utils.AutoCodeVerify); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + autoCode, err := autoCodeService.PreviewTemp(a) + if err != nil { + global.GVA_LOG.Error("预览失败!", zap.Any("err", err)) + response.FailWithMessage("预览失败", c) + } else { + response.OkWithDetailed(gin.H{"autoCode": autoCode}, "预览成功", c) + } +} + +// @Tags AutoCode +// @Summary 自动代码模板 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body system.AutoCodeStruct true "创建自动代码" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" +// @Router /autoCode/createTemp [post] +func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) { + var a system.AutoCodeStruct + _ = c.ShouldBindJSON(&a) + if err := utils.Verify(a, utils.AutoCodeVerify); err != nil { + response.FailWithMessage(err.Error(), c) + return + } + var apiIds []uint + if a.AutoCreateApiToSql { + if ids, err := autoCodeService.AutoCreateApi(&a); err != nil { + global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err)) + c.Writer.Header().Add("success", "false") + c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!")) + return + } else { + apiIds = ids + } + } + err := autoCodeService.CreateTemp(a, apiIds...) + if err != nil { + if errors.Is(err, system.AutoMoveErr) { + c.Writer.Header().Add("success", "false") + c.Writer.Header().Add("msgtype", "success") + c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) + } else { + c.Writer.Header().Add("success", "false") + c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) + _ = os.Remove("./ginvueadmin.zip") + } + } else { + c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) // fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名 + c.Writer.Header().Add("Content-Type", "application/json") + c.Writer.Header().Add("success", "true") + c.File("./ginvueadmin.zip") + _ = os.Remove("./ginvueadmin.zip") + } +} + +// @Tags AutoCode +// @Summary 获取当前数据库所有表 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCode/getTables [get] +func (autoApi *AutoCodeApi) GetTables(c *gin.Context) { + dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname) + err, tables := autoCodeService.GetTables(dbName) + if err != nil { + global.GVA_LOG.Error("查询table失败!", zap.Any("err", err)) + response.FailWithMessage("查询table失败", c) + } else { + response.OkWithDetailed(gin.H{"tables": tables}, "获取成功", c) + } +} + +// @Tags AutoCode +// @Summary 获取当前所有数据库 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCode/getDatabase [get] +func (autoApi *AutoCodeApi) GetDB(c *gin.Context) { + if err, dbs := autoCodeService.GetDB(); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } else { + response.OkWithDetailed(gin.H{"dbs": dbs}, "获取成功", c) + } +} + +// @Tags AutoCode +// @Summary 获取当前表所有字段 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /autoCode/getColumn [get] +func (autoApi *AutoCodeApi) GetColumn(c *gin.Context) { + dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname) + tableName := c.Query("tableName") + if err, columns := autoCodeService.GetColumn(tableName, dbName); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } else { + response.OkWithDetailed(gin.H{"columns": columns}, "获取成功", c) + } +} diff --git a/server/api/v1/sys_captcha.go b/server/api/v1/system/sys_captcha.go similarity index 65% rename from server/api/v1/sys_captcha.go rename to server/api/v1/system/sys_captcha.go index 48a4c6a6..1a357f7d 100644 --- a/server/api/v1/sys_captcha.go +++ b/server/api/v1/system/sys_captcha.go @@ -1,15 +1,21 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model/response" + "gin-vue-admin/model/common/response" + systemRes "gin-vue-admin/model/system/response" "github.com/gin-gonic/gin" "github.com/mojocn/base64Captcha" "go.uber.org/zap" ) +// 当开启多服务器部署时,替换下面的配置,使用redis共享存储验证码 +//var store = captcha.NewDefaultRedisStore() var store = base64Captcha.DefaultMemStore +type BaseApi struct { +} + // @Tags Base // @Summary 生成验证码 // @Security ApiKeyAuth @@ -17,16 +23,17 @@ var store = base64Captcha.DefaultMemStore // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"验证码获取成功"}" // @Router /base/captcha [post] -func Captcha(c *gin.Context) { - //字符,公式,验证码配置 +func (b *BaseApi) Captcha(c *gin.Context) { + // 字符,公式,验证码配置 // 生成默认数字的driver driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80) + //cp := base64Captcha.NewCaptcha(driver, store.UseWithCtx(c)) // v8下使用redis cp := base64Captcha.NewCaptcha(driver, store) if id, b64s, err := cp.Generate(); err != nil { global.GVA_LOG.Error("验证码获取失败!", zap.Any("err", err)) response.FailWithMessage("验证码获取失败", c) } else { - response.OkWithDetailed(response.SysCaptchaResponse{ + response.OkWithDetailed(systemRes.SysCaptchaResponse{ CaptchaId: id, PicPath: b64s, }, "验证码获取成功", c) diff --git a/server/api/v1/sys_casbin.go b/server/api/v1/system/sys_casbin.go similarity index 71% rename from server/api/v1/sys_casbin.go rename to server/api/v1/system/sys_casbin.go index 24e0ba5e..0b3ced48 100644 --- a/server/api/v1/sys_casbin.go +++ b/server/api/v1/system/sys_casbin.go @@ -1,15 +1,18 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system/request" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type CasbinApi struct { +} + // @Tags Casbin // @Summary 更新角色api权限 // @Security ApiKeyAuth @@ -18,14 +21,14 @@ import ( // @Param data body request.CasbinInReceive true "权限id, 权限模型列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /casbin/UpdateCasbin [post] -func UpdateCasbin(c *gin.Context) { +func (cas *CasbinApi) UpdateCasbin(c *gin.Context) { var cmr request.CasbinInReceive _ = c.ShouldBindJSON(&cmr) if err := utils.Verify(cmr, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos); err != nil { + if err := casbinService.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { @@ -41,13 +44,13 @@ func UpdateCasbin(c *gin.Context) { // @Param data body request.CasbinInReceive true "权限id, 权限模型列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/getPolicyPathByAuthorityId [post] -func GetPolicyPathByAuthorityId(c *gin.Context) { +func (cas *CasbinApi) GetPolicyPathByAuthorityId(c *gin.Context) { var casbin request.CasbinInReceive _ = c.ShouldBindJSON(&casbin) if err := utils.Verify(casbin, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - paths := service.GetPolicyPathByAuthorityId(casbin.AuthorityId) - response.OkWithDetailed(response.PolicyPathResponse{Paths: paths}, "获取成功", c) + paths := casbinService.GetPolicyPathByAuthorityId(casbin.AuthorityId) + response.OkWithDetailed(systemRes.PolicyPathResponse{Paths: paths}, "获取成功", c) } diff --git a/server/api/v1/sys_dictionary.go b/server/api/v1/system/sys_dictionary.go similarity index 66% rename from server/api/v1/sys_dictionary.go rename to server/api/v1/system/sys_dictionary.go index 23477de2..11aa6104 100644 --- a/server/api/v1/sys_dictionary.go +++ b/server/api/v1/system/sys_dictionary.go @@ -1,28 +1,30 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + "gin-vue-admin/model/system/request" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type DictionaryApi struct { +} + // @Tags SysDictionary // @Summary 创建SysDictionary // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionary true "SysDictionary模型" +// @Param data body system.SysDictionary true "SysDictionary模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /sysDictionary/createSysDictionary [post] -func CreateSysDictionary(c *gin.Context) { - var dictionary model.SysDictionary +func (s *DictionaryApi) CreateSysDictionary(c *gin.Context) { + var dictionary system.SysDictionary _ = c.ShouldBindJSON(&dictionary) - if err := service.CreateSysDictionary(dictionary); err != nil { + if err := dictionaryService.CreateSysDictionary(dictionary); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -35,13 +37,13 @@ func CreateSysDictionary(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionary true "SysDictionary模型" +// @Param data body system.SysDictionary true "SysDictionary模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysDictionary/deleteSysDictionary [delete] -func DeleteSysDictionary(c *gin.Context) { - var dictionary model.SysDictionary +func (s *DictionaryApi) DeleteSysDictionary(c *gin.Context) { + var dictionary system.SysDictionary _ = c.ShouldBindJSON(&dictionary) - if err := service.DeleteSysDictionary(dictionary); err != nil { + if err := dictionaryService.DeleteSysDictionary(dictionary); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -54,13 +56,13 @@ func DeleteSysDictionary(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionary true "SysDictionary模型" +// @Param data body system.SysDictionary true "SysDictionary模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /sysDictionary/updateSysDictionary [put] -func UpdateSysDictionary(c *gin.Context) { - var dictionary model.SysDictionary +func (s *DictionaryApi) UpdateSysDictionary(c *gin.Context) { + var dictionary system.SysDictionary _ = c.ShouldBindJSON(&dictionary) - if err := service.UpdateSysDictionary(&dictionary); err != nil { + if err := dictionaryService.UpdateSysDictionary(&dictionary); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { @@ -73,13 +75,13 @@ func UpdateSysDictionary(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionary true "ID或字典英名" +// @Param data query system.SysDictionary true "ID或字典英名" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /sysDictionary/findSysDictionary [get] -func FindSysDictionary(c *gin.Context) { - var dictionary model.SysDictionary +func (s *DictionaryApi) FindSysDictionary(c *gin.Context) { + var dictionary system.SysDictionary _ = c.ShouldBindQuery(&dictionary) - if err, sysDictionary := service.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil { + if err, sysDictionary := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { @@ -92,17 +94,17 @@ func FindSysDictionary(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.SysDictionarySearch true "页码, 每页大小, 搜索条件" +// @Param data query request.SysDictionarySearch true "页码, 每页大小, 搜索条件" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionary/getSysDictionaryList [get] -func GetSysDictionaryList(c *gin.Context) { +func (s *DictionaryApi) GetSysDictionaryList(c *gin.Context) { var pageInfo request.SysDictionarySearch _ = c.ShouldBindQuery(&pageInfo) if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, list, total := service.GetSysDictionaryInfoList(pageInfo); err != nil { + if err, list, total := dictionaryService.GetSysDictionaryInfoList(pageInfo); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { diff --git a/server/api/v1/sys_dictionary_detail.go b/server/api/v1/system/sys_dictionary_detail.go similarity index 65% rename from server/api/v1/sys_dictionary_detail.go rename to server/api/v1/system/sys_dictionary_detail.go index a1c2f3f7..756b640e 100644 --- a/server/api/v1/sys_dictionary_detail.go +++ b/server/api/v1/system/sys_dictionary_detail.go @@ -1,28 +1,30 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + "gin-vue-admin/model/system/request" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type DictionaryDetailApi struct { +} + // @Tags SysDictionaryDetail // @Summary 创建SysDictionaryDetail // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型" +// @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /sysDictionaryDetail/createSysDictionaryDetail [post] -func CreateSysDictionaryDetail(c *gin.Context) { - var detail model.SysDictionaryDetail +func (s *DictionaryDetailApi) CreateSysDictionaryDetail(c *gin.Context) { + var detail system.SysDictionaryDetail _ = c.ShouldBindJSON(&detail) - if err := service.CreateSysDictionaryDetail(detail); err != nil { + if err := dictionaryDetailService.CreateSysDictionaryDetail(detail); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -35,13 +37,13 @@ func CreateSysDictionaryDetail(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型" +// @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete] -func DeleteSysDictionaryDetail(c *gin.Context) { - var detail model.SysDictionaryDetail +func (s *DictionaryDetailApi) DeleteSysDictionaryDetail(c *gin.Context) { + var detail system.SysDictionaryDetail _ = c.ShouldBindJSON(&detail) - if err := service.DeleteSysDictionaryDetail(detail); err != nil { + if err := dictionaryDetailService.DeleteSysDictionaryDetail(detail); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -54,13 +56,13 @@ func DeleteSysDictionaryDetail(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionaryDetail true "更新SysDictionaryDetail" +// @Param data body system.SysDictionaryDetail true "更新SysDictionaryDetail" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /sysDictionaryDetail/updateSysDictionaryDetail [put] -func UpdateSysDictionaryDetail(c *gin.Context) { - var detail model.SysDictionaryDetail +func (s *DictionaryDetailApi) UpdateSysDictionaryDetail(c *gin.Context) { + var detail system.SysDictionaryDetail _ = c.ShouldBindJSON(&detail) - if err := service.UpdateSysDictionaryDetail(&detail); err != nil { + if err := dictionaryDetailService.UpdateSysDictionaryDetail(&detail); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { @@ -73,17 +75,17 @@ func UpdateSysDictionaryDetail(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysDictionaryDetail true "用id查询SysDictionaryDetail" +// @Param data query system.SysDictionaryDetail true "用id查询SysDictionaryDetail" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /sysDictionaryDetail/findSysDictionaryDetail [get] -func FindSysDictionaryDetail(c *gin.Context) { - var detail model.SysDictionaryDetail +func (s *DictionaryDetailApi) FindSysDictionaryDetail(c *gin.Context) { + var detail system.SysDictionaryDetail _ = c.ShouldBindQuery(&detail) if err := utils.Verify(detail, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, resysDictionaryDetail := service.GetSysDictionaryDetail(detail.ID); err != nil { + if err, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(detail.ID); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { @@ -96,13 +98,13 @@ func FindSysDictionaryDetail(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件" +// @Param data query request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionaryDetail/getSysDictionaryDetailList [get] -func GetSysDictionaryDetailList(c *gin.Context) { +func (s *DictionaryDetailApi) GetSysDictionaryDetailList(c *gin.Context) { var pageInfo request.SysDictionaryDetailSearch _ = c.ShouldBindQuery(&pageInfo) - if err, list, total := service.GetSysDictionaryDetailInfoList(pageInfo); err != nil { + if err, list, total := dictionaryDetailService.GetSysDictionaryDetailInfoList(pageInfo); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { diff --git a/server/api/v1/sys_email.go b/server/api/v1/system/sys_email.go similarity index 75% rename from server/api/v1/sys_email.go rename to server/api/v1/system/sys_email.go index 2f594843..39b305ca 100644 --- a/server/api/v1/sys_email.go +++ b/server/api/v1/system/sys_email.go @@ -1,9 +1,8 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" "github.com/gin-gonic/gin" "go.uber.org/zap" ) @@ -14,8 +13,8 @@ import ( // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}" // @Router /email/emailTest [post] -func EmailTest(c *gin.Context) { - if err := service.EmailTest(); err != nil { +func (s *SystemApi) EmailTest(c *gin.Context) { + if err := emailService.EmailTest(); err != nil { global.GVA_LOG.Error("发送失败!", zap.Any("err", err)) response.FailWithMessage("发送失败", c) } else { diff --git a/server/api/v1/sys_initdb.go b/server/api/v1/system/sys_initdb.go similarity index 58% rename from server/api/v1/sys_initdb.go rename to server/api/v1/system/sys_initdb.go index f55c8dfb..00ee98e5 100644 --- a/server/api/v1/sys_initdb.go +++ b/server/api/v1/system/sys_initdb.go @@ -1,36 +1,38 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system/request" "go.uber.org/zap" "github.com/gin-gonic/gin" ) +type DBApi struct { +} + // @Tags InitDB // @Summary 初始化用户数据库 // @Produce application/json // @Param data body request.InitDB true "初始化数据库参数" // @Success 200 {string} string "{"code":0,"data":{},"msg":"自动创建数据库成功"}" // @Router /init/initdb [post] -func InitDB(c *gin.Context) { +func (i *DBApi) InitDB(c *gin.Context) { if global.GVA_DB != nil { - global.GVA_LOG.Error("非法访问") - response.FailWithMessage("非法访问", c) + global.GVA_LOG.Error("已存在数据库配置!") + response.FailWithMessage("已存在数据库配置", c) return } var dbInfo request.InitDB if err := c.ShouldBindJSON(&dbInfo); err != nil { - global.GVA_LOG.Error("参数校验不通过", zap.Any("err", err)) + global.GVA_LOG.Error("参数校验不通过!", zap.Any("err", err)) response.FailWithMessage("参数校验不通过", c) return } - if err := service.InitDB(dbInfo); err != nil { - global.GVA_LOG.Error("自动创建数据库失败", zap.Any("err", err)) - response.FailWithMessage("自动创建数据库失败,请查看后台日志", c) + if err := initDBService.InitDB(dbInfo); err != nil { + global.GVA_LOG.Error("自动创建数据库失败!", zap.Any("err", err)) + response.FailWithMessage("自动创建数据库失败,请查看后台日志,检查后在进行初始化", c) return } response.OkWithData("自动创建数据库成功", c) @@ -41,18 +43,14 @@ func InitDB(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"code":0,"data":{},"msg":"探测完成"}" // @Router /init/checkdb [post] -func CheckDB(c *gin.Context) { +func (i *DBApi) CheckDB(c *gin.Context) { if global.GVA_DB != nil { global.GVA_LOG.Info("数据库无需初始化") - response.OkWithDetailed(gin.H{ - "needInit": false, - }, "数据库无需初始化", c) + response.OkWithDetailed(gin.H{"needInit": false}, "数据库无需初始化", c) return } else { global.GVA_LOG.Info("前往初始化数据库") - response.OkWithDetailed(gin.H{ - "needInit": true, - }, "前往初始化数据库", c) + response.OkWithDetailed(gin.H{"needInit": true}, "前往初始化数据库", c) return } } diff --git a/server/api/v1/sys_jwt_blacklist.go b/server/api/v1/system/sys_jwt_blacklist.go similarity index 68% rename from server/api/v1/sys_jwt_blacklist.go rename to server/api/v1/system/sys_jwt_blacklist.go index 62d7ff94..76bedf8a 100644 --- a/server/api/v1/sys_jwt_blacklist.go +++ b/server/api/v1/system/sys_jwt_blacklist.go @@ -1,14 +1,16 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type JwtApi struct { +} + // @Tags Jwt // @Summary jwt加入黑名单 // @Security ApiKeyAuth @@ -16,10 +18,10 @@ import ( // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"拉黑成功"}" // @Router /jwt/jsonInBlacklist [post] -func JsonInBlacklist(c *gin.Context) { +func (j *JwtApi) JsonInBlacklist(c *gin.Context) { token := c.Request.Header.Get("x-token") - jwt := model.JwtBlacklist{Jwt: token} - if err := service.JsonInBlacklist(jwt); err != nil { + jwt := system.JwtBlacklist{Jwt: token} + if err := jwtService.JsonInBlacklist(jwt); err != nil { global.GVA_LOG.Error("jwt作废失败!", zap.Any("err", err)) response.FailWithMessage("jwt作废失败", c) } else { diff --git a/server/api/v1/sys_menu.go b/server/api/v1/system/sys_menu.go similarity index 71% rename from server/api/v1/sys_menu.go rename to server/api/v1/system/sys_menu.go index 4f920d7b..0335d0b9 100644 --- a/server/api/v1/sys_menu.go +++ b/server/api/v1/system/sys_menu.go @@ -1,17 +1,21 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type AuthorityMenuApi struct { +} + // @Tags AuthorityMenu // @Summary 获取用户动态路由 // @Security ApiKeyAuth @@ -19,12 +23,15 @@ import ( // @Param data body request.Empty true "空" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getMenu [post] -func GetMenu(c *gin.Context) { - if err, menus := service.GetMenuTree(getUserAuthorityId(c)); err != nil { +func (a *AuthorityMenuApi) GetMenu(c *gin.Context) { + if err, menus := menuService.GetMenuTree(utils.GetUserAuthorityId(c)); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c) + if menus == nil { + menus = []system.SysMenu{} + } + response.OkWithDetailed(systemRes.SysMenusResponse{Menus: menus}, "获取成功", c) } } @@ -35,12 +42,12 @@ func GetMenu(c *gin.Context) { // @Param data body request.Empty true "空" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getBaseMenuTree [post] -func GetBaseMenuTree(c *gin.Context) { - if err, menus := service.GetBaseMenuTree(); err != nil { +func (a *AuthorityMenuApi) GetBaseMenuTree(c *gin.Context) { + if err, menus := menuService.GetBaseMenuTree(); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.SysBaseMenusResponse{Menus: menus}, "获取成功", c) + response.OkWithDetailed(systemRes.SysBaseMenusResponse{Menus: menus}, "获取成功", c) } } @@ -49,17 +56,17 @@ func GetBaseMenuTree(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.AddMenuAuthorityInfo true "角色ID" +// @Param data body systemReq.AddMenuAuthorityInfo true "角色ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}" // @Router /menu/addMenuAuthority [post] -func AddMenuAuthority(c *gin.Context) { - var authorityMenu request.AddMenuAuthorityInfo +func (a *AuthorityMenuApi) AddMenuAuthority(c *gin.Context) { + var authorityMenu systemReq.AddMenuAuthorityInfo _ = c.ShouldBindJSON(&authorityMenu) if err := utils.Verify(authorityMenu, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.AddMenuAuthority(authorityMenu.Menus, authorityMenu.AuthorityId); err != nil { + if err := menuService.AddMenuAuthority(authorityMenu.Menus, authorityMenu.AuthorityId); err != nil { global.GVA_LOG.Error("添加失败!", zap.Any("err", err)) response.FailWithMessage("添加失败", c) } else { @@ -75,16 +82,16 @@ func AddMenuAuthority(c *gin.Context) { // @Param data body request.GetAuthorityId true "角色ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/GetMenuAuthority [post] -func GetMenuAuthority(c *gin.Context) { +func (a *AuthorityMenuApi) GetMenuAuthority(c *gin.Context) { var param request.GetAuthorityId _ = c.ShouldBindJSON(¶m) if err := utils.Verify(param, utils.AuthorityIdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, menus := service.GetMenuAuthority(¶m); err != nil { + if err, menus := menuService.GetMenuAuthority(¶m); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) - response.FailWithDetailed(response.SysMenusResponse{Menus: menus}, "获取失败", c) + response.FailWithDetailed(systemRes.SysMenusResponse{Menus: menus}, "获取失败", c) } else { response.OkWithDetailed(gin.H{"menus": menus}, "获取成功", c) } @@ -95,11 +102,11 @@ func GetMenuAuthority(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记" +// @Param data body system.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记" // @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}" // @Router /menu/addBaseMenu [post] -func AddBaseMenu(c *gin.Context) { - var menu model.SysBaseMenu +func (a *AuthorityMenuApi) AddBaseMenu(c *gin.Context) { + var menu system.SysBaseMenu _ = c.ShouldBindJSON(&menu) if err := utils.Verify(menu, utils.MenuVerify); err != nil { response.FailWithMessage(err.Error(), c) @@ -109,7 +116,7 @@ func AddBaseMenu(c *gin.Context) { response.FailWithMessage(err.Error(), c) return } - if err := service.AddBaseMenu(menu); err != nil { + if err := menuService.AddBaseMenu(menu); err != nil { global.GVA_LOG.Error("添加失败!", zap.Any("err", err)) response.FailWithMessage("添加失败", c) @@ -126,14 +133,14 @@ func AddBaseMenu(c *gin.Context) { // @Param data body request.GetById true "菜单id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /menu/deleteBaseMenu [post] -func DeleteBaseMenu(c *gin.Context) { +func (a *AuthorityMenuApi) DeleteBaseMenu(c *gin.Context) { var menu request.GetById _ = c.ShouldBindJSON(&menu) if err := utils.Verify(menu, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err := service.DeleteBaseMenu(menu.ID); err != nil { + if err := baseMenuService.DeleteBaseMenu(menu.ID); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -146,11 +153,11 @@ func DeleteBaseMenu(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记" +// @Param data body system.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /menu/updateBaseMenu [post] -func UpdateBaseMenu(c *gin.Context) { - var menu model.SysBaseMenu +func (a *AuthorityMenuApi) UpdateBaseMenu(c *gin.Context) { + var menu system.SysBaseMenu _ = c.ShouldBindJSON(&menu) if err := utils.Verify(menu, utils.MenuVerify); err != nil { response.FailWithMessage(err.Error(), c) @@ -160,7 +167,7 @@ func UpdateBaseMenu(c *gin.Context) { response.FailWithMessage(err.Error(), c) return } - if err := service.UpdateBaseMenu(menu); err != nil { + if err := baseMenuService.UpdateBaseMenu(menu); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { @@ -176,18 +183,18 @@ func UpdateBaseMenu(c *gin.Context) { // @Param data body request.GetById true "菜单id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getBaseMenuById [post] -func GetBaseMenuById(c *gin.Context) { +func (a *AuthorityMenuApi) GetBaseMenuById(c *gin.Context) { var idInfo request.GetById _ = c.ShouldBindJSON(&idInfo) if err := utils.Verify(idInfo, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, menu := service.GetBaseMenuById(idInfo.ID); err != nil { + if err, menu := baseMenuService.GetBaseMenuById(idInfo.ID); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.SysBaseMenuResponse{Menu: menu}, "获取成功", c) + response.OkWithDetailed(systemRes.SysBaseMenuResponse{Menu: menu}, "获取成功", c) } } @@ -199,14 +206,14 @@ func GetBaseMenuById(c *gin.Context) { // @Param data body request.PageInfo true "页码, 每页大小" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getMenuList [post] -func GetMenuList(c *gin.Context) { +func (a *AuthorityMenuApi) GetMenuList(c *gin.Context) { var pageInfo request.PageInfo _ = c.ShouldBindJSON(&pageInfo) if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, menuList, total := service.GetInfoList(); err != nil { + if err, menuList, total := menuService.GetInfoList(); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { diff --git a/server/api/v1/sys_operation_record.go b/server/api/v1/system/sys_operation_record.go similarity index 66% rename from server/api/v1/sys_operation_record.go rename to server/api/v1/system/sys_operation_record.go index d3d5745e..1fb1bdce 100644 --- a/server/api/v1/sys_operation_record.go +++ b/server/api/v1/system/sys_operation_record.go @@ -1,28 +1,31 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type OperationRecordApi struct { +} + // @Tags SysOperationRecord // @Summary 创建SysOperationRecord // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysOperationRecord true "创建SysOperationRecord" +// @Param data body system.SysOperationRecord true "创建SysOperationRecord" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysOperationRecord/createSysOperationRecord [post] -func CreateSysOperationRecord(c *gin.Context) { - var sysOperationRecord model.SysOperationRecord +func (s *OperationRecordApi) CreateSysOperationRecord(c *gin.Context) { + var sysOperationRecord system.SysOperationRecord _ = c.ShouldBindJSON(&sysOperationRecord) - if err := service.CreateSysOperationRecord(sysOperationRecord); err != nil { + if err := operationRecordService.CreateSysOperationRecord(sysOperationRecord); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -35,13 +38,13 @@ func CreateSysOperationRecord(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysOperationRecord true "SysOperationRecord模型" +// @Param data body system.SysOperationRecord true "SysOperationRecord模型" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysOperationRecord/deleteSysOperationRecord [delete] -func DeleteSysOperationRecord(c *gin.Context) { - var sysOperationRecord model.SysOperationRecord +func (s *OperationRecordApi) DeleteSysOperationRecord(c *gin.Context) { + var sysOperationRecord system.SysOperationRecord _ = c.ShouldBindJSON(&sysOperationRecord) - if err := service.DeleteSysOperationRecord(sysOperationRecord); err != nil { + if err := operationRecordService.DeleteSysOperationRecord(sysOperationRecord); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -57,10 +60,10 @@ func DeleteSysOperationRecord(c *gin.Context) { // @Param data body request.IdsReq true "批量删除SysOperationRecord" // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}" // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete] -func DeleteSysOperationRecordByIds(c *gin.Context) { +func (s *OperationRecordApi) DeleteSysOperationRecordByIds(c *gin.Context) { var IDS request.IdsReq _ = c.ShouldBindJSON(&IDS) - if err := service.DeleteSysOperationRecordByIds(IDS); err != nil { + if err := operationRecordService.DeleteSysOperationRecordByIds(IDS); err != nil { global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err)) response.FailWithMessage("批量删除失败", c) } else { @@ -73,17 +76,17 @@ func DeleteSysOperationRecordByIds(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysOperationRecord true "Id" +// @Param data query system.SysOperationRecord true "Id" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /sysOperationRecord/findSysOperationRecord [get] -func FindSysOperationRecord(c *gin.Context) { - var sysOperationRecord model.SysOperationRecord +func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) { + var sysOperationRecord system.SysOperationRecord _ = c.ShouldBindQuery(&sysOperationRecord) if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID); err != nil { + if err, resysOperationRecord := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { @@ -96,13 +99,13 @@ func FindSysOperationRecord(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件" +// @Param data query request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysOperationRecord/getSysOperationRecordList [get] -func GetSysOperationRecordList(c *gin.Context) { - var pageInfo request.SysOperationRecordSearch +func (s *OperationRecordApi) GetSysOperationRecordList(c *gin.Context) { + var pageInfo systemReq.SysOperationRecordSearch _ = c.ShouldBindQuery(&pageInfo) - if err, list, total := service.GetSysOperationRecordInfoList(pageInfo); err != nil { + if err, list, total := operationRecordService.GetSysOperationRecordInfoList(pageInfo); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { diff --git a/server/api/v1/sys_system.go b/server/api/v1/system/sys_system.go similarity index 67% rename from server/api/v1/sys_system.go rename to server/api/v1/system/sys_system.go index b18fe759..a022639a 100644 --- a/server/api/v1/sys_system.go +++ b/server/api/v1/system/sys_system.go @@ -1,28 +1,31 @@ -package v1 +package system import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type SystemApi struct { +} + // @Tags System // @Summary 获取配置文件内容 // @Security ApiKeyAuth // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /system/getSystemConfig [post] -func GetSystemConfig(c *gin.Context) { - if err, config := service.GetSystemConfig(); err != nil { +func (s *SystemApi) GetSystemConfig(c *gin.Context) { + if err, config := systemConfigService.GetSystemConfig(); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { - response.OkWithDetailed(response.SysConfigResponse{Config: config}, "获取成功", c) + response.OkWithDetailed(systemRes.SysConfigResponse{Config: config}, "获取成功", c) } } @@ -30,13 +33,13 @@ func GetSystemConfig(c *gin.Context) { // @Summary 设置配置文件内容 // @Security ApiKeyAuth // @Produce application/json -// @Param data body model.System true "设置配置文件内容" +// @Param data body system.System true "设置配置文件内容" // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /system/setSystemConfig [post] -func SetSystemConfig(c *gin.Context) { - var sys model.System +func (s *SystemApi) SetSystemConfig(c *gin.Context) { + var sys system.System _ = c.ShouldBindJSON(&sys) - if err := service.SetSystemConfig(sys); err != nil { + if err := systemConfigService.SetSystemConfig(sys); err != nil { global.GVA_LOG.Error("设置失败!", zap.Any("err", err)) response.FailWithMessage("设置失败", c) } else { @@ -50,15 +53,14 @@ func SetSystemConfig(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"code":0,"data":{},"msg":"重启系统成功"}" // @Router /system/reloadSystem [post] -func ReloadSystem(c *gin.Context) { +func (s *SystemApi) ReloadSystem(c *gin.Context) { err := utils.Reload() if err != nil { global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err)) response.FailWithMessage("重启系统失败", c) - return + } else { + response.OkWithMessage("重启系统成功", c) } - response.OkWithMessage("重启系统成功", c) - return } // @Tags System @@ -67,13 +69,11 @@ func ReloadSystem(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /system/getServerInfo [post] -func GetServerInfo(c *gin.Context) { - if server, err := service.GetServerInfo(); err != nil { +func (s *SystemApi) GetServerInfo(c *gin.Context) { + if server, err := systemConfigService.GetServerInfo(); err != nil { global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) - return } else { response.OkWithDetailed(gin.H{"server": server}, "获取成功", c) } - } diff --git a/server/api/v1/sys_user.go b/server/api/v1/system/sys_user.go similarity index 50% rename from server/api/v1/sys_user.go rename to server/api/v1/system/sys_user.go index 7b5dd6a8..29d1262c 100644 --- a/server/api/v1/sys_user.go +++ b/server/api/v1/system/sys_user.go @@ -1,41 +1,43 @@ -package v1 +package system import ( "gin-vue-admin/global" "gin-vue-admin/middleware" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" - "gin-vue-admin/service" + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + systemReq "gin-vue-admin/model/system/request" + systemRes "gin-vue-admin/model/system/response" "gin-vue-admin/utils" + "strconv" "time" "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" - "github.com/go-redis/redis" + "github.com/go-redis/redis/v8" "go.uber.org/zap" ) // @Tags Base // @Summary 用户登录 // @Produce application/json -// @Param data body request.Login true "用户名, 密码, 验证码" +// @Param data body systemReq.Login true "用户名, 密码, 验证码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /base/login [post] -func Login(c *gin.Context) { - var L request.Login - _ = c.ShouldBindJSON(&L) - if err := utils.Verify(L, utils.LoginVerify); err != nil { +func (b *BaseApi) Login(c *gin.Context) { + var l systemReq.Login + _ = c.ShouldBindJSON(&l) + if err := utils.Verify(l, utils.LoginVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if store.Verify(L.CaptchaId, L.Captcha, true) { - U := &model.SysUser{Username: L.Username, Password: L.Password} - if err, user := service.Login(U); err != nil { - global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误", zap.Any("err", err)) + if store.Verify(l.CaptchaId, l.Captcha, true) { + u := &system.SysUser{Username: l.Username, Password: l.Password} + if err, user := userService.Login(u); err != nil { + global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Any("err", err)) response.FailWithMessage("用户名不存在或者密码错误", c) } else { - tokenNext(c, *user) + b.tokenNext(c, *user) } } else { response.FailWithMessage("验证码错误", c) @@ -43,9 +45,9 @@ func Login(c *gin.Context) { } // 登录以后签发jwt -func tokenNext(c *gin.Context, user model.SysUser) { +func (b *BaseApi) tokenNext(c *gin.Context, user system.SysUser) { j := &middleware.JWT{SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey)} // 唯一签名 - claims := request.CustomClaims{ + claims := systemReq.CustomClaims{ UUID: user.UUID, ID: user.ID, NickName: user.NickName, @@ -60,44 +62,44 @@ func tokenNext(c *gin.Context, user model.SysUser) { } token, err := j.CreateToken(claims) if err != nil { - global.GVA_LOG.Error("获取token失败", zap.Any("err", err)) + global.GVA_LOG.Error("获取token失败!", zap.Any("err", err)) response.FailWithMessage("获取token失败", c) return } if !global.GVA_CONFIG.System.UseMultipoint { - response.OkWithDetailed(response.LoginResponse{ + response.OkWithDetailed(systemRes.LoginResponse{ User: user, Token: token, ExpiresAt: claims.StandardClaims.ExpiresAt * 1000, }, "登录成功", c) return } - if err, jwtStr := service.GetRedisJWT(user.Username); err == redis.Nil { - if err := service.SetRedisJWT(token, user.Username); err != nil { - global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err)) + if err, jwtStr := jwtService.GetRedisJWT(user.Username); err == redis.Nil { + if err := jwtService.SetRedisJWT(token, user.Username); err != nil { + global.GVA_LOG.Error("设置登录状态失败!", zap.Any("err", err)) response.FailWithMessage("设置登录状态失败", c) return } - response.OkWithDetailed(response.LoginResponse{ + response.OkWithDetailed(systemRes.LoginResponse{ User: user, Token: token, ExpiresAt: claims.StandardClaims.ExpiresAt * 1000, }, "登录成功", c) } else if err != nil { - global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err)) + global.GVA_LOG.Error("设置登录状态失败!", zap.Any("err", err)) response.FailWithMessage("设置登录状态失败", c) } else { - var blackJWT model.JwtBlacklist + var blackJWT system.JwtBlacklist blackJWT.Jwt = jwtStr - if err := service.JsonInBlacklist(blackJWT); err != nil { + if err := jwtService.JsonInBlacklist(blackJWT); err != nil { response.FailWithMessage("jwt作废失败", c) return } - if err := service.SetRedisJWT(token, user.Username); err != nil { + if err := jwtService.SetRedisJWT(token, user.Username); err != nil { response.FailWithMessage("设置登录状态失败", c) return } - response.OkWithDetailed(response.LoginResponse{ + response.OkWithDetailed(systemRes.LoginResponse{ User: user, Token: token, ExpiresAt: claims.StandardClaims.ExpiresAt * 1000, @@ -108,23 +110,29 @@ func tokenNext(c *gin.Context, user model.SysUser) { // @Tags SysUser // @Summary 用户注册账号 // @Produce application/json -// @Param data body model.SysUser true "用户名, 昵称, 密码, 角色ID" +// @Param data body systemReq.Register true "用户名, 昵称, 密码, 角色ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}" // @Router /user/register [post] -func Register(c *gin.Context) { - var R request.Register - _ = c.ShouldBindJSON(&R) - if err := utils.Verify(R, utils.RegisterVerify); err != nil { +func (b *BaseApi) Register(c *gin.Context) { + var r systemReq.Register + _ = c.ShouldBindJSON(&r) + if err := utils.Verify(r, utils.RegisterVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - user := &model.SysUser{Username: R.Username, NickName: R.NickName, Password: R.Password, HeaderImg: R.HeaderImg, AuthorityId: R.AuthorityId} - err, userReturn := service.Register(*user) + var authorities []system.SysAuthority + for _, v := range r.AuthorityIds { + authorities = append(authorities, system.SysAuthority{ + AuthorityId: v, + }) + } + user := &system.SysUser{Username: r.Username, NickName: r.NickName, Password: r.Password, HeaderImg: r.HeaderImg, AuthorityId: r.AuthorityId, Authorities: authorities} + err, userReturn := userService.Register(*user) if err != nil { - global.GVA_LOG.Error("注册失败", zap.Any("err", err)) - response.FailWithDetailed(response.SysUserResponse{User: userReturn}, "注册失败", c) + global.GVA_LOG.Error("注册失败!", zap.Any("err", err)) + response.FailWithDetailed(systemRes.SysUserResponse{User: userReturn}, "注册失败", c) } else { - response.OkWithDetailed(response.SysUserResponse{User: userReturn}, "注册成功", c) + response.OkWithDetailed(systemRes.SysUserResponse{User: userReturn}, "注册成功", c) } } @@ -132,19 +140,19 @@ func Register(c *gin.Context) { // @Summary 用户修改密码 // @Security ApiKeyAuth // @Produce application/json -// @Param data body request.ChangePasswordStruct true "用户名, 原密码, 新密码" +// @Param data body systemReq.ChangePasswordStruct true "用户名, 原密码, 新密码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" -// @Router /user/changePassword [put] -func ChangePassword(c *gin.Context) { - var user request.ChangePasswordStruct +// @Router /user/changePassword [post] +func (b *BaseApi) ChangePassword(c *gin.Context) { + var user systemReq.ChangePasswordStruct _ = c.ShouldBindJSON(&user) if err := utils.Verify(user, utils.ChangePasswordVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - U := &model.SysUser{Username: user.Username, Password: user.Password} - if err, _ := service.ChangePassword(U, user.NewPassword); err != nil { - global.GVA_LOG.Error("修改失败", zap.Any("err", err)) + u := &system.SysUser{Username: user.Username, Password: user.Password} + if err, _ := userService.ChangePassword(u, user.NewPassword); err != nil { + global.GVA_LOG.Error("修改失败!", zap.Any("err", err)) response.FailWithMessage("修改失败,原密码与当前账户不符", c) } else { response.OkWithMessage("修改成功", c) @@ -159,15 +167,15 @@ func ChangePassword(c *gin.Context) { // @Param data body request.PageInfo true "页码, 每页大小" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /user/getUserList [post] -func GetUserList(c *gin.Context) { +func (b *BaseApi) GetUserList(c *gin.Context) { var pageInfo request.PageInfo _ = c.ShouldBindJSON(&pageInfo) if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, list, total := service.GetUserInfoList(pageInfo); err != nil { - global.GVA_LOG.Error("获取失败", zap.Any("err", err)) + if err, list, total := userService.GetUserInfoList(pageInfo); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { response.OkWithDetailed(response.PageResult{ @@ -180,22 +188,54 @@ func GetUserList(c *gin.Context) { } // @Tags SysUser -// @Summary 设置用户权限 +// @Summary 更改用户权限 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.SetUserAuth true "用户UUID, 角色ID" +// @Param data body systemReq.SetUserAuth true "用户UUID, 角色ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/setUserAuthority [post] -func SetUserAuthority(c *gin.Context) { - var sua request.SetUserAuth +func (b *BaseApi) SetUserAuthority(c *gin.Context) { + var sua systemReq.SetUserAuth _ = c.ShouldBindJSON(&sua) if UserVerifyErr := utils.Verify(sua, utils.SetUserAuthorityVerify); UserVerifyErr != nil { response.FailWithMessage(UserVerifyErr.Error(), c) return } - if err := service.SetUserAuthority(sua.UUID, sua.AuthorityId); err != nil { - global.GVA_LOG.Error("修改失败", zap.Any("err", err)) + userID := utils.GetUserID(c) + uuid := utils.GetUserUuid(c) + if err := userService.SetUserAuthority(userID, uuid, sua.AuthorityId); err != nil { + global.GVA_LOG.Error("修改失败!", zap.Any("err", err)) + response.FailWithMessage(err.Error(), c) + } else { + claims := utils.GetUserInfo(c) + j := &middleware.JWT{SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey)} // 唯一签名 + claims.AuthorityId = sua.AuthorityId + if token, err := j.CreateToken(*claims); err != nil { + global.GVA_LOG.Error("修改失败!", zap.Any("err", err)) + response.FailWithMessage(err.Error(), c) + } else { + c.Header("new-token", token) + c.Header("new-expires-at", strconv.FormatInt(claims.ExpiresAt, 10)) + response.OkWithMessage("修改成功", c) + } + + } +} + +// @Tags SysUser +// @Summary 设置用户权限 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body systemReq.SetUserAuthorities true "用户UUID, 角色ID" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" +// @Router /user/setUserAuthorities [post] +func (b *BaseApi) SetUserAuthorities(c *gin.Context) { + var sua systemReq.SetUserAuthorities + _ = c.ShouldBindJSON(&sua) + if err := userService.SetUserAuthorities(sua.ID, sua.AuthorityIds); err != nil { + global.GVA_LOG.Error("修改失败!", zap.Any("err", err)) response.FailWithMessage("修改失败", c) } else { response.OkWithMessage("修改成功", c) @@ -210,19 +250,19 @@ func SetUserAuthority(c *gin.Context) { // @Param data body request.GetById true "用户ID" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /user/deleteUser [delete] -func DeleteUser(c *gin.Context) { +func (b *BaseApi) DeleteUser(c *gin.Context) { var reqId request.GetById _ = c.ShouldBindJSON(&reqId) if err := utils.Verify(reqId, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - jwtId := getUserID(c) + jwtId := utils.GetUserID(c) if jwtId == uint(reqId.ID) { response.FailWithMessage("删除失败, 自杀失败", c) return } - if err := service.DeleteUser(reqId.ID); err != nil { + if err := userService.DeleteUser(reqId.ID); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -235,53 +275,37 @@ func DeleteUser(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.SysUser true "ID, 用户名, 昵称, 头像链接" +// @Param data body system.SysUser true "ID, 用户名, 昵称, 头像链接" // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /user/setUserInfo [put] -func SetUserInfo(c *gin.Context) { - var user model.SysUser +func (b *BaseApi) SetUserInfo(c *gin.Context) { + var user system.SysUser _ = c.ShouldBindJSON(&user) if err := utils.Verify(user, utils.IdVerify); err != nil { response.FailWithMessage(err.Error(), c) return } - if err, ReqUser := service.SetUserInfo(user); err != nil { - global.GVA_LOG.Error("设置失败", zap.Any("err", err)) + if err, ReqUser := userService.SetUserInfo(user); err != nil { + global.GVA_LOG.Error("设置失败!", zap.Any("err", err)) response.FailWithMessage("设置失败", c) } else { response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "设置成功", c) } } -// 从Gin的Context中获取从jwt解析出来的用户ID -func getUserID(c *gin.Context) uint { - if claims, exists := c.Get("claims"); !exists { - global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件") - return 0 +// @Tags SysUser +// @Summary 获取用户信息 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /user/getUserInfo [get] +func (b *BaseApi) GetUserInfo(c *gin.Context) { + uuid := utils.GetUserUuid(c) + if err, ReqUser := userService.GetUserInfo(uuid); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) } else { - waitUse := claims.(*request.CustomClaims) - return waitUse.ID - } -} - -// 从Gin的Context中获取从jwt解析出来的用户UUID -func getUserUuid(c *gin.Context) string { - if claims, exists := c.Get("claims"); !exists { - global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件") - return "" - } else { - waitUse := claims.(*request.CustomClaims) - return waitUse.UUID.String() - } -} - -// 从Gin的Context中获取从jwt解析出来的用户角色id -func getUserAuthorityId(c *gin.Context) string { - if claims, exists := c.Get("claims"); !exists { - global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件") - return "" - } else { - waitUse := claims.(*request.CustomClaims) - return waitUse.AuthorityId + response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "获取成功", c) } } diff --git a/server/config.docker.yaml b/server/config.docker.yaml new file mode 100644 index 00000000..5554d4a2 --- /dev/null +++ b/server/config.docker.yaml @@ -0,0 +1,132 @@ +# Gin-Vue-Admin Global Configuration + +# jwt configuration +jwt: + signing-key: 'qmPlus' + expires-time: 604800 + buffer-time: 86400 + +# zap logger configuration +zap: + level: 'info' + format: 'console' + prefix: '[GIN-VUE-ADMIN]' + director: 'log' + link-name: 'latest_log' + show-line: true + encode-level: 'LowercaseColorLevelEncoder' + stacktrace-key: 'stacktrace' + log-in-console: true + +# redis configuration +redis: + db: 0 + addr: '177.7.0.14:6379' + password: '' + +# email configuration +email: + to: 'xxx@qq.com' + port: 465 + from: 'xxx@163.com' + host: 'smtp.163.com' + is-ssl: true + secret: 'xxx' + nickname: 'test' + +# casbin configuration +casbin: + model-path: './resource/rbac_model.conf' + +# system configuration +system: + env: 'public' # Change to "develop" to skip authentication for development mode + addr: 8888 + db-type: 'mysql' + oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置 + use-multipoint: false + +# captcha configuration +captcha: + key-long: 6 + img-width: 240 + img-height: 80 + +# mysql connect configuration +mysql: + path: '' + config: '' + db-name: '' + username: '' + password: '' + max-idle-conns: 10 + max-open-conns: 100 + log-mode: "" + log-zap: false + +# local configuration +local: + path: 'uploads/file' + +# autocode configuration +autocode: + transfer-restart: true + root: "" + server: /server + server-api: /api/v1 + server-initialize: /initialize + server-model: /model + server-request: /model/request/ + server-router: /router + server-service: /service + web: /web/src + web-api: /api + web-flow: /view + web-form: /view + web-table: /view + +# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址) +qiniu: + zone: 'ZoneHuaDong' + bucket: '' + img-path: '' + use-https: false + access-key: '' + secret-key: '' + use-cdn-domains: false + + +# aliyun oss configuration +aliyun-oss: + endpoint: 'yourEndpoint' + access-key-id: 'yourAccessKeyId' + access-key-secret: 'yourAccessKeySecret' + bucket-name: 'yourBucketName' + bucket-url: 'yourBucketUrl' + +# tencent cos configuration +tencent-cos: + bucket: 'xxxxx-10005608' + region: 'ap-shanghai' + secret-id: 'xxxxxxxx' + secret-key: 'xxxxxxxx' + base-url: 'https://gin.vue.admin' + path-prefix: 'gin-vue-admin' + +# excel configuration +excel: + dir: './resource/excel/' + + +# timer task db clear table +Timer: + start: true + spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron/v3 + detail: [ + # tableName: 需要清理的表名 + # compareField: 需要比较时间的字段 + # interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数 + # 2160h = 24 * 30 * 3 -> 三个月 + { tableName: "sys_operation_records" , compareField: "created_at", interval: "2160h" }, + #{ tableName: "log2" , compareField: "created_at", interval: "2160h" } + ] diff --git a/server/config.yaml b/server/config.yaml index fb77272f..fa0c233d 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -53,6 +53,7 @@ captcha: img-height: 80 # mysql connect configuration +# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://www.gin-vue-admin.com/docs/first) mysql: path: '' config: '' @@ -73,12 +74,12 @@ autocode: transfer-restart: true root: "" server: /server - server-api: /api/v1 + server-api: /api/v1/autocode server-initialize: /initialize - server-model: /model - server-request: /model/request/ - server-router: /router - server-service: /service + server-model: /model/autocode + server-request: /model/autocode/request/ + server-router: /router/autocode + server-service: /service/autocode web: /web/src web-api: /api web-flow: /view @@ -103,6 +104,7 @@ aliyun-oss: access-key-secret: 'yourAccessKeySecret' bucket-name: 'yourBucketName' bucket-url: 'yourBucketUrl' + base-path: 'yourBasePath' # tencent cos configuration tencent-cos: @@ -120,7 +122,8 @@ excel: # timer task db clear table Timer: - spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron?utm_source=godoc + start: true + spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron/v3 detail: [ # tableName: 需要清理的表名 # compareField: 需要比较时间的字段 diff --git a/server/config/gorm.go b/server/config/gorm.go index 2524b190..ae6c7384 100644 --- a/server/config/gorm.go +++ b/server/config/gorm.go @@ -8,8 +8,8 @@ type Mysql struct { Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数 MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 - LogMode bool `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 - LogZap string `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` + LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 + LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` // 是否通过zap写入日志文件 } func (m *Mysql) Dsn() string { diff --git a/server/config/oss.go b/server/config/oss.go index a78420af..37957ddf 100644 --- a/server/config/oss.go +++ b/server/config/oss.go @@ -20,6 +20,7 @@ type AliyunOSS struct { AccessKeySecret string `mapstructure:"access-key-secret" json:"accessKeySecret" yaml:"access-key-secret"` BucketName string `mapstructure:"bucket-name" json:"bucketName" yaml:"bucket-name"` BucketUrl string `mapstructure:"bucket-url" json:"bucketUrl" yaml:"bucket-url"` + BasePath string `mapstructure:"base-path" json:"basePath" yaml:"base-path"` } type TencentCOS struct { Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` diff --git a/server/core/server.go b/server/core/server.go index 573d32f1..e6b8c4cb 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -29,7 +29,7 @@ func RunWindowsServer() { fmt.Printf(` 欢迎使用 Gin-Vue-Admin - 当前版本:V2.4.1 + 当前版本:V2.4.4 加群方式:微信号:shouzi_1994 QQ群:622360840 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html 默认前端文件运行地址:http://127.0.0.1:8080 diff --git a/server/docs/docs.go b/server/docs/docs.go index 07296df7..851b7f2d 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -1,6 +1,5 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT -// This file was generated by swaggo/swag at -// 2021-05-14 11:28:23.4731221 +0800 CST m=+1.258292701 +// This file was generated by swaggo/swag package docs @@ -25,6 +24,108 @@ var doc = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/SimpleUploaderApi/checkFileMd5": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "断点续传插件版示例", + "parameters": [ + { + "type": "string", + "description": "md5", + "name": "md5", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/SimpleUploaderApi/mergeFileMd5": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "合并文件", + "parameters": [ + { + "type": "string", + "description": "md5", + "name": "md5", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"合并成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/SimpleUploaderApi/upload": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "断点续传插件版示例", + "parameters": [ + { + "type": "file", + "description": "断点续传插件版示例", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"切片创建成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/api/createApi": { "post": { "security": [ @@ -49,7 +150,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -87,7 +188,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -266,7 +367,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -342,7 +443,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -380,7 +481,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -456,7 +557,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -494,7 +595,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -532,7 +633,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.AutoCodeStruct" + "$ref": "#/definitions/system.AutoCodeStruct" } } ], @@ -546,6 +647,44 @@ var doc = `{ } } }, + "/autoCode/delSysHistory": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "删除回滚记录", + "parameters": [ + { + "description": "删除回滚记录", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/autoCode/getColumn": { "get": { "security": [ @@ -600,6 +739,82 @@ var doc = `{ } } }, + "/autoCode/getMeta": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "回滚", + "parameters": [ + { + "description": "获取meta信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCode/getSysHistory": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "查询回滚记录", + "parameters": [ + { + "description": "查询回滚记录", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SysAutoHistory" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/autoCode/getTables": { "get": { "security": [ @@ -651,7 +866,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.AutoCodeStruct" + "$ref": "#/definitions/system.AutoCodeStruct" } } ], @@ -665,6 +880,276 @@ var doc = `{ } } }, + "/autoCode/rollback": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "回滚", + "parameters": [ + { + "description": "回滚自动生成代码", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"回滚成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/createAutoCodeExample": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "创建AutoCodeExample", + "parameters": [ + { + "description": "AutoCodeExample模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"创建成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/deleteAutoCodeExample": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "删除AutoCodeExample", + "parameters": [ + { + "description": "AutoCodeExample模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/findAutoCodeExample": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "用id查询AutoCodeExample", + "parameters": [ + { + "type": "string", + "description": "展示值", + "name": "autoCodeExampleField", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/getAutoCodeExampleList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "分页获取AutoCodeExample列表", + "parameters": [ + { + "type": "string", + "description": "展示值", + "name": "autoCodeExampleField", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/updateAutoCodeExample": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "更新AutoCodeExample", + "parameters": [ + { + "description": "更新AutoCodeExample", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/base/captcha": { "post": { "security": [ @@ -817,13 +1302,46 @@ var doc = `{ "summary": "获取单一客户信息", "parameters": [ { - "description": "客户ID", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.ExaCustomer" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "客户名", + "name": "customerName", + "in": "query" + }, + { + "type": "string", + "description": "客户手机号", + "name": "customerPhoneData", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "管理角色ID", + "name": "sysUserAuthorityID", + "in": "query" + }, + { + "type": "integer", + "description": "管理ID", + "name": "sysUserId", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -858,7 +1376,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -894,7 +1412,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -930,7 +1448,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -963,13 +1481,16 @@ var doc = `{ "summary": "分页获取权限客户列表", "parameters": [ { - "description": "页码, 每页大小", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.PageInfo" - } + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" } ], "responses": { @@ -1033,9 +1554,7 @@ var doc = `{ } ], "responses": { - "200": { - "description": "" - } + "200": {} } } }, @@ -1063,14 +1582,12 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExcelInfo" + "$ref": "#/definitions/example.ExcelInfo" } } ], "responses": { - "200": { - "description": "" - } + "200": {} } } }, @@ -1191,7 +1708,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaFileUploadAndDownload" + "$ref": "#/definitions/example.ExaFileUploadAndDownload" } } ], @@ -1489,7 +2006,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } ], @@ -1749,7 +2266,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } ], @@ -1763,108 +2280,6 @@ var doc = `{ } } }, - "/simpleUploader/checkFileMd5": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "断点续传插件版示例", - "parameters": [ - { - "type": "string", - "description": "md5", - "name": "md5", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, - "/simpleUploader/mergeFileMd5": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "合并文件", - "parameters": [ - { - "type": "string", - "description": "md5", - "name": "md5", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"合并成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, - "/simpleUploader/upload": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "断点续传插件版示例", - "parameters": [ - { - "type": "file", - "description": "断点续传插件版示例", - "name": "file", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"切片创建成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, "/sysDictionary/createSysDictionary": { "post": { "security": [ @@ -1889,7 +2304,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -1927,7 +2342,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -1960,13 +2375,46 @@ var doc = `{ "summary": "用id查询SysDictionary", "parameters": [ { - "description": "ID或字典英名", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysDictionary" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "描述", + "name": "desc", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "字典名(中)", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "description": "状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "字典名(英)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -1998,13 +2446,58 @@ var doc = `{ "summary": "分页获取SysDictionary列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysDictionarySearch" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "描述", + "name": "desc", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "字典名(中)", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "boolean", + "description": "状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "字典名(英)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -2041,7 +2534,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -2079,7 +2572,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2117,7 +2610,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2150,13 +2643,52 @@ var doc = `{ "summary": "用id查询SysDictionaryDetail", "parameters": [ { - "description": "用id查询SysDictionaryDetail", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "展示值", + "name": "label", + "in": "query" + }, + { + "type": "integer", + "description": "排序标记", + "name": "sort", + "in": "query" + }, + { + "type": "boolean", + "description": "启用状态", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "关联标记", + "name": "sysDictionaryID", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "字典值", + "name": "value", + "in": "query" } ], "responses": { @@ -2188,13 +2720,64 @@ var doc = `{ "summary": "分页获取SysDictionaryDetail列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysDictionaryDetailSearch" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "展示值", + "name": "label", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "description": "排序标记", + "name": "sort", + "in": "query" + }, + { + "type": "boolean", + "description": "启用状态", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "关联标记", + "name": "sysDictionaryID", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "字典值", + "name": "value", + "in": "query" } ], "responses": { @@ -2231,7 +2814,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2269,7 +2852,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysOperationRecord" + "$ref": "#/definitions/system.SysOperationRecord" } } ], @@ -2307,7 +2890,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysOperationRecord" + "$ref": "#/definitions/system.SysOperationRecord" } } ], @@ -2378,13 +2961,82 @@ var doc = `{ "summary": "用id查询SysOperationRecord", "parameters": [ { - "description": "Id", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysOperationRecord" - } + "type": "string", + "description": "代理", + "name": "agent", + "in": "query" + }, + { + "type": "string", + "description": "请求Body", + "name": "body", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "错误信息", + "name": "error_message", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "请求ip", + "name": "ip", + "in": "query" + }, + { + "type": "string", + "description": "延迟", + "name": "latency", + "in": "query" + }, + { + "type": "string", + "description": "请求方法", + "name": "method", + "in": "query" + }, + { + "type": "string", + "description": "请求路径", + "name": "path", + "in": "query" + }, + { + "type": "string", + "description": "响应Body", + "name": "resp", + "in": "query" + }, + { + "type": "integer", + "description": "请求状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "用户id", + "name": "user_id", + "in": "query" } ], "responses": { @@ -2416,13 +3068,94 @@ var doc = `{ "summary": "分页获取SysOperationRecord列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysOperationRecordSearch" - } + "type": "string", + "description": "代理", + "name": "agent", + "in": "query" + }, + { + "type": "string", + "description": "请求Body", + "name": "body", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "错误信息", + "name": "error_message", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "请求ip", + "name": "ip", + "in": "query" + }, + { + "type": "string", + "description": "延迟", + "name": "latency", + "in": "query" + }, + { + "type": "string", + "description": "请求方法", + "name": "method", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "请求路径", + "name": "path", + "in": "query" + }, + { + "type": "string", + "description": "响应Body", + "name": "resp", + "in": "query" + }, + { + "type": "integer", + "description": "请求状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "用户id", + "name": "user_id", + "in": "query" } ], "responses": { @@ -2528,7 +3261,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.System" + "$ref": "#/definitions/system.System" } } ], @@ -2543,7 +3276,7 @@ var doc = `{ } }, "/user/changePassword": { - "put": { + "post": { "security": [ { "ApiKeyAuth": [] @@ -2615,6 +3348,33 @@ var doc = `{ } } }, + "/user/getUserInfo": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "获取用户信息", + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/user/getUserList": { "post": { "security": [ @@ -2669,7 +3429,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/request.Register" } } ], @@ -2683,6 +3443,44 @@ var doc = `{ } } }, + "/user/setUserAuthorities": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "设置用户权限", + "parameters": [ + { + "description": "用户UUID, 角色ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SetUserAuthorities" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/user/setUserAuthority": { "post": { "security": [ @@ -2699,7 +3497,7 @@ var doc = `{ "tags": [ "SysUser" ], - "summary": "设置用户权限", + "summary": "更改用户权限", "parameters": [ { "description": "用户UUID, 角色ID", @@ -2745,7 +3543,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" } } ], @@ -2761,6 +3559,27 @@ var doc = `{ } }, "definitions": { + "autocode.AutoCodeExample": { + "type": "object", + "properties": { + "autoCodeExampleField": { + "description": "展示值", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, "config.AliyunOSS": { "type": "object", "properties": { @@ -2770,6 +3589,9 @@ var doc = `{ "accessKeySecret": { "type": "string" }, + "basePath": { + "type": "string" + }, "bucketName": { "type": "string" }, @@ -2808,6 +3630,9 @@ var doc = `{ "serverService": { "type": "string" }, + "transferRestart": { + "type": "boolean" + }, "web": { "type": "string" }, @@ -2948,10 +3773,11 @@ var doc = `{ }, "logMode": { "description": "是否开启Gorm全局日志", - "type": "boolean" + "type": "string" }, "logZap": { - "type": "string" + "description": "是否通过zap写入日志文件", + "type": "boolean" }, "maxIdleConns": { "description": "空闲中的最大连接数", @@ -3186,46 +4012,7 @@ var doc = `{ } } }, - "model.AutoCodeStruct": { - "type": "object", - "properties": { - "abbreviation": { - "description": "Struct简称", - "type": "string" - }, - "autoCreateApiToSql": { - "description": "是否自动创建api", - "type": "boolean" - }, - "autoMoveFile": { - "description": "是否自动移动文件", - "type": "boolean" - }, - "description": { - "description": "Struct中文名称", - "type": "string" - }, - "fields": { - "type": "array", - "items": { - "$ref": "#/definitions/model.Field" - } - }, - "packageName": { - "description": "文件名称", - "type": "string" - }, - "structName": { - "description": "Struct名称", - "type": "string" - }, - "tableName": { - "description": "表名", - "type": "string" - } - } - }, - "model.ExaCustomer": { + "example.ExaCustomer": { "type": "object", "properties": { "createdAt": { @@ -3246,7 +4033,7 @@ var doc = `{ }, "sysUser": { "description": "管理详情", - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" }, "sysUserAuthorityID": { "description": "管理角色ID", @@ -3262,7 +4049,7 @@ var doc = `{ } } }, - "model.ExaFileUploadAndDownload": { + "example.ExaFileUploadAndDownload": { "type": "object", "properties": { "createdAt": { @@ -3295,7 +4082,7 @@ var doc = `{ } } }, - "model.ExcelInfo": { + "example.ExcelInfo": { "type": "object", "properties": { "fileName": { @@ -3305,434 +4092,11 @@ var doc = `{ "infoList": { "type": "array", "items": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } } }, - "model.Field": { - "type": "object", - "properties": { - "columnName": { - "description": "数据库字段", - "type": "string" - }, - "comment": { - "description": "数据库字段描述", - "type": "string" - }, - "dataType": { - "description": "数据库字段类型", - "type": "string" - }, - "dataTypeLong": { - "description": "数据库字段长度", - "type": "string" - }, - "dictType": { - "description": "字典", - "type": "string" - }, - "fieldDesc": { - "description": "中文名", - "type": "string" - }, - "fieldJson": { - "description": "FieldJson", - "type": "string" - }, - "fieldName": { - "description": "Field名", - "type": "string" - }, - "fieldSearchType": { - "description": "搜索条件", - "type": "string" - }, - "fieldType": { - "description": "Field数据类型", - "type": "string" - } - } - }, - "model.SysApi": { - "type": "object", - "properties": { - "apiGroup": { - "description": "api组", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "description": { - "description": "api中文描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "method": { - "description": "方法:创建POST(默认)|查看GET|更新PUT|删除DELETE", - "type": "string" - }, - "path": { - "description": "api路径", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysAuthority": { - "type": "object", - "properties": { - "authorityId": { - "description": "角色ID", - "type": "string" - }, - "authorityName": { - "description": "角色名", - "type": "string" - }, - "children": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "dataAuthorityId": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "defaultRouter": { - "description": "默认菜单(默认dashboard)", - "type": "string" - }, - "deletedAt": { - "type": "string" - }, - "menus": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenu" - } - }, - "parentId": { - "description": "父角色ID", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysBaseMenu": { - "type": "object", - "properties": { - "authoritys": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "children": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenu" - } - }, - "closeTab": { - "description": "自动关闭tab", - "type": "boolean" - }, - "component": { - "description": "对应前端文件路径", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "defaultMenu": { - "description": "是否是基础路由(开发中)", - "type": "boolean" - }, - "hidden": { - "description": "是否在列表隐藏", - "type": "boolean" - }, - "icon": { - "description": "菜单图标", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "keepAlive": { - "description": "是否缓存", - "type": "boolean" - }, - "name": { - "description": "路由name", - "type": "string" - }, - "parameters": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenuParameter" - } - }, - "parentId": { - "description": "父菜单ID", - "type": "string" - }, - "path": { - "description": "路由path", - "type": "string" - }, - "sort": { - "description": "排序标记", - "type": "integer" - }, - "title": { - "description": "菜单名", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysBaseMenuParameter": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "key": { - "description": "地址栏携带参数的key", - "type": "string" - }, - "sysBaseMenuID": { - "type": "integer" - }, - "type": { - "description": "地址栏携带参数为params还是query", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "value": { - "description": "地址栏携带参数的值", - "type": "string" - } - } - }, - "model.SysDictionary": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "desc": { - "description": "描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "name": { - "description": "字典名(中)", - "type": "string" - }, - "status": { - "description": "状态", - "type": "boolean" - }, - "sysDictionaryDetails": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } - }, - "type": { - "description": "字典名(英)", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysDictionaryDetail": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "label": { - "description": "展示值", - "type": "string" - }, - "sort": { - "description": "排序标记", - "type": "integer" - }, - "status": { - "description": "启用状态", - "type": "boolean" - }, - "sysDictionaryID": { - "description": "关联标记", - "type": "integer" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "value": { - "description": "字典值", - "type": "integer" - } - } - }, - "model.SysOperationRecord": { - "type": "object", - "properties": { - "agent": { - "description": "代理", - "type": "string" - }, - "body": { - "description": "请求Body", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "error_message": { - "description": "错误信息", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "ip": { - "description": "请求ip", - "type": "string" - }, - "latency": { - "description": "延迟", - "type": "string" - }, - "method": { - "description": "请求方法", - "type": "string" - }, - "path": { - "description": "请求路径", - "type": "string" - }, - "resp": { - "description": "响应Body", - "type": "string" - }, - "status": { - "description": "请求状态", - "type": "integer" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "user": { - "$ref": "#/definitions/model.SysUser" - }, - "user_id": { - "description": "用户id", - "type": "integer" - } - } - }, - "model.SysUser": { - "type": "object", - "properties": { - "authority": { - "$ref": "#/definitions/model.SysAuthority" - }, - "authorityId": { - "description": "用户角色ID", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "headerImg": { - "description": "用户头像", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "nickName": { - "description": "用户昵称", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "userName": { - "description": "用户登录名", - "type": "string" - }, - "uuid": { - "description": "用户UUID", - "type": "string" - } - } - }, - "model.System": { - "type": "object", - "properties": { - "config": { - "$ref": "#/definitions/config.Server" - } - } - }, "request.AddMenuAuthorityInfo": { "type": "object", "properties": { @@ -3743,11 +4107,19 @@ var doc = `{ "menus": { "type": "array", "items": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } } }, + "request.AutoHistoryByID": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, "request.CasbinInReceive": { "type": "object", "properties": { @@ -3888,6 +4260,32 @@ var doc = `{ } } }, + "request.Register": { + "type": "object", + "properties": { + "authorityId": { + "type": "string" + }, + "authorityIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "headerImg": { + "type": "string" + }, + "nickName": { + "type": "string" + }, + "passWord": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, "request.SearchApiParams": { "type": "object", "properties": { @@ -3943,14 +4341,371 @@ var doc = `{ "authorityId": { "description": "角色ID", "type": "string" + } + } + }, + "request.SetUserAuthorities": { + "type": "object", + "properties": { + "authorityIds": { + "description": "角色ID", + "type": "array", + "items": { + "type": "string" + } }, - "uuid": { - "description": "用户UUID", + "id": { + "type": "integer" + } + } + }, + "request.SysAutoHistory": { + "type": "object", + "properties": { + "page": { + "description": "页码", + "type": "integer" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, + "response.SysAuthorityCopyResponse": { + "type": "object", + "properties": { + "authority": { + "$ref": "#/definitions/system.SysAuthority" + }, + "oldAuthorityId": { + "description": "旧角色ID", "type": "string" } } }, - "request.SysDictionaryDetailSearch": { + "system.AutoCodeStruct": { + "type": "object", + "properties": { + "abbreviation": { + "description": "Struct简称", + "type": "string" + }, + "autoCreateApiToSql": { + "description": "是否自动创建api", + "type": "boolean" + }, + "autoMoveFile": { + "description": "是否自动移动文件", + "type": "boolean" + }, + "description": { + "description": "Struct中文名称", + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/system.Field" + } + }, + "humpPackageName": { + "description": "go文件名称", + "type": "string" + }, + "packageName": { + "description": "文件名称", + "type": "string" + }, + "structName": { + "description": "Struct名称", + "type": "string" + }, + "tableName": { + "description": "表名", + "type": "string" + } + } + }, + "system.Field": { + "type": "object", + "properties": { + "columnName": { + "description": "数据库字段", + "type": "string" + }, + "comment": { + "description": "数据库字段描述", + "type": "string" + }, + "dataType": { + "description": "数据库字段类型", + "type": "string" + }, + "dataTypeLong": { + "description": "数据库字段长度", + "type": "string" + }, + "dictType": { + "description": "字典", + "type": "string" + }, + "fieldDesc": { + "description": "中文名", + "type": "string" + }, + "fieldJson": { + "description": "FieldJson", + "type": "string" + }, + "fieldName": { + "description": "Field名", + "type": "string" + }, + "fieldSearchType": { + "description": "搜索条件", + "type": "string" + }, + "fieldType": { + "description": "Field数据类型", + "type": "string" + } + } + }, + "system.SysApi": { + "type": "object", + "properties": { + "apiGroup": { + "description": "api组", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "description": { + "description": "api中文描述", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "method": { + "description": "方法:创建POST(默认)|查看GET|更新PUT|删除DELETE", + "type": "string" + }, + "path": { + "description": "api路径", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysAuthority": { + "type": "object", + "properties": { + "authorityId": { + "description": "角色ID", + "type": "string" + }, + "authorityName": { + "description": "角色名", + "type": "string" + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "dataAuthorityId": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "defaultRouter": { + "description": "默认菜单(默认dashboard)", + "type": "string" + }, + "deletedAt": { + "type": "string" + }, + "menus": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenu" + } + }, + "parentId": { + "description": "父角色ID", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysBaseMenu": { + "type": "object", + "properties": { + "authoritys": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenu" + } + }, + "closeTab": { + "description": "自动关闭tab", + "type": "boolean" + }, + "component": { + "description": "对应前端文件路径", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "defaultMenu": { + "description": "是否是基础路由(开发中)", + "type": "boolean" + }, + "hidden": { + "description": "是否在列表隐藏", + "type": "boolean" + }, + "icon": { + "description": "菜单图标", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "keepAlive": { + "description": "是否缓存", + "type": "boolean" + }, + "name": { + "description": "路由name", + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenuParameter" + } + }, + "parentId": { + "description": "父菜单ID", + "type": "string" + }, + "path": { + "description": "路由path", + "type": "string" + }, + "sort": { + "description": "排序标记", + "type": "integer" + }, + "title": { + "description": "菜单名", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysBaseMenuParameter": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "key": { + "description": "地址栏携带参数的key", + "type": "string" + }, + "sysBaseMenuID": { + "type": "integer" + }, + "type": { + "description": "地址栏携带参数为params还是query", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "value": { + "description": "地址栏携带参数的值", + "type": "string" + } + } + }, + "system.SysDictionary": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "desc": { + "description": "描述", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "name": { + "description": "字典名(中)", + "type": "string" + }, + "status": { + "description": "状态", + "type": "boolean" + }, + "sysDictionaryDetails": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysDictionaryDetail" + } + }, + "type": { + "description": "字典名(英)", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysDictionaryDetail": { "type": "object", "properties": { "createdAt": { @@ -3965,14 +4720,6 @@ var doc = `{ "description": "展示值", "type": "string" }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, "sort": { "description": "排序标记", "type": "integer" @@ -3995,54 +4742,7 @@ var doc = `{ } } }, - "request.SysDictionarySearch": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "desc": { - "description": "描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "name": { - "description": "字典名(中)", - "type": "string" - }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, - "status": { - "description": "状态", - "type": "boolean" - }, - "sysDictionaryDetails": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } - }, - "type": { - "description": "字典名(英)", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "request.SysOperationRecordSearch": { + "system.SysOperationRecord": { "type": "object", "properties": { "agent": { @@ -4077,14 +4777,6 @@ var doc = `{ "description": "请求方法", "type": "string" }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, "path": { "description": "请求路径", "type": "string" @@ -4102,7 +4794,7 @@ var doc = `{ "type": "string" }, "user": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" }, "user_id": { "description": "用户id", @@ -4110,15 +4802,69 @@ var doc = `{ } } }, - "response.SysAuthorityCopyResponse": { + "system.SysUser": { "type": "object", "properties": { - "authority": { - "$ref": "#/definitions/model.SysAuthority" - }, - "oldAuthorityId": { - "description": "旧角色ID", + "activeColor": { + "description": "活跃颜色", "type": "string" + }, + "authorities": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "authority": { + "$ref": "#/definitions/system.SysAuthority" + }, + "authorityId": { + "description": "用户角色ID", + "type": "string" + }, + "baseColor": { + "description": "基础颜色", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "headerImg": { + "description": "用户头像", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "nickName": { + "description": "用户昵称", + "type": "string" + }, + "sideMode": { + "description": "用户侧边主题", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "userName": { + "description": "用户登录名", + "type": "string" + }, + "uuid": { + "description": "用户UUID", + "type": "string" + } + } + }, + "system.System": { + "type": "object", + "properties": { + "config": { + "$ref": "#/definitions/config.Server" } } } diff --git a/server/docs/swagger.json b/server/docs/swagger.json index 9884a45d..b48dbd9a 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -8,6 +8,108 @@ }, "basePath": "/", "paths": { + "/SimpleUploaderApi/checkFileMd5": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "断点续传插件版示例", + "parameters": [ + { + "type": "string", + "description": "md5", + "name": "md5", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/SimpleUploaderApi/mergeFileMd5": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "合并文件", + "parameters": [ + { + "type": "string", + "description": "md5", + "name": "md5", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"合并成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/SimpleUploaderApi/upload": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SimpleUploader" + ], + "summary": "断点续传插件版示例", + "parameters": [ + { + "type": "file", + "description": "断点续传插件版示例", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"切片创建成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/api/createApi": { "post": { "security": [ @@ -32,7 +134,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -70,7 +172,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -249,7 +351,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysApi" + "$ref": "#/definitions/system.SysApi" } } ], @@ -325,7 +427,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -363,7 +465,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -439,7 +541,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -477,7 +579,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysAuthority" + "$ref": "#/definitions/system.SysAuthority" } } ], @@ -515,7 +617,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.AutoCodeStruct" + "$ref": "#/definitions/system.AutoCodeStruct" } } ], @@ -529,6 +631,44 @@ } } }, + "/autoCode/delSysHistory": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "删除回滚记录", + "parameters": [ + { + "description": "删除回滚记录", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/autoCode/getColumn": { "get": { "security": [ @@ -583,6 +723,82 @@ } } }, + "/autoCode/getMeta": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "回滚", + "parameters": [ + { + "description": "获取meta信息", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCode/getSysHistory": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "查询回滚记录", + "parameters": [ + { + "description": "查询回滚记录", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SysAutoHistory" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/autoCode/getTables": { "get": { "security": [ @@ -634,7 +850,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.AutoCodeStruct" + "$ref": "#/definitions/system.AutoCodeStruct" } } ], @@ -648,6 +864,276 @@ } } }, + "/autoCode/rollback": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCode" + ], + "summary": "回滚", + "parameters": [ + { + "description": "回滚自动生成代码", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AutoHistoryByID" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"回滚成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/createAutoCodeExample": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "创建AutoCodeExample", + "parameters": [ + { + "description": "AutoCodeExample模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"创建成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/deleteAutoCodeExample": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "删除AutoCodeExample", + "parameters": [ + { + "description": "AutoCodeExample模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/findAutoCodeExample": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "用id查询AutoCodeExample", + "parameters": [ + { + "type": "string", + "description": "展示值", + "name": "autoCodeExampleField", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/getAutoCodeExampleList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "分页获取AutoCodeExample列表", + "parameters": [ + { + "type": "string", + "description": "展示值", + "name": "autoCodeExampleField", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/autoCodeExample/updateAutoCodeExample": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "AutoCodeExample" + ], + "summary": "更新AutoCodeExample", + "parameters": [ + { + "description": "更新AutoCodeExample", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/autocode.AutoCodeExample" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/base/captcha": { "post": { "security": [ @@ -800,13 +1286,46 @@ "summary": "获取单一客户信息", "parameters": [ { - "description": "客户ID", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.ExaCustomer" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "客户名", + "name": "customerName", + "in": "query" + }, + { + "type": "string", + "description": "客户手机号", + "name": "customerPhoneData", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "管理角色ID", + "name": "sysUserAuthorityID", + "in": "query" + }, + { + "type": "integer", + "description": "管理ID", + "name": "sysUserId", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -841,7 +1360,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -877,7 +1396,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -913,7 +1432,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaCustomer" + "$ref": "#/definitions/example.ExaCustomer" } } ], @@ -946,13 +1465,16 @@ "summary": "分页获取权限客户列表", "parameters": [ { - "description": "页码, 每页大小", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.PageInfo" - } + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" } ], "responses": { @@ -1016,9 +1538,7 @@ } ], "responses": { - "200": { - "description": "" - } + "200": {} } } }, @@ -1046,14 +1566,12 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExcelInfo" + "$ref": "#/definitions/example.ExcelInfo" } } ], "responses": { - "200": { - "description": "" - } + "200": {} } } }, @@ -1174,7 +1692,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.ExaFileUploadAndDownload" + "$ref": "#/definitions/example.ExaFileUploadAndDownload" } } ], @@ -1472,7 +1990,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } ], @@ -1732,7 +2250,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } ], @@ -1746,108 +2264,6 @@ } } }, - "/simpleUploader/checkFileMd5": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "断点续传插件版示例", - "parameters": [ - { - "type": "string", - "description": "md5", - "name": "md5", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, - "/simpleUploader/mergeFileMd5": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "合并文件", - "parameters": [ - { - "type": "string", - "description": "md5", - "name": "md5", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"合并成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, - "/simpleUploader/upload": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SimpleUploader" - ], - "summary": "断点续传插件版示例", - "parameters": [ - { - "type": "file", - "description": "断点续传插件版示例", - "name": "file", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "{\"success\":true,\"data\":{},\"msg\":\"切片创建成功\"}", - "schema": { - "type": "string" - } - } - } - } - }, "/sysDictionary/createSysDictionary": { "post": { "security": [ @@ -1872,7 +2288,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -1910,7 +2326,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -1943,13 +2359,46 @@ "summary": "用id查询SysDictionary", "parameters": [ { - "description": "ID或字典英名", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysDictionary" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "描述", + "name": "desc", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "字典名(中)", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "description": "状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "字典名(英)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -1981,13 +2430,58 @@ "summary": "分页获取SysDictionary列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysDictionarySearch" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "描述", + "name": "desc", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "字典名(中)", + "name": "name", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "boolean", + "description": "状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "字典名(英)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" } ], "responses": { @@ -2024,7 +2518,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionary" + "$ref": "#/definitions/system.SysDictionary" } } ], @@ -2062,7 +2556,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2100,7 +2594,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2133,13 +2627,52 @@ "summary": "用id查询SysDictionaryDetail", "parameters": [ { - "description": "用id查询SysDictionaryDetail", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "展示值", + "name": "label", + "in": "query" + }, + { + "type": "integer", + "description": "排序标记", + "name": "sort", + "in": "query" + }, + { + "type": "boolean", + "description": "启用状态", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "关联标记", + "name": "sysDictionaryID", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "字典值", + "name": "value", + "in": "query" } ], "responses": { @@ -2171,13 +2704,64 @@ "summary": "分页获取SysDictionaryDetail列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysDictionaryDetailSearch" - } + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "展示值", + "name": "label", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "description": "排序标记", + "name": "sort", + "in": "query" + }, + { + "type": "boolean", + "description": "启用状态", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "关联标记", + "name": "sysDictionaryID", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "字典值", + "name": "value", + "in": "query" } ], "responses": { @@ -2214,7 +2798,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysDictionaryDetail" + "$ref": "#/definitions/system.SysDictionaryDetail" } } ], @@ -2252,7 +2836,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysOperationRecord" + "$ref": "#/definitions/system.SysOperationRecord" } } ], @@ -2290,7 +2874,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysOperationRecord" + "$ref": "#/definitions/system.SysOperationRecord" } } ], @@ -2361,13 +2945,82 @@ "summary": "用id查询SysOperationRecord", "parameters": [ { - "description": "Id", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/model.SysOperationRecord" - } + "type": "string", + "description": "代理", + "name": "agent", + "in": "query" + }, + { + "type": "string", + "description": "请求Body", + "name": "body", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "错误信息", + "name": "error_message", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "请求ip", + "name": "ip", + "in": "query" + }, + { + "type": "string", + "description": "延迟", + "name": "latency", + "in": "query" + }, + { + "type": "string", + "description": "请求方法", + "name": "method", + "in": "query" + }, + { + "type": "string", + "description": "请求路径", + "name": "path", + "in": "query" + }, + { + "type": "string", + "description": "响应Body", + "name": "resp", + "in": "query" + }, + { + "type": "integer", + "description": "请求状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "用户id", + "name": "user_id", + "in": "query" } ], "responses": { @@ -2399,13 +3052,94 @@ "summary": "分页获取SysOperationRecord列表", "parameters": [ { - "description": "页码, 每页大小, 搜索条件", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SysOperationRecordSearch" - } + "type": "string", + "description": "代理", + "name": "agent", + "in": "query" + }, + { + "type": "string", + "description": "请求Body", + "name": "body", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "description": "错误信息", + "name": "error_message", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "string", + "description": "请求ip", + "name": "ip", + "in": "query" + }, + { + "type": "string", + "description": "延迟", + "name": "latency", + "in": "query" + }, + { + "type": "string", + "description": "请求方法", + "name": "method", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "请求路径", + "name": "path", + "in": "query" + }, + { + "type": "string", + "description": "响应Body", + "name": "resp", + "in": "query" + }, + { + "type": "integer", + "description": "请求状态", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + }, + { + "type": "integer", + "description": "用户id", + "name": "user_id", + "in": "query" } ], "responses": { @@ -2511,7 +3245,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.System" + "$ref": "#/definitions/system.System" } } ], @@ -2526,7 +3260,7 @@ } }, "/user/changePassword": { - "put": { + "post": { "security": [ { "ApiKeyAuth": [] @@ -2598,6 +3332,33 @@ } } }, + "/user/getUserInfo": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "获取用户信息", + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/user/getUserList": { "post": { "security": [ @@ -2652,7 +3413,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/request.Register" } } ], @@ -2666,6 +3427,44 @@ } } }, + "/user/setUserAuthorities": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SysUser" + ], + "summary": "设置用户权限", + "parameters": [ + { + "description": "用户UUID, 角色ID", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.SetUserAuthorities" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, "/user/setUserAuthority": { "post": { "security": [ @@ -2682,7 +3481,7 @@ "tags": [ "SysUser" ], - "summary": "设置用户权限", + "summary": "更改用户权限", "parameters": [ { "description": "用户UUID, 角色ID", @@ -2728,7 +3527,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" } } ], @@ -2744,6 +3543,27 @@ } }, "definitions": { + "autocode.AutoCodeExample": { + "type": "object", + "properties": { + "autoCodeExampleField": { + "description": "展示值", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, "config.AliyunOSS": { "type": "object", "properties": { @@ -2753,6 +3573,9 @@ "accessKeySecret": { "type": "string" }, + "basePath": { + "type": "string" + }, "bucketName": { "type": "string" }, @@ -2791,6 +3614,9 @@ "serverService": { "type": "string" }, + "transferRestart": { + "type": "boolean" + }, "web": { "type": "string" }, @@ -2931,10 +3757,11 @@ }, "logMode": { "description": "是否开启Gorm全局日志", - "type": "boolean" + "type": "string" }, "logZap": { - "type": "string" + "description": "是否通过zap写入日志文件", + "type": "boolean" }, "maxIdleConns": { "description": "空闲中的最大连接数", @@ -3169,46 +3996,7 @@ } } }, - "model.AutoCodeStruct": { - "type": "object", - "properties": { - "abbreviation": { - "description": "Struct简称", - "type": "string" - }, - "autoCreateApiToSql": { - "description": "是否自动创建api", - "type": "boolean" - }, - "autoMoveFile": { - "description": "是否自动移动文件", - "type": "boolean" - }, - "description": { - "description": "Struct中文名称", - "type": "string" - }, - "fields": { - "type": "array", - "items": { - "$ref": "#/definitions/model.Field" - } - }, - "packageName": { - "description": "文件名称", - "type": "string" - }, - "structName": { - "description": "Struct名称", - "type": "string" - }, - "tableName": { - "description": "表名", - "type": "string" - } - } - }, - "model.ExaCustomer": { + "example.ExaCustomer": { "type": "object", "properties": { "createdAt": { @@ -3229,7 +4017,7 @@ }, "sysUser": { "description": "管理详情", - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" }, "sysUserAuthorityID": { "description": "管理角色ID", @@ -3245,7 +4033,7 @@ } } }, - "model.ExaFileUploadAndDownload": { + "example.ExaFileUploadAndDownload": { "type": "object", "properties": { "createdAt": { @@ -3278,7 +4066,7 @@ } } }, - "model.ExcelInfo": { + "example.ExcelInfo": { "type": "object", "properties": { "fileName": { @@ -3288,434 +4076,11 @@ "infoList": { "type": "array", "items": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } } }, - "model.Field": { - "type": "object", - "properties": { - "columnName": { - "description": "数据库字段", - "type": "string" - }, - "comment": { - "description": "数据库字段描述", - "type": "string" - }, - "dataType": { - "description": "数据库字段类型", - "type": "string" - }, - "dataTypeLong": { - "description": "数据库字段长度", - "type": "string" - }, - "dictType": { - "description": "字典", - "type": "string" - }, - "fieldDesc": { - "description": "中文名", - "type": "string" - }, - "fieldJson": { - "description": "FieldJson", - "type": "string" - }, - "fieldName": { - "description": "Field名", - "type": "string" - }, - "fieldSearchType": { - "description": "搜索条件", - "type": "string" - }, - "fieldType": { - "description": "Field数据类型", - "type": "string" - } - } - }, - "model.SysApi": { - "type": "object", - "properties": { - "apiGroup": { - "description": "api组", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "description": { - "description": "api中文描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "method": { - "description": "方法:创建POST(默认)|查看GET|更新PUT|删除DELETE", - "type": "string" - }, - "path": { - "description": "api路径", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysAuthority": { - "type": "object", - "properties": { - "authorityId": { - "description": "角色ID", - "type": "string" - }, - "authorityName": { - "description": "角色名", - "type": "string" - }, - "children": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "dataAuthorityId": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "defaultRouter": { - "description": "默认菜单(默认dashboard)", - "type": "string" - }, - "deletedAt": { - "type": "string" - }, - "menus": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenu" - } - }, - "parentId": { - "description": "父角色ID", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysBaseMenu": { - "type": "object", - "properties": { - "authoritys": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysAuthority" - } - }, - "children": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenu" - } - }, - "closeTab": { - "description": "自动关闭tab", - "type": "boolean" - }, - "component": { - "description": "对应前端文件路径", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "defaultMenu": { - "description": "是否是基础路由(开发中)", - "type": "boolean" - }, - "hidden": { - "description": "是否在列表隐藏", - "type": "boolean" - }, - "icon": { - "description": "菜单图标", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "keepAlive": { - "description": "是否缓存", - "type": "boolean" - }, - "name": { - "description": "路由name", - "type": "string" - }, - "parameters": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysBaseMenuParameter" - } - }, - "parentId": { - "description": "父菜单ID", - "type": "string" - }, - "path": { - "description": "路由path", - "type": "string" - }, - "sort": { - "description": "排序标记", - "type": "integer" - }, - "title": { - "description": "菜单名", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysBaseMenuParameter": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "key": { - "description": "地址栏携带参数的key", - "type": "string" - }, - "sysBaseMenuID": { - "type": "integer" - }, - "type": { - "description": "地址栏携带参数为params还是query", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "value": { - "description": "地址栏携带参数的值", - "type": "string" - } - } - }, - "model.SysDictionary": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "desc": { - "description": "描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "name": { - "description": "字典名(中)", - "type": "string" - }, - "status": { - "description": "状态", - "type": "boolean" - }, - "sysDictionaryDetails": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } - }, - "type": { - "description": "字典名(英)", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "model.SysDictionaryDetail": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "label": { - "description": "展示值", - "type": "string" - }, - "sort": { - "description": "排序标记", - "type": "integer" - }, - "status": { - "description": "启用状态", - "type": "boolean" - }, - "sysDictionaryID": { - "description": "关联标记", - "type": "integer" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "value": { - "description": "字典值", - "type": "integer" - } - } - }, - "model.SysOperationRecord": { - "type": "object", - "properties": { - "agent": { - "description": "代理", - "type": "string" - }, - "body": { - "description": "请求Body", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "error_message": { - "description": "错误信息", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "ip": { - "description": "请求ip", - "type": "string" - }, - "latency": { - "description": "延迟", - "type": "string" - }, - "method": { - "description": "请求方法", - "type": "string" - }, - "path": { - "description": "请求路径", - "type": "string" - }, - "resp": { - "description": "响应Body", - "type": "string" - }, - "status": { - "description": "请求状态", - "type": "integer" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "user": { - "$ref": "#/definitions/model.SysUser" - }, - "user_id": { - "description": "用户id", - "type": "integer" - } - } - }, - "model.SysUser": { - "type": "object", - "properties": { - "authority": { - "$ref": "#/definitions/model.SysAuthority" - }, - "authorityId": { - "description": "用户角色ID", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "headerImg": { - "description": "用户头像", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "nickName": { - "description": "用户昵称", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "userName": { - "description": "用户登录名", - "type": "string" - }, - "uuid": { - "description": "用户UUID", - "type": "string" - } - } - }, - "model.System": { - "type": "object", - "properties": { - "config": { - "$ref": "#/definitions/config.Server" - } - } - }, "request.AddMenuAuthorityInfo": { "type": "object", "properties": { @@ -3726,11 +4091,19 @@ "menus": { "type": "array", "items": { - "$ref": "#/definitions/model.SysBaseMenu" + "$ref": "#/definitions/system.SysBaseMenu" } } } }, + "request.AutoHistoryByID": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, "request.CasbinInReceive": { "type": "object", "properties": { @@ -3871,6 +4244,32 @@ } } }, + "request.Register": { + "type": "object", + "properties": { + "authorityId": { + "type": "string" + }, + "authorityIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "headerImg": { + "type": "string" + }, + "nickName": { + "type": "string" + }, + "passWord": { + "type": "string" + }, + "userName": { + "type": "string" + } + } + }, "request.SearchApiParams": { "type": "object", "properties": { @@ -3926,14 +4325,371 @@ "authorityId": { "description": "角色ID", "type": "string" + } + } + }, + "request.SetUserAuthorities": { + "type": "object", + "properties": { + "authorityIds": { + "description": "角色ID", + "type": "array", + "items": { + "type": "string" + } }, - "uuid": { - "description": "用户UUID", + "id": { + "type": "integer" + } + } + }, + "request.SysAutoHistory": { + "type": "object", + "properties": { + "page": { + "description": "页码", + "type": "integer" + }, + "pageSize": { + "description": "每页大小", + "type": "integer" + } + } + }, + "response.SysAuthorityCopyResponse": { + "type": "object", + "properties": { + "authority": { + "$ref": "#/definitions/system.SysAuthority" + }, + "oldAuthorityId": { + "description": "旧角色ID", "type": "string" } } }, - "request.SysDictionaryDetailSearch": { + "system.AutoCodeStruct": { + "type": "object", + "properties": { + "abbreviation": { + "description": "Struct简称", + "type": "string" + }, + "autoCreateApiToSql": { + "description": "是否自动创建api", + "type": "boolean" + }, + "autoMoveFile": { + "description": "是否自动移动文件", + "type": "boolean" + }, + "description": { + "description": "Struct中文名称", + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/system.Field" + } + }, + "humpPackageName": { + "description": "go文件名称", + "type": "string" + }, + "packageName": { + "description": "文件名称", + "type": "string" + }, + "structName": { + "description": "Struct名称", + "type": "string" + }, + "tableName": { + "description": "表名", + "type": "string" + } + } + }, + "system.Field": { + "type": "object", + "properties": { + "columnName": { + "description": "数据库字段", + "type": "string" + }, + "comment": { + "description": "数据库字段描述", + "type": "string" + }, + "dataType": { + "description": "数据库字段类型", + "type": "string" + }, + "dataTypeLong": { + "description": "数据库字段长度", + "type": "string" + }, + "dictType": { + "description": "字典", + "type": "string" + }, + "fieldDesc": { + "description": "中文名", + "type": "string" + }, + "fieldJson": { + "description": "FieldJson", + "type": "string" + }, + "fieldName": { + "description": "Field名", + "type": "string" + }, + "fieldSearchType": { + "description": "搜索条件", + "type": "string" + }, + "fieldType": { + "description": "Field数据类型", + "type": "string" + } + } + }, + "system.SysApi": { + "type": "object", + "properties": { + "apiGroup": { + "description": "api组", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "description": { + "description": "api中文描述", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "method": { + "description": "方法:创建POST(默认)|查看GET|更新PUT|删除DELETE", + "type": "string" + }, + "path": { + "description": "api路径", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysAuthority": { + "type": "object", + "properties": { + "authorityId": { + "description": "角色ID", + "type": "string" + }, + "authorityName": { + "description": "角色名", + "type": "string" + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "dataAuthorityId": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "defaultRouter": { + "description": "默认菜单(默认dashboard)", + "type": "string" + }, + "deletedAt": { + "type": "string" + }, + "menus": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenu" + } + }, + "parentId": { + "description": "父角色ID", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysBaseMenu": { + "type": "object", + "properties": { + "authoritys": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenu" + } + }, + "closeTab": { + "description": "自动关闭tab", + "type": "boolean" + }, + "component": { + "description": "对应前端文件路径", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "defaultMenu": { + "description": "是否是基础路由(开发中)", + "type": "boolean" + }, + "hidden": { + "description": "是否在列表隐藏", + "type": "boolean" + }, + "icon": { + "description": "菜单图标", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "keepAlive": { + "description": "是否缓存", + "type": "boolean" + }, + "name": { + "description": "路由name", + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysBaseMenuParameter" + } + }, + "parentId": { + "description": "父菜单ID", + "type": "string" + }, + "path": { + "description": "路由path", + "type": "string" + }, + "sort": { + "description": "排序标记", + "type": "integer" + }, + "title": { + "description": "菜单名", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysBaseMenuParameter": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "key": { + "description": "地址栏携带参数的key", + "type": "string" + }, + "sysBaseMenuID": { + "type": "integer" + }, + "type": { + "description": "地址栏携带参数为params还是query", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "value": { + "description": "地址栏携带参数的值", + "type": "string" + } + } + }, + "system.SysDictionary": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "desc": { + "description": "描述", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "name": { + "description": "字典名(中)", + "type": "string" + }, + "status": { + "description": "状态", + "type": "boolean" + }, + "sysDictionaryDetails": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysDictionaryDetail" + } + }, + "type": { + "description": "字典名(英)", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "system.SysDictionaryDetail": { "type": "object", "properties": { "createdAt": { @@ -3948,14 +4704,6 @@ "description": "展示值", "type": "string" }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, "sort": { "description": "排序标记", "type": "integer" @@ -3978,54 +4726,7 @@ } } }, - "request.SysDictionarySearch": { - "type": "object", - "properties": { - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "desc": { - "description": "描述", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "name": { - "description": "字典名(中)", - "type": "string" - }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, - "status": { - "description": "状态", - "type": "boolean" - }, - "sysDictionaryDetails": { - "type": "array", - "items": { - "$ref": "#/definitions/model.SysDictionaryDetail" - } - }, - "type": { - "description": "字典名(英)", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - } - } - }, - "request.SysOperationRecordSearch": { + "system.SysOperationRecord": { "type": "object", "properties": { "agent": { @@ -4060,14 +4761,6 @@ "description": "请求方法", "type": "string" }, - "page": { - "description": "页码", - "type": "integer" - }, - "pageSize": { - "description": "每页大小", - "type": "integer" - }, "path": { "description": "请求路径", "type": "string" @@ -4085,7 +4778,7 @@ "type": "string" }, "user": { - "$ref": "#/definitions/model.SysUser" + "$ref": "#/definitions/system.SysUser" }, "user_id": { "description": "用户id", @@ -4093,15 +4786,69 @@ } } }, - "response.SysAuthorityCopyResponse": { + "system.SysUser": { "type": "object", "properties": { - "authority": { - "$ref": "#/definitions/model.SysAuthority" - }, - "oldAuthorityId": { - "description": "旧角色ID", + "activeColor": { + "description": "活跃颜色", "type": "string" + }, + "authorities": { + "type": "array", + "items": { + "$ref": "#/definitions/system.SysAuthority" + } + }, + "authority": { + "$ref": "#/definitions/system.SysAuthority" + }, + "authorityId": { + "description": "用户角色ID", + "type": "string" + }, + "baseColor": { + "description": "基础颜色", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "headerImg": { + "description": "用户头像", + "type": "string" + }, + "id": { + "description": "主键ID", + "type": "integer" + }, + "nickName": { + "description": "用户昵称", + "type": "string" + }, + "sideMode": { + "description": "用户侧边主题", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + }, + "userName": { + "description": "用户登录名", + "type": "string" + }, + "uuid": { + "description": "用户UUID", + "type": "string" + } + } + }, + "system.System": { + "type": "object", + "properties": { + "config": { + "$ref": "#/definitions/config.Server" } } } diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index c8299717..af6f70c2 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1,11 +1,28 @@ basePath: / definitions: + autocode.AutoCodeExample: + properties: + autoCodeExampleField: + description: 展示值 + type: string + createdAt: + description: 创建时间 + type: string + id: + description: 主键ID + type: integer + updatedAt: + description: 更新时间 + type: string + type: object config.AliyunOSS: properties: accessKeyId: type: string accessKeySecret: type: string + basePath: + type: string bucketName: type: string bucketUrl: @@ -31,6 +48,8 @@ definitions: type: string serverService: type: string + transferRestart: + type: boolean web: type: string webApi: @@ -129,9 +148,10 @@ definitions: type: string logMode: description: 是否开启Gorm全局日志 - type: boolean - logZap: type: string + logZap: + description: 是否通过zap写入日志文件 + type: boolean maxIdleConns: description: 空闲中的最大连接数 type: integer @@ -296,35 +316,7 @@ definitions: description: 栈名 type: string type: object - model.AutoCodeStruct: - properties: - abbreviation: - description: Struct简称 - type: string - autoCreateApiToSql: - description: 是否自动创建api - type: boolean - autoMoveFile: - description: 是否自动移动文件 - type: boolean - description: - description: Struct中文名称 - type: string - fields: - items: - $ref: '#/definitions/model.Field' - type: array - packageName: - description: 文件名称 - type: string - structName: - description: Struct名称 - type: string - tableName: - description: 表名 - type: string - type: object - model.ExaCustomer: + example.ExaCustomer: properties: createdAt: description: 创建时间 @@ -339,7 +331,7 @@ definitions: description: 主键ID type: integer sysUser: - $ref: '#/definitions/model.SysUser' + $ref: '#/definitions/system.SysUser' description: 管理详情 sysUserAuthorityID: description: 管理角色ID @@ -351,7 +343,7 @@ definitions: description: 更新时间 type: string type: object - model.ExaFileUploadAndDownload: + example.ExaFileUploadAndDownload: properties: createdAt: description: 创建时间 @@ -375,321 +367,16 @@ definitions: description: 文件地址 type: string type: object - model.ExcelInfo: + example.ExcelInfo: properties: fileName: description: 文件名 type: string infoList: items: - $ref: '#/definitions/model.SysBaseMenu' + $ref: '#/definitions/system.SysBaseMenu' type: array type: object - model.Field: - properties: - columnName: - description: 数据库字段 - type: string - comment: - description: 数据库字段描述 - type: string - dataType: - description: 数据库字段类型 - type: string - dataTypeLong: - description: 数据库字段长度 - type: string - dictType: - description: 字典 - type: string - fieldDesc: - description: 中文名 - type: string - fieldJson: - description: FieldJson - type: string - fieldName: - description: Field名 - type: string - fieldSearchType: - description: 搜索条件 - type: string - fieldType: - description: Field数据类型 - type: string - type: object - model.SysApi: - properties: - apiGroup: - description: api组 - type: string - createdAt: - description: 创建时间 - type: string - description: - description: api中文描述 - type: string - id: - description: 主键ID - type: integer - method: - description: 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE - type: string - path: - description: api路径 - type: string - updatedAt: - description: 更新时间 - type: string - type: object - model.SysAuthority: - properties: - authorityId: - description: 角色ID - type: string - authorityName: - description: 角色名 - type: string - children: - items: - $ref: '#/definitions/model.SysAuthority' - type: array - createdAt: - description: 创建时间 - type: string - dataAuthorityId: - items: - $ref: '#/definitions/model.SysAuthority' - type: array - defaultRouter: - description: 默认菜单(默认dashboard) - type: string - deletedAt: - type: string - menus: - items: - $ref: '#/definitions/model.SysBaseMenu' - type: array - parentId: - description: 父角色ID - type: string - updatedAt: - description: 更新时间 - type: string - type: object - model.SysBaseMenu: - properties: - authoritys: - items: - $ref: '#/definitions/model.SysAuthority' - type: array - children: - items: - $ref: '#/definitions/model.SysBaseMenu' - type: array - closeTab: - description: 自动关闭tab - type: boolean - component: - description: 对应前端文件路径 - type: string - createdAt: - description: 创建时间 - type: string - defaultMenu: - description: 是否是基础路由(开发中) - type: boolean - hidden: - description: 是否在列表隐藏 - type: boolean - icon: - description: 菜单图标 - type: string - id: - description: 主键ID - type: integer - keepAlive: - description: 是否缓存 - type: boolean - name: - description: 路由name - type: string - parameters: - items: - $ref: '#/definitions/model.SysBaseMenuParameter' - type: array - parentId: - description: 父菜单ID - type: string - path: - description: 路由path - type: string - sort: - description: 排序标记 - type: integer - title: - description: 菜单名 - type: string - updatedAt: - description: 更新时间 - type: string - type: object - model.SysBaseMenuParameter: - properties: - createdAt: - description: 创建时间 - type: string - id: - description: 主键ID - type: integer - key: - description: 地址栏携带参数的key - type: string - sysBaseMenuID: - type: integer - type: - description: 地址栏携带参数为params还是query - type: string - updatedAt: - description: 更新时间 - type: string - value: - description: 地址栏携带参数的值 - type: string - type: object - model.SysDictionary: - properties: - createdAt: - description: 创建时间 - type: string - desc: - description: 描述 - type: string - id: - description: 主键ID - type: integer - name: - description: 字典名(中) - type: string - status: - description: 状态 - type: boolean - sysDictionaryDetails: - items: - $ref: '#/definitions/model.SysDictionaryDetail' - type: array - type: - description: 字典名(英) - type: string - updatedAt: - description: 更新时间 - type: string - type: object - model.SysDictionaryDetail: - properties: - createdAt: - description: 创建时间 - type: string - id: - description: 主键ID - type: integer - label: - description: 展示值 - type: string - sort: - description: 排序标记 - type: integer - status: - description: 启用状态 - type: boolean - sysDictionaryID: - description: 关联标记 - type: integer - updatedAt: - description: 更新时间 - type: string - value: - description: 字典值 - type: integer - type: object - model.SysOperationRecord: - properties: - agent: - description: 代理 - type: string - body: - description: 请求Body - type: string - createdAt: - description: 创建时间 - type: string - error_message: - description: 错误信息 - type: string - id: - description: 主键ID - type: integer - ip: - description: 请求ip - type: string - latency: - description: 延迟 - type: string - method: - description: 请求方法 - type: string - path: - description: 请求路径 - type: string - resp: - description: 响应Body - type: string - status: - description: 请求状态 - type: integer - updatedAt: - description: 更新时间 - type: string - user: - $ref: '#/definitions/model.SysUser' - user_id: - description: 用户id - type: integer - type: object - model.SysUser: - properties: - authority: - $ref: '#/definitions/model.SysAuthority' - authorityId: - description: 用户角色ID - type: string - createdAt: - description: 创建时间 - type: string - headerImg: - description: 用户头像 - type: string - id: - description: 主键ID - type: integer - nickName: - description: 用户昵称 - type: string - updatedAt: - description: 更新时间 - type: string - userName: - description: 用户登录名 - type: string - uuid: - description: 用户UUID - type: string - type: object - model.System: - properties: - config: - $ref: '#/definitions/config.Server' - type: object request.AddMenuAuthorityInfo: properties: authorityId: @@ -697,9 +384,14 @@ definitions: type: string menus: items: - $ref: '#/definitions/model.SysBaseMenu' + $ref: '#/definitions/system.SysBaseMenu' type: array type: object + request.AutoHistoryByID: + properties: + id: + type: integer + type: object request.CasbinInReceive: properties: authorityId: @@ -797,6 +489,23 @@ definitions: description: 每页大小 type: integer type: object + request.Register: + properties: + authorityId: + type: string + authorityIds: + items: + type: string + type: array + headerImg: + type: string + nickName: + type: string + passWord: + type: string + userName: + type: string + type: object request.SearchApiParams: properties: apiGroup: @@ -838,11 +547,266 @@ definitions: authorityId: description: 角色ID type: string - uuid: - description: 用户UUID + type: object + request.SetUserAuthorities: + properties: + authorityIds: + description: 角色ID + items: + type: string + type: array + id: + type: integer + type: object + request.SysAutoHistory: + properties: + page: + description: 页码 + type: integer + pageSize: + description: 每页大小 + type: integer + type: object + response.SysAuthorityCopyResponse: + properties: + authority: + $ref: '#/definitions/system.SysAuthority' + oldAuthorityId: + description: 旧角色ID type: string type: object - request.SysDictionaryDetailSearch: + system.AutoCodeStruct: + properties: + abbreviation: + description: Struct简称 + type: string + autoCreateApiToSql: + description: 是否自动创建api + type: boolean + autoMoveFile: + description: 是否自动移动文件 + type: boolean + description: + description: Struct中文名称 + type: string + fields: + items: + $ref: '#/definitions/system.Field' + type: array + humpPackageName: + description: go文件名称 + type: string + packageName: + description: 文件名称 + type: string + structName: + description: Struct名称 + type: string + tableName: + description: 表名 + type: string + type: object + system.Field: + properties: + columnName: + description: 数据库字段 + type: string + comment: + description: 数据库字段描述 + type: string + dataType: + description: 数据库字段类型 + type: string + dataTypeLong: + description: 数据库字段长度 + type: string + dictType: + description: 字典 + type: string + fieldDesc: + description: 中文名 + type: string + fieldJson: + description: FieldJson + type: string + fieldName: + description: Field名 + type: string + fieldSearchType: + description: 搜索条件 + type: string + fieldType: + description: Field数据类型 + type: string + type: object + system.SysApi: + properties: + apiGroup: + description: api组 + type: string + createdAt: + description: 创建时间 + type: string + description: + description: api中文描述 + type: string + id: + description: 主键ID + type: integer + method: + description: 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE + type: string + path: + description: api路径 + type: string + updatedAt: + description: 更新时间 + type: string + type: object + system.SysAuthority: + properties: + authorityId: + description: 角色ID + type: string + authorityName: + description: 角色名 + type: string + children: + items: + $ref: '#/definitions/system.SysAuthority' + type: array + createdAt: + description: 创建时间 + type: string + dataAuthorityId: + items: + $ref: '#/definitions/system.SysAuthority' + type: array + defaultRouter: + description: 默认菜单(默认dashboard) + type: string + deletedAt: + type: string + menus: + items: + $ref: '#/definitions/system.SysBaseMenu' + type: array + parentId: + description: 父角色ID + type: string + updatedAt: + description: 更新时间 + type: string + type: object + system.SysBaseMenu: + properties: + authoritys: + items: + $ref: '#/definitions/system.SysAuthority' + type: array + children: + items: + $ref: '#/definitions/system.SysBaseMenu' + type: array + closeTab: + description: 自动关闭tab + type: boolean + component: + description: 对应前端文件路径 + type: string + createdAt: + description: 创建时间 + type: string + defaultMenu: + description: 是否是基础路由(开发中) + type: boolean + hidden: + description: 是否在列表隐藏 + type: boolean + icon: + description: 菜单图标 + type: string + id: + description: 主键ID + type: integer + keepAlive: + description: 是否缓存 + type: boolean + name: + description: 路由name + type: string + parameters: + items: + $ref: '#/definitions/system.SysBaseMenuParameter' + type: array + parentId: + description: 父菜单ID + type: string + path: + description: 路由path + type: string + sort: + description: 排序标记 + type: integer + title: + description: 菜单名 + type: string + updatedAt: + description: 更新时间 + type: string + type: object + system.SysBaseMenuParameter: + properties: + createdAt: + description: 创建时间 + type: string + id: + description: 主键ID + type: integer + key: + description: 地址栏携带参数的key + type: string + sysBaseMenuID: + type: integer + type: + description: 地址栏携带参数为params还是query + type: string + updatedAt: + description: 更新时间 + type: string + value: + description: 地址栏携带参数的值 + type: string + type: object + system.SysDictionary: + properties: + createdAt: + description: 创建时间 + type: string + desc: + description: 描述 + type: string + id: + description: 主键ID + type: integer + name: + description: 字典名(中) + type: string + status: + description: 状态 + type: boolean + sysDictionaryDetails: + items: + $ref: '#/definitions/system.SysDictionaryDetail' + type: array + type: + description: 字典名(英) + type: string + updatedAt: + description: 更新时间 + type: string + type: object + system.SysDictionaryDetail: properties: createdAt: description: 创建时间 @@ -853,12 +817,6 @@ definitions: label: description: 展示值 type: string - page: - description: 页码 - type: integer - pageSize: - description: 每页大小 - type: integer sort: description: 排序标记 type: integer @@ -875,41 +833,7 @@ definitions: description: 字典值 type: integer type: object - request.SysDictionarySearch: - properties: - createdAt: - description: 创建时间 - type: string - desc: - description: 描述 - type: string - id: - description: 主键ID - type: integer - name: - description: 字典名(中) - type: string - page: - description: 页码 - type: integer - pageSize: - description: 每页大小 - type: integer - status: - description: 状态 - type: boolean - sysDictionaryDetails: - items: - $ref: '#/definitions/model.SysDictionaryDetail' - type: array - type: - description: 字典名(英) - type: string - updatedAt: - description: 更新时间 - type: string - type: object - request.SysOperationRecordSearch: + system.SysOperationRecord: properties: agent: description: 代理 @@ -935,12 +859,6 @@ definitions: method: description: 请求方法 type: string - page: - description: 页码 - type: integer - pageSize: - description: 每页大小 - type: integer path: description: 请求路径 type: string @@ -954,18 +872,57 @@ definitions: description: 更新时间 type: string user: - $ref: '#/definitions/model.SysUser' + $ref: '#/definitions/system.SysUser' user_id: description: 用户id type: integer type: object - response.SysAuthorityCopyResponse: + system.SysUser: properties: - authority: - $ref: '#/definitions/model.SysAuthority' - oldAuthorityId: - description: 旧角色ID + activeColor: + description: 活跃颜色 type: string + authorities: + items: + $ref: '#/definitions/system.SysAuthority' + type: array + authority: + $ref: '#/definitions/system.SysAuthority' + authorityId: + description: 用户角色ID + type: string + baseColor: + description: 基础颜色 + type: string + createdAt: + description: 创建时间 + type: string + headerImg: + description: 用户头像 + type: string + id: + description: 主键ID + type: integer + nickName: + description: 用户昵称 + type: string + sideMode: + description: 用户侧边主题 + type: string + updatedAt: + description: 更新时间 + type: string + userName: + description: 用户登录名 + type: string + uuid: + description: 用户UUID + type: string + type: object + system.System: + properties: + config: + $ref: '#/definitions/config.Server' type: object info: contact: {} @@ -973,6 +930,68 @@ info: title: Swagger Example API version: 0.0.1 paths: + /SimpleUploaderApi/checkFileMd5: + get: + parameters: + - description: md5 + in: query + name: md5 + required: true + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"查询成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 断点续传插件版示例 + tags: + - SimpleUploader + /SimpleUploaderApi/mergeFileMd5: + get: + parameters: + - description: md5 + in: query + name: md5 + required: true + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"合并成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 合并文件 + tags: + - SimpleUploader + /SimpleUploaderApi/upload: + post: + consumes: + - multipart/form-data + parameters: + - description: 断点续传插件版示例 + in: formData + name: file + required: true + type: file + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"切片创建成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 断点续传插件版示例 + tags: + - SimpleUploader /api/createApi: post: consumes: @@ -983,7 +1002,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysApi' + $ref: '#/definitions/system.SysApi' produces: - application/json responses: @@ -1006,7 +1025,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysApi' + $ref: '#/definitions/system.SysApi' produces: - application/json responses: @@ -1114,7 +1133,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysApi' + $ref: '#/definitions/system.SysApi' produces: - application/json responses: @@ -1160,7 +1179,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysAuthority' + $ref: '#/definitions/system.SysAuthority' produces: - application/json responses: @@ -1183,7 +1202,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysAuthority' + $ref: '#/definitions/system.SysAuthority' produces: - application/json responses: @@ -1229,7 +1248,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysAuthority' + $ref: '#/definitions/system.SysAuthority' produces: - application/json responses: @@ -1252,7 +1271,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysAuthority' + $ref: '#/definitions/system.SysAuthority' produces: - application/json responses: @@ -1275,7 +1294,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.AutoCodeStruct' + $ref: '#/definitions/system.AutoCodeStruct' produces: - application/json responses: @@ -1288,6 +1307,29 @@ paths: summary: 自动代码模板 tags: - AutoCode + /autoCode/delSysHistory: + post: + consumes: + - application/json + parameters: + - description: 删除回滚记录 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AutoHistoryByID' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"删除成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 删除回滚记录 + tags: + - AutoCode /autoCode/getColumn: get: consumes: @@ -1320,6 +1362,52 @@ paths: summary: 获取当前所有数据库 tags: - AutoCode + /autoCode/getMeta: + post: + consumes: + - application/json + parameters: + - description: 获取meta信息 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AutoHistoryByID' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 回滚 + tags: + - AutoCode + /autoCode/getSysHistory: + post: + consumes: + - application/json + parameters: + - description: 查询回滚记录 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SysAutoHistory' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 查询回滚记录 + tags: + - AutoCode /autoCode/getTables: get: consumes: @@ -1346,7 +1434,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.AutoCodeStruct' + $ref: '#/definitions/system.AutoCodeStruct' produces: - application/json responses: @@ -1359,6 +1447,172 @@ paths: summary: 预览创建后的代码 tags: - AutoCode + /autoCode/rollback: + post: + consumes: + - application/json + parameters: + - description: 回滚自动生成代码 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.AutoHistoryByID' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"回滚成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 回滚 + tags: + - AutoCode + /autoCodeExample/createAutoCodeExample: + post: + consumes: + - application/json + parameters: + - description: AutoCodeExample模型 + in: body + name: data + required: true + schema: + $ref: '#/definitions/autocode.AutoCodeExample' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"创建成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 创建AutoCodeExample + tags: + - AutoCodeExample + /autoCodeExample/deleteAutoCodeExample: + delete: + consumes: + - application/json + parameters: + - description: AutoCodeExample模型 + in: body + name: data + required: true + schema: + $ref: '#/definitions/autocode.AutoCodeExample' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"删除成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 删除AutoCodeExample + tags: + - AutoCodeExample + /autoCodeExample/findAutoCodeExample: + get: + consumes: + - application/json + parameters: + - description: 展示值 + in: query + name: autoCodeExampleField + type: string + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"查询成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 用id查询AutoCodeExample + tags: + - AutoCodeExample + /autoCodeExample/getAutoCodeExampleList: + get: + consumes: + - application/json + parameters: + - description: 展示值 + in: query + name: autoCodeExampleField + type: string + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 分页获取AutoCodeExample列表 + tags: + - AutoCodeExample + /autoCodeExample/updateAutoCodeExample: + put: + consumes: + - application/json + parameters: + - description: 更新AutoCodeExample + in: body + name: data + required: true + schema: + $ref: '#/definitions/autocode.AutoCodeExample' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"更新成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 更新AutoCodeExample + tags: + - AutoCodeExample /base/captcha: post: consumes: @@ -1450,7 +1704,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.ExaCustomer' + $ref: '#/definitions/example.ExaCustomer' produces: - application/json responses: @@ -1467,12 +1721,34 @@ paths: consumes: - application/json parameters: - - description: 客户ID - in: body - name: data - required: true - schema: - $ref: '#/definitions/model.ExaCustomer' + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 客户名 + in: query + name: customerName + type: string + - description: 客户手机号 + in: query + name: customerPhoneData + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 管理角色ID + in: query + name: sysUserAuthorityID + type: string + - description: 管理ID + in: query + name: sysUserId + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string produces: - application/json responses: @@ -1494,7 +1770,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.ExaCustomer' + $ref: '#/definitions/example.ExaCustomer' produces: - application/json responses: @@ -1516,7 +1792,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.ExaCustomer' + $ref: '#/definitions/example.ExaCustomer' produces: - application/json responses: @@ -1534,12 +1810,14 @@ paths: consumes: - application/json parameters: - - description: 页码, 每页大小 - in: body - name: data - required: true - schema: - $ref: '#/definitions/request.PageInfo' + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer produces: - application/json responses: @@ -1579,8 +1857,7 @@ paths: produces: - application/json responses: - "200": - description: "" + "200": {} security: - ApiKeyAuth: [] summary: 下载模板 @@ -1596,12 +1873,11 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.ExcelInfo' + $ref: '#/definitions/example.ExcelInfo' produces: - application/octet-stream responses: - "200": - description: "" + "200": {} security: - ApiKeyAuth: [] summary: 导出Excel @@ -1673,7 +1949,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.ExaFileUploadAndDownload' + $ref: '#/definitions/example.ExaFileUploadAndDownload' produces: - application/json responses: @@ -1855,7 +2131,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysBaseMenu' + $ref: '#/definitions/system.SysBaseMenu' produces: - application/json responses: @@ -2012,7 +2288,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysBaseMenu' + $ref: '#/definitions/system.SysBaseMenu' produces: - application/json responses: @@ -2025,68 +2301,6 @@ paths: summary: 更新菜单 tags: - Menu - /simpleUploader/checkFileMd5: - get: - parameters: - - description: md5 - in: query - name: md5 - required: true - type: string - produces: - - application/json - responses: - "200": - description: '{"success":true,"data":{},"msg":"查询成功"}' - schema: - type: string - security: - - ApiKeyAuth: [] - summary: 断点续传插件版示例 - tags: - - SimpleUploader - /simpleUploader/mergeFileMd5: - get: - parameters: - - description: md5 - in: query - name: md5 - required: true - type: string - produces: - - application/json - responses: - "200": - description: '{"success":true,"data":{},"msg":"合并成功"}' - schema: - type: string - security: - - ApiKeyAuth: [] - summary: 合并文件 - tags: - - SimpleUploader - /simpleUploader/upload: - post: - consumes: - - multipart/form-data - parameters: - - description: 断点续传插件版示例 - in: formData - name: file - required: true - type: file - produces: - - application/json - responses: - "200": - description: '{"success":true,"data":{},"msg":"切片创建成功"}' - schema: - type: string - security: - - ApiKeyAuth: [] - summary: 断点续传插件版示例 - tags: - - SimpleUploader /sysDictionary/createSysDictionary: post: consumes: @@ -2097,7 +2311,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionary' + $ref: '#/definitions/system.SysDictionary' produces: - application/json responses: @@ -2120,7 +2334,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionary' + $ref: '#/definitions/system.SysDictionary' produces: - application/json responses: @@ -2138,12 +2352,34 @@ paths: consumes: - application/json parameters: - - description: ID或字典英名 - in: body - name: data - required: true - schema: - $ref: '#/definitions/model.SysDictionary' + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 描述 + in: query + name: desc + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 字典名(中) + in: query + name: name + type: string + - description: 状态 + in: query + name: status + type: boolean + - description: 字典名(英) + in: query + name: type + type: string + - description: 更新时间 + in: query + name: updatedAt + type: string produces: - application/json responses: @@ -2161,12 +2397,42 @@ paths: consumes: - application/json parameters: - - description: 页码, 每页大小, 搜索条件 - in: body - name: data - required: true - schema: - $ref: '#/definitions/request.SysDictionarySearch' + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 描述 + in: query + name: desc + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 字典名(中) + in: query + name: name + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - description: 状态 + in: query + name: status + type: boolean + - description: 字典名(英) + in: query + name: type + type: string + - description: 更新时间 + in: query + name: updatedAt + type: string produces: - application/json responses: @@ -2189,7 +2455,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionary' + $ref: '#/definitions/system.SysDictionary' produces: - application/json responses: @@ -2212,7 +2478,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionaryDetail' + $ref: '#/definitions/system.SysDictionaryDetail' produces: - application/json responses: @@ -2235,7 +2501,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionaryDetail' + $ref: '#/definitions/system.SysDictionaryDetail' produces: - application/json responses: @@ -2253,12 +2519,38 @@ paths: consumes: - application/json parameters: - - description: 用id查询SysDictionaryDetail - in: body - name: data - required: true - schema: - $ref: '#/definitions/model.SysDictionaryDetail' + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 展示值 + in: query + name: label + type: string + - description: 排序标记 + in: query + name: sort + type: integer + - description: 启用状态 + in: query + name: status + type: boolean + - description: 关联标记 + in: query + name: sysDictionaryID + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + - description: 字典值 + in: query + name: value + type: integer produces: - application/json responses: @@ -2276,12 +2568,46 @@ paths: consumes: - application/json parameters: - - description: 页码, 每页大小, 搜索条件 - in: body - name: data - required: true - schema: - $ref: '#/definitions/request.SysDictionaryDetailSearch' + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 展示值 + in: query + name: label + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - description: 排序标记 + in: query + name: sort + type: integer + - description: 启用状态 + in: query + name: status + type: boolean + - description: 关联标记 + in: query + name: sysDictionaryID + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + - description: 字典值 + in: query + name: value + type: integer produces: - application/json responses: @@ -2304,7 +2630,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysDictionaryDetail' + $ref: '#/definitions/system.SysDictionaryDetail' produces: - application/json responses: @@ -2327,7 +2653,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysOperationRecord' + $ref: '#/definitions/system.SysOperationRecord' produces: - application/json responses: @@ -2350,7 +2676,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysOperationRecord' + $ref: '#/definitions/system.SysOperationRecord' produces: - application/json responses: @@ -2391,12 +2717,58 @@ paths: consumes: - application/json parameters: - - description: Id - in: body - name: data - required: true - schema: - $ref: '#/definitions/model.SysOperationRecord' + - description: 代理 + in: query + name: agent + type: string + - description: 请求Body + in: query + name: body + type: string + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 错误信息 + in: query + name: error_message + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 请求ip + in: query + name: ip + type: string + - description: 延迟 + in: query + name: latency + type: string + - description: 请求方法 + in: query + name: method + type: string + - description: 请求路径 + in: query + name: path + type: string + - description: 响应Body + in: query + name: resp + type: string + - description: 请求状态 + in: query + name: status + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + - description: 用户id + in: query + name: user_id + type: integer produces: - application/json responses: @@ -2414,12 +2786,66 @@ paths: consumes: - application/json parameters: - - description: 页码, 每页大小, 搜索条件 - in: body - name: data - required: true - schema: - $ref: '#/definitions/request.SysOperationRecordSearch' + - description: 代理 + in: query + name: agent + type: string + - description: 请求Body + in: query + name: body + type: string + - description: 创建时间 + in: query + name: createdAt + type: string + - description: 错误信息 + in: query + name: error_message + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 请求ip + in: query + name: ip + type: string + - description: 延迟 + in: query + name: latency + type: string + - description: 请求方法 + in: query + name: method + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - description: 请求路径 + in: query + name: path + type: string + - description: 响应Body + in: query + name: resp + type: string + - description: 请求状态 + in: query + name: status + type: integer + - description: 更新时间 + in: query + name: updatedAt + type: string + - description: 用户id + in: query + name: user_id + type: integer produces: - application/json responses: @@ -2482,7 +2908,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.System' + $ref: '#/definitions/system.System' produces: - application/json responses: @@ -2496,7 +2922,7 @@ paths: tags: - System /user/changePassword: - put: + post: parameters: - description: 用户名, 原密码, 新密码 in: body @@ -2539,6 +2965,22 @@ paths: summary: 删除用户 tags: - SysUser + /user/getUserInfo: + get: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 获取用户信息 + tags: + - SysUser /user/getUserList: post: consumes: @@ -2570,7 +3012,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysUser' + $ref: '#/definitions/request.Register' produces: - application/json responses: @@ -2581,6 +3023,29 @@ paths: summary: 用户注册账号 tags: - SysUser + /user/setUserAuthorities: + post: + consumes: + - application/json + parameters: + - description: 用户UUID, 角色ID + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.SetUserAuthorities' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"修改成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 设置用户权限 + tags: + - SysUser /user/setUserAuthority: post: consumes: @@ -2601,7 +3066,7 @@ paths: type: string security: - ApiKeyAuth: [] - summary: 设置用户权限 + summary: 更改用户权限 tags: - SysUser /user/setUserInfo: @@ -2614,7 +3079,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/model.SysUser' + $ref: '#/definitions/system.SysUser' produces: - application/json responses: diff --git a/server/global/global.go b/server/global/global.go index 43577a4c..404bb8ae 100644 --- a/server/global/global.go +++ b/server/global/global.go @@ -3,11 +3,13 @@ package global import ( "gin-vue-admin/utils/timer" + "golang.org/x/sync/singleflight" + "go.uber.org/zap" "gin-vue-admin/config" - "github.com/go-redis/redis" + "github.com/go-redis/redis/v8" "github.com/spf13/viper" "gorm.io/gorm" ) @@ -18,6 +20,7 @@ var ( GVA_CONFIG config.Server GVA_VP *viper.Viper //GVA_LOG *oplogging.Logger - GVA_LOG *zap.Logger - GVA_Timer timer.Timer = timer.NewTimerTask() + GVA_LOG *zap.Logger + GVA_Timer timer.Timer = timer.NewTimerTask() + GVA_Concurrency_Control = &singleflight.Group{} ) diff --git a/server/go.mod b/server/go.mod index 231eed65..19c98309 100644 --- a/server/go.mod +++ b/server/go.mod @@ -16,23 +16,22 @@ require ( github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 github.com/gin-gonic/gin v1.6.3 github.com/go-ole/go-ole v1.2.4 // indirect - github.com/go-openapi/spec v0.19.7 // indirect - github.com/go-openapi/swag v0.19.8 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/spec v0.20.3 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/validator/v10 v10.3.0 // indirect github.com/go-redis/redis v6.15.7+incompatible + github.com/go-redis/redis/v8 v8.11.0 github.com/go-sql-driver/mysql v1.5.0 - github.com/golang/protobuf v1.4.2 // indirect github.com/gookit/color v1.3.1 github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84 github.com/json-iterator/go v1.1.10 // indirect github.com/lestrrat-go/file-rotatelogs v2.3.0+incompatible github.com/lestrrat-go/strftime v1.0.3 // indirect - github.com/mailru/easyjson v0.7.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mitchellh/mapstructure v1.2.2 // indirect github.com/mojocn/base64Captcha v1.3.1 - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect github.com/pelletier/go-toml v1.6.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/qiniu/api.v7/v7 v7.4.1 @@ -44,17 +43,19 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 - github.com/swaggo/gin-swagger v1.2.0 - github.com/swaggo/swag v1.6.7 + github.com/swaggo/gin-swagger v1.3.0 + github.com/swaggo/swag v1.7.0 github.com/tebeka/strftime v0.1.3 // indirect github.com/tencentyun/cos-go-sdk-v5 v0.7.19 github.com/unrolled/secure v1.0.7 go.uber.org/zap v1.10.0 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect - golang.org/x/tools v0.0.0-20200324003944-a576cf524670 // indirect + golang.org/x/net v0.0.0-20210716203947-853a461950ff // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c + golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect + golang.org/x/tools v0.1.5 // indirect google.golang.org/protobuf v1.24.0 // indirect gopkg.in/ini.v1 v1.55.0 // indirect - gopkg.in/yaml.v2 v2.3.0 // indirect gorm.io/driver/mysql v1.0.1 gorm.io/gorm v1.20.7 ) diff --git a/server/initialize/gorm.go b/server/initialize/gorm.go index 7f726352..8a9b529e 100644 --- a/server/initialize/gorm.go +++ b/server/initialize/gorm.go @@ -3,7 +3,9 @@ package initialize import ( "gin-vue-admin/global" "gin-vue-admin/initialize/internal" - "gin-vue-admin/model" + "gin-vue-admin/model/autocode" + "gin-vue-admin/model/example" + "gin-vue-admin/model/system" "os" "go.uber.org/zap" @@ -34,22 +36,23 @@ func Gorm() *gorm.DB { func MysqlTables(db *gorm.DB) { err := db.AutoMigrate( - model.SysUser{}, - model.SysAuthority{}, - model.SysApi{}, - model.SysBaseMenu{}, - model.SysBaseMenuParameter{}, - model.JwtBlacklist{}, - model.SysDictionary{}, - model.SysDictionaryDetail{}, - model.ExaFileUploadAndDownload{}, - model.ExaFile{}, - model.ExaFileChunk{}, - model.ExaSimpleUploader{}, - model.ExaCustomer{}, - model.SysOperationRecord{}, - + system.SysUser{}, + system.SysAuthority{}, + system.SysApi{}, + system.SysBaseMenu{}, + system.SysBaseMenuParameter{}, + system.JwtBlacklist{}, + system.SysDictionary{}, + system.SysDictionaryDetail{}, + example.ExaFileUploadAndDownload{}, + example.ExaFile{}, + example.ExaFileChunk{}, + example.ExaSimpleUploader{}, + example.ExaCustomer{}, + system.SysOperationRecord{}, + system.SysAutoCodeHistory{}, // Code generated by gin-vue-admin Begin; DO NOT EDIT. + autocode.AutoCodeExample{}, // Code generated by gin-vue-admin End; DO NOT EDIT. ) if err != nil { @@ -59,7 +62,6 @@ func MysqlTables(db *gorm.DB) { global.GVA_LOG.Info("register table success") } -// //@author: SliverHorn //@function: GormMysql //@description: 初始化Mysql数据库 @@ -79,7 +81,7 @@ func GormMysql() *gorm.DB { DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列 SkipInitializeWithVersion: false, // 根据版本自动配置 } - if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig(m.LogMode)); err != nil { + if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig()); err != nil { //global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err)) //os.Exit(0) //return nil @@ -98,9 +100,9 @@ func GormMysql() *gorm.DB { //@param: mod bool //@return: *gorm.Config -func gormConfig(mod bool) *gorm.Config { - var config = &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true} - switch global.GVA_CONFIG.Mysql.LogZap { +func gormConfig() *gorm.Config { + config := &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true} + switch global.GVA_CONFIG.Mysql.LogMode { case "silent", "Silent": config.Logger = internal.Default.LogMode(logger.Silent) case "error", "Error": @@ -109,14 +111,8 @@ func gormConfig(mod bool) *gorm.Config { config.Logger = internal.Default.LogMode(logger.Warn) case "info", "Info": config.Logger = internal.Default.LogMode(logger.Info) - case "zap", "Zap": - config.Logger = internal.Default.LogMode(logger.Info) default: - if mod { - config.Logger = internal.Default.LogMode(logger.Info) - break - } - config.Logger = internal.Default.LogMode(logger.Silent) + config.Logger = internal.Default.LogMode(logger.Info) } return config } diff --git a/server/initialize/internal/logger.go b/server/initialize/internal/logger.go index e44f563c..c7fe9254 100644 --- a/server/initialize/internal/logger.go +++ b/server/initialize/internal/logger.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "gin-vue-admin/global" - "go.uber.org/zap" "gorm.io/gorm/logger" "gorm.io/gorm/utils" "io/ioutil" @@ -13,11 +12,6 @@ import ( "time" ) -// writer log writer interface -type writer interface { - Printf(string, ...interface{}) -} - type config struct { SlowThreshold time.Duration Colorful bool @@ -34,27 +28,27 @@ var ( Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()} ) -func New(writer writer, config config) logger.Interface { +func New(writer logger.Writer, config config) logger.Interface { var ( infoStr = "%s\n[info] " warnStr = "%s\n[warn] " errStr = "%s\n[error] " - traceStr = "%s\n[%.3fms] [rows:%v] %s" - traceWarnStr = "%s %s\n[%.3fms] [rows:%v] %s" - traceErrStr = "%s %s\n[%.3fms] [rows:%v] %s" + traceStr = "%s\n[%.3fms] [rows:%v] %s\n" + traceWarnStr = "%s %s\n[%.3fms] [rows:%v] %s\n" + traceErrStr = "%s %s\n[%.3fms] [rows:%v] %s\n" ) if config.Colorful { infoStr = logger.Green + "%s\n" + logger.Reset + logger.Green + "[info] " + logger.Reset warnStr = logger.BlueBold + "%s\n" + logger.Reset + logger.Magenta + "[warn] " + logger.Reset errStr = logger.Magenta + "%s\n" + logger.Reset + logger.Red + "[error] " + logger.Reset - traceStr = logger.Green + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s" - traceWarnStr = logger.Green + "%s " + logger.Yellow + "%s\n" + logger.Reset + logger.RedBold + "[%.3fms] " + logger.Yellow + "[rows:%v]" + logger.Magenta + " %s" + logger.Reset - traceErrStr = logger.RedBold + "%s " + logger.MagentaBold + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s" + traceStr = logger.Green + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s\n" + traceWarnStr = logger.Green + "%s " + logger.Yellow + "%s\n" + logger.Reset + logger.RedBold + "[%.3fms] " + logger.Yellow + "[rows:%v]" + logger.Magenta + " %s\n" + logger.Reset + traceErrStr = logger.RedBold + "%s " + logger.MagentaBold + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s\n" } - return &customLogger{ - writer: writer, + return &_logger{ + Writer: writer, config: config, infoStr: infoStr, warnStr: warnStr, @@ -65,43 +59,43 @@ func New(writer writer, config config) logger.Interface { } } -type customLogger struct { - writer +type _logger struct { config + logger.Writer infoStr, warnStr, errStr string traceStr, traceErrStr, traceWarnStr string } // LogMode log mode -func (c *customLogger) LogMode(level logger.LogLevel) logger.Interface { +func (c *_logger) LogMode(level logger.LogLevel) logger.Interface { newLogger := *c newLogger.LogLevel = level return &newLogger } // Info print info -func (c *customLogger) Info(ctx context.Context, message string, data ...interface{}) { +func (c *_logger) Info(ctx context.Context, message string, data ...interface{}) { if c.LogLevel >= logger.Info { c.Printf(c.infoStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...) } } // Warn print warn messages -func (c *customLogger) Warn(ctx context.Context, message string, data ...interface{}) { +func (c *_logger) Warn(ctx context.Context, message string, data ...interface{}) { if c.LogLevel >= logger.Warn { c.Printf(c.warnStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...) } } // Error print error messages -func (c *customLogger) Error(ctx context.Context, message string, data ...interface{}) { +func (c *_logger) Error(ctx context.Context, message string, data ...interface{}) { if c.LogLevel >= logger.Error { c.Printf(c.errStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...) } } // Trace print sql message -func (c *customLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { +func (c *_logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { if c.LogLevel > 0 { elapsed := time.Since(begin) switch { @@ -131,35 +125,11 @@ func (c *customLogger) Trace(ctx context.Context, begin time.Time, fc func() (st } } -func (c *customLogger) Printf(message string, data ...interface{}) { - if global.GVA_CONFIG.Mysql.LogZap != "" { - switch len(data) { - case 0: - global.GVA_LOG.Info(message) - case 1: - global.GVA_LOG.Info("gorm", zap.Any("src", data[0])) - case 2: - global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1])) - case 3: - global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1]), zap.Any("rows", data[2])) - case 4: - global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1]), zap.Any("rows", data[2]), zap.Any("sql", data[3])) - } - return - } - switch len(data) { - case 0: - c.writer.Printf(message, "") - case 1: - c.writer.Printf(message, data[0]) - case 2: - c.writer.Printf(message, data[0], data[1]) - case 3: - c.writer.Printf(message, data[0], data[1], data[2]) - case 4: - c.writer.Printf(message, data[0], data[1], data[2], data[3]) - case 5: - c.writer.Printf(message, data[0], data[1], data[2], data[3], data[4]) +func (c *_logger) Printf(message string, data ...interface{}) { + if global.GVA_CONFIG.Mysql.LogZap { + global.GVA_LOG.Info(fmt.Sprintf(message, data...)) + } else { + c.Writer.Printf(message, data...) } } diff --git a/server/initialize/redis.go b/server/initialize/redis.go index f9571ddf..6ecc5a8e 100644 --- a/server/initialize/redis.go +++ b/server/initialize/redis.go @@ -1,8 +1,10 @@ package initialize import ( + "context" "gin-vue-admin/global" - "github.com/go-redis/redis" + + "github.com/go-redis/redis/v8" "go.uber.org/zap" ) @@ -13,7 +15,7 @@ func Redis() { Password: redisCfg.Password, // no password set DB: redisCfg.DB, // use default DB }) - pong, err := client.Ping().Result() + pong, err := client.Ping(context.Background()).Result() if err != nil { global.GVA_LOG.Error("redis connect ping failed, err:", zap.Any("err", err)) } else { diff --git a/server/initialize/router.go b/server/initialize/router.go index 0744d258..213a3bbe 100644 --- a/server/initialize/router.go +++ b/server/initialize/router.go @@ -25,32 +25,38 @@ func Routers() *gin.Engine { Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) global.GVA_LOG.Info("register swagger handler") // 方便统一添加路由组前缀 多服务器上线使用 + + //获取路由组实例 + systemRouter := router.RouterGroupApp.System + exampleRouter := router.RouterGroupApp.Example + autocodeRouter := router.RouterGroupApp.Autocode PublicGroup := Router.Group("") { - router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权 - router.InitInitRouter(PublicGroup) // 自动初始化相关 + systemRouter.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权 + systemRouter.InitInitRouter(PublicGroup) // 自动初始化相关 } PrivateGroup := Router.Group("") PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) { - router.InitApiRouter(PrivateGroup) // 注册功能api路由 - router.InitJwtRouter(PrivateGroup) // jwt相关路由 - router.InitUserRouter(PrivateGroup) // 注册用户路由 - router.InitMenuRouter(PrivateGroup) // 注册menu路由 - router.InitEmailRouter(PrivateGroup) // 邮件相关路由 - router.InitSystemRouter(PrivateGroup) // system相关路由 - router.InitCasbinRouter(PrivateGroup) // 权限相关路由 - router.InitCustomerRouter(PrivateGroup) // 客户路由 - router.InitAutoCodeRouter(PrivateGroup) // 创建自动化代码 - router.InitAuthorityRouter(PrivateGroup) // 注册角色路由 - router.InitSimpleUploaderRouter(PrivateGroup) // 断点续传(插件版) - router.InitSysDictionaryRouter(PrivateGroup) // 字典管理 - router.InitSysOperationRecordRouter(PrivateGroup) // 操作记录 - router.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理 - router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由 - router.InitExcelRouter(PrivateGroup) // 表格导入导出 + systemRouter.InitApiRouter(PrivateGroup) // 注册功能api路由 + systemRouter.InitJwtRouter(PrivateGroup) // jwt相关路由 + systemRouter.InitUserRouter(PrivateGroup) // 注册用户路由 + systemRouter.InitMenuRouter(PrivateGroup) // 注册menu路由 + systemRouter.InitEmailRouter(PrivateGroup) // 邮件相关路由 + systemRouter.InitSystemRouter(PrivateGroup) // system相关路由 + systemRouter.InitCasbinRouter(PrivateGroup) // 权限相关路由 + systemRouter.InitAutoCodeRouter(PrivateGroup) // 创建自动化代码 + systemRouter.InitAuthorityRouter(PrivateGroup) // 注册角色路由 + systemRouter.InitSysDictionaryRouter(PrivateGroup) // 字典管理 + systemRouter.InitSysOperationRecordRouter(PrivateGroup) // 操作记录 + systemRouter.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理 + exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由 + exampleRouter.InitExcelRouter(PrivateGroup) // 表格导入导出 + exampleRouter.InitSimpleUploaderRouter(PrivateGroup) // 断点续传(插件版) + exampleRouter.InitCustomerRouter(PrivateGroup) // 客户路由 // Code generated by gin-vue-admin Begin; DO NOT EDIT. + autocodeRouter.InitSysAutoCodeExampleRouter(PrivateGroup) // Code generated by gin-vue-admin End; DO NOT EDIT. } global.GVA_LOG.Info("router register success") diff --git a/server/initialize/timer.go b/server/initialize/timer.go index 6fa27913..ecc41c8d 100644 --- a/server/initialize/timer.go +++ b/server/initialize/timer.go @@ -10,7 +10,6 @@ import ( func Timer() { if global.GVA_CONFIG.Timer.Start { for _, detail := range global.GVA_CONFIG.Timer.Detail { - fmt.Println(detail) go func(detail config.Detail) { global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() { err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval) diff --git a/server/main.go b/server/main.go index ee9080f1..ae8f256d 100644 --- a/server/main.go +++ b/server/main.go @@ -6,6 +6,11 @@ import ( "gin-vue-admin/initialize" ) +//go:generate go env -w GO111MODULE=on +//go:generate go env -w GOPROXY=https://goproxy.cn,direct +//go:generate go mod tidy +//go:generate go mod download + // @title Swagger Example API // @version 0.0.1 // @description This is a sample Server pets diff --git a/server/middleware/casbin_rbac.go b/server/middleware/casbin_rbac.go index e643335e..8812f10b 100644 --- a/server/middleware/casbin_rbac.go +++ b/server/middleware/casbin_rbac.go @@ -2,12 +2,14 @@ package middleware import ( "gin-vue-admin/global" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system/request" "gin-vue-admin/service" "github.com/gin-gonic/gin" ) +var casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService + // 拦截器 func CasbinHandler() gin.HandlerFunc { return func(c *gin.Context) { @@ -19,7 +21,7 @@ func CasbinHandler() gin.HandlerFunc { act := c.Request.Method // 获取用户的角色 sub := waitUse.AuthorityId - e := service.Casbin() + e := casbinService.Casbin() // 判断策略中是否存在 success, _ := e.Enforce(sub, obj, act) if global.GVA_CONFIG.System.Env == "develop" || success { diff --git a/server/middleware/email.go b/server/middleware/email.go index c9d4e79b..d6f0cbfd 100644 --- a/server/middleware/email.go +++ b/server/middleware/email.go @@ -2,8 +2,8 @@ package middleware import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" + "gin-vue-admin/model/system" + "gin-vue-admin/model/system/request" "gin-vue-admin/service" "gin-vue-admin/utils" "github.com/gin-gonic/gin" @@ -13,6 +13,8 @@ import ( "time" ) +var userService = service.ServiceGroupApp.SystemServiceGroup.UserService + func ErrorToEmail() gin.HandlerFunc { return func(c *gin.Context) { var username string @@ -21,14 +23,14 @@ func ErrorToEmail() gin.HandlerFunc { username = waitUse.Username } else { id, _ := strconv.Atoi(c.Request.Header.Get("x-user-id")) - err, user := service.FindUserById(id) + err, user := userService.FindUserById(id) if err != nil { username = "Unknown" } username = user.Username } body, _ := ioutil.ReadAll(c.Request.Body) - record := model.SysOperationRecord{ + record := system.SysOperationRecord{ Ip: c.ClientIP(), Method: c.Request.Method, Path: c.Request.URL.Path, diff --git a/server/middleware/jwt.go b/server/middleware/jwt.go index 56343a3e..74b285dc 100644 --- a/server/middleware/jwt.go +++ b/server/middleware/jwt.go @@ -3,17 +3,20 @@ package middleware import ( "errors" "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" + "gin-vue-admin/model/common/response" + "gin-vue-admin/model/system" + "gin-vue-admin/model/system/request" "gin-vue-admin/service" + "strconv" + "time" + "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "go.uber.org/zap" - "strconv" - "time" ) +var jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService + func JWTAuth() gin.HandlerFunc { return func(c *gin.Context) { // 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localStorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录 @@ -23,7 +26,7 @@ func JWTAuth() gin.HandlerFunc { c.Abort() return } - if service.IsBlacklist(token) { + if jwtService.IsBlacklist(token) { response.FailWithDetailed(gin.H{"reload": true}, "您的帐户异地登陆或令牌失效", c) c.Abort() return @@ -41,26 +44,26 @@ func JWTAuth() gin.HandlerFunc { c.Abort() return } - if err, _ = service.FindUserByUuid(claims.UUID.String()); err != nil { - _ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: token}) + if err, _ = userService.FindUserByUuid(claims.UUID.String()); err != nil { + _ = jwtService.JsonInBlacklist(system.JwtBlacklist{Jwt: token}) response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c) c.Abort() } if claims.ExpiresAt-time.Now().Unix() < claims.BufferTime { claims.ExpiresAt = time.Now().Unix() + global.GVA_CONFIG.JWT.ExpiresTime - newToken, _ := j.CreateToken(*claims) + newToken, _ := j.CreateTokenByOldToken(token, *claims) newClaims, _ := j.ParseToken(newToken) c.Header("new-token", newToken) c.Header("new-expires-at", strconv.FormatInt(newClaims.ExpiresAt, 10)) if global.GVA_CONFIG.System.UseMultipoint { - err, RedisJwtToken := service.GetRedisJWT(newClaims.Username) + err, RedisJwtToken := jwtService.GetRedisJWT(newClaims.Username) if err != nil { global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err)) } else { // 当之前的取成功时才进行拉黑操作 - _ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken}) + _ = jwtService.JsonInBlacklist(system.JwtBlacklist{Jwt: RedisJwtToken}) } // 无论如何都要记录当前的活跃状态 - _ = service.SetRedisJWT(newToken, newClaims.Username) + _ = jwtService.SetRedisJWT(newToken, newClaims.Username) } } c.Set("claims", claims) @@ -91,6 +94,14 @@ func (j *JWT) CreateToken(claims request.CustomClaims) (string, error) { return token.SignedString(j.SigningKey) } +// CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题 +func (j *JWT) CreateTokenByOldToken(oldToken string, claims request.CustomClaims) (string, error) { + v, err, _ := global.GVA_Concurrency_Control.Do("JWT:"+oldToken, func() (interface{}, error) { + return j.CreateToken(claims) + }) + return v.(string), err +} + // 解析 token func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error) { token, err := jwt.ParseWithClaims(tokenString, &request.CustomClaims{}, func(token *jwt.Token) (i interface{}, e error) { diff --git a/server/middleware/need_init.go b/server/middleware/need_init.go index 4263dd9c..c883bb81 100644 --- a/server/middleware/need_init.go +++ b/server/middleware/need_init.go @@ -2,7 +2,7 @@ package middleware import ( "gin-vue-admin/global" - "gin-vue-admin/model/response" + "gin-vue-admin/model/common/response" "github.com/gin-gonic/gin" ) diff --git a/server/middleware/operation.go b/server/middleware/operation.go index 3c4ea2b6..2bfa25b5 100644 --- a/server/middleware/operation.go +++ b/server/middleware/operation.go @@ -3,8 +3,8 @@ package middleware import ( "bytes" "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" + "gin-vue-admin/model/system" + "gin-vue-admin/model/system/request" "gin-vue-admin/service" "github.com/gin-gonic/gin" "go.uber.org/zap" @@ -14,6 +14,8 @@ import ( "time" ) +var operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService + func OperationRecord() gin.HandlerFunc { return func(c *gin.Context) { var body []byte @@ -37,7 +39,7 @@ func OperationRecord() gin.HandlerFunc { } userId = id } - record := model.SysOperationRecord{ + record := system.SysOperationRecord{ Ip: c.ClientIP(), Method: c.Request.Method, Path: c.Request.URL.Path, @@ -65,7 +67,7 @@ func OperationRecord() gin.HandlerFunc { record.Latency = latency record.Resp = writer.body.String() - if err := service.CreateSysOperationRecord(record); err != nil { + if err := operationRecordService.CreateSysOperationRecord(record); err != nil { global.GVA_LOG.Error("create operation record error:", zap.Any("err", err)) } } diff --git a/server/model/autocode/autocodeExample.go b/server/model/autocode/autocodeExample.go new file mode 100644 index 00000000..e3c64a90 --- /dev/null +++ b/server/model/autocode/autocodeExample.go @@ -0,0 +1,12 @@ +// 自动生成模板SysDictionaryDetail +package autocode + +import ( + "gin-vue-admin/global" +) + +// 如果含有time.Time 请自行import time包 +type AutoCodeExample struct { + global.GVA_MODEL + AutoCodeExampleField string `json:"autoCodeExampleField" form:"autoCodeExampleField" gorm:"column:auto_code_example_field;comment:仅作示例条目无实际作用"` // 展示值 +} diff --git a/server/model/autocode/request/autocodeExample.go b/server/model/autocode/request/autocodeExample.go new file mode 100644 index 00000000..cdfa48f9 --- /dev/null +++ b/server/model/autocode/request/autocodeExample.go @@ -0,0 +1,13 @@ +// 自动生成模板SysDictionaryDetail +package request + +import ( + "gin-vue-admin/model/autocode" + "gin-vue-admin/model/common/request" +) + +// 如果含有time.Time 请自行import time包 +type AutoCodeExampleSearch struct { + autocode.AutoCodeExample + request.PageInfo +} diff --git a/server/model/request/common.go b/server/model/common/request/common.go similarity index 100% rename from server/model/request/common.go rename to server/model/common/request/common.go diff --git a/server/model/response/common.go b/server/model/common/response/common.go similarity index 100% rename from server/model/response/common.go rename to server/model/common/response/common.go diff --git a/server/model/response/response.go b/server/model/common/response/response.go similarity index 100% rename from server/model/response/response.go rename to server/model/common/response/response.go diff --git a/server/model/exa_customer.go b/server/model/exa_customer.go deleted file mode 100644 index 066032c5..00000000 --- a/server/model/exa_customer.go +++ /dev/null @@ -1,14 +0,0 @@ -package model - -import ( - "gin-vue-admin/global" -) - -type ExaCustomer struct { - global.GVA_MODEL - CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"` // 客户名 - CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"` // 客户手机号 - SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"` // 管理ID - SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"` // 管理角色ID - SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"` // 管理详情 -} diff --git a/server/model/exa_excel.go b/server/model/exa_excel.go deleted file mode 100644 index facaceb8..00000000 --- a/server/model/exa_excel.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -type ExcelInfo struct { - FileName string `json:"fileName"` // 文件名 - InfoList []SysBaseMenu `json:"infoList"` -} diff --git a/server/model/exa_breakpoint_continue.go b/server/model/example/exa_breakpoint_continue.go similarity index 96% rename from server/model/exa_breakpoint_continue.go rename to server/model/example/exa_breakpoint_continue.go index 9dd6e253..4505100c 100644 --- a/server/model/exa_breakpoint_continue.go +++ b/server/model/example/exa_breakpoint_continue.go @@ -1,4 +1,4 @@ -package model +package example import ( "gin-vue-admin/global" diff --git a/server/model/example/exa_customer.go b/server/model/example/exa_customer.go new file mode 100644 index 00000000..6955ba9c --- /dev/null +++ b/server/model/example/exa_customer.go @@ -0,0 +1,15 @@ +package example + +import ( + "gin-vue-admin/global" + "gin-vue-admin/model/system" +) + +type ExaCustomer struct { + global.GVA_MODEL + CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"` // 客户名 + CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"` // 客户手机号 + SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"` // 管理ID + SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"` // 管理角色ID + SysUser system.SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"` // 管理详情 +} diff --git a/server/model/example/exa_excel.go b/server/model/example/exa_excel.go new file mode 100644 index 00000000..a84e62de --- /dev/null +++ b/server/model/example/exa_excel.go @@ -0,0 +1,8 @@ +package example + +import "gin-vue-admin/model/system" + +type ExcelInfo struct { + FileName string `json:"fileName"` // 文件名 + InfoList []system.SysBaseMenu `json:"infoList"` +} diff --git a/server/model/exa_file_upload_download.go b/server/model/example/exa_file_upload_download.go similarity index 95% rename from server/model/exa_file_upload_download.go rename to server/model/example/exa_file_upload_download.go index 5504375f..1299440f 100644 --- a/server/model/exa_file_upload_download.go +++ b/server/model/example/exa_file_upload_download.go @@ -1,4 +1,4 @@ -package model +package example import ( "gin-vue-admin/global" diff --git a/server/model/exa_simple_uploader.go b/server/model/example/exa_simple_uploader.go similarity index 97% rename from server/model/exa_simple_uploader.go rename to server/model/example/exa_simple_uploader.go index 4e5285fd..1e7e82a7 100644 --- a/server/model/exa_simple_uploader.go +++ b/server/model/example/exa_simple_uploader.go @@ -1,4 +1,4 @@ -package model +package example type ExaSimpleUploader struct { ChunkNumber string `json:"chunkNumber" gorm:"comment:当前切片标记"` diff --git a/server/model/response/exa_breakpoint_continue.go b/server/model/example/response/exa_breakpoint_continue.go similarity index 61% rename from server/model/response/exa_breakpoint_continue.go rename to server/model/example/response/exa_breakpoint_continue.go index 43596696..55c1235c 100644 --- a/server/model/response/exa_breakpoint_continue.go +++ b/server/model/example/response/exa_breakpoint_continue.go @@ -1,11 +1,11 @@ package response -import "gin-vue-admin/model" +import "gin-vue-admin/model/example" type FilePathResponse struct { FilePath string `json:"filePath"` } type FileResponse struct { - File model.ExaFile `json:"file"` + File example.ExaFile `json:"file"` } diff --git a/server/model/example/response/exa_customer.go b/server/model/example/response/exa_customer.go new file mode 100644 index 00000000..36efc075 --- /dev/null +++ b/server/model/example/response/exa_customer.go @@ -0,0 +1,7 @@ +package response + +import "gin-vue-admin/model/example" + +type ExaCustomerResponse struct { + Customer example.ExaCustomer `json:"customer"` +} diff --git a/server/model/example/response/exa_file_upload_download.go b/server/model/example/response/exa_file_upload_download.go new file mode 100644 index 00000000..e04bd5f3 --- /dev/null +++ b/server/model/example/response/exa_file_upload_download.go @@ -0,0 +1,7 @@ +package response + +import "gin-vue-admin/model/example" + +type ExaFileResponse struct { + File example.ExaFileUploadAndDownload `json:"file"` +} diff --git a/server/model/request/sys_casbin.go b/server/model/request/sys_casbin.go deleted file mode 100644 index ccb461b8..00000000 --- a/server/model/request/sys_casbin.go +++ /dev/null @@ -1,13 +0,0 @@ -package request - -// Casbin info structure -type CasbinInfo struct { - Path string `json:"path"` // 路径 - Method string `json:"method"` // 方法 -} - -// Casbin structure for input parameters -type CasbinInReceive struct { - AuthorityId string `json:"authorityId"` // 权限id - CasbinInfos []CasbinInfo `json:"casbinInfos"` -} diff --git a/server/model/request/sys_dictionary.go b/server/model/request/sys_dictionary.go deleted file mode 100644 index abd8ff04..00000000 --- a/server/model/request/sys_dictionary.go +++ /dev/null @@ -1,8 +0,0 @@ -package request - -import "gin-vue-admin/model" - -type SysDictionarySearch struct { - model.SysDictionary - PageInfo -} diff --git a/server/model/request/sys_dictionary_detail.go b/server/model/request/sys_dictionary_detail.go deleted file mode 100644 index 8b5e1065..00000000 --- a/server/model/request/sys_dictionary_detail.go +++ /dev/null @@ -1,8 +0,0 @@ -package request - -import "gin-vue-admin/model" - -type SysDictionaryDetailSearch struct { - model.SysDictionaryDetail - PageInfo -} diff --git a/server/model/request/sys_menu.go b/server/model/request/sys_menu.go deleted file mode 100644 index 0c4b95da..00000000 --- a/server/model/request/sys_menu.go +++ /dev/null @@ -1,9 +0,0 @@ -package request - -import "gin-vue-admin/model" - -// Add menu authority info structure -type AddMenuAuthorityInfo struct { - Menus []model.SysBaseMenu - AuthorityId string // 角色ID -} diff --git a/server/model/request/sys_operation_record.go b/server/model/request/sys_operation_record.go deleted file mode 100644 index a9b7abbe..00000000 --- a/server/model/request/sys_operation_record.go +++ /dev/null @@ -1,8 +0,0 @@ -package request - -import "gin-vue-admin/model" - -type SysOperationRecordSearch struct { - model.SysOperationRecord - PageInfo -} diff --git a/server/model/response/exa_customer.go b/server/model/response/exa_customer.go deleted file mode 100644 index 3a4102ac..00000000 --- a/server/model/response/exa_customer.go +++ /dev/null @@ -1,7 +0,0 @@ -package response - -import "gin-vue-admin/model" - -type ExaCustomerResponse struct { - Customer model.ExaCustomer `json:"customer"` -} diff --git a/server/model/response/exa_file_upload_download.go b/server/model/response/exa_file_upload_download.go deleted file mode 100644 index 56dbc0fc..00000000 --- a/server/model/response/exa_file_upload_download.go +++ /dev/null @@ -1,7 +0,0 @@ -package response - -import "gin-vue-admin/model" - -type ExaFileResponse struct { - File model.ExaFileUploadAndDownload `json:"file"` -} diff --git a/server/model/response/sys_api.go b/server/model/response/sys_api.go deleted file mode 100644 index d3025fdb..00000000 --- a/server/model/response/sys_api.go +++ /dev/null @@ -1,11 +0,0 @@ -package response - -import "gin-vue-admin/model" - -type SysAPIResponse struct { - Api model.SysApi `json:"api"` -} - -type SysAPIListResponse struct { - Apis []model.SysApi `json:"apis"` -} diff --git a/server/model/response/sys_authority.go b/server/model/response/sys_authority.go deleted file mode 100644 index 7b1f75d8..00000000 --- a/server/model/response/sys_authority.go +++ /dev/null @@ -1,12 +0,0 @@ -package response - -import "gin-vue-admin/model" - -type SysAuthorityResponse struct { - Authority model.SysAuthority `json:"authority"` -} - -type SysAuthorityCopyResponse struct { - Authority model.SysAuthority `json:"authority"` - OldAuthorityId string `json:"oldAuthorityId"` // 旧角色ID -} diff --git a/server/model/response/sys_menu.go b/server/model/response/sys_menu.go deleted file mode 100644 index 6c7dbbdf..00000000 --- a/server/model/response/sys_menu.go +++ /dev/null @@ -1,15 +0,0 @@ -package response - -import "gin-vue-admin/model" - -type SysMenusResponse struct { - Menus []model.SysMenu `json:"menus"` -} - -type SysBaseMenusResponse struct { - Menus []model.SysBaseMenu `json:"menus"` -} - -type SysBaseMenuResponse struct { - Menu model.SysBaseMenu `json:"menu"` -} diff --git a/server/model/response/sys_user.go b/server/model/response/sys_user.go deleted file mode 100644 index 75d92827..00000000 --- a/server/model/response/sys_user.go +++ /dev/null @@ -1,15 +0,0 @@ -package response - -import ( - "gin-vue-admin/model" -) - -type SysUserResponse struct { - User model.SysUser `json:"user"` -} - -type LoginResponse struct { - User model.SysUser `json:"user"` - Token string `json:"token"` - ExpiresAt int64 `json:"expiresAt"` -} diff --git a/server/model/sys_base_menu.go b/server/model/sys_base_menu.go deleted file mode 100644 index 83a287b7..00000000 --- a/server/model/sys_base_menu.go +++ /dev/null @@ -1,36 +0,0 @@ -package model - -import ( - "gin-vue-admin/global" -) - -type SysBaseMenu struct { - global.GVA_MODEL - MenuLevel uint `json:"-"` - ParentId string `json:"parentId" gorm:"comment:父菜单ID"` // 父菜单ID - Path string `json:"path" gorm:"comment:路由path"` // 路由path - Name string `json:"name" gorm:"comment:路由name"` // 路由name - Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"` // 是否在列表隐藏 - Component string `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径 - Sort int `json:"sort" gorm:"comment:排序标记"` // 排序标记 - Meta `json:"meta" gorm:"comment:附加属性"` // 附加属性 - SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"` - Children []SysBaseMenu `json:"children" gorm:"-"` - Parameters []SysBaseMenuParameter `json:"parameters"` -} - -type Meta struct { - KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"` // 是否缓存 - DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中) - Title string `json:"title" gorm:"comment:菜单名"` // 菜单名 - Icon string `json:"icon" gorm:"comment:菜单图标"` // 菜单图标 - CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"` // 自动关闭tab -} - -type SysBaseMenuParameter struct { - global.GVA_MODEL - SysBaseMenuID uint - Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"` // 地址栏携带参数为params还是query - Key string `json:"key" gorm:"comment:地址栏携带参数的key"` // 地址栏携带参数的key - Value string `json:"value" gorm:"comment:地址栏携带参数的值"` // 地址栏携带参数的值 -} diff --git a/server/model/sys_user.go b/server/model/sys_user.go deleted file mode 100644 index 4c7a2aac..00000000 --- a/server/model/sys_user.go +++ /dev/null @@ -1,17 +0,0 @@ -package model - -import ( - "gin-vue-admin/global" - "github.com/satori/go.uuid" -) - -type SysUser struct { - global.GVA_MODEL - UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID - Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 - Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码 - NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 - HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像 - Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` - AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID -} diff --git a/server/model/request/jwt.go b/server/model/system/request/jwt.go similarity index 100% rename from server/model/request/jwt.go rename to server/model/system/request/jwt.go diff --git a/server/model/request/sys_api.go b/server/model/system/request/sys_api.go similarity index 66% rename from server/model/request/sys_api.go rename to server/model/system/request/sys_api.go index f9d5ec03..d86e8c89 100644 --- a/server/model/request/sys_api.go +++ b/server/model/system/request/sys_api.go @@ -1,11 +1,14 @@ package request -import "gin-vue-admin/model" +import ( + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/system" +) // api分页条件查询及排序结构体 type SearchApiParams struct { - model.SysApi - PageInfo + system.SysApi + request.PageInfo OrderKey string `json:"orderKey"` // 排序 Desc bool `json:"desc"` // 排序方式:升序false(默认)|降序true } diff --git a/server/model/request/sys_autocode.go b/server/model/system/request/sys_autocode.go similarity index 75% rename from server/model/request/sys_autocode.go rename to server/model/system/request/sys_autocode.go index d97be350..9cfa2880 100644 --- a/server/model/request/sys_autocode.go +++ b/server/model/system/request/sys_autocode.go @@ -1,5 +1,15 @@ package request +import "gin-vue-admin/model/common/request" + +type SysAutoHistory struct { + request.PageInfo +} + +type AutoHistoryByID struct { + ID uint `json:"id"` +} + type DBReq struct { Database string `json:"database" gorm:"column:database"` } diff --git a/server/model/system/request/sys_casbin.go b/server/model/system/request/sys_casbin.go new file mode 100644 index 00000000..d0031dcf --- /dev/null +++ b/server/model/system/request/sys_casbin.go @@ -0,0 +1,26 @@ +package request + +// Casbin info structure +type CasbinInfo struct { + Path string `json:"path"` // 路径 + Method string `json:"method"` // 方法 +} + +// Casbin structure for input parameters +type CasbinInReceive struct { + AuthorityId string `json:"authorityId"` // 权限id + CasbinInfos []CasbinInfo `json:"casbinInfos"` +} + +func DefaultCasbin() []CasbinInfo { + return []CasbinInfo{ + {Path: "/menu/getMenu", Method: "POST"}, + {Path: "/jwt/jsonInBlacklist", Method: "POST"}, + {Path: "/base/login", Method: "POST"}, + {Path: "/user/register", Method: "POST"}, + {Path: "/user/changePassword", Method: "POST"}, + {Path: "/user/setUserAuthority", Method: "POST"}, + {Path: "/user/setUserInfo", Method: "PUT"}, + {Path: "/user/getUserInfo", Method: "GET"}, + } +} diff --git a/server/model/system/request/sys_dictionary.go b/server/model/system/request/sys_dictionary.go new file mode 100644 index 00000000..4402daa7 --- /dev/null +++ b/server/model/system/request/sys_dictionary.go @@ -0,0 +1,11 @@ +package request + +import ( + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/system" +) + +type SysDictionarySearch struct { + system.SysDictionary + request.PageInfo +} diff --git a/server/model/system/request/sys_dictionary_detail.go b/server/model/system/request/sys_dictionary_detail.go new file mode 100644 index 00000000..5d688e64 --- /dev/null +++ b/server/model/system/request/sys_dictionary_detail.go @@ -0,0 +1,11 @@ +package request + +import ( + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/system" +) + +type SysDictionaryDetailSearch struct { + system.SysDictionaryDetail + request.PageInfo +} diff --git a/server/model/request/sys_init.go b/server/model/system/request/sys_init.go similarity index 100% rename from server/model/request/sys_init.go rename to server/model/system/request/sys_init.go diff --git a/server/model/system/request/sys_menu.go b/server/model/system/request/sys_menu.go new file mode 100644 index 00000000..c19ee6ae --- /dev/null +++ b/server/model/system/request/sys_menu.go @@ -0,0 +1,27 @@ +package request + +import ( + "gin-vue-admin/global" + "gin-vue-admin/model/system" +) + +// Add menu authority info structure +type AddMenuAuthorityInfo struct { + Menus []system.SysBaseMenu + AuthorityId string // 角色ID +} + +func DefaultMenu() []system.SysBaseMenu { + return []system.SysBaseMenu{{ + GVA_MODEL: global.GVA_MODEL{ID: 1}, + ParentId: "0", + Path: "dashboard", + Name: "dashboard", + Component: "view/dashboard/index.vue", + Sort: 1, + Meta: system.Meta{ + Title: "仪表盘", + Icon: "setting", + }, + }} +} diff --git a/server/model/system/request/sys_operation_record.go b/server/model/system/request/sys_operation_record.go new file mode 100644 index 00000000..03506330 --- /dev/null +++ b/server/model/system/request/sys_operation_record.go @@ -0,0 +1,11 @@ +package request + +import ( + "gin-vue-admin/model/common/request" + "gin-vue-admin/model/system" +) + +type SysOperationRecordSearch struct { + system.SysOperationRecord + request.PageInfo +} diff --git a/server/model/request/sys_user.go b/server/model/system/request/sys_user.go similarity index 52% rename from server/model/request/sys_user.go rename to server/model/system/request/sys_user.go index f2b147ed..84ab1ef4 100644 --- a/server/model/request/sys_user.go +++ b/server/model/system/request/sys_user.go @@ -1,14 +1,13 @@ package request -import uuid "github.com/satori/go.uuid" - // User register structure type Register struct { - Username string `json:"userName"` - Password string `json:"passWord"` - NickName string `json:"nickName" gorm:"default:'QMPlusUser'"` - HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"` - AuthorityId string `json:"authorityId" gorm:"default:888"` + Username string `json:"userName"` + Password string `json:"passWord"` + NickName string `json:"nickName" gorm:"default:'QMPlusUser'"` + HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"` + AuthorityId string `json:"authorityId" gorm:"default:888"` + AuthorityIds []string `json:"authorityIds"` } // User login structure @@ -28,6 +27,11 @@ type ChangePasswordStruct struct { // Modify user's auth structure type SetUserAuth struct { - UUID uuid.UUID `json:"uuid"` // 用户UUID - AuthorityId string `json:"authorityId"` // 角色ID + AuthorityId string `json:"authorityId"` // 角色ID +} + +// Modify user's auth structure +type SetUserAuthorities struct { + ID uint + AuthorityIds []string `json:"authorityIds"` // 角色ID } diff --git a/server/model/system/response/sys_api.go b/server/model/system/response/sys_api.go new file mode 100644 index 00000000..35492a13 --- /dev/null +++ b/server/model/system/response/sys_api.go @@ -0,0 +1,11 @@ +package response + +import "gin-vue-admin/model/system" + +type SysAPIResponse struct { + Api system.SysApi `json:"api"` +} + +type SysAPIListResponse struct { + Apis []system.SysApi `json:"apis"` +} diff --git a/server/model/system/response/sys_authority.go b/server/model/system/response/sys_authority.go new file mode 100644 index 00000000..5a107802 --- /dev/null +++ b/server/model/system/response/sys_authority.go @@ -0,0 +1,12 @@ +package response + +import "gin-vue-admin/model/system" + +type SysAuthorityResponse struct { + Authority system.SysAuthority `json:"authority"` +} + +type SysAuthorityCopyResponse struct { + Authority system.SysAuthority `json:"authority"` + OldAuthorityId string `json:"oldAuthorityId"` // 旧角色ID +} diff --git a/server/model/response/sys_captcha.go b/server/model/system/response/sys_captcha.go similarity index 100% rename from server/model/response/sys_captcha.go rename to server/model/system/response/sys_captcha.go diff --git a/server/model/response/sys_casbin.go b/server/model/system/response/sys_casbin.go similarity index 66% rename from server/model/response/sys_casbin.go rename to server/model/system/response/sys_casbin.go index 5bf962c2..ef57bc3f 100644 --- a/server/model/response/sys_casbin.go +++ b/server/model/system/response/sys_casbin.go @@ -1,6 +1,8 @@ package response -import "gin-vue-admin/model/request" +import ( + "gin-vue-admin/model/system/request" +) type PolicyPathResponse struct { Paths []request.CasbinInfo `json:"paths"` diff --git a/server/model/system/response/sys_menu.go b/server/model/system/response/sys_menu.go new file mode 100644 index 00000000..26bcc1c1 --- /dev/null +++ b/server/model/system/response/sys_menu.go @@ -0,0 +1,15 @@ +package response + +import "gin-vue-admin/model/system" + +type SysMenusResponse struct { + Menus []system.SysMenu `json:"menus"` +} + +type SysBaseMenusResponse struct { + Menus []system.SysBaseMenu `json:"menus"` +} + +type SysBaseMenuResponse struct { + Menu system.SysBaseMenu `json:"menu"` +} diff --git a/server/model/response/sys_system.go b/server/model/system/response/sys_system.go similarity index 100% rename from server/model/response/sys_system.go rename to server/model/system/response/sys_system.go diff --git a/server/model/system/response/sys_user.go b/server/model/system/response/sys_user.go new file mode 100644 index 00000000..91602311 --- /dev/null +++ b/server/model/system/response/sys_user.go @@ -0,0 +1,15 @@ +package response + +import ( + "gin-vue-admin/model/system" +) + +type SysUserResponse struct { + User system.SysUser `json:"user"` +} + +type LoginResponse struct { + User system.SysUser `json:"user"` + Token string `json:"token"` + ExpiresAt int64 `json:"expiresAt"` +} diff --git a/server/model/sys_api.go b/server/model/system/sys_api.go similarity index 52% rename from server/model/sys_api.go rename to server/model/system/sys_api.go index 20d9b657..ce945a6f 100644 --- a/server/model/sys_api.go +++ b/server/model/system/sys_api.go @@ -1,4 +1,4 @@ -package model +package system import ( "gin-vue-admin/global" @@ -6,8 +6,8 @@ import ( type SysApi struct { global.GVA_MODEL - Path string `json:"path" gorm:"comment:api路径"` // api路径 - Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述 - ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组 - Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE + Path string `json:"path" gorm:"comment:api路径"` // api路径 + Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述 + ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组 + Method string `json:"method" gorm:"default:POST;comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE } diff --git a/server/model/sys_authority.go b/server/model/system/sys_authority.go similarity index 98% rename from server/model/sys_authority.go rename to server/model/system/sys_authority.go index de2964ae..580b0b9f 100644 --- a/server/model/sys_authority.go +++ b/server/model/system/sys_authority.go @@ -1,4 +1,4 @@ -package model +package system import ( "time" diff --git a/server/model/sys_authority_menu.go b/server/model/system/sys_authority_menu.go similarity index 96% rename from server/model/sys_authority_menu.go rename to server/model/system/sys_authority_menu.go index 23ee4ab2..7af5f54d 100644 --- a/server/model/sys_authority_menu.go +++ b/server/model/system/sys_authority_menu.go @@ -1,4 +1,4 @@ -package model +package system type SysMenu struct { SysBaseMenu diff --git a/server/model/sys_auto_code.go b/server/model/system/sys_auto_code.go similarity index 94% rename from server/model/sys_auto_code.go rename to server/model/system/sys_auto_code.go index 6e9e0bde..7047b810 100644 --- a/server/model/sys_auto_code.go +++ b/server/model/system/sys_auto_code.go @@ -1,4 +1,4 @@ -package model +package system import "errors" @@ -7,6 +7,7 @@ type AutoCodeStruct struct { StructName string `json:"structName"` // Struct名称 TableName string `json:"tableName"` // 表名 PackageName string `json:"packageName"` // 文件名称 + HumpPackageName string `json:"humpPackageName"` // go文件名称 Abbreviation string `json:"abbreviation"` // Struct简称 Description string `json:"description"` // Struct中文名称 AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api diff --git a/server/model/system/sys_autocode_history.go b/server/model/system/sys_autocode_history.go new file mode 100644 index 00000000..aef66c6b --- /dev/null +++ b/server/model/system/sys_autocode_history.go @@ -0,0 +1,18 @@ +package system + +import "gin-vue-admin/global" + +// 自动迁移代码记录,用于回滚,重放使用 + +type SysAutoCodeHistory struct { + global.GVA_MODEL + TableName string `json:"tableName"` + RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息 + AutoCodePath string `gorm:"type:text" json:"autoCodePath,omitempty"` // 其他meta信息 path;path + InjectionMeta string `gorm:"type:text" json:"injectionMeta,omitempty"` // 注入的内容 RouterPath@functionName@RouterString; + StructName string `json:"structName"` + StructCNName string `json:"structCNName"` + ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容 + Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ... + +} diff --git a/server/model/system/sys_base_menu.go b/server/model/system/sys_base_menu.go new file mode 100644 index 00000000..84c3b416 --- /dev/null +++ b/server/model/system/sys_base_menu.go @@ -0,0 +1,36 @@ +package system + +import ( + "gin-vue-admin/global" +) + +type SysBaseMenu struct { + global.GVA_MODEL + MenuLevel uint `json:"-"` + ParentId string `json:"parentId" gorm:"comment:父菜单ID"` // 父菜单ID + Path string `json:"path" gorm:"comment:路由path"` // 路由path + Name string `json:"name" gorm:"comment:路由name"` // 路由name + Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"` // 是否在列表隐藏 + Component string `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径 + Sort int `json:"sort" gorm:"comment:排序标记"` // 排序标记 + Meta `json:"meta" gorm:"comment:附加属性"` // 附加属性 + SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"` + Children []SysBaseMenu `json:"children" gorm:"-"` + Parameters []SysBaseMenuParameter `json:"parameters"` +} + +type Meta struct { + KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"` // 是否缓存 + DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中) + Title string `json:"title" gorm:"comment:菜单名"` // 菜单名 + Icon string `json:"icon" gorm:"comment:菜单图标"` // 菜单图标 + CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"` // 自动关闭tab +} + +type SysBaseMenuParameter struct { + global.GVA_MODEL + SysBaseMenuID uint + Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"` // 地址栏携带参数为params还是query + Key string `json:"key" gorm:"comment:地址栏携带参数的key"` // 地址栏携带参数的key + Value string `json:"value" gorm:"comment:地址栏携带参数的值"` // 地址栏携带参数的值 +} diff --git a/server/model/sys_casbin.go b/server/model/system/sys_casbin.go similarity index 94% rename from server/model/sys_casbin.go rename to server/model/system/sys_casbin.go index 9bb19886..d205bb95 100644 --- a/server/model/sys_casbin.go +++ b/server/model/system/sys_casbin.go @@ -1,4 +1,4 @@ -package model +package system type CasbinModel struct { Ptype string `json:"ptype" gorm:"column:ptype"` diff --git a/server/model/sys_dictionary.go b/server/model/system/sys_dictionary.go similarity index 98% rename from server/model/sys_dictionary.go rename to server/model/system/sys_dictionary.go index 153a0f4f..1eeb30b2 100644 --- a/server/model/sys_dictionary.go +++ b/server/model/system/sys_dictionary.go @@ -1,5 +1,5 @@ // 自动生成模板SysDictionary -package model +package system import ( "gin-vue-admin/global" diff --git a/server/model/sys_dictionary_detail.go b/server/model/system/sys_dictionary_detail.go similarity index 98% rename from server/model/sys_dictionary_detail.go rename to server/model/system/sys_dictionary_detail.go index b75d1336..1bd9cd2c 100644 --- a/server/model/sys_dictionary_detail.go +++ b/server/model/system/sys_dictionary_detail.go @@ -1,5 +1,5 @@ // 自动生成模板SysDictionaryDetail -package model +package system import ( "gin-vue-admin/global" diff --git a/server/model/sys_initdb.go b/server/model/system/sys_initdb.go similarity index 77% rename from server/model/sys_initdb.go rename to server/model/system/sys_initdb.go index 05ee62e9..ae05a748 100644 --- a/server/model/sys_initdb.go +++ b/server/model/system/sys_initdb.go @@ -1,4 +1,4 @@ -package model +package system type InitDBFunc interface { Init() (err error) diff --git a/server/model/sys_jwt_blacklist.go b/server/model/system/sys_jwt_blacklist.go similarity index 89% rename from server/model/sys_jwt_blacklist.go rename to server/model/system/sys_jwt_blacklist.go index 6cda6e2e..06b23e66 100644 --- a/server/model/sys_jwt_blacklist.go +++ b/server/model/system/sys_jwt_blacklist.go @@ -1,4 +1,4 @@ -package model +package system import ( "gin-vue-admin/global" diff --git a/server/model/sys_operation_record.go b/server/model/system/sys_operation_record.go similarity index 99% rename from server/model/sys_operation_record.go rename to server/model/system/sys_operation_record.go index 46d02f83..b3522ebb 100644 --- a/server/model/sys_operation_record.go +++ b/server/model/system/sys_operation_record.go @@ -1,5 +1,5 @@ // 自动生成模板SysOperationRecord -package model +package system import ( "gin-vue-admin/global" diff --git a/server/model/sys_system.go b/server/model/system/sys_system.go similarity index 87% rename from server/model/sys_system.go rename to server/model/system/sys_system.go index 44910003..8ea71140 100644 --- a/server/model/sys_system.go +++ b/server/model/system/sys_system.go @@ -1,4 +1,4 @@ -package model +package system import ( "gin-vue-admin/config" diff --git a/server/model/system/sys_user.go b/server/model/system/sys_user.go new file mode 100644 index 00000000..1fccf157 --- /dev/null +++ b/server/model/system/sys_user.go @@ -0,0 +1,21 @@ +package system + +import ( + "gin-vue-admin/global" + "github.com/satori/go.uuid" +) + +type SysUser struct { + global.GVA_MODEL + UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID + Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 + Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码 + NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 + HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像 + Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` + AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID + SideMode string `json:"sideMode" gorm:"default:dark;comment:用户角色ID"` // 用户侧边主题 + ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:用户角色ID"` // 活跃颜色 + BaseColor string `json:"baseColor" gorm:"default:#fff;comment:用户角色ID"` // 基础颜色 + Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` +} diff --git a/server/model/system/sys_user_authority.go b/server/model/system/sys_user_authority.go new file mode 100644 index 00000000..ba37605a --- /dev/null +++ b/server/model/system/sys_user_authority.go @@ -0,0 +1,10 @@ +package system + +type SysUseAuthority struct { + SysUserId uint `gorm:"column:sys_user_id"` + SysAuthorityAuthorityId string `gorm:"column:sys_authority_authority_id"` +} + +func (s *SysUseAuthority) TableName() string { + return "sys_user_authority" +} diff --git a/server/resource/template/server/api.go.tpl b/server/resource/template/server/api.go.tpl index fc6dd04a..92ed7c6a 100644 --- a/server/resource/template/server/api.go.tpl +++ b/server/resource/template/server/api.go.tpl @@ -1,27 +1,35 @@ -package v1 +package autocode import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" - "gin-vue-admin/model/response" + "gin-vue-admin/model/autocode" + "gin-vue-admin/model/common/request" + autocodeReq "gin-vue-admin/model/autocode/request" + "gin-vue-admin/model/common/response" "gin-vue-admin/service" "github.com/gin-gonic/gin" "go.uber.org/zap" ) +type {{.StructName}}Api struct { +} + +var {{.Abbreviation}}Service = service.ServiceGroupApp.AutoCodeServiceGroup.{{.StructName}}Service + + +// Create{{.StructName}} 创建{{.StructName}} // @Tags {{.StructName}} // @Summary 创建{{.StructName}} // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.{{.StructName}} true "创建{{.StructName}}" +// @Param data body autocode.{{.StructName}} true "创建{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /{{.Abbreviation}}/create{{.StructName}} [post] -func Create{{.StructName}}(c *gin.Context) { - var {{.Abbreviation}} model.{{.StructName}} +func ({{.Abbreviation}}Api *{{.StructName}}Api) Create{{.StructName}}(c *gin.Context) { + var {{.Abbreviation}} autocode.{{.StructName}} _ = c.ShouldBindJSON(&{{.Abbreviation}}) - if err := service.Create{{.StructName}}({{.Abbreviation}}); err != nil { + if err := {{.Abbreviation}}Service.Create{{.StructName}}({{.Abbreviation}}); err != nil { global.GVA_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { @@ -29,18 +37,19 @@ func Create{{.StructName}}(c *gin.Context) { } } +// Delete{{.StructName}} 删除{{.StructName}} // @Tags {{.StructName}} // @Summary 删除{{.StructName}} // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.{{.StructName}} true "删除{{.StructName}}" +// @Param data body autocode.{{.StructName}} true "删除{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /{{.Abbreviation}}/delete{{.StructName}} [delete] -func Delete{{.StructName}}(c *gin.Context) { - var {{.Abbreviation}} model.{{.StructName}} +func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}(c *gin.Context) { + var {{.Abbreviation}} autocode.{{.StructName}} _ = c.ShouldBindJSON(&{{.Abbreviation}}) - if err := service.Delete{{.StructName}}({{.Abbreviation}}); err != nil { + if err := {{.Abbreviation}}Service.Delete{{.StructName}}({{.Abbreviation}}); err != nil { global.GVA_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { @@ -48,6 +57,7 @@ func Delete{{.StructName}}(c *gin.Context) { } } +// Delete{{.StructName}}ByIds 批量删除{{.StructName}} // @Tags {{.StructName}} // @Summary 批量删除{{.StructName}} // @Security ApiKeyAuth @@ -56,10 +66,10 @@ func Delete{{.StructName}}(c *gin.Context) { // @Param data body request.IdsReq true "批量删除{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}" // @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete] -func Delete{{.StructName}}ByIds(c *gin.Context) { +func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}ByIds(c *gin.Context) { var IDS request.IdsReq _ = c.ShouldBindJSON(&IDS) - if err := service.Delete{{.StructName}}ByIds(IDS); err != nil { + if err := {{.Abbreviation}}Service.Delete{{.StructName}}ByIds(IDS); err != nil { global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err)) response.FailWithMessage("批量删除失败", c) } else { @@ -67,18 +77,19 @@ func Delete{{.StructName}}ByIds(c *gin.Context) { } } +// Update{{.StructName}} 更新{{.StructName}} // @Tags {{.StructName}} // @Summary 更新{{.StructName}} // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.{{.StructName}} true "更新{{.StructName}}" +// @Param data body autocode.{{.StructName}} true "更新{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /{{.Abbreviation}}/update{{.StructName}} [put] -func Update{{.StructName}}(c *gin.Context) { - var {{.Abbreviation}} model.{{.StructName}} +func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Context) { + var {{.Abbreviation}} autocode.{{.StructName}} _ = c.ShouldBindJSON(&{{.Abbreviation}}) - if err := service.Update{{.StructName}}({{.Abbreviation}}); err != nil { + if err := {{.Abbreviation}}Service.Update{{.StructName}}({{.Abbreviation}}); err != nil { global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { @@ -86,18 +97,19 @@ func Update{{.StructName}}(c *gin.Context) { } } +// Find{{.StructName}} 用id查询{{.StructName}} // @Tags {{.StructName}} // @Summary 用id查询{{.StructName}} // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.{{.StructName}} true "用id查询{{.StructName}}" +// @Param data query autocode.{{.StructName}} true "用id查询{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /{{.Abbreviation}}/find{{.StructName}} [get] -func Find{{.StructName}}(c *gin.Context) { - var {{.Abbreviation}} model.{{.StructName}} +func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Context) { + var {{.Abbreviation}} autocode.{{.StructName}} _ = c.ShouldBindQuery(&{{.Abbreviation}}) - if err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil { + if err, re{{.Abbreviation}} := {{.Abbreviation}}Service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { @@ -105,19 +117,20 @@ func Find{{.StructName}}(c *gin.Context) { } } +// Get{{.StructName}}List 分页获取{{.StructName}}列表 // @Tags {{.StructName}} // @Summary 分页获取{{.StructName}}列表 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.{{.StructName}}Search true "分页获取{{.StructName}}列表" +// @Param data query autocodeReq.{{.StructName}}Search true "分页获取{{.StructName}}列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /{{.Abbreviation}}/get{{.StructName}}List [get] -func Get{{.StructName}}List(c *gin.Context) { - var pageInfo request.{{.StructName}}Search +func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Context) { + var pageInfo autocodeReq.{{.StructName}}Search _ = c.ShouldBindQuery(&pageInfo) - if err, list, total := service.Get{{.StructName}}InfoList(pageInfo); err != nil { - global.GVA_LOG.Error("获取失败", zap.Any("err", err)) + if err, list, total := {{.Abbreviation}}Service.Get{{.StructName}}InfoList(pageInfo); err != nil { + global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { response.OkWithDetailed(response.PageResult{ diff --git a/server/resource/template/server/model.go.tpl b/server/resource/template/server/model.go.tpl index 6ec46518..86e1874a 100644 --- a/server/resource/template/server/model.go.tpl +++ b/server/resource/template/server/model.go.tpl @@ -1,21 +1,23 @@ // 自动生成模板{{.StructName}} -package model +package autocode import ( "gin-vue-admin/global" ) +// {{.StructName}} 结构体 // 如果含有time.Time 请自行import time包 type {{.StructName}} struct { global.GVA_MODEL {{- range .Fields}} - {{- if eq .FieldType "bool" }} - {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"` + {{- if ne .FieldType "string" }} + {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- end }}"` {{- else }} - {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"` + {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if ne .FieldType "string" -}}{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}{{- end -}}"` {{- end }} {{- end }} } {{ if .TableName }} +// TableName {{.StructName}} 表名 func ({{.StructName}}) TableName() string { return "{{.TableName}}" } diff --git a/server/resource/template/server/request.go.tpl b/server/resource/template/server/request.go.tpl index 68cc026d..e9e7f121 100644 --- a/server/resource/template/server/request.go.tpl +++ b/server/resource/template/server/request.go.tpl @@ -1,8 +1,11 @@ package request -import "gin-vue-admin/model" +import ( + "gin-vue-admin/model/autocode" + "gin-vue-admin/model/common/request" +) type {{.StructName}}Search struct{ - model.{{.StructName}} - PageInfo + autocode.{{.StructName}} + request.PageInfo } \ No newline at end of file diff --git a/server/resource/template/server/router.go.tpl b/server/resource/template/server/router.go.tpl index 87c41885..0100966b 100644 --- a/server/resource/template/server/router.go.tpl +++ b/server/resource/template/server/router.go.tpl @@ -1,4 +1,4 @@ -package router +package autocode import ( "gin-vue-admin/api/v1" @@ -6,14 +6,19 @@ import ( "github.com/gin-gonic/gin" ) -func Init{{.StructName}}Router(Router *gin.RouterGroup) { - {{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.OperationRecord()) +type {{.StructName}}Router struct { +} + +// Init{{.StructName}}Router 初始化 {{.StructName}} 路由信息 +func (s *{{.StructName}}Router) Init{{.StructName}}Router(Router *gin.RouterGroup) { + {{.Abbreviation}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.OperationRecord()) + var {{.Abbreviation}}Api = v1.ApiGroupApp.AutoCodeApiGroup.{{.StructName}}Api { - {{.StructName}}Router.POST("create{{.StructName}}", v1.Create{{.StructName}}) // 新建{{.StructName}} - {{.StructName}}Router.DELETE("delete{{.StructName}}", v1.Delete{{.StructName}}) // 删除{{.StructName}} - {{.StructName}}Router.DELETE("delete{{.StructName}}ByIds", v1.Delete{{.StructName}}ByIds) // 批量删除{{.StructName}} - {{.StructName}}Router.PUT("update{{.StructName}}", v1.Update{{.StructName}}) // 更新{{.StructName}} - {{.StructName}}Router.GET("find{{.StructName}}", v1.Find{{.StructName}}) // 根据ID获取{{.StructName}} - {{.StructName}}Router.GET("get{{.StructName}}List", v1.Get{{.StructName}}List) // 获取{{.StructName}}列表 + {{.Abbreviation}}Router.POST("create{{.StructName}}", {{.Abbreviation}}Api.Create{{.StructName}}) // 新建{{.StructName}} + {{.Abbreviation}}Router.DELETE("delete{{.StructName}}", {{.Abbreviation}}Api.Delete{{.StructName}}) // 删除{{.StructName}} + {{.Abbreviation}}Router.DELETE("delete{{.StructName}}ByIds", {{.Abbreviation}}Api.Delete{{.StructName}}ByIds) // 批量删除{{.StructName}} + {{.Abbreviation}}Router.PUT("update{{.StructName}}", {{.Abbreviation}}Api.Update{{.StructName}}) // 更新{{.StructName}} + {{.Abbreviation}}Router.GET("find{{.StructName}}", {{.Abbreviation}}Api.Find{{.StructName}}) // 根据ID获取{{.StructName}} + {{.Abbreviation}}Router.GET("get{{.StructName}}List", {{.Abbreviation}}Api.Get{{.StructName}}List) // 获取{{.StructName}}列表 } } diff --git a/server/resource/template/server/service.go.tpl b/server/resource/template/server/service.go.tpl index 323f7956..69a04b1c 100644 --- a/server/resource/template/server/service.go.tpl +++ b/server/resource/template/server/service.go.tpl @@ -1,78 +1,58 @@ -package service +package autocode import ( "gin-vue-admin/global" - "gin-vue-admin/model" - "gin-vue-admin/model/request" + "gin-vue-admin/model/autocode" + "gin-vue-admin/model/common/request" + autoCodeReq "gin-vue-admin/model/autocode/request" ) -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Create{{.StructName}} -//@description: 创建{{.StructName}}记录 -//@param: {{.Abbreviation}} model.{{.StructName}} -//@return: err error +type {{.StructName}}Service struct { +} -func Create{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) { +// Create{{.StructName}} 创建{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service) Create{{.StructName}}({{.Abbreviation}} autocode.{{.StructName}}) (err error) { err = global.GVA_DB.Create(&{{.Abbreviation}}).Error return err } -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Delete{{.StructName}} -//@description: 删除{{.StructName}}记录 -//@param: {{.Abbreviation}} model.{{.StructName}} -//@return: err error - -func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) { +// Delete{{.StructName}} 删除{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Delete{{.StructName}}({{.Abbreviation}} autocode.{{.StructName}}) (err error) { err = global.GVA_DB.Delete(&{{.Abbreviation}}).Error return err } -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Delete{{.StructName}}ByIds -//@description: 批量删除{{.StructName}}记录 -//@param: ids request.IdsReq -//@return: err error - -func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) { - err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in ?",ids.Ids).Error +// Delete{{.StructName}}ByIds 批量删除{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) { + err = global.GVA_DB.Delete(&[]autocode.{{.StructName}}{},"id in ?",ids.Ids).Error return err } -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Update{{.StructName}} -//@description: 更新{{.StructName}}记录 -//@param: {{.Abbreviation}} *model.{{.StructName}} -//@return: err error - -func Update{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) { +// Update{{.StructName}} 更新{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Update{{.StructName}}({{.Abbreviation}} autocode.{{.StructName}}) (err error) { err = global.GVA_DB.Save(&{{.Abbreviation}}).Error return err } -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Get{{.StructName}} -//@description: 根据id获取{{.StructName}}记录 -//@param: id uint -//@return: err error, {{.Abbreviation}} model.{{.StructName}} - -func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructName}}) { +// Get{{.StructName}} 根据id获取{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} autocode.{{.StructName}}) { err = global.GVA_DB.Where("id = ?", id).First(&{{.Abbreviation}}).Error return } -//@author: [piexlmax](https://github.com/piexlmax) -//@function: Get{{.StructName}}InfoList -//@description: 分页获取{{.StructName}}记录 -//@param: info request.{{.StructName}}Search -//@return: err error, list interface{}, total int64 - -func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, list interface{}, total int64) { +// Get{{.StructName}}InfoList 分页获取{{.StructName}}记录 +// Author [piexlmax](https://github.com/piexlmax) +func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoList(info autoCodeReq.{{.StructName}}Search) (err error, list interface{}, total int64) { limit := info.PageSize offset := info.PageSize * (info.Page - 1) // 创建db - db := global.GVA_DB.Model(&model.{{.StructName}}{}) - var {{.Abbreviation}}s []model.{{.StructName}} + db := global.GVA_DB.Model(&autocode.{{.StructName}}{}) + var {{.Abbreviation}}s []autocode.{{.StructName}} // 如果有条件搜索 下方会自动创建搜索语句 {{- range .Fields}} {{- if .FieldSearchType}} @@ -85,15 +65,15 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, db = db.Where("`{{.ColumnName}}` {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- else if eq .FieldType "int" }} - if info.{{.FieldName}} != 0 { + if info.{{.FieldName}} != nil { db = db.Where("`{{.ColumnName}}` {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- else if eq .FieldType "float64" }} - if info.{{.FieldName}} != 0 { + if info.{{.FieldName}} != nil { db = db.Where("`{{.ColumnName}}` {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- else if eq .FieldType "time.Time" }} - if !info.{{.FieldName}}.IsZero() { + if !info.{{.FieldName}} != nil { db = db.Where("`{{.ColumnName}}` {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- end }} @@ -102,4 +82,4 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, err = db.Count(&total).Error err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error return err, {{.Abbreviation}}s, total -} \ No newline at end of file +} diff --git a/server/resource/template/web/api.js.tpl b/server/resource/template/web/api.js.tpl index 1c3c6d21..9b771ba9 100644 --- a/server/resource/template/web/api.js.tpl +++ b/server/resource/template/web/api.js.tpl @@ -9,13 +9,12 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /{{.Abbreviation}}/create{{.StructName}} [post] export const create{{.StructName}} = (data) => { - return service({ - url: "/{{.Abbreviation}}/create{{.StructName}}", - method: 'post', - data - }) - } - + return service({ + url: '/{{.Abbreviation}}/create{{.StructName}}', + method: 'post', + data + }) +} // @Tags {{.StructName}} // @Summary 删除{{.StructName}} @@ -25,13 +24,13 @@ export const create{{.StructName}} = (data) => { // @Param data body model.{{.StructName}} true "删除{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /{{.Abbreviation}}/delete{{.StructName}} [delete] - export const delete{{.StructName}} = (data) => { - return service({ - url: "/{{.Abbreviation}}/delete{{.StructName}}", - method: 'delete', - data - }) - } +export const delete{{.StructName}} = (data) => { + return service({ + url: '/{{.Abbreviation}}/delete{{.StructName}}', + method: 'delete', + data + }) +} // @Tags {{.StructName}} // @Summary 删除{{.StructName}} @@ -41,13 +40,13 @@ export const create{{.StructName}} = (data) => { // @Param data body request.IdsReq true "批量删除{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /{{.Abbreviation}}/delete{{.StructName}} [delete] - export const delete{{.StructName}}ByIds = (data) => { - return service({ - url: "/{{.Abbreviation}}/delete{{.StructName}}ByIds", - method: 'delete', - data - }) - } +export const delete{{.StructName}}ByIds = (data) => { + return service({ + url: '/{{.Abbreviation}}/delete{{.StructName}}ByIds', + method: 'delete', + data + }) +} // @Tags {{.StructName}} // @Summary 更新{{.StructName}} @@ -57,44 +56,42 @@ export const create{{.StructName}} = (data) => { // @Param data body model.{{.StructName}} true "更新{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /{{.Abbreviation}}/update{{.StructName}} [put] - export const update{{.StructName}} = (data) => { - return service({ - url: "/{{.Abbreviation}}/update{{.StructName}}", - method: 'put', - data - }) - } - +export const update{{.StructName}} = (data) => { + return service({ + url: '/{{.Abbreviation}}/update{{.StructName}}', + method: 'put', + data + }) +} // @Tags {{.StructName}} // @Summary 用id查询{{.StructName}} // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.{{.StructName}} true "用id查询{{.StructName}}" +// @Param data query model.{{.StructName}} true "用id查询{{.StructName}}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /{{.Abbreviation}}/find{{.StructName}} [get] - export const find{{.StructName}} = (params) => { - return service({ - url: "/{{.Abbreviation}}/find{{.StructName}}", - method: 'get', - params - }) - } - +export const find{{.StructName}} = (params) => { + return service({ + url: '/{{.Abbreviation}}/find{{.StructName}}', + method: 'get', + params + }) +} // @Tags {{.StructName}} // @Summary 分页获取{{.StructName}}列表 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body request.PageInfo true "分页获取{{.StructName}}列表" +// @Param data query request.PageInfo true "分页获取{{.StructName}}列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /{{.Abbreviation}}/get{{.StructName}}List [get] - export const get{{.StructName}}List = (params) => { - return service({ - url: "/{{.Abbreviation}}/get{{.StructName}}List", - method: 'get', - params - }) - } \ No newline at end of file +export const get{{.StructName}}List = (params) => { + return service({ + url: '/{{.Abbreviation}}/get{{.StructName}}List', + method: 'get', + params + }) +} \ No newline at end of file diff --git a/server/resource/template/web/form.vue.tpl b/server/resource/template/web/form.vue.tpl index 44ace3cb..5a83bdd8 100644 --- a/server/resource/template/web/form.vue.tpl +++ b/server/resource/template/web/form.vue.tpl @@ -1,124 +1,121 @@ diff --git a/web/src/api/api.js b/web/src/api/api.js index 8549e9b1..2e665a42 100644 --- a/web/src/api/api.js +++ b/web/src/api/api.js @@ -1,4 +1,5 @@ import service from '@/utils/request' + // @Tags api // @Summary 分页获取角色列表 // @Security ApiKeyAuth @@ -12,14 +13,13 @@ import service from '@/utils/request' // pageSize int // } export const getApiList = (data) => { - return service({ - url: "/api/getApiList", - method: 'post', - data - }) + return service({ + url: '/api/getApiList', + method: 'post', + data + }) } - // @Tags Api // @Summary 创建基础api // @Security ApiKeyAuth @@ -29,11 +29,11 @@ export const getApiList = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/createApi [post] export const createApi = (data) => { - return service({ - url: "/api/createApi", - method: 'post', - data - }) + return service({ + url: '/api/createApi', + method: 'post', + data + }) } // @Tags menu @@ -45,15 +45,13 @@ export const createApi = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getApiById [post] export const getApiById = (data) => { - return service({ - url: "/api/getApiById", - method: 'post', - data - }) + return service({ + url: '/api/getApiById', + method: 'post', + data + }) } - - // @Tags Api // @Summary 更新api // @Security ApiKeyAuth @@ -63,11 +61,11 @@ export const getApiById = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"更新成功"}" // @Router /api/updateApi [post] export const updateApi = (data) => { - return service({ - url: "/api/updateApi", - method: 'post', - data - }) + return service({ + url: '/api/updateApi', + method: 'post', + data + }) } // @Tags Api @@ -79,11 +77,11 @@ export const updateApi = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"更新成功"}" // @Router /api/setAuthApi [post] export const setAuthApi = (data) => { - return service({ - url: "/api/setAuthApi", - method: 'post', - data - }) + return service({ + url: '/api/setAuthApi', + method: 'post', + data + }) } // @Tags Api @@ -94,11 +92,11 @@ export const setAuthApi = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getAllApis [post] export const getAllApis = (data) => { - return service({ - url: "/api/getAllApis", - method: 'post', - data - }) + return service({ + url: '/api/getAllApis', + method: 'post', + data + }) } // @Tags Api @@ -110,11 +108,11 @@ export const getAllApis = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/deleteApi [post] export const deleteApi = (data) => { - return service({ - url: "/api/deleteApi", - method: 'post', - data - }) + return service({ + url: '/api/deleteApi', + method: 'post', + data + }) } // @Tags SysApi @@ -126,9 +124,9 @@ export const deleteApi = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /api/deleteApisByIds [delete] export const deleteApisByIds = (data) => { - return service({ - url: "/api/deleteApisByIds", - method: 'delete', - data - }) -} \ No newline at end of file + return service({ + url: '/api/deleteApisByIds', + method: 'delete', + data + }) +} diff --git a/web/src/api/authority.js b/web/src/api/authority.js index baee9e42..02dc4136 100644 --- a/web/src/api/authority.js +++ b/web/src/api/authority.js @@ -1,16 +1,14 @@ import service from '@/utils/request' - // @Router /authority/getAuthorityList [post] export const getAuthorityList = (data) => { - return service({ - url: "/authority/getAuthorityList", - method: 'post', - data - }) + return service({ + url: '/authority/getAuthorityList', + method: 'post', + data + }) } - // @Summary 删除角色 // @Security ApiKeyAuth // @accept application/json @@ -19,11 +17,11 @@ export const getAuthorityList = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /authority/deleteAuthority [post] export const deleteAuthority = (data) => { - return service({ - url: "/authority/deleteAuthority", - method: 'post', - data - }) + return service({ + url: '/authority/deleteAuthority', + method: 'post', + data + }) } // @Summary 创建角色 @@ -34,11 +32,11 @@ export const deleteAuthority = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /authority/createAuthority [post] export const createAuthority = (data) => { - return service({ - url: "/authority/createAuthority", - method: 'post', - data - }) + return service({ + url: '/authority/createAuthority', + method: 'post', + data + }) } // @Tags authority @@ -50,11 +48,11 @@ export const createAuthority = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"拷贝成功"}" // @Router /authority/copyAuthority [post] export const copyAuthority = (data) => { - return service({ - url: "/authority/copyAuthority", - method: 'post', - data - }) + return service({ + url: '/authority/copyAuthority', + method: 'post', + data + }) } // @Summary 设置角色资源权限 @@ -65,11 +63,11 @@ export const copyAuthority = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /authority/setDataAuthority [post] export const setDataAuthority = (data) => { - return service({ - url: "/authority/setDataAuthority", - method: 'post', - data - }) + return service({ + url: '/authority/setDataAuthority', + method: 'post', + data + }) } // @Summary 修改角色 @@ -80,9 +78,9 @@ export const setDataAuthority = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /authority/setDataAuthority [post] export const updateAuthority = (data) => { - return service({ - url: "/authority/updateAuthority", - method: 'put', - data - }) -} \ No newline at end of file + return service({ + url: '/authority/updateAuthority', + method: 'put', + data + }) +} diff --git a/web/src/api/autoCode.js b/web/src/api/autoCode.js index a5756b51..fc732919 100644 --- a/web/src/api/autoCode.js +++ b/web/src/api/autoCode.js @@ -1,20 +1,20 @@ import service from '@/utils/request' export const preview = (data) => { - return service({ - url: "/autoCode/preview", - method: 'post', - data, - }) + return service({ + url: '/autoCode/preview', + method: 'post', + data + }) } export const createTemp = (data) => { - return service({ - url: "/autoCode/createTemp", - method: 'post', - data, - responseType: 'blob' - }) + return service({ + url: '/autoCode/createTemp', + method: 'post', + data, + responseType: 'blob' + }) } // @Tags SysApi @@ -25,14 +25,12 @@ export const createTemp = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /autoCode/getDatabase [get] export const getDB = () => { - return service({ - url: "/autoCode/getDB", - method: 'get', - }) + return service({ + url: '/autoCode/getDB', + method: 'get' + }) } - - // @Tags SysApi // @Summary 获取当前数据库所有表 // @Security ApiKeyAuth @@ -41,11 +39,11 @@ export const getDB = () => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /autoCode/getTables [get] export const getTable = (params) => { - return service({ - url: "/autoCode/getTables", - method: 'get', - params, - }) + return service({ + url: '/autoCode/getTables', + method: 'get', + params + }) } // @Tags SysApi @@ -56,9 +54,41 @@ export const getTable = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /autoCode/getColumn [get] export const getColumn = (params) => { - return service({ - url: "/autoCode/getColumn", - method: 'get', - params, - }) -} \ No newline at end of file + return service({ + url: '/autoCode/getColumn', + method: 'get', + params + }) +} + +export const getSysHistory = (data) => { + return service({ + url: '/autoCode/getSysHistory', + method: 'post', + data + }) +} + +export const rollback = (data) => { + return service({ + url: '/autoCode/rollback', + method: 'post', + data + }) +} + +export const getMeta = (data) => { + return service({ + url: '/autoCode/getMeta', + method: 'post', + data + }) +} + +export const delSysHistory = (data) => { + return service({ + url: '/autoCode/delSysHistory', + method: 'post', + data + }) +} diff --git a/web/src/api/breakpoint.js b/web/src/api/breakpoint.js index 382f53b9..04d754e8 100644 --- a/web/src/api/breakpoint.js +++ b/web/src/api/breakpoint.js @@ -9,28 +9,26 @@ import service from '@/utils/request' // @Router /authority/setDataAuthority [post] export const findFile = (params) => { - return service({ - url: "/fileUploadAndDownload/findFile", - method: 'get', - params - }) + return service({ + url: '/fileUploadAndDownload/findFile', + method: 'get', + params + }) } - - export const breakpointContinueFinish = (params) => { - return service({ - url: "/fileUploadAndDownload/breakpointContinueFinish", - method: 'post', - params - }) + return service({ + url: '/fileUploadAndDownload/breakpointContinueFinish', + method: 'post', + params + }) } export const removeChunk = (data, params) => { - return service({ - url: "/fileUploadAndDownload/removeChunk", - method: 'post', - data, - params - }) -} \ No newline at end of file + return service({ + url: '/fileUploadAndDownload/removeChunk', + method: 'post', + data, + params + }) +} diff --git a/web/src/api/casbin.js b/web/src/api/casbin.js index 8ef9f8e0..6d8e02b4 100644 --- a/web/src/api/casbin.js +++ b/web/src/api/casbin.js @@ -8,16 +8,14 @@ import service from '@/utils/request' // @Param data body api.CreateAuthorityPatams true "更改角色api权限" // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/UpdateCasbin [post] - export const UpdateCasbin = (data) => { - return service({ - url: "/casbin/updateCasbin", - method: 'post', - data - }) + return service({ + url: '/casbin/updateCasbin', + method: 'post', + data + }) } - // @Tags casbin // @Summary 获取权限列表 // @Security ApiKeyAuth @@ -27,9 +25,9 @@ export const UpdateCasbin = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/getPolicyPathByAuthorityId [post] export const getPolicyPathByAuthorityId = (data) => { - return service({ - url: "/casbin/getPolicyPathByAuthorityId", - method: 'post', - data - }) -} \ No newline at end of file + return service({ + url: '/casbin/getPolicyPathByAuthorityId', + method: 'post', + data + }) +} diff --git a/web/src/api/customer.js b/web/src/api/customer.js index 2cfa49c2..3e8f5e11 100644 --- a/web/src/api/customer.js +++ b/web/src/api/customer.js @@ -9,15 +9,13 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customer [post] export const createExaCustomer = (data) => { - return service({ - url: "/customer/customer", - method: 'post', - data - }) + return service({ + url: '/customer/customer', + method: 'post', + data + }) } - - // @Tags SysApi // @Summary 更新客户信息 // @Security ApiKeyAuth @@ -27,14 +25,13 @@ export const createExaCustomer = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customer [put] export const updateExaCustomer = (data) => { - return service({ - url: "/customer/customer", - method: 'put', - data - }) + return service({ + url: '/customer/customer', + method: 'put', + data + }) } - // @Tags SysApi // @Summary 创建客户 // @Security ApiKeyAuth @@ -44,14 +41,13 @@ export const updateExaCustomer = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customer [delete] export const deleteExaCustomer = (data) => { - return service({ - url: "/customer/customer", - method: 'delete', - data - }) + return service({ + url: '/customer/customer', + method: 'delete', + data + }) } - // @Tags SysApi // @Summary 获取单一客户信息 // @Security ApiKeyAuth @@ -61,14 +57,13 @@ export const deleteExaCustomer = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customer [get] export const getExaCustomer = (params) => { - return service({ - url: "/customer/customer", - method: 'get', - params - }) + return service({ + url: '/customer/customer', + method: 'get', + params + }) } - // @Tags SysApi // @Summary 获取权限客户列表 // @Security ApiKeyAuth @@ -78,9 +73,9 @@ export const getExaCustomer = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/customerList [get] export const getExaCustomerList = (params) => { - return service({ - url: "/customer/customerList", - method: 'get', - params - }) -} \ No newline at end of file + return service({ + url: '/customer/customerList', + method: 'get', + params + }) +} diff --git a/web/src/api/email.js b/web/src/api/email.js index 25023533..932aa1f2 100644 --- a/web/src/api/email.js +++ b/web/src/api/email.js @@ -7,9 +7,9 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /email/emailTest [post] export const emailTest = (data) => { - return service({ - url: "/email/emailTest", - method: 'post', - data - }) -} \ No newline at end of file + return service({ + url: '/email/emailTest', + method: 'post', + data + }) +} diff --git a/web/src/api/excel.js b/web/src/api/excel.js index 3315f6ab..398be2ee 100644 --- a/web/src/api/excel.js +++ b/web/src/api/excel.js @@ -1,29 +1,29 @@ -import service from '@/utils/request'; -import { Message } from 'element-ui'; +import service from '@/utils/request' +import { Message } from 'element-ui' const handleFileError = (res, fileName) => { - if (typeof(res.data) !== "undefined") { - if (res.data.type == "application/json") { - const reader = new FileReader(); - reader.onload = function() { - let message = JSON.parse(reader.result).msg; - Message({ - showClose: true, - message: message, - type: 'error' - }) - }; - reader.readAsText(new Blob([res.data])); - } - } else { - var downloadUrl = window.URL.createObjectURL(new Blob([res])); - var a = document.createElement('a'); - a.style.display = 'none'; - a.href = downloadUrl; - a.download = fileName; - var event = new MouseEvent("click"); - a.dispatchEvent(event); + if (typeof (res.data) !== 'undefined') { + if (res.data.type === 'application/json') { + const reader = new FileReader() + reader.onload = function() { + const message = JSON.parse(reader.result).msg + Message({ + showClose: true, + message: message, + type: 'error' + }) + } + reader.readAsText(new Blob([res.data])) } + } else { + var downloadUrl = window.URL.createObjectURL(new Blob([res])) + var a = document.createElement('a') + a.style.display = 'none' + a.href = downloadUrl + a.download = fileName + var event = new MouseEvent('click') + a.dispatchEvent(event) + } } // @Tags excel @@ -35,17 +35,17 @@ const handleFileError = (res, fileName) => { // @Success 200 // @Router /excel/exportExcel [post] export const exportExcel = (tableData, fileName) => { - service({ - url: "/excel/exportExcel", - method: 'post', - data: { - fileName: fileName, - infoList: tableData - }, - responseType: 'blob' - }).then((res) => { - handleFileError(res, fileName) - }) + service({ + url: '/excel/exportExcel', + method: 'post', + data: { + fileName: fileName, + infoList: tableData + }, + responseType: 'blob' + }).then((res) => { + handleFileError(res, fileName) + }) } // @Tags excel @@ -57,10 +57,10 @@ export const exportExcel = (tableData, fileName) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"导入成功"}" // @Router /excel/importExcel [post] export const loadExcelData = () => { - return service({ - url: "/excel/loadExcel", - method: 'get' - }) + return service({ + url: '/excel/loadExcel', + method: 'get' + }) } // @Tags excel @@ -72,14 +72,14 @@ export const loadExcelData = () => { // @Success 200 // @Router /excel/downloadTemplate [get] export const downloadTemplate = (fileName) => { - return service({ - url: "/excel/downloadTemplate", - method: 'get', - params: { - fileName: fileName - }, - responseType: 'blob' - }).then((res) => { - handleFileError(res, fileName) - }) -} \ No newline at end of file + return service({ + url: '/excel/downloadTemplate', + method: 'get', + params: { + fileName: fileName + }, + responseType: 'blob' + }).then((res) => { + handleFileError(res, fileName) + }) +} diff --git a/web/src/api/fileUploadAndDownload.js b/web/src/api/fileUploadAndDownload.js index 492be034..c8063961 100644 --- a/web/src/api/fileUploadAndDownload.js +++ b/web/src/api/fileUploadAndDownload.js @@ -1,4 +1,4 @@ -import service from '@/utils/request'; +import service from '@/utils/request' // @Tags FileUploadAndDownload // @Summary 分页文件列表 @@ -9,11 +9,11 @@ import service from '@/utils/request'; // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /fileUploadAndDownload/getFileList [post] export const getFileList = (data) => { - return service({ - url: "/fileUploadAndDownload/getFileList", - method: "post", - data - }) + return service({ + url: '/fileUploadAndDownload/getFileList', + method: 'post', + data + }) } // @Tags FileUploadAndDownload @@ -24,9 +24,9 @@ export const getFileList = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}" // @Router /fileUploadAndDownload/deleteFile [post] export const deleteFile = (data) => { - return service({ - url: "/fileUploadAndDownload/deleteFile", - method: "post", - data - }) -} \ No newline at end of file + return service({ + url: '/fileUploadAndDownload/deleteFile', + method: 'post', + data + }) +} diff --git a/web/src/api/github.js b/web/src/api/github.js index 3a3559d9..0f28509b 100644 --- a/web/src/api/github.js +++ b/web/src/api/github.js @@ -1,33 +1,32 @@ -import axios from "axios"; -import { Loading } from "element-ui"; +import axios from 'axios' +import { Loading } from 'element-ui' -let loadingInstance; -let service = axios.create(); +let loadingInstance +const service = axios.create() service.interceptors.request.use((config) => { - loadingInstance = Loading.service({ fullscreen: true }); - return config; -}); + loadingInstance = Loading.service({ fullscreen: true }) + return config +}) service.interceptors.response.use((resp) => { - loadingInstance.close(); - return resp; + loadingInstance.close() + return resp }, (error) => { - loadingInstance.close(); - return error; -}); + loadingInstance.close() + return error +}) export function Commits(page) { - return service({ - url: "https://api.github.com/repos/flipped-aurora/gin-vue-admin/commits?page=" + - page, - method: "get", - }); + return service({ + url: 'https://api.github.com/repos/flipped-aurora/gin-vue-admin/commits?page=' + page, + method: 'get' + }) } export function Members() { - return service({ - url: "https://api.github.com/orgs/FLIPPED-AURORA/members", - method: "get", - }); -} \ No newline at end of file + return service({ + url: 'https://api.github.com/orgs/FLIPPED-AURORA/members', + method: 'get' + }) +} diff --git a/web/src/api/initdb.js b/web/src/api/initdb.js index 1c8f072a..c67ebc4a 100644 --- a/web/src/api/initdb.js +++ b/web/src/api/initdb.js @@ -7,23 +7,21 @@ import service from '@/utils/request' // @Success 200 {string} string "{"code":0,"data":{},"msg":"自动创建数据库成功"}" // @Router /init/initdb [post] export const initDB = (data) => { - return service({ - url: "/init/initdb", - method: 'post', - data - }) + return service({ + url: '/init/initdb', + method: 'post', + data + }) } - // @Tags CheckDB // @Summary 初始化用户数据库 // @Produce application/json // @Success 200 {string} string "{"code":0,"data":{},"msg":"探测完成"}" // @Router /init/checkdb [post] - export const checkDB = () => { - return service({ - url: "/init/checkdb", - method: 'post', - }) -} \ No newline at end of file + return service({ + url: '/init/checkdb', + method: 'post' + }) +} diff --git a/web/src/api/jwt.js b/web/src/api/jwt.js index a4be8429..39ac494e 100644 --- a/web/src/api/jwt.js +++ b/web/src/api/jwt.js @@ -7,10 +7,9 @@ import service from '@/utils/request' // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"拉黑成功"}" // @Router /jwt/jsonInBlacklist [post] - export const jsonInBlacklist = () => { - return service({ - url: "/jwt/jsonInBlacklist", - method: 'post', - }) -} \ No newline at end of file + return service({ + url: '/jwt/jsonInBlacklist', + method: 'post' + }) +} diff --git a/web/src/api/menu.js b/web/src/api/menu.js index cf512fbe..7f5a7c6b 100644 --- a/web/src/api/menu.js +++ b/web/src/api/menu.js @@ -5,10 +5,10 @@ import service from '@/utils/request' // @Param 可以什么都不填 调一下即可 // @Router /menu/getMenu [post] export const asyncMenu = () => { - return service({ - url: "/menu/getMenu", - method: 'post', - }) + return service({ + url: '/menu/getMenu', + method: 'post' + }) } // @Summary 获取menu列表 @@ -19,24 +19,23 @@ export const asyncMenu = () => { // } // @Router /menu/getMenuList [post] export const getMenuList = (data) => { - return service({ - url: "/menu/getMenuList", - method: 'post', - data - }) + return service({ + url: '/menu/getMenuList', + method: 'post', + data + }) } - // @Summary 新增基础menu // @Produce application/json // @Param menu Object // @Router /menu/getMenuList [post] export const addBaseMenu = (data) => { - return service({ - url: "/menu/addBaseMenu", - method: 'post', - data - }) + return service({ + url: '/menu/addBaseMenu', + method: 'post', + data + }) } // @Summary 获取基础路由列表 @@ -44,10 +43,10 @@ export const addBaseMenu = (data) => { // @Param 可以什么都不填 调一下即可 // @Router /menu/getBaseMenuTree [post] export const getBaseMenuTree = () => { - return service({ - url: "/menu/getBaseMenuTree", - method: 'post', - }) + return service({ + url: '/menu/getBaseMenuTree', + method: 'post' + }) } // @Summary 添加用户menu关联关系 @@ -55,11 +54,11 @@ export const getBaseMenuTree = () => { // @Param menus Object authorityId string // @Router /menu/getMenuList [post] export const addMenuAuthority = (data) => { - return service({ - url: "/menu/addMenuAuthority", - method: 'post', - data - }) + return service({ + url: '/menu/addMenuAuthority', + method: 'post', + data + }) } // @Summary 获取用户menu关联关系 @@ -67,11 +66,11 @@ export const addMenuAuthority = (data) => { // @Param authorityId string // @Router /menu/getMenuAuthority [post] export const getMenuAuthority = (data) => { - return service({ - url: "/menu/getMenuAuthority", - method: 'post', - data - }) + return service({ + url: '/menu/getMenuAuthority', + method: 'post', + data + }) } // @Summary 获取用户menu关联关系 @@ -79,27 +78,25 @@ export const getMenuAuthority = (data) => { // @Param ID float64 // @Router /menu/deleteBaseMenu [post] export const deleteBaseMenu = (data) => { - return service({ - url: "/menu/deleteBaseMenu", - method: 'post', - data - }) + return service({ + url: '/menu/deleteBaseMenu', + method: 'post', + data + }) } - // @Summary 修改menu列表 // @Produce application/json // @Param menu Object // @Router /menu/updateBaseMenu [post] export const updateBaseMenu = (data) => { - return service({ - url: "/menu/updateBaseMenu", - method: 'post', - data - }) + return service({ + url: '/menu/updateBaseMenu', + method: 'post', + data + }) } - // @Tags menu // @Summary 根据id获取菜单 // @Security ApiKeyAuth @@ -109,9 +106,9 @@ export const updateBaseMenu = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getBaseMenuById [post] export const getBaseMenuById = (data) => { - return service({ - url: "/menu/getBaseMenuById", - method: 'post', - data - }) -} \ No newline at end of file + return service({ + url: '/menu/getBaseMenuById', + method: 'post', + data + }) +} diff --git a/web/src/api/simpleUploader.js b/web/src/api/simpleUploader.js index 7cfe7d6c..e3064c9b 100644 --- a/web/src/api/simpleUploader.js +++ b/web/src/api/simpleUploader.js @@ -1,5 +1,4 @@ - import service from '@/utils/request' // @Tags SimpleUploader @@ -11,14 +10,13 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /simpleUploader/checkFileMd5 [get] export const checkFileMd5 = (params) => { - return service({ - url: "/simpleUploader/checkFileMd5", - method: 'get', - params - }) + return service({ + url: '/simpleUploader/checkFileMd5', + method: 'get', + params + }) } - // @Tags SimpleUploader // @Summary 合并文件 // @Security ApiKeyAuth @@ -27,10 +25,10 @@ export const checkFileMd5 = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"合并成功"}" // @Router /simpleUploader/mergeFileMd5 [get] export const mergeFileMd5 = (params) => { - return service({ - url: "/simpleUploader/mergeFileMd5", - method: 'get', - params - }) + return service({ + url: '/simpleUploader/mergeFileMd5', + method: 'get', + params + }) } diff --git a/web/src/api/sysDictionary.js b/web/src/api/sysDictionary.js index e08efbbb..dc953313 100644 --- a/web/src/api/sysDictionary.js +++ b/web/src/api/sysDictionary.js @@ -9,13 +9,12 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionary/createSysDictionary [post] export const createSysDictionary = (data) => { - return service({ - url: "/sysDictionary/createSysDictionary", - method: 'post', - data - }) - } - + return service({ + url: '/sysDictionary/createSysDictionary', + method: 'post', + data + }) +} // @Tags SysDictionary // @Summary 删除SysDictionary @@ -25,13 +24,13 @@ export const createSysDictionary = (data) => { // @Param data body model.SysDictionary true "删除SysDictionary" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysDictionary/deleteSysDictionary [delete] - export const deleteSysDictionary = (data) => { - return service({ - url: "/sysDictionary/deleteSysDictionary", - method: 'delete', - data - }) - } +export const deleteSysDictionary = (data) => { + return service({ + url: '/sysDictionary/deleteSysDictionary', + method: 'delete', + data + }) +} // @Tags SysDictionary // @Summary 更新SysDictionary @@ -41,14 +40,13 @@ export const createSysDictionary = (data) => { // @Param data body model.SysDictionary true "更新SysDictionary" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /sysDictionary/updateSysDictionary [put] - export const updateSysDictionary = (data) => { - return service({ - url: "/sysDictionary/updateSysDictionary", - method: 'put', - data - }) - } - +export const updateSysDictionary = (data) => { + return service({ + url: '/sysDictionary/updateSysDictionary', + method: 'put', + data + }) +} // @Tags SysDictionary // @Summary 用id查询SysDictionary @@ -58,14 +56,13 @@ export const createSysDictionary = (data) => { // @Param data body model.SysDictionary true "用id查询SysDictionary" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /sysDictionary/findSysDictionary [get] - export const findSysDictionary = (params) => { - return service({ - url: "/sysDictionary/findSysDictionary", - method: 'get', - params - }) - } - +export const findSysDictionary = (params) => { + return service({ + url: '/sysDictionary/findSysDictionary', + method: 'get', + params + }) +} // @Tags SysDictionary // @Summary 分页获取SysDictionary列表 @@ -75,10 +72,10 @@ export const createSysDictionary = (data) => { // @Param data body request.PageInfo true "分页获取SysDictionary列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionary/getSysDictionaryList [get] - export const getSysDictionaryList = (params) => { - return service({ - url: "/sysDictionary/getSysDictionaryList", - method: 'get', - params - }) - } \ No newline at end of file +export const getSysDictionaryList = (params) => { + return service({ + url: '/sysDictionary/getSysDictionaryList', + method: 'get', + params + }) +} diff --git a/web/src/api/sysDictionaryDetail.js b/web/src/api/sysDictionaryDetail.js index a64fe68a..35fc04bf 100644 --- a/web/src/api/sysDictionaryDetail.js +++ b/web/src/api/sysDictionaryDetail.js @@ -9,13 +9,12 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionaryDetail/createSysDictionaryDetail [post] export const createSysDictionaryDetail = (data) => { - return service({ - url: "/sysDictionaryDetail/createSysDictionaryDetail", - method: 'post', - data - }) - } - + return service({ + url: '/sysDictionaryDetail/createSysDictionaryDetail', + method: 'post', + data + }) +} // @Tags SysDictionaryDetail // @Summary 删除SysDictionaryDetail @@ -25,13 +24,13 @@ export const createSysDictionaryDetail = (data) => { // @Param data body model.SysDictionaryDetail true "删除SysDictionaryDetail" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete] - export const deleteSysDictionaryDetail = (data) => { - return service({ - url: "/sysDictionaryDetail/deleteSysDictionaryDetail", - method: 'delete', - data - }) - } +export const deleteSysDictionaryDetail = (data) => { + return service({ + url: '/sysDictionaryDetail/deleteSysDictionaryDetail', + method: 'delete', + data + }) +} // @Tags SysDictionaryDetail // @Summary 更新SysDictionaryDetail @@ -41,14 +40,13 @@ export const createSysDictionaryDetail = (data) => { // @Param data body model.SysDictionaryDetail true "更新SysDictionaryDetail" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /sysDictionaryDetail/updateSysDictionaryDetail [put] - export const updateSysDictionaryDetail = (data) => { - return service({ - url: "/sysDictionaryDetail/updateSysDictionaryDetail", - method: 'put', - data - }) - } - +export const updateSysDictionaryDetail = (data) => { + return service({ + url: '/sysDictionaryDetail/updateSysDictionaryDetail', + method: 'put', + data + }) +} // @Tags SysDictionaryDetail // @Summary 用id查询SysDictionaryDetail @@ -58,14 +56,13 @@ export const createSysDictionaryDetail = (data) => { // @Param data body model.SysDictionaryDetail true "用id查询SysDictionaryDetail" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /sysDictionaryDetail/findSysDictionaryDetail [get] - export const findSysDictionaryDetail = (params) => { - return service({ - url: "/sysDictionaryDetail/findSysDictionaryDetail", - method: 'get', - params - }) - } - +export const findSysDictionaryDetail = (params) => { + return service({ + url: '/sysDictionaryDetail/findSysDictionaryDetail', + method: 'get', + params + }) +} // @Tags SysDictionaryDetail // @Summary 分页获取SysDictionaryDetail列表 @@ -75,10 +72,10 @@ export const createSysDictionaryDetail = (data) => { // @Param data body request.PageInfo true "分页获取SysDictionaryDetail列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysDictionaryDetail/getSysDictionaryDetailList [get] - export const getSysDictionaryDetailList = (params) => { - return service({ - url: "/sysDictionaryDetail/getSysDictionaryDetailList", - method: 'get', - params - }) - } \ No newline at end of file +export const getSysDictionaryDetailList = (params) => { + return service({ + url: '/sysDictionaryDetail/getSysDictionaryDetailList', + method: 'get', + params + }) +} diff --git a/web/src/api/sysOperationRecord.js b/web/src/api/sysOperationRecord.js index 18a67e84..fb64245c 100644 --- a/web/src/api/sysOperationRecord.js +++ b/web/src/api/sysOperationRecord.js @@ -9,11 +9,11 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysOperationRecord/deleteSysOperationRecord [delete] export const deleteSysOperationRecord = (data) => { - return service({ - url: "/sysOperationRecord/deleteSysOperationRecord", - method: 'delete', - data - }) + return service({ + url: '/sysOperationRecord/deleteSysOperationRecord', + method: 'delete', + data + }) } // @Tags SysOperationRecord @@ -25,11 +25,11 @@ export const deleteSysOperationRecord = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysOperationRecord/deleteSysOperationRecord [delete] export const deleteSysOperationRecordByIds = (data) => { - return service({ - url: "/sysOperationRecord/deleteSysOperationRecordByIds", - method: 'delete', - data - }) + return service({ + url: '/sysOperationRecord/deleteSysOperationRecordByIds', + method: 'delete', + data + }) } // @Tags SysOperationRecord @@ -41,9 +41,9 @@ export const deleteSysOperationRecordByIds = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysOperationRecord/getSysOperationRecordList [get] export const getSysOperationRecordList = (params) => { - return service({ - url: "/sysOperationRecord/getSysOperationRecordList", - method: 'get', - params - }) -} \ No newline at end of file + return service({ + url: '/sysOperationRecord/getSysOperationRecordList', + method: 'get', + params + }) +} diff --git a/web/src/api/system.js b/web/src/api/system.js index 622685db..3f32c52a 100644 --- a/web/src/api/system.js +++ b/web/src/api/system.js @@ -1,4 +1,4 @@ -import service from "@/utils/request"; +import service from '@/utils/request' // @Tags systrm // @Summary 获取配置文件内容 @@ -7,11 +7,11 @@ import service from "@/utils/request"; // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /system/getSystemConfig [post] export const getSystemConfig = () => { - return service({ - url: "/system/getSystemConfig", - method: "post", - }); -}; + return service({ + url: '/system/getSystemConfig', + method: 'post' + }) +} // @Tags system // @Summary 设置配置文件内容 @@ -21,12 +21,12 @@ export const getSystemConfig = () => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /system/setSystemConfig [post] export const setSystemConfig = (data) => { - return service({ - url: "/system/setSystemConfig", - method: "post", - data, - }); -}; + return service({ + url: '/system/setSystemConfig', + method: 'post', + data + }) +} // @Tags system // @Summary 获取服务器运行状态 @@ -35,9 +35,9 @@ export const setSystemConfig = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /system/getServerInfo [post] export const getSystemState = () => { - return service({ - url: "/system/getServerInfo", - method: "post", - donNotShowLoading: true - }); -}; \ No newline at end of file + return service({ + url: '/system/getServerInfo', + method: 'post', + donNotShowLoading: true + }) +} diff --git a/web/src/api/user.js b/web/src/api/user.js index aae6ccfa..32ee55c1 100644 --- a/web/src/api/user.js +++ b/web/src/api/user.js @@ -5,11 +5,11 @@ import service from '@/utils/request' // @Param data body {username:"string",password:"string"} // @Router /base/login [post] export const login = (data) => { - return service({ - url: "/base/login", - method: 'post', - data: data - }) + return service({ + url: '/base/login', + method: 'post', + data: data + }) } // @Summary 获取验证码 @@ -17,11 +17,11 @@ export const login = (data) => { // @Param data body {username:"string",password:"string"} // @Router /base/captcha [post] export const captcha = (data) => { - return service({ - url: "/base/captcha", - method: 'post', - data: data - }) + return service({ + url: '/base/captcha', + method: 'post', + data: data + }) } // @Summary 用户注册 @@ -29,39 +29,40 @@ export const captcha = (data) => { // @Param data body {username:"string",password:"string"} // @Router /base/resige [post] export const register = (data) => { - return service({ - url: "/user/register", - method: 'post', - data: data - }) - } - // @Summary 修改密码 - // @Produce application/json - // @Param data body {username:"string",password:"string",newPassword:"string"} - // @Router /user/changePassword [post] -export const changePassword = (data) => { - return service({ - url: "/user/changePassword", - method: 'post', - data: data - }) - } - // @Tags User - // @Summary 分页获取用户列表 - // @Security ApiKeyAuth - // @accept application/json - // @Produce application/json - // @Param data body modelInterface.PageInfo true "分页获取用户列表" - // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" - // @Router /user/getUserList [post] -export const getUserList = (data) => { - return service({ - url: "/user/getUserList", - method: 'post', - data: data - }) + return service({ + url: '/user/register', + method: 'post', + data: data + }) } +// @Summary 修改密码 +// @Produce application/json +// @Param data body {username:"string",password:"string",newPassword:"string"} +// @Router /user/changePassword [post] +export const changePassword = (data) => { + return service({ + url: '/user/changePassword', + method: 'post', + data: data + }) +} + +// @Tags User +// @Summary 分页获取用户列表 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body modelInterface.PageInfo true "分页获取用户列表" +// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /user/getUserList [post] +export const getUserList = (data) => { + return service({ + url: '/user/getUserList', + method: 'post', + data: data + }) +} // @Tags User // @Summary 设置用户权限 @@ -72,14 +73,13 @@ export const getUserList = (data) => { // @Success 200 {string} json "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/setUserAuthority [post] export const setUserAuthority = (data) => { - return service({ - url: "/user/setUserAuthority", - method: 'post', - data: data - }) + return service({ + url: '/user/setUserAuthority', + method: 'post', + data: data + }) } - // @Tags SysUser // @Summary 删除用户 // @Security ApiKeyAuth @@ -89,11 +89,11 @@ export const setUserAuthority = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/deleteUser [delete] export const deleteUser = (data) => { - return service({ - url: "/user/deleteUser", - method: 'delete', - data: data - }) + return service({ + url: '/user/deleteUser', + method: 'delete', + data: data + }) } // @Tags SysUser @@ -105,9 +105,39 @@ export const deleteUser = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/setUserInfo [put] export const setUserInfo = (data) => { - return service({ - url: "/user/setUserInfo", - method: 'put', - data: data - }) -} \ No newline at end of file + return service({ + url: '/user/setUserInfo', + method: 'put', + data: data + }) +} + +// @Tags User +// @Summary 设置用户权限 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body api.setUserAuthorities true "设置用户权限" +// @Success 200 {string} json "{"success":true,"data":{},"msg":"修改成功"}" +// @Router /user/setUserAuthorities [post] +export const setUserAuthorities = (data) => { + return service({ + url: '/user/setUserAuthorities', + method: 'post', + data: data + }) +} + +// @Tags User +// @Summary 获取用户信息 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /user/getUserInfo [get] +export const getUserInfo = () => { + return service({ + url: '/user/getUserInfo', + method: 'get' + }) +} diff --git a/web/src/api/workflowProcess.js b/web/src/api/workflowProcess.js index e73644b1..347df2a6 100644 --- a/web/src/api/workflowProcess.js +++ b/web/src/api/workflowProcess.js @@ -9,14 +9,13 @@ import service from '@/utils/request' // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/createWorkflowProcess [post] export const createWorkflowProcess = (data) => { - return service({ - url: "/workflowProcess/createWorkflowProcess", - method: 'post', - data - }) + return service({ + url: '/workflowProcess/createWorkflowProcess', + method: 'post', + data + }) } - // @Tags WorkflowProcess // @Summary 删除WorkflowProcess // @Security ApiKeyAuth @@ -26,11 +25,11 @@ export const createWorkflowProcess = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /workflowProcess/deleteWorkflowProcess [delete] export const deleteWorkflowProcess = (data) => { - return service({ - url: "/workflowProcess/deleteWorkflowProcess", - method: 'delete', - data - }) + return service({ + url: '/workflowProcess/deleteWorkflowProcess', + method: 'delete', + data + }) } // @Tags WorkflowProcess @@ -42,11 +41,11 @@ export const deleteWorkflowProcess = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /workflowProcess/deleteWorkflowProcess [delete] export const deleteWorkflowProcessByIds = (data) => { - return service({ - url: "/workflowProcess/deleteWorkflowProcessByIds", - method: 'delete', - data - }) + return service({ + url: '/workflowProcess/deleteWorkflowProcessByIds', + method: 'delete', + data + }) } // @Tags WorkflowProcess @@ -58,14 +57,13 @@ export const deleteWorkflowProcessByIds = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /workflowProcess/updateWorkflowProcess [put] export const updateWorkflowProcess = (data) => { - return service({ - url: "/workflowProcess/updateWorkflowProcess", - method: 'put', - data - }) + return service({ + url: '/workflowProcess/updateWorkflowProcess', + method: 'put', + data + }) } - // @Tags WorkflowProcess // @Summary 用id查询WorkflowProcess // @Security ApiKeyAuth @@ -75,14 +73,13 @@ export const updateWorkflowProcess = (data) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /workflowProcess/findWorkflowProcess [get] export const findWorkflowProcess = (params) => { - return service({ - url: "/workflowProcess/findWorkflowProcess", - method: 'get', - params - }) + return service({ + url: '/workflowProcess/findWorkflowProcess', + method: 'get', + params + }) } - // @Tags WorkflowProcess // @Summary 分页获取WorkflowProcess列表 // @Security ApiKeyAuth @@ -92,11 +89,11 @@ export const findWorkflowProcess = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/getWorkflowProcessList [get] export const getWorkflowProcessList = (params) => { - return service({ - url: "/workflowProcess/getWorkflowProcessList", - method: 'get', - params - }) + return service({ + url: '/workflowProcess/getWorkflowProcessList', + method: 'get', + params + }) } // @Tags WorkflowProcess @@ -108,14 +105,13 @@ export const getWorkflowProcessList = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /workflowProcess/findWorkflowStep [get] export const findWorkflowStep = (params) => { - return service({ - url: "/workflowProcess/findWorkflowStep", - method: 'get', - params - }) + return service({ + url: '/workflowProcess/findWorkflowStep', + method: 'get', + params + }) } - // @Tags ExaWfLeave // @Summary 创建ExaWfLeave // @Security ApiKeyAuth @@ -124,15 +120,14 @@ export const findWorkflowStep = (params) => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/startWorkflow [post] export const startWorkflow = (data, params = { businessType: data.wf.businessType }) => { - return service({ - url: "/workflowProcess/startWorkflow", - method: 'post', - data, - params - }) + return service({ + url: '/workflowProcess/startWorkflow', + method: 'post', + data, + params + }) } - // @Tags ExaWfLeave // @Summary 创建ExaWfLeave // @Security ApiKeyAuth @@ -141,28 +136,27 @@ export const startWorkflow = (data, params = { businessType: data.wf.businessTyp // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/completeWorkflowMove [post] export const completeWorkflowMove = (data, params = { businessType: data.wf.businessType }) => { - return service({ - url: "/workflowProcess/completeWorkflowMove", - method: 'post', - data, - params - }) - } - // @Tags WorkflowProcess - // @Summary 我发起的工作流 - // @Security ApiKeyAuth - // @accept application/json - // @Produce application/json - // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" - // @Router /workflowProcess/getMyStated [get] -export const getMyStated = () => { - return service({ - url: "/workflowProcess/getMyStated", - method: 'get', - }) + return service({ + url: '/workflowProcess/completeWorkflowMove', + method: 'post', + data, + params + }) } - +// @Tags WorkflowProcess +// @Summary 我发起的工作流 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /workflowProcess/getMyStated [get] +export const getMyStated = () => { + return service({ + url: '/workflowProcess/getMyStated', + method: 'get' + }) +} // @Tags WorkflowProcess // @Summary 我发起的工作流 @@ -172,10 +166,10 @@ export const getMyStated = () => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/getMyNeed [get] export const getMyNeed = () => { - return service({ - url: "/workflowProcess/getMyNeed", - method: 'get', - }) + return service({ + url: '/workflowProcess/getMyNeed', + method: 'get' + }) } // @Tags WorkflowProcess @@ -187,9 +181,9 @@ export const getMyNeed = () => { // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /workflowProcess/getWorkflowMoveByID [get] export const getWorkflowMoveByID = (params) => { - return service({ - url: "/workflowProcess/getWorkflowMoveByID", - method: 'get', - params - }) -} \ No newline at end of file + return service({ + url: '/workflowProcess/getWorkflowMoveByID', + method: 'get', + params + }) +} diff --git a/web/src/assets/login_background.svg b/web/src/assets/login_background.svg new file mode 100644 index 00000000..0a9514b5 --- /dev/null +++ b/web/src/assets/login_background.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/login_left.svg b/web/src/assets/login_left.svg new file mode 100644 index 00000000..9c48b0b1 --- /dev/null +++ b/web/src/assets/login_left.svg @@ -0,0 +1,123 @@ + + + 搭建网站 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/components/chooseImg/index.vue b/web/src/components/chooseImg/index.vue index 517e401b..73d0462b 100644 --- a/web/src/components/chooseImg/index.vue +++ b/web/src/components/chooseImg/index.vue @@ -2,14 +2,14 @@
- +
@@ -18,34 +18,40 @@ \ No newline at end of file + diff --git a/web/src/components/customPic/index.vue b/web/src/components/customPic/index.vue index 956c67af..a4785f08 100644 --- a/web/src/components/customPic/index.vue +++ b/web/src/components/customPic/index.vue @@ -1,63 +1,63 @@ diff --git a/web/src/components/upload/image.vue b/web/src/components/upload/image.vue index 47479df5..c0acc258 100644 --- a/web/src/components/upload/image.vue +++ b/web/src/components/upload/image.vue @@ -1,12 +1,3 @@ - + diff --git a/web/src/view/dashboard/component/todoList/Todo.vue b/web/src/view/dashboard/component/todoList/Todo.vue index 1ca0af92..c4b3cae2 100644 --- a/web/src/view/dashboard/component/todoList/Todo.vue +++ b/web/src/view/dashboard/component/todoList/Todo.vue @@ -1,81 +1,81 @@ diff --git a/web/src/view/dashboard/component/todoList/index.vue b/web/src/view/dashboard/component/todoList/index.vue index 7e2159a4..79d7a164 100644 --- a/web/src/view/dashboard/component/todoList/index.vue +++ b/web/src/view/dashboard/component/todoList/index.vue @@ -1,120 +1,120 @@ \ No newline at end of file + diff --git a/web/src/view/example/breakpoint/breakpoint.vue b/web/src/view/example/breakpoint/breakpoint.vue index a297f305..3388c7e5 100644 --- a/web/src/view/example/breakpoint/breakpoint.vue +++ b/web/src/view/example/breakpoint/breakpoint.vue @@ -1,30 +1,31 @@ + \ No newline at end of file + diff --git a/web/src/view/example/excel/excel.vue b/web/src/view/example/excel/excel.vue index c211eb89..16bf1d1c 100644 --- a/web/src/view/example/excel/excel.vue +++ b/web/src/view/example/excel/excel.vue @@ -1,44 +1,40 @@ + \ No newline at end of file + + + diff --git a/web/src/view/example/index.vue b/web/src/view/example/index.vue index 87b57206..9962dcb4 100644 --- a/web/src/view/example/index.vue +++ b/web/src/view/example/index.vue @@ -1,15 +1,14 @@ - diff --git a/web/src/view/example/simpleUploader/simpleUploader.vue b/web/src/view/example/simpleUploader/simpleUploader.vue index dcfb916d..82c17206 100644 --- a/web/src/view/example/simpleUploader/simpleUploader.vue +++ b/web/src/view/example/simpleUploader/simpleUploader.vue @@ -2,152 +2,150 @@ - +

拖拽文件至此或点击

选择文件
- +
\ No newline at end of file + diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index 70b2f7d5..898e01e4 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -12,12 +12,12 @@ :show-file-list="false" > 点击上传 -
只能上传jpg/png文件,且不超过500kb
+
只能上传jpg/png文件,且不超过500kb
带压缩的上传, (512(k)为压缩限制) - + 已上传文件 {{ imageUrl }} @@ -25,7 +25,7 @@ @@ -33,8 +33,8 @@
{{ scope.row.UpdatedAt | formatDate }}
- - + + diff --git a/web/src/view/iconList/index.vue b/web/src/view/iconList/index.vue index 61199e9d..4d1e9283 100644 --- a/web/src/view/iconList/index.vue +++ b/web/src/view/iconList/index.vue @@ -1,305 +1,304 @@ diff --git a/web/src/view/init/init.vue b/web/src/view/init/init.vue index 2b20dbe1..4b224ceb 100644 --- a/web/src/view/init/init.vue +++ b/web/src/view/init/init.vue @@ -5,28 +5,27 @@
- - - + + - + - + - + + /> - +
@@ -39,46 +38,47 @@ + \ No newline at end of file diff --git a/web/src/view/layout/aside/asideComponent/index.vue b/web/src/view/layout/aside/asideComponent/index.vue index 004f1e66..98be93f5 100644 --- a/web/src/view/layout/aside/asideComponent/index.vue +++ b/web/src/view/layout/aside/asideComponent/index.vue @@ -1,7 +1,7 @@ @@ -12,14 +12,9 @@ import AsyncSubmenu from './asyncSubmenu' export default { name: 'AsideComponent', - computed: { - menuComponent() { - if (this.routerInfo.children&&this.routerInfo.children.filter(item=>!item.hidden).length) { - return 'AsyncSubmenu' - } else { - return 'MenuItem' - } - } + components: { + MenuItem, + AsyncSubmenu }, props: { routerInfo: { @@ -29,11 +24,14 @@ export default { type: Object } }, - components: { - MenuItem, - AsyncSubmenu + computed: { + menuComponent() { + if (this.routerInfo.children && this.routerInfo.children.filter(item => !item.hidden).length) { + return 'AsyncSubmenu' + } else { + return 'MenuItem' + } + } } } - \ No newline at end of file diff --git a/web/src/view/layout/aside/asideComponent/menuItem.vue b/web/src/view/layout/aside/asideComponent/menuItem.vue index bfb14783..b7fc90f0 100644 --- a/web/src/view/layout/aside/asideComponent/menuItem.vue +++ b/web/src/view/layout/aside/asideComponent/menuItem.vue @@ -1,7 +1,7 @@ @@ -18,5 +18,3 @@ export default { } } - \ No newline at end of file diff --git a/web/src/view/layout/aside/historyComponent/history.vue b/web/src/view/layout/aside/historyComponent/history.vue index e546d75b..ec645799 100644 --- a/web/src/view/layout/aside/historyComponent/history.vue +++ b/web/src/view/layout/aside/historyComponent/history.vue @@ -1,24 +1,27 @@ - \ No newline at end of file + diff --git a/web/src/view/layout/bottomInfo/bottomInfo.vue b/web/src/view/layout/bottomInfo/bottomInfo.vue index 889136fe..98b3e2b3 100644 --- a/web/src/view/layout/bottomInfo/bottomInfo.vue +++ b/web/src/view/layout/bottomInfo/bottomInfo.vue @@ -3,21 +3,23 @@
+ + diff --git a/web/src/view/layout/screenfull/index.vue b/web/src/view/layout/screenfull/index.vue index b1c1ef7a..1fba70ce 100644 --- a/web/src/view/layout/screenfull/index.vue +++ b/web/src/view/layout/screenfull/index.vue @@ -25,60 +25,93 @@ d="M333.590658 594.033341 167.8171 759.804852 64.218604 655.67219 64.218604 958.270996 366.342596 958.502263 262.234493 855.071589 428.421466 688.86108Z" p-id="2073"/> --> - + - + - + - + - - + + - - - - - - - + fill="" + p-id="1864" + /> + + + + + + +
+ + \ No newline at end of file + diff --git a/web/src/view/layout/setting/index.vue b/web/src/view/layout/setting/index.vue new file mode 100644 index 00000000..654b5c9a --- /dev/null +++ b/web/src/view/layout/setting/index.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/web/src/view/login/index.vue b/web/src/view/login/index.vue new file mode 100644 index 00000000..738eade2 --- /dev/null +++ b/web/src/view/login/index.vue @@ -0,0 +1,173 @@ + + + + + diff --git a/web/src/view/login/login.vue b/web/src/view/login/login.vue deleted file mode 100644 index 7aeb82af..00000000 --- a/web/src/view/login/login.vue +++ /dev/null @@ -1,165 +0,0 @@ - - - - - diff --git a/web/src/view/person/person.vue b/web/src/view/person/person.vue index 2cde321b..c33e085e 100644 --- a/web/src/view/person/person.vue +++ b/web/src/view/person/person.vue @@ -4,29 +4,34 @@
-
+
- + 重新上传 -
+
-

{{userInfo.nickName}}

+

{{ userInfo.nickName }}

这个家伙很懒,什么都没有留下

  • - {{userInfo.nickName}} + {{ userInfo.nickName }}
  • + +
  • + 北京反转极光科技有限公司-技术部-前端事业群 +
  • +
  • - 北京反转极光科技有限公司-技术部-前端事业群 -
  • -
  • - 中国·北京市·朝阳区 -
  • -
  • - goLang/JavaScript/Vue/Gorm + 中国·北京市·朝阳区
  • + +
  • + goLang/JavaScript/Vue/Gorm +
  • +
    +
@@ -74,73 +79,74 @@ - - + + - + - + - + - - + \ No newline at end of file + diff --git a/web/src/view/routerHolder.vue b/web/src/view/routerHolder.vue index 1a382f96..b8fec872 100644 --- a/web/src/view/routerHolder.vue +++ b/web/src/view/routerHolder.vue @@ -1,16 +1,15 @@ - diff --git a/web/src/view/superAdmin/api/api.vue b/web/src/view/superAdmin/api/api.vue index e5d586d0..78183e90 100644 --- a/web/src/view/superAdmin/api/api.vue +++ b/web/src/view/superAdmin/api/api.vue @@ -3,61 +3,57 @@
- + - + - + - + + /> - 查询 - - - 新增api - - - + 查询 + 新增 +

确定要删除吗?

-
- 取消 - 确定 -
- 批量删除 +
+ 取消 + 确定 +
+ 批量删除
- - + - - - - - + width="55" + /> + + + + @@ -65,12 +61,12 @@ @@ -81,43 +77,42 @@ :page-sizes="[10, 30, 50, 100]" :style="{float:'right',padding:'20px'}" :total="total" + layout="total, sizes, prev, pager, next, jumper" @current-change="handleCurrentChange" @size-change="handleSizeChange" - layout="total, sizes, prev, pager, next, jumper" - > + /> - + - + - + + /> - + - +
新增Api需要在角色管理内配置权限才可使用
- - + \ No newline at end of file + diff --git a/web/src/view/superAdmin/authority/authority.vue b/web/src/view/superAdmin/authority/authority.vue index 52569572..8497af11 100644 --- a/web/src/view/superAdmin/authority/authority.vue +++ b/web/src/view/superAdmin/authority/authority.vue @@ -1,7 +1,7 @@ + - diff --git a/web/src/view/systemTools/formCreate/index.vue b/web/src/view/systemTools/formCreate/index.vue index 2ca75bdd..0b976223 100644 --- a/web/src/view/systemTools/formCreate/index.vue +++ b/web/src/view/systemTools/formCreate/index.vue @@ -1,20 +1,17 @@