1
This commit is contained in:
		
							
								
								
									
										23
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | |||||||
|  | .idea | ||||||
|  | .vscode | ||||||
|  | */.DS_Store | ||||||
|  | static/uploadfile | ||||||
|  | main.exe | ||||||
|  | *.exe | ||||||
|  | go-admin | ||||||
|  | go-admin.exe | ||||||
|  | temp/ | ||||||
|  | !temp | ||||||
|  | vendor | ||||||
|  | config/settings.dev.yml | ||||||
|  | config/settings.dev.*.yml | ||||||
|  | config/settings.dev.*.yml.log | ||||||
|  | temp/logs | ||||||
|  | config/settings.dev.yml.log | ||||||
|  | config/settings.b.dev.yml | ||||||
|  | cmd/migrate/migration/version-local/* | ||||||
|  | !cmd/migrate/migration/version-local/doc.go | ||||||
|  |  | ||||||
|  | # go sum | ||||||
|  | go.sum | ||||||
|  | config/settings.deva.yml | ||||||
							
								
								
									
										18
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | |||||||
|  | FROM alpine | ||||||
|  |  | ||||||
|  | # ENV GOPROXY https://goproxy.cn/ | ||||||
|  |  | ||||||
|  | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories | ||||||
|  |  | ||||||
|  | RUN apk update --no-cache | ||||||
|  | RUN apk add --update gcc g++ libc6-compat | ||||||
|  | RUN apk add --no-cache ca-certificates | ||||||
|  | RUN apk add --no-cache tzdata | ||||||
|  | ENV TZ Asia/Shanghai | ||||||
|  |  | ||||||
|  | COPY ./main /main | ||||||
|  | COPY ./config/settings.demo.yml /config/settings.yml | ||||||
|  | COPY ./go-admin-db.db /go-admin-db.db | ||||||
|  | EXPOSE 8000 | ||||||
|  | RUN  chmod +x /main | ||||||
|  | CMD ["/main","server","-c", "/config/settings.yml"] | ||||||
							
								
								
									
										28
									
								
								Dockerfilebak
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Dockerfilebak
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | |||||||
|  | FROM golang:alpine as builder | ||||||
|  |  | ||||||
|  | MAINTAINER lwnmengjing | ||||||
|  |  | ||||||
|  | ENV GOPROXY https://goproxy.cn/ | ||||||
|  |  | ||||||
|  | WORKDIR /go/release | ||||||
|  | #RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories | ||||||
|  | RUN apk update && apk add tzdata | ||||||
|  |  | ||||||
|  | COPY go.mod ./go.mod | ||||||
|  | RUN go mod tidy | ||||||
|  | COPY . . | ||||||
|  | RUN pwd && ls | ||||||
|  |  | ||||||
|  | RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin . | ||||||
|  |  | ||||||
|  | FROM alpine | ||||||
|  |  | ||||||
|  | COPY --from=builder /go/release/go-admin / | ||||||
|  |  | ||||||
|  | COPY --from=builder /go/release/config/settings.yml /config/settings.yml | ||||||
|  |  | ||||||
|  | COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||||||
|  |  | ||||||
|  | EXPOSE 8000 | ||||||
|  |  | ||||||
|  | CMD ["/go-admin","server","-c", "/config/settings.yml"] | ||||||
							
								
								
									
										21
									
								
								LICENSE.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								LICENSE.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | |||||||
|  | MIT License | ||||||
|  |  | ||||||
|  | Copyright (c) 2020 go-admin-team | ||||||
|  |  | ||||||
|  | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  | of this software and associated documentation files (the "Software"), to deal | ||||||
|  | in the Software without restriction, including without limitation the rights | ||||||
|  | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||
|  | copies of the Software, and to permit persons to whom the Software is | ||||||
|  | furnished to do so, subject to the following conditions: | ||||||
|  |  | ||||||
|  | The above copyright notice and this permission notice shall be included in all | ||||||
|  | copies or substantial portions of the Software. | ||||||
|  |  | ||||||
|  | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||
|  | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||
|  | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||
|  | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||
|  | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||
|  | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  | SOFTWARE. | ||||||
							
								
								
									
										54
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | |||||||
|  | PROJECT:=go-admin | ||||||
|  |  | ||||||
|  | .PHONY: build | ||||||
|  | build: | ||||||
|  | 	CGO_ENABLED=0 go build -ldflags="-w -s" -a -installsuffix "" -o go-admin . | ||||||
|  |  | ||||||
|  | # make build-linux | ||||||
|  | build-linux: | ||||||
|  | 	@docker build -t go-admin:latest . | ||||||
|  | 	@echo "build successful" | ||||||
|  |  | ||||||
|  | build-sqlite: | ||||||
|  | 	go build -tags sqlite3 -ldflags="-w -s" -a -installsuffix -o go-admin . | ||||||
|  |  | ||||||
|  | # make run | ||||||
|  | run: | ||||||
|  |     # delete go-admin-api container | ||||||
|  | 	@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi | ||||||
|  |  | ||||||
|  |     # 启动方法一 run go-admin-api container  docker-compose 启动方式 | ||||||
|  |     # 进入到项目根目录 执行 make run 命令 | ||||||
|  | 	@docker-compose up -d | ||||||
|  |  | ||||||
|  | 	# 启动方式二 docker run  这里注意-v挂载的宿主机的地址改为部署时的实际决对路径 | ||||||
|  |     #@docker run --name=go-admin -p 8000:8000 -v /home/code/go/src/go-admin/go-admin/config:/go-admin-api/config  -v /home/code/go/src/go-admin/go-admin-api/static:/go-admin/static -v /home/code/go/src/go-admin/go-admin/temp:/go-admin-api/temp -d --restart=always go-admin:latest | ||||||
|  |  | ||||||
|  | 	@echo "go-admin service is running..." | ||||||
|  |  | ||||||
|  | 	# delete Tag=<none> 的镜像 | ||||||
|  | 	@docker image prune -f | ||||||
|  | 	@docker ps -a | grep "go-admin" | ||||||
|  |  | ||||||
|  | stop: | ||||||
|  |     # delete go-admin-api container | ||||||
|  | 	@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker-compose down; fi | ||||||
|  | 	#@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi | ||||||
|  | 	#@echo "go-admin stop success" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #.PHONY: test | ||||||
|  | #test: | ||||||
|  | #	go test -v ./... -cover | ||||||
|  |  | ||||||
|  | #.PHONY: docker | ||||||
|  | #docker: | ||||||
|  | #	docker build . -t go-admin:latest | ||||||
|  |  | ||||||
|  | # make deploy | ||||||
|  | deploy: | ||||||
|  |  | ||||||
|  | 	#@git checkout master | ||||||
|  | 	#@git pull origin master | ||||||
|  | 	make build-linux | ||||||
|  | 	make run | ||||||
							
								
								
									
										352
									
								
								README.Zh-cn.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										352
									
								
								README.Zh-cn.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,352 @@ | |||||||
|  | # go-admin | ||||||
|  |  | ||||||
|  |   <img align="right" width="320" src="https://doc-image.zhangwj.com/img/go-admin.svg"> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | [](https://github.com/go-admin-team/go-admin) | ||||||
|  | [](https://github.com/go-admin-team/go-admin/releases) | ||||||
|  | [](https://github.com/go-admin-team/go-admin) | ||||||
|  |  | ||||||
|  | [English](https://github.com/go-admin-team/go-admin/blob/master/README.md) | 简体中文 | ||||||
|  |  | ||||||
|  | 基于Gin + Vue + Element UI OR Arco Design OR Ant Design的前后端分离权限管理系统,系统初始化极度简单,只需要配置文件中,修改数据库连接,系统支持多指令操作,迁移指令可以让初始化数据库信息变得更简单,服务指令可以很简单的启动api服务 | ||||||
|  |  | ||||||
|  | [在线文档](https://www.go-admin.pro) | ||||||
|  |  | ||||||
|  | [前端项目](https://github.com/go-admin-team/go-admin-ui) | ||||||
|  |  | ||||||
|  | [视频教程](https://space.bilibili.com/565616721/channel/detail?cid=125737) | ||||||
|  |  | ||||||
|  | ## 🎬 在线体验 | ||||||
|  |  | ||||||
|  | Element UI vue体验:[https://vue2.go-admin.dev](https://vue2.go-admin.dev/#/login) | ||||||
|  | > ⚠️⚠️⚠️ 账号 / 密码: admin / 123456 | ||||||
|  |  | ||||||
|  | Arco Design vue3 demo:[https://vue3.go-admin.dev](https://vue3.go-admin.dev/#/login) | ||||||
|  | > ⚠️⚠️⚠️ 账号 / 密码: admin / 123456 | ||||||
|  |  | ||||||
|  | antd体验:[https://antd.go-admin.pro](https://antd.go-admin.pro/) | ||||||
|  | > ⚠️⚠️⚠️ 账号 / 密码: admin / 123456 | ||||||
|  |  | ||||||
|  | ## ✨ 特性 | ||||||
|  |  | ||||||
|  | - 遵循 RESTful API 设计规范 | ||||||
|  |  | ||||||
|  | - 基于 GIN WEB API 框架,提供了丰富的中间件支持(用户认证、跨域、访问日志、追踪ID等) | ||||||
|  |  | ||||||
|  | - 基于Casbin的 RBAC 访问控制模型 | ||||||
|  |  | ||||||
|  | - JWT 认证 | ||||||
|  |  | ||||||
|  | - 支持 Swagger 文档(基于swaggo) | ||||||
|  |  | ||||||
|  | - 基于 GORM 的数据库存储,可扩展多种类型数据库 | ||||||
|  |  | ||||||
|  | - 配置文件简单的模型映射,快速能够得到想要的配置 | ||||||
|  |  | ||||||
|  | - 代码生成工具 | ||||||
|  |  | ||||||
|  | - 表单构建工具 | ||||||
|  |  | ||||||
|  | - 多指令模式 | ||||||
|  |  | ||||||
|  | - 多租户的支持 | ||||||
|  |  | ||||||
|  | - TODO: 单元测试 | ||||||
|  |  | ||||||
|  | ## 🎁 内置 | ||||||
|  |  | ||||||
|  | 1. 多租户:系统默认支持多租户,按库分离,一个库一个租户。 | ||||||
|  | 1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 | ||||||
|  | 2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。 | ||||||
|  | 3. 岗位管理:配置系统用户所属担任职务。 | ||||||
|  | 4. 菜单管理:配置系统菜单,操作权限,按钮权限标识,接口权限等。 | ||||||
|  | 5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 | ||||||
|  | 6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。 | ||||||
|  | 7. 参数管理:对系统动态配置常用参数。 | ||||||
|  | 8. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 | ||||||
|  | 9. 登录日志:系统登录日志记录查询包含登录异常。 | ||||||
|  | 1. 接口文档:根据业务代码自动生成相关的api接口文档。 | ||||||
|  | 1. 代码生成:根据数据表结构生成对应的增删改查相对应业务,全程可视化操作,让基本业务可以零代码实现。 | ||||||
|  | 1. 表单构建:自定义页面样式,拖拉拽实现页面布局。 | ||||||
|  | 1. 服务监控:查看一些服务器的基本信息。 | ||||||
|  | 1. 内容管理:demo功能,下设分类管理、内容管理。可以参考使用方便快速入门。 | ||||||
|  | 1. 定时任务:自动化任务,目前支持接口调用和函数调用。 | ||||||
|  |  | ||||||
|  | ## 准备工作 | ||||||
|  |  | ||||||
|  | 你需要在本地安装 [go] [gin] [node](http://nodejs.org/) 和 [git](https://git-scm.com/)  | ||||||
|  |  | ||||||
|  | 同时配套了系列教程包含视频和文档,如何从下载完成到熟练使用,强烈建议大家先看完这些教程再来实践本项目!!! | ||||||
|  |  | ||||||
|  | ### 轻松实现go-admin写出第一个应用 - 文档教程 | ||||||
|  |  | ||||||
|  | [步骤一 - 基础内容介绍](https://doc.zhangwj.com/guide/intro/tutorial01.html) | ||||||
|  |  | ||||||
|  | [步骤二 - 实际应用 - 编写增删改查](https://doc.zhangwj.com/guide/intro/tutorial02.html) | ||||||
|  |  | ||||||
|  | ### 手把手教你从入门到放弃 - 视频教程 | ||||||
|  |  | ||||||
|  | [如何启动go-admin](https://www.bilibili.com/video/BV1z5411x7JG) | ||||||
|  |  | ||||||
|  | [使用生成工具轻松实现业务](https://www.bilibili.com/video/BV1Dg4y1i79D) | ||||||
|  |  | ||||||
|  | [v1.1.0版本代码生成工具-释放双手](https://www.bilibili.com/video/BV1N54y1i71P) [进阶] | ||||||
|  |  | ||||||
|  | [多命令启动方式讲解以及IDE配置](https://www.bilibili.com/video/BV1Fg4y1q7ph) | ||||||
|  |  | ||||||
|  | [go-admin菜单的配置说明](https://www.bilibili.com/video/BV1Wp4y1D715) [必看] | ||||||
|  |  | ||||||
|  | [如何配置菜单信息以及接口信息](https://www.bilibili.com/video/BV1zv411B7nG) [必看] | ||||||
|  |  | ||||||
|  | [go-admin权限配置使用说明](https://www.bilibili.com/video/BV1rt4y197d3) [必看] | ||||||
|  |  | ||||||
|  | [go-admin数据权限使用说明](https://www.bilibili.com/video/BV1LK4y1s71e) [必看] | ||||||
|  |  | ||||||
|  | **如有问题请先看上述使用文档和文章,若不能满足,欢迎 issue 和 pr ,视频教程和文档持续更新中** | ||||||
|  |  | ||||||
|  | ## 📦 本地开发 | ||||||
|  |  | ||||||
|  | ### 环境要求 | ||||||
|  |  | ||||||
|  | go 1.18 | ||||||
|  |  | ||||||
|  | node版本: v14.16.0 | ||||||
|  |  | ||||||
|  | npm版本: 6.14.11 | ||||||
|  |  | ||||||
|  | ### 开发目录创建 | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  |  | ||||||
|  | # 创建开发目录 | ||||||
|  | mkdir goadmin | ||||||
|  | cd goadmin | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### 获取代码 | ||||||
|  |  | ||||||
|  | > 重点注意:两个项目必须放在同一文件夹下; | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # 获取后端代码 | ||||||
|  | git clone https://github.com/go-admin-team/go-admin.git | ||||||
|  |  | ||||||
|  | # 获取前端代码 | ||||||
|  | git clone https://github.com/go-admin-team/go-admin-ui.git | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### 启动说明 | ||||||
|  |  | ||||||
|  | #### 服务端启动说明 | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # 进入 go-admin 后端项目 | ||||||
|  | cd ./go-admin | ||||||
|  |  | ||||||
|  | # 更新整理依赖 | ||||||
|  | go mod tidy | ||||||
|  |  | ||||||
|  | # 编译项目 | ||||||
|  | go build | ||||||
|  |  | ||||||
|  | # 修改配置  | ||||||
|  | # 文件路径  go-admin/config/settings.yml | ||||||
|  | vi ./config/settings.yml | ||||||
|  |  | ||||||
|  | # 1. 配置文件中修改数据库信息  | ||||||
|  | # 注意: settings.database 下对应的配置数据 | ||||||
|  | # 2. 确认log路径 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ⚠️注意 在windows环境如果没有安装中CGO,会出现这个问题; | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | E:\go-admin>go build | ||||||
|  | # github.com/mattn/go-sqlite3 | ||||||
|  | cgo: exec /missing-cc: exec: "/missing-cc": file does not exist | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | or | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | D:\Code\go-admin>go build | ||||||
|  | # github.com/mattn/go-sqlite3 | ||||||
|  | cgo: exec gcc: exec: "gcc": executable file not found in %PATH% | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | [解决cgo问题进入](https://doc.go-admin.dev/zh-CN/guide/faq#cgo-%E7%9A%84%E9%97%AE%E9%A2%98) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #### 初始化数据库,以及服务启动 | ||||||
|  |  | ||||||
|  | ``` bash | ||||||
|  | # 首次配置需要初始化数据库资源信息 | ||||||
|  | # macOS or linux 下使用 | ||||||
|  | $ ./go-admin migrate -c config/settings.dev.yml | ||||||
|  |  | ||||||
|  | # ⚠️注意:windows 下使用 | ||||||
|  | $ go-admin.exe migrate -c config/settings.dev.yml | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # 启动项目,也可以用IDE进行调试 | ||||||
|  | # macOS or linux 下使用 | ||||||
|  | $ ./go-admin server -c config/settings.yml | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # ⚠️注意:windows 下使用 | ||||||
|  | $ go-admin.exe server -c config/settings.yml | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### sys_api 表的数据如何添加 | ||||||
|  |  | ||||||
|  | 在项目启动时,使用`-a true` 系统会自动添加缺少的接口数据 | ||||||
|  | ```bash | ||||||
|  | ./go-admin server -c config/settings.yml -a true | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### 使用docker 编译启动 | ||||||
|  |  | ||||||
|  | ```shell | ||||||
|  | # 编译镜像 | ||||||
|  | docker build -t go-admin . | ||||||
|  |  | ||||||
|  | # 启动容器,第一个go-admin是容器名字,第二个go-admin是镜像名称 | ||||||
|  | # -v 映射配置文件 本地路径:容器路径 | ||||||
|  | docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### 文档生成 | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | go generate | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### 交叉编译 | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # windows | ||||||
|  | env GOOS=windows GOARCH=amd64 go build main.go | ||||||
|  |  | ||||||
|  | # or | ||||||
|  | # linux | ||||||
|  | env GOOS=linux GOARCH=amd64 go build main.go | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### UI交互端启动说明 | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # 安装依赖 | ||||||
|  | npm install | ||||||
|  |  | ||||||
|  | # 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题 | ||||||
|  | npm install --registry=https://registry.npmmirror.com | ||||||
|  |  | ||||||
|  | # 启动服务 | ||||||
|  | npm run dev | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## 📨 互动 | ||||||
|  |  | ||||||
|  | <table> | ||||||
|  |    <tr> | ||||||
|  |     <td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/wx.png" width="180px"></td> | ||||||
|  |     <td><img src="https://doc-image.zhangwj.com/img/qrcode_for_gh_b798dc7db30c_258.jpg" width="180px"></td> | ||||||
|  |     <td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq2.png" width="200px"></td> | ||||||
|  |     <td><a href="https://space.bilibili.com/565616721">wenjianzhang</a></td> | ||||||
|  |   </tr> | ||||||
|  |   <tr> | ||||||
|  |     <td>微信</td> | ||||||
|  |     <td>公众号🔥🔥🔥</td> | ||||||
|  |     <td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流乙号" title="go-admin技术交流乙号"></a></td> | ||||||
|  |     <td>哔哩哔哩🔥🔥🔥</td> | ||||||
|  |   </tr> | ||||||
|  | </table> | ||||||
|  |  | ||||||
|  | ## 💎 贡献者 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wenjianzhang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3890175?v=4&h=60&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/G-Akiraka" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/45746659?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/lwnmengjing" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/12806223?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/bing127" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/31166183?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/chengxiao" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/1379545?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/NightFire0307" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19854086?v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/appleboy" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/21979?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/ninstein" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/580303?v=4&h=60&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/kikiyou" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/17959053?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/horizonzy" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/22524871?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Cassuis" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/48005724?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/hqcchina" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/5179057?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/nodece" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16235121?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/stephenzhang0713" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/18169290?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zhouxixi-dev" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/100399679?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Jalins" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/31172582?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wkf928592" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/6063351?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wxxiong6" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/6983441?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Silicon-He" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/52478309?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/GizmoOAO" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/20385106?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/bestgopher" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/36840497?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wxb1207" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/20775558?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/misakichan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16569274?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zhuxuyang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19301024?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/mss-boot" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/109259065?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/AuroraV" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Vingurzhou" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/57127283?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/haimait" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40926384?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zyd" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3446278?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/infnan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/38274826?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/d1y" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/45585937?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/qlijin" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/515900?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/logtous | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/88697234?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/stepway | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/9927079?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/NaturalGao | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/43291304?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/DemoLiang | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/23476007?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/jfcg | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/1410597?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Nicole0724 | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/10487328?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  |  | ||||||
|  | ## JetBrains 开源证书支持 | ||||||
|  |  | ||||||
|  | `go-admin` 项目一直以来都是在 JetBrains 公司旗下的 GoLand 集成开发环境中进行开发,基于 **free JetBrains Open Source license(s)** 正版免费授权,在此表达我的谢意。 | ||||||
|  |  | ||||||
|  | <a href="https://www.jetbrains.com/?from=kubeadm-ha" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="250" align="middle"/></a> | ||||||
|  |  | ||||||
|  | ## 🤝 特别感谢 | ||||||
|  |  | ||||||
|  | 1. [ant-design](https://github.com/ant-design/ant-design) | ||||||
|  | 2. [ant-design-pro](https://github.com/ant-design/ant-design-pro) | ||||||
|  | 2. [arco-design](https://github.com/arco-design/arco-design) | ||||||
|  | 2. [arco-design-pro](https://github.com/arco-design/arco-design-pro) | ||||||
|  | 4. [gin](https://github.com/gin-gonic/gin) | ||||||
|  | 5. [casbin](https://github.com/casbin/casbin) | ||||||
|  | 6. [spf13/viper](https://github.com/spf13/viper) | ||||||
|  | 7. [gorm](https://github.com/jinzhu/gorm) | ||||||
|  | 8. [gin-swagger](https://github.com/swaggo/gin-swagger) | ||||||
|  | 9. [jwt-go](https://github.com/dgrijalva/jwt-go) | ||||||
|  | 10. [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) | ||||||
|  | 11. [ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue) | ||||||
|  | 12. [form-generator](https://github.com/JakHuang/form-generator) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## 🤟 打赏 | ||||||
|  |  | ||||||
|  | > 如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 :tropical_drink: | ||||||
|  |  | ||||||
|  | <img class="no-margin" src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/pay.png"  height="200px" > | ||||||
|  |  | ||||||
|  | ## 🤝 链接 | ||||||
|  |  | ||||||
|  | [Go开发者成长线路图](http://www.golangroadmap.com/) | ||||||
|  |  | ||||||
|  | ## 🔑 License | ||||||
|  |  | ||||||
|  | [MIT](https://github.com/go-admin-team/go-admin/blob/master/LICENSE.md) | ||||||
|  |  | ||||||
|  | Copyright (c) 2024 wenjianzhang | ||||||
							
								
								
									
										342
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										342
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,342 @@ | |||||||
|  |  | ||||||
|  | # go-admin | ||||||
|  |  | ||||||
|  | <img align="right" width="320" src="https://doc-image.zhangwj.com/img/go-admin.svg"> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | [](https://github.com/go-admin-team/go-admin) | ||||||
|  | [](https://github.com/go-admin-team/go-admin/releases) | ||||||
|  | [](https://github.com/go-admin-team/go-admin) | ||||||
|  |  | ||||||
|  | English | [简体中文](https://github.com/go-admin-team/go-admin/blob/master/README.Zh-cn.md) | ||||||
|  |  | ||||||
|  | The front-end and back-end separation authority management system based on Gin + Vue + Element UI OR Arco Design is extremely simple to initialize the system. You only need to modify the database connection in the configuration file. The system supports multi-instruction operations. Migration instructions can make it easier to initialize database information. Service instructions It's easy to start the api service. | ||||||
|  |  | ||||||
|  | [documentation](https://www.go-admin.dev) | ||||||
|  |  | ||||||
|  | [Front-end project](https://github.com/go-admin-team/go-admin-ui) | ||||||
|  |  | ||||||
|  | [Video tutorial](https://space.bilibili.com/565616721/channel/detail?cid=125737) | ||||||
|  |  | ||||||
|  | ## 🎬 Online Demo | ||||||
|  |  | ||||||
|  | Element UI vue demo:[https://vue2.go-admin.dev](https://vue2.go-admin.dev/#/login) | ||||||
|  | > 账号 / 密码: admin / 123456 | ||||||
|  |  | ||||||
|  | Arco Design vue3 demo:[https://vue3.go-admin.dev](https://vue3.go-admin.dev/#/login) | ||||||
|  | > 账号 / 密码: admin / 123456 | ||||||
|  |  | ||||||
|  | antd demo:[https://antd.go-admin.pro](https://antd.go-admin.pro/) | ||||||
|  | > 账号 / 密码: admin / 123456 | ||||||
|  | >  | ||||||
|  | ## ✨ Feature | ||||||
|  |  | ||||||
|  | - Follow RESTful API design specifications | ||||||
|  |  | ||||||
|  | - Based on the GIN WEB API framework, it provides rich middleware support (user authentication, cross-domain, access log, tracking ID, etc.) | ||||||
|  |  | ||||||
|  | - RBAC access control model based on Casbin | ||||||
|  |  | ||||||
|  | - JWT authentication | ||||||
|  |  | ||||||
|  | - Support Swagger documents (based on swaggo) | ||||||
|  |  | ||||||
|  | - Database storage based on GORM, which can expand multiple types of databases | ||||||
|  |  | ||||||
|  | - Simple model mapping of configuration files to quickly get the desired configuration | ||||||
|  |  | ||||||
|  | - Code generation tool | ||||||
|  |  | ||||||
|  | - Form builder | ||||||
|  |  | ||||||
|  | - Multi-command mode | ||||||
|  |  | ||||||
|  | - TODO: unit test | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## 🎁 Internal | ||||||
|  |  | ||||||
|  | 1. User management: The user is the system operator, this function mainly completes the system user configuration. | ||||||
|  | 2. Department management: configure the system organization (company, department, group), and display the tree structure to support data permissions. | ||||||
|  | 3. Position management: configure the positions of system users. | ||||||
|  | 4. Menu management: configure the system menu, operation authority, button authority identification, interface authority, etc. | ||||||
|  | 5. Role management: Role menu permission assignment and role setting are divided into data scope permissions by organization. | ||||||
|  | 6. Dictionary management: Maintain some relatively fixed data frequently used in the system. | ||||||
|  | 7. Parameter management: dynamically configure common parameters for the system. | ||||||
|  | 8. Operation log: system normal operation log record and query; system abnormal information log record and query. | ||||||
|  | 9. Login log: The system login log record query contains login exceptions. | ||||||
|  | 1. Interface documentation: Automatically generate related api interface documents according to the business code. | ||||||
|  | 1. Code generation: According to the data table structure, generate the corresponding addition, deletion, modification, and check corresponding business, and the whole process of visual operation, so that the basic business can be implemented with zero code. | ||||||
|  | 1. Form construction: Customize the page style, drag and drop to realize the page layout. | ||||||
|  | 1. Service monitoring: View the basic information of some servers. | ||||||
|  | 1. Content management: demo function, including classification management and content management. You can refer to the easy to use quick start. | ||||||
|  |  | ||||||
|  | ## Ready to work | ||||||
|  |  | ||||||
|  | You need to install locally [go] [gin] [node](http://nodejs.org/) 和 [git](https://git-scm.com/) | ||||||
|  |  | ||||||
|  | At the same time, a series of tutorials including videos and documents are provided. How to complete the downloading to the proficient use, it is strongly recommended that you read these tutorials before you practice this project! ! ! | ||||||
|  |  | ||||||
|  | ### Easily implement go-admin to write the first application-documentation tutorial | ||||||
|  |  | ||||||
|  | [Step 1 - basic content introduction](https://doc.zhangwj.com/guide/intro/tutorial01.html) | ||||||
|  |  | ||||||
|  | [Step 2 - Practical application - writing database operations](https://doc.zhangwj.com/guide/intro/tutorial02.html) | ||||||
|  |  | ||||||
|  | ### Teach you from getting started to giving up-video tutorial | ||||||
|  |  | ||||||
|  | [How to start go-admin](https://www.bilibili.com/video/BV1z5411x7JG) | ||||||
|  |  | ||||||
|  | [Easily implement business using build tools](https://www.bilibili.com/video/BV1Dg4y1i79D) | ||||||
|  |  | ||||||
|  | [v1.1.0 version code generation tool-free your hands](https://www.bilibili.com/video/BV1N54y1i71P) [Advanced] | ||||||
|  |  | ||||||
|  | [Explanation of multi-command startup mode and IDE configuration](https://www.bilibili.com/video/BV1Fg4y1q7ph) | ||||||
|  |  | ||||||
|  | [Configuration instructions for go-admin menu](https://www.bilibili.com/video/BV1Wp4y1D715) [Must see] | ||||||
|  |  | ||||||
|  | [How to configure menu information and interface information](https://www.bilibili.com/video/BV1zv411B7nG) [Must see] | ||||||
|  |  | ||||||
|  | [go-admin permission configuration instructions](https://www.bilibili.com/video/BV1rt4y197d3) [Must see] | ||||||
|  |  | ||||||
|  | [Instructions for use of go-admin data permissions](https://www.bilibili.com/video/BV1LK4y1s71e) [Must see] | ||||||
|  |  | ||||||
|  | **If you have any questions, please read the above-mentioned usage documents and articles first. If you are not satisfied, welcome to issue and pr. Video tutorials and documents are being updated continuously.** | ||||||
|  |  | ||||||
|  | ## 📦 Local development | ||||||
|  |  | ||||||
|  | ### Environmental requirements | ||||||
|  |  | ||||||
|  | go 1.18 | ||||||
|  |  | ||||||
|  | nodejs: v14.16.0 | ||||||
|  |  | ||||||
|  | npm: 6.14.11 | ||||||
|  |  | ||||||
|  | ### Development directory creation | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  |  | ||||||
|  | # Create a development directory | ||||||
|  | mkdir goadmin | ||||||
|  | cd goadmin | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### Get the code | ||||||
|  |  | ||||||
|  | > Important note: the two projects must be placed in the same folder; | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # Get backend code | ||||||
|  | git clone https://github.com/go-admin-team/go-admin.git | ||||||
|  |  | ||||||
|  | # Get the front-end code | ||||||
|  | git clone https://github.com/go-admin-team/go-admin-ui.git | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### Startup instructions | ||||||
|  |  | ||||||
|  | #### Server startup instructions | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # Enter the go-admin backend project | ||||||
|  | cd ./go-admin | ||||||
|  |  | ||||||
|  | # Update dependencies | ||||||
|  | go mod tidy | ||||||
|  |  | ||||||
|  | # Compile the project | ||||||
|  | go build | ||||||
|  |  | ||||||
|  | # Change setting  | ||||||
|  | # File path go-admin/config/settings.yml | ||||||
|  | vi ./config/settings.yml | ||||||
|  |  | ||||||
|  | # 1. Modify the database information in the configuration file | ||||||
|  | # Note: The corresponding configuration data under settings.database | ||||||
|  | # 2. Confirm the log path | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | :::tip ⚠️Note that this problem will occur if CGO is not installed in the windows10+ environment; | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | E:\go-admin>go build | ||||||
|  | # github.com/mattn/go-sqlite3 | ||||||
|  | cgo: exec /missing-cc: exec: "/missing-cc": file does not exist | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | or | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | D:\Code\go-admin>go build | ||||||
|  | # github.com/mattn/go-sqlite3 | ||||||
|  | cgo: exec gcc: exec: "gcc": executable file not found in %PATH% | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | [Solve the cgo problem and enter](https://doc.go-admin.dev/guide/faq#cgo-%E7%9A%84%E9%97%AE%E9%A2%98) | ||||||
|  |  | ||||||
|  | ::: | ||||||
|  |  | ||||||
|  | #### Initialize the database, and start the service | ||||||
|  |  | ||||||
|  | ``` bash | ||||||
|  | # The first configuration needs to initialize the database resource information | ||||||
|  | # Use under macOS or linux | ||||||
|  | $ ./go-admin migrate -c config/settings.dev.yml | ||||||
|  |  | ||||||
|  | # ⚠️Note: Use under windows | ||||||
|  | $ go-admin.exe migrate -c config/settings.dev.yml | ||||||
|  |  | ||||||
|  | # Start the project, you can also use the IDE for debugging | ||||||
|  | # Use under macOS or linux | ||||||
|  | $ ./go-admin server -c config/settings.yml | ||||||
|  |  | ||||||
|  | # ⚠️Note: Use under windows | ||||||
|  | $ go-admin.exe server -c config/settings.yml | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### Use docker to compile and start | ||||||
|  |  | ||||||
|  | ```shell | ||||||
|  | # Compile the image | ||||||
|  | docker build -t go-admin . | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # Start the container, the first go-admin is the container name, and the second go-admin is the image name | ||||||
|  | # -v Mapping configuration file Local path: container path | ||||||
|  | docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #### Generation Document | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | go generate | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | #### Cross compile | ||||||
|  | ```bash | ||||||
|  | # windows | ||||||
|  | env GOOS=windows GOARCH=amd64 go build main.go | ||||||
|  |  | ||||||
|  | # or | ||||||
|  | # linux | ||||||
|  | env GOOS=linux GOARCH=amd64 go build main.go | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### UI interactive terminal startup instructions | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # Installation dependencies | ||||||
|  | npm install   # or cnpm install | ||||||
|  |  | ||||||
|  | # Start service | ||||||
|  | npm run dev | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## 📨 Interactive | ||||||
|  |  | ||||||
|  | <table> | ||||||
|  |   <tr> | ||||||
|  |     <td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/wx.png" width="180px"></td> | ||||||
|  |     <td><img src="https://doc-image.zhangwj.com/img/qrcode_for_gh_b798dc7db30c_258.jpg" width="180px"></td> | ||||||
|  |     <td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq2.png" width="200px"></td> | ||||||
|  |     <td><a href="https://space.bilibili.com/565616721">wenjianzhang</a></td> | ||||||
|  |   </tr> | ||||||
|  |   <tr> | ||||||
|  |     <td>Wechat</td> | ||||||
|  |     <td>Wechat公众号🔥🔥🔥</td> | ||||||
|  |     <td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流乙号" title="go-admin技术交流乙号"></a></td> | ||||||
|  |     <td>bilibili🔥🔥🔥</td> | ||||||
|  |   </tr> | ||||||
|  | </table> | ||||||
|  |  | ||||||
|  | ## 💎 Contributors | ||||||
|  |  | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wenjianzhang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3890175?v=4&h=60&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/G-Akiraka" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/45746659?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/lwnmengjing" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/12806223?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/bing127" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/31166183?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/chengxiao" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/1379545?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/NightFire0307" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19854086?v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/appleboy" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/21979?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/ninstein" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/580303?v=4&h=60&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/kikiyou" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/17959053?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/horizonzy" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/22524871?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Cassuis" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/48005724?s=64&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/hqcchina" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/5179057?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/nodece" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16235121?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/stephenzhang0713" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/18169290?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zhouxixi-dev" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/100399679?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Jalins" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/31172582?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wkf928592" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/6063351?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wxxiong6" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/6983441?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Silicon-He" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/52478309?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/GizmoOAO" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/20385106?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/bestgopher" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/36840497?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/wxb1207" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/20775558?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/misakichan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16569274?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zhuxuyang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19301024?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/mss-boot" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/109259065?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/AuroraV" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Vingurzhou" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/57127283?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/haimait" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40926384?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/zyd" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3446278?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/infnan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/38274826?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/d1y" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/45585937?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/qlijin" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/515900?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/logtous | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/88697234?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/stepway | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/9927079?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/NaturalGao | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/43291304?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/DemoLiang | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/23476007?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/jfcg | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/1410597?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  | <span style="margin: 0 5px;" ><a href="https://github.com/Nicole0724 | ||||||
|  | " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/10487328?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span> | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## JetBrains open source certificate support | ||||||
|  |  | ||||||
|  | The `go-admin` project has always been developed in the GoLand integrated development environment under JetBrains, based on the **free JetBrains Open Source license(s)** genuine free license. I would like to express my gratitude. | ||||||
|  |  | ||||||
|  | <a href="https://www.jetbrains.com/?from=kubeadm-ha" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="250" align="middle"/></a> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## 🤝 Thanks | ||||||
|  |  | ||||||
|  | 1. [ant-design](https://github.com/ant-design/ant-design) | ||||||
|  | 2. [ant-design-pro](https://github.com/ant-design/ant-design-pro) | ||||||
|  | 2. [arco-design](https://github.com/arco-design/arco-design) | ||||||
|  | 2. [arco-design-pro](https://github.com/arco-design/arco-design-pro) | ||||||
|  | 2. [gin](https://github.com/gin-gonic/gin) | ||||||
|  | 2. [casbin](https://github.com/casbin/casbin) | ||||||
|  | 2. [spf13/viper](https://github.com/spf13/viper) | ||||||
|  | 2. [gorm](https://github.com/jinzhu/gorm) | ||||||
|  | 2. [gin-swagger](https://github.com/swaggo/gin-swagger) | ||||||
|  | 2. [jwt-go](https://github.com/dgrijalva/jwt-go) | ||||||
|  | 2. [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) | ||||||
|  | 2. [ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue) | ||||||
|  | 2. [form-generator](https://github.com/JakHuang/form-generator) | ||||||
|  |  | ||||||
|  | ## 🤟 Sponsor Us | ||||||
|  |  | ||||||
|  | > If you think this project helped you, you can buy a glass of juice for the author to show encouragement :tropical_drink: | ||||||
|  |  | ||||||
|  | <img class="no-margin" src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/pay.png"  height="200px" > | ||||||
|  |  | ||||||
|  | ## 🤝 Link | ||||||
|  | - [Go developer growth roadmap](http://www.golangroadmap.com/) | ||||||
|  | - [mss-boot-io](https://docs.mss-boot-io.top/) | ||||||
|  |  | ||||||
|  | ## 🔑 License | ||||||
|  |  | ||||||
|  | [MIT](https://github.com/go-admin-team/go-admin/blob/master/LICENSE.md) | ||||||
|  |  | ||||||
|  | Copyright (c) 2022 wenjianzhang | ||||||
							
								
								
									
										1
									
								
								_config.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								_config.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | theme: jekyll-theme-cayman | ||||||
							
								
								
									
										37
									
								
								app/admin/apis/captcha.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/admin/apis/captcha.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/captcha" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type System struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GenerateCaptchaHandler 获取验证码 | ||||||
|  | // @Summary 获取验证码 | ||||||
|  | // @Description 获取验证码 | ||||||
|  | // @Tags 登陆 | ||||||
|  | // @Success 200 {object} response.Response{data=string,id=string,msg=string} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/captcha [get] | ||||||
|  | func (e System) GenerateCaptchaHandler(c *gin.Context) { | ||||||
|  | 	err := e.MakeContext(c).Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "服务初始化失败!") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	id, b64s, err := captcha.DriverDigitFunc() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Errorf("DriverDigitFunc error, %s", err.Error()) | ||||||
|  | 		e.Error(500, err, "验证码获取失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.Custom(gin.H{ | ||||||
|  | 		"code": 200, | ||||||
|  | 		"data": b64s, | ||||||
|  | 		"id":   id, | ||||||
|  | 		"msg":  "success", | ||||||
|  | 	}) | ||||||
|  | } | ||||||
							
								
								
									
										39
									
								
								app/admin/apis/go_admin.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								app/admin/apis/go_admin.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | const INDEX = ` | ||||||
|  | <!DOCTYPE html> | ||||||
|  | <html> | ||||||
|  | <head> | ||||||
|  | <meta charset="utf-8"> | ||||||
|  | <title>GO-ADMIN欢迎您</title> | ||||||
|  | <style> | ||||||
|  | body{ | ||||||
|  |   margin:0;  | ||||||
|  |   padding:0;  | ||||||
|  |   overflow-y:hidden | ||||||
|  | } | ||||||
|  | </style> | ||||||
|  | <script src="https://libs.baidu.com/jquery/1.9.0/jquery.js"></script> | ||||||
|  | <script type="text/javascript">  | ||||||
|  | window.onerror=function(){return true;}  | ||||||
|  | $(function(){  | ||||||
|  |   headerH = 0;   | ||||||
|  |   var h=$(window).height(); | ||||||
|  |   $("#iframe").height((h-headerH)+"px");  | ||||||
|  | }); | ||||||
|  | </script> | ||||||
|  | </head> | ||||||
|  | <body> | ||||||
|  | <iframe id="iframe" frameborder="0" src="https://www.go-admin.pro" style="width:100%;"></iframe> | ||||||
|  | </body> | ||||||
|  | </html> | ||||||
|  | ` | ||||||
|  |  | ||||||
|  | func GoAdmin(c *gin.Context) { | ||||||
|  | 	c.Header("Content-Type", "text/html; charset=utf-8") | ||||||
|  | 	c.String(200, INDEX) | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineAccountSetting struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取登录账户管理列表 | ||||||
|  | // @Summary 获取登录账户管理列表 | ||||||
|  | // @Description 获取登录账户管理列表 | ||||||
|  | // @Tags 登录账户管理 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineAccountSetting}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-account-setting [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineAccountSetting) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineAccountSettingGetPageReq{} | ||||||
|  |     s := service.LineAccountSetting{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineAccountSetting, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取登录账户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取登录账户管理 | ||||||
|  | // @Summary 获取登录账户管理 | ||||||
|  | // @Description 获取登录账户管理 | ||||||
|  | // @Tags 登录账户管理 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineAccountSetting} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-account-setting/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineAccountSetting) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineAccountSettingGetReq{} | ||||||
|  | 	s := service.LineAccountSetting{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineAccountSetting | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取登录账户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建登录账户管理 | ||||||
|  | // @Summary 创建登录账户管理 | ||||||
|  | // @Description 创建登录账户管理 | ||||||
|  | // @Tags 登录账户管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineAccountSettingInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-account-setting [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineAccountSetting) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineAccountSettingInsertReq{} | ||||||
|  |     s := service.LineAccountSetting{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建登录账户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改登录账户管理 | ||||||
|  | // @Summary 修改登录账户管理 | ||||||
|  | // @Description 修改登录账户管理 | ||||||
|  | // @Tags 登录账户管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineAccountSettingUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-account-setting/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineAccountSetting) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineAccountSettingUpdateReq{} | ||||||
|  |     s := service.LineAccountSetting{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改登录账户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除登录账户管理 | ||||||
|  | // @Summary 删除登录账户管理 | ||||||
|  | // @Description 删除登录账户管理 | ||||||
|  | // @Tags 登录账户管理 | ||||||
|  | // @Param data body dto.LineAccountSettingDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-account-setting [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineAccountSetting) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineAccountSetting{} | ||||||
|  |     req := dto.LineAccountSettingDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除登录账户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										192
									
								
								app/admin/apis/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								app/admin/apis/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,192 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineApiGroup struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取用户绑定从属关系表列表 | ||||||
|  | // @Summary 获取用户绑定从属关系表列表 | ||||||
|  | // @Description 获取用户绑定从属关系表列表 | ||||||
|  | // @Tags 用户绑定从属关系表 | ||||||
|  | // @Param groupName query string false "用户组名称" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineApiGroup}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-api-group [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiGroup) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiGroupGetPageReq{} | ||||||
|  | 	s := service.LineApiGroup{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineApiGroup, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户绑定从属关系表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取用户绑定从属关系表 | ||||||
|  | // @Summary 获取用户绑定从属关系表 | ||||||
|  | // @Description 获取用户绑定从属关系表 | ||||||
|  | // @Tags 用户绑定从属关系表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineApiGroup} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-api-group/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiGroup) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiGroupGetReq{} | ||||||
|  | 	s := service.LineApiGroup{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineApiGroup | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户绑定从属关系表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建用户绑定从属关系表 | ||||||
|  | // @Summary 创建用户绑定从属关系表 | ||||||
|  | // @Description 创建用户绑定从属关系表 | ||||||
|  | // @Tags 用户绑定从属关系表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineApiGroupInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-api-group [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiGroup) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiGroupInsertReq{} | ||||||
|  | 	s := service.LineApiGroup{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建用户绑定从属关系表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改用户绑定从属关系表 | ||||||
|  | // @Summary 修改用户绑定从属关系表 | ||||||
|  | // @Description 修改用户绑定从属关系表 | ||||||
|  | // @Tags 用户绑定从属关系表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineApiGroupUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-api-group/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiGroup) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiGroupUpdateReq{} | ||||||
|  | 	s := service.LineApiGroup{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改用户绑定从属关系表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除用户绑定从属关系表 | ||||||
|  | // @Summary 删除用户绑定从属关系表 | ||||||
|  | // @Description 删除用户绑定从属关系表 | ||||||
|  | // @Tags 用户绑定从属关系表 | ||||||
|  | // @Param data body dto.LineApiGroupDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-api-group [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiGroup) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LineApiGroup{} | ||||||
|  | 	req := dto.LineApiGroupDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除用户绑定从属关系表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										267
									
								
								app/admin/apis/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										267
									
								
								app/admin/apis/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,267 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineApiUser struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取api用户管理列表 | ||||||
|  | // @Summary 获取api用户管理列表 | ||||||
|  | // @Description 获取api用户管理列表 | ||||||
|  | // @Tags api用户管理 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineApiUser}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-api-user [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiUser) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiUserGetPageReq{} | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineApiUser, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取api用户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	for i, apiUser := range list { | ||||||
|  | 		if apiUser.UserId <= 0 { | ||||||
|  | 			list[i].OpenStatus = 1 | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取api用户管理 | ||||||
|  | // @Summary 获取api用户管理 | ||||||
|  | // @Description 获取api用户管理 | ||||||
|  | // @Tags api用户管理 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineApiUser} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-api-user/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiUser) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiUserGetReq{} | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineApiUser | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取api用户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建api用户管理 | ||||||
|  | // @Summary 创建api用户管理 | ||||||
|  | // @Description 创建api用户管理 | ||||||
|  | // @Tags api用户管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineApiUserInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-api-user [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiUser) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiUserInsertReq{} | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建api用户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改api用户管理 | ||||||
|  | // @Summary 修改api用户管理 | ||||||
|  | // @Description 修改api用户管理 | ||||||
|  | // @Tags api用户管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineApiUserUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-api-user/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiUser) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LineApiUserUpdateReq{} | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改api用户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除api用户管理 | ||||||
|  | // @Summary 删除api用户管理 | ||||||
|  | // @Description 删除api用户管理 | ||||||
|  | // @Tags api用户管理 | ||||||
|  | // @Param data body dto.LineApiUserDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-api-user [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineApiUser) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	req := dto.LineApiUserDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除api用户管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LineApiUser) Bind(c *gin.Context) { | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	req := dto.LineApiUserBindSubordinateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Bind(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("绑定api用户关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LineApiUser) GetUser(c *gin.Context) { | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	req := dto.LineApiUserBindSubordinateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	//p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineApiUser, 0) | ||||||
|  | 	err = s.GetUser(&list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetMainUser 获取主账号 | ||||||
|  | func (e LineApiUser) GetMainUser(c *gin.Context) { | ||||||
|  | 	s := service.LineApiUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	//p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineApiUser, 0) | ||||||
|  | 	err = s.GetMainUser(&list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "操作成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineCoinnetwork struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取【币种网络】列表 | ||||||
|  | // @Summary 获取【币种网络】列表 | ||||||
|  | // @Description 获取【币种网络】列表 | ||||||
|  | // @Tags 【币种网络】 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineCoinnetwork}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-coinnetwork [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCoinnetwork) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineCoinnetworkGetPageReq{} | ||||||
|  |     s := service.LineCoinnetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineCoinnetwork, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取【币种网络】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取【币种网络】 | ||||||
|  | // @Summary 获取【币种网络】 | ||||||
|  | // @Description 获取【币种网络】 | ||||||
|  | // @Tags 【币种网络】 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineCoinnetwork} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-coinnetwork/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCoinnetwork) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineCoinnetworkGetReq{} | ||||||
|  | 	s := service.LineCoinnetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineCoinnetwork | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取【币种网络】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建【币种网络】 | ||||||
|  | // @Summary 创建【币种网络】 | ||||||
|  | // @Description 创建【币种网络】 | ||||||
|  | // @Tags 【币种网络】 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineCoinnetworkInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-coinnetwork [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCoinnetwork) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineCoinnetworkInsertReq{} | ||||||
|  |     s := service.LineCoinnetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建【币种网络】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改【币种网络】 | ||||||
|  | // @Summary 修改【币种网络】 | ||||||
|  | // @Description 修改【币种网络】 | ||||||
|  | // @Tags 【币种网络】 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineCoinnetworkUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-coinnetwork/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCoinnetwork) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineCoinnetworkUpdateReq{} | ||||||
|  |     s := service.LineCoinnetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改【币种网络】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除【币种网络】 | ||||||
|  | // @Summary 删除【币种网络】 | ||||||
|  | // @Description 删除【币种网络】 | ||||||
|  | // @Tags 【币种网络】 | ||||||
|  | // @Param data body dto.LineCoinnetworkDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-coinnetwork [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCoinnetwork) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineCoinnetwork{} | ||||||
|  |     req := dto.LineCoinnetworkDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除【币种网络】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineCointonetwork struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取币种与网络关系列表 | ||||||
|  | // @Summary 获取币种与网络关系列表 | ||||||
|  | // @Description 获取币种与网络关系列表 | ||||||
|  | // @Tags 币种与网络关系 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineCointonetwork}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-cointonetwork [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCointonetwork) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineCointonetworkGetPageReq{} | ||||||
|  |     s := service.LineCointonetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineCointonetwork, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取币种与网络关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取币种与网络关系 | ||||||
|  | // @Summary 获取币种与网络关系 | ||||||
|  | // @Description 获取币种与网络关系 | ||||||
|  | // @Tags 币种与网络关系 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineCointonetwork} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-cointonetwork/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCointonetwork) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineCointonetworkGetReq{} | ||||||
|  | 	s := service.LineCointonetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineCointonetwork | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取币种与网络关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建币种与网络关系 | ||||||
|  | // @Summary 创建币种与网络关系 | ||||||
|  | // @Description 创建币种与网络关系 | ||||||
|  | // @Tags 币种与网络关系 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineCointonetworkInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-cointonetwork [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCointonetwork) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineCointonetworkInsertReq{} | ||||||
|  |     s := service.LineCointonetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建币种与网络关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改币种与网络关系 | ||||||
|  | // @Summary 修改币种与网络关系 | ||||||
|  | // @Description 修改币种与网络关系 | ||||||
|  | // @Tags 币种与网络关系 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineCointonetworkUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-cointonetwork/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCointonetwork) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineCointonetworkUpdateReq{} | ||||||
|  |     s := service.LineCointonetwork{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改币种与网络关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除币种与网络关系 | ||||||
|  | // @Summary 删除币种与网络关系 | ||||||
|  | // @Description 删除币种与网络关系 | ||||||
|  | // @Tags 币种与网络关系 | ||||||
|  | // @Param data body dto.LineCointonetworkDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-cointonetwork [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineCointonetwork) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineCointonetwork{} | ||||||
|  |     req := dto.LineCointonetworkDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除币种与网络关系失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										240
									
								
								app/admin/apis/line_direction.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										240
									
								
								app/admin/apis/line_direction.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,240 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineDirection struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取预估方向管理列表 | ||||||
|  | // @Summary 获取预估方向管理列表 | ||||||
|  | // @Description 获取预估方向管理列表 | ||||||
|  | // @Tags 预估方向管理 | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param type query int64 false "交易对类型:1=现货,2=合约" | ||||||
|  | // @Param direction query string false "预估方向" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineDirection}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-direction [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineDirection) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LineDirectionGetPageReq{} | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineDirection, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取预估方向管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取预估方向管理 | ||||||
|  | // @Summary 获取预估方向管理 | ||||||
|  | // @Description 获取预估方向管理 | ||||||
|  | // @Tags 预估方向管理 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineDirection} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-direction/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineDirection) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineDirectionGetReq{} | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineDirection | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取预估方向管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建预估方向管理 | ||||||
|  | // @Summary 创建预估方向管理 | ||||||
|  | // @Description 创建预估方向管理 | ||||||
|  | // @Tags 预估方向管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineDirectionInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-direction [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineDirection) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LineDirectionInsertReq{} | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建预估方向管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改预估方向管理 | ||||||
|  | // @Summary 修改预估方向管理 | ||||||
|  | // @Description 修改预估方向管理 | ||||||
|  | // @Tags 预估方向管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineDirectionUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-direction/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineDirection) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LineDirectionUpdateReq{} | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改预估方向管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除预估方向管理 | ||||||
|  | // @Summary 删除预估方向管理 | ||||||
|  | // @Description 删除预估方向管理 | ||||||
|  | // @Tags 预估方向管理 | ||||||
|  | // @Param data body dto.LineDirectionDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-direction [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineDirection) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	req := dto.LineDirectionDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除预估方向管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // AddDirection 新增预估方向 | ||||||
|  | func (e LineDirection) AddDirection(c *gin.Context) { | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  | 	req := dto.AddDirectionReq{} | ||||||
|  |  | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.AddDirection(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("生成预估方向失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 重新统计分组信息 | ||||||
|  | func (e LineDirection) ReloadGroupData(c *gin.Context) { | ||||||
|  | 	s := service.LineDirection{} | ||||||
|  |  | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if err := s.ReloadGroup(); err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("重新统计分组信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
							
								
								
									
										194
									
								
								app/admin/apis/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										194
									
								
								app/admin/apis/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,194 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineOrderTemplateLogs struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取委托下单模板列表 | ||||||
|  | // @Summary 获取委托下单模板列表 | ||||||
|  | // @Description 获取委托下单模板列表 | ||||||
|  | // @Tags 委托下单模板 | ||||||
|  | // @Param name query string false "模板名称" | ||||||
|  | // @Param userId query int64 false "用户id" | ||||||
|  | // @Param type query int64 false "模板类型:1=单独添加;2=批量添加" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineOrderTemplateLogs}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-order-template-logs [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineOrderTemplateLogs) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineOrderTemplateLogsGetPageReq{} | ||||||
|  |     s := service.LineOrderTemplateLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineOrderTemplateLogs, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托下单模板失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取委托下单模板 | ||||||
|  | // @Summary 获取委托下单模板 | ||||||
|  | // @Description 获取委托下单模板 | ||||||
|  | // @Tags 委托下单模板 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineOrderTemplateLogs} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-order-template-logs/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineOrderTemplateLogs) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineOrderTemplateLogsGetReq{} | ||||||
|  | 	s := service.LineOrderTemplateLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineOrderTemplateLogs | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托下单模板失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建委托下单模板 | ||||||
|  | // @Summary 创建委托下单模板 | ||||||
|  | // @Description 创建委托下单模板 | ||||||
|  | // @Tags 委托下单模板 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineOrderTemplateLogsInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-order-template-logs [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineOrderTemplateLogs) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineOrderTemplateLogsInsertReq{} | ||||||
|  |     s := service.LineOrderTemplateLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建委托下单模板失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改委托下单模板 | ||||||
|  | // @Summary 修改委托下单模板 | ||||||
|  | // @Description 修改委托下单模板 | ||||||
|  | // @Tags 委托下单模板 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineOrderTemplateLogsUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-order-template-logs/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineOrderTemplateLogs) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineOrderTemplateLogsUpdateReq{} | ||||||
|  |     s := service.LineOrderTemplateLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改委托下单模板失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除委托下单模板 | ||||||
|  | // @Summary 删除委托下单模板 | ||||||
|  | // @Description 删除委托下单模板 | ||||||
|  | // @Tags 委托下单模板 | ||||||
|  | // @Param data body dto.LineOrderTemplateLogsDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-order-template-logs [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineOrderTemplateLogs) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineOrderTemplateLogs{} | ||||||
|  |     req := dto.LineOrderTemplateLogsDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除委托下单模板失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										613
									
								
								app/admin/apis/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										613
									
								
								app/admin/apis/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,613 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"go-admin/common/const/rediskey" | ||||||
|  | 	"go-admin/common/global" | ||||||
|  | 	"go-admin/common/helper" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreOrder struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取委托管理列表 | ||||||
|  | // @Summary 获取委托管理列表 | ||||||
|  | // @Description 获取委托管理列表 | ||||||
|  | // @Tags 委托管理 | ||||||
|  | // @Param apiId query string false "api用户" | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param quoteSymbol query string false "计较货币" | ||||||
|  | // @Param signPriceType query string false "对标价类型: new=最新价格;tall=24小时最高;low=24小时最低;mixture=标记价;entrust=委托实价;add=补仓" | ||||||
|  | // @Param rate query string false "下单百分比" | ||||||
|  | // @Param site query string false "购买方向:BUY=买;SELL=卖" | ||||||
|  | // @Param orderSn query string false "订单号" | ||||||
|  | // @Param orderType query string false "订单类型:1=现货;2=合约;3=合约止盈;4=合约止损;5=现货止盈;6=现货止损;7=止损补仓;8=现货加仓;9=现货平仓;10 = 合约止损补仓,11=合约加仓;12=合约平仓" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LinePreOrder}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-order [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrder) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderGetPageReq{} | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePreOrder, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetOrderPage 获取LinePreOrder列表 | ||||||
|  | func (e LinePreOrder) GetOrderPage(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderGetPageReq{} | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePreOrder, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetOrderPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LinePreOrder) GetChildOrderList(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.GetChildOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if req.Id <= 0 { | ||||||
|  | 		e.Error(500, err, "参数错误") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePreOrder, 0) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.GetChildList(&req, p, &list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取子订单信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取委托管理 | ||||||
|  | // @Summary 获取委托管理 | ||||||
|  | // @Description 获取委托管理 | ||||||
|  | // @Tags 委托管理 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LinePreOrder} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-order/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrder) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderGetReq{} | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LinePreOrder | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建委托管理 | ||||||
|  | // @Summary 创建委托管理 | ||||||
|  | // @Description 创建委托管理 | ||||||
|  | // @Tags 委托管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LinePreOrderInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrder) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderInsertReq{} | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改委托管理 | ||||||
|  | // @Summary 修改委托管理 | ||||||
|  | // @Description 修改委托管理 | ||||||
|  | // @Tags 委托管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LinePreOrderUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrder) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderUpdateReq{} | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除委托管理 | ||||||
|  | // @Summary 删除委托管理 | ||||||
|  | // @Description 删除委托管理 | ||||||
|  | // @Tags 委托管理 | ||||||
|  | // @Param data body dto.LinePreOrderDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrder) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.LinePreOrderDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除委托管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // AddPreOrder 单个添加 | ||||||
|  | func (e LinePreOrder) AddPreOrder(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.LineAddPreOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	var tickerSymbol string | ||||||
|  | 	if req.SymbolType == global.SYMBOL_SPOT { | ||||||
|  | 		tickerSymbol = helper.DefaultRedis.Get(rediskey.SpotSymbolTicker).Val() | ||||||
|  | 	} else { | ||||||
|  | 		tickerSymbol = helper.DefaultRedis.Get(rediskey.FutSymbolTicker).Val() | ||||||
|  | 	} | ||||||
|  | 	s.AddPreOrder(&req, p, &errs, tickerSymbol) | ||||||
|  |  | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		//e.Logger.Error(err) | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // BatchAddOrder 批量添加 | ||||||
|  | func (e LinePreOrder) BatchAddOrder(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.LineBatchAddPreOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	s.AddBatchPreOrder(&req, p, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		//e.Logger.Error(err) | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // QuickAddPreOrder 模板快速下单 | ||||||
|  | func (e LinePreOrder) QuickAddPreOrder(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.QuickAddPreOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if req.Ids == "" { | ||||||
|  | 		e.Error(500, err, "参数错误") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	err = s.QuickAddPreOrder(&req, p, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		//e.Logger.Error(err) | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Lever 设置杠杆 | ||||||
|  | func (e LinePreOrder) Lever(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.LeverReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	s.Lever(&req, p, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // MarginType 设置仓位模式 | ||||||
|  | func (e LinePreOrder) MarginType(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.MarginTypeReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	s.MarginType(&req, p, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CancelOpenOrder 取消指定交易对的委托 | ||||||
|  | func (e LinePreOrder) CancelOpenOrder(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.CancelOpenOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if req.ApiId <= 0 { | ||||||
|  | 		e.Error(500, err, "参数错误") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	s.CancelOpenOrder(&req, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ClearAll 一键清除数据 | ||||||
|  | func (e LinePreOrder) ClearAll(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.MarginTypeReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.ClearAll() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ManuallyCover 手动加仓 | ||||||
|  | func (e LinePreOrder) ManuallyCover(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.ManuallyCover{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  |  | ||||||
|  | 	s.ManuallyCover(req, p, &errs) | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ClosePosition 平仓 | ||||||
|  | func (e LinePreOrder) ClosePosition(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.ClosePosition{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = req.CheckParams() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	errs := make([]error, 0) | ||||||
|  | 	errStr := make([]string, 0) | ||||||
|  | 	if req.CloseType == 1 { | ||||||
|  | 		s.SpotClosePosition(&req, &errs) | ||||||
|  | 	} else { | ||||||
|  | 		s.FutClosePosition(&req, &errs) | ||||||
|  | 	} | ||||||
|  | 	if len(errs) > 0 { | ||||||
|  | 		for _, err2 := range errs { | ||||||
|  | 			errStr = append(errStr, err2.Error()) | ||||||
|  | 		} | ||||||
|  | 		e.Error(500, nil, strings.Join(errStr, ",")) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ClearUnTriggered 清除待触发的交易对 | ||||||
|  | func (e LinePreOrder) ClearUnTriggered(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.ClearUnTriggered() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LinePreOrder) QueryOrder(c *gin.Context) { | ||||||
|  | 	s := service.LinePreOrder{} | ||||||
|  | 	req := dto.QueryOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	res, err := s.QueryOrder(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(res, "操作成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreOrderStatus struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取订单状态信息列表 | ||||||
|  | // @Summary 获取订单状态信息列表 | ||||||
|  | // @Description 获取订单状态信息列表 | ||||||
|  | // @Tags 订单状态信息 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LinePreOrderStatus}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-order-status [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrderStatus) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LinePreOrderStatusGetPageReq{} | ||||||
|  |     s := service.LinePreOrderStatus{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePreOrderStatus, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取订单状态信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取订单状态信息 | ||||||
|  | // @Summary 获取订单状态信息 | ||||||
|  | // @Description 获取订单状态信息 | ||||||
|  | // @Tags 订单状态信息 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LinePreOrderStatus} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-order-status/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrderStatus) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreOrderStatusGetReq{} | ||||||
|  | 	s := service.LinePreOrderStatus{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LinePreOrderStatus | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取订单状态信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建订单状态信息 | ||||||
|  | // @Summary 创建订单状态信息 | ||||||
|  | // @Description 创建订单状态信息 | ||||||
|  | // @Tags 订单状态信息 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LinePreOrderStatusInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order-status [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrderStatus) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LinePreOrderStatusInsertReq{} | ||||||
|  |     s := service.LinePreOrderStatus{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建订单状态信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改订单状态信息 | ||||||
|  | // @Summary 修改订单状态信息 | ||||||
|  | // @Description 修改订单状态信息 | ||||||
|  | // @Tags 订单状态信息 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LinePreOrderStatusUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order-status/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrderStatus) Update(c *gin.Context) { | ||||||
|  |     req := dto.LinePreOrderStatusUpdateReq{} | ||||||
|  |     s := service.LinePreOrderStatus{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改订单状态信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除订单状态信息 | ||||||
|  | // @Summary 删除订单状态信息 | ||||||
|  | // @Description 删除订单状态信息 | ||||||
|  | // @Tags 订单状态信息 | ||||||
|  | // @Param data body dto.LinePreOrderStatusDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-pre-order-status [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreOrderStatus) Delete(c *gin.Context) { | ||||||
|  |     s := service.LinePreOrderStatus{} | ||||||
|  |     req := dto.LinePreOrderStatusDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除订单状态信息失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										193
									
								
								app/admin/apis/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								app/admin/apis/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,193 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreScript struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取委托下单脚本记录表列表 | ||||||
|  | // @Summary 获取委托下单脚本记录表列表 | ||||||
|  | // @Description 获取委托下单脚本记录表列表 | ||||||
|  | // @Tags 委托下单脚本记录表 | ||||||
|  | // @Param apiId query int64 false "api用户" | ||||||
|  | // @Param status query string false "执行状态:0=等待执行,1=执行中,2=执行结束" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LinePreScript}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-script [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreScript) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LinePreScriptGetPageReq{} | ||||||
|  |     s := service.LinePreScript{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePreScript, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托下单脚本记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取委托下单脚本记录表 | ||||||
|  | // @Summary 获取委托下单脚本记录表 | ||||||
|  | // @Description 获取委托下单脚本记录表 | ||||||
|  | // @Tags 委托下单脚本记录表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LinePreScript} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-pre-script/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreScript) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LinePreScriptGetReq{} | ||||||
|  | 	s := service.LinePreScript{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LinePreScript | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取委托下单脚本记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建委托下单脚本记录表 | ||||||
|  | // @Summary 创建委托下单脚本记录表 | ||||||
|  | // @Description 创建委托下单脚本记录表 | ||||||
|  | // @Tags 委托下单脚本记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LinePreScriptInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-pre-script [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreScript) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LinePreScriptInsertReq{} | ||||||
|  |     s := service.LinePreScript{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建委托下单脚本记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改委托下单脚本记录表 | ||||||
|  | // @Summary 修改委托下单脚本记录表 | ||||||
|  | // @Description 修改委托下单脚本记录表 | ||||||
|  | // @Tags 委托下单脚本记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LinePreScriptUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-pre-script/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreScript) Update(c *gin.Context) { | ||||||
|  |     req := dto.LinePreScriptUpdateReq{} | ||||||
|  |     s := service.LinePreScript{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改委托下单脚本记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除委托下单脚本记录表 | ||||||
|  | // @Summary 删除委托下单脚本记录表 | ||||||
|  | // @Description 删除委托下单脚本记录表 | ||||||
|  | // @Tags 委托下单脚本记录表 | ||||||
|  | // @Param data body dto.LinePreScriptDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-pre-script [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePreScript) Delete(c *gin.Context) { | ||||||
|  |     s := service.LinePreScript{} | ||||||
|  |     req := dto.LinePreScriptDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除委托下单脚本记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										213
									
								
								app/admin/apis/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								app/admin/apis/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,213 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePriceLimit struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取涨跌幅列表 | ||||||
|  | // @Summary 获取涨跌幅列表 | ||||||
|  | // @Description 获取涨跌幅列表 | ||||||
|  | // @Tags 涨跌幅 | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param type query string false "类型:1=现货,2=合约" | ||||||
|  | // @Param directionStatus query string false "方向:1=涨,2=跌" | ||||||
|  | // @Param range query string false "幅度" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LinePriceLimit}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-price-limit [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePriceLimit) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LinePriceLimitGetPageReq{} | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LinePriceLimit, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取涨跌幅 | ||||||
|  | // @Summary 获取涨跌幅 | ||||||
|  | // @Description 获取涨跌幅 | ||||||
|  | // @Tags 涨跌幅 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LinePriceLimit} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-price-limit/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePriceLimit) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LinePriceLimitGetReq{} | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LinePriceLimit | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建涨跌幅 | ||||||
|  | // @Summary 创建涨跌幅 | ||||||
|  | // @Description 创建涨跌幅 | ||||||
|  | // @Tags 涨跌幅 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LinePriceLimitInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-price-limit [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePriceLimit) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LinePriceLimitInsertReq{} | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改涨跌幅 | ||||||
|  | // @Summary 修改涨跌幅 | ||||||
|  | // @Description 修改涨跌幅 | ||||||
|  | // @Tags 涨跌幅 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LinePriceLimitUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-price-limit/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePriceLimit) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LinePriceLimitUpdateReq{} | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除涨跌幅 | ||||||
|  | // @Summary 删除涨跌幅 | ||||||
|  | // @Description 删除涨跌幅 | ||||||
|  | // @Tags 涨跌幅 | ||||||
|  | // @Param data body dto.LinePriceLimitDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-price-limit [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LinePriceLimit) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	req := dto.LinePriceLimitDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LinePriceLimit) UpRange(c *gin.Context) { | ||||||
|  | 	s := service.LinePriceLimit{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.UpRange() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("更新涨跌幅失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineRecharge struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取充值记录表列表 | ||||||
|  | // @Summary 获取充值记录表列表 | ||||||
|  | // @Description 获取充值记录表列表 | ||||||
|  | // @Tags 充值记录表 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineRecharge}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-recharge [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineRecharge) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineRechargeGetPageReq{} | ||||||
|  |     s := service.LineRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineRecharge, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取充值记录表 | ||||||
|  | // @Summary 获取充值记录表 | ||||||
|  | // @Description 获取充值记录表 | ||||||
|  | // @Tags 充值记录表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineRecharge} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-recharge/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineRecharge) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineRechargeGetReq{} | ||||||
|  | 	s := service.LineRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineRecharge | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建充值记录表 | ||||||
|  | // @Summary 创建充值记录表 | ||||||
|  | // @Description 创建充值记录表 | ||||||
|  | // @Tags 充值记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineRechargeInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-recharge [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineRecharge) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineRechargeInsertReq{} | ||||||
|  |     s := service.LineRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改充值记录表 | ||||||
|  | // @Summary 修改充值记录表 | ||||||
|  | // @Description 修改充值记录表 | ||||||
|  | // @Tags 充值记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineRechargeUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-recharge/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineRecharge) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineRechargeUpdateReq{} | ||||||
|  |     s := service.LineRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除充值记录表 | ||||||
|  | // @Summary 删除充值记录表 | ||||||
|  | // @Description 删除充值记录表 | ||||||
|  | // @Tags 充值记录表 | ||||||
|  | // @Param data body dto.LineRechargeDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-recharge [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineRecharge) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineRecharge{} | ||||||
|  |     req := dto.LineRechargeDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										497
									
								
								app/admin/apis/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										497
									
								
								app/admin/apis/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,497 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"errors" | ||||||
|  | 	"fmt" | ||||||
|  | 	"go-admin/common/const/rediskey" | ||||||
|  | 	"go-admin/common/global" | ||||||
|  | 	"go-admin/common/helper" | ||||||
|  | 	"go-admin/config/serverinit" | ||||||
|  | 	models2 "go-admin/models" | ||||||
|  | 	"go-admin/pkg/utility" | ||||||
|  | 	"go-admin/services/binanceservice" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
|  | 	"github.com/bytedance/sonic" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | 	"gorm.io/gorm" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbol struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取交易对管理列表 | ||||||
|  | // @Summary 获取交易对管理列表 | ||||||
|  | // @Description 获取交易对管理列表 | ||||||
|  | // @Tags 交易对管理 | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param baseAsset query string false "基础货币" | ||||||
|  | // @Param quoteAsset query string false "计价货币" | ||||||
|  | // @Param type query string false "交易对类型" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineSymbol}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbol) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolGetPageReq{} | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineSymbol, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取交易对管理 | ||||||
|  | // @Summary 获取交易对管理 | ||||||
|  | // @Description 获取交易对管理 | ||||||
|  | // @Tags 交易对管理 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineSymbol} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbol) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolGetReq{} | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineSymbol | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建交易对管理 | ||||||
|  | // @Summary 创建交易对管理 | ||||||
|  | // @Description 创建交易对管理 | ||||||
|  | // @Tags 交易对管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineSymbolInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-symbol [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbol) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolInsertReq{} | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改交易对管理 | ||||||
|  | // @Summary 修改交易对管理 | ||||||
|  | // @Description 修改交易对管理 | ||||||
|  | // @Tags 交易对管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineSymbolUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-symbol/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbol) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolUpdateReq{} | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除交易对管理 | ||||||
|  | // @Summary 删除交易对管理 | ||||||
|  | // @Description 删除交易对管理 | ||||||
|  | // @Tags 交易对管理 | ||||||
|  | // @Param data body dto.LineSymbolDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-symbol [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbol) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	req := dto.LineSymbolDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SyncSpotSymbol  同步交易对 | ||||||
|  | func (e LineSymbol) SyncSpotSymbol(c *gin.Context) { | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  |  | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	tradeSets, deleteSymbols := serverinit.SpotCurrencyInit() | ||||||
|  | 	symbols := make([]models.LineSymbol, 0) | ||||||
|  |  | ||||||
|  | 	sysConfig := service.SysConfig{Service: s.Service} | ||||||
|  | 	var req = new(dto.SysConfigByKeyReq) | ||||||
|  | 	var resp = new(dto.GetSysConfigByKEYForServiceResp) | ||||||
|  | 	req.ConfigKey = "quote_volume_24hr" | ||||||
|  | 	sysConfig.GetWithKey(req, resp) | ||||||
|  | 	symbolBlack := make([]models.LineSymbolBlack, 0) | ||||||
|  | 	e.Orm.Model(&models.LineSymbolBlack{}).Where("type = 1").Find(&symbolBlack) | ||||||
|  |  | ||||||
|  | 	type Ticker struct { | ||||||
|  | 		Symbol string `json:"symbol"` | ||||||
|  | 		Price  string `json:"price"` | ||||||
|  | 	} | ||||||
|  | 	tickerSymbol := helper.DefaultRedis.Get(rediskey.SpotSymbolTicker).Val() | ||||||
|  | 	tickerSymbolMaps := make([]Ticker, 0) | ||||||
|  | 	sonic.Unmarshal([]byte(tickerSymbol), &tickerSymbolMaps) | ||||||
|  |  | ||||||
|  | 	for symbol, tradeSet := range tradeSets { | ||||||
|  | 		var lineSymbol models.LineSymbol | ||||||
|  | 		err := e.Orm.Model(&models.LineSymbol{}).Where("symbol = ? AND type = 1", symbol).Find(&lineSymbol).Error | ||||||
|  | 		if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 		key := fmt.Sprintf("%s:%s", global.TICKER_SPOT, symbol) | ||||||
|  |  | ||||||
|  | 		//判断是否在黑名单里面 | ||||||
|  | 		for _, black := range symbolBlack { | ||||||
|  | 			if black.Symbol == symbol { | ||||||
|  | 				helper.DefaultRedis.DeleteString(key) | ||||||
|  | 				deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		val := helper.DefaultRedis.Get(key).Val() | ||||||
|  | 		var spotTicker24h models2.TradeSet | ||||||
|  | 		sonic.Unmarshal([]byte(val), &spotTicker24h) | ||||||
|  | 		//成交量 | ||||||
|  | 		if spotTicker24h.Currency == "USDT" { | ||||||
|  | 			if utility.StringToFloat64(spotTicker24h.QuoteVolume) < utility.StringToFloat64(resp.ConfigValue) { | ||||||
|  | 				helper.DefaultRedis.DeleteString(key) | ||||||
|  | 				deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  |  | ||||||
|  | 			var tickerPrice decimal.Decimal | ||||||
|  | 			for _, symbolMap := range tickerSymbolMaps { | ||||||
|  | 				if symbolMap.Symbol == strings.ToUpper(spotTicker24h.Currency+"USDT") { | ||||||
|  | 					tickerPrice, _ = decimal.NewFromString(symbolMap.Price) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			if tickerPrice.GreaterThan(decimal.Zero) { | ||||||
|  | 				mul := decimal.NewFromFloat(utility.StringToFloat64(spotTicker24h.QuoteVolume)).Mul(tickerPrice) | ||||||
|  | 				if mul.LessThan(decimal.NewFromFloat(utility.StringToFloat64(resp.ConfigValue))) { | ||||||
|  | 					helper.DefaultRedis.DeleteString(key) | ||||||
|  | 					deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 					continue | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if lineSymbol.Id <= 0 { | ||||||
|  | 			lineSymbol.Symbol = symbol | ||||||
|  | 			lineSymbol.BaseAsset = tradeSet.Coin | ||||||
|  | 			lineSymbol.QuoteAsset = tradeSet.Currency | ||||||
|  | 			lineSymbol.Switch = "1" | ||||||
|  | 			lineSymbol.Type = "1" | ||||||
|  | 			if lineSymbol.Symbol == "" { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			symbols = append(symbols, lineSymbol) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if len(deleteSymbols) > 0 { | ||||||
|  | 		for _, symbol := range deleteSymbols { | ||||||
|  | 			//如果在交易对组里面 | ||||||
|  | 			//var symbolGroup []models.LineSymbolGroup | ||||||
|  | 			groups := make([]models.LineSymbolGroup, 0) | ||||||
|  | 			e.Orm.Model(&models.LineSymbolGroup{}).Find(&groups) | ||||||
|  | 			for _, group := range groups { | ||||||
|  | 				if group.Id > 0 && strings.Contains(group.Symbol, symbol) { | ||||||
|  | 					split := strings.Split(group.Symbol, ",") | ||||||
|  | 					value := utility.RemoveByValue(split, symbol) | ||||||
|  | 					join := strings.Join(value, ",") | ||||||
|  | 					e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ?", group.Id).Update("symbol", join) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			e.Orm.Model(&models.LineSymbol{}).Where("symbol = ? AND type = 1", symbol).Unscoped().Delete(&models.LineSymbol{}) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if len(symbols) > 0 { | ||||||
|  | 		err = e.Orm.Model(&models.LineSymbol{}).Omit("api_id").Create(&symbols).Error | ||||||
|  | 		if err != nil { | ||||||
|  | 			e.Error(500, err, err.Error()) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SyncFutSymbol 更新合约交易对 | ||||||
|  | func (e LineSymbol) SyncFutSymbol(c *gin.Context) { | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	tradeSets := make(map[string]models2.TradeSet, 0) | ||||||
|  | 	//获取交易对 | ||||||
|  | 	err = binanceservice.GetAndReloadSymbols(&tradeSets) | ||||||
|  | 	//获取交易对24小时行情 | ||||||
|  | 	deleteSymbols, err := binanceservice.InitSymbolsTicker24h(&tradeSets) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	sysConfig := service.SysConfig{Service: s.Service} | ||||||
|  | 	var req = new(dto.SysConfigByKeyReq) | ||||||
|  | 	var resp = new(dto.GetSysConfigByKEYForServiceResp) | ||||||
|  | 	req.ConfigKey = "quote_volume_24hr" | ||||||
|  | 	sysConfig.GetWithKey(req, resp) | ||||||
|  | 	symbols := make([]models.LineSymbol, 0) | ||||||
|  | 	symbolBlack := make([]models.LineSymbolBlack, 0) | ||||||
|  |  | ||||||
|  | 	type Ticker struct { | ||||||
|  | 		Symbol string `json:"symbol"` | ||||||
|  | 		Price  string `json:"price"` | ||||||
|  | 	} | ||||||
|  | 	tickerSymbol := helper.DefaultRedis.Get(rediskey.FutSymbolTicker).Val() | ||||||
|  | 	tickerSymbolMaps := make([]Ticker, 0) | ||||||
|  | 	sonic.Unmarshal([]byte(tickerSymbol), &tickerSymbolMaps) | ||||||
|  |  | ||||||
|  | 	e.Orm.Model(&models.LineSymbolBlack{}).Where("type = 1").Find(&symbolBlack) | ||||||
|  | 	for symbol, tradeSet := range tradeSets { | ||||||
|  | 		var lineSymbol models.LineSymbol | ||||||
|  | 		err := e.Orm.Model(&models.LineSymbol{}).Where("symbol = ? AND type = 2", symbol).Find(&lineSymbol).Error | ||||||
|  | 		if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 		key := fmt.Sprintf("%s:%s", global.TICKER_FUTURES, symbol) | ||||||
|  |  | ||||||
|  | 		//判断是否在黑名单里面 | ||||||
|  | 		for _, black := range symbolBlack { | ||||||
|  | 			if black.Symbol == symbol { | ||||||
|  | 				helper.DefaultRedis.DeleteString(key) | ||||||
|  | 				deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		val := helper.DefaultRedis.Get(key).Val() | ||||||
|  | 		var spotTicker24h models2.TradeSet | ||||||
|  | 		sonic.Unmarshal([]byte(val), &spotTicker24h) | ||||||
|  | 		//成交量 | ||||||
|  | 		if spotTicker24h.Currency == "USDT" { | ||||||
|  | 			if utility.StringToFloat64(spotTicker24h.QuoteVolume) < utility.StringToFloat64(resp.ConfigValue) { | ||||||
|  | 				helper.DefaultRedis.DeleteString(key) | ||||||
|  | 				deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			var tickerPrice decimal.Decimal | ||||||
|  | 			for _, symbolMap := range tickerSymbolMaps { | ||||||
|  | 				if symbolMap.Symbol == strings.ToUpper(spotTicker24h.Currency+"USDT") { | ||||||
|  | 					tickerPrice, _ = decimal.NewFromString(symbolMap.Price) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			if tickerPrice.GreaterThan(decimal.Zero) { | ||||||
|  | 				mul := decimal.NewFromFloat(utility.StringToFloat64(spotTicker24h.QuoteVolume)).Mul(tickerPrice) | ||||||
|  | 				if mul.LessThan(decimal.NewFromFloat(utility.StringToFloat64(resp.ConfigValue))) { | ||||||
|  | 					helper.DefaultRedis.DeleteString(key) | ||||||
|  | 					deleteSymbols = append(deleteSymbols, symbol) | ||||||
|  | 					continue | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if lineSymbol.Id <= 0 { | ||||||
|  | 			lineSymbol.Symbol = symbol | ||||||
|  | 			lineSymbol.BaseAsset = tradeSet.Coin | ||||||
|  | 			lineSymbol.QuoteAsset = tradeSet.Currency | ||||||
|  | 			lineSymbol.Switch = "1" | ||||||
|  | 			lineSymbol.Type = "2" | ||||||
|  | 			if lineSymbol.Symbol == "" { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			symbols = append(symbols, lineSymbol) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if len(deleteSymbols) > 0 { | ||||||
|  | 		for _, symbol := range deleteSymbols { | ||||||
|  | 			//如果在交易对组里面 | ||||||
|  | 			groups := make([]models.LineSymbolGroup, 0) | ||||||
|  | 			//var symbolGroup []models.LineSymbolGroup | ||||||
|  | 			sql := "SELECT * FROM line_symbol_group WHERE FIND_IN_SET( ? , symbol) AND type = 2 AND deleted_at is NULL;" | ||||||
|  | 			e.Orm.Model(&models.LineSymbolGroup{}).Exec(sql, symbol).Find(&groups) | ||||||
|  | 			for _, group := range groups { | ||||||
|  | 				if group.Id > 0 { | ||||||
|  | 					split := strings.Split(group.Symbol, ",") | ||||||
|  | 					value := utility.RemoveByValue(split, symbol) | ||||||
|  | 					join := strings.Join(value, ",") | ||||||
|  | 					e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ?", group.Id).Update("symbol", join) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			e.Orm.Model(&models.LineSymbol{}).Where("symbol = ? AND type = 2", symbol).Unscoped().Delete(&models.LineSymbol{}) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if len(symbols) > 0 { | ||||||
|  | 		err = e.Orm.Model(&models.LineSymbol{}).Omit("api_id").Create(&symbols).Error | ||||||
|  | 		if err != nil { | ||||||
|  | 			e.Error(500, err, err.Error()) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetSymbol 获取现货和合约都有的交易对 | ||||||
|  | func (e LineSymbol) GetSymbol(c *gin.Context) { | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	data, err := s.GetSymbol() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(data, "操作成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetSameSymbol 获取现货和合约都有的交易对 | ||||||
|  | func (e LineSymbol) GetSameSymbol(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolGetPageReq{} | ||||||
|  | 	s := service.LineSymbol{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineSymbol, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetSamePage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对管理失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
							
								
								
									
										193
									
								
								app/admin/apis/line_symbol_black.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								app/admin/apis/line_symbol_black.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,193 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbolBlack struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取交易对黑名单列表 | ||||||
|  | // @Summary 获取交易对黑名单列表 | ||||||
|  | // @Description 获取交易对黑名单列表 | ||||||
|  | // @Tags 交易对黑名单 | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param type query string false "类型:1=现货,2=合约" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineSymbolBlack}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol-black [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolBlack) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolBlackGetPageReq{} | ||||||
|  |     s := service.LineSymbolBlack{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineSymbolBlack, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取交易对黑名单 | ||||||
|  | // @Summary 获取交易对黑名单 | ||||||
|  | // @Description 获取交易对黑名单 | ||||||
|  | // @Tags 交易对黑名单 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineSymbolBlack} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol-black/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolBlack) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolBlackGetReq{} | ||||||
|  | 	s := service.LineSymbolBlack{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineSymbolBlack | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对黑名单失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建交易对黑名单 | ||||||
|  | // @Summary 创建交易对黑名单 | ||||||
|  | // @Description 创建交易对黑名单 | ||||||
|  | // @Tags 交易对黑名单 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineSymbolBlackInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-black [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolBlack) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolBlackInsertReq{} | ||||||
|  |     s := service.LineSymbolBlack{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建交易对黑名单失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改交易对黑名单 | ||||||
|  | // @Summary 修改交易对黑名单 | ||||||
|  | // @Description 修改交易对黑名单 | ||||||
|  | // @Tags 交易对黑名单 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineSymbolBlackUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-black/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolBlack) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolBlackUpdateReq{} | ||||||
|  |     s := service.LineSymbolBlack{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改交易对黑名单失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除交易对黑名单 | ||||||
|  | // @Summary 删除交易对黑名单 | ||||||
|  | // @Description 删除交易对黑名单 | ||||||
|  | // @Tags 交易对黑名单 | ||||||
|  | // @Param data body dto.LineSymbolBlackDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-black [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolBlack) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineSymbolBlack{} | ||||||
|  |     req := dto.LineSymbolBlackDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除交易对黑名单失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										192
									
								
								app/admin/apis/line_symbol_group.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								app/admin/apis/line_symbol_group.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,192 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbolGroup struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取交易对组列表列表 | ||||||
|  | // @Summary 获取交易对组列表列表 | ||||||
|  | // @Description 获取交易对组列表列表 | ||||||
|  | // @Tags 交易对组列表 | ||||||
|  | // @Param type query string false "类型:1=现货,2=合约" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineSymbolGroup}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol-group [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolGroup) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolGroupGetPageReq{} | ||||||
|  |     s := service.LineSymbolGroup{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineSymbolGroup, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对组列表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取交易对组列表 | ||||||
|  | // @Summary 获取交易对组列表 | ||||||
|  | // @Description 获取交易对组列表 | ||||||
|  | // @Tags 交易对组列表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineSymbolGroup} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-symbol-group/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolGroup) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineSymbolGroupGetReq{} | ||||||
|  | 	s := service.LineSymbolGroup{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineSymbolGroup | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取交易对组列表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建交易对组列表 | ||||||
|  | // @Summary 创建交易对组列表 | ||||||
|  | // @Description 创建交易对组列表 | ||||||
|  | // @Tags 交易对组列表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineSymbolGroupInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-group [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolGroup) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolGroupInsertReq{} | ||||||
|  |     s := service.LineSymbolGroup{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建交易对组列表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改交易对组列表 | ||||||
|  | // @Summary 修改交易对组列表 | ||||||
|  | // @Description 修改交易对组列表 | ||||||
|  | // @Tags 交易对组列表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineSymbolGroupUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-group/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolGroup) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineSymbolGroupUpdateReq{} | ||||||
|  |     s := service.LineSymbolGroup{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改交易对组列表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除交易对组列表 | ||||||
|  | // @Summary 删除交易对组列表 | ||||||
|  | // @Description 删除交易对组列表 | ||||||
|  | // @Tags 交易对组列表 | ||||||
|  | // @Param data body dto.LineSymbolGroupDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-symbol-group [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSymbolGroup) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineSymbolGroup{} | ||||||
|  |     req := dto.LineSymbolGroupDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除交易对组列表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_system_setting.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_system_setting.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSystemSetting struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取挂单配置列表 | ||||||
|  | // @Summary 获取挂单配置列表 | ||||||
|  | // @Description 获取挂单配置列表 | ||||||
|  | // @Tags 挂单配置 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineSystemSetting}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-system-setting [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSystemSetting) GetPage(c *gin.Context) { | ||||||
|  | 	req := dto.LineSystemSettingGetPageReq{} | ||||||
|  | 	s := service.LineSystemSetting{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineSystemSetting, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取挂单配置失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取挂单配置 | ||||||
|  | // @Summary 获取挂单配置 | ||||||
|  | // @Description 获取挂单配置 | ||||||
|  | // @Tags 挂单配置 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineSystemSetting} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-system-setting/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSystemSetting) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineSystemSettingGetReq{} | ||||||
|  | 	s := service.LineSystemSetting{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineSystemSetting | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取挂单配置失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建挂单配置 | ||||||
|  | // @Summary 创建挂单配置 | ||||||
|  | // @Description 创建挂单配置 | ||||||
|  | // @Tags 挂单配置 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineSystemSettingInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-system-setting [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSystemSetting) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.LineSystemSettingInsertReq{} | ||||||
|  | 	s := service.LineSystemSetting{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建挂单配置失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改挂单配置 | ||||||
|  | // @Summary 修改挂单配置 | ||||||
|  | // @Description 修改挂单配置 | ||||||
|  | // @Tags 挂单配置 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineSystemSettingUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-system-setting/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSystemSetting) Update(c *gin.Context) { | ||||||
|  | 	req := dto.LineSystemSettingUpdateReq{} | ||||||
|  | 	s := service.LineSystemSetting{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改挂单配置失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除挂单配置 | ||||||
|  | // @Summary 删除挂单配置 | ||||||
|  | // @Description 删除挂单配置 | ||||||
|  | // @Tags 挂单配置 | ||||||
|  | // @Param data body dto.LineSystemSettingDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-system-setting [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineSystemSetting) Delete(c *gin.Context) { | ||||||
|  | 	s := service.LineSystemSetting{} | ||||||
|  | 	req := dto.LineSystemSettingDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除挂单配置失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_uduncoin.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_uduncoin.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUduncoin struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取【u盾支持的币种信息】列表 | ||||||
|  | // @Summary 获取【u盾支持的币种信息】列表 | ||||||
|  | // @Description 获取【u盾支持的币种信息】列表 | ||||||
|  | // @Tags 【u盾支持的币种信息】 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineUduncoin}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-uduncoin [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUduncoin) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineUduncoinGetPageReq{} | ||||||
|  |     s := service.LineUduncoin{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineUduncoin, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取【u盾支持的币种信息】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取【u盾支持的币种信息】 | ||||||
|  | // @Summary 获取【u盾支持的币种信息】 | ||||||
|  | // @Description 获取【u盾支持的币种信息】 | ||||||
|  | // @Tags 【u盾支持的币种信息】 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineUduncoin} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-uduncoin/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUduncoin) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineUduncoinGetReq{} | ||||||
|  | 	s := service.LineUduncoin{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineUduncoin | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取【u盾支持的币种信息】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建【u盾支持的币种信息】 | ||||||
|  | // @Summary 创建【u盾支持的币种信息】 | ||||||
|  | // @Description 创建【u盾支持的币种信息】 | ||||||
|  | // @Tags 【u盾支持的币种信息】 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineUduncoinInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-uduncoin [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUduncoin) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineUduncoinInsertReq{} | ||||||
|  |     s := service.LineUduncoin{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建【u盾支持的币种信息】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改【u盾支持的币种信息】 | ||||||
|  | // @Summary 修改【u盾支持的币种信息】 | ||||||
|  | // @Description 修改【u盾支持的币种信息】 | ||||||
|  | // @Tags 【u盾支持的币种信息】 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineUduncoinUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-uduncoin/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUduncoin) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineUduncoinUpdateReq{} | ||||||
|  |     s := service.LineUduncoin{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改【u盾支持的币种信息】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除【u盾支持的币种信息】 | ||||||
|  | // @Summary 删除【u盾支持的币种信息】 | ||||||
|  | // @Description 删除【u盾支持的币种信息】 | ||||||
|  | // @Tags 【u盾支持的币种信息】 | ||||||
|  | // @Param data body dto.LineUduncoinDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-uduncoin [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUduncoin) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineUduncoin{} | ||||||
|  |     req := dto.LineUduncoinDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除【u盾支持的币种信息】失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUser struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取会员表列表 | ||||||
|  | // @Summary 获取会员表列表 | ||||||
|  | // @Description 获取会员表列表 | ||||||
|  | // @Tags 会员表 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineUser}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUser) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineUserGetPageReq{} | ||||||
|  |     s := service.LineUser{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineUser, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取会员表 | ||||||
|  | // @Summary 获取会员表 | ||||||
|  | // @Description 获取会员表 | ||||||
|  | // @Tags 会员表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineUser} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUser) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineUserGetReq{} | ||||||
|  | 	s := service.LineUser{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineUser | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取会员表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建会员表 | ||||||
|  | // @Summary 创建会员表 | ||||||
|  | // @Description 创建会员表 | ||||||
|  | // @Tags 会员表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineUserInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-user [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUser) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineUserInsertReq{} | ||||||
|  |     s := service.LineUser{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建会员表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改会员表 | ||||||
|  | // @Summary 修改会员表 | ||||||
|  | // @Description 修改会员表 | ||||||
|  | // @Tags 会员表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineUserUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-user/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUser) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineUserUpdateReq{} | ||||||
|  |     s := service.LineUser{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改会员表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除会员表 | ||||||
|  | // @Summary 删除会员表 | ||||||
|  | // @Description 删除会员表 | ||||||
|  | // @Tags 会员表 | ||||||
|  | // @Param data body dto.LineUserDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-user [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUser) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineUser{} | ||||||
|  |     req := dto.LineUserDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除会员表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_user_funding_trend.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_user_funding_trend.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUserFundingTrend struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取用户资金走势列表 | ||||||
|  | // @Summary 获取用户资金走势列表 | ||||||
|  | // @Description 获取用户资金走势列表 | ||||||
|  | // @Tags 用户资金走势 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineUserFundingTrend}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user-funding-trend [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserFundingTrend) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineUserFundingTrendGetPageReq{} | ||||||
|  |     s := service.LineUserFundingTrend{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineUserFundingTrend, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户资金走势失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取用户资金走势 | ||||||
|  | // @Summary 获取用户资金走势 | ||||||
|  | // @Description 获取用户资金走势 | ||||||
|  | // @Tags 用户资金走势 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineUserFundingTrend} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user-funding-trend/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserFundingTrend) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineUserFundingTrendGetReq{} | ||||||
|  | 	s := service.LineUserFundingTrend{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineUserFundingTrend | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户资金走势失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建用户资金走势 | ||||||
|  | // @Summary 创建用户资金走势 | ||||||
|  | // @Description 创建用户资金走势 | ||||||
|  | // @Tags 用户资金走势 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineUserFundingTrendInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-user-funding-trend [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserFundingTrend) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineUserFundingTrendInsertReq{} | ||||||
|  |     s := service.LineUserFundingTrend{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建用户资金走势失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改用户资金走势 | ||||||
|  | // @Summary 修改用户资金走势 | ||||||
|  | // @Description 修改用户资金走势 | ||||||
|  | // @Tags 用户资金走势 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineUserFundingTrendUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-user-funding-trend/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserFundingTrend) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineUserFundingTrendUpdateReq{} | ||||||
|  |     s := service.LineUserFundingTrend{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改用户资金走势失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除用户资金走势 | ||||||
|  | // @Summary 删除用户资金走势 | ||||||
|  | // @Description 删除用户资金走势 | ||||||
|  | // @Tags 用户资金走势 | ||||||
|  | // @Param data body dto.LineUserFundingTrendDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-user-funding-trend [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserFundingTrend) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineUserFundingTrend{} | ||||||
|  |     req := dto.LineUserFundingTrendDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除用户资金走势失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										196
									
								
								app/admin/apis/line_user_profit_logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								app/admin/apis/line_user_profit_logs.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,196 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUserProfitLogs struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取会员盈利记录表列表 | ||||||
|  | // @Summary 获取会员盈利记录表列表 | ||||||
|  | // @Description 获取会员盈利记录表列表 | ||||||
|  | // @Tags 会员盈利记录表 | ||||||
|  | // @Param userId query int64 false "line_user 表的id" | ||||||
|  | // @Param apiId query int64 false "line_apiuser 表的id" | ||||||
|  | // @Param preOrderId query int64 false "line_pre_order 主订单id" | ||||||
|  | // @Param num query string false "成交数量" | ||||||
|  | // @Param symbol query string false "交易对" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineUserProfitLogs}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user-profit-logs [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserProfitLogs) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineUserProfitLogsGetPageReq{} | ||||||
|  |     s := service.LineUserProfitLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineUserProfitLogs, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取会员盈利记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取会员盈利记录表 | ||||||
|  | // @Summary 获取会员盈利记录表 | ||||||
|  | // @Description 获取会员盈利记录表 | ||||||
|  | // @Tags 会员盈利记录表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineUserProfitLogs} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-user-profit-logs/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserProfitLogs) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineUserProfitLogsGetReq{} | ||||||
|  | 	s := service.LineUserProfitLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineUserProfitLogs | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取会员盈利记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建会员盈利记录表 | ||||||
|  | // @Summary 创建会员盈利记录表 | ||||||
|  | // @Description 创建会员盈利记录表 | ||||||
|  | // @Tags 会员盈利记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineUserProfitLogsInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-user-profit-logs [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserProfitLogs) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineUserProfitLogsInsertReq{} | ||||||
|  |     s := service.LineUserProfitLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建会员盈利记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改会员盈利记录表 | ||||||
|  | // @Summary 修改会员盈利记录表 | ||||||
|  | // @Description 修改会员盈利记录表 | ||||||
|  | // @Tags 会员盈利记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineUserProfitLogsUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-user-profit-logs/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserProfitLogs) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineUserProfitLogsUpdateReq{} | ||||||
|  |     s := service.LineUserProfitLogs{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改会员盈利记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除会员盈利记录表 | ||||||
|  | // @Summary 删除会员盈利记录表 | ||||||
|  | // @Description 删除会员盈利记录表 | ||||||
|  | // @Tags 会员盈利记录表 | ||||||
|  | // @Param data body dto.LineUserProfitLogsDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-user-profit-logs [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineUserProfitLogs) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineUserProfitLogs{} | ||||||
|  |     req := dto.LineUserProfitLogsDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除会员盈利记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										191
									
								
								app/admin/apis/line_wallet.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								app/admin/apis/line_wallet.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,191 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineWallet struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取用户钱包地址列表 | ||||||
|  | // @Summary 获取用户钱包地址列表 | ||||||
|  | // @Description 获取用户钱包地址列表 | ||||||
|  | // @Tags 用户钱包地址 | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.LineWallet}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-wallet [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineWallet) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.LineWalletGetPageReq{} | ||||||
|  |     s := service.LineWallet{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.LineWallet, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户钱包地址失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取用户钱包地址 | ||||||
|  | // @Summary 获取用户钱包地址 | ||||||
|  | // @Description 获取用户钱包地址 | ||||||
|  | // @Tags 用户钱包地址 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.LineWallet} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/line-wallet/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineWallet) Get(c *gin.Context) { | ||||||
|  | 	req := dto.LineWalletGetReq{} | ||||||
|  | 	s := service.LineWallet{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.LineWallet | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取用户钱包地址失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建用户钱包地址 | ||||||
|  | // @Summary 创建用户钱包地址 | ||||||
|  | // @Description 创建用户钱包地址 | ||||||
|  | // @Tags 用户钱包地址 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.LineWalletInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/line-wallet [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineWallet) Insert(c *gin.Context) { | ||||||
|  |     req := dto.LineWalletInsertReq{} | ||||||
|  |     s := service.LineWallet{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建用户钱包地址失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改用户钱包地址 | ||||||
|  | // @Summary 修改用户钱包地址 | ||||||
|  | // @Description 修改用户钱包地址 | ||||||
|  | // @Tags 用户钱包地址 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.LineWalletUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/line-wallet/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineWallet) Update(c *gin.Context) { | ||||||
|  |     req := dto.LineWalletUpdateReq{} | ||||||
|  |     s := service.LineWallet{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改用户钱包地址失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除用户钱包地址 | ||||||
|  | // @Summary 删除用户钱包地址 | ||||||
|  | // @Description 删除用户钱包地址 | ||||||
|  | // @Tags 用户钱包地址 | ||||||
|  | // @Param data body dto.LineWalletDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/line-wallet [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e LineWallet) Delete(c *gin.Context) { | ||||||
|  |     s := service.LineWallet{} | ||||||
|  |     req := dto.LineWalletDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除用户钱包地址失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										148
									
								
								app/admin/apis/sys_api.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								app/admin/apis/sys_api.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,148 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysApi struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取接口管理列表 | ||||||
|  | // @Summary 获取接口管理列表 | ||||||
|  | // @Description 获取接口管理列表 | ||||||
|  | // @Tags 接口管理 | ||||||
|  | // @Param name query string false "名称" | ||||||
|  | // @Param title query string false "标题" | ||||||
|  | // @Param path query string false "地址" | ||||||
|  | // @Param action query string false "类型" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.SysApi}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-api [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysApi) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysApi{} | ||||||
|  | 	req := dto.SysApiGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.SysApi, 0) | ||||||
|  | 	var count int64 | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取接口管理 | ||||||
|  | // @Summary 获取接口管理 | ||||||
|  | // @Description 获取接口管理 | ||||||
|  | // @Tags 接口管理 | ||||||
|  | // @Param id path string false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.SysApi} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-api/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysApi) Get(c *gin.Context) { | ||||||
|  | 	req := dto.SysApiGetReq{} | ||||||
|  | 	s := service.SysApi{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	var object models.SysApi | ||||||
|  | 	err = s.Get(&req, p, &object).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改接口管理 | ||||||
|  | // @Summary 修改接口管理 | ||||||
|  | // @Description 修改接口管理 | ||||||
|  | // @Tags 接口管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysApiUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/sys-api/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysApi) Update(c *gin.Context) { | ||||||
|  | 	req := dto.SysApiUpdateReq{} | ||||||
|  | 	s := service.SysApi{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "更新失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // DeleteSysApi 删除接口管理 | ||||||
|  | // @Summary 删除接口管理 | ||||||
|  | // @Description 删除接口管理 | ||||||
|  | // @Tags 接口管理 | ||||||
|  | // @Param data body dto.SysApiDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/sys-api [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysApi) DeleteSysApi(c *gin.Context) { | ||||||
|  | 	req := dto.SysApiDeleteReq{} | ||||||
|  | 	s := service.SysApi{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										313
									
								
								app/admin/apis/sys_config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										313
									
								
								app/admin/apis/sys_config.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,313 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysConfig struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取配置管理列表 | ||||||
|  | // @Summary 获取配置管理列表 | ||||||
|  | // @Description 获取配置管理列表 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Param configName query string false "名称" | ||||||
|  | // @Param configKey query string false "key" | ||||||
|  | // @Param configType query string false "类型" | ||||||
|  | // @Param isFrontend query int false "是否前端" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.SysApi}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-config [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := dto.SysConfigGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysConfig, 0) | ||||||
|  | 	var count int64 | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取配置管理 | ||||||
|  | // @Summary 获取配置管理 | ||||||
|  | // @Description 获取配置管理 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Param id path string false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.SysConfig} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-config/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Get(c *gin.Context) { | ||||||
|  | 	req := dto.SysConfigGetReq{} | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysConfig | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建配置管理 | ||||||
|  | // @Summary 创建配置管理 | ||||||
|  | // @Description 创建配置管理 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysConfigControl true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "创建成功"}" | ||||||
|  | // @Router /api/v1/sys-config [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := dto.SysConfigControl{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "创建失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改配置管理 | ||||||
|  | // @Summary 修改配置管理 | ||||||
|  | // @Description 修改配置管理 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysConfigControl true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/sys-config/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := dto.SysConfigControl{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Update(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "更新失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除配置管理 | ||||||
|  | // @Summary 删除配置管理 | ||||||
|  | // @Description 删除配置管理 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Param ids body []int false "ids" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/sys-config [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := dto.SysConfigDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get2SysApp 获取系统配置信息 | ||||||
|  | // @Summary 获取系统前台配置信息,主要注意这里不在验证权限 | ||||||
|  | // @Description 获取系统配置信息,主要注意这里不在验证权限 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Success 200 {object} response.Response{data=map[string]string} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/app-config [get] | ||||||
|  | func (e SysConfig) Get2SysApp(c *gin.Context) { | ||||||
|  | 	req := dto.SysConfigGetToSysAppReq{} | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 控制只读前台的数据 | ||||||
|  | 	req.IsFrontend = "1" | ||||||
|  | 	list := make([]models.SysConfig, 0) | ||||||
|  | 	err = s.GetWithKeyList(&req, &list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	mp := make(map[string]string) | ||||||
|  | 	for i := 0; i < len(list); i++ { | ||||||
|  | 		key := list[i].ConfigKey | ||||||
|  | 		if key != "" { | ||||||
|  | 			mp[key] = list[i].ConfigValue | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	e.OK(mp, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get2Set 获取配置 | ||||||
|  | // @Summary 获取配置 | ||||||
|  | // @Description 界面操作设置配置值的获取 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Success 200 {object} response.Response{data=map[string]interface{}}	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/set-config [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Get2Set(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := make([]dto.GetSetSysConfigReq, 0) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.GetForSet(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	m := make(map[string]interface{}, 0) | ||||||
|  | 	for _, v := range req { | ||||||
|  | 		m[v.ConfigKey] = v.ConfigValue | ||||||
|  | 	} | ||||||
|  | 	e.OK(m, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update2Set 设置配置 | ||||||
|  | // @Summary 设置配置 | ||||||
|  | // @Description 界面操作设置配置值 | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body []dto.GetSetSysConfigReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/set-config [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) Update2Set(c *gin.Context) { | ||||||
|  | 	s := service.SysConfig{} | ||||||
|  | 	req := make([]dto.GetSetSysConfigReq, 0) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.UpdateForSet(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK("", "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetSysConfigByKEYForService 根据Key获取SysConfig的Service | ||||||
|  | // @Summary 根据Key获取SysConfig的Service | ||||||
|  | // @Description 根据Key获取SysConfig的Service | ||||||
|  | // @Tags 配置管理 | ||||||
|  | // @Param configKey path string false "configKey" | ||||||
|  | // @Success 200 {object} response.Response{data=dto.SysConfigByKeyReq} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-config/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysConfig) GetSysConfigByKEYForService(c *gin.Context) { | ||||||
|  | 	var s = new(service.SysConfig) | ||||||
|  | 	var req = new(dto.SysConfigByKeyReq) | ||||||
|  | 	var resp = new(dto.GetSysConfigByKEYForServiceResp) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.GetWithKey(req, resp) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(resp, s.Msg) | ||||||
|  | } | ||||||
							
								
								
									
										238
									
								
								app/admin/apis/sys_dept.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										238
									
								
								app/admin/apis/sys_dept.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,238 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysDept struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage | ||||||
|  | // @Summary 分页部门列表数据 | ||||||
|  | // @Description 分页列表 | ||||||
|  | // @Tags 部门 | ||||||
|  | // @Param deptName query string false "deptName" | ||||||
|  | // @Param deptId query string false "deptId" | ||||||
|  | // @Param position query string false "position" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dept [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDept) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]models.SysDept, 0) | ||||||
|  | 	list, err = s.SetDeptPage(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get | ||||||
|  | // @Summary 获取部门数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 部门 | ||||||
|  | // @Param deptId path string false "deptId" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dept/{deptId} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDept) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysDept | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 添加部门 | ||||||
|  | // @Summary 添加部门 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 部门 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysDeptInsertReq true "data" | ||||||
|  | // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}" | ||||||
|  | // @Router /api/v1/dept [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDept) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "创建失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update | ||||||
|  | // @Summary 修改部门 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 部门 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.SysDeptUpdateReq true "body" | ||||||
|  | // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}" | ||||||
|  | // @Router /api/v1/dept/{deptId} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDept) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Update(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除部门 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 部门 | ||||||
|  | // @Param data body dto.SysDeptDeleteReq true "body" | ||||||
|  | // @Success 200 {string} string	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Success 200 {string} string	"{"code": -1, "message": "删除失败"}" | ||||||
|  | // @Router /api/v1/dept [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDept) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get2Tree 用户管理 左侧部门树 | ||||||
|  | func (e SysDept) Get2Tree(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	req := dto.SysDeptGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]dto.DeptLabel, 0) | ||||||
|  | 	list, err = s.SetDeptTree(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetDeptTreeRoleSelect TODO: 此接口需要调整不应该将list和选中放在一起 | ||||||
|  | func (e SysDept) GetDeptTreeRoleSelect(c *gin.Context) { | ||||||
|  | 	s := service.SysDept{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	id, err := pkg.StringToInt(c.Param("roleId")) | ||||||
|  | 	result, err := s.SetDeptLabel() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	menuIds := make([]int, 0) | ||||||
|  | 	if id != 0 { | ||||||
|  | 		menuIds, err = s.GetWithRoleId(id) | ||||||
|  | 		if err != nil { | ||||||
|  | 			e.Error(500, err, err.Error()) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	e.OK(gin.H{ | ||||||
|  | 		"depts":       result, | ||||||
|  | 		"checkedKeys": menuIds, | ||||||
|  | 	}, "") | ||||||
|  | } | ||||||
							
								
								
									
										220
									
								
								app/admin/apis/sys_dict_data.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										220
									
								
								app/admin/apis/sys_dict_data.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,220 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysDictData struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage | ||||||
|  | // @Summary 字典数据列表 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Param status query string false "status" | ||||||
|  | // @Param dictCode query string false "dictCode" | ||||||
|  | // @Param dictType query string false "dictType" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/data [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysDictData, 0) | ||||||
|  | 	var count int64 | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get | ||||||
|  | // @Summary 通过编码获取字典数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Param dictCode path int true "字典编码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/data/{dictCode} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var object models.SysDictData | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Warnf("Get error: %s", err.Error()) | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert | ||||||
|  | // @Summary 添加字典数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysDictDataInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/dict/data [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "创建失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update | ||||||
|  | // @Summary 修改字典数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysDictDataUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/dict/data/{dictCode} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Update(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "更新失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除字典数据 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Param dictCode body dto.SysDictDataDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/dict/data [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetAll 数据字典根据key获取 业务页面使用 | ||||||
|  | // @Summary 数据字典根据key获取 | ||||||
|  | // @Description 数据字典根据key获取 | ||||||
|  | // @Tags 字典数据 | ||||||
|  | // @Param dictType query int true "dictType" | ||||||
|  | // @Success 200 {object} response.Response{data=[]dto.SysDictDataGetAllResp}  "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict-data/option-select [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictData) GetAll(c *gin.Context) { | ||||||
|  | 	s := service.SysDictData{} | ||||||
|  | 	req := dto.SysDictDataGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]models.SysDictData, 0) | ||||||
|  | 	err = s.GetAll(&req, &list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	l := make([]dto.SysDictDataGetAllResp, 0) | ||||||
|  | 	for _, i := range list { | ||||||
|  | 		d := dto.SysDictDataGetAllResp{} | ||||||
|  | 		e.Translate(i, &d) | ||||||
|  | 		l = append(l, d) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(l,"查询成功") | ||||||
|  | } | ||||||
							
								
								
									
										210
									
								
								app/admin/apis/sys_dict_type.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										210
									
								
								app/admin/apis/sys_dict_type.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,210 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysDictType struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 字典类型列表数据 | ||||||
|  | // @Summary 字典类型列表数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Param dictName query string false "dictName" | ||||||
|  | // @Param dictId query string false "dictId" | ||||||
|  | // @Param dictType query string false "dictType" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]models.SysDictType, 0) | ||||||
|  | 	var count int64 | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 字典类型通过字典id获取 | ||||||
|  | // @Summary 字典类型通过字典id获取 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Param dictId path int true "字典类型编码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type/{dictId} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysDictType | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | //Insert 字典类型创建 | ||||||
|  | // @Summary 添加字典类型 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysDictTypeInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err,fmt.Sprintf(" 创建字典类型失败,详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update | ||||||
|  | // @Summary 修改字典类型 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysDictTypeUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type/{dictId} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Update(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除字典类型 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Param dictCode body dto.SysDictTypeDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetAll | ||||||
|  | // @Summary 字典类型全部数据 代码生成使用接口 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 字典类型 | ||||||
|  | // @Param dictName query string false "dictName" | ||||||
|  | // @Param dictId query string false "dictId" | ||||||
|  | // @Param dictType query string false "dictType" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/dict/type-option-select [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysDictType) GetAll(c *gin.Context) { | ||||||
|  | 	s := service.SysDictType{} | ||||||
|  | 	req :=dto.SysDictTypeGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]models.SysDictType, 0) | ||||||
|  | 	err = s.GetAll(&req, &list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "查询成功") | ||||||
|  | } | ||||||
							
								
								
									
										110
									
								
								app/admin/apis/sys_login_log.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								app/admin/apis/sys_login_log.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,110 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysLoginLog struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 登录日志列表 | ||||||
|  | // @Summary 登录日志列表 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 登录日志 | ||||||
|  | // @Param username query string false "用户名" | ||||||
|  | // @Param ipaddr query string false "ip地址" | ||||||
|  | // @Param loginLocation  query string false "归属地" | ||||||
|  | // @Param status query string false "状态" | ||||||
|  | // @Param beginTime query string false "开始时间" | ||||||
|  | // @Param endTime query string false "结束时间" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-login-log [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysLoginLog) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysLoginLog{} | ||||||
|  | 	req :=dto.SysLoginLogGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	list := make([]models.SysLoginLog, 0) | ||||||
|  | 	var count int64 | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 登录日志通过id获取 | ||||||
|  | // @Summary 登录日志通过id获取 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 登录日志 | ||||||
|  | // @Param id path string false "id" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-login-log/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysLoginLog) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysLoginLog{} | ||||||
|  | 	req :=dto.SysLoginLogGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysLoginLog | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 登录日志删除 | ||||||
|  | // @Summary 登录日志删除 | ||||||
|  | // @Description 登录日志删除 | ||||||
|  | // @Tags 登录日志 | ||||||
|  | // @Param data body dto.SysLoginLogDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-login-log [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysLoginLog) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysLoginLog{} | ||||||
|  | 	req :=dto.SysLoginLogDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										287
									
								
								app/admin/apis/sys_menu.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								app/admin/apis/sys_menu.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,287 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysMenu struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage Menu列表数据 | ||||||
|  | // @Summary Menu列表数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Param menuName query string false "menuName" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menu [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysMenu{} | ||||||
|  | 	req := dto.SysMenuGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var list = make([]models.SysMenu, 0) | ||||||
|  | 	err = s.GetPage(&req, &list).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(list, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取菜单详情 | ||||||
|  | // @Summary Menu详情数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Param id path string false "id" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menu/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) Get(c *gin.Context) { | ||||||
|  | 	req := dto.SysMenuGetReq{} | ||||||
|  | 	s := new(service.SysMenu) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object = models.SysMenu{} | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建菜单 | ||||||
|  | // @Summary 创建菜单 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysMenuInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menu [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) Insert(c *gin.Context) { | ||||||
|  | 	req := dto.SysMenuInsertReq{} | ||||||
|  | 	s := new(service.SysMenu) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "创建失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改菜单 | ||||||
|  | // @Summary 修改菜单 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.SysMenuUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menu/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) Update(c *gin.Context) { | ||||||
|  | 	req := dto.SysMenuUpdateReq{} | ||||||
|  | 	s := new(service.SysMenu) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Update(&req).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "更新失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除菜单 | ||||||
|  | // @Summary 删除菜单 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Param data body dto.SysMenuDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menu [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) Delete(c *gin.Context) { | ||||||
|  | 	control := new(dto.SysMenuDeleteReq) | ||||||
|  | 	s := new(service.SysMenu) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(control, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.Remove(control).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Errorf("RemoveSysMenu error, %s", err) | ||||||
|  | 		e.Error(500, err, "删除失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(control.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetMenuRole 根据登录角色名称获取菜单列表数据(左菜单使用) | ||||||
|  | // @Summary 根据登录角色名称获取菜单列表数据(左菜单使用) | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menurole [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) GetMenuRole(c *gin.Context) { | ||||||
|  | 	s := new(service.SysMenu) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	result, err := s.SetMenuRole(user.GetRoleName(c)) | ||||||
|  |  | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(result, "") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | //// GetMenuIDS 获取角色对应的菜单id数组 | ||||||
|  | //// @Summary 获取角色对应的菜单id数组,设置角色权限使用 | ||||||
|  | //// @Description 获取JSON | ||||||
|  | //// @Tags 菜单 | ||||||
|  | //// @Param id path int true "id" | ||||||
|  | //// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | //// @Router /api/v1/menuids/{id} [get] | ||||||
|  | //// @Security Bearer | ||||||
|  | //func (e SysMenu) GetMenuIDS(c *gin.Context) { | ||||||
|  | //	s := new(service.SysMenu) | ||||||
|  | //	r := service.SysRole{} | ||||||
|  | //	m := dto.SysRoleByName{} | ||||||
|  | //	err := e.MakeContext(c). | ||||||
|  | //		MakeOrm(). | ||||||
|  | //		Bind(&m, binding.JSON). | ||||||
|  | //		MakeService(&s.Service). | ||||||
|  | //		MakeService(&r.Service). | ||||||
|  | //		Errors | ||||||
|  | //	if err != nil { | ||||||
|  | //		e.Logger.Error(err) | ||||||
|  | //		e.Error(500, err, err.Error()) | ||||||
|  | //		return | ||||||
|  | //	} | ||||||
|  | //	var data models.SysRole | ||||||
|  | //	err = r.GetWithName(&m, &data).Error | ||||||
|  | // | ||||||
|  | //	//data.RoleName = c.GetString("role") | ||||||
|  | //	//data.UpdateBy = user.GetUserId(c) | ||||||
|  | //	//result, err := data.GetIDS(s.Orm) | ||||||
|  | // | ||||||
|  | //	if err != nil { | ||||||
|  | //		e.Logger.Errorf("GetIDS error, %s", err.Error()) | ||||||
|  | //		e.Error(500, err, "获取失败") | ||||||
|  | //		return | ||||||
|  | //	} | ||||||
|  | //	e.OK(result, "") | ||||||
|  | //} | ||||||
|  |  | ||||||
|  | // GetMenuTreeSelect 根据角色ID查询菜单下拉树结构 | ||||||
|  | // @Summary 角色修改使用的菜单列表 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 菜单 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param roleId path int true "roleId" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/menuTreeselect/{roleId} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysMenu) GetMenuTreeSelect(c *gin.Context) { | ||||||
|  | 	m := service.SysMenu{} | ||||||
|  | 	r := service.SysRole{} | ||||||
|  | 	req :=dto.SelectRole{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&m.Service). | ||||||
|  | 		MakeService(&r.Service). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	result, err := m.SetLabel() | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	menuIds := make([]int, 0) | ||||||
|  | 	if req.RoleId != 0 { | ||||||
|  | 		menuIds, err = r.GetRoleMenuId(req.RoleId) | ||||||
|  | 		if err != nil { | ||||||
|  | 			e.Error(500, err, "") | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	e.OK(gin.H{ | ||||||
|  | 		"menus":       result, | ||||||
|  | 		"checkedKeys": menuIds, | ||||||
|  | 	}, "获取成功") | ||||||
|  | } | ||||||
							
								
								
									
										118
									
								
								app/admin/apis/sys_opera_log.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								app/admin/apis/sys_opera_log.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,118 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysOperaLog struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 操作日志列表 | ||||||
|  | // @Summary 操作日志列表 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 操作日志 | ||||||
|  | // @Param title query string false "title" | ||||||
|  | // @Param method query string false "method" | ||||||
|  | // @Param requestMethod  query string false "requestMethod" | ||||||
|  | // @Param operUrl query string false "operUrl" | ||||||
|  | // @Param operIp query string false "operIp" | ||||||
|  | // @Param status query string false "status" | ||||||
|  | // @Param beginTime query string false "beginTime" | ||||||
|  | // @Param endTime query string false "endTime" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-opera-log [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysOperaLog) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysOperaLog{} | ||||||
|  | 	req := new(dto.SysOperaLogGetPageReq) | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysOperaLog, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 操作日志通过id获取 | ||||||
|  | // @Summary 操作日志通过id获取 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 操作日志 | ||||||
|  | // @Param id path string false "id" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-opera-log/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysOperaLog) Get(c *gin.Context) { | ||||||
|  | 	s := new(service.SysOperaLog) | ||||||
|  | 	req :=dto.SysOperaLogGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysOperaLog | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 操作日志删除 | ||||||
|  | // DeleteSysMenu 操作日志删除 | ||||||
|  | // @Summary 删除操作日志 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 操作日志 | ||||||
|  | // @Param data body dto.SysOperaLogDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-opera-log [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysOperaLog) Delete(c *gin.Context) { | ||||||
|  | 	s := new(service.SysOperaLog) | ||||||
|  | 	req :=dto.SysOperaLogDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500,err, fmt.Sprintf("删除失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										184
									
								
								app/admin/apis/sys_post.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								app/admin/apis/sys_post.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,184 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	 | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysPost struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage | ||||||
|  | // @Summary 岗位列表数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 岗位 | ||||||
|  | // @Param postName query string false "postName" | ||||||
|  | // @Param postCode query string false "postCode" | ||||||
|  | // @Param postId query string false "postId" | ||||||
|  | // @Param status query string false "status" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/post [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysPost) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysPost{} | ||||||
|  | 	req :=dto.SysPostPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysPost, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get | ||||||
|  | // @Summary 获取岗位信息 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 岗位 | ||||||
|  | // @Param id path int true "编码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/post/{postId} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysPost) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysPost{} | ||||||
|  | 	req :=dto.SysPostGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysPost | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("岗位信息获取失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert | ||||||
|  | // @Summary 添加岗位 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 岗位 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysPostInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/post [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysPost) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysPost{} | ||||||
|  | 	req :=dto.SysPostInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("新建岗位失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update | ||||||
|  | // @Summary 修改岗位 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 岗位 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysPostUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/post/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysPost) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysPost{} | ||||||
|  | 	req :=dto.SysPostUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("岗位更新失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除岗位 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 岗位 | ||||||
|  | // @Param id body dto.SysPostDeleteReq true "请求参数" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/post [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysPost) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysPost{} | ||||||
|  | 	req :=dto.SysPostDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Remove(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("岗位删除失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										284
									
								
								app/admin/apis/sys_role.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								app/admin/apis/sys_role.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,284 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"go-admin/common/global" | ||||||
|  | 	"net/http" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysRole struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage | ||||||
|  | // @Summary 角色列表数据 | ||||||
|  | // @Description Get JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Param roleName query string false "roleName" | ||||||
|  | // @Param status query string false "status" | ||||||
|  | // @Param roleKey query string false "roleKey" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.SysRoleGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.Form). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysRole, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get | ||||||
|  | // @Summary 获取Role数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Param roleId path string false "roleId" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.SysRoleGetReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, fmt.Sprintf(" %s ", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var object models.SysRole | ||||||
|  |  | ||||||
|  | 	err = s.Get(&req, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(http.StatusUnprocessableEntity, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert | ||||||
|  | // @Summary 创建角色 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysRoleInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.SysRoleInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.CreateBy = user.GetUserId(c) | ||||||
|  | 	if req.Status == "" { | ||||||
|  | 		req.Status = "2" | ||||||
|  | 	} | ||||||
|  | 	cb := sdk.Runtime.GetCasbinKey(c.Request.Host) | ||||||
|  | 	err = s.Insert(&req, cb) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, "创建失败,"+err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	_, err = global.LoadPolicy(c) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, "创建失败,"+err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改用户角色 | ||||||
|  | // @Summary 修改用户角色 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysRoleUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.SysRoleUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	cb := sdk.Runtime.GetCasbinKey(c.Request.Host) | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, cb) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	_, err = global.LoadPolicy(c) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, "更新失败,"+err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除用户角色 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Param data body dto.SysRoleDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Delete(c *gin.Context) { | ||||||
|  | 	s := new(service.SysRole) | ||||||
|  | 	req := dto.SysRoleDeleteReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,\r\n失败信息 %s", req.Ids, err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	cb := sdk.Runtime.GetCasbinKey(c.Request.Host) | ||||||
|  | 	err = s.Remove(&req, cb) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, "") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId())) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update2Status 修改用户角色状态 | ||||||
|  | // @Summary 修改用户角色 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.UpdateStatusReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role-status/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Update2Status(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.UpdateStatusReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("更新角色状态失败,失败原因:%s ", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.UpdateStatus(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("更新角色状态失败,失败原因:%s ", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), fmt.Sprintf("更新角色 %v 状态成功!", req.GetId())) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update2DataScope 更新角色数据权限 | ||||||
|  | // @Summary 更新角色数据权限 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 角色/Role | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.RoleDataScopeReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/role-status/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysRole) Update2DataScope(c *gin.Context) { | ||||||
|  | 	s := service.SysRole{} | ||||||
|  | 	req := dto.RoleDataScopeReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	data := &models.SysRole{ | ||||||
|  | 		RoleId:    req.RoleId, | ||||||
|  | 		DataScope: req.DataScope, | ||||||
|  | 		DeptIds:   req.DeptIds, | ||||||
|  | 	} | ||||||
|  | 	data.UpdateBy = user.GetUserId(c) | ||||||
|  | 	err = s.UpdateDataScope(&req).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("更新角色数据权限失败!错误详情:%s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "操作成功") | ||||||
|  | } | ||||||
							
								
								
									
										459
									
								
								app/admin/apis/sys_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										459
									
								
								app/admin/apis/sys_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,459 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin/binding" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"golang.org/x/crypto/bcrypt" | ||||||
|  | 	"net/http" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  | 	"github.com/google/uuid" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysUser struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage | ||||||
|  | // @Summary 列表用户信息数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Param username query string false "username" | ||||||
|  | // @Success 200 {string} {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-user [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) GetPage(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserGetPageReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	list := make([]models.SysUser, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get | ||||||
|  | // @Summary 获取用户 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Param userId path int true "用户编码" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-user/{userId} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) Get(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserById{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.SysUser | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(http.StatusUnprocessableEntity, err, "查询失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert | ||||||
|  | // @Summary 创建用户 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysUserInsertReq true "用户数据" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-user [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) Insert(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserInsertReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update | ||||||
|  | // @Summary 修改用户数据 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.SysUserUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-user/{userId} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) Update(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserUpdateReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete | ||||||
|  | // @Summary 删除用户数据 | ||||||
|  | // @Description 删除数据 | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Param userId path int true "userId" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/sys-user/{userId} [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) Delete(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserById{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 设置编辑人 | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	// 数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "删除成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // InsetAvatar | ||||||
|  | // @Summary 修改头像 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 个人中心 | ||||||
|  | // @Accept multipart/form-data | ||||||
|  | // @Param file formData file true "file" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/user/avatar [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) InsetAvatar(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.UpdateSysUserAvatarReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	form, _ := c.MultipartForm() | ||||||
|  | 	files := form.File["upload[]"] | ||||||
|  | 	guid := uuid.New().String() | ||||||
|  | 	filPath := "static/uploadfile/" + guid + ".jpg" | ||||||
|  | 	for _, file := range files { | ||||||
|  | 		e.Logger.Debugf("upload avatar file: %s", file.Filename) | ||||||
|  | 		// 上传文件至指定目录 | ||||||
|  | 		err = c.SaveUploadedFile(file, filPath) | ||||||
|  | 		if err != nil { | ||||||
|  | 			e.Logger.Errorf("save file error, %s", err.Error()) | ||||||
|  | 			e.Error(500, err, "") | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	req.UserId = p.UserId | ||||||
|  | 	req.Avatar = "/" + filPath | ||||||
|  |  | ||||||
|  | 	err = s.UpdateAvatar(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(filPath, "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UpdateStatus 修改用户状态 | ||||||
|  | // @Summary 修改用户状态 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.UpdateSysUserStatusReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/user/status [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) UpdateStatus(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.UpdateSysUserStatusReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON, nil). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.UpdateStatus(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ResetPwd 重置用户密码 | ||||||
|  | // @Summary 重置用户密码 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.ResetSysUserPwdReq true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/user/pwd/reset [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) ResetPwd(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.ResetSysUserPwdReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req, binding.JSON). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	//数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.ResetPwd(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(req.GetId(), "更新成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UpdatePwd | ||||||
|  | // @Summary 修改密码 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 用户 | ||||||
|  | // @Accept  application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.PassWord true "body" | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/user/pwd/set [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) UpdatePwd(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.PassWord{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 数据权限检查 | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	var hash []byte | ||||||
|  | 	if hash, err = bcrypt.GenerateFromPassword([]byte(req.NewPassword), bcrypt.DefaultCost); err != nil { | ||||||
|  | 		req.NewPassword = string(hash) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = s.UpdatePwd(user.GetUserId(c), req.OldPassword, req.NewPassword, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(http.StatusForbidden, err, "密码修改失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(nil, "密码修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetProfile | ||||||
|  | // @Summary 获取个人中心用户 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 个人中心 | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/user/profile [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) GetProfile(c *gin.Context) { | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	req := dto.SysUserById{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	req.Id = user.GetUserId(c) | ||||||
|  |  | ||||||
|  | 	sysUser := models.SysUser{} | ||||||
|  | 	roles := make([]models.SysRole, 0) | ||||||
|  | 	posts := make([]models.SysPost, 0) | ||||||
|  | 	err = s.GetProfile(&req, &sysUser, &roles, &posts) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Errorf("get user profile error, %s", err.Error()) | ||||||
|  | 		e.Error(500, err, "获取用户信息失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(gin.H{ | ||||||
|  | 		"user":  sysUser, | ||||||
|  | 		"roles": roles, | ||||||
|  | 		"posts": posts, | ||||||
|  | 	}, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetInfo | ||||||
|  | // @Summary 获取个人信息 | ||||||
|  | // @Description 获取JSON | ||||||
|  | // @Tags 个人中心 | ||||||
|  | // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/getinfo [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e SysUser) GetInfo(c *gin.Context) { | ||||||
|  | 	req := dto.SysUserById{} | ||||||
|  | 	s := service.SysUser{} | ||||||
|  | 	r := service.SysRole{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&r.Service). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	var roles = make([]string, 1) | ||||||
|  | 	roles[0] = user.GetRoleName(c) | ||||||
|  | 	var permissions = make([]string, 1) | ||||||
|  | 	permissions[0] = "*:*:*" | ||||||
|  | 	var buttons = make([]string, 1) | ||||||
|  | 	buttons[0] = "*:*:*" | ||||||
|  |  | ||||||
|  | 	var mp = make(map[string]interface{}) | ||||||
|  | 	mp["roles"] = roles | ||||||
|  | 	if user.GetRoleName(c) == "admin" || user.GetRoleName(c) == "系统管理员" { | ||||||
|  | 		mp["permissions"] = permissions | ||||||
|  | 		mp["buttons"] = buttons | ||||||
|  | 	} else { | ||||||
|  | 		list, _ := r.GetById(user.GetRoleId(c)) | ||||||
|  | 		mp["permissions"] = list | ||||||
|  | 		mp["buttons"] = list | ||||||
|  | 	} | ||||||
|  | 	sysUser := models.SysUser{} | ||||||
|  | 	req.Id = user.GetUserId(c) | ||||||
|  | 	err = s.Get(&req, p, &sysUser) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(http.StatusUnauthorized, err, "登录失败") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	mp["introduction"] = " am a super administrator" | ||||||
|  | 	mp["avatar"] = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif" | ||||||
|  | 	if sysUser.Avatar != "" { | ||||||
|  | 		mp["avatar"] = sysUser.Avatar | ||||||
|  | 	} | ||||||
|  | 	mp["userName"] = sysUser.Username | ||||||
|  | 	mp["userId"] = sysUser.UserId | ||||||
|  | 	mp["deptId"] = sysUser.DeptId | ||||||
|  | 	mp["name"] = sysUser.NickName | ||||||
|  | 	mp["code"] = 200 | ||||||
|  | 	e.OK(mp, "") | ||||||
|  | } | ||||||
							
								
								
									
										194
									
								
								app/admin/apis/vts_recharge.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										194
									
								
								app/admin/apis/vts_recharge.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,194 @@ | |||||||
|  | package apis | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "fmt" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" | ||||||
|  | 	_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type VtsRecharge struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPage 获取coinGate充值记录表列表 | ||||||
|  | // @Summary 获取coinGate充值记录表列表 | ||||||
|  | // @Description 获取coinGate充值记录表列表 | ||||||
|  | // @Tags coinGate充值记录表 | ||||||
|  | // @Param coinCode query string false "币种" | ||||||
|  | // @Param orderNo query string false "订单号" | ||||||
|  | // @Param adUserId query int64 false "用户id" | ||||||
|  | // @Param pageSize query int false "页条数" | ||||||
|  | // @Param pageIndex query int false "页码" | ||||||
|  | // @Success 200 {object} response.Response{data=response.Page{list=[]models.VtsRecharge}} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/vts-recharge [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e VtsRecharge) GetPage(c *gin.Context) { | ||||||
|  |     req := dto.VtsRechargeGetPageReq{} | ||||||
|  |     s := service.VtsRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |    	if err != nil { | ||||||
|  |    		e.Logger.Error(err) | ||||||
|  |    		e.Error(500, err, err.Error()) | ||||||
|  |    		return | ||||||
|  |    	} | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	list := make([]models.VtsRecharge, 0) | ||||||
|  | 	var count int64 | ||||||
|  |  | ||||||
|  | 	err = s.GetPage(&req, p, &list, &count) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取coinGate充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get 获取coinGate充值记录表 | ||||||
|  | // @Summary 获取coinGate充值记录表 | ||||||
|  | // @Description 获取coinGate充值记录表 | ||||||
|  | // @Tags coinGate充值记录表 | ||||||
|  | // @Param id path int false "id" | ||||||
|  | // @Success 200 {object} response.Response{data=models.VtsRecharge} "{"code": 200, "data": [...]}" | ||||||
|  | // @Router /api/v1/vts-recharge/{id} [get] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e VtsRecharge) Get(c *gin.Context) { | ||||||
|  | 	req := dto.VtsRechargeGetReq{} | ||||||
|  | 	s := service.VtsRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var object models.VtsRecharge | ||||||
|  |  | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  | 	err = s.Get(&req, p, &object) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("获取coinGate充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK( object, "查询成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Insert 创建coinGate充值记录表 | ||||||
|  | // @Summary 创建coinGate充值记录表 | ||||||
|  | // @Description 创建coinGate充值记录表 | ||||||
|  | // @Tags coinGate充值记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param data body dto.VtsRechargeInsertReq true "data" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "添加成功"}" | ||||||
|  | // @Router /api/v1/vts-recharge [post] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e VtsRecharge) Insert(c *gin.Context) { | ||||||
|  |     req := dto.VtsRechargeInsertReq{} | ||||||
|  |     s := service.VtsRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	// 设置创建人 | ||||||
|  | 	req.SetCreateBy(user.GetUserId(c)) | ||||||
|  |  | ||||||
|  | 	err = s.Insert(&req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("创建coinGate充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(req.GetId(), "创建成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update 修改coinGate充值记录表 | ||||||
|  | // @Summary 修改coinGate充值记录表 | ||||||
|  | // @Description 修改coinGate充值记录表 | ||||||
|  | // @Tags coinGate充值记录表 | ||||||
|  | // @Accept application/json | ||||||
|  | // @Product application/json | ||||||
|  | // @Param id path int true "id" | ||||||
|  | // @Param data body dto.VtsRechargeUpdateReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "修改成功"}" | ||||||
|  | // @Router /api/v1/vts-recharge/{id} [put] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e VtsRecharge) Update(c *gin.Context) { | ||||||
|  |     req := dto.VtsRechargeUpdateReq{} | ||||||
|  |     s := service.VtsRecharge{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  | 	req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Update(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("修改coinGate充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "修改成功") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Delete 删除coinGate充值记录表 | ||||||
|  | // @Summary 删除coinGate充值记录表 | ||||||
|  | // @Description 删除coinGate充值记录表 | ||||||
|  | // @Tags coinGate充值记录表 | ||||||
|  | // @Param data body dto.VtsRechargeDeleteReq true "body" | ||||||
|  | // @Success 200 {object} response.Response	"{"code": 200, "message": "删除成功"}" | ||||||
|  | // @Router /api/v1/vts-recharge [delete] | ||||||
|  | // @Security Bearer | ||||||
|  | func (e VtsRecharge) Delete(c *gin.Context) { | ||||||
|  |     s := service.VtsRecharge{} | ||||||
|  |     req := dto.VtsRechargeDeleteReq{} | ||||||
|  |     err := e.MakeContext(c). | ||||||
|  |         MakeOrm(). | ||||||
|  |         Bind(&req). | ||||||
|  |         MakeService(&s.Service). | ||||||
|  |         Errors | ||||||
|  |     if err != nil { | ||||||
|  |         e.Logger.Error(err) | ||||||
|  |         e.Error(500, err, err.Error()) | ||||||
|  |         return | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	// req.SetUpdateBy(user.GetUserId(c)) | ||||||
|  | 	p := actions.GetPermissionFromContext(c) | ||||||
|  |  | ||||||
|  | 	err = s.Remove(&req, p) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("删除coinGate充值记录表失败,\r\n失败信息 %s", err.Error())) | ||||||
|  |         return | ||||||
|  | 	} | ||||||
|  | 	e.OK( req.GetId(), "删除成功") | ||||||
|  | } | ||||||
							
								
								
									
										581
									
								
								app/admin/fronted/line_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										581
									
								
								app/admin/fronted/line_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,581 @@ | |||||||
|  | package fronted | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"errors" | ||||||
|  | 	"fmt" | ||||||
|  | 	"go-admin/app/admin/models" | ||||||
|  | 	"go-admin/app/admin/models/sysmodel" | ||||||
|  | 	"go-admin/app/admin/service" | ||||||
|  | 	"go-admin/app/admin/service/aduserdb" | ||||||
|  | 	"go-admin/app/admin/service/common" | ||||||
|  | 	"go-admin/app/admin/service/dto" | ||||||
|  | 	"go-admin/common/const/rediskey" | ||||||
|  | 	"go-admin/common/helper" | ||||||
|  | 	"go-admin/common/service/sysservice/authservice" | ||||||
|  | 	"go-admin/common/service/sysservice/sysstatuscode" | ||||||
|  | 	statuscode "go-admin/common/status_code" | ||||||
|  | 	ext "go-admin/config" | ||||||
|  | 	"go-admin/models/coingatedto" | ||||||
|  | 	"go-admin/pkg/cryptohelper/inttostring" | ||||||
|  | 	"go-admin/pkg/utility" | ||||||
|  | 	"go-admin/services/binanceservice" | ||||||
|  | 	"go-admin/services/udunservice" | ||||||
|  |  | ||||||
|  | 	"github.com/bytedance/sonic" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/api" | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | 	"gorm.io/gorm" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUserApi struct { | ||||||
|  | 	api.Api | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Register 用户注册 | ||||||
|  | func (e LineUserApi) Register(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := sysmodel.FrontedUserRegisterReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	//校验参数 | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 注册前校验 | ||||||
|  | 	pid, code := authservice.UserRegisterBefore(e.Orm, req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.Pid = pid | ||||||
|  | 	req.IP = utility.GetIp(c) | ||||||
|  | 	ok, user := authservice.UserRegister(e.Orm, req) | ||||||
|  | 	if ok != statuscode.OK { | ||||||
|  | 		e.Error(ok, nil, sysstatuscode.GetStatusCodeDescription(c, ok)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	resp := map[string]interface{}{ | ||||||
|  | 		"email":      req.Email, | ||||||
|  | 		"mobile":     req.Phone, | ||||||
|  | 		"status":     "verify", | ||||||
|  | 		"login_type": 2, | ||||||
|  | 		"jwt_token":  "", | ||||||
|  | 		"jwt_expire": "", | ||||||
|  | 	} | ||||||
|  | 	if req.RegisterType == sysmodel.TSmsCode { | ||||||
|  | 		if req.Pid > 0 { | ||||||
|  | 			updateSql := `UPDATE line_user SET recommend_num = recommend_num + 1 WHERE id = ?` | ||||||
|  | 			if err := e.Orm.Exec(updateSql, req.Pid).Error; err != nil { | ||||||
|  | 				e.Logger.Error(err) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		token, expire, _ := authservice.GenerateToken(user.Id, 1, user.Mobile, user.Mobile, user.Email, req.IP, "PC") | ||||||
|  | 		resp["jwt_token"] = token | ||||||
|  | 		resp["jwt_expire"] = expire | ||||||
|  | 		resp["status"] = "normal" | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(resp, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // VerifyEmail 验证邮箱 | ||||||
|  | func (e LineUserApi) VerifyEmail(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.FrontedUserVerifyEmailReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if req.VerifyCode == "" || req.Email == "" { | ||||||
|  | 		e.Error(statuscode.ParameterInvalid, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.ParameterInvalid)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 核验邮箱验证码 | ||||||
|  | 	code := authservice.UserVerifyEmail(req.Email, req.VerifyCode, e.Orm) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	ok := s.UserVerifyEmail(req.Email) | ||||||
|  | 	if ok != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SendVerifyEmail 发送注册校验邮箱 | ||||||
|  | func (e LineUserApi) SendVerifyEmail(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.FrontedSendVerifyEmailReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	emailCode := inttostring.GenerateRandomString(10) | ||||||
|  | 	code = authservice.SendRegisterEmail(req.Email, emailCode) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SendRegisterSms 发送注册短信 | ||||||
|  | func (e LineUserApi) SendRegisterSms(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.FrontedSendVerifySmsReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	user, _ := aduserdb.GetUserByPhone(e.Orm, req.PhoneAreaCode, req.Phone) | ||||||
|  | 	if user.Id > 0 { | ||||||
|  | 		e.Error(statuscode.TheAccountIsAlreadyRegistered, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.TheAccountIsAlreadyRegistered)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	code = authservice.SendGoToneSms(req.Phone, req.PhoneAreaCode) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Login 登录 | ||||||
|  | func (e LineUserApi) Login(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.FrontedLoginReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// 登录前校验 | ||||||
|  | 	user, code, langArg := authservice.UserPwdLoginBefore(e.Orm, req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDiscreptionArgs(c, code, langArg)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	token, expire, code := authservice.GenerateToken(user.Id, 1, user.Email, user.Mobile, user.Email, utility.GetIp(c), "PC") | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 		// return app.Fail(ctx, code) | ||||||
|  | 	} | ||||||
|  | 	resp := map[string]interface{}{ | ||||||
|  | 		"email":      req.Email, | ||||||
|  | 		"mobile":     "", | ||||||
|  | 		"status":     user.Status, | ||||||
|  | 		"login_type": 2, | ||||||
|  | 		"jwt_token":  token, | ||||||
|  | 		"jwt_expire": expire, | ||||||
|  | 	} | ||||||
|  | 	e.OK(resp, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LineUserApi) UserInfo(c *gin.Context) { | ||||||
|  | 	userId := common.GetUserId(c) | ||||||
|  | 	var user models.LineUser | ||||||
|  | 	err := e.Orm.Model(&models.LineUser{}).Where("id = ?", userId).Find(&user).Error | ||||||
|  | 	if err != nil && !errors.Is(err, gorm.ErrNotImplemented) { | ||||||
|  | 		e.Error(statuscode.UserIdInvalid, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.UserIdInvalid)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if user.Status == "verify" { | ||||||
|  | 		e.Error(statuscode.UserNotVerify, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.UserNotVerify)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // AddApiKey 用户手动添加apikey | ||||||
|  | func (e LineUserApi) AddApiKey(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.AddApiKeyReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	code = s.AddApiKey(common.GetUserId(c), &req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UpdateApiKey 修改apikey | ||||||
|  | func (e LineUserApi) UpdateApiKey(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.AddApiKeyReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	code := req.CheckParams() | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	code = s.UpdateApiKey(common.GetUserId(c), &req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetWhiteIp 用户手动获取ip | ||||||
|  | func (e LineUserApi) GetWhiteIp(c *gin.Context) { | ||||||
|  | 	//s := service.LineUser{} | ||||||
|  | 	configS := service.SysConfig{} | ||||||
|  | 	//req := dto.AddApiKeyReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&configS.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req := dto.SysConfigByKeyReq{ConfigKey: "sys_user_white_ip"} | ||||||
|  | 	var resp dto.GetSysConfigByKEYForServiceResp | ||||||
|  | 	err = configS.GetWithKey(&req, &resp) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(resp.ConfigValue, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Info 用户中心 | ||||||
|  | func (e LineUserApi) Info(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	userId := common.GetUserId(c) | ||||||
|  | 	binanceAccount := service.BinanceAccount{Service: s.Service} | ||||||
|  |  | ||||||
|  | 	//获取用户资金账户资产 | ||||||
|  | 	resp, err := binanceAccount.GetFundingAsset(userId) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	//用户u的余额 | ||||||
|  | 	var tickerData []binanceservice.Ticker | ||||||
|  | 	val := helper.DefaultRedis.Get(rediskey.SpotSymbolTicker).Val() | ||||||
|  | 	if val != "" { | ||||||
|  | 		sonic.Unmarshal([]byte(val), &tickerData) | ||||||
|  | 	} | ||||||
|  | 	var usdtBalance decimal.Decimal | ||||||
|  | 	for i, asset := range resp { | ||||||
|  | 		symbol := asset.Asset + "USDT" | ||||||
|  | 		for _, datum := range tickerData { | ||||||
|  | 			if datum.Symbol == symbol { | ||||||
|  | 				mul := utility.StringToDecimal(datum.Price).Mul(utility.StringToDecimal(asset.Free)) | ||||||
|  | 				usdtBalance = usdtBalance.Add(mul) | ||||||
|  | 				resp[i].UsdtValuation = datum.Price | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		//if asset.Asset == "USDT" { | ||||||
|  | 		//	usdt = asset.Free | ||||||
|  | 		//} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 邀请人数 | ||||||
|  | 	//var inviteNum int64 | ||||||
|  | 	var userinfo models.LineUser | ||||||
|  | 	e.Orm.Model(&models.LineUser{}).Where("id = ?", userId).Find(&userinfo) | ||||||
|  |  | ||||||
|  | 	var apiUserinfo models.LineApiUser | ||||||
|  | 	e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Find(&apiUserinfo) | ||||||
|  | 	var isAuth bool | ||||||
|  | 	if apiUserinfo.ApiKey != "" && apiUserinfo.ApiSecret != "" { | ||||||
|  | 		isAuth = true | ||||||
|  | 	} | ||||||
|  | 	//持仓分布 | ||||||
|  | 	var fundingAsset []models.FundingAsset | ||||||
|  | 	if len(resp) > 10 { | ||||||
|  | 		fundingAsset = resp[0:10] | ||||||
|  | 	} else { | ||||||
|  | 		fundingAsset = resp[0:] | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	//获取盈利情况 | ||||||
|  | 	logs := service.LineUserProfitLogs{Service: s.Service} | ||||||
|  | 	totalProfit, todayProfit := logs.GetProfitInfoByUserId(userinfo.Id) | ||||||
|  | 	user := map[string]interface{}{ | ||||||
|  | 		"avatar":      userinfo.Avatar, | ||||||
|  | 		"invite_num":  userinfo.RecommendNum, | ||||||
|  | 		"open_status": apiUserinfo.OpenStatus, | ||||||
|  | 		"is_auth":     isAuth, | ||||||
|  | 		"invite_url":  fmt.Sprintf("%s/invice_url?invite_code=%s", ext.ExtConfig.Domain, userinfo.InviteCode), | ||||||
|  | 		"invite_code": userinfo.InviteCode, | ||||||
|  | 		"api_name":    apiUserinfo.ApiName, | ||||||
|  | 		"api_key":     inttostring.EncryptString(apiUserinfo.ApiKey, 4, 4), | ||||||
|  | 		"api_secret":  inttostring.EncryptString(apiUserinfo.ApiSecret, 4, 4), | ||||||
|  | 	} | ||||||
|  | 	returnMap := map[string]interface{}{ | ||||||
|  | 		"u_balance":     usdtBalance.Truncate(2), | ||||||
|  | 		"margin":        userinfo.Money, | ||||||
|  | 		"userinfo":      user, | ||||||
|  | 		"funding_asset": fundingAsset, | ||||||
|  | 		"total_profit":  totalProfit.Float64, | ||||||
|  | 		"today_profit":  todayProfit.Float64, | ||||||
|  | 	} | ||||||
|  | 	e.OK(returnMap, "success") | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // OpenStatus 开启或者关闭 | ||||||
|  | func (e LineUserApi) OpenStatus(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.OpenStatusReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	userId := common.GetUserId(c) | ||||||
|  | 	var apiUser models.LineApiUser | ||||||
|  | 	err = e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Find(&apiUser).Error | ||||||
|  |  | ||||||
|  | 	if apiUser.ApiSecret == "" || apiUser.ApiKey == "" { | ||||||
|  | 		e.Error(statuscode.UserApiKeyRequired, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.UserApiKeyRequired)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = e.Orm.Model(&models.LineApiUser{}).Where("user_id = ?", userId).Update("open_status", req.Status).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(nil, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // RechargeNetworkList 充值 通过充值币种选择主网络 | ||||||
|  | func (e LineUserApi) RechargeNetworkList(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.RechargeListReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	data, code := s.RechargeNetworkList(&req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(data, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // RechargeNetworkAddress 充值 通过主网ID和用户ID获取交易地址 | ||||||
|  | func (e LineUserApi) RechargeNetworkAddress(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.RechargeAddressListReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	req.UserId = common.GetUserId(c) | ||||||
|  | 	data, code := s.RechargeNetworkAddress(&req) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(data, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Notify uDun回调 | ||||||
|  | func (e LineUserApi) Notify(c *gin.Context) { | ||||||
|  | 	timestamp := c.PostForm("timestamp") | ||||||
|  | 	nonce := c.PostForm("nonce") | ||||||
|  | 	body := c.PostForm("body") | ||||||
|  | 	sign := c.PostForm("sign") | ||||||
|  | 	callback := udunservice.TradeCallback(e.Orm, timestamp, nonce, body, sign) | ||||||
|  | 	c.String(200, callback) | ||||||
|  | 	//c.Writer.WriteString(callback) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // FundingTrend 资金走势 | ||||||
|  | func (e LineUserApi) FundingTrend(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.RechargeAddressListReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	userId := common.GetUserId(c) | ||||||
|  | 	data, code := s.FundingTrend(userId) | ||||||
|  | 	if code != statuscode.OK { | ||||||
|  | 		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	e.OK(data, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // PreOrder 预下单 | ||||||
|  | func (e LineUserApi) PreOrder(c *gin.Context) { | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	req := dto.VtsRechargePreOrderReq{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	userId := common.GetUserId(c) | ||||||
|  | 	resp := dto.VtsRechargePreOrderResp{} | ||||||
|  | 	err = s.PreOrder(userId, &req, &resp) | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("发起充值失败,\r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(resp, "success") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e LineUserApi) CallBack(c *gin.Context) { | ||||||
|  | 	req := coingatedto.OrderCallBackResponse{} | ||||||
|  | 	s := service.LineUser{} | ||||||
|  | 	err := e.MakeContext(c). | ||||||
|  | 		MakeOrm(). | ||||||
|  | 		Bind(&req). | ||||||
|  | 		MakeService(&s.Service). | ||||||
|  | 		Errors | ||||||
|  | 	if err != nil { | ||||||
|  | 		e.Logger.Error(err) | ||||||
|  | 		e.Error(500, err, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	err = s.CallBack(&req) | ||||||
|  |  | ||||||
|  | 	if err != nil { | ||||||
|  | 		val, _ := sonic.Marshal(req) | ||||||
|  | 		e.Logger.Error("回调失败:", err.Error(), " \r\n回调内容:", string(val)) | ||||||
|  | 		e.Error(500, err, fmt.Sprintf("支付回调失败, \r\n失败信息 %s", err.Error())) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	e.OK(nil, "") | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								app/admin/models/binance_account.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/admin/models/binance_account.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | type FundingAsset struct { | ||||||
|  | 	Asset         string `json:"asset"` | ||||||
|  | 	Free          string `json:"free"` | ||||||
|  | 	Locked        string `json:"locked"` | ||||||
|  | 	Freeze        string `json:"freeze"` | ||||||
|  | 	Withdrawing   string `json:"withdrawing"` | ||||||
|  | 	BtcValuation  string `json:"btcValuation"` | ||||||
|  | 	UsdtValuation string `json:"usdt_valuation"` | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								app/admin/models/casbin_rule.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/admin/models/casbin_rule.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | type CasbinRule struct { | ||||||
|  | 	ID    uint   `gorm:"primaryKey;autoIncrement"` | ||||||
|  | 	Ptype string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V0    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V1    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V2    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V3    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V4    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | 	V5    string `gorm:"size:512;uniqueIndex:unique_index"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (CasbinRule) TableName() string { | ||||||
|  | 	return "sys_casbin_rule" | ||||||
|  | } | ||||||
							
								
								
									
										81
									
								
								app/admin/models/datascope.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								app/admin/models/datascope.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,81 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"errors" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/pkg" | ||||||
|  | 	"gorm.io/gorm" | ||||||
|  |  | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/config" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type DataPermission struct { | ||||||
|  | 	DataScope string | ||||||
|  | 	UserId    int | ||||||
|  | 	DeptId    int | ||||||
|  | 	RoleId    int | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *DataPermission) GetDataScope(tableName string, db *gorm.DB) (*gorm.DB, error) { | ||||||
|  |  | ||||||
|  | 	if !config.ApplicationConfig.EnableDP { | ||||||
|  | 		usageStr := `数据权限已经为您` + pkg.Green(`关闭`) + `,如需开启请参考配置文件字段说明` | ||||||
|  | 		log.Debug("%s\n", usageStr) | ||||||
|  | 		return db, nil | ||||||
|  | 	} | ||||||
|  | 	user := new(SysUser) | ||||||
|  | 	role := new(SysRole) | ||||||
|  | 	err := db.Find(user, e.UserId).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, errors.New("获取用户数据出错 msg:" + err.Error()) | ||||||
|  | 	} | ||||||
|  | 	err = db.Find(role, user.RoleId).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, errors.New("获取用户数据出错 msg:" + err.Error()) | ||||||
|  | 	} | ||||||
|  | 	if role.DataScope == "2" { | ||||||
|  | 		db = db.Where(tableName+".create_by in (select sys_user.user_id from sys_role_dept left join sys_user on sys_user.dept_id=sys_role_dept.dept_id where sys_role_dept.role_id = ?)", user.RoleId) | ||||||
|  | 	} | ||||||
|  | 	if role.DataScope == "3" { | ||||||
|  | 		db = db.Where(tableName+".create_by in (SELECT user_id from sys_user where dept_id = ? )", user.DeptId) | ||||||
|  | 	} | ||||||
|  | 	if role.DataScope == "4" { | ||||||
|  | 		db = db.Where(tableName+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+pkg.IntToString(user.DeptId)+"%") | ||||||
|  | 	} | ||||||
|  | 	if role.DataScope == "5" || role.DataScope == "" { | ||||||
|  | 		db = db.Where(tableName+".create_by = ?", e.UserId) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return db, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | //func DataScopes(tableName string, userId int) func(db *gorm.DB) *gorm.DB { | ||||||
|  | //	return func(db *gorm.DB) *gorm.DB { | ||||||
|  | //		user := new(SysUser) | ||||||
|  | //		role := new(SysRole) | ||||||
|  | //		user.UserId = userId | ||||||
|  | //		err := db.Find(user, userId).Error | ||||||
|  | //		if err != nil { | ||||||
|  | //			db.Error = errors.New("获取用户数据出错 msg:" + err.Error()) | ||||||
|  | //			return db | ||||||
|  | //		} | ||||||
|  | //		err = db.Find(role, user.RoleId).Error | ||||||
|  | //		if err != nil { | ||||||
|  | //			db.Error = errors.New("获取用户数据出错 msg:" + err.Error()) | ||||||
|  | //			return db | ||||||
|  | //		} | ||||||
|  | //		if role.DataScope == "2" { | ||||||
|  | //			return db.Where(tableName+".create_by in (select sys_user.user_id from sys_role_dept left join sys_user on sys_user.dept_id=sys_role_dept.dept_id where sys_role_dept.role_id = ?)", user.RoleId) | ||||||
|  | //		} | ||||||
|  | //		if role.DataScope == "3" { | ||||||
|  | //			return db.Where(tableName+".create_by in (SELECT user_id from sys_user where dept_id = ? )", user.DeptId) | ||||||
|  | //		} | ||||||
|  | //		if role.DataScope == "4" { | ||||||
|  | //			return db.Where(tableName+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+pkg.IntToString(user.DeptId)+"%") | ||||||
|  | //		} | ||||||
|  | //		if role.DataScope == "5" || role.DataScope == "" { | ||||||
|  | //			return db.Where(tableName+".create_by = ?", userId) | ||||||
|  | //		} | ||||||
|  | //		return db | ||||||
|  | //	} | ||||||
|  | //} | ||||||
							
								
								
									
										55
									
								
								app/admin/models/initdb.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								app/admin/models/initdb.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,55 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"go-admin/common/global" | ||||||
|  | 	"gorm.io/gorm" | ||||||
|  | 	"io/ioutil" | ||||||
|  | 	"log" | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func InitDb(db *gorm.DB) (err error) { | ||||||
|  | 	filePath := "config/db.sql" | ||||||
|  | 	err = ExecSql(db, filePath) | ||||||
|  | 	if global.Driver == "postgres" { | ||||||
|  | 		filePath = "config/pg.sql" | ||||||
|  | 		err = ExecSql(db, filePath) | ||||||
|  | 	} | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func ExecSql(db *gorm.DB, filePath string) error { | ||||||
|  | 	sql, err := Ioutil(filePath) | ||||||
|  | 	if err != nil { | ||||||
|  | 		fmt.Println("数据库基础数据初始化脚本读取失败!原因:", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	sqlList := strings.Split(sql, ";") | ||||||
|  | 	for i := 0; i < len(sqlList)-1; i++ { | ||||||
|  | 		if strings.Contains(sqlList[i], "--") { | ||||||
|  | 			fmt.Println(sqlList[i]) | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 		sql := strings.Replace(sqlList[i]+";", "\n", "", -1) | ||||||
|  | 		sql = strings.TrimSpace(sql) | ||||||
|  | 		if err = db.Exec(sql).Error; err != nil { | ||||||
|  | 			log.Printf("error sql: %s", sql) | ||||||
|  | 			if !strings.Contains(err.Error(), "Query was empty") { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func Ioutil(filePath string) (string, error) { | ||||||
|  | 	if contents, err := ioutil.ReadFile(filePath); err == nil { | ||||||
|  | 		//因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符 | ||||||
|  | 		result := strings.Replace(string(contents), "\n", "", 1) | ||||||
|  | 		fmt.Println("Use ioutil.ReadFile to read a file:", result) | ||||||
|  | 		return result, nil | ||||||
|  | 	} else { | ||||||
|  | 		return "", err | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										29
									
								
								app/admin/models/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								app/admin/models/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineAccountSetting struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     UserName string `json:"userName" gorm:"type:varchar(255);comment:用户"`  | ||||||
|  |     Password string `json:"password" gorm:"type:varchar(255);comment:密码"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineAccountSetting) TableName() string { | ||||||
|  |     return "line_account_setting" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineAccountSetting) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineAccountSetting) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										29
									
								
								app/admin/models/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								app/admin/models/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineApiGroup struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	GroupName string `json:"groupName" gorm:"type:varchar(255);comment:用户组名称"` | ||||||
|  | 	ApiUserId string `json:"apiUserId" gorm:"type:varchar(255);comment:绑定的api账户id"` | ||||||
|  | 	AApiName  string `json:"a_api_name" gorm:"-"` | ||||||
|  | 	BApiName  string `json:"b_api_name" gorm:"-"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineApiGroup) TableName() string { | ||||||
|  | 	return "line_api_group" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineApiGroup) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineApiGroup) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								app/admin/models/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								app/admin/models/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineApiUser struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	UserId      int64  `json:"userId" gorm:"type:int unsigned;comment:用户id"` | ||||||
|  | 	JysId       int64  `json:"jysId" gorm:"type:int;comment:关联交易所账号id"` | ||||||
|  | 	ApiName     string `json:"apiName" gorm:"type:varchar(255);comment:api用户名"` | ||||||
|  | 	ApiKey      string `json:"apiKey" gorm:"type:varchar(255);comment:apiKey"` | ||||||
|  | 	ApiSecret   string `json:"apiSecret" gorm:"type:varchar(255);comment:apiSecret"` | ||||||
|  | 	IpAddress   string `json:"ipAddress" gorm:"type:varchar(255);comment:代理地址"` | ||||||
|  | 	UserPass    string `json:"userPass" gorm:"type:varchar(255);comment:代码账号密码"` | ||||||
|  | 	AdminId     int64  `json:"adminId" gorm:"type:int unsigned;comment:管理员id"` | ||||||
|  | 	Affiliation int64  `json:"affiliation" gorm:"type:int;comment:归属:1=现货,2=合约,3=现货合约"` | ||||||
|  | 	AdminShow   int64  `json:"adminShow" gorm:"type:int;comment:是否超管可见:1=是,0=否"` | ||||||
|  | 	Site        string `json:"site" gorm:"type:enum('1','2','3');comment:允许下单的方向:1=多;2=空;3=多空"` | ||||||
|  | 	Subordinate string `json:"subordinate" gorm:"type:enum('0','1','2');comment:从属关系:0=未绑定关系;1=主账号;2=副帐号"` | ||||||
|  | 	GroupId     int64  `json:"groupId" gorm:"type:int unsigned;comment:所属组id"` | ||||||
|  | 	OpenStatus  int64  `json:"openStatus" gorm:"type:int unsigned;comment:开启状态 0=关闭 1=开启"` | ||||||
|  |  | ||||||
|  | 	SpotLastTime    string `json:"spotLastTime" gorm:"-"`    //现货websocket最后通信时间 | ||||||
|  | 	FuturesLastTime string `json:"futuresLastTime" gorm:"-"` //合约websocket最后通信时间 | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineApiUser) TableName() string { | ||||||
|  | 	return "line_api_user" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineApiUser) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineApiUser) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								app/admin/models/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								app/admin/models/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineCoinnetwork struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	NetworkName string `json:"networkName" gorm:"type:varchar(255);comment:网络名称"` | ||||||
|  | 	TokenName   string `json:"tokenName" gorm:"type:varchar(255);comment:网络token名称"` | ||||||
|  | 	ArrivalNum  int64  `json:"arrivalNum" gorm:"type:int;comment:充值区块确认数"` | ||||||
|  | 	UnlockNum   int64  `json:"unlockNum" gorm:"type:int;comment:提现解锁确认数"` | ||||||
|  | 	UnlockTime  int64  `json:"unlockTime" gorm:"type:int;comment:提现确认平均时间,单位分钟"` | ||||||
|  | 	Fee         string `json:"fee" gorm:"type:decimal(32,6);comment:网络手续费,该字段是动态的,后面会有服务定时更新该字段"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineCoinnetwork) TableName() string { | ||||||
|  | 	return "line_coinnetwork" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineCoinnetwork) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineCoinnetwork) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type VtsCoinNetWorkDB struct { | ||||||
|  | 	Id          int     `json:"id"` | ||||||
|  | 	NetworkName string  `json:"network_name"` | ||||||
|  | 	TokenName   string  `json:"token_name"` | ||||||
|  | 	ArrivalNum  int     `json:"arrival_num"` | ||||||
|  | 	UnlockNum   int     `json:"unlock_num"` | ||||||
|  | 	UnlockTime  int     `json:"unlock_time"` | ||||||
|  | 	Fee         float64 `json:"fee"` | ||||||
|  | } | ||||||
							
								
								
									
										79
									
								
								app/admin/models/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								app/admin/models/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,79 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineCointonetwork struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	CoinId                   int64     `json:"coinId" gorm:"type:int unsigned;comment:币种id"` | ||||||
|  | 	NetworkId                int64     `json:"networkId" gorm:"type:int unsigned;comment:公链网络id"` | ||||||
|  | 	IsMain                   int64     `json:"isMain" gorm:"type:int unsigned;comment:是否主网--1否,3是.比如BTC在BTC网络中就属于主网"` | ||||||
|  | 	IsDeposit                int64     `json:"isDeposit" gorm:"type:int;comment:是否开启充值:1==否,3==是"` | ||||||
|  | 	IsWithdraw               int64     `json:"isWithdraw" gorm:"type:int unsigned;comment:是否开启提现:1==否,3==是"` | ||||||
|  | 	CoinCode                 string    `json:"coinCode" gorm:"type:varchar(255);comment:币种代号"` | ||||||
|  | 	Token                    string    `json:"token" gorm:"type:varchar(255);comment:代币token"` | ||||||
|  | 	MinChargeNum             string    `json:"minChargeNum" gorm:"type:decimal(32,8);comment:最小充值数量"` | ||||||
|  | 	MinOutNum                string    `json:"minOutNum" gorm:"type:decimal(32,8);comment:单笔最小提币数量"` | ||||||
|  | 	MaxOutNum                string    `json:"maxOutNum" gorm:"type:decimal(32,8);comment:单笔最大提币数量"` | ||||||
|  | 	TransferFee              string    `json:"transferFee" gorm:"type:decimal(32,8);comment:提币手续费"` | ||||||
|  | 	DetailCode               string    `json:"detailCode" gorm:"type:varchar(255);comment:币种全称"` | ||||||
|  | 	NetworkName              string    `json:"networkName" gorm:"type:varchar(255);comment:公链网络简称"` | ||||||
|  | 	TokenName                string    `json:"tokenName" gorm:"type:varchar(255);comment:公链网络全称"` | ||||||
|  | 	ChargeType               int64     `json:"chargeType" gorm:"type:int;comment:手续费类型 1==固定 3==百分比"` | ||||||
|  | 	RechargeSwitchTime       time.Time `json:"rechargeSwitchTime" gorm:"type:timestamp(6);comment:充值开关时间"` | ||||||
|  | 	WithdrawSwitchTime       time.Time `json:"withdrawSwitchTime" gorm:"type:timestamp(6);comment:提币开关时间"` | ||||||
|  | 	IsoutsideWithdrawVerify  int64     `json:"isoutsideWithdrawVerify" gorm:"type:int;comment:是否开启外部提币免审1==否3==是"` | ||||||
|  | 	OutsideWithdrawVerifyNum string    `json:"outsideWithdrawVerifyNum" gorm:"type:decimal(32,8);comment:外部提币免审阈值"` | ||||||
|  | 	IsinsideTransferVerify   int64     `json:"isinsideTransferVerify" gorm:"type:int;comment:是否开启内部转账免审1==否3==是"` | ||||||
|  | 	InsidetransferVerifyNum  string    `json:"insidetransferVerifyNum" gorm:"type:decimal(32,8);comment:内部转账免审阈值"` | ||||||
|  | 	EverydaymaxWithdrawNum   string    `json:"everydaymaxWithdrawNum" gorm:"type:decimal(32,8);comment:每日最大累计提币数量"` | ||||||
|  | 	EverydaymaxVerifyNum     string    `json:"everydaymaxVerifyNum" gorm:"type:decimal(32,8);comment:每日最大免审累计数量"` | ||||||
|  | 	Isinsidetransferfee      int64     `json:"isinsidetransferfee" gorm:"type:int;comment:是否开启内部转账免手续费1==否3==是"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineCointonetwork) TableName() string { | ||||||
|  | 	return "line_cointonetwork" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineCointonetwork) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineCointonetwork) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type VtsCoinToNetWorkDB struct { | ||||||
|  | 	CoinId      int     `json:"coin_id"` | ||||||
|  | 	CoinCode    string  `json:"coin_code"` | ||||||
|  | 	DetailCode  string  `json:"detail_code"` | ||||||
|  | 	NetworkId   int     `json:"network_id"` | ||||||
|  | 	NetWorkName string  `json:"network_name"` | ||||||
|  | 	TokenName   string  `json:"token_name"` | ||||||
|  | 	TransferFee float64 `json:"transfer_fee"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type VtsCoinToNetWorkResp struct { | ||||||
|  | 	CoinId          int    `json:"coin_id"` | ||||||
|  | 	CoinCode        string `json:"coin_code"` | ||||||
|  | 	DetailCode      string `json:"detail_code"` | ||||||
|  | 	NetWorkId       int    `json:"network_id"` | ||||||
|  | 	NetWorkName     string `json:"network_name"` | ||||||
|  | 	TokenName       string `json:"token_name"` | ||||||
|  | 	TransferFee     string `json:"transfer_fee"` | ||||||
|  | 	TransferFeeUsdt string `json:"transfer_fee_usdt"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type RechargeAddressListResp struct { | ||||||
|  | 	Address    string `json:"address"`     //地址 | ||||||
|  | 	MinNum     string `json:"min_num"`     //最小充值数量 | ||||||
|  | 	ArrivalNum int    `json:"arrival_num"` //充值区块确认数 | ||||||
|  | 	UnlockNum  int    `json:"unlock_num"`  //提现解锁确认数 | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								app/admin/models/line_direction.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/admin/models/line_direction.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineDirection struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     Symbol string `json:"symbol" gorm:"type:varchar(255);comment:交易对"`  | ||||||
|  |     Type int64 `json:"type" gorm:"type:int unsigned;comment:交易对类型:1=现货,2=合约"`  | ||||||
|  |     BuyPoint1 string `json:"buyPoint1" gorm:"type:varchar(255);comment:买入点一"`  | ||||||
|  |     BuyPoint2 string `json:"buyPoint2" gorm:"type:varchar(255);comment:买入点二"`  | ||||||
|  |     BuyPoint3 string `json:"buyPoint3" gorm:"type:varchar(255);comment:买入点三"`  | ||||||
|  |     SellPoint1 string `json:"sellPoint1" gorm:"type:varchar(255);comment:卖出点一"`  | ||||||
|  |     SellPoint2 string `json:"sellPoint2" gorm:"type:varchar(255);comment:卖出点二"`  | ||||||
|  |     SellPoint3 string `json:"sellPoint3" gorm:"type:varchar(255);comment:卖出点三"`  | ||||||
|  |     Direction string `json:"direction" gorm:"type:varchar(255);comment:预估方向"`  | ||||||
|  |     AiAnswer string `json:"aiAnswer" gorm:"type:text;comment:AI智能分析"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineDirection) TableName() string { | ||||||
|  |     return "line_direction" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineDirection) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineDirection) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										32
									
								
								app/admin/models/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/admin/models/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineOrderTemplateLogs struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     Name string `json:"name" gorm:"type:varchar(255);comment:模板名称"`  | ||||||
|  |     UserId int64 `json:"userId" gorm:"type:int;comment:用户id"`  | ||||||
|  |     Params string `json:"params" gorm:"type:text;comment:参数"`  | ||||||
|  |     Type int64 `json:"type" gorm:"type:int unsigned;comment:模板类型:1=单独添加;2=批量添加"`  | ||||||
|  |     Switch string `json:"switch" gorm:"type:enum('0','1');comment:开关:0=关,1=开"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineOrderTemplateLogs) TableName() string { | ||||||
|  |     return "line_order_template_logs" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineOrderTemplateLogs) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineOrderTemplateLogs) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										60
									
								
								app/admin/models/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								app/admin/models/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,60 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreOrder struct { | ||||||
|  | 	models.Model | ||||||
|  | 	ExchangeType   string          `json:"exchangeType" gorm:"type:varchar(20);comment:交易所类型 (字典 exchange_type)"` | ||||||
|  | 	Pid            int             `json:"pid" gorm:"type:int unsigned;omitempty;comment:pid"` | ||||||
|  | 	ApiId          int             `json:"apiId" gorm:"type:varchar(255);omitempty;comment:api用户"` | ||||||
|  | 	GroupId        string          `json:"groupId" gorm:"type:int unsigned;omitempty;comment:交易对组id"` | ||||||
|  | 	Symbol         string          `json:"symbol" gorm:"type:varchar(255);omitempty;comment:交易对"` | ||||||
|  | 	QuoteSymbol    string          `json:"quoteSymbol" gorm:"type:varchar(255);omitempty;comment:计较货币"` | ||||||
|  | 	SignPrice      string          `json:"signPrice" gorm:"type:decimal(18,8);omitempty;comment:对标价"` | ||||||
|  | 	SignPriceU     decimal.Decimal `json:"signPriceU" gorm:"type:decimal(18,8);omitempty;comment:交易对对标U的行情价"` | ||||||
|  | 	SignPriceType  string          `json:"signPriceType" gorm:"type:enum('new','tall','low','mixture','entrust','add');omitempty;comment:对标价类型: new=最新价格;tall=24小时最高;low=24小时最低;mixture=标记价;entrust=委托实价;add=补仓"` | ||||||
|  | 	Rate           string          `json:"rate" gorm:"type:decimal(18,2);omitempty;comment:下单百分比"` | ||||||
|  | 	Price          string          `json:"price" gorm:"type:decimal(18,8);omitempty;comment:触发价格"` | ||||||
|  | 	Num            string          `json:"num" gorm:"type:decimal(18,8);omitempty;comment:购买数量"` | ||||||
|  | 	BuyPrice       string          `json:"buyPrice" gorm:"type:decimal(18,8);omitempty;comment:购买金额"` | ||||||
|  | 	SymbolType     int             `json:"symbolType" gorm:"type:int;comment:交易对类型:1=现货;2=合约"` | ||||||
|  | 	Site           string          `json:"site" gorm:"type:enum('BUY','SELL');omitempty;comment:购买方向:BUY=买;SELL=卖"` | ||||||
|  | 	OrderSn        string          `json:"orderSn" gorm:"type:varchar(255);omitempty;comment:订单号"` | ||||||
|  | 	OrderType      int             `json:"orderType" gorm:"type:int;omitempty;comment:订单类型:0=主单 1=止盈 2=止损 3=平仓"` | ||||||
|  | 	Desc           string          `json:"desc" gorm:"type:text;omitempty;comment:订单描述"` | ||||||
|  | 	Status         int             `json:"status" gorm:"type:int;omitempty;comment:是否被触发:0=待触发;1=已触发;2=下单失败;4=已取消;5=委托中;6=已成交;9=已平仓"` | ||||||
|  | 	AdminId        string          `json:"adminId" gorm:"type:int unsigned;omitempty;comment:操作管理员id"` | ||||||
|  | 	CloseType      int             `json:"closeType" gorm:"type:int unsigned;omitempty;comment:平仓类型 是否为盈利平仓 1= 是 0 =否"` | ||||||
|  | 	CoverType      int             `json:"coverType" gorm:"type:int unsigned;omitempty;comment:对冲类型 1= 现货对合约 2=合约对合约 3 合约对现货"` | ||||||
|  | 	ExpireTime     time.Time       `json:"expireTime" gorm:"comment:过期时间"` | ||||||
|  | 	MainOrderType  string          `json:"mainOrderType" gorm:"type:enum;comment:第一笔(主单类型) 限价(LIMIT)市价(MARKET)"` | ||||||
|  | 	HedgeOrderType string          `json:"hedgeOrderType" gorm:"type:enum;comment:第二笔类型 限价(LIMIT)市价(MARKET)"` | ||||||
|  | 	Child          []LinePreOrder  `json:"child" gorm:"-"` | ||||||
|  | 	ApiName        string          `json:"api_name" gorm:"->"` | ||||||
|  | 	ChildNum       int64           `json:"child_num" gorm:"->"` | ||||||
|  | 	// LinePreOrder 线上预埋单\ | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LinePreOrder) TableName() string { | ||||||
|  | 	return "line_pre_order" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreOrder) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreOrder) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type PositionSymbol struct { | ||||||
|  | 	Symbol string | ||||||
|  | } | ||||||
							
								
								
									
										29
									
								
								app/admin/models/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								app/admin/models/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreOrderStatus struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	OrderId           int    `json:"orderId" gorm:"type:bigint;comment:主订单id"` | ||||||
|  | 	OrderSn           string `json:"orderSn" gorm:"type:varchar(255);comment:主订单号"` | ||||||
|  | 	AddPositionStatus int    `json:"addPositionStatus" gorm:"type:int;comment:加仓状态 0-无 1-已加仓"` | ||||||
|  | 	HedgeStatus       int    `json:"hedgeStatus" gorm:"type:int;comment:对冲状态 0-无 1-已对冲"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LinePreOrderStatus) TableName() string { | ||||||
|  | 	return "line_pre_order_status" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreOrderStatus) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreOrderStatus) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										33
									
								
								app/admin/models/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/admin/models/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePreScript struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     ApiId int64 `json:"apiId" gorm:"type:int unsigned;comment:api用户"`  | ||||||
|  |     ScriptNum int64 `json:"scriptNum" gorm:"type:int unsigned;comment:脚本批次"`  | ||||||
|  |     ScriptParams string `json:"scriptParams" gorm:"type:text;comment:脚本参数"`  | ||||||
|  |     Status string `json:"status" gorm:"type:enum('0','1','2');comment:执行状态:0=等待执行,1=执行中,2=执行结束"`  | ||||||
|  |     Desc string `json:"desc" gorm:"type:longtext;comment:运行备注"`  | ||||||
|  |     AdminId int64 `json:"adminId" gorm:"type:int unsigned;comment:管理员id"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LinePreScript) TableName() string { | ||||||
|  |     return "line_pre_script" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreScript) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePreScript) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										30
									
								
								app/admin/models/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/admin/models/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LinePriceLimit struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	Symbol          string          `json:"symbol" gorm:"type:varchar(255);comment:交易对"` | ||||||
|  | 	Type            string          `json:"type" gorm:"type:enum('1','2');comment:类型:1=现货,2=合约"` | ||||||
|  | 	DirectionStatus string          `json:"directionStatus" gorm:"type:enum('1','2');comment:方向:1=涨,2=跌"` | ||||||
|  | 	Range           decimal.Decimal `json:"range" gorm:"type:decimal(10,5);comment:幅度"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LinePriceLimit) TableName() string { | ||||||
|  | 	return "line_price_limit" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePriceLimit) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LinePriceLimit) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										45
									
								
								app/admin/models/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								app/admin/models/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |     "time" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineRecharge struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     CoinId int64 `json:"coinId" gorm:"type:int;comment:币种id"`  | ||||||
|  |     UserId int64 `json:"userId" gorm:"type:int;comment:用户Id"`  | ||||||
|  |     Confirms string `json:"confirms" gorm:"type:int;comment:区块确认数"`  | ||||||
|  |     TranType string `json:"tranType" gorm:"type:int;comment:类型:1线上,2内部"`  | ||||||
|  |     BlockIndex string `json:"blockIndex" gorm:"type:int;comment:区块高度"`  | ||||||
|  |     Amount string `json:"amount" gorm:"type:decimal(32,8);comment:数量"`  | ||||||
|  |     Account string `json:"account" gorm:"type:varchar(255);comment:账户"`  | ||||||
|  |     Address string `json:"address" gorm:"type:varchar(255);comment:地址"`  | ||||||
|  |     Txid string `json:"txid" gorm:"type:varchar(255);comment:交易id"`  | ||||||
|  |     BlockTime time.Time `json:"blockTime" gorm:"type:timestamp;comment:同步时间"`  | ||||||
|  |     TimeReceived time.Time `json:"timeReceived" gorm:"type:timestamp;comment:确认时间"`  | ||||||
|  |     MainCoin string `json:"mainCoin" gorm:"type:varchar(255);comment:充值网络"`  | ||||||
|  |     OrderNo string `json:"orderNo" gorm:"type:varchar(50);comment:订单号"`  | ||||||
|  |     Status string `json:"status" gorm:"type:int;comment:状态1==进行中暂时保留,2==成功,3==失败"`  | ||||||
|  |     State string `json:"state" gorm:"type:int;comment:来源状态 0 待審核 1 審核成功 2 審核駁回 3交易成功 4交易失敗"`  | ||||||
|  |     Fee string `json:"fee" gorm:"type:decimal(32,8);comment:手续费"`  | ||||||
|  |     AddressFrom string `json:"addressFrom" gorm:"type:varchar(255);comment:来源地址"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineRecharge) TableName() string { | ||||||
|  |     return "line_recharge" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineRecharge) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineRecharge) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										32
									
								
								app/admin/models/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/admin/models/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbol struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	ApiId      string `json:"apiId" gorm:"type:int;comment:api账户id"` | ||||||
|  | 	Symbol     string `json:"symbol" gorm:"type:varchar(32);comment:交易对"` | ||||||
|  | 	BaseAsset  string `json:"baseAsset" gorm:"type:varchar(255);comment:基础货币"` | ||||||
|  | 	QuoteAsset string `json:"quoteAsset" gorm:"type:varchar(255);comment:计价货币"` | ||||||
|  | 	Switch     string `json:"switch" gorm:"type:enum('0','1');comment:状态"` | ||||||
|  | 	Type       string `json:"type" gorm:"type:enum('1','2');comment:交易对类型"` | ||||||
|  | 	Number     int    `json:"number" gorm:"->"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineSymbol) TableName() string { | ||||||
|  | 	return "line_symbol" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbol) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbol) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										29
									
								
								app/admin/models/line_symbol_black.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								app/admin/models/line_symbol_black.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbolBlack struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     Symbol string `json:"symbol" gorm:"type:varchar(255);comment:交易对"`  | ||||||
|  |     Type string `json:"type" gorm:"type:enum('1','2');comment:类型:1=现货,2=合约"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineSymbolBlack) TableName() string { | ||||||
|  |     return "line_symbol_black" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbolBlack) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbolBlack) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										30
									
								
								app/admin/models/line_symbol_group.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/admin/models/line_symbol_group.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSymbolGroup struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	GroupName string `json:"groupName" gorm:"type:varchar(255);comment:交易对组名称"` | ||||||
|  | 	Symbol    string `json:"symbol" gorm:"type:text;comment:交易对"` | ||||||
|  | 	GroupType string `json:"groupType" gorm:"type:enum('1','2');comment:分组类型:1=普通类型"` | ||||||
|  | 	Type      string `json:"type" gorm:"type:enum('1','2');comment:类型:1=现货,2=合约"` | ||||||
|  | 	Count     int    `json:"count" gorm:"->"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineSymbolGroup) TableName() string { | ||||||
|  | 	return "line_symbol_group" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbolGroup) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSymbolGroup) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								app/admin/models/line_system_setting.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								app/admin/models/line_system_setting.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineSystemSetting struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	Time                      int64           `json:"time" gorm:"type:int;comment:导入:挂单时长达到时间后失效"` | ||||||
|  | 	BatchTime                 int64           `json:"batchTime" gorm:"type:int;comment:批量:挂单时长达到时间后失效"` | ||||||
|  | 	ProfitRate                string          `json:"profitRate" gorm:"type:decimal(10,2);comment:平仓盈利比例"` | ||||||
|  | 	CoverOrderTypeBRate       string          `json:"coverOrderTypeBRate" gorm:"type:decimal(10,2);comment:b账户限价补单的买入百分比"` | ||||||
|  | 	ScaleOrderTypeARate       string          `json:"scaleOrderTypeARate" gorm:"type:decimal(10,2);comment:a账户限价加仓买入百分比"` | ||||||
|  | 	ScaleOrderTypeBRate       string          `json:"scaleOrderTypeBRate" gorm:"type:decimal(10,2);comment:b账户限价加仓买入百分比"` | ||||||
|  | 	ScaleUnrealizedProfitRate string          `json:"scaleUnrealizedProfitRate" gorm:"type:decimal(10,5) unsigned;comment:亏损百分比加仓"` | ||||||
|  | 	ScaleType                 int             `json:"scaleType" gorm:"type:int;comment:加仓类型 1-百分比 2-数值"` | ||||||
|  | 	ScaleNum                  string          `json:"scaleNum" gorm:"type:decimal(18,2) unsigned;comment:加仓数值"` | ||||||
|  | 	ScaleSubordinate          int64           `json:"scaleSubordinate" gorm:"type:int unsigned;comment:加仓账户:1=A账户;2=副账户;3=都加"` | ||||||
|  | 	AutoScaleTimes            int64           `json:"autoScaleTimes" gorm:"type:int unsigned;comment:自动加仓次数"` | ||||||
|  | 	HedgePerformance          decimal.Decimal `json:"hedgePerformance" gorm:"type:decimal(5,2);comment:对冲平仓涨跌幅"` | ||||||
|  | 	ProtectHedgeRate          decimal.Decimal `json:"protectHedgeRate" gorm:"type:decimal(5,2);comment:保护对冲触发百分比"` | ||||||
|  | 	ProtectHedgeEnable        int             `json:"protectHedgeEnable" gorm:"type:int;comment:是否只开启保护对冲 1-开启 0-关闭"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineSystemSetting) TableName() string { | ||||||
|  | 	return "line_system_setting" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSystemSetting) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineSystemSetting) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										36
									
								
								app/admin/models/line_uduncoin.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								app/admin/models/line_uduncoin.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  |  | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUduncoin struct { | ||||||
|  |     models.Model | ||||||
|  |      | ||||||
|  |     TokenStatus int64 `json:"tokenStatus" gorm:"type:int;comment:0: 主幣 1:代幣"`  | ||||||
|  |     Decimals int64 `json:"decimals" gorm:"type:int;comment:幣種精度,8"`  | ||||||
|  |     MainCoinType string `json:"mainCoinType" gorm:"type:varchar(255);comment:主幣種類型"`  | ||||||
|  |     CoinType string `json:"coinType" gorm:"type:varchar(255);comment:幣種類型"`  | ||||||
|  |     Symbol string `json:"symbol" gorm:"type:varchar(255);comment:幣種symbol"`  | ||||||
|  |     Name string `json:"name" gorm:"type:varchar(255);comment:幣種別名,BTC"`  | ||||||
|  |     Logo string `json:"logo" gorm:"type:varchar(255);comment:幣種logo地址"`  | ||||||
|  |     CoinName string `json:"coinName" gorm:"type:varchar(255);comment:幣種全稱,Bitcoin"`  | ||||||
|  |     MainSymbol string `json:"mainSymbol" gorm:"type:varchar(255);comment:主幣種symbol"`  | ||||||
|  |     models.ModelTime | ||||||
|  |     models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineUduncoin) TableName() string { | ||||||
|  |     return "line_uduncoin" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUduncoin) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUduncoin) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										56
									
								
								app/admin/models/line_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								app/admin/models/line_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUser struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	GroupId        int             `json:"groupId" gorm:"type:int unsigned;comment:组别ID"` | ||||||
|  | 	Pid            int             `json:"pid" gorm:"type:int unsigned;comment:推荐人ID"` | ||||||
|  | 	Username       string          `json:"username" gorm:"type:varchar(32);comment:用户名"` | ||||||
|  | 	Nickname       string          `json:"nickname" gorm:"type:varchar(50);comment:昵称"` | ||||||
|  | 	Password       string          `json:"password" gorm:"type:varchar(32);comment:密码"` | ||||||
|  | 	Salt           string          `json:"salt" gorm:"type:varchar(30);comment:密码盐"` | ||||||
|  | 	Email          string          `json:"email" gorm:"type:varchar(100);comment:电子邮箱"` | ||||||
|  | 	Mobile         string          `json:"mobile" gorm:"type:varchar(11);comment:手机号"` | ||||||
|  | 	Area           string          `json:"area" gorm:"type:varchar(255);comment:手机号归属地"` | ||||||
|  | 	Avatar         string          `json:"avatar" gorm:"type:varchar(255);comment:头像"` | ||||||
|  | 	Level          int             `json:"level" gorm:"type:tinyint unsigned;comment:等级"` | ||||||
|  | 	Gender         int             `json:"gender" gorm:"type:tinyint unsigned;comment:性别"` | ||||||
|  | 	Bio            string          `json:"bio" gorm:"type:varchar(100);comment:格言"` | ||||||
|  | 	Money          decimal.Decimal `json:"money" gorm:"type:decimal(10,2) unsigned;comment:保证金"` | ||||||
|  | 	Score          int             `json:"score" gorm:"type:int unsigned;comment:积分"` | ||||||
|  | 	InviteCode     string          `json:"invite_code" gorm:"type:varchar(255);comment:邀请码"` | ||||||
|  | 	Successions    int             `json:"successions" gorm:"type:int unsigned;comment:连续登录天数"` | ||||||
|  | 	MaxSuccessions int             `json:"maxSuccessions" gorm:"type:int unsigned;comment:最大连续登录天数"` | ||||||
|  | 	Loginip        string          `json:"loginip" gorm:"type:varchar(50);comment:登录IP"` | ||||||
|  | 	Loginfailure   int             `json:"loginfailure" gorm:"type:tinyint unsigned;comment:失败次数"` | ||||||
|  | 	Joinip         string          `json:"joinip" gorm:"type:varchar(50);comment:加入IP"` | ||||||
|  | 	Jointime       int             `json:"jointime" gorm:"type:int;comment:加入时间"` | ||||||
|  | 	RecommendNum   int             `json:"recommend_num" gorm:"type:int;comment:推荐人数"` | ||||||
|  | 	Token          string          `json:"token" gorm:"type:varchar(50);comment:Token"` | ||||||
|  | 	Status         string          `json:"status" gorm:"type:varchar(30);comment:状态"` | ||||||
|  | 	Verification   string          `json:"verification" gorm:"type:varchar(255);comment:验证"` | ||||||
|  | 	LoginTime      time.Time       `json:"loginTime" gorm:"type:timestamp;comment:登录时间"` | ||||||
|  | 	OpenStatus     int             `json:"open_status" gorm:"-"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineUser) TableName() string { | ||||||
|  | 	return "line_user" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUser) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUser) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										33
									
								
								app/admin/models/line_user_funding_trend.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/admin/models/line_user_funding_trend.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUserFundingTrend struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	UserId  int64  `json:"userId" gorm:"type:int unsigned;comment:用户id"` | ||||||
|  | 	Funding string `json:"funding" gorm:"type:decimal(32,8) unsigned;comment:资金账户总额 换算U"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineUserFundingTrend) TableName() string { | ||||||
|  | 	return "line_user_funding_trend" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUserFundingTrend) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUserFundingTrend) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type LineUserFundingTrendResp struct { | ||||||
|  | 	UserId    int64  `json:"user_id" gorm:"type:int unsigned;comment:用户id"` | ||||||
|  | 	Funding   string `json:"funding" gorm:"type:decimal(32,8) unsigned;comment:资金账户总额"` | ||||||
|  | 	CreatedAt string `json:"created_at"` | ||||||
|  | } | ||||||
							
								
								
									
										32
									
								
								app/admin/models/line_user_profit_logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/admin/models/line_user_profit_logs.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineUserProfitLogs struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	UserId     int64  `json:"userId" gorm:"type:int unsigned;comment:line_user 表的id"` | ||||||
|  | 	ApiId      int64  `json:"apiId" gorm:"type:int unsigned;comment:line_apiuser 表的id"` | ||||||
|  | 	PreOrderId int64  `json:"preOrderId" gorm:"type:int unsigned;comment:line_pre_order 止盈单id"` | ||||||
|  | 	Num        string `json:"num" gorm:"type:decimal(18,8);comment:成交数量"` | ||||||
|  | 	Symbol     string `json:"symbol" gorm:"type:varchar(255);comment:交易对"` | ||||||
|  | 	Rate       string `json:"rate" gorm:"type:decimal(10,5);comment:盈利比例"` | ||||||
|  | 	Amount     string `json:"amount" gorm:"type:decimal(18,5);comment:盈利金额(换算成U的价值)"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineUserProfitLogs) TableName() string { | ||||||
|  | 	return "line_user_profit_logs" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUserProfitLogs) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineUserProfitLogs) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										31
									
								
								app/admin/models/line_wallet.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								app/admin/models/line_wallet.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type LineWallet struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	UserId        int64  `json:"userId" gorm:"type:int;comment:用户Id"` | ||||||
|  | 	CoinId        int64  `json:"coinId" gorm:"type:int;comment:币种id"` | ||||||
|  | 	CoinCode      string `json:"coinCode" gorm:"type:varchar(255);comment:标签"` | ||||||
|  | 	Tag           string `json:"tag" gorm:"type:varchar(255);comment:标签"` | ||||||
|  | 	Address       string `json:"address" gorm:"type:varchar(255);comment:地址"` | ||||||
|  | 	CoinNetworkId int    `json:"coinNetworkId" gorm:"type:int;comment:币种主网id,useri+主网id做唯一"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (LineWallet) TableName() string { | ||||||
|  | 	return "line_wallet" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineWallet) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *LineWallet) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										91
									
								
								app/admin/models/sys_api.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								app/admin/models/sys_api.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,91 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"bytes" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"fmt" | ||||||
|  | 	"io/ioutil" | ||||||
|  | 	"regexp" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
|  | 	"github.com/bitly/go-simplejson" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk/runtime" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/storage" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysApi struct { | ||||||
|  | 	Id     int    `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"` | ||||||
|  | 	Handle string `json:"handle" gorm:"size:128;comment:handle"` | ||||||
|  | 	Title  string `json:"title" gorm:"size:128;comment:标题"` | ||||||
|  | 	Path   string `json:"path" gorm:"size:128;comment:地址"` | ||||||
|  | 	Action string `json:"action" gorm:"size:16;comment:请求类型"` | ||||||
|  | 	Type   string `json:"type" gorm:"size:16;comment:接口类型"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysApi) TableName() string { | ||||||
|  | 	return "sys_api" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysApi) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysApi) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func SaveSysApi(message storage.Messager) (err error) { | ||||||
|  | 	var rb []byte | ||||||
|  | 	rb, err = json.Marshal(message.GetValues()) | ||||||
|  | 	if err != nil { | ||||||
|  | 		err = fmt.Errorf("json Marshal error, %v", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var l runtime.Routers | ||||||
|  | 	err = json.Unmarshal(rb, &l) | ||||||
|  | 	if err != nil { | ||||||
|  | 		err = fmt.Errorf("json Unmarshal error, %s", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	dbList := sdk.Runtime.GetDb() | ||||||
|  | 	for _, d := range dbList { | ||||||
|  | 		for _, v := range l.List { | ||||||
|  | 			if v.HttpMethod != "HEAD" || | ||||||
|  | 				strings.Contains(v.RelativePath, "/swagger/") || | ||||||
|  | 				strings.Contains(v.RelativePath, "/static/") || | ||||||
|  | 				strings.Contains(v.RelativePath, "/form-generator/") || | ||||||
|  | 				strings.Contains(v.RelativePath, "/sys/tables") { | ||||||
|  |  | ||||||
|  | 				// 根据接口方法注释里的@Summary填充接口名称,适用于代码生成器 | ||||||
|  | 				// 可在此处增加配置路径前缀的if判断,只对代码生成的自建应用进行定向的接口名称填充 | ||||||
|  | 				jsonFile, _ := ioutil.ReadFile("docs/swagger.json") | ||||||
|  | 				jsonData, _ := simplejson.NewFromReader(bytes.NewReader(jsonFile)) | ||||||
|  | 				urlPath := v.RelativePath | ||||||
|  | 				idPatten := "(.*)/:(\\w+)" // 正则替换,把:id换成{id} | ||||||
|  | 				reg, _ := regexp.Compile(idPatten) | ||||||
|  | 				if reg.MatchString(urlPath) { | ||||||
|  | 					urlPath = reg.ReplaceAllString(v.RelativePath, "${1}/{${2}}") // 把:id换成{id} | ||||||
|  | 				} | ||||||
|  | 				apiTitle, _ := jsonData.Get("paths").Get(urlPath).Get(strings.ToLower(v.HttpMethod)).Get("summary").String() | ||||||
|  |  | ||||||
|  | 				err := d.Debug().Where(SysApi{Path: v.RelativePath, Action: v.HttpMethod}). | ||||||
|  | 					Attrs(SysApi{Handle: v.Handler, Title: apiTitle}). | ||||||
|  | 					FirstOrCreate(&SysApi{}). | ||||||
|  | 					//Update("handle", v.Handler). | ||||||
|  | 					Error | ||||||
|  | 				if err != nil { | ||||||
|  | 					err := fmt.Errorf("Models SaveSysApi error: %s \r\n ", err.Error()) | ||||||
|  | 					return err | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
							
								
								
									
										30
									
								
								app/admin/models/sys_config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/admin/models/sys_config.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysConfig struct { | ||||||
|  | 	models.Model | ||||||
|  | 	ConfigName  string `json:"configName" gorm:"size:128;comment:ConfigName"`   // | ||||||
|  | 	ConfigKey   string `json:"configKey" gorm:"size:128;comment:ConfigKey"`     // | ||||||
|  | 	ConfigValue string `json:"configValue" gorm:"size:255;comment:ConfigValue"` // | ||||||
|  | 	ConfigType  string `json:"configType" gorm:"size:64;comment:ConfigType"` | ||||||
|  | 	IsFrontend  string `json:"isFrontend" gorm:"size:64;comment:是否前台"` // | ||||||
|  | 	Remark      string `json:"remark" gorm:"size:128;comment:Remark"`  // | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysConfig) TableName() string { | ||||||
|  | 	return "sys_config" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysConfig) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysConfig) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										33
									
								
								app/admin/models/sys_dept.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/admin/models/sys_dept.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import "go-admin/common/models" | ||||||
|  |  | ||||||
|  | type SysDept struct { | ||||||
|  | 	DeptId   int    `json:"deptId" gorm:"primaryKey;autoIncrement;"` //部门编码 | ||||||
|  | 	ParentId int    `json:"parentId" gorm:""`                        //上级部门 | ||||||
|  | 	DeptPath string `json:"deptPath" gorm:"size:255;"`               // | ||||||
|  | 	DeptName string `json:"deptName"  gorm:"size:128;"`              //部门名称 | ||||||
|  | 	Sort     int    `json:"sort" gorm:"size:4;"`                     //排序 | ||||||
|  | 	Leader   string `json:"leader" gorm:"size:128;"`                 //负责人 | ||||||
|  | 	Phone    string `json:"phone" gorm:"size:11;"`                   //手机 | ||||||
|  | 	Email    string `json:"email" gorm:"size:64;"`                   //邮箱 | ||||||
|  | 	Status   int    `json:"status" gorm:"size:4;"`                   //状态 | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | 	DataScope string    `json:"dataScope" gorm:"-"` | ||||||
|  | 	Params    string    `json:"params" gorm:"-"` | ||||||
|  | 	Children  []SysDept `json:"children" gorm:"-"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysDept) TableName() string { | ||||||
|  | 	return "sys_dept" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDept) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDept) GetId() interface{} { | ||||||
|  | 	return e.DeptId | ||||||
|  | } | ||||||
							
								
								
									
										34
									
								
								app/admin/models/sys_dict_data.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								app/admin/models/sys_dict_data.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysDictData struct { | ||||||
|  | 	DictCode  int    `json:"dictCode" gorm:"primaryKey;column:dict_code;autoIncrement;comment:主键编码"` | ||||||
|  | 	DictSort  int    `json:"dictSort" gorm:"size:20;comment:DictSort"` | ||||||
|  | 	DictLabel string `json:"dictLabel" gorm:"size:128;comment:DictLabel"` | ||||||
|  | 	DictValue string `json:"dictValue" gorm:"size:255;comment:DictValue"` | ||||||
|  | 	DictType  string `json:"dictType" gorm:"size:64;comment:DictType"` | ||||||
|  | 	CssClass  string `json:"cssClass" gorm:"size:128;comment:CssClass"` | ||||||
|  | 	ListClass string `json:"listClass" gorm:"size:128;comment:ListClass"` | ||||||
|  | 	IsDefault string `json:"isDefault" gorm:"size:8;comment:IsDefault"` | ||||||
|  | 	Status    int    `json:"status" gorm:"size:4;comment:Status"` | ||||||
|  | 	Default   string `json:"default" gorm:"size:8;comment:Default"` | ||||||
|  | 	Remark    string `json:"remark" gorm:"size:255;comment:Remark"` | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysDictData) TableName() string { | ||||||
|  | 	return "sys_dict_data" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDictData) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDictData) GetId() interface{} { | ||||||
|  | 	return e.DictCode | ||||||
|  | } | ||||||
							
								
								
									
										28
									
								
								app/admin/models/sys_dict_type.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								app/admin/models/sys_dict_type.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysDictType struct { | ||||||
|  | 	ID       int    `json:"id" gorm:"primaryKey;column:dict_id;autoIncrement;comment:主键编码"` | ||||||
|  | 	DictName string `json:"dictName" gorm:"size:128;comment:DictName"` | ||||||
|  | 	DictType string `json:"dictType" gorm:"size:128;comment:DictType"` | ||||||
|  | 	Status   int    `json:"status" gorm:"size:4;comment:Status"` | ||||||
|  | 	Remark   string `json:"remark" gorm:"size:255;comment:Remark"` | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysDictType) TableName() string { | ||||||
|  | 	return "sys_dict_type" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDictType) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysDictType) GetId() interface{} { | ||||||
|  | 	return e.ID | ||||||
|  | } | ||||||
							
								
								
									
										72
									
								
								app/admin/models/sys_login_log.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								app/admin/models/sys_login_log.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"errors" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/storage" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysLoginLog struct { | ||||||
|  | 	models.Model | ||||||
|  | 	Username      string    `json:"username" gorm:"size:128;comment:用户名"` | ||||||
|  | 	Status        string    `json:"status" gorm:"size:4;comment:状态"` | ||||||
|  | 	Ipaddr        string    `json:"ipaddr" gorm:"size:255;comment:ip地址"` | ||||||
|  | 	LoginLocation string    `json:"loginLocation" gorm:"size:255;comment:归属地"` | ||||||
|  | 	Browser       string    `json:"browser" gorm:"size:255;comment:浏览器"` | ||||||
|  | 	Os            string    `json:"os" gorm:"size:255;comment:系统"` | ||||||
|  | 	Platform      string    `json:"platform" gorm:"size:255;comment:固件"` | ||||||
|  | 	LoginTime     time.Time `json:"loginTime" gorm:"comment:登录时间"` | ||||||
|  | 	Remark        string    `json:"remark" gorm:"size:255;comment:备注"` | ||||||
|  | 	Msg           string    `json:"msg" gorm:"size:255;comment:信息"` | ||||||
|  | 	CreatedAt     time.Time `json:"createdAt" gorm:"comment:创建时间"` | ||||||
|  | 	UpdatedAt     time.Time `json:"updatedAt" gorm:"comment:最后更新时间"` | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysLoginLog) TableName() string { | ||||||
|  | 	return "sys_login_log" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysLoginLog) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysLoginLog) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SaveLoginLog 从队列中获取登录日志 | ||||||
|  | func SaveLoginLog(message storage.Messager) (err error) { | ||||||
|  | 	//准备db | ||||||
|  | 	db := sdk.Runtime.GetDbByKey(message.GetPrefix()) | ||||||
|  | 	if db == nil { | ||||||
|  | 		err = errors.New("db not exist") | ||||||
|  | 		log.Errorf("host[%s]'s %s", message.GetPrefix(), err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	var rb []byte | ||||||
|  | 	rb, err = json.Marshal(message.GetValues()) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("json Marshal error, %s", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	var l SysLoginLog | ||||||
|  | 	err = json.Unmarshal(rb, &l) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("json Unmarshal error, %s", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	err = db.Create(&l).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("db create error, %s", err.Error()) | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
							
								
								
									
										50
									
								
								app/admin/models/sys_menu.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								app/admin/models/sys_menu.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import "go-admin/common/models" | ||||||
|  |  | ||||||
|  | type SysMenu struct { | ||||||
|  | 	MenuId     int       `json:"menuId" gorm:"primaryKey;autoIncrement"` | ||||||
|  | 	MenuName   string    `json:"menuName" gorm:"size:128;"` | ||||||
|  | 	Title      string    `json:"title" gorm:"size:128;"` | ||||||
|  | 	Icon       string    `json:"icon" gorm:"size:128;"` | ||||||
|  | 	Path       string    `json:"path" gorm:"size:128;"` | ||||||
|  | 	Paths      string    `json:"paths" gorm:"size:128;"` | ||||||
|  | 	MenuType   string    `json:"menuType" gorm:"size:1;"` | ||||||
|  | 	Action     string    `json:"action" gorm:"size:16;"` | ||||||
|  | 	Permission string    `json:"permission" gorm:"size:255;"` | ||||||
|  | 	ParentId   int       `json:"parentId" gorm:"size:11;"` | ||||||
|  | 	NoCache    bool      `json:"noCache" gorm:"size:8;"` | ||||||
|  | 	Breadcrumb string    `json:"breadcrumb" gorm:"size:255;"` | ||||||
|  | 	Component  string    `json:"component" gorm:"size:255;"` | ||||||
|  | 	Sort       int       `json:"sort" gorm:"size:4;"` | ||||||
|  | 	Visible    string    `json:"visible" gorm:"size:1;"` | ||||||
|  | 	IsFrame    string    `json:"isFrame" gorm:"size:1;DEFAULT:0;"` | ||||||
|  | 	SysApi     []SysApi  `json:"sysApi" gorm:"many2many:sys_menu_api_rule"` | ||||||
|  | 	Apis       []int     `json:"apis" gorm:"-"` | ||||||
|  | 	DataScope  string    `json:"dataScope" gorm:"-"` | ||||||
|  | 	Params     string    `json:"params" gorm:"-"` | ||||||
|  | 	RoleId     int       `gorm:"-"` | ||||||
|  | 	Children   []SysMenu `json:"children,omitempty" gorm:"-"` | ||||||
|  | 	IsSelect   bool      `json:"is_select" gorm:"-"` | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type SysMenuSlice []SysMenu | ||||||
|  |  | ||||||
|  | func (x SysMenuSlice) Len() int           { return len(x) } | ||||||
|  | func (x SysMenuSlice) Less(i, j int) bool { return x[i].Sort < x[j].Sort } | ||||||
|  | func (x SysMenuSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] } | ||||||
|  |  | ||||||
|  | func (*SysMenu) TableName() string { | ||||||
|  | 	return "sys_menu" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysMenu) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysMenu) GetId() interface{} { | ||||||
|  | 	return e.MenuId | ||||||
|  | } | ||||||
							
								
								
									
										88
									
								
								app/admin/models/sys_opera_log.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								app/admin/models/sys_opera_log.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,88 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"errors" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/storage" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysOperaLog struct { | ||||||
|  | 	models.Model | ||||||
|  | 	Title         string    `json:"title" gorm:"size:255;comment:操作模块"` | ||||||
|  | 	BusinessType  string    `json:"businessType" gorm:"size:128;comment:操作类型"` | ||||||
|  | 	BusinessTypes string    `json:"businessTypes" gorm:"size:128;comment:BusinessTypes"` | ||||||
|  | 	Method        string    `json:"method" gorm:"size:128;comment:函数"` | ||||||
|  | 	RequestMethod string    `json:"requestMethod" gorm:"size:128;comment:请求方式 GET POST PUT DELETE"` | ||||||
|  | 	OperatorType  string    `json:"operatorType" gorm:"size:128;comment:操作类型"` | ||||||
|  | 	OperName      string    `json:"operName" gorm:"size:128;comment:操作者"` | ||||||
|  | 	DeptName      string    `json:"deptName" gorm:"size:128;comment:部门名称"` | ||||||
|  | 	OperUrl       string    `json:"operUrl" gorm:"size:255;comment:访问地址"` | ||||||
|  | 	OperIp        string    `json:"operIp" gorm:"size:128;comment:客户端ip"` | ||||||
|  | 	OperLocation  string    `json:"operLocation" gorm:"size:128;comment:访问位置"` | ||||||
|  | 	OperParam     string    `json:"operParam" gorm:"text;comment:请求参数"` | ||||||
|  | 	Status        string    `json:"status" gorm:"size:4;comment:操作状态 1:正常 2:关闭"` | ||||||
|  | 	OperTime      time.Time `json:"operTime" gorm:"comment:操作时间"` | ||||||
|  | 	JsonResult    string    `json:"jsonResult" gorm:"size:255;comment:返回数据"` | ||||||
|  | 	Remark        string    `json:"remark" gorm:"size:255;comment:备注"` | ||||||
|  | 	LatencyTime   string    `json:"latencyTime" gorm:"size:128;comment:耗时"` | ||||||
|  | 	UserAgent     string    `json:"userAgent" gorm:"size:255;comment:ua"` | ||||||
|  | 	CreatedAt     time.Time `json:"createdAt" gorm:"comment:创建时间"` | ||||||
|  | 	UpdatedAt     time.Time `json:"updatedAt" gorm:"comment:最后更新时间"` | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysOperaLog) TableName() string { | ||||||
|  | 	return "sys_opera_log" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysOperaLog) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysOperaLog) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // SaveOperaLog 从队列中获取操作日志 | ||||||
|  | func SaveOperaLog(message storage.Messager) (err error) { | ||||||
|  | 	//准备db | ||||||
|  | 	db := sdk.Runtime.GetDbByKey(message.GetPrefix()) | ||||||
|  | 	if db == nil { | ||||||
|  | 		err = errors.New("db not exist") | ||||||
|  | 		log.Errorf("host[%s]'s %s", message.GetPrefix(), err.Error()) | ||||||
|  | 		// Log writing to the database ignores error | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	var rb []byte | ||||||
|  | 	rb, err = json.Marshal(message.GetValues()) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("json Marshal error, %s", err.Error()) | ||||||
|  | 		// Log writing to the database ignores error | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	var l SysOperaLog | ||||||
|  | 	err = json.Unmarshal(rb, &l) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("json Unmarshal error, %s", err.Error()) | ||||||
|  | 		// Log writing to the database ignores error | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	// 超出100个字符返回值截断 | ||||||
|  | 	if len(l.JsonResult) > 100 { | ||||||
|  | 		l.JsonResult = l.JsonResult[:100] | ||||||
|  | 	} | ||||||
|  | 	err = db.Create(&l).Error | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Errorf("db create error, %s", err.Error()) | ||||||
|  | 		// Log writing to the database ignores error | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
							
								
								
									
										30
									
								
								app/admin/models/sys_post.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/admin/models/sys_post.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import "go-admin/common/models" | ||||||
|  |  | ||||||
|  | type SysPost struct { | ||||||
|  | 	PostId   int    `gorm:"primaryKey;autoIncrement" json:"postId"` //岗位编号 | ||||||
|  | 	PostName string `gorm:"size:128;" json:"postName"`              //岗位名称 | ||||||
|  | 	PostCode string `gorm:"size:128;" json:"postCode"`              //岗位代码 | ||||||
|  | 	Sort     int    `gorm:"size:4;" json:"sort"`                    //岗位排序 | ||||||
|  | 	Status   int    `gorm:"size:4;" json:"status"`                  //状态 | ||||||
|  | 	Remark   string `gorm:"size:255;" json:"remark"`                //描述 | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  |  | ||||||
|  | 	DataScope string `gorm:"-" json:"dataScope"` | ||||||
|  | 	Params    string `gorm:"-" json:"params"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysPost) TableName() string { | ||||||
|  | 	return "sys_post" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysPost) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysPost) GetId() interface{} { | ||||||
|  | 	return e.PostId | ||||||
|  | } | ||||||
							
								
								
									
										35
									
								
								app/admin/models/sys_role.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								app/admin/models/sys_role.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import "go-admin/common/models" | ||||||
|  |  | ||||||
|  | type SysRole struct { | ||||||
|  | 	RoleId    int        `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码 | ||||||
|  | 	RoleName  string     `json:"roleName" gorm:"size:128;"`              // 角色名称 | ||||||
|  | 	Status    string     `json:"status" gorm:"size:4;"`                  // 状态 1禁用 2正常 | ||||||
|  | 	RoleKey   string     `json:"roleKey" gorm:"size:128;"`               //角色代码 | ||||||
|  | 	RoleSort  int        `json:"roleSort" gorm:""`                       //角色排序 | ||||||
|  | 	Flag      string     `json:"flag" gorm:"size:128;"`                  // | ||||||
|  | 	Remark    string     `json:"remark" gorm:"size:255;"`                //备注 | ||||||
|  | 	Admin     bool       `json:"admin" gorm:"size:4;"` | ||||||
|  | 	DataScope string     `json:"dataScope" gorm:"size:128;"` | ||||||
|  | 	Params    string     `json:"params" gorm:"-"` | ||||||
|  | 	MenuIds   []int      `json:"menuIds" gorm:"-"` | ||||||
|  | 	DeptIds   []int      `json:"deptIds" gorm:"-"` | ||||||
|  | 	SysDept   []SysDept  `json:"sysDept" gorm:"many2many:sys_role_dept;foreignKey:RoleId;joinForeignKey:role_id;references:DeptId;joinReferences:dept_id;"` | ||||||
|  | 	SysMenu   *[]SysMenu `json:"sysMenu" gorm:"many2many:sys_role_menu;foreignKey:RoleId;joinForeignKey:role_id;references:MenuId;joinReferences:menu_id;"` | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysRole) TableName() string { | ||||||
|  | 	return "sys_role" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysRole) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysRole) GetId() interface{} { | ||||||
|  | 	return e.RoleId | ||||||
|  | } | ||||||
							
								
								
									
										77
									
								
								app/admin/models/sys_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								app/admin/models/sys_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,77 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | 	"golang.org/x/crypto/bcrypt" | ||||||
|  | 	"gorm.io/gorm" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SysUser struct { | ||||||
|  | 	UserId   int      `gorm:"primaryKey;autoIncrement;comment:编码"  json:"userId"` | ||||||
|  | 	Username string   `json:"username" gorm:"size:64;comment:用户名"` | ||||||
|  | 	Password string   `json:"-" gorm:"size:128;comment:密码"` | ||||||
|  | 	NickName string   `json:"nickName" gorm:"size:128;comment:昵称"` | ||||||
|  | 	Phone    string   `json:"phone" gorm:"size:11;comment:手机号"` | ||||||
|  | 	RoleId   int      `json:"roleId" gorm:"size:20;comment:角色ID"` | ||||||
|  | 	Salt     string   `json:"-" gorm:"size:255;comment:加盐"` | ||||||
|  | 	Avatar   string   `json:"avatar" gorm:"size:255;comment:头像"` | ||||||
|  | 	Sex      string   `json:"sex" gorm:"size:255;comment:性别"` | ||||||
|  | 	Email    string   `json:"email" gorm:"size:128;comment:邮箱"` | ||||||
|  | 	DeptId   int      `json:"deptId" gorm:"size:20;comment:部门"` | ||||||
|  | 	PostId   int      `json:"postId" gorm:"size:20;comment:岗位"` | ||||||
|  | 	Remark   string   `json:"remark" gorm:"size:255;comment:备注"` | ||||||
|  | 	Status   string   `json:"status" gorm:"size:4;comment:状态"` | ||||||
|  | 	DeptIds  []int    `json:"deptIds" gorm:"-"` | ||||||
|  | 	PostIds  []int    `json:"postIds" gorm:"-"` | ||||||
|  | 	RoleIds  []int    `json:"roleIds" gorm:"-"` | ||||||
|  | 	Dept     *SysDept `json:"dept"` | ||||||
|  | 	models.ControlBy | ||||||
|  | 	models.ModelTime | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (*SysUser) TableName() string { | ||||||
|  | 	return "sys_user" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysUser) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysUser) GetId() interface{} { | ||||||
|  | 	return e.UserId | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Encrypt 加密 | ||||||
|  | func (e *SysUser) Encrypt() (err error) { | ||||||
|  | 	if e.Password == "" { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var hash []byte | ||||||
|  | 	if hash, err = bcrypt.GenerateFromPassword([]byte(e.Password), bcrypt.DefaultCost); err != nil { | ||||||
|  | 		return | ||||||
|  | 	} else { | ||||||
|  | 		e.Password = string(hash) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysUser) BeforeCreate(_ *gorm.DB) error { | ||||||
|  | 	return e.Encrypt() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysUser) BeforeUpdate(_ *gorm.DB) error { | ||||||
|  | 	var err error | ||||||
|  | 	if e.Password != "" { | ||||||
|  | 		err = e.Encrypt() | ||||||
|  | 	} | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *SysUser) AfterFind(_ *gorm.DB) error { | ||||||
|  | 	e.DeptIds = []int{e.DeptId} | ||||||
|  | 	e.PostIds = []int{e.PostId} | ||||||
|  | 	e.RoleIds = []int{e.RoleId} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
							
								
								
									
										72
									
								
								app/admin/models/sysmodel/article.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								app/admin/models/sysmodel/article.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | |||||||
|  | package sysmodel | ||||||
|  |  | ||||||
|  | import "time" | ||||||
|  |  | ||||||
|  | // 文章中心 | ||||||
|  | type GetArticleListReq struct { | ||||||
|  | 	TypeID   int    `json:"category_id" query:"category_id"` // 类别 ID | ||||||
|  | 	Language string `json:"-"`                               // | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type ArticleCenterList struct { | ||||||
|  | 	Type      int    `json:"type"` // 类型:1 文章类别,2 文章 | ||||||
|  | 	ID        int    `json:"id"` | ||||||
|  | 	ParentID  int    `json:"parent_id"` | ||||||
|  | 	Icon      string `json:"icon"` | ||||||
|  | 	Title     string `json:"title"` | ||||||
|  | 	JumpRoute string `json:"jump_route"` // 自助服务的跳转路由 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type GetArticleCenterResp struct { | ||||||
|  | 	Type      int                    `json:"type"` // 类型:1 文章类别,2 文章 | ||||||
|  | 	ID        int                    `json:"id"` | ||||||
|  | 	Icon      string                 `json:"icon"` | ||||||
|  | 	Title     string                 `json:"title"` | ||||||
|  | 	JumpRoute string                 `json:"jump_route"` | ||||||
|  | 	Child     []GetArticleCenterResp `json:"child"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 文章类别 | ||||||
|  | type GetArticleCategoryResp struct { | ||||||
|  | 	ID       int                      `json:"id"` | ||||||
|  | 	ParentID int                      `json:"parent_id"` | ||||||
|  | 	Title    string                   `json:"title"` | ||||||
|  | 	Child    []GetArticleCategoryResp `json:"child"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 文章列表 | ||||||
|  | type GetArticleListResp struct { | ||||||
|  | 	ID         int    `json:"id"` | ||||||
|  | 	CategoryID int    `json:"category_id"` | ||||||
|  | 	Title      string `json:"title"` | ||||||
|  | 	Content    string `json:"content"` | ||||||
|  | 	CreateTime int64  `json:"create_time"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 文章详情 | ||||||
|  | type GetArticleDetailResp struct { | ||||||
|  | 	ID             int       `json:"id"` | ||||||
|  | 	Title          string    `json:"title"` | ||||||
|  | 	Content        string    `json:"content"` | ||||||
|  | 	CreateTime     time.Time `json:"-"` // | ||||||
|  | 	UpdateTime     time.Time `json:"-"` // | ||||||
|  | 	CreateTimeResp int64     `json:"create_time"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 文章搜索 | ||||||
|  | type GetArticleSearchList struct { | ||||||
|  | 	ID             int            `json:"id"` | ||||||
|  | 	TypeID         int            `json:"category_id"` | ||||||
|  | 	Path           string         `json:"path"` | ||||||
|  | 	Title          string         `json:"title"` | ||||||
|  | 	Content        string         `json:"content"` | ||||||
|  | 	CreateTime     time.Time      `json:"-"` | ||||||
|  | 	CreateTimeResp int64          `json:"create_time"` | ||||||
|  | 	AllParent      []CategoryList `json:"all_parent"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type CategoryList struct { | ||||||
|  | 	ID       int    `json:"id"` | ||||||
|  | 	ParentID int    `json:"parent_id"` | ||||||
|  | 	Title    string `json:"title"` | ||||||
|  | } | ||||||
							
								
								
									
										384
									
								
								app/admin/models/sysmodel/authentication.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										384
									
								
								app/admin/models/sysmodel/authentication.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,384 @@ | |||||||
|  | package sysmodel | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	statuscode "go-admin/common/status_code" | ||||||
|  | 	"go-admin/pkg/cryptohelper/md5helper" | ||||||
|  | 	"go-admin/pkg/emailhelper" | ||||||
|  |  | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  |  | ||||||
|  | 	"go-admin/pkg/utility" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type FrontedUserRegisterReq struct { | ||||||
|  | 	Account       string `json:"account"`         // 账号 | ||||||
|  | 	RegisterType  int    `json:"register_type"`   // 注册类型 1: 手机 2: 邮箱 | ||||||
|  | 	PhoneAreaCode string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone         string `json:"phone"`           // 手机号码 | ||||||
|  | 	Captcha       string `json:"captcha"`         // 验证码:携带验证码注册 | ||||||
|  | 	Email         string `json:"email"`           // 邮箱地址 | ||||||
|  | 	Password      string `json:"password"`        // 密码 | ||||||
|  | 	CheckPassword string `json:"check_password"`  // 确认密码 | ||||||
|  | 	InviteCode    string `json:"invite_code"`     // 邀请码 | ||||||
|  | 	IP            string `json:"-"`               // IP | ||||||
|  | 	Pid           int    `json:"-"`               // 推荐人ID | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CheckParams 校验邮箱参数 | ||||||
|  | func (i *FrontedUserRegisterReq) CheckParams() int { | ||||||
|  | 	if i.RegisterType == TSmsCode { | ||||||
|  | 		if i.Phone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  | 		if i.PhoneAreaCode == "+86" { | ||||||
|  | 			if !utility.IsMobileChina(i.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		i.Account = i.Phone | ||||||
|  |  | ||||||
|  | 	} else if i.RegisterType == TEmailCode { | ||||||
|  | 		// 邮箱校验 | ||||||
|  | 		if i.Email == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  | 		if !emailhelper.CheckIsEmail(i.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  | 		i.Account = i.Email | ||||||
|  | 	} else { | ||||||
|  | 		log.Error("only support email and phone register") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 身份认证模型 | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | // UserRegisterReq 用户注册 | ||||||
|  | type UserRegisterReq struct { | ||||||
|  | 	Account        string `json:"account"`         // 账号 | ||||||
|  | 	RegisterType   int    `json:"register_type"`   // 注册类型 1: 手机 2: 邮箱 | ||||||
|  | 	PhoneAreaCode  string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone          string `json:"phone"`           // 手机号码 | ||||||
|  | 	Email          string `json:"email"`           // 邮箱地址 | ||||||
|  | 	Password       string `json:"password"`        // 密码 | ||||||
|  | 	Captcha        string `json:"captcha"`         // 验证码:1-不带验证码注册,仅验证注册信息是否合法;2-携带验证码注册,成功后返回 token | ||||||
|  | 	InviteCode     string `json:"invite_code"`     // 邀请码 | ||||||
|  | 	UserAddress    string `json:"user_address"`    // 地址 | ||||||
|  | 	Receive        string `json:"-"`               // 验证码接收方 | ||||||
|  | 	PhoneBindState int    `json:"-"`               // 手机绑定状态 | ||||||
|  | 	EmailBindState int    `json:"-"`               // 邮箱绑定状态 | ||||||
|  | 	IP             string `json:"-"`               // IP | ||||||
|  | 	Source         int    `json:"-"`               // 来源:0-未知,1-Android,2-iOS,3-PC | ||||||
|  | 	AgentCode      string `json:"agent_code"`      // 代理邀请码 | ||||||
|  | 	AreaId         int    `json:"areaid"`          // 地区序号 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (i *UserRegisterReq) Valid() int { | ||||||
|  | 	// 注册类型 | ||||||
|  | 	if i.RegisterType == TSmsCode { | ||||||
|  | 		// 手机校验 | ||||||
|  | 		if i.PhoneAreaCode == "" { | ||||||
|  | 			return statuscode.PleaseSelectThePhoneAreaCode | ||||||
|  | 		} | ||||||
|  | 		if i.Phone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  | 		if i.PhoneAreaCode == "86" { | ||||||
|  | 			if !utility.IsMobileChina(i.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(i.Phone) { | ||||||
|  | 				return statuscode.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  |  | ||||||
|  | 		i.Account = i.Phone | ||||||
|  | 		i.Receive = i.Phone | ||||||
|  | 		i.PhoneBindState = AuthBoundOpen | ||||||
|  |  | ||||||
|  | 	} else if i.RegisterType == TEmailCode { | ||||||
|  | 		// 邮箱校验 | ||||||
|  | 		if i.Email == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  | 		if !emailhelper.CheckIsEmail(i.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		i.Account = i.Email | ||||||
|  | 		i.Receive = i.Email | ||||||
|  | 		i.EmailBindState = AuthBoundOpen | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  | 		log.Error("only support email and phone register") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 密码校验 | ||||||
|  | 	if i.Password == "" { | ||||||
|  | 		return statuscode.PasswordRequired | ||||||
|  | 	} | ||||||
|  | 	if !utility.CheckPasswordOk(8, 32, i.Password) { | ||||||
|  | 		return statuscode.PasswordRules | ||||||
|  | 	} | ||||||
|  | 	// 加密密码 | ||||||
|  | 	i.Password = md5helper.MD52(i.Password) | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // TokenResp 注册成功,返回 token | ||||||
|  | type TokenResp struct { | ||||||
|  | 	JwtToken  string `json:"jwt_token"` | ||||||
|  | 	JwtExpire string `json:"jwt_expire"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UserAccountPwdLoginReq 用户账号密码登录 | ||||||
|  | type UserAccountPwdLoginReq struct { | ||||||
|  | 	LoginType       int    `json:"login_type"`      // 1 手机,2 邮箱 | ||||||
|  | 	PhoneAreaCode   string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone           string `json:"phone"`           // 手机号码 | ||||||
|  | 	Email           string `json:"email"`           // 邮箱 | ||||||
|  | 	Password        string `json:"password"`        // 密码 | ||||||
|  | 	CaptchaEmbedded        // 嵌入验证码 | ||||||
|  | 	LoginIP         string `json:"-"`         // IP | ||||||
|  | 	Source          int    `json:"-"`         // 来源:0-未知,1-Android,2-iOS,3-PC | ||||||
|  | 	DeviceID        string `json:"-"`         // 设备ID | ||||||
|  | 	TimeStamp       string `json:"sessionId"` //时间戳 | ||||||
|  | } | ||||||
|  | type UserRefreshTokenReq struct { | ||||||
|  | 	RefreshKey  string `json:"refresh_key"`  // 刷新token的key | ||||||
|  | 	RefreshTime string `json:"refresh_time"` // 刷新时间戳 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (l *UserAccountPwdLoginReq) Valid() int { | ||||||
|  | 	// 登录类型 | ||||||
|  | 	if l.LoginType == TSmsCode { | ||||||
|  | 		// 手机校验 | ||||||
|  | 		if l.PhoneAreaCode == "86" { | ||||||
|  | 			if !utility.IsMobileChina(l.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(l.Phone) { | ||||||
|  | 				return statuscode.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  | 	} else if l.LoginType == TEmailCode { | ||||||
|  | 		// 邮箱校验 | ||||||
|  | 		if !emailhelper.CheckIsEmail(l.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  | 	} else { | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 密码校验 | ||||||
|  | 	if len(l.Password) == 0 { | ||||||
|  | 		return statuscode.PasswordRequired | ||||||
|  | 	} | ||||||
|  | 	l.Password = md5helper.MD52(l.Password) | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UserLoginResp 用户登录响应 | ||||||
|  | type UserLoginResp struct { | ||||||
|  | 	UserAccount   string `json:"user_account"`    // 账号 | ||||||
|  | 	AreaPhoneCode string `json:"area_phone_code"` // 区域电话代码 | ||||||
|  | 	PhoneNumber   string `json:"phone_number"`    // 手机 | ||||||
|  | 	EmailAddr     string `json:"email_addr"`      // 邮箱 | ||||||
|  | 	PhonePass     string `json:"phone_pass"`      // 手机加密显示 | ||||||
|  | 	EmailPass     string `json:"email_pass"`      // 邮箱加密显示 | ||||||
|  | 	IsPhoneAuth   int    `json:"is_phone_auth"`   // 是否开启手机验证 0否,1是 | ||||||
|  | 	IsEmailAuth   int    `json:"is_email_auth"`   // 是否开启手机验证 0否,1是 | ||||||
|  | 	IsGoogleAuth  int    `json:"is_google_auth"`  // 是否开启谷歌验证 0否,1是 | ||||||
|  | 	LoginType     int    `json:"login_type"`      // 登录类型 1 手机 2 邮箱 | ||||||
|  | 	IdCardState   int    `json:"id_card_state"`   // 实名认证审核状态:1未审核,2审核通过,3审核不通过4审核中 | ||||||
|  | 	JwtToken      string `json:"jwt_token"`       // 登录成功返回 token | ||||||
|  | 	JwtExpire     string `json:"jwt_expire"`      // token过期时间 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 扫码登录 - 秘钥 | ||||||
|  | type ScanLoginSecret struct { | ||||||
|  | 	Secret   string `json:"secret"`    // 秘钥 | ||||||
|  | 	Status   int    `json:"status"`    // 状态:0 初始化,1 登录中,2 登录成功,-1 已过期 | ||||||
|  | 	Token    string `json:"token"`     // 登录成功返回 | ||||||
|  | 	IP       string `json:"ip"`        // 登录IP(PC) | ||||||
|  | 	Position string `json:"position"`  // IP归属地 | ||||||
|  | 	DeviceID string `json:"device_id"` // 登录设备(PC) | ||||||
|  | 	Time     int64  `json:"time"`      // 秘钥生成时间 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 扫码登录 - APP扫描请求参数 | ||||||
|  | type ScanLoginScanReq struct { | ||||||
|  | 	Secret  string `json:"secret"`  // 二维码秘钥 | ||||||
|  | 	Confirm int    `json:"confirm"` // 确认登录:0-查询登录状态,1-确认登录 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UserChangePwdReq 修改密码 | ||||||
|  | type UserChangePwdReq struct { | ||||||
|  | 	NewPassword     string `json:"new_password"` // 密码 | ||||||
|  | 	OldPassword     string `json:"old_password"` // 旧密码 | ||||||
|  | 	CaptchaEmbedded        // 嵌入验证码 | ||||||
|  | 	UserId          int    `json:"-"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (p *UserChangePwdReq) Valid() int { | ||||||
|  | 	if p.OldPassword == "" { | ||||||
|  | 		return statuscode.OriginalPasswordRequired | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if p.NewPassword == "" { | ||||||
|  | 		return statuscode.NewPasswordRequired | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if !utility.CheckPasswordOk(8, 32, p.NewPassword) { | ||||||
|  | 		return statuscode.PasswordRules | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p.OldPassword = md5helper.MD52(p.OldPassword) | ||||||
|  | 	p.NewPassword = md5helper.MD52(p.NewPassword) | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ResetPwdReq 重置密码 | ||||||
|  | type ResetPwdReq struct { | ||||||
|  | 	RetrieveType  int    `json:"retrieve_type"`   // 找回密码类型:1 手机,2 邮箱 | ||||||
|  | 	PhoneAreaCode string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone         string `json:"phone"`           // 手机号码 | ||||||
|  | 	Email         string `json:"email"`           // 邮箱地址 | ||||||
|  | 	Password      string `json:"password"`        // 密码 | ||||||
|  | 	Credentials   string `json:"credentials"`     // 凭证 | ||||||
|  | 	UserID        int    `json:"-"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (self *ResetPwdReq) Valid() int { | ||||||
|  | 	// 发送手机验证码 | ||||||
|  | 	if self.RetrieveType == TSmsCode { | ||||||
|  | 		// 区域电话代码不能为空 | ||||||
|  | 		if self.PhoneAreaCode == "" { | ||||||
|  | 			return statuscode.PleaseSelectThePhoneAreaCode | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 电话号码不能为空 | ||||||
|  | 		if self.Phone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验手机号码是否合法 | ||||||
|  | 		if self.PhoneAreaCode == "86" { | ||||||
|  | 			if !utility.IsMobileChina(self.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(self.Phone) { | ||||||
|  | 				return statuscode.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  |  | ||||||
|  | 	} else if self.RetrieveType == TEmailCode { // 发送邮箱验证码 | ||||||
|  | 		// 邮箱不能为空 | ||||||
|  | 		if self.Email == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验邮箱是否合法 | ||||||
|  | 		if !emailhelper.CheckIsEmail(self.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		log.Error("only support phone and email auth") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 传凭证时,才校验密码 | ||||||
|  | 	if len(self.Credentials) > 0 { | ||||||
|  | 		if self.Password == "" { | ||||||
|  | 			return statuscode.NewPasswordRequired | ||||||
|  | 		} | ||||||
|  | 		if !utility.CheckPasswordOk(8, 32, self.Password) { | ||||||
|  | 			return statuscode.PasswordRules | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		self.Password = md5helper.MD52(self.Password) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // ResetPwdResp 重置密码响应 | ||||||
|  | type ResetPwdResp struct { | ||||||
|  | 	RetrieveType  int    `json:"retrieve_type"`   // 找回密码类型:1 手机,2 邮箱 | ||||||
|  | 	Account       string `json:"account"`         // 账号 | ||||||
|  | 	AreaPhoneCode string `json:"area_phone_code"` // 区域电话代码 | ||||||
|  | 	PhoneNumber   string `json:"phone_number"`    // 手机号码 | ||||||
|  | 	EmailAddr     string `json:"email_addr"`      // 邮箱地址 | ||||||
|  | 	PhonePass     string `json:"phone_pass"`      // 手机加密显示 | ||||||
|  | 	EmailPass     string `json:"email_pass"`      // 邮箱加密显示 | ||||||
|  | 	IsPhoneAuth   int    `json:"is_phone_auth"`   // 是否绑定手机 0否,1是 | ||||||
|  | 	IsEmailAuth   int    `json:"is_email_auth"`   // 是否绑定邮箱 0否,1是 | ||||||
|  | 	IsGoogleAuth  int    `json:"is_google_auth"`  // 是否绑定谷歌验证器 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 重置密码安全校验 | ||||||
|  | type ResetPwdCheck struct { | ||||||
|  | 	RetrieveType    int    `json:"retrieve_type"`   // 找回密码类型:1 手机,2 邮箱 | ||||||
|  | 	PhoneAreaCode   string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone           string `json:"phone"`           // 手机号码 | ||||||
|  | 	Email           string `json:"email"`           // 邮箱地址 | ||||||
|  | 	CaptchaEmbedded        // 嵌入验证码 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (self *ResetPwdCheck) Valid() int { | ||||||
|  | 	// 发送手机验证码 | ||||||
|  | 	if self.RetrieveType == TSmsCode { | ||||||
|  | 		// 区域电话代码不能为空 | ||||||
|  | 		if self.PhoneAreaCode == "" { | ||||||
|  | 			return statuscode.PleaseSelectThePhoneAreaCode | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 电话号码不能为空 | ||||||
|  | 		if self.Phone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验手机号码是否合法 | ||||||
|  | 		if self.PhoneAreaCode == "86" { | ||||||
|  | 			if !utility.IsMobileChina(self.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(self.Phone) { | ||||||
|  | 				return statuscode.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  |  | ||||||
|  | 	} else if self.RetrieveType == TEmailCode { // 发送邮箱验证码 | ||||||
|  | 		// 邮箱不能为空 | ||||||
|  | 		if self.Email == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验邮箱是否合法 | ||||||
|  | 		if !emailhelper.CheckIsEmail(self.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		log.Error("only support phone and email auth") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
							
								
								
									
										124
									
								
								app/admin/models/sysmodel/authenticator.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								app/admin/models/sysmodel/authenticator.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,124 @@ | |||||||
|  | package sysmodel | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"go-admin/common/const/enum/businesstype" | ||||||
|  | 	statuscode "go-admin/common/status_code" | ||||||
|  | 	"go-admin/pkg/emailhelper" | ||||||
|  | 	"go-admin/pkg/utility" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 验证器模型 | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | // 验证器状态 | ||||||
|  | var AuthNotBound = 0   // 未绑定 | ||||||
|  | var AuthBoundOpen = 1  // 绑定开启 | ||||||
|  | var AuthBoundClose = 2 // 绑定未开启 | ||||||
|  |  | ||||||
|  | // GetGoogleSecretResp 获取 Google 验证器秘钥 | ||||||
|  | type GetGoogleSecretResp struct { | ||||||
|  | 	Secret     string `json:"secret"` | ||||||
|  | 	GoogleAuth string `json:"google_auth"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UserAuthSwitchStatus 用户身份验证器开关状态 | ||||||
|  | type UserAuthSwitchStatus struct { | ||||||
|  | 	PhoneAuth    int    `db:"phoneauthisopen"`    // 手机验证器:0 关,1 开 | ||||||
|  | 	EmailAuth    int    `db:"emailauthisopen"`    // 邮箱验证器:0 关,1 开 | ||||||
|  | 	GoogleAuth   int    `db:"googleidcardisopen"` // 谷歌验证器:0 关,1 开 | ||||||
|  | 	GoogleSecret string `db:"googlesecret"`       // 谷歌秘钥 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Authenticator 验证器-验证结构 | ||||||
|  | type Authenticator struct { | ||||||
|  | 	UserID        int | ||||||
|  | 	PhoneAuth     int                       // 手机验证器:0 关,1 开 | ||||||
|  | 	EmailAuth     int                       // 邮箱验证器:0 关,1 开 | ||||||
|  | 	GoogleAuth    int                       // 谷歌验证器:0 关,1 开 | ||||||
|  | 	Phone         string                    // 手机号 | ||||||
|  | 	Email         string                    // 邮箱 | ||||||
|  | 	GoogleSecret  string                    // 谷歌秘钥 | ||||||
|  | 	SmsCaptcha    string                    // 手机验证码 | ||||||
|  | 	EmailCaptcha  string                    // 邮箱验证码 | ||||||
|  | 	GoogleCaptcha string                    // 谷歌验证码 | ||||||
|  | 	BusinessType  businesstype.BusinessType // 业务类型 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // AuthenticatorSwitch 身份验证开关【请求】结构 | ||||||
|  | type AuthenticatorSwitch struct { | ||||||
|  | 	OperationType    int                       `json:"operation_type"`     // 操作类型:1-开启,2-更改,3-关闭 | ||||||
|  | 	ValidatorType    int                       `json:"validator_type"`     // 验证器类型:1-手机,2-邮箱,3-Google | ||||||
|  | 	SmsCaptcha       string                    `json:"sms_captcha"`        // 手机验证码 | ||||||
|  | 	EmailCaptcha     string                    `json:"email_captcha"`      // 邮箱验证码 | ||||||
|  | 	GoogleCaptcha    string                    `json:"google_captcha"`     // 谷歌验证码 | ||||||
|  | 	NewPhoneArea     string                    `json:"new_phone_area"`     // 新区号:开启、更改手机验证器时必传 | ||||||
|  | 	NewPhone         string                    `json:"new_phone"`          // 新手机号:开启、更改手机验证器时必传 | ||||||
|  | 	NewPhoneCaptcha  string                    `json:"new_phone_captcha"`  // 新手机验证码 | ||||||
|  | 	NewEmail         string                    `json:"new_email"`          // 新邮箱:开启、更改邮箱验证器时必传 | ||||||
|  | 	NewEmailCaptcha  string                    `json:"new_email_captcha"`  // 新邮箱验证码:开启、更改邮箱验证器时必传 | ||||||
|  | 	NewGoogleCaptcha string                    `json:"new_google_captcha"` // 新邮箱验证码:开启、更改邮箱验证器时必传 | ||||||
|  | 	UserID           int                       `json:"-"`                  // | ||||||
|  | 	BusinessType     businesstype.BusinessType `json:"-"`                  // 业务类型:11-开启手机验证,21-更改手机验证,31-关闭手机验证,12-开启邮箱验证,22-更改邮箱验证,32-关闭邮箱验证,13-开启Google验证,23-更改Google验证,33-关闭Google验证 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (self *AuthenticatorSwitch) Valid() int { | ||||||
|  | 	// 计算业务类型 | ||||||
|  | 	self.BusinessType = businesstype.BusinessType(self.OperationType*10 + self.ValidatorType) | ||||||
|  |  | ||||||
|  | 	switch self.BusinessType { | ||||||
|  |  | ||||||
|  | 	case businesstype.OpenPhoneAuth, businesstype.ChangePhoneAuth: // 开启手机 & 更改手机 | ||||||
|  | 		if self.NewPhoneArea == "" { | ||||||
|  | 			return statuscode.PleaseSelectThePhoneAreaCode | ||||||
|  | 		} | ||||||
|  | 		if self.NewPhone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  | 		if self.NewPhoneCaptcha == "" { | ||||||
|  | 			return statuscode.PhoneCaptchaRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if self.NewPhoneArea == "86" { | ||||||
|  | 			if !utility.IsMobileChina(self.NewPhone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(self.NewPhone) { | ||||||
|  | 				return enum.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  |  | ||||||
|  | 		return statuscode.OK | ||||||
|  |  | ||||||
|  | 	case businesstype.ClosePhoneAuth: // 关闭手机 | ||||||
|  |  | ||||||
|  | 	case businesstype.OpenEmailAuth, businesstype.ChangeEmailAuth: // 开启邮箱 & 更改邮箱 | ||||||
|  | 		if self.NewEmail == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  | 		if self.NewEmailCaptcha == "" { | ||||||
|  | 			return statuscode.EmailCaptchaRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if !emailhelper.CheckIsEmail(self.NewEmail) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		return statuscode.OK | ||||||
|  |  | ||||||
|  | 	case businesstype.CloseEmailAuth: // 关闭邮箱 | ||||||
|  |  | ||||||
|  | 	case businesstype.OpenGoogleAuth: // 开启 Google | ||||||
|  | 		if self.NewGoogleCaptcha == "" { | ||||||
|  | 			return statuscode.GoogleCaptchaRequired | ||||||
|  | 		} | ||||||
|  | 	case businesstype.ChangeGoogleAuth: // 更改 Google 实质就是关闭,但业务类型要区分开 | ||||||
|  | 	case businesstype.CloseGoogleAuth: // 关闭 Google | ||||||
|  |  | ||||||
|  | 	default: | ||||||
|  | 		return statuscode.UnsupportedBusinessType | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
							
								
								
									
										116
									
								
								app/admin/models/sysmodel/captcha.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								app/admin/models/sysmodel/captcha.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,116 @@ | |||||||
|  | package sysmodel | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	statuscode "go-admin/common/status_code" | ||||||
|  | 	"go-admin/pkg/emailhelper" | ||||||
|  | 	"go-admin/pkg/utility" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 验证码模型 | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | var TSmsCode = 1                         // 手机验证码 | ||||||
|  | var TEmailCode = 2                       // 邮箱验证码 | ||||||
|  | var CodeValidTime = 5 * 60 * time.Second // 验证码有效期 5min | ||||||
|  |  | ||||||
|  | // SendCaptchaReq 发送验证码 | ||||||
|  | type SendCaptchaReq struct { | ||||||
|  | 	BusinessType  int    `json:"business_type"`   // 业务类型:1-注册,2-登录,3-找回密码,4-修改密码,11-开启手机验证,21-更改手机验证,31-关闭手机验证,12-开启邮箱验证,22-更改邮箱验证,32-关闭邮箱验证,13-开启Google验证,23-更改Google验证,33-关闭Google验证  100-手机验证码 101 | ||||||
|  | 	SendType      int    `json:"send_type"`       // 发送验证码类型 1 手机 2 邮箱 | ||||||
|  | 	IsNew         int    `json:"is_new"`          // 更改手机、邮箱验证时,新号码获取验证码需传 is_new: 1 | ||||||
|  | 	PhoneAreaCode string `json:"phone_area_code"` // 区域电话代码 | ||||||
|  | 	Phone         string `json:"phone"`           // 手机号码 | ||||||
|  | 	Email         string `json:"email"`           // 邮箱地址 | ||||||
|  | 	Uid           int    `json:"-"`               // 存用户ID用于判断是否登录,从token中解析得到,而非传入 | ||||||
|  | 	IP            string `json:"-"`               // IP | ||||||
|  | 	Receive       string `json:"-"`               // 验证码接收方 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (self *SendCaptchaReq) Valid() int { | ||||||
|  | 	// 业务类型不能为空 | ||||||
|  | 	if self.BusinessType <= 0 { | ||||||
|  | 		log.Error("send verify code business info unknown") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  | 	// 业务类型 1 注册 2 登录 3 找回密码 无须登录,其余业务须登录 | ||||||
|  | 	if self.BusinessType > 3 && self.Uid == 0 { | ||||||
|  | 		return statuscode.NotLoggedIn | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 发送手机验证码 | ||||||
|  | 	if self.SendType == TSmsCode { | ||||||
|  | 		// 区域电话代码不能为空 | ||||||
|  | 		if self.PhoneAreaCode == "" { | ||||||
|  | 			return statuscode.PleaseSelectThePhoneAreaCode | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 电话号码不能为空 | ||||||
|  | 		if self.Phone == "" { | ||||||
|  | 			return statuscode.PhoneRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验手机号码是否合法 | ||||||
|  | 		if self.PhoneAreaCode == "86" { | ||||||
|  | 			if !utility.IsMobileChina(self.Phone) { | ||||||
|  | 				return statuscode.PhoneFormatInvalid | ||||||
|  | 			} | ||||||
|  | 		} /*else { | ||||||
|  | 			if !utility.ValidatePhoneNumber(self.Phone) { | ||||||
|  | 				return enum.Differentarea | ||||||
|  | 			} | ||||||
|  | 		}*/ | ||||||
|  |  | ||||||
|  | 		// 接收方 | ||||||
|  | 		self.Receive = self.Phone | ||||||
|  |  | ||||||
|  | 	} else if self.SendType == TEmailCode { // 发送邮箱验证码 | ||||||
|  | 		// 邮箱不能为空 | ||||||
|  | 		if self.Email == "" { | ||||||
|  | 			return statuscode.EmailRequired | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 校验邮箱是否合法 | ||||||
|  | 		if !emailhelper.CheckIsEmail(self.Email) { | ||||||
|  | 			return statuscode.EmailFormatInvalid | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// 接收方 | ||||||
|  | 		self.Receive = self.Email | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  | 		log.Error("only support phone and email auth") | ||||||
|  | 		return statuscode.ParameterInvalid | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return statuscode.OK | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CaptchaEmbedded 校验验证码的嵌入结构 | ||||||
|  | type CaptchaEmbedded struct { | ||||||
|  | 	SmsCaptcha    string `json:"sms_captcha"`    // 手机验证码 | ||||||
|  | 	EmailCaptcha  string `json:"email_captcha"`  // 邮箱验证码 | ||||||
|  | 	GoogleCaptcha string `json:"google_captcha"` // 谷歌验证码 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CheckCaptcha 校验验证码 | ||||||
|  | type CheckCaptcha struct { | ||||||
|  | 	BusinessType int       `db:"businesstype"` // 业务类型 | ||||||
|  | 	Receive      string    `db:"phone"`        // 接收方, 手机或邮箱 | ||||||
|  | 	Captcha      string    `db:"code"`         // 验证码 | ||||||
|  | 	Flag         int       `db:"verifyflag"`   // 标志:0-未验证,1-已验证 | ||||||
|  | 	Now          time.Time `db:"now"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Credential 验证码校验通过生成凭证 | ||||||
|  | type Credential struct { | ||||||
|  | 	BusinessType int    // 业务类型 | ||||||
|  | 	UserID       int    // 用户ID | ||||||
|  | 	Phone        string // 手机 | ||||||
|  | 	Email        string // 邮箱 | ||||||
|  | 	Time         int64  // 凭证生成时间戳 | ||||||
|  | 	Rand         int64  // 随机种子 | ||||||
|  | } | ||||||
							
								
								
									
										13
									
								
								app/admin/models/sysmodel/sysstatuscode.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								app/admin/models/sysmodel/sysstatuscode.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | |||||||
|  | package sysmodel | ||||||
|  |  | ||||||
|  | type StatusCode struct { | ||||||
|  | 	Code    int    `db:"code" gorm:"code"`       // 状态码 | ||||||
|  | 	Explain string `db:"explain" gorm:"explain"` // 描述 | ||||||
|  | 	ZhCN    string `db:"zh_cn" gorm:"zh_cn"`     // 简体中文 | ||||||
|  | 	ZhHK    string `db:"zh_hk" gorm:"zh_hk"`     // 繁体中文 | ||||||
|  | 	En      string `db:"en" gorm:"en"`           // 英文 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (StatusCode) TableName() string { | ||||||
|  | 	return "sys_status_code" | ||||||
|  | } | ||||||
							
								
								
									
										47
									
								
								app/admin/models/vts_recharge.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								app/admin/models/vts_recharge.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | |||||||
|  | package models | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/shopspring/decimal" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"go-admin/common/models" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type VtsRecharge struct { | ||||||
|  | 	models.Model | ||||||
|  |  | ||||||
|  | 	CoinCode        string          `json:"coinCode" gorm:"type:varchar(20);comment:币种"` | ||||||
|  | 	TranType        int             `json:"tranType" gorm:"type:int;comment:类型:1-线上 2-内部"` | ||||||
|  | 	OrderNo         string          `json:"orderNo" gorm:"type:varchar(255);comment:订单号"` | ||||||
|  | 	AdUserId        int             `json:"adUserId" gorm:"type:bigint;comment:用户id"` | ||||||
|  | 	Amount          decimal.Decimal `json:"amount" gorm:"type:decimal(32,8);comment:订单价格"` | ||||||
|  | 	PriceCurrency   string          `json:"priceCurrency" gorm:"type:varchar(20);comment:CoinGate结算货币代码"` | ||||||
|  | 	ReceiveAmount   decimal.Decimal `json:"receiveAmount" gorm:"type:decimal(32,8);comment:实收数量"` | ||||||
|  | 	PayAmount       decimal.Decimal `json:"payAmount" gorm:"type:decimal(32,8);comment:实际支付数量"` | ||||||
|  | 	PayCurrency     string          `json:"payCurrency" gorm:"type:varchar(255);comment:实际支付的加密货币"` | ||||||
|  | 	UnderpaidAmount decimal.Decimal `json:"underpaidAmount" gorm:"type:decimal(32,8);comment:买家少付数量"` | ||||||
|  | 	OverpaidAmount  decimal.Decimal `json:"overpaidAmount" gorm:"type:decimal(32,8);comment:买家多付数量"` | ||||||
|  | 	IsRefundable    int             `json:"isRefundable" gorm:"type:tinyint;comment:指示购物者是否可以请求发票退款"` | ||||||
|  | 	WalletCreateAt  time.Time       `json:"walletCreateAt" gorm:"type:datetime;comment:第三方创建时间"` | ||||||
|  | 	WalletId        int             `json:"walletId" gorm:"type:int;comment:第三方钱包订单"` | ||||||
|  | 	Fee             decimal.Decimal `json:"fee" gorm:"type:decimal(32,8);comment:手续费"` | ||||||
|  | 	CallbackAt      time.Time       `json:"callbackAt" gorm:"type:datetime;comment:回调时间"` | ||||||
|  | 	Status          string          `json:"status" gorm:"type:varchar(20);comment:状态(字典 vts_recharge_status)"` | ||||||
|  | 	ConfirmStatus   string          `json:"confirmStatus" gorm:"type:varchar(20);comment:确认状态(字典 vts_confirm_status)"` | ||||||
|  | 	Remark          string          `json:"remark" gorm:"type:varchar(500);comment:备注"` | ||||||
|  | 	models.ModelTime | ||||||
|  | 	models.ControlBy | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (VtsRecharge) TableName() string { | ||||||
|  | 	return "vts_recharge" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *VtsRecharge) Generate() models.ActiveRecord { | ||||||
|  | 	o := *e | ||||||
|  | 	return &o | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (e *VtsRecharge) GetId() interface{} { | ||||||
|  | 	return e.Id | ||||||
|  | } | ||||||
							
								
								
									
										40
									
								
								app/admin/router/init_router.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								app/admin/router/init_router.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"os" | ||||||
|  |  | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	log "github.com/go-admin-team/go-admin-core/logger" | ||||||
|  | 	"github.com/go-admin-team/go-admin-core/sdk" | ||||||
|  | 	common "go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | // InitRouter 路由初始化,不要怀疑,这里用到了 | ||||||
|  | func InitRouter() { | ||||||
|  | 	var r *gin.Engine | ||||||
|  | 	h := sdk.Runtime.GetEngine() | ||||||
|  | 	if h == nil { | ||||||
|  | 		log.Fatal("not found engine...") | ||||||
|  | 		os.Exit(-1) | ||||||
|  | 	} | ||||||
|  | 	switch h.(type) { | ||||||
|  | 	case *gin.Engine: | ||||||
|  | 		r = h.(*gin.Engine) | ||||||
|  | 	default: | ||||||
|  | 		log.Fatal("not support other engine") | ||||||
|  | 		os.Exit(-1) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// the jwt middleware | ||||||
|  | 	authMiddleware, err := common.AuthInit() | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Fatalf("JWT Init Error, %s", err.Error()) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// 注册系统路由 | ||||||
|  | 	InitSysRouter(r, authMiddleware) | ||||||
|  |  | ||||||
|  | 	// 注册业务路由 | ||||||
|  | 	// TODO: 这里可存放业务路由,里边并无实际路由只有演示代码 | ||||||
|  | 	InitExamplesRouter(r, authMiddleware) | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_account_setting.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineAccountSettingRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineAccountSettingRouter | ||||||
|  | func registerLineAccountSettingRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineAccountSetting{} | ||||||
|  | 	r := v1.Group("/line-account-setting").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_api_group.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineApiGroupRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineApiGroupRouter | ||||||
|  | func registerLineApiGroupRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineApiGroup{} | ||||||
|  | 	r := v1.Group("/line-api-group").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										31
									
								
								app/admin/router/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								app/admin/router/line_api_user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineApiUserRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineApiUserRouter | ||||||
|  | func registerLineApiUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineApiUser{} | ||||||
|  | 	r := v1.Group("/line-api-user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  |  | ||||||
|  | 		r.POST("bind", api.Bind)               //绑定从属关系 | ||||||
|  | 		r.POST("getUser", api.GetUser)         //获取未绑定的用户 | ||||||
|  | 		r.POST("getMainUser", api.GetMainUser) //获取获取主账号的用户 | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_coinnetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineCoinnetworkRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineCoinnetworkRouter | ||||||
|  | func registerLineCoinnetworkRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineCoinnetwork{} | ||||||
|  | 	r := v1.Group("/line-coinnetwork").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_cointonetwork.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineCointonetworkRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineCointonetworkRouter | ||||||
|  | func registerLineCointonetworkRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineCointonetwork{} | ||||||
|  | 	r := v1.Group("/line-cointonetwork").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										39
									
								
								app/admin/router/line_direction.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								app/admin/router/line_direction.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineDirectionRouter) | ||||||
|  | 	routerNoVersion = append(routerNoVersion, registerLineDirectionNoVersionRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func registerLineDirectionNoVersionRouter(v1 *gin.RouterGroup) { | ||||||
|  | 	api := apis.LineDirection{} | ||||||
|  |  | ||||||
|  | 	group := v1.Group("/Direction") | ||||||
|  | 	{ | ||||||
|  | 		group.POST("addDirection", api.AddDirection) // 新增预估方向 | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineDirectionRouter | ||||||
|  | func registerLineDirectionRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineDirection{} | ||||||
|  | 	r := v1.Group("/line-direction").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  |  | ||||||
|  | 		r.PUT("/reload-group", api.ReloadGroupData) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_order_template_logs.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineOrderTemplateLogsRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineOrderTemplateLogsRouter | ||||||
|  | func registerLineOrderTemplateLogsRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineOrderTemplateLogs{} | ||||||
|  | 	r := v1.Group("/line-order-template-logs").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										49
									
								
								app/admin/router/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								app/admin/router/line_pre_order.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLinePreOrderRouter) | ||||||
|  | 	routerNoCheckRole = append(routerNoCheckRole, unRegisterLinePreOrderRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLinePreOrderRouter | ||||||
|  | func registerLinePreOrderRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LinePreOrder{} | ||||||
|  | 	r := v1.Group("/line-pre-order").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  |  | ||||||
|  | 		r.POST("addOrder", actions.PermissionAction(), api.AddPreOrder)              //添加订单 | ||||||
|  | 		r.POST("batchAddOrder", actions.PermissionAction(), api.BatchAddOrder)       //批量添加订单 | ||||||
|  | 		r.POST("quickAddPreOrder", actions.PermissionAction(), api.QuickAddPreOrder) //快捷下单 | ||||||
|  | 		r.POST("lever", actions.PermissionAction(), api.Lever)                       //设置杠杆 | ||||||
|  | 		r.POST("marginType", actions.PermissionAction(), api.MarginType)             //设置仓位模式 | ||||||
|  | 		r.POST("cancelOpenOrder", actions.PermissionAction(), api.CancelOpenOrder)   //取消委托 | ||||||
|  | 		r.POST("clearAll", actions.PermissionAction(), api.ClearAll)                 // 一键清除数据 | ||||||
|  | 		r.POST("getChildOrder", actions.PermissionAction(), api.GetChildOrderList)   // 获取子订单 | ||||||
|  | 		r.POST("manuallyCover", actions.PermissionAction(), api.ManuallyCover)       // 手动加仓 | ||||||
|  | 		r.POST("closePosition", actions.PermissionAction(), api.ClosePosition)       // 平仓 | ||||||
|  | 		r.GET("getOrderPage", actions.PermissionAction(), api.GetOrderPage)          //订单列表 | ||||||
|  | 		r.POST("clearUnTriggered", actions.PermissionAction(), api.ClearUnTriggered) // 清除待触发的交易对 | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func unRegisterLinePreOrderRouter(v1 *gin.RouterGroup) { | ||||||
|  | 	api := apis.LinePreOrder{} | ||||||
|  | 	r := v1.Group("/line-pre-order") | ||||||
|  | 	{ | ||||||
|  | 		r.POST("queryOrder", api.QueryOrder) //查询订单 | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_pre_order_status.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLinePreOrderStatusRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLinePreOrderStatusRouter | ||||||
|  | func registerLinePreOrderStatusRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LinePreOrderStatus{} | ||||||
|  | 	r := v1.Group("/line-pre-order-status").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_pre_script.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLinePreScriptRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLinePreScriptRouter | ||||||
|  | func registerLinePreScriptRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LinePreScript{} | ||||||
|  | 	r := v1.Group("/line-pre-script").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										28
									
								
								app/admin/router/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								app/admin/router/line_price_limit.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLinePriceLimitRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLinePriceLimitRouter | ||||||
|  | func registerLinePriceLimitRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LinePriceLimit{} | ||||||
|  | 	r := v1.Group("/line-price-limit").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 		r.POST("upRange", api.UpRange) //更新涨跌幅 | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								app/admin/router/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/admin/router/line_recharge.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineRechargeRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineRechargeRouter | ||||||
|  | func registerLineRechargeRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineRecharge{} | ||||||
|  | 	r := v1.Group("/line-recharge").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										32
									
								
								app/admin/router/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/admin/router/line_symbol.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | package router | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" | ||||||
|  |  | ||||||
|  | 	"go-admin/app/admin/apis" | ||||||
|  | 	"go-admin/common/actions" | ||||||
|  | 	"go-admin/common/middleware" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func init() { | ||||||
|  | 	routerCheckRole = append(routerCheckRole, registerLineSymbolRouter) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // registerLineSymbolRouter | ||||||
|  | func registerLineSymbolRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||||||
|  | 	api := apis.LineSymbol{} | ||||||
|  | 	r := v1.Group("/line-symbol").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||||||
|  | 	{ | ||||||
|  | 		r.GET("", actions.PermissionAction(), api.GetPage) | ||||||
|  | 		r.GET("getSameSymbol", actions.PermissionAction(), api.GetSameSymbol) //获取现货和合约都有的交易对 | ||||||
|  | 		r.GET("/:id", actions.PermissionAction(), api.Get) | ||||||
|  | 		r.POST("", api.Insert) | ||||||
|  | 		r.PUT("/:id", actions.PermissionAction(), api.Update) | ||||||
|  | 		r.DELETE("", api.Delete) | ||||||
|  |  | ||||||
|  | 		r.POST("syncSpotSymbol", api.SyncSpotSymbol) //同步现货交易对 | ||||||
|  | 		r.POST("syncFutSymbol", api.SyncFutSymbol)   //同步合约交易对 | ||||||
|  | 		r.POST("getSymbol", api.GetSymbol)           //获取现货和合约都有的交易对 | ||||||
|  | 	} | ||||||
|  | } | ||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user