Browse Source

初始化

master
Viviman 2 years ago
commit
51ed2b0c27
  1. 10
      .gitignore
  2. 191
      LICENSE
  3. 71
      README.md
  4. 4
      common/constant.go
  5. 51
      conf/app.conf
  6. 72
      controllers/BaseController.go
  7. 94
      controllers/admin/DeptController.go
  8. 90
      controllers/admin/DictController.go
  9. 93
      controllers/admin/DictDetailController.go
  10. 93
      controllers/admin/JobController.go
  11. 144
      controllers/admin/LoginController.go
  12. 114
      controllers/admin/MenuController.go
  13. 125
      controllers/admin/RoleController.go
  14. 16
      controllers/admin/ToolsController.go
  15. 190
      controllers/admin/UserController.go
  16. 8
      dto/AuthUser.go
  17. 7
      dto/BasePage.go
  18. 7
      dto/DictPost.go
  19. 6
      dto/DictQuery.go
  20. 10
      dto/RoleMenu.go
  21. 6
      dto/UserPass.go
  22. 8
      dto/UserPost.go
  23. 8
      dto/UserQuery.go
  24. 15
      go.mod
  25. 141
      jwt/jwt.go
  26. 130
      main.go
  27. 43
      models/BaseModel.go
  28. 68
      models/SysDept.go
  29. 56
      models/SysDict.go
  30. 65
      models/SysDictDetail.go
  31. 69
      models/SysJob.go
  32. 23
      models/SysLog.go
  33. 195
      models/SysMenu.go
  34. 20
      models/SysPicture.go
  35. 73
      models/SysRole.go
  36. 13
      models/SysRoleDepts.go
  37. 30
      models/SysRoleMenus.go
  38. 200
      models/SysUser.go
  39. 21
      models/SysUsersRoles.go
  40. 63
      redis/pool.go
  41. 59
      redis/redis.go
  42. 370
      routers/commentsRouter_.go
  43. 66
      routers/router.go
  44. 424
      sql/yshop_go.sql
  45. BIN
      static/upload/1.jpg
  46. BIN
      static/upload/1614928266851.jpg
  47. BIN
      swagger/favicon-16x16.png
  48. BIN
      swagger/favicon-32x32.png
  49. 93
      swagger/index.html
  50. 53
      swagger/oauth2-redirect.html
  51. 108
      swagger/swagger-ui-bundle.js
  52. 1
      swagger/swagger-ui-bundle.js.map
  53. 20
      swagger/swagger-ui-standalone-preset.js
  54. 1
      swagger/swagger-ui-standalone-preset.js.map
  55. 2
      swagger/swagger-ui.css
  56. 1
      swagger/swagger-ui.css.map
  57. 15
      swagger/swagger-ui.js
  58. 1
      swagger/swagger-ui.js.map
  59. 989
      swagger/swagger.json
  60. 667
      swagger/swagger.yml
  61. 38
      tests/default_test.go
  62. 68
      untils/tools.go
  63. 13
      vo/JwtUser.go
  64. 8
      vo/LoginVo.go
  65. 6
      vo/ResultList.go
  66. 18
      vo/menu/MenuVo.go

10
.gitignore

@ -0,0 +1,10 @@
.idea/
logs/
lastupdate.tmp
yshop
*.exe
yshop.tar.gz
/routers/commentsRouter___________________Users_zhangxianwei_GolandProjects_beego-vue-admin_controllers.go
/routers/commentsRouter___________________Users_zhangxianwei_GolandProjects_bee-vue-demo_controllers.go
/desc/
/web/node_modules/

191
LICENSE

@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "{}" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright 2021 hu peng
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

71
README.md

@ -0,0 +1,71 @@
<h1 style="text-align: center">beego-vue-admin 后台管理系统</h1>
#### 项目简介
beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue
的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等
**体验地址:** [https://go.yixiang.co](https://go.yixiang.co)
**账号密码:** `admin / 123456`
#### 项目源码
| | 后端源码 | 前端源码 |
|--- |--- | --- |
| 码云 | https://gitee.com/guchengwuyue/beego-vue-admin | https://gitee.com/guchengwuyue/beego-vue-admin-web |
| github | https://github.com/guchengwuyue/beego-vue-admin | https://github.com/guchengwuyue/beego-vue-admin-web |
#### 系统功能
- 用户管理:提供用户的相关配置
- 角色管理:对权限与菜单进行分配,可根据部门设置角色的数据权限
- 菜单管理:已实现菜单动态路由,后端可配置化
- 部门管理:可配置系统组织架构,树形表格展示
- 岗位管理:配置各个部门的职位
- 字典管理:可维护常用一些固定的数据,如:状态,性别等
#### 详细结构
```
- common 公共模块
- constant.go 常量
- conf 公共配置
- controllers 控制器模块
- admin 管理后台
- app app模块
- base.go 公共控制器
- dto dto模块
- jwt jwt模块
- logs 日志存放
- models 公共模型
- redis redis模块
- pool.go 连接池
- redis.go 常用操作
- routers 路由
- static 上传图片资源目录
- swagger swagger
- tests tests
- untils 工具模块
- vo vo模块
```
#### 启动与部署
```
1、go get 安装所需依赖
2、导入sql/yshop_go.sql,修改conf/app.conf 里数据库与redis配置
3、bee run 启动即可
4、线上部署: bee pack -be GOOS=linux 打包然后上传服务器命令: nohup ./yshop &
5、配置nginx 反向代理即可
```
### 效果图
| ![输入图片说明](https://images.gitee.com/uploads/images/2021/0324/091742_84ebf16e_477893.png "01.png") | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0324/091938_e3408f92_477893.png "02.png") |
|---|---|
| ![输入图片说明](https://images.gitee.com/uploads/images/2021/0324/092327_601b2411_477893.png "03.png") | ![输入图片说明](https://images.gitee.com/uploads/images/2021/0324/092343_9cadff96_477893.png "04.png") |
#### 特别鸣谢
- beego:https://github.com/beego/beego/
- vue:https://github.com/vuejs/vue
- element:https://github.com/ElemeFE/element

4
common/constant.go

@ -0,0 +1,4 @@
package common
const ContextKeyUserObj = "authedUserObj"
const REDIS_PREFIX_AUTH = "auth:"

51
conf/app.conf

@ -0,0 +1,51 @@
appname = yshop
httpport = 8080
runmode = dev
autorender = false
copyrequestbody = true
EnableDocs = true
sqlconn =
api_url = https://goapi.yixiang.co
#忽略URL
ignore_urls = "/admin/auth/login,/admin/auth/captcha"
[dev]
#数据库配置
mysqluser = "beego"
mysqlpass = "Asdfghjklm123."
mysqlhost = "nas.viviman.top"
mysqlport = 35017
mysqldb = "beego_demo01"
db_max_idle_conn = 30
db_max_open_open = 100
maxmemory = 1<<22
#redis
redis_host = nas.viviman.top:20017
redis_pwd =
#日志等级 debug
logLevel = 7
jwt_token = 1BD6C43CA0BBF4B7ABA5E486D6A5AA2D
[prod]
#数据库配置
mysqluser = "beego"
mysqlpass = "Asdfghjklm123."
mysqlhost = "nas.viviman.top"
mysqlport = 35017
mysqldb = "beego_demo01"
db_max_idle_conn = 30
db_max_open_open = 100
maxmemory = 1<<22
#redis
redis_host = nas.viviman.top:20017
redis_pwd =
#日志等级 debug
logLevel = 4
jwt_token = 1BD6C43CA0BBF4B7ABA5E486D6A5AA2D

72
controllers/BaseController.go

@ -0,0 +1,72 @@
/**
* Copyright (C) 2020-2021
* All rights reserved, Designed By www.yixiang.co
* 注意本软件为www.yixiang.co开发研制
*/
package controllers
import (
beego "github.com/beego/beego/v2/server/web"
"viviman.top/dto"
)
type BaseController struct {
beego.Controller
}
func (c *BaseController) GetParams() dto.BasePage {
var (
page int
size int
blurry string
)
c.Ctx.Input.Bind(&page, "page")
c.Ctx.Input.Bind(&size, "size")
c.Ctx.Input.Bind(&blurry, "blurry")
return dto.BasePage{Page: page, Size: size, Blurry: blurry}
}
type any = interface{}
type Result struct {
Data interface{} `json:"data"`
Msg string `json:"msg"`
Status int `json:"status"`
}
func ErrMsg(msg string, status ...int) Result {
var r Result
if len(status) > 0 {
r.Status = status[0]
} else {
r.Status = 500000
}
r.Msg = msg
r.Data = nil
return r
}
func ErrData(msg error, status ...int) Result {
var r Result
if len(status) > 0 {
r.Status = status[0]
} else {
r.Status = 500000
}
r.Msg = msg.Error()
r.Data = nil
return r
}
func SuccessData(data any) Result {
var r Result
r.Status = 200
r.Msg = "ok"
r.Data = data
return r
}

94
controllers/admin/DeptController.go

@ -0,0 +1,94 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"viviman.top/controllers"
"viviman.top/models"
"viviman.top/vo"
)
// 部门api
type DeptController struct {
controllers.BaseController
}
func (c *DeptController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 获取部门列表
// @Description 获取部门列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *DeptController) GetAll() {
name := c.GetString("name")
enabled, _ := c.GetInt8("enabled", -1)
list := models.GetAllDepts(name, enabled)
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: 0})
c.ServeJSON()
}
// @Title 添加部门
// @Description 添加部门
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *DeptController) Post() {
var model models.SysDept
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddDept(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 修改部门
// @Description 修改部门
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *DeptController) Put() {
var model models.SysDept
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByDept(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 删除部门
// @Description 删除部门
// @Success 200 {object} controllers.Result
// @router / [delete]
func (c *DeptController) Delete() {
var ids []int64
json.Unmarshal(c.Ctx.Input.RequestBody, &ids)
logs.Info(ids)
e := models.DelByDept(ids)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

90
controllers/admin/DictController.go

@ -0,0 +1,90 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/validation"
"viviman.top/controllers"
"viviman.top/models"
"viviman.top/vo"
)
// 字典api
type DictController struct {
controllers.BaseController
}
func (c *DictController) URLMapping() {
c.Mapping("Post", c.Post)
//c.Mapping("GetOne", c.GetOne)
c.Mapping("GetAll", c.GetAll)
//c.Mapping("Put", c.Put)
//c.Mapping("Delete", c.Delete)
}
// @Title 获取字典列表
// @Description 获取字典列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *DictController) GetAll() {
total, list := models.GetAllDict(c.GetParams())
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: total})
c.ServeJSON()
}
// @Title 添加字典
// @Description 添加字典
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *DictController) Post() {
var dictModel models.SysDict
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &dictModel)
b, _ := valid.Valid(&dictModel)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddDict(&dictModel)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 修改字典
// @Description 修改字典
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *DictController) Put() {
var dictModel models.SysDict
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &dictModel)
b, _ := valid.Valid(&dictModel)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByDict(&dictModel)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 删除字典
// @Description 删除字典
// @Success 200 {object} controllers.Result
// @router /:id [delete]
func (c *DictController) Delete() {
id, _ := c.GetInt64(":id", 1)
e := models.DelByDict(id)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

93
controllers/admin/DictDetailController.go

@ -0,0 +1,93 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"viviman.top/controllers"
"viviman.top/models"
"viviman.top/vo"
)
// 字典详情api
type DictDetailController struct {
controllers.BaseController
}
func (c *DictDetailController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 获取字典详情列表
// @Description 获取字典详情列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *DictDetailController) GetAll() {
dictId, _ := c.GetInt64("dictId")
dictName := c.GetString("dictName")
total, list := models.GetAllDictDetail(c.GetParams(), dictId, dictName)
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: total})
c.ServeJSON()
}
// @Title 添加字典详情
// @Description 添加字典详情
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *DictDetailController) Post() {
var model models.SysDictDetail
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
logs.Info(model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddDictDetail(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 修改字典详情
// @Description 修改字典详情
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *DictDetailController) Put() {
var model models.SysDictDetail
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByDictDetail(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 删除字典详情
// @Description 删除字典详情
// @Success 200 {object} controllers.Result
// @router /:id [delete]
func (c *DictDetailController) Delete() {
id, _ := c.GetInt64(":id", 1)
e := models.DelByDictDetail(id)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

93
controllers/admin/JobController.go

@ -0,0 +1,93 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"viviman.top/controllers"
"viviman.top/models"
"viviman.top/vo"
)
// 岗位api
type JobController struct {
controllers.BaseController
}
func (c *JobController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 岗位列表
// @Description 岗位列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *JobController) GetAll() {
enabled, _ := c.GetInt64("enabled", -1)
total, list := models.GetAllJob(c.GetParams(), enabled)
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: total})
c.ServeJSON()
}
// @Title 岗位添加
// @Description 岗位添加
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *JobController) Post() {
var model models.SysJob
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddJob(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 岗位修改
// @Description 岗位修改
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *JobController) Put() {
var model models.SysJob
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByJob(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 岗位删除
// @Description 岗位删除
// @Success 200 {object} controllers.Result
// @router / [delete]
func (c *JobController) Delete() {
var ids []int64
json.Unmarshal(c.Ctx.Input.RequestBody, &ids)
logs.Info(ids)
e := models.DelByJob(ids)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

144
controllers/admin/LoginController.go

@ -0,0 +1,144 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/server/web/context"
"github.com/mojocn/base64Captcha"
"image/color"
"time"
"viviman.top/controllers"
"viviman.top/dto"
"viviman.top/jwt"
"viviman.top/models"
"viviman.top/untils"
"viviman.top/vo"
)
// 登录api
type LoginController struct {
controllers.BaseController
}
type CaptchaResult struct {
Id string `json:"id"`
Base64Blob string `json:"base_64_blob"`
VerifyValue string `json:"code"`
}
// 设置自带的store
var store = base64Captcha.DefaultMemStore
func (c *LoginController) URLMapping() {
c.Mapping("Login", c.Login)
c.Mapping("Captcha", c.Captcha)
c.Mapping("Info", c.Info)
c.Mapping("Logout", c.Logout)
}
// @Title 登录
// @Description 登录
// @Success 200 {object} controllers.Result
// @router /login [post]
func (c *LoginController) Login() {
var authUser *dto.AuthUser
err := json.Unmarshal(c.Ctx.Input.RequestBody, &authUser)
logs.Info(authUser)
if err == nil {
currentUser, e := models.GetUserByUsername(authUser.Username)
//校验验证码
if !store.Verify(authUser.Id, authUser.Code, true) {
c.Data["json"] = controllers.ErrMsg("验证码不对")
c.ServeJSON()
}
if e != nil {
c.Data["json"] = controllers.ErrMsg("用户不存在")
}
logs.Info("=======currentUser======")
logs.Info(currentUser)
if !untils.ComparePwd(currentUser.Password, []byte(authUser.Password)) {
c.Data["json"] = controllers.ErrMsg("密码错误")
} else {
token, _ := jwt.GenerateToken(currentUser, time.Hour*24*100)
var loginVO = new(vo.LoginVo)
loginVO.Token = token
loginVO.User = currentUser
c.Data["json"] = controllers.SuccessData(loginVO)
}
} else {
c.Data["json"] = controllers.ErrMsg(err.Error())
}
c.ServeJSON()
}
// @Title 获取用户信息
// @Description 获取用户信息
// @Success 200 {object} controllers.Result
// @router /info [get]
func (c *LoginController) Info() {
c.Data["json"] = controllers.SuccessData(jwt.GetAdminDetailUser(c.Ctx.Input))
c.ServeJSON()
}
// @Title 退出登录
// @Description 退出登录
// @Success 200 {object} controllers.Result
// @router /logout [delete]
func (c *LoginController) Logout() {
err := jwt.RemoveUser(c.Ctx.Input)
if err != nil {
c.Data["json"] = controllers.ErrMsg("退出失败")
} else {
c.Data["json"] = controllers.SuccessData("退出成功")
}
c.ServeJSON()
}
// @Title 获取验证码
// @Description 获取验证码
// @router /captcha [get]
func (c *LoginController) Captcha() {
GenerateCaptcha(c.Ctx)
c.ServeJSON()
}
// 生成图形化验证码 ctx *context.Context
func GenerateCaptcha(ctx *context.Context) {
var driver base64Captcha.Driver
var driverString base64Captcha.DriverMath
// 配置验证码信息
captchaConfig := base64Captcha.DriverMath{
Height: 38,
Width: 110,
NoiseCount: 0,
ShowLineOptions: 0,
BgColor: &color.RGBA{
R: 3,
G: 102,
B: 214,
A: 125,
},
Fonts: []string{"wqy-microhei.ttc"},
}
// 自定义配置,如果不需要自定义配置,则上面的结构体和下面这行代码不用写
driverString = captchaConfig
driver = driverString.ConvertFonts()
captcha := base64Captcha.NewCaptcha(driver, store)
id, b64s, err := captcha.Generate()
if err != nil {
logs.Error(err.Error())
}
captchaResult := CaptchaResult{
Id: id,
Base64Blob: b64s,
}
ctx.Output.JSON(controllers.SuccessData(captchaResult), true, true)
}

114
controllers/admin/MenuController.go

@ -0,0 +1,114 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/validation"
"viviman.top/controllers"
"viviman.top/jwt"
"viviman.top/models"
"viviman.top/vo"
)
// 菜单api
type MenuController struct {
controllers.BaseController
}
func (c *MenuController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Build", c.Build)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 菜单列表
// @Description 菜单列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *MenuController) GetAll() {
name := c.GetString("blurry")
menus := models.GetAllMenus(name)
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: menus, TotalElements: 0})
c.ServeJSON()
}
// @Title 菜单添加
// @Description 菜单添加
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *MenuController) Post() {
var model models.SysMenu
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddMenu(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 菜单修改
// @Description 菜单修改
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *MenuController) Put() {
var model models.SysMenu
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByMenu(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 菜单删除
// @Description 菜单删除
// @Success 200 {object} controllers.Result
// @router / [delete]
func (c *MenuController) Delete() {
var ids []int64
json.Unmarshal(c.Ctx.Input.RequestBody, &ids)
e := models.DelByMenu(ids)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 菜单构建
// @Description 菜单构建
// @Success 200 {object} controllers.Result
// @router /build [get]
func (c *MenuController) Build() {
uid, _ := jwt.GetAdminUserId(c.Ctx.Input)
menus := models.BuildMenus(uid)
c.Data["json"] = controllers.SuccessData(menus)
c.ServeJSON()
}
// @Title 菜单树形
// @Description 菜单树形
// @Success 200 {object} controllers.Result
// @router /tree [get]
func (c *MenuController) GetTree() {
menus := models.GetAllMenus("")
c.Data["json"] = controllers.SuccessData(menus)
c.ServeJSON()
}

125
controllers/admin/RoleController.go

@ -0,0 +1,125 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"strconv"
"viviman.top/controllers"
"viviman.top/dto"
"viviman.top/models"
"viviman.top/vo"
)
// 角色 API
type RoleController struct {
controllers.BaseController
}
func (c *RoleController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 获取单个角色
// @Description 获取单个角色
// @Param id path int true "角色ID"
// @Success 200 {object} models.Role
// @router /:id [get]
func (c *RoleController) GetOne() {
id := c.Ctx.Input.Param(":id")
id64, _ := strconv.ParseInt(id, 10, 64)
role := models.GetOneRole(id64)
c.Data["json"] = controllers.SuccessData(role)
c.ServeJSON()
}
// @Title 角色列表
// @Description 角色列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *RoleController) GetAll() {
total, list := models.GetAllRole(c.GetParams())
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: total})
c.ServeJSON()
}
// @Title 角色添加
// @Description 角色添加
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *RoleController) Post() {
var model models.SysRole
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddRole(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @router / [put]
func (c *RoleController) Put() {
var model models.SysRole
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByRole(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 角色删除
// @Description 角色删除
// @Success 200 {object} controllers.Result
// @router / [delete]
func (c *RoleController) Delete() {
var ids []int64
json.Unmarshal(c.Ctx.Input.RequestBody, &ids)
logs.Info(ids)
e := models.DelByRole(ids)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 角色菜单更新
// @Description 角色菜单更新
// @Success 200 {object} controllers.Result
// @router /menu [put]
func (c *RoleController) Menu() {
var model dto.RoleMenu
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
logs.Info("=======menu======")
logs.Info(model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
models.BatchRoleMenuAdd(model)
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

16
controllers/admin/ToolsController.go

@ -0,0 +1,16 @@
package admin
import (
"viviman.top/controllers"
)
type ToolsController struct {
controllers.BaseController
}
// @router / [post]
func (c *ToolsController) Post() {
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}

190
controllers/admin/UserController.go

@ -0,0 +1,190 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
beego "github.com/beego/beego/v2/server/web"
"viviman.top/controllers"
"viviman.top/dto"
"viviman.top/jwt"
"viviman.top/models"
"viviman.top/untils"
"viviman.top/vo"
)
// 用户 API
type UserController struct {
controllers.BaseController
}
func (c *UserController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// @Title 用户列表
// @Description 用户列表
// @Success 200 {object} controllers.Result
// @router / [get]
func (c *UserController) GetAll() {
deptId, _ := c.GetInt64("deptId", -1)
enabled, _ := c.GetInt64("enabled", -1)
total, list := models.GetAllUser(c.GetParams(), deptId, enabled)
c.Data["json"] = controllers.SuccessData(vo.ResultList{Content: list, TotalElements: total})
c.ServeJSON()
}
// @Title 用户添加
// @Description 用户添加
// @Success 200 {object} controllers.Result
// @router / [post]
func (c *UserController) Post() {
var model models.SysUser
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
_, e := models.AddUser(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 用户编辑
// @Description 用户编辑
// @Success 200 {object} controllers.Result
// @router / [put]
func (c *UserController) Put() {
var model models.SysUser
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
logs.Info("======start======")
logs.Info(model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
e := models.UpdateByUser(&model)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 用户删除
// @Description 用户删除
// @Success 200 {object} controllers.Result
// @router / [delete]
func (c *UserController) Delete() {
var ids []int64
json.Unmarshal(c.Ctx.Input.RequestBody, &ids)
e := models.DelByUser(ids)
if e != nil {
c.Data["json"] = controllers.ErrMsg(e.Error())
}
c.Data["json"] = controllers.SuccessData("操作成功")
c.ServeJSON()
}
// @Title 用户上传图像
// @Description 用户上传图像
// @Success 200 {object} controllers.Result
// @router /updateAvatar [post]
func (c *UserController) Avatar() {
logs.Info("======file start======")
f, h, err := c.GetFile("file")
if err != nil {
logs.Error(err)
}
defer f.Close()
var path = "static/upload/" + h.Filename
e := c.SaveToFile("file", path) // 保存位置在 static/upload, 没有文件夹要先创建
logs.Error(e)
apiUrl, _ := beego.AppConfig.String("api_url")
avatarUrl := apiUrl + "/" + path
//save user
uid, _ := jwt.GetAdminUserId(c.Ctx.Input)
user, _ := models.GetUserById(uid)
if user == nil {
c.Data["json"] = controllers.ErrMsg("非法操作")
} else {
user.Avatar = avatarUrl
models.UpdateCurrentUser(user)
c.Data["json"] = controllers.SuccessData("ok")
}
c.ServeJSON()
}
// @Title 用户修改密码
// @Description 用户修改密码
// @Success 200 {object} controllers.Result
// @router /updatePass [post]
func (c *UserController) Pass() {
var model dto.UserPass
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
}
//save user
uid, _ := jwt.GetAdminUserId(c.Ctx.Input)
user, _ := models.GetUserById(uid)
if user == nil {
c.Data["json"] = controllers.ErrMsg("非法操作")
} else {
if !untils.ComparePwd(user.Password, []byte(model.OldPass)) {
c.Data["json"] = controllers.ErrMsg("旧密码错误密码错误")
c.ServeJSON()
}
user.Password = untils.HashAndSalt([]byte(model.NewPass))
models.UpdateCurrentUser(user)
c.Data["json"] = controllers.SuccessData("ok")
}
c.ServeJSON()
}
// @Title 用户修改个人信息
// @Description 用户修改个人信息
// @Success 200 {object} controllers.Result
// @router /center [put]
func (c *UserController) Center() {
var model dto.UserPost
valid := validation.Validation{}
json.Unmarshal(c.Ctx.Input.RequestBody, &model)
b, _ := valid.Valid(&model)
if !b {
for _, err := range valid.Errors {
c.Data["json"] = controllers.ErrMsg(err.Message)
}
c.ServeJSON()
}
//save user
uid, _ := jwt.GetAdminUserId(c.Ctx.Input)
user, _ := models.GetUserById(uid)
if user == nil {
c.Data["json"] = controllers.ErrMsg("非法操作")
} else {
user.Phone = model.Phone
user.Sex = model.Sex
user.NickName = model.NickName
models.UpdateCurrentUser(user)
c.Data["json"] = controllers.SuccessData("ok")
}
c.ServeJSON()
}

8
dto/AuthUser.go

@ -0,0 +1,8 @@
package dto
type AuthUser struct {
Code string `json:"code"`
Password string `json:"password"`
Username string `json:"username"`
Id string `json:"uuid"`
}

7
dto/BasePage.go

@ -0,0 +1,7 @@
package dto
type BasePage struct {
Page int
Size int
Blurry string
}

7
dto/DictPost.go

@ -0,0 +1,7 @@
package dto
type DictPost struct {
Id int64 `json:"id"`
Name string `json:"name"`
Remark string `json:"remark"`
}

6
dto/DictQuery.go

@ -0,0 +1,6 @@
package dto
type DictQuery struct {
BasePage
Blurry string
}

10
dto/RoleMenu.go

@ -0,0 +1,10 @@
package dto
type RoleMenu struct {
Id int64 `json:"id"`
Menus []Menu `json:"menus" valid:"Required;"`
}
type Menu struct {
Id int64 `json:"id"`
}

6
dto/UserPass.go

@ -0,0 +1,6 @@
package dto
type UserPass struct {
OldPass string `json:"oldPass" valid:"Required;"`
NewPass string `json:"newPass" valid:"Required;"`
}

8
dto/UserPost.go

@ -0,0 +1,8 @@
package dto
type UserPost struct {
Id int64 `json:"id"`
NickName string `json:"nickName" valid:"Required;"`
Phone string `json:"phone" valid:"Required;"`
Sex string `json:"sex"`
}

8
dto/UserQuery.go

@ -0,0 +1,8 @@
package dto
type UserQuery struct {
BasePage
Sort string
Blurry string
Enabled bool
}

15
go.mod

@ -0,0 +1,15 @@
module viviman.top
go 1.15
require github.com/beego/beego/v2 v2.0.1
require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-sql-driver/mysql v1.5.0
github.com/gomodule/redigo v2.0.0+incompatible
github.com/mojocn/base64Captcha v1.3.1
github.com/smartystreets/goconvey v1.6.4
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 // indirect
)

141
jwt/jwt.go

@ -0,0 +1,141 @@
package jwt
import (
"encoding/json"
"errors"
"fmt"
"github.com/beego/beego/v2/core/logs"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context"
"github.com/dgrijalva/jwt-go"
"strconv"
"strings"
"time"
"viviman.top/common"
"viviman.top/models"
"viviman.top/redis"
"viviman.top/vo"
)
type userStdClaims struct {
vo.JwtUser
//*models.User
jwt.StandardClaims
}
var (
verifyKey string
ErrAbsent = "token absent" // 令牌不存在
ErrInvalid = "token invalid" // 令牌无效
ErrExpired = "token expired" // 令牌过期
ErrOther = "other error" // 其他错误
)
const bearerLength = len("Bearer ")
func init() {
verifyKey, _ = beego.AppConfig.String("jwt_token")
}
func GenerateToken(m *models.SysUser, d time.Duration) (string, error) {
m.Password = ""
//m.Permissions = []string{}
expireTime := time.Now().Add(d)
stdClaims := jwt.StandardClaims{
ExpiresAt: expireTime.Unix(),
Id: strconv.FormatInt(m.Id, 10),
Issuer: "YshopGo",
}
var jwtUser = vo.JwtUser{
Id: m.Id,
Avatar: m.Avatar,
Email: m.Email,
Username: m.Username,
Phone: m.Phone,
NickName: m.NickName,
Sex: m.Sex,
Dept: m.Depts.Name,
Job: m.Jobs.Name,
}
uClaims := userStdClaims{
StandardClaims: stdClaims,
JwtUser: jwtUser,
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, uClaims)
tokenString, err := token.SignedString([]byte(verifyKey))
if err != nil {
logs.Info(err)
}
//set redis
var key = common.REDIS_PREFIX_AUTH + tokenString
json, _ := json.Marshal(m)
redis.SetEx(key, string(json), expireTime.Unix())
return tokenString, err
}
func ValidateToken(tokenString string) (*vo.JwtUser, error) {
if tokenString == "" {
return nil, errors.New(ErrAbsent)
}
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
return []byte(verifyKey), nil
})
if token == nil {
return nil, errors.New(ErrInvalid)
}
claims := userStdClaims{}
_, err = jwt.ParseWithClaims(tokenString, &claims, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}
return []byte(verifyKey), nil
})
if err != nil {
return nil, err
}
return &claims.JwtUser, err
}
//返回id
func GetAdminUserId(c *context.BeegoInput) (int64, error) {
u := c.GetData(common.ContextKeyUserObj)
user, ok := u.(*vo.JwtUser)
if ok {
return user.Id, nil
}
return 0, errors.New("can't convert to user struct")
}
//返回user
func GetAdminUser(c *context.BeegoInput) (*vo.JwtUser, error) {
u := c.GetData(common.ContextKeyUserObj)
user, ok := u.(*vo.JwtUser)
if ok {
return user, nil
}
return nil, errors.New("can't convert to user struct")
}
//返回 detail user
func GetAdminDetailUser(c *context.BeegoInput) *models.SysUser {
mytoken := c.Header("Authorization")
token := strings.TrimSpace(mytoken[bearerLength:])
var key = common.REDIS_PREFIX_AUTH + token
userMap, _ := redis.Get(key)
jsonStr := userMap[key]
user := &models.SysUser{}
json.Unmarshal([]byte(jsonStr), user)
return user
}
func RemoveUser(c *context.BeegoInput) error {
mytoken := c.Header("Authorization")
token := strings.TrimSpace(mytoken[bearerLength:])
var key = common.REDIS_PREFIX_AUTH + token
return redis.Del(key)
}

130
main.go

@ -0,0 +1,130 @@
package main
import (
"encoding/json"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context"
_ "github.com/go-sql-driver/mysql"
"log"
"regexp"
"strings"
"time"
"viviman.top/common"
"viviman.top/controllers"
"viviman.top/jwt"
"viviman.top/models"
"viviman.top/redis"
_ "viviman.top/routers"
"viviman.top/untils"
)
const bearerLength = len("Bearer ")
func init() {
//初始化数据库
dbUser, _ := beego.AppConfig.String("mysqluser")
dbPass, _ := beego.AppConfig.String("mysqlpass")
dbName, _ := beego.AppConfig.String("mysqldb")
dbHost, _ := beego.AppConfig.String("mysqlhost")
dbPort, _ := beego.AppConfig.String("mysqlport")
maxIdleConn, _ := beego.AppConfig.Int("db_max_idle_conn")
maxOpenConn, _ := beego.AppConfig.Int("db_max_open_open")
orm.RegisterDriver("mysql", orm.DRMySQL)
orm.RegisterDataBase("default", "mysql",
dbUser+":"+dbPass+"@tcp("+dbHost+":"+dbPort+")/"+dbName+"?charset=utf8&parseTime=true&loc=Asia%2FShanghai",
)
orm.MaxIdleConnections(maxIdleConn)
orm.MaxOpenConnections(maxOpenConn)
orm.DefaultTimeLoc = time.UTC
if beego.BConfig.RunMode == "dev" {
orm.Debug = true
}
//日志
logs.Async()
level, _ := beego.AppConfig.Int("logLevel")
logs.SetLevel(level)
logs.SetLogger(logs.AdapterMultiFile, `{"filename":"./logs/yshop.log",
"level":6,"maxlines":0,"maxsize":0,"daily":true,"maxdays":30,
"separate":["emergency", "alert", "critical", "error", "warning", "notice", "info"]}`)
}
func main() {
log.Print("==========VIVIB管理后台 start=============")
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
//
beego.InsertFilterChain("/*", func(next beego.FilterFunc) beego.FilterFunc {
return func(ctx *context.Context) {
url := ctx.Input.URL()
ignoreUrls, _ := beego.AppConfig.String("ignore_urls")
if strings.Contains(ignoreUrls, url) || strings.Contains(url, "/swagger") || strings.Contains(url, "/static") {
next(ctx)
} else {
//method := strings.ToLower(ctx.Input.Method())
//部署线上开启 = 验证请求类型,避免线上请求非发类型,导致系统异常
//prohibit := "post,put,delete"
//if url != "/admin/auth/logout" && strings.Contains(prohibit,method) {
// ctx.Output.JSON(controllers.ErrMsg("演示环境禁止操作",40006),
// true,true)
// return
//}
mytoken := ctx.Input.Header("Authorization")
if len(mytoken) < bearerLength {
ctx.Output.Status = 401
ctx.Output.JSON(controllers.ErrMsg("header Authorization has not Bearer token", 40001),
true, true)
return
}
token := strings.TrimSpace(mytoken[bearerLength:])
usr, err := jwt.ValidateToken(token)
if err != nil {
ctx.Output.Status = 401
ctx.Output.JSON(controllers.ErrMsg(err.Error(), 40001),
true, true)
return
}
//校验权限 = 验证权限部分,不推荐打开,否则基本功能无法实现
//index := checkPermission(url, method, token)
//if index == -1 {
// ctx.Output.JSON(controllers.ErrMsg("无权限", 40001), true, true)
// return
//}
ctx.Input.SetData(common.ContextKeyUserObj, usr)
next(ctx)
}
}
})
beego.Run()
}
// checkPermission 验证请求权限情况
func checkPermission(url string, method string, token string) int {
logs.Info(url, method, token, method)
//公共路由直接放行
var ignoreUrls = "/admin/menu/build,/admin/user/center,/admin/user/updatePass,/admin/auth/info,/admin/auth/logout"
if strings.Contains(ignoreUrls, url) {
return 0
}
reg := regexp.MustCompile(`[0-9]+`)
newUrl := reg.ReplaceAllString(url, "*")
permission := models.FindByRouterAndMethod(newUrl, method)
var key = common.REDIS_PREFIX_AUTH + token
userMap, _ := redis.Get(key)
jsonStr := userMap[key]
user := &models.SysUser{}
json.Unmarshal([]byte(jsonStr), user)
index := untils.Contains(user.Permissions, permission)
return index
}

43
models/BaseModel.go

@ -0,0 +1,43 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"strconv"
"time"
)
type BaseModel struct {
UpdateTime time.Time `orm:"auto_now_add;type(datetime)" json:"updateTime"`
CreateTime time.Time `orm:"auto_now;type(datetime)" json:"createTime"`
IsDel int8 `json:"isDel"`
}
/**
* 分页函数适用任何表
* 返回 总记录条数,总页数,以及当前请求的数据RawSeter,调用中需要"rs.QueryRows(&tblog)"就行了 --tblog是一个Tb_log对象
* 参数表名当前页数页面大小条件查询条件,格式为 " and name='zhifeiya' and age=12 "
*/
func GetPagesInfo(tableName string, currentpage int, pagesize int, conditions string) (int, int, orm.RawSeter) {
if currentpage <= 1 {
currentpage = 1
}
if pagesize == 0 {
pagesize = 20
}
var rs orm.RawSeter
o := orm.NewOrm()
var totalItem, totalpages int = 0, 0 //总条数,总页数
o.Raw("SELECT count(*) FROM " + tableName + " where is_del=0 " + conditions).QueryRow(&totalItem) //获取总条数
if totalItem <= pagesize {
totalpages = 1
} else if totalItem > pagesize {
temp := totalItem / pagesize
if (totalItem % pagesize) != 0 {
temp = temp + 1
}
totalpages = temp
}
rs = o.Raw("select * from " + tableName + " where is_del=0 " + conditions +
" LIMIT " + strconv.Itoa((currentpage-1)*pagesize) + "," + strconv.Itoa(pagesize))
return totalItem, totalpages, rs
}

68
models/SysDept.go

@ -0,0 +1,68 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"viviman.top/untils"
)
type SysDept struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Pid int64 `json:"pid"`
Enabled int8 `json:"enabled" valid:"Required;"`
Children []SysDept `orm:"-" json:"children"`
Label string `orm:"-" json:"label"`
BaseModel
}
func init() {
orm.RegisterModel(new(SysDept))
}
func GetAllDepts(name string, enabled int8) []SysDept {
var depts []SysDept
o := orm.NewOrm()
qs := o.QueryTable("sys_dept").Filter("is_del", 0)
if name != "" {
qs = qs.Filter("name", name)
}
if enabled > -1 {
qs = qs.Filter("enabled", enabled)
}
qs.All(&depts)
return RecursionDeptList(depts, 0)
}
//递归函数
func RecursionDeptList(data []SysDept, pid int64) []SysDept {
var listTree = make([]SysDept, 0)
for _, value := range data {
value.Label = value.Name
if value.Pid == pid {
value.Children = RecursionDeptList(data, value.Id)
listTree = append(listTree, value)
}
}
return listTree
}
func AddDept(m *SysDept) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDept(m *SysDept) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByDept(ids []int64) (err error) {
str := untils.ReturnQ(len(ids))
logs.Info(str)
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_dept SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

56
models/SysDict.go

@ -0,0 +1,56 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"viviman.top/dto"
)
type SysDict struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Remark string `json:"remark" valid:"Required;"`
BaseModel
}
func init() {
orm.RegisterModel(new(SysDict))
}
// get all
func GetAllDict(base dto.BasePage, query ...interface{}) (int, []SysDict) {
var (
tableName = "sys_dict"
dicts []SysDict
condition = ""
)
if base.Blurry != "" {
condition = " and name= '" + base.Blurry + "'"
}
logs.Info(base)
total, _, rs := GetPagesInfo(tableName, base.Page, base.Size, condition)
rs.QueryRows(&dicts)
//o := orm.NewOrm()
return total, dicts
}
// last inserted Id on success.
func AddDict(m *SysDict) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDict(m *SysDict) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByDict(id int64) (err error) {
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_dict SET is_del = ? WHERE id = ?", 1, id).Exec()
return
}

65
models/SysDictDetail.go

@ -0,0 +1,65 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"strconv"
"viviman.top/dto"
)
type SysDictDetail struct {
Id int64 `json:"id"`
Label string `json:"label" valid:"Required;"`
Value string `json:"value" valid:"Required;"`
Sort int `json:"sort"`
DictId int64 `json:"dictId"`
DictName string `json:"dictName"`
BaseModel
}
func init() {
orm.RegisterModel(new(SysDictDetail))
}
// get all
func GetAllDictDetail(base dto.BasePage, query ...interface{}) (int, []SysDictDetail) {
var (
tableName = "sys_dict_detail"
lists []SysDictDetail
condition = ""
)
if base.Blurry != "" {
condition = " and label= '" + base.Blurry + "'"
}
if len(query) > 0 {
dictId := query[0].(int64)
if dictId > 0 {
condition += " and dict_id=" + strconv.FormatInt(dictId, 10)
}
if len(query) > 1 {
condition += " and dict_name= '" + query[1].(string) + "'"
}
}
total, _, rs := GetPagesInfo(tableName, base.Page, base.Size, condition)
rs.QueryRows(&lists)
return total, lists
}
func AddDictDetail(m *SysDictDetail) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDictDetail(m *SysDictDetail) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByDictDetail(id int64) (err error) {
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_dict_detail SET is_del = ? WHERE id = ?", 1, id).Exec()
return
}

69
models/SysJob.go

@ -0,0 +1,69 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"strconv"
"viviman.top/dto"
"viviman.top/untils"
)
type SysJob struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Enabled int8 `json:"enabled"`
Sort int8 `json:"sort"`
//DeptId int64 `json:"deptId"`
Dept *SysDept `json:"dept" orm:"column(dept_id);bigint;rel(one)""`
BaseModel
}
func init() {
orm.RegisterModel(new(SysJob))
}
// get all
func GetAllJob(base dto.BasePage, query ...interface{}) (int, []SysJob) {
var (
tableName = "sys_job"
lists []SysJob
condition = ""
)
if base.Blurry != "" {
condition = " and name= '" + base.Blurry + "'"
}
if len(query) > 0 {
enabled := query[0].(int64)
if enabled >= 0 {
condition += " and enabled=" + strconv.FormatInt(enabled, 10)
}
}
total, _, rs := GetPagesInfo(tableName, base.Page, base.Size, condition)
rs.QueryRows(&lists)
o := orm.NewOrm()
for k, _ := range lists {
_, _ = o.LoadRelated(&lists[k], "Dept")
}
return total, lists
}
func AddJob(m *SysJob) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByJob(m *SysJob) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByJob(ids []int64) (err error) {
str := untils.ReturnQ(len(ids))
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_job SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

23
models/SysLog.go

@ -0,0 +1,23 @@
package models
import "github.com/beego/beego/v2/client/orm"
type SysLog struct {
Id int64
Description string
ExceptionDetail string
LogType string
Method string
Params string
RequestIp string
Username string
Address string
Browser string
Type int8
Uid int64
BaseModel
}
func init() {
orm.RegisterModel(new(SysLog))
}

195
models/SysMenu.go

@ -0,0 +1,195 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"viviman.top/untils"
"viviman.top/vo/menu"
)
type SysMenu struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
IFrame int8 `json:"iframe"`
Component string `json:"component"`
Pid int64 `json:"pid"`
Sort int32 `json:"sort"`
Icon string `json:"icon"`
Path string `json:"path"`
Cache int8 `json:"cache"`
Hidden int8 `json:"hidden"`
ComponentName string `json:"componentName"`
Permission string `json:"permission"`
Type int32 `json:"type"`
Router string `json:"router"`
RouterMethod string `json:"routerMethod"`
Children []SysMenu `json:"children" orm:"-"`
Label string `orm:"-" json:"label"`
BaseModel
}
func init() {
orm.RegisterModel(new(SysMenu))
}
func GetAllMenus(name string) []SysMenu {
var menus []SysMenu
o := orm.NewOrm()
qs := o.QueryTable("sys_menu").Filter("is_del", 0)
if name != "" {
qs = qs.Filter("name", name)
}
qs.All(&menus)
return RecursionMenuList(menus, 0)
}
//递归函数
func RecursionMenuList(data []SysMenu, pid int64) []SysMenu {
var listTree = make([]SysMenu, 0)
for _, value := range data {
value.Label = value.Name
if value.Pid == pid {
value.Children = RecursionMenuList(data, value.Id)
listTree = append(listTree, value)
}
}
return listTree
}
func AddMenu(m *SysMenu) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByMenu(m *SysMenu) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByMenu(ids []int64) (err error) {
str := untils.ReturnQ(len(ids))
logs.Info(str)
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_menu SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}
//获取权限string
func FindByRouterAndMethod(url string, method string) (permission string) {
o := orm.NewOrm()
var menu SysMenu
err := o.QueryTable(new(SysMenu)).Filter("router", url).Filter("router_method", method).One(&menu)
if err != nil {
return ""
}
return menu.Permission
}
func BuildMenus(uid int64) []menu.MenuVo {
o := orm.NewOrm()
var lists orm.ParamsList
_, err := o.Raw("SELECT r.* FROM sys_role r, sys_users_roles u "+
"WHERE r.id = u.role_id AND u.user_id = ?", uid).ValuesFlat(&lists, "id")
if err != nil {
logs.Error(err)
}
idsStr := untils.Convert(lists)
logs.Info(idsStr)
var menus []SysMenu
_, e := o.Raw("select m.* from sys_menu m LEFT OUTER JOIN sys_roles_menus t on m.id= t.menu_id "+
"LEFT OUTER JOIN sys_role r on r.id = t.role_id where m.is_del=0 and m.hidden=0 and m.type!=2 and r.id in (?)",
idsStr).QueryRows(&menus)
if e != nil {
logs.Error(e)
}
return buildMenus(buildTree(menus))
}
func buildTree(menus []SysMenu) []SysMenu {
var trees []SysMenu
for _, menu := range menus {
if menu.Pid == 0 {
trees = append(trees, menu)
}
}
for k, tree := range trees {
var child []SysMenu
for _, it := range menus {
if it.Pid == tree.Id {
child = append(child, it)
}
}
trees[k].Children = child
}
return trees
}
func buildMenus(menus []SysMenu) []menu.MenuVo {
var list []menu.MenuVo
for _, menuO := range menus {
menuList := menuO.Children
var menuVo = new(menu.MenuVo)
if menuO.ComponentName != "" {
menuVo.Name = menuO.ComponentName
} else {
menuVo.Name = menuO.Name
}
if menuO.Pid == 0 {
menuVo.Path = "/" + menuO.Path
} else {
menuVo.Path = menuO.Path
}
menuVo.Hidden = menuO.Hidden
//判断不是外链
if menuO.IFrame == 0 {
if menuO.Pid == 0 {
if menuO.Component == "" {
menuVo.Component = "Layout"
} else {
menuVo.Component = menuO.Component
}
} else if menuO.Component != "" {
menuVo.Component = menuO.Component
}
}
menuVo.Meta = menu.MenuMetaVo{Title: menuO.Name, Icon: menuO.Icon, NoCache: !untils.IntToBool(menuO.Cache)}
if len(menuList) > 0 {
menuVo.AlwaysShow = true
menuVo.Redirect = "noredirect"
menuVo.Children = buildMenus(menuList)
} else if menuO.Pid == 0 {
var menuVo1 = new(menu.MenuVo)
menuVo1.Meta = menuVo.Meta
if menuO.IFrame == 0 {
menuVo1.Path = "index"
menuVo1.Name = menuVo.Name
menuVo1.Component = menuVo.Component
} else {
menuVo1.Path = menuO.Path
}
menuVo.Name = ""
menuVo.Meta = menu.MenuMetaVo{}
menuVo.Component = "Layout"
var list1 []menu.MenuVo
list1 = append(list1, *menuVo1)
menuVo.Children = list1
}
list = append(list, *menuVo)
}
return list
}

20
models/SysPicture.go

@ -0,0 +1,20 @@
package models
import "github.com/beego/beego/v2/client/orm"
type SysPicture struct {
Id int64
DeleteUrl string
Filename string
Height string
Size string
Url string
Username string
Width string
Md5code string
BaseModel
}
func init() {
orm.RegisterModel(new(SysPicture))
}

73
models/SysRole.go

@ -0,0 +1,73 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"viviman.top/dto"
"viviman.top/untils"
)
type SysRole struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Remark string `json:"remark"`
DataScope string `json:"dataScope"`
Level int32 `json:"level"`
Permission string `json:"permission"`
Users []*SysUser `orm:"reverse(many)"`
Menus []*SysMenu `json:"menus" orm:"rel(m2m);rel_through(viviman.top/models.SysRolesMenus)"`
Depts []*SysDept `orm:"rel(m2m);rel_through(viviman.top/models.SysRolesDepts)"`
BaseModel
}
func init() {
orm.RegisterModel(new(SysRole))
}
func GetOneRole(id int64) SysRole {
o := orm.NewOrm()
role := SysRole{Id: id}
o.Read(&role)
_, _ = o.LoadRelated(&role, "Menus")
return role
}
// get all
func GetAllRole(base dto.BasePage, query ...interface{}) (int, []SysRole) {
var (
tableName = "sys_role"
lists []SysRole
condition = ""
)
if base.Blurry != "" {
condition = " and name= '" + base.Blurry + "'"
}
total, _, rs := GetPagesInfo(tableName, base.Page, base.Size, condition)
rs.QueryRows(&lists)
o := orm.NewOrm()
for k, _ := range lists {
_, _ = o.LoadRelated(&lists[k], "Menus")
}
return total, lists
}
func AddRole(m *SysRole) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByRole(m *SysRole) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByRole(ids []int64) (err error) {
str := untils.ReturnQ(len(ids))
o := orm.NewOrm()
_, err = o.Raw("UPDATE sys_role SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

13
models/SysRoleDepts.go

@ -0,0 +1,13 @@
package models
import "github.com/beego/beego/v2/client/orm"
type SysRolesDepts struct {
Id int64
RoleId *SysRole `orm:"column(role_id);rel(fk)"`
DeptId *SysDept `orm:"column(dept_id);rel(fk)"`
}
func init() {
orm.RegisterModel(new(SysRolesDepts))
}

30
models/SysRoleMenus.go

@ -0,0 +1,30 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"viviman.top/dto"
)
type SysRolesMenus struct {
Id int64
MenuId *SysMenu `orm:"column(menu_id);rel(fk)"`
RoleId *SysRole `orm:"column(role_id);rel(fk)"`
}
func init() {
orm.RegisterModel(new(SysRolesMenus))
}
func BatchRoleMenuAdd(menu dto.RoleMenu) {
o := orm.NewOrm()
o.Raw("delete from sys_roles_menus WHERE role_id = ?", menu.Id).Exec()
var roleMenus []SysRolesMenus
for _, val := range menu.Menus {
var menus = SysMenu{Id: val.Id}
var roles = SysRole{Id: menu.Id}
roleMenus = append(roleMenus, SysRolesMenus{MenuId: &menus, RoleId: &roles})
}
o.InsertMulti(100, roleMenus)
}

200
models/SysUser.go

@ -0,0 +1,200 @@
package models
import (
"context"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"strconv"
"viviman.top/dto"
"viviman.top/untils"
)
type SysUser struct {
Id int64 `json:"id"`
Avatar string `json:"avatar"`
Email string `json:"email"`
Enabled int8 `json:"enabled"`
Password string `json:"password"`
Username string `json:"username" valid:"Required;"`
//DeptId int32
Phone string `json:"phone"`
//JobId int32
NickName string `json:"nickName"`
Sex string `json:"sex"`
Roles []*SysRole `json:"roles" orm:"rel(m2m);rel_through(viviman.top/models.SysUsersRoles)"`
Jobs *SysJob `json:"job" orm:"column(job_id);bigint;rel(one)""`
Depts *SysDept `json:"dept" orm:"column(dept_id);bigint;rel(one)""`
Permissions []string `orm:"-"`
RoleIds []int64 `json:"roleIds" orm:"-"`
BaseModel
}
type RoleId struct {
Id int64 `json:"id"`
}
func init() {
orm.RegisterModel(new(SysUser))
}
func FindByUserId(id int64) ([]string, error) {
o := orm.NewOrm()
var roles []SysRole
_, err := o.Raw("SELECT r.* FROM sys_role r, sys_users_roles u "+
"WHERE r.id = u.role_id AND u.user_id = ?", id).QueryRows(&roles)
for k, _ := range roles {
_, err = o.LoadRelated(&roles[k], "Menus")
}
var permissions []string
for _, v := range roles {
menus := v.Menus
for _, m := range menus {
if m.Permission == "" {
continue
}
permissions = append(permissions, m.Permission)
}
}
return permissions, err
}
//根据用户名返回
func GetUserByUsername(name string) (v *SysUser, err error) {
o := orm.NewOrm()
user := &SysUser{}
err = o.QueryTable(new(SysUser)).Filter("username", name).RelatedSel().One(user)
if _, err = o.LoadRelated(user, "Roles"); err != nil {
return nil, err
}
if err == nil {
permissions, _ := FindByUserId(user.Id)
user.Permissions = permissions
return user, nil
}
return nil, err
}
// GetUserById retrieves User by Id. Returns error if
// Id doesn't exist
func GetUserById(id int64) (v *SysUser, err error) {
//var userlist []User
o := orm.NewOrm()
v = &SysUser{Id: id}
err = o.QueryTable(new(SysUser)).Filter("Id", id).RelatedSel().One(v)
if _, err = o.LoadRelated(v, "Roles"); err != nil {
return nil, err
}
if err == nil {
return v, nil
}
return nil, err
}
// get all
func GetAllUser(base dto.BasePage, query ...interface{}) (int, []SysUser) {
var (
tableName = "sys_user"
users []SysUser
condition = ""
)
if base.Blurry != "" {
condition = " and username= '" + base.Blurry + "'"
}
if len(query) > 0 {
deptId := query[0].(int64)
enabled := query[1].(int64)
if deptId >= 0 {
condition += " and dept_id=" + strconv.FormatInt(deptId, 10)
}
if enabled >= 0 {
condition += " and enabled=" + strconv.FormatInt(enabled, 10)
}
}
total, _, rs := GetPagesInfo(tableName, base.Page, base.Size, condition)
rs.QueryRows(&users)
o := orm.NewOrm()
for k, _ := range users {
_, _ = o.LoadRelated(&users[k], "Jobs")
_, _ = o.LoadRelated(&users[k], "Depts")
_, _ = o.LoadRelated(&users[k], "Roles")
}
return total, users
}
func UpdateCurrentUser(m *SysUser) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func AddUser(m *SysUser) (id int64, err error) {
o := orm.NewOrm()
//transaction
err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
// data
m.Password = untils.HashAndSalt([]byte("123456"))
id, e := txOrm.Insert(m)
if e != nil {
return e
}
var ee error
// add user_role
for _, roleId := range m.RoleIds {
_, ee = txOrm.Raw("INSERT INTO sys_users_roles (user_id,role_id) VALUES (?,?)", id, roleId).Exec()
}
return ee
})
return 0, err
}
func UpdateByUser(m *SysUser) (err error) {
o := orm.NewOrm()
//transaction
err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
// data
_, e := txOrm.Update(m)
if e != nil {
return e
}
//先删除
_, eee := txOrm.Raw("delete from sys_users_roles WHERE user_id = ?", m.Id).Exec()
if eee != nil {
return eee
}
var ee error
for _, roleId := range m.RoleIds {
_, ee = txOrm.Raw("INSERT INTO sys_users_roles (user_id,role_id) VALUES (?,?)", m.Id, roleId).Exec()
}
return ee
})
logs.Error(err)
return
}
func DelByUser(ids []int64) (err error) {
str := untils.ReturnQ(len(ids))
o := orm.NewOrm()
err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
_, e1 := txOrm.Raw("UPDATE sys_user SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
_, e2 := txOrm.Raw("delete from sys_users_roles WHERE user_id in("+str+")", ids).Exec()
if e1 != nil {
return e1
}
return e2
})
return
}

21
models/SysUsersRoles.go

@ -0,0 +1,21 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
)
type SysUsersRoles struct {
Id int64
UserId *SysUser `orm:"column(user_id);rel(fk)"`
RoleId *SysRole `orm:"column(role_id);rel(fk)"`
}
func init() {
orm.RegisterModel(new(SysUsersRoles))
}
func AddUserRole(m *SysUsersRoles) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}

63
redis/pool.go

@ -0,0 +1,63 @@
package redis
import (
beego "github.com/beego/beego/v2/server/web"
"github.com/gomodule/redigo/redis"
"os"
"os/signal"
"syscall"
"time"
)
var (
Pool *redis.Pool
)
func init() {
host, _ := beego.AppConfig.String("redis_host")
pwd, _ := beego.AppConfig.String("redis_pwd")
Pool = newPool(host, pwd)
cleanupHook()
}
func newPool(server string, pwd string) *redis.Pool {
return &redis.Pool{
MaxIdle: 3,
IdleTimeout: 240 * time.Second,
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", server)
if err != nil {
return nil, err
}
//处理密码
if pwd != "" {
_, err = c.Do("AUTH", pwd)
if err != nil {
return nil, err
}
}
return c, err
},
TestOnBorrow: func(c redis.Conn, t time.Time) error {
_, err := c.Do("PING")
return err
},
}
}
func cleanupHook() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
signal.Notify(c, syscall.SIGKILL)
go func() {
<-c
Pool.Close()
os.Exit(0)
}()
}

59
redis/redis.go

@ -0,0 +1,59 @@
package redis
func Set(key, val string) error {
client := Pool.Get()
defer client.Close()
_, err := client.Do("SET", key, val)
return err
}
func SetEx(key, val string, exp int64) error {
client := Pool.Get()
defer client.Close()
_, err := client.Do("SETEX", key, exp, val)
return err
}
func Get(key string) (map[string]string, error) {
client := Pool.Get()
defer client.Close()
rsp := make(map[string]string)
res, err := client.Do("GET", key)
rsp[key] = string(res.([]byte))
return rsp, err
}
func LPush(key, val string) error {
client := Pool.Get()
defer client.Close()
_, err := client.Do("lpush", key, val)
return err
}
func LPop(key string) (interface{}, error) {
client := Pool.Get()
defer client.Close()
res, err := client.Do("lpop", key)
return res, err
}
func RPush(key, val string) error {
client := Pool.Get()
defer client.Close()
_, err := client.Do("rpush", key, val)
return err
}
func RPop(key string) (interface{}, error) {
client := Pool.Get()
defer client.Close()
res, err := client.Do("rpop", key)
return res, err
}
func Del(key string) error {
client := Pool.Get()
defer client.Close()
_, err := client.Do("DEL", key)
return err
}

370
routers/commentsRouter_.go

@ -0,0 +1,370 @@
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context/param"
)
func init() {
beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:id",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:id",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Captcha",
Router: "/captcha",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Info",
Router: "/info",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Login",
Router: "/login",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Logout",
Router: "/logout",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Build",
Router: "/build",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "GetTree",
Router: "/tree",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "GetOne",
Router: "/:id",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Menu",
Router: "/menu",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:ToolsController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:ToolsController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Center",
Router: "/center",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Avatar",
Router: "/updateAvatar",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["viviman.top/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Pass",
Router: "/updatePass",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

66
routers/router.go

@ -0,0 +1,66 @@
// @APIVersion 1.0.0
// @Title VIVIB API
// @Description VIVIB管理系统API
// @TermsOfServiceUrl https://www.yixiang.co/
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"viviman.top/controllers/admin"
)
func init() {
//移动端路由
ns1 := beego.NewNamespace("/v1",
beego.NSNamespace("/mem",
beego.NSInclude(),
),
)
//管理后台路由
ns2 := beego.NewNamespace("/admin",
beego.NSNamespace("/auth",
beego.NSInclude(
&admin.LoginController{},
),
),
beego.NSNamespace("/user",
beego.NSInclude(
&admin.UserController{},
),
),
beego.NSNamespace("/menu",
beego.NSInclude(
&admin.MenuController{},
),
),
beego.NSNamespace("/dict",
beego.NSInclude(
&admin.DictController{},
),
),
beego.NSNamespace("/dictDetail",
beego.NSInclude(
&admin.DictDetailController{},
),
),
beego.NSNamespace("/dept",
beego.NSInclude(
&admin.DeptController{},
),
),
beego.NSNamespace("/job",
beego.NSInclude(
&admin.JobController{},
),
),
beego.NSNamespace("/roles",
beego.NSInclude(
&admin.RoleController{},
),
),
)
beego.AddNamespace(ns1, ns2)
//beego.SetStaticPath("/swagger/", "swagger")
}

424
sql/yshop_go.sql

@ -0,0 +1,424 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80021
Source Host : localhost:3306
Source Schema : yshop_go
Target Server Type : MySQL
Target Server Version : 80021
File Encoding : 65001
Date: 27/04/2021 16:53:40
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_dept
-- ----------------------------
DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
`pid` bigint NOT NULL COMMENT '上级部门',
`enabled` tinyint(1) NOT NULL COMMENT '状态',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门';
-- ----------------------------
-- Records of sys_dept
-- ----------------------------
BEGIN;
INSERT INTO `sys_dept` VALUES (1, 'YSHOP', 0, 1, '2021-02-26 14:51:14', NULL, 0);
INSERT INTO `sys_dept` VALUES (2, '研发部', 7, 1, '2019-03-25 09:15:32', NULL, 0);
INSERT INTO `sys_dept` VALUES (5, '运维部', 7, 1, '2019-03-25 09:20:44', NULL, 0);
INSERT INTO `sys_dept` VALUES (6, '测试部', 8, 0, '2021-02-25 16:22:53', NULL, 0);
INSERT INTO `sys_dept` VALUES (7, '华南分部', 1, 1, '2019-03-25 11:04:50', NULL, 0);
INSERT INTO `sys_dept` VALUES (8, '华北分部', 1, 1, '2019-03-25 11:04:53', NULL, 0);
INSERT INTO `sys_dept` VALUES (11, '人事部', 8, 1, '2019-03-25 11:07:58', NULL, 0);
INSERT INTO `sys_dept` VALUES (12, '7773888', 1, 1, '2021-02-26 15:04:43', NULL, 1);
INSERT INTO `sys_dept` VALUES (13, '333', 1, 0, '2021-02-26 14:28:26', '2021-02-26 14:28:26', 1);
INSERT INTO `sys_dept` VALUES (14, '9922', 13, 1, '2021-02-26 15:05:05', '2021-02-26 14:29:17', 1);
COMMIT;
-- ----------------------------
-- Table structure for sys_dict
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典名称',
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '描述',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='数据字典';
-- ----------------------------
-- Records of sys_dict
-- ----------------------------
BEGIN;
INSERT INTO `sys_dict` VALUES (1, 'user_status', '用户状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `sys_dict` VALUES (4, 'dept_status', '部门状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `sys_dict` VALUES (5, 'job_status', '岗位状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `sys_dict` VALUES (6, '33', '3', '2020-05-18 19:55:49', NULL, 1);
INSERT INTO `sys_dict` VALUES (16, 'force_update', '强制升级', '2020-12-09 11:13:21', NULL, 0);
INSERT INTO `sys_dict` VALUES (17, 'is_enable', '是否启用', '2020-12-10 12:02:57', NULL, 0);
INSERT INTO `sys_dict` VALUES (18, 'sex2', '性别', '2021-02-23 15:20:40', '2021-02-23 14:12:04', 0);
INSERT INTO `sys_dict` VALUES (19, 'sex4', '性别', '2021-02-23 15:20:20', '2021-02-23 14:14:29', 0);
COMMIT;
-- ----------------------------
-- Table structure for sys_dict_detail
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_detail`;
CREATE TABLE `sys_dict_detail` (
`id` bigint NOT NULL AUTO_INCREMENT,
`label` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典标签',
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典值',
`sort` int DEFAULT '0' COMMENT '排序',
`dict_id` bigint DEFAULT NULL COMMENT '字典id',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
`dict_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
KEY `FK5tpkputc6d9nboxojdbgnpmyb` (`dict_id`) USING BTREE,
CONSTRAINT `FK5tpkputc6d9nboxojdbgnpmyb` FOREIGN KEY (`dict_id`) REFERENCES `sys_dict` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='数据字典详情';
-- ----------------------------
-- Records of sys_dict_detail
-- ----------------------------
BEGIN;
INSERT INTO `sys_dict_detail` VALUES (1, '激活', '1', 1, 1, '2021-03-04 13:48:42', NULL, 0, 'user_status');
INSERT INTO `sys_dict_detail` VALUES (2, '禁用', '0', 2, 1, '2021-03-04 13:48:49', NULL, 0, 'user_status');
INSERT INTO `sys_dict_detail` VALUES (3, '启用', '1', 1, 4, '2021-02-25 16:12:46', NULL, 0, 'dept_status');
INSERT INTO `sys_dict_detail` VALUES (4, '停用', '0', 2, 4, '2021-02-25 16:12:51', NULL, 0, 'dept_status');
INSERT INTO `sys_dict_detail` VALUES (5, '启用', '1', 1, 5, '2021-02-26 16:23:39', NULL, 0, 'job_status');
INSERT INTO `sys_dict_detail` VALUES (6, '停用', '0', 2, 5, '2021-02-26 16:23:46', NULL, 0, 'job_status');
INSERT INTO `sys_dict_detail` VALUES (20, '', '1', 999, 16, '2020-12-09 11:41:30', NULL, 0, 'force_update');
INSERT INTO `sys_dict_detail` VALUES (21, '', '0', 999, 16, '2020-12-09 11:41:36', NULL, 0, 'force_update');
INSERT INTO `sys_dict_detail` VALUES (22, '', '1', 999, 17, '2021-02-25 15:32:00', NULL, 0, 'is_enable');
INSERT INTO `sys_dict_detail` VALUES (23, '', '0', 999, 17, '2020-12-10 12:03:16', NULL, 0, 'is_enable');
COMMIT;
-- ----------------------------
-- Table structure for sys_job
-- ----------------------------
DROP TABLE IF EXISTS `sys_job`;
CREATE TABLE `sys_job` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '岗位名称',
`enabled` tinyint(1) NOT NULL COMMENT '岗位状态',
`sort` bigint NOT NULL COMMENT '岗位排序',
`dept_id` bigint DEFAULT NULL COMMENT '部门ID',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE,
KEY `FKmvhj0rogastlctflsxf1d6k3i` (`dept_id`) USING BTREE,
CONSTRAINT `FKmvhj0rogastlctflsxf1d6k3i` FOREIGN KEY (`dept_id`) REFERENCES `sys_dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='岗位';
-- ----------------------------
-- Records of sys_job
-- ----------------------------
BEGIN;
INSERT INTO `sys_job` VALUES (8, '人事专员', 1, 3, 11, '2021-03-07 10:15:49', NULL, 0);
INSERT INTO `sys_job` VALUES (10, '产品经理', 1, 4, 2, '2019-03-29 14:55:51', NULL, 0);
INSERT INTO `sys_job` VALUES (11, '全栈开发2', 1, 2, 2, '2019-03-31 13:39:30', NULL, 0);
INSERT INTO `sys_job` VALUES (12, '软件测试', 1, 5, 2, '2019-03-31 13:39:43', NULL, 0);
INSERT INTO `sys_job` VALUES (13, '6665', 1, 0, 1, '2021-03-02 15:45:16', '2021-03-02 15:42:55', 1);
INSERT INTO `sys_job` VALUES (14, '99', 1, 0, 5, '2021-03-02 15:44:05', '2021-03-02 15:44:05', 1);
COMMIT;
-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`i_frame` tinyint(1) DEFAULT NULL COMMENT '是否外链',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '菜单名称',
`component` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '组件',
`pid` bigint NOT NULL COMMENT '上级菜单ID',
`sort` int NOT NULL COMMENT '排序',
`icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '图标',
`path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '链接地址',
`cache` tinyint(1) DEFAULT '0' COMMENT '缓存',
`hidden` tinyint(1) DEFAULT '0' COMMENT '是否隐藏',
`component_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '-' COMMENT '组件名称',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`permission` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '权限',
`type` int DEFAULT NULL COMMENT '类型',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
`router` varchar(255) DEFAULT NULL COMMENT '操作的路由',
`router_method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '路由动作',
PRIMARY KEY (`id`) USING BTREE,
KEY `FKqcf9gem97gqa5qjm4d3elcqt5` (`pid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=279 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
-- ----------------------------
-- Records of sys_menu
-- ----------------------------
BEGIN;
INSERT INTO `sys_menu` VALUES (1, 0, '系统管理', NULL, 0, 99, 'system', 'system', 0, 0, NULL, '2018-12-18 15:11:29', NULL, 1, '2020-07-16 20:05:34', 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (2, 0, '用户管理', 'system/user/index', 1, 2, 'peoples', 'user', 0, 0, 'User', '2021-03-06 10:24:34', 'user:list', 1, NULL, 0, '/admin/user', 'get');
INSERT INTO `sys_menu` VALUES (3, 0, '角色管理', 'system/role/index', 1, 3, 'role', 'role', 0, 0, 'Role', '2021-03-06 10:31:55', 'roles:list', 1, NULL, 0, '/admin/roles', 'get');
INSERT INTO `sys_menu` VALUES (5, 0, '菜单管理', 'system/menu/index', 1, 5, 'menu', 'menu', 0, 0, 'Menu', '2021-03-06 10:33:17', 'menu:list', 1, NULL, 0, '/admin/menu', 'get');
INSERT INTO `sys_menu` VALUES (35, 0, '部门管理', 'system/dept/index', 1, 6, 'dept', 'dept', 0, 0, 'Dept', '2021-03-06 10:34:35', 'dept:list', 1, NULL, 0, '/admin/dept', 'get');
INSERT INTO `sys_menu` VALUES (36, 0, '系统工具', '', 0, 101, 'sys-tools', 'sys-tools', 0, 0, NULL, '2019-03-29 10:57:35', NULL, 1, NULL, 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (37, 0, '岗位管理', 'system/job/index', 1, 7, 'Steve-Jobs', 'job', 0, 0, 'Job', '2021-03-06 10:35:42', 'user:list', 1, NULL, 0, '/admin/job', 'get');
INSERT INTO `sys_menu` VALUES (39, 0, '字典管理', 'system/dict/index', 1, 8, 'dictionary', 'dict', 0, 0, 'Dict', '2021-03-06 12:54:29', 'dict:list', 1, NULL, 0, '/admin/dict', 'get');
INSERT INTO `sys_menu` VALUES (117, 0, '图表库', 'components/Echarts', 10, 50, 'chart', 'echarts', 1, 0, 'Echarts', '2019-11-21 09:04:32', '', 1, NULL, 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (120, 0, '商品删除', NULL, 45, 4, NULL, NULL, 0, 0, NULL, '2019-12-24 13:03:51', 'YXSTOREPRODUCT_DELETE', 2, '2020-07-10 16:22:51', 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (123, 0, '后台接口文档', 'tools/swagger/index', 36, 31, 'swagger', 'swagger2', 0, 0, 'Swagger', '2020-01-07 18:05:52', NULL, 1, NULL, 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (126, 0, '编辑', NULL, 54, 1, NULL, NULL, 0, 0, NULL, '2020-02-14 21:05:28', 'YXSTOREORDER_EDIT', 2, NULL, 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (127, 0, '用户新增', '', 2, 2, '', '', 0, 0, '', '2021-03-06 10:30:11', 'user:add', 2, NULL, 0, '/admin/user', 'post');
INSERT INTO `sys_menu` VALUES (128, 0, '用户编辑', '', 2, 3, '', '', 0, 0, '', '2021-03-06 10:30:38', 'user:edit', 2, NULL, 0, '/admin/user', 'edit');
INSERT INTO `sys_menu` VALUES (129, 0, '用户删除', '', 2, 4, '', '', 0, 0, '', '2021-03-06 10:30:48', 'user:del', 2, NULL, 0, '/admin/user', 'delete');
INSERT INTO `sys_menu` VALUES (130, 0, '角色创建', '', 3, 2, '', '', 0, 0, '', '2021-03-06 10:32:15', 'roles:add', 2, NULL, 0, '/admin/roles', 'post');
INSERT INTO `sys_menu` VALUES (131, 0, '角色修改', '', 3, 3, '', '', 0, 0, '', '2021-03-06 10:32:27', 'roles:edit', 2, NULL, 0, '/admin/roles', 'put');
INSERT INTO `sys_menu` VALUES (132, 0, '角色删除', '', 3, 999, '', '', 0, 0, '', '2021-03-06 10:32:40', 'roles:del', 2, NULL, 0, '/admin/roles', 'delete');
INSERT INTO `sys_menu` VALUES (133, 0, '菜单新增', '', 5, 2, '', '', 0, 0, '', '2021-03-06 10:33:27', 'menu:add', 2, NULL, 0, '/admin/menu', 'post');
INSERT INTO `sys_menu` VALUES (134, 0, '菜单编辑', '', 5, 3, '', '', 0, 0, '', '2021-03-06 10:33:37', 'menu:edit', 2, NULL, 0, '/admin/menu', 'put');
INSERT INTO `sys_menu` VALUES (135, 0, '菜单删除', '', 5, 4, '', '', 0, 0, '', '2021-03-06 10:33:47', 'menu:del', 2, NULL, 0, '/admin/menu', 'delete');
INSERT INTO `sys_menu` VALUES (136, 0, '部门新增', '', 35, 2, '', '', 0, 0, '', '2021-03-06 10:34:58', 'dept:add', 2, NULL, 0, '/admin/dept', 'post');
INSERT INTO `sys_menu` VALUES (137, 0, '部门编辑', '', 35, 3, '', '', 0, 0, '', '2021-03-06 10:35:07', 'dept:edit', 2, NULL, 0, '/admin/dept', 'put');
INSERT INTO `sys_menu` VALUES (138, 0, '部门删除', '', 35, 4, '', '', 0, 0, '', '2021-03-06 10:35:16', 'dept:del', 2, NULL, 0, '/admin/dept', 'delete');
INSERT INTO `sys_menu` VALUES (139, 0, '岗位新增', '', 37, 2, '', '', 0, 0, '', '2021-03-06 10:35:53', 'job:add', 2, NULL, 0, '/admin/job', 'post');
INSERT INTO `sys_menu` VALUES (140, 0, '岗位编辑', '', 37, 3, '', '', 0, 0, '', '2021-03-06 10:36:02', 'job:edit', 2, NULL, 0, '/admin/job', 'put');
INSERT INTO `sys_menu` VALUES (141, 0, '岗位删除', '', 37, 4, '', '', 0, 0, '', '2021-03-06 10:36:10', 'job:del', 2, NULL, 0, '/admin/job', 'delete');
INSERT INTO `sys_menu` VALUES (142, 0, '字典新增', '', 39, 2, '', '', 0, 0, '', '2021-03-06 10:36:51', 'dict:add', 2, NULL, 0, '/admin/dict', 'post');
INSERT INTO `sys_menu` VALUES (143, 0, '字典编辑', '', 39, 3, '', '', 0, 0, '', '2021-03-06 10:36:59', 'dict:edit', 2, NULL, 0, '/admin/dict', 'put');
INSERT INTO `sys_menu` VALUES (144, 0, '字典删除', '', 39, 4, '', '', 0, 0, '', '2021-03-06 10:37:10', 'dict:del', 2, NULL, 0, '/admin/dict', 'delete');
INSERT INTO `sys_menu` VALUES (184, 0, '新增菜单', NULL, 49, 0, 'add', NULL, 0, 0, NULL, '2020-06-14 20:10:02', 'YxWechatMenu_CREATE', 2, NULL, 0, NULL, NULL);
INSERT INTO `sys_menu` VALUES (265, 0, '顶级2', 'top/aa', 264, 999, 'alipay', 'top2', 0, 0, 'TOp', '2021-03-03 16:09:42', 'top2', 1, '2021-03-03 16:00:39', 0, '/top', 'get');
INSERT INTO `sys_menu` VALUES (269, 0, '字典详情列表', '', 1, 999, 'configure', '/no', 0, 1, '', '2021-03-06 12:59:31', 'dict_detail:list', 1, '2021-03-06 10:40:50', 0, '/admin/dictDetail', 'get');
INSERT INTO `sys_menu` VALUES (270, 0, '字典详情增加', '', 269, 999, '', '', 0, 0, '', '2021-03-06 12:57:17', 'dict_detail:add', 2, '2021-03-06 10:42:14', 0, '/admin/dictDetail', 'post');
INSERT INTO `sys_menu` VALUES (271, 0, '字典详情编辑', '', 269, 999, '', '', 0, 0, '', '2021-03-06 12:57:25', 'dict_detail:edit', 2, '2021-03-06 10:43:33', 0, '/admin/dictDetail', 'put');
INSERT INTO `sys_menu` VALUES (272, 0, '字典详情删除', '', 269, 999, '', '', 0, 0, '', '2021-03-06 12:57:33', 'dict_detail:delete', 2, '2021-03-06 10:44:09', 0, '/admin/dictDetail', 'delete');
INSERT INTO `sys_menu` VALUES (273, 0, '角色菜单数', '', 3, 999, '', '', 0, 0, '', '2021-03-06 10:36:41', 'role_menu:tree', 2, '2021-03-06 10:46:21', 0, '/admin/menu/tree', 'get');
INSERT INTO `sys_menu` VALUES (274, 0, '角色菜单保存', '', 3, 999, '', '', 0, 0, '', '2021-03-06 10:36:41', 'role_menu:save', 2, '2021-03-06 10:49:47', 0, '/admin/roles/menu', 'put');
INSERT INTO `sys_menu` VALUES (275, 0, '单个角色', '', 3, 999, '', '', 0, 0, '', '2021-03-06 10:36:41', 'roles:one', 2, '2021-03-06 11:18:28', 0, '/admin/roles/*', 'get');
INSERT INTO `sys_menu` VALUES (276, 0, '用户个人信息', '', 2, 999, '', '', 0, 0, '', '2021-03-06 10:36:41', 'user:info', 2, '2021-03-06 11:20:25', 0, '/admin/auth/info', 'get');
INSERT INTO `sys_menu` VALUES (277, 0, '用户头像', '', 2, 999, '', '', 0, 0, '', '2021-03-06 10:36:41', 'user:avatar', 2, '2021-03-06 11:21:41', 0, '/admin/user/updateAvatar', 'post');
INSERT INTO `sys_menu` VALUES (278, 0, '用户退出', '', 2, 999, '', '', 0, 0, '', '2021-03-06 11:25:00', 'user:logout', 2, '2021-03-06 11:25:00', 0, '/admin/auth/logout', 'delete');
COMMIT;
-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注',
`data_scope` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '数据权限',
`level` int DEFAULT NULL COMMENT '角色级别',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`permission` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '功能权限',
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表';
-- ----------------------------
-- Records of sys_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_role` VALUES (1, '超级管理员', '-', '全部', 1, '2018-11-23 11:04:37', 'admin', NULL, 0);
INSERT INTO `sys_role` VALUES (2, '普通用户', '-555', '本级', 2, '2021-03-07 10:09:08', 'common', NULL, 0);
INSERT INTO `sys_role` VALUES (3, '管理员2', '222', '全部', 3, '2020-01-31 16:53:25', '22', NULL, 0);
INSERT INTO `sys_role` VALUES (4, '667', '66', '全部', 3, '2021-03-02 16:16:43', '666', '2021-03-02 16:15:20', 1);
INSERT INTO `sys_role` VALUES (5, '99', '9', '全部', 3, '2021-03-02 16:16:35', '9', '2021-03-02 16:16:35', 1);
COMMIT;
-- ----------------------------
-- Table structure for sys_roles_depts
-- ----------------------------
DROP TABLE IF EXISTS `sys_roles_depts`;
CREATE TABLE `sys_roles_depts` (
`role_id` bigint NOT NULL,
`dept_id` bigint NOT NULL,
`id` bigint NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`) USING BTREE,
KEY `FK7qg6itn5ajdoa9h9o78v9ksur` (`dept_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色部门关联';
-- ----------------------------
-- Records of sys_roles_depts
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for sys_roles_menus
-- ----------------------------
DROP TABLE IF EXISTS `sys_roles_menus`;
CREATE TABLE `sys_roles_menus` (
`menu_id` bigint NOT NULL COMMENT '菜单ID',
`role_id` bigint NOT NULL COMMENT '角色ID',
`id` bigint NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `FKcngg2qadojhi3a651a5adkvbq` (`role_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=503 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色菜单关联';
-- ----------------------------
-- Records of sys_roles_menus
-- ----------------------------
BEGIN;
INSERT INTO `sys_roles_menus` VALUES (1, 1, 411);
INSERT INTO `sys_roles_menus` VALUES (2, 1, 412);
INSERT INTO `sys_roles_menus` VALUES (127, 1, 413);
INSERT INTO `sys_roles_menus` VALUES (128, 1, 414);
INSERT INTO `sys_roles_menus` VALUES (129, 1, 415);
INSERT INTO `sys_roles_menus` VALUES (276, 1, 416);
INSERT INTO `sys_roles_menus` VALUES (277, 1, 417);
INSERT INTO `sys_roles_menus` VALUES (278, 1, 418);
INSERT INTO `sys_roles_menus` VALUES (3, 1, 419);
INSERT INTO `sys_roles_menus` VALUES (130, 1, 420);
INSERT INTO `sys_roles_menus` VALUES (131, 1, 421);
INSERT INTO `sys_roles_menus` VALUES (132, 1, 422);
INSERT INTO `sys_roles_menus` VALUES (273, 1, 423);
INSERT INTO `sys_roles_menus` VALUES (274, 1, 424);
INSERT INTO `sys_roles_menus` VALUES (275, 1, 425);
INSERT INTO `sys_roles_menus` VALUES (5, 1, 426);
INSERT INTO `sys_roles_menus` VALUES (133, 1, 427);
INSERT INTO `sys_roles_menus` VALUES (134, 1, 428);
INSERT INTO `sys_roles_menus` VALUES (135, 1, 429);
INSERT INTO `sys_roles_menus` VALUES (35, 1, 430);
INSERT INTO `sys_roles_menus` VALUES (136, 1, 431);
INSERT INTO `sys_roles_menus` VALUES (137, 1, 432);
INSERT INTO `sys_roles_menus` VALUES (138, 1, 433);
INSERT INTO `sys_roles_menus` VALUES (37, 1, 434);
INSERT INTO `sys_roles_menus` VALUES (139, 1, 435);
INSERT INTO `sys_roles_menus` VALUES (140, 1, 436);
INSERT INTO `sys_roles_menus` VALUES (141, 1, 437);
INSERT INTO `sys_roles_menus` VALUES (39, 1, 438);
INSERT INTO `sys_roles_menus` VALUES (142, 1, 439);
INSERT INTO `sys_roles_menus` VALUES (143, 1, 440);
INSERT INTO `sys_roles_menus` VALUES (144, 1, 441);
INSERT INTO `sys_roles_menus` VALUES (269, 1, 442);
INSERT INTO `sys_roles_menus` VALUES (270, 1, 443);
INSERT INTO `sys_roles_menus` VALUES (271, 1, 444);
INSERT INTO `sys_roles_menus` VALUES (272, 1, 445);
INSERT INTO `sys_roles_menus` VALUES (36, 1, 446);
INSERT INTO `sys_roles_menus` VALUES (123, 1, 447);
INSERT INTO `sys_roles_menus` VALUES (1, 2, 461);
INSERT INTO `sys_roles_menus` VALUES (35, 2, 462);
INSERT INTO `sys_roles_menus` VALUES (37, 2, 463);
INSERT INTO `sys_roles_menus` VALUES (136, 2, 464);
INSERT INTO `sys_roles_menus` VALUES (137, 2, 465);
INSERT INTO `sys_roles_menus` VALUES (139, 2, 466);
INSERT INTO `sys_roles_menus` VALUES (140, 2, 467);
INSERT INTO `sys_roles_menus` VALUES (269, 2, 468);
INSERT INTO `sys_roles_menus` VALUES (270, 2, 469);
INSERT INTO `sys_roles_menus` VALUES (271, 2, 470);
INSERT INTO `sys_roles_menus` VALUES (272, 2, 471);
INSERT INTO `sys_roles_menus` VALUES (1, 3, 472);
INSERT INTO `sys_roles_menus` VALUES (2, 3, 473);
INSERT INTO `sys_roles_menus` VALUES (127, 3, 474);
INSERT INTO `sys_roles_menus` VALUES (128, 3, 475);
INSERT INTO `sys_roles_menus` VALUES (129, 3, 476);
INSERT INTO `sys_roles_menus` VALUES (276, 3, 477);
INSERT INTO `sys_roles_menus` VALUES (277, 3, 478);
INSERT INTO `sys_roles_menus` VALUES (278, 3, 479);
INSERT INTO `sys_roles_menus` VALUES (3, 3, 480);
INSERT INTO `sys_roles_menus` VALUES (130, 3, 481);
INSERT INTO `sys_roles_menus` VALUES (131, 3, 482);
INSERT INTO `sys_roles_menus` VALUES (132, 3, 483);
INSERT INTO `sys_roles_menus` VALUES (273, 3, 484);
INSERT INTO `sys_roles_menus` VALUES (274, 3, 485);
INSERT INTO `sys_roles_menus` VALUES (275, 3, 486);
INSERT INTO `sys_roles_menus` VALUES (5, 3, 487);
INSERT INTO `sys_roles_menus` VALUES (133, 3, 488);
INSERT INTO `sys_roles_menus` VALUES (134, 3, 489);
INSERT INTO `sys_roles_menus` VALUES (135, 3, 490);
INSERT INTO `sys_roles_menus` VALUES (35, 3, 491);
INSERT INTO `sys_roles_menus` VALUES (136, 3, 492);
INSERT INTO `sys_roles_menus` VALUES (137, 3, 493);
INSERT INTO `sys_roles_menus` VALUES (138, 3, 494);
INSERT INTO `sys_roles_menus` VALUES (37, 3, 495);
INSERT INTO `sys_roles_menus` VALUES (139, 3, 496);
INSERT INTO `sys_roles_menus` VALUES (140, 3, 497);
INSERT INTO `sys_roles_menus` VALUES (141, 3, 498);
INSERT INTO `sys_roles_menus` VALUES (39, 3, 499);
INSERT INTO `sys_roles_menus` VALUES (142, 3, 500);
INSERT INTO `sys_roles_menus` VALUES (143, 3, 501);
INSERT INTO `sys_roles_menus` VALUES (144, 3, 502);
COMMIT;
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`avatar` varchar(200) DEFAULT NULL COMMENT '头像',
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '邮箱',
`enabled` tinyint(1) DEFAULT NULL COMMENT '状态:1启用、0禁用',
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '密码',
`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '用户名',
`dept_id` bigint DEFAULT NULL COMMENT '部门名称',
`phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '手机号码',
`job_id` bigint DEFAULT NULL COMMENT '岗位名称',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`sex` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`is_del` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `username` (`username`) USING BTREE,
KEY `FK5rwmryny6jthaaxkogownknqp` (`dept_id`) USING BTREE,
KEY `FKfftoc2abhot8f2wu6cl9a5iky` (`job_id`) USING BTREE,
KEY `FKpq2dhypk2qgt68nauh2by22jb` (`avatar`) USING BTREE,
CONSTRAINT `FK5rwmryny6jthaaxkogownknqp` FOREIGN KEY (`dept_id`) REFERENCES `sys_dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `FKfftoc2abhot8f2wu6cl9a5iky` FOREIGN KEY (`job_id`) REFERENCES `sys_job` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=9998 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` VALUES (1, 'https://goapi.yixiang.co/static/upload/1.jpg', 'yshop@qq.com', 1, '$2a$10$fP.426qKaTmix50Oln8L.uav55gELhAd0Eg66Av4oG86u8km7D/Ky', 'admin', 2, '18888888888', 11, '2021-03-07 10:08:30', '管理员', '', '2020-06-27 12:05:56', 0);
INSERT INTO `sys_user` VALUES (3, '', 'test@yshopnet', 1, '$2a$04$tw0sZ2EOqt7y.tkrnWHdgeyTG6ku7iv0vAACBTBwym5lNr2oQkG.y', 'test', 2, '17777777777', 12, '2021-03-06 12:46:08', '测试2', '', NULL, 0);
INSERT INTO `sys_user` VALUES (4, NULL, 'test2@qq.com', 1, '$2a$10$IjehtV8MiXb8ni.Qz0wBteE7FjVn49cEcsSj2.ZBUqqHjnC3umSh.', 'test2', 2, '15136175247', 11, '2020-02-15 20:39:16', 'test2', '', NULL, 0);
INSERT INTO `sys_user` VALUES (5, '', '444@qq.com', 1, '$2a$10$f/VH35NBOBszycV9KEA1HenQ0qVjazDm8LacQU9PO.A4UizFxLMuq', 'qqqqq', 11, '15136175249', 8, '2021-03-04 16:22:56', 'eeeeee', '', NULL, 1);
INSERT INTO `sys_user` VALUES (6, '', '666@qq.com', 0, '$2a$10$3Vlo24eOmHHW7.3vAjqPSusfIINNo4JiujzxgqsaoWLx/d5de/jEm', '7777', 8, '15136175246', 8, '2021-03-04 15:31:40', '777', '', NULL, 1);
INSERT INTO `sys_user` VALUES (9992, '', '66@qq.com', 1, '$2a$04$zI7VSH/WspYF9Kea1lCMkO/0pMh.d0U72EO6T0YinOxs.d97dTImi', 'hupeng33333', 7, '18888888888', 8, '2021-03-05 10:42:42', 'hu', '', '2021-03-04 15:07:36', 1);
INSERT INTO `sys_user` VALUES (9993, '', '44@qq.com', 1, '$2a$04$IBgD8Un9Xgbi0lzbklZlC.uK1srn5w1Y5ntN1qfpzDgcipLLRp1aG', 'hupeng2', 11, '', 10, '2021-03-04 15:28:40', 'hu2', '', '2021-03-04 15:09:11', 1);
INSERT INTO `sys_user` VALUES (9996, '', '777@qq.com', 0, '$2a$04$Ep/UAK2kmJKPto6efG9qyOYlwQ5NGL0T/PkLVrUcXJxTcq6WG5Zca', 'zhang', 5, '18888888888', 11, '2021-03-04 16:23:49', 'zhang', '', '2021-03-04 16:14:59', 1);
COMMIT;
-- ----------------------------
-- Table structure for sys_users_roles
-- ----------------------------
DROP TABLE IF EXISTS `sys_users_roles`;
CREATE TABLE `sys_users_roles` (
`user_id` bigint NOT NULL COMMENT '用户ID',
`role_id` bigint NOT NULL COMMENT '角色ID',
`id` bigint NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户角色关联';
-- ----------------------------
-- Records of sys_users_roles
-- ----------------------------
BEGIN;
INSERT INTO `sys_users_roles` VALUES (1, 1, 1);
INSERT INTO `sys_users_roles` VALUES (3, 2, 2);
INSERT INTO `sys_users_roles` VALUES (4, 2, 3);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;

BIN
static/upload/1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
static/upload/1614928266851.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
swagger/favicon-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

BIN
swagger/favicon-32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

93
swagger/index.html

@ -0,0 +1,93 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</script>
</body>
</html>

53
swagger/oauth2-redirect.html

@ -0,0 +1,53 @@
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}
isValid = qp.state === sentState
if (oauth2.auth.schema.get("flow") === "accessCode" && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
} else {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: "Authorization failed: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
}
window.close();
}
</script>

108
swagger/swagger-ui-bundle.js

File diff suppressed because one or more lines are too long

1
swagger/swagger-ui-bundle.js.map

@ -0,0 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAyrGA;AA0lFA;AA4nFA;AA+9CA;AA+gDA;AAwrCA;AA60EA;;;;;AA6oCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAu9CA;AAy8EA;AAsiCA;AA+yFA;;;;;;;;;AAgkDA;AA2zIA;AAu7FA;AAmrFA;AAu0EA","sourceRoot":""}

20
swagger/swagger-ui-standalone-preset.js

File diff suppressed because one or more lines are too long

1
swagger/swagger-ui-standalone-preset.js.map

@ -0,0 +1 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8QA;AAmvGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}

2
swagger/swagger-ui.css

File diff suppressed because one or more lines are too long

1
swagger/swagger-ui.css.map

@ -0,0 +1 @@
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":"","sourceRoot":""}

15
swagger/swagger-ui.js

File diff suppressed because one or more lines are too long

1
swagger/swagger-ui.js.map

@ -0,0 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AAmyHA;AAykGA;AA+9BA;AA6iCA;AAojCA;AAu5BA","sourceRoot":""}

989
swagger/swagger.json

@ -0,0 +1,989 @@
{
"swagger": "2.0",
"info": {
"title": "VIVIB API",
"description": "VIVIB管理系统API",
"version": "1.0.0",
"termsOfService": "https://www.yixiang.co/",
"contact": {}
},
"basePath": "/v1",
"paths": {
"/auth/captcha": {
"get": {
"tags": [
"auth"
],
"description": "获取验证码",
"operationId": "LoginController.获取验证码"
}
},
"/auth/info": {
"get": {
"tags": [
"auth"
],
"description": "获取用户信息",
"operationId": "LoginController.获取用户信息",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/auth/login": {
"post": {
"tags": [
"auth"
],
"description": "登录",
"operationId": "LoginController.登录",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/auth/logout": {
"delete": {
"tags": [
"auth"
],
"description": "退出登录",
"operationId": "LoginController.退出登录",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/dept/": {
"get": {
"tags": [
"dept"
],
"description": "获取部门列表",
"operationId": "DeptController.获取部门列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"dept"
],
"description": "修改部门",
"operationId": "DeptController.修改部门",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"dept"
],
"description": "添加部门",
"operationId": "DeptController.添加部门",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"delete": {
"tags": [
"dept"
],
"description": "删除部门",
"operationId": "DeptController.删除部门",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/dict/": {
"get": {
"tags": [
"dict"
],
"description": "获取字典列表",
"operationId": "DictController.获取字典列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"dict"
],
"description": "修改字典",
"operationId": "DictController.修改字典",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"dict"
],
"description": "添加字典",
"operationId": "DictController.添加字典",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/dict/{id}": {
"delete": {
"tags": [
"dict"
],
"description": "删除字典",
"operationId": "DictController.删除字典",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/dictDetail/": {
"get": {
"tags": [
"dictDetail"
],
"description": "获取字典详情列表",
"operationId": "DictDetailController.获取字典详情列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"dictDetail"
],
"description": "修改字典详情",
"operationId": "DictDetailController.修改字典详情",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"dictDetail"
],
"description": "添加字典详情",
"operationId": "DictDetailController.添加字典详情",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/dictDetail/{id}": {
"delete": {
"tags": [
"dictDetail"
],
"description": "删除字典详情",
"operationId": "DictDetailController.删除字典详情",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/job/": {
"get": {
"tags": [
"job"
],
"description": "岗位列表",
"operationId": "JobController.岗位列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"job"
],
"description": "岗位修改",
"operationId": "JobController.岗位修改",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"job"
],
"description": "岗位添加",
"operationId": "JobController.岗位添加",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"delete": {
"tags": [
"job"
],
"description": "岗位删除",
"operationId": "JobController.岗位删除",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/menu/": {
"get": {
"tags": [
"menu"
],
"description": "菜单列表",
"operationId": "MenuController.菜单列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"menu"
],
"description": "菜单修改",
"operationId": "MenuController.菜单修改",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"menu"
],
"description": "菜单添加",
"operationId": "MenuController.菜单添加",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"delete": {
"tags": [
"menu"
],
"description": "菜单删除",
"operationId": "MenuController.菜单删除",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/menu/build": {
"get": {
"tags": [
"menu"
],
"description": "菜单构建",
"operationId": "MenuController.菜单构建",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/menu/tree": {
"get": {
"tags": [
"menu"
],
"description": "菜单树形",
"operationId": "MenuController.菜单树形",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/roles/": {
"get": {
"tags": [
"roles"
],
"description": "角色列表",
"operationId": "RoleController.角色列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"roles"
]
},
"post": {
"tags": [
"roles"
],
"description": "角色添加",
"operationId": "RoleController.角色添加",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"delete": {
"tags": [
"roles"
],
"description": "角色删除",
"operationId": "RoleController.角色删除",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/roles/menu": {
"put": {
"tags": [
"roles"
],
"description": "角色菜单更新",
"operationId": "RoleController.角色菜单更新",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/roles/{id}": {
"get": {
"tags": [
"roles"
],
"description": "获取单个角色",
"operationId": "RoleController.获取单个角色",
"parameters": [
{
"in": "path",
"name": "id",
"description": "角色ID",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.Role"
}
}
}
}
},
"/user/": {
"get": {
"tags": [
"user"
],
"description": "用户列表",
"operationId": "UserController.用户列表",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"put": {
"tags": [
"user"
],
"description": "用户编辑",
"operationId": "UserController.用户编辑",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"post": {
"tags": [
"user"
],
"description": "用户添加",
"operationId": "UserController.用户添加",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
},
"delete": {
"tags": [
"user"
],
"description": "用户删除",
"operationId": "UserController.用户删除",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/user/center": {
"put": {
"tags": [
"user"
],
"description": "用户修改个人信息",
"operationId": "UserController.用户修改个人信息",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/user/updateAvatar": {
"post": {
"tags": [
"user"
],
"description": "用户上传图像",
"operationId": "UserController.用户上传图像",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
},
"/user/updatePass": {
"post": {
"tags": [
"user"
],
"description": "用户修改密码",
"operationId": "UserController.用户修改密码",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controllers.Result"
}
}
}
}
}
},
"definitions": {
"611.0xc000380630.false": {
"title": "false",
"type": "object"
},
"controllers.Result": {
"title": "Result",
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/611.0xc000380630.false"
},
"msg": {
"type": "string"
},
"status": {
"type": "integer",
"format": "int64"
}
}
},
"models.BaseModel": {
"title": "BaseModel",
"type": "object",
"properties": {
"createTime": {
"type": "string",
"format": "datetime"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"updateTime": {
"type": "string",
"format": "datetime"
}
}
},
"models.Dept": {
"title": "Dept",
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Dept"
}
},
"createTime": {
"type": "string",
"format": "datetime"
},
"enabled": {
"type": "integer",
"format": "int32"
},
"id": {
"type": "integer",
"format": "int64"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"label": {
"type": "string"
},
"name": {
"type": "string"
},
"pid": {
"type": "integer",
"format": "int64"
},
"updateTime": {
"type": "string",
"format": "datetime"
}
}
},
"models.Job": {
"title": "Job",
"type": "object",
"properties": {
"createTime": {
"type": "string",
"format": "datetime"
},
"dept": {
"$ref": "#/definitions/models.Dept"
},
"enabled": {
"type": "integer",
"format": "int32"
},
"id": {
"type": "integer",
"format": "int64"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string"
},
"sort": {
"type": "integer",
"format": "int32"
},
"updateTime": {
"type": "string",
"format": "datetime"
}
}
},
"models.Menu": {
"title": "Menu",
"type": "object",
"properties": {
"cache": {
"type": "integer",
"format": "int32"
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Menu"
}
},
"component": {
"type": "string"
},
"componentName": {
"type": "string"
},
"createTime": {
"type": "string",
"format": "datetime"
},
"hidden": {
"type": "integer",
"format": "int32"
},
"icon": {
"type": "string"
},
"id": {
"type": "integer",
"format": "int64"
},
"iframe": {
"type": "integer",
"format": "int32"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"label": {
"type": "string"
},
"name": {
"type": "string"
},
"path": {
"type": "string"
},
"permission": {
"type": "string"
},
"pid": {
"type": "integer",
"format": "int64"
},
"router": {
"type": "string"
},
"routerMethod": {
"type": "string"
},
"sort": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "integer",
"format": "int32"
},
"updateTime": {
"type": "string",
"format": "datetime"
}
}
},
"models.Role": {
"title": "Role",
"type": "object",
"properties": {
"Depts": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Dept"
}
},
"Users": {
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"createTime": {
"type": "string",
"format": "datetime"
},
"dataScope": {
"type": "string"
},
"id": {
"type": "integer",
"format": "int64"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"level": {
"type": "integer",
"format": "int32"
},
"menus": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Menu"
}
},
"name": {
"type": "string"
},
"permission": {
"type": "string"
},
"remark": {
"type": "string"
},
"updateTime": {
"type": "string",
"format": "datetime"
}
}
},
"models.User": {
"title": "User",
"type": "object",
"properties": {
"Permissions": {
"type": "array",
"items": {
"type": "string"
}
},
"avatar": {
"type": "string"
},
"createTime": {
"type": "string",
"format": "datetime"
},
"dept": {
"$ref": "#/definitions/models.Dept"
},
"email": {
"type": "string"
},
"enabled": {
"type": "integer",
"format": "int32"
},
"id": {
"type": "integer",
"format": "int64"
},
"isDel": {
"type": "integer",
"format": "int32"
},
"job": {
"$ref": "#/definitions/models.Job"
},
"nickName": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"roleIds": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
},
"roles": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Role"
}
},
"sex": {
"type": "string"
},
"updateTime": {
"type": "string",
"format": "datetime"
},
"username": {
"type": "string"
}
}
}
},
"tags": [
{
"name": "auth",
"description": "登录api\n"
},
{
"name": "user",
"description": "用户 API\n"
},
{
"name": "menu",
"description": "菜单api\n"
},
{
"name": "dict",
"description": "字典api\n"
},
{
"name": "dictDetail",
"description": "字典详情api\n"
},
{
"name": "dept",
"description": "部门api\n"
},
{
"name": "job",
"description": "岗位api\n"
},
{
"name": "roles",
"description": "角色 API\n"
}
]
}

667
swagger/swagger.yml

@ -0,0 +1,667 @@
swagger: "2.0"
info:
title: VIVIB API
description: VIVIB管理系统API
version: 1.0.0
termsOfService: https://www.yixiang.co/
basePath: /v1
paths:
/auth/captcha:
get:
tags:
- auth
description: 获取验证码
operationId: LoginController.获取验证码
/auth/info:
get:
tags:
- auth
description: 获取用户信息
operationId: LoginController.获取用户信息
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/auth/login:
post:
tags:
- auth
description: 登录
operationId: LoginController.登录
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/auth/logout:
delete:
tags:
- auth
description: 退出登录
operationId: LoginController.退出登录
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/dept/:
get:
tags:
- dept
description: 获取部门列表
operationId: DeptController.获取部门列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- dept
description: 修改部门
operationId: DeptController.修改部门
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- dept
description: 添加部门
operationId: DeptController.添加部门
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
delete:
tags:
- dept
description: 删除部门
operationId: DeptController.删除部门
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/dict/:
get:
tags:
- dict
description: 获取字典列表
operationId: DictController.获取字典列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- dict
description: 修改字典
operationId: DictController.修改字典
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- dict
description: 添加字典
operationId: DictController.添加字典
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/dict/{id}:
delete:
tags:
- dict
description: 删除字典
operationId: DictController.删除字典
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/dictDetail/:
get:
tags:
- dictDetail
description: 获取字典详情列表
operationId: DictDetailController.获取字典详情列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- dictDetail
description: 修改字典详情
operationId: DictDetailController.修改字典详情
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- dictDetail
description: 添加字典详情
operationId: DictDetailController.添加字典详情
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/dictDetail/{id}:
delete:
tags:
- dictDetail
description: 删除字典详情
operationId: DictDetailController.删除字典详情
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/job/:
get:
tags:
- job
description: 岗位列表
operationId: JobController.岗位列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- job
description: 岗位修改
operationId: JobController.岗位修改
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- job
description: 岗位添加
operationId: JobController.岗位添加
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
delete:
tags:
- job
description: 岗位删除
operationId: JobController.岗位删除
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/menu/:
get:
tags:
- menu
description: 菜单列表
operationId: MenuController.菜单列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- menu
description: 菜单修改
operationId: MenuController.菜单修改
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- menu
description: 菜单添加
operationId: MenuController.菜单添加
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
delete:
tags:
- menu
description: 菜单删除
operationId: MenuController.菜单删除
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/menu/build:
get:
tags:
- menu
description: 菜单构建
operationId: MenuController.菜单构建
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/menu/tree:
get:
tags:
- menu
description: 菜单树形
operationId: MenuController.菜单树形
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/roles/:
get:
tags:
- roles
description: 角色列表
operationId: RoleController.角色列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- roles
post:
tags:
- roles
description: 角色添加
operationId: RoleController.角色添加
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
delete:
tags:
- roles
description: 角色删除
operationId: RoleController.角色删除
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/roles/{id}:
get:
tags:
- roles
description: 获取单个角色
operationId: RoleController.获取单个角色
parameters:
- in: path
name: id
description: 角色ID
required: true
type: integer
format: int64
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.Role'
/roles/menu:
put:
tags:
- roles
description: 角色菜单更新
operationId: RoleController.角色菜单更新
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/user/:
get:
tags:
- user
description: 用户列表
operationId: UserController.用户列表
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
put:
tags:
- user
description: 用户编辑
operationId: UserController.用户编辑
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
post:
tags:
- user
description: 用户添加
operationId: UserController.用户添加
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
delete:
tags:
- user
description: 用户删除
operationId: UserController.用户删除
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/user/center:
put:
tags:
- user
description: 用户修改个人信息
operationId: UserController.用户修改个人信息
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/user/updateAvatar:
post:
tags:
- user
description: 用户上传图像
operationId: UserController.用户上传图像
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
/user/updatePass:
post:
tags:
- user
description: 用户修改密码
operationId: UserController.用户修改密码
responses:
"200":
description: ""
schema:
$ref: '#/definitions/controllers.Result'
definitions:
611.0xc000380630.false:
title: "false"
type: object
controllers.Result:
title: Result
type: object
properties:
data:
$ref: '#/definitions/611.0xc000380630.false'
msg:
type: string
status:
type: integer
format: int64
models.BaseModel:
title: BaseModel
type: object
properties:
createTime:
type: string
format: datetime
isDel:
type: integer
format: int32
updateTime:
type: string
format: datetime
models.Dept:
title: Dept
type: object
properties:
children:
type: array
items:
$ref: '#/definitions/models.Dept'
createTime:
type: string
format: datetime
enabled:
type: integer
format: int32
id:
type: integer
format: int64
isDel:
type: integer
format: int32
label:
type: string
name:
type: string
pid:
type: integer
format: int64
updateTime:
type: string
format: datetime
models.Job:
title: Job
type: object
properties:
createTime:
type: string
format: datetime
dept:
$ref: '#/definitions/models.Dept'
enabled:
type: integer
format: int32
id:
type: integer
format: int64
isDel:
type: integer
format: int32
name:
type: string
sort:
type: integer
format: int32
updateTime:
type: string
format: datetime
models.Menu:
title: Menu
type: object
properties:
cache:
type: integer
format: int32
children:
type: array
items:
$ref: '#/definitions/models.Menu'
component:
type: string
componentName:
type: string
createTime:
type: string
format: datetime
hidden:
type: integer
format: int32
icon:
type: string
id:
type: integer
format: int64
iframe:
type: integer
format: int32
isDel:
type: integer
format: int32
label:
type: string
name:
type: string
path:
type: string
permission:
type: string
pid:
type: integer
format: int64
router:
type: string
routerMethod:
type: string
sort:
type: integer
format: int32
type:
type: integer
format: int32
updateTime:
type: string
format: datetime
models.Role:
title: Role
type: object
properties:
Depts:
type: array
items:
$ref: '#/definitions/models.Dept'
Users:
type: array
items:
$ref: '#/definitions/models.User'
createTime:
type: string
format: datetime
dataScope:
type: string
id:
type: integer
format: int64
isDel:
type: integer
format: int32
level:
type: integer
format: int32
menus:
type: array
items:
$ref: '#/definitions/models.Menu'
name:
type: string
permission:
type: string
remark:
type: string
updateTime:
type: string
format: datetime
models.User:
title: User
type: object
properties:
Permissions:
type: array
items:
type: string
avatar:
type: string
createTime:
type: string
format: datetime
dept:
$ref: '#/definitions/models.Dept'
email:
type: string
enabled:
type: integer
format: int32
id:
type: integer
format: int64
isDel:
type: integer
format: int32
job:
$ref: '#/definitions/models.Job'
nickName:
type: string
password:
type: string
phone:
type: string
roleIds:
type: array
items:
type: integer
format: int64
roles:
type: array
items:
$ref: '#/definitions/models.Role'
sex:
type: string
updateTime:
type: string
format: datetime
username:
type: string
tags:
- name: auth
description: |
登录api
- name: user
description: |
用户 API
- name: menu
description: |
菜单api
- name: dict
description: |
字典api
- name: dictDetail
description: |
字典详情api
- name: dept
description: |
部门api
- name: job
description: |
岗位api
- name: roles
description: |
角色 API

38
tests/default_test.go

@ -0,0 +1,38 @@
package test
import (
"net/http"
"net/http/httptest"
"path/filepath"
"runtime"
"testing"
_ "viviman.top/routers"
"github.com/beego/beego/v2/core/logs"
beego "github.com/beego/beego/v2/server/web"
. "github.com/smartystreets/goconvey/convey"
)
func init() {
_, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
beego.TestBeegoInit(apppath)
}
// TestGet is a sample to run an endpoint test
func TestGet(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/object", nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)
logs.Info("testing", "TestGet", "Code[%d]\n%s", w.Code, w.Body.String())
Convey("Subject: Test Station Endpoint\n", t, func() {
Convey("Status Code Should Be 200", func() {
So(w.Code, ShouldEqual, 200)
})
Convey("The Result Should Not Be Empty", func() {
So(w.Body.Len(), ShouldBeGreaterThan, 0)
})
})
}

68
untils/tools.go

@ -0,0 +1,68 @@
package untils
import (
"fmt"
"golang.org/x/crypto/bcrypt"
"reflect"
"strings"
"viviman.top/controllers"
)
//加密
func HashAndSalt(pwd []byte) string {
hash, err := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost)
if err != nil {
controllers.ErrMsg(err.Error())
}
return string(hash)
}
//密码验证
func ComparePwd(hashPwd string, plainPwd []byte) bool {
byteHash := []byte(hashPwd)
err := bcrypt.CompareHashAndPassword(byteHash, plainPwd)
if err != nil {
return false
}
return true
}
//判断array contain item
func Contains(array interface{}, val interface{}) (index int) {
index = -1
switch reflect.TypeOf(array).Kind() {
case reflect.Slice:
{
s := reflect.ValueOf(array)
for i := 0; i < s.Len(); i++ {
if reflect.DeepEqual(val, s.Index(i).Interface()) {
index = i
return
}
}
}
}
return
}
//[a] -> a -> a
//[a b c] -> a b c -> a,b,c
func Convert(array interface{}) string {
return strings.Replace(strings.Trim(fmt.Sprint(array), "[]"), " ", ",", -1)
}
func IntToBool(num int8) bool {
if num > 0 {
return true
}
return false
}
func ReturnQ(length int) string {
var str string
for i := 0; i < length; i++ {
str += ",?"
}
return str[1:]
}

13
vo/JwtUser.go

@ -0,0 +1,13 @@
package vo
type JwtUser struct {
Id int64
Avatar string
Email string
Username string
Phone string
NickName string
Sex string
Dept string
Job string
}

8
vo/LoginVo.go

@ -0,0 +1,8 @@
package vo
import "viviman.top/models"
type LoginVo struct {
Token string `json:"token"`
User *models.SysUser `json:"user"`
}

6
vo/ResultList.go

@ -0,0 +1,6 @@
package vo
type ResultList struct {
Content interface{} `json:"content"`
TotalElements int `json:"totalElements"`
}

18
vo/menu/MenuVo.go

@ -0,0 +1,18 @@
package menu
type MenuVo struct {
Name string `json:"name"`
Component string `json:"component"`
Path string `json:"path"`
Hidden int8 `json:"hidden"`
AlwaysShow bool `json:"alwaysShow"`
Redirect string `json:"redirect"`
Meta MenuMetaVo `json:"meta"`
Children []MenuVo `json:"children"`
}
type MenuMetaVo struct {
Title string `json:"title"`
Icon string `json:"icon"`
NoCache bool `json:"noCache"`
}
Loading…
Cancel
Save