Browse Source

YSHOP-GO 1.0版本 发布

master
hupeng 4 years ago
commit
f484577ae3
  1. 5
      .gitignore
  2. 191
      LICENSE
  3. 66
      README.md
  4. 4
      common/constant.go
  5. 51
      conf/app.conf
  6. 93
      controllers/admin/dept.go
  7. 90
      controllers/admin/dict.go
  8. 93
      controllers/admin/dict_detail.go
  9. 93
      controllers/admin/job.go
  10. 147
      controllers/admin/login.go
  11. 116
      controllers/admin/menu.go
  12. 124
      controllers/admin/role.go
  13. 16
      controllers/admin/tools.go
  14. 190
      controllers/admin/user.go
  15. 74
      controllers/base.go
  16. 8
      dto/auth_user.go
  17. 7
      dto/base.go
  18. 7
      dto/dict_post.go
  19. 6
      dto/dict_query.go
  20. 10
      dto/role_menu.go
  21. 6
      dto/user_pass.go
  22. 8
      dto/user_post.go
  23. 8
      dto/user_query.go
  24. 16
      go.mod
  25. 284
      go.sum
  26. 142
      jwt/jwt.go
  27. 131
      main.go
  28. 45
      models/base.go
  29. 68
      models/dept.go
  30. 56
      models/dict.go
  31. 68
      models/dict_detail.go
  32. 71
      models/job.go
  33. 23
      models/log.go
  34. 196
      models/menu.go
  35. 20
      models/picture.go
  36. 75
      models/role.go
  37. 13
      models/role_depts.go
  38. 30
      models/role_menus.go
  39. 209
      models/user.go
  40. 151
      models/user.go-bak
  41. 23
      models/users_roles.go
  42. 63
      redis/pool.go
  43. 59
      redis/redis.go
  44. 163
      routers/commentsRouter___________________Users_hupeng_go_src_yixiang_co_yshop_controllers.go
  45. 370
      routers/commentsRouter_controllers.go
  46. 71
      routers/router.go
  47. 419
      sql/yshop_go.sql
  48. BIN
      static/upload/1.jpg
  49. BIN
      static/upload/1614928266851.jpg
  50. BIN
      swagger/favicon-16x16.png
  51. BIN
      swagger/favicon-32x32.png
  52. 93
      swagger/index.html
  53. 53
      swagger/oauth2-redirect.html
  54. 108
      swagger/swagger-ui-bundle.js
  55. 1
      swagger/swagger-ui-bundle.js.map
  56. 20
      swagger/swagger-ui-standalone-preset.js
  57. 1
      swagger/swagger-ui-standalone-preset.js.map
  58. 2
      swagger/swagger-ui.css
  59. 1
      swagger/swagger-ui.css.map
  60. 15
      swagger/swagger-ui.js
  61. 1
      swagger/swagger-ui.js.map
  62. 989
      swagger/swagger.json
  63. 667
      swagger/swagger.yml
  64. 39
      tests/default_test.go
  65. 69
      untils/tools.go
  66. 13
      vo/jwt_user.go
  67. 8
      vo/login_vo.go
  68. 18
      vo/menu/menu_vo.go
  69. 6
      vo/result_list.go
  70. BIN
      yshop.tar.gz

5
.gitignore

@ -0,0 +1,5 @@
.idea/
logs/
lastupdate.tmp
yshop
*.exe

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.

66
README.md

@ -0,0 +1,66 @@
<h1 style="text-align: center">YSHOP-GO 后台管理系统</h1>
#### 项目简介
YSHOP-GO基于当前流行技术组合的前后端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/YSHOP-GO | https://gitee.com/guchengwuyue/YSHOP-GO-WEB |
| github | https://github.com/guchengwuyue/YSHOP-GO | https://github.com/guchengwuyue/YSHOP-GO-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 反向代理即可
```
#### 特别鸣谢
- 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 = "root"
mysqlpass = "root"
mysqlhost = "localhost"
mysqlport = 3306
mysqldb = "yshop_go"
db_max_idle_conn = 30
db_max_open_open = 100
maxmemory = 1<<22
#redis
redis_host = 127.0.0.1:6379
redis_pwd =
#日志等级 debug
logLevel = 7
jwt_token = 1BD6C43CA0BBF4B7ABA5E486D6A5AA2D
[prod]
#数据库配置
mysqluser = "root"
mysqlpass = ""
mysqlhost = "localhost"
mysqlport = 3306
mysqldb = "yshop_go"
db_max_idle_conn = 30
db_max_open_open = 100
maxmemory = 1<<22
#redis
redis_host = 127.0.0.1:6379
redis_pwd =
#日志等级 debug
logLevel = 4
jwt_token = 1BD6C43CA0BBF4B7ABA5E486D6A5AA2D

93
controllers/admin/dept.go

@ -0,0 +1,93 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.Dept
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.Dept
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/dict.go

@ -0,0 +1,90 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/validation"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.Dict
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.Dict
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/dict_detail.go

@ -0,0 +1,93 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.DictDetail
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.DictDetail
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/job.go

@ -0,0 +1,93 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.Job
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.Job
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()
}

147
controllers/admin/login.go

@ -0,0 +1,147 @@
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"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/jwt"
"yixiang.co/yshop/models"
"yixiang.co/yshop/untils"
"yixiang.co/yshop/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)
}

116
controllers/admin/menu.go

@ -0,0 +1,116 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/validation"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/jwt"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.Menu
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.Menu
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()
}

124
controllers/admin/role.go

@ -0,0 +1,124 @@
package admin
import (
"encoding/json"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/core/validation"
"strconv"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/models"
"yixiang.co/yshop/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.Role
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.Role
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/tools.go

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

190
controllers/admin/user.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"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/jwt"
"yixiang.co/yshop/models"
"yixiang.co/yshop/untils"
"yixiang.co/yshop/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.User
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.User
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()
}

74
controllers/base.go

@ -0,0 +1,74 @@
/**
* 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"
"yixiang.co/yshop/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
}

8
dto/auth_user.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/base.go

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

7
dto/dict_post.go

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

6
dto/dict_query.go

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

10
dto/role_menu.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/user_pass.go

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

8
dto/user_post.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/user_query.go

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

16
go.mod

@ -0,0 +1,16 @@
module yixiang.co/yshop
go 1.15
require github.com/beego/beego/v2 v2.0.1
require (
github.com/casbin/casbin v1.9.1
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
)

284
go.sum

@ -0,0 +1,284 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/beego/beego v1.12.3 h1:yHJ9h4lzC/Vp3z9DzYoL+8SvJo82nGPe5+LMmPa3IPw=
github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
github.com/casbin/casbin v1.9.1 h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM=
github.com/casbin/casbin v1.9.1/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v1.0.2 h1:KPldsxuKGsS2FPWsNeg9ZO18aCrGKujPoWXn2yo+KQM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/gomodule/redigo/redis v0.0.0-do-not-use h1:J7XIp6Kau0WoyT4JtXHT3Ei0gA1KkSc6bc87j9v9WIo=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mojocn/base64Captcha v1.3.1 h1:2Wbkt8Oc8qjmNJ5GyOfSo4tgVQPsbKMftqASnq8GlT0=
github.com/mojocn/base64Captcha v1.3.1/go.mod h1:wAQCKEc5bDujxKRmbT6/vTnTt5CjStQ8bRfPWUuz/iY=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 h1:TbGuee8sSq15Iguxu4deQ7+Bqq/d2rsQejGcEtADAMQ=
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 h1:nfeHNc1nAqecKCy2FCy4HY+soOOe5sDLJ/gZLbx6GYI=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58 h1:1Bs6RVeBFtLZ8Yi1Hk07DiOqzvwLD/4hln4iahvFlag=
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=

142
jwt/jwt.go

@ -0,0 +1,142 @@
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"
"yixiang.co/yshop/common"
"yixiang.co/yshop/models"
"yixiang.co/yshop/redis"
"yixiang.co/yshop/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.User,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.User {
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.User{}
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)
}

131
main.go

@ -0,0 +1,131 @@
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"
"yixiang.co/yshop/common"
"yixiang.co/yshop/controllers"
"yixiang.co/yshop/jwt"
"yixiang.co/yshop/models"
"yixiang.co/yshop/redis"
_ "yixiang.co/yshop/routers"
"yixiang.co/yshop/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("==========yshop管理后台 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()
}
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.User{}
json.Unmarshal([]byte(jsonStr),user)
index := untils.Contains(user.Permissions,permission)
return index
}

45
models/base.go

@ -0,0 +1,45 @@
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/dept.go

@ -0,0 +1,68 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"yixiang.co/yshop/untils"
)
type Dept struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Pid int64 `json:"pid"`
Enabled int8 `json:"enabled" valid:"Required;"`
Children []Dept `orm:"-" json:"children"`
Label string `orm:"-" json:"label"`
BaseModel
}
func init() {
orm.RegisterModel(new(Dept))
}
func GetAllDepts(name string, enabled int8) []Dept {
var depts []Dept
o := orm.NewOrm()
qs := o.QueryTable("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 []Dept, pid int64) []Dept {
var listTree = make([]Dept,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 *Dept) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDept(m *Dept) (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 dept SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

56
models/dict.go

@ -0,0 +1,56 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"yixiang.co/yshop/dto"
)
type Dict struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Remark string `json:"remark" valid:"Required;"`
BaseModel
}
func init() {
orm.RegisterModel(new(Dict))
}
// get all
func GetAllDict(base dto.BasePage,query ...interface{}) (int,[]Dict) {
var (
tableName = "dict"
dicts []Dict
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 *Dict) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDict(m *Dict) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByDict(id int64) (err error) {
o := orm.NewOrm()
_, err = o.Raw("UPDATE dict SET is_del = ? WHERE id = ?", 1, id).Exec()
return
}

68
models/dict_detail.go

@ -0,0 +1,68 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"strconv"
"yixiang.co/yshop/dto"
)
type DictDetail 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(DictDetail))
}
// get all
func GetAllDictDetail(base dto.BasePage,query ...interface{}) (int,[]DictDetail) {
var (
tableName = "dict_detail"
lists []DictDetail
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 *DictDetail) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByDictDetail(m *DictDetail) (err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func DelByDictDetail(id int64) (err error) {
o := orm.NewOrm()
_, err = o.Raw("UPDATE dict_detail SET is_del = ? WHERE id = ?", 1, id).Exec()
return
}

71
models/job.go

@ -0,0 +1,71 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"strconv"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/untils"
)
type Job struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"Required;"`
Enabled int8 `json:"enabled"`
Sort int8 `json:"sort"`
//DeptId int64 `json:"deptId"`
Dept *Dept `json:"dept" orm:"column(dept_id);bigint;rel(one)""`
BaseModel
}
func init() {
orm.RegisterModel(new(Job))
}
// get all
func GetAllJob(base dto.BasePage,query ...interface{}) (int,[]Job) {
var (
tableName = "job"
lists []Job
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 *Job) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByJob(m *Job) (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 job SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

23
models/log.go

@ -0,0 +1,23 @@
package models
import "github.com/beego/beego/v2/client/orm"
type Log 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(Log))
}

196
models/menu.go

@ -0,0 +1,196 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"yixiang.co/yshop/untils"
"yixiang.co/yshop/vo/menu"
)
type Menu 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 []Menu `json:"children" orm:"-"`
Label string `orm:"-" json:"label"`
BaseModel
}
func init() {
orm.RegisterModel(new(Menu))
}
func GetAllMenus(name string) []Menu {
var menus []Menu
o := orm.NewOrm()
qs := o.QueryTable("menu").Filter("is_del",0)
if name != "" {
qs = qs.Filter("name",name)
}
qs.All(&menus)
return RecursionMenuList(menus,0)
}
//递归函数
func RecursionMenuList(data []Menu, pid int64) []Menu {
var listTree = make([]Menu,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 *Menu) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByMenu(m *Menu) (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 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 Menu
err := o.QueryTable(new(Menu)).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 role r, 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 []Menu
_, e := o.Raw("select m.* from menu m LEFT OUTER JOIN roles_menus t on m.id= t.menu_id " +
"LEFT OUTER JOIN 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 []Menu) ([]Menu) {
var trees []Menu
for _, menu := range menus {
if menu.Pid == 0 {
trees = append(trees, menu)
}
}
for k, tree := range trees {
var child []Menu
for _, it := range menus {
if it.Pid == tree.Id {
child = append(child,it)
}
}
trees[k].Children = child
}
return trees
}
func buildMenus(menus []Menu) []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/picture.go

@ -0,0 +1,20 @@
package models
import "github.com/beego/beego/v2/client/orm"
type Picture 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(Picture))
}

75
models/role.go

@ -0,0 +1,75 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/untils"
)
type Role 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 []*User `orm:"reverse(many)"`
Menus []*Menu `json:"menus" orm:"rel(m2m);rel_through(yixiang.co/yshop/models.RolesMenus)"`
Depts []*Dept `orm:"rel(m2m);rel_through(yixiang.co/yshop/models.RolesDepts)"`
BaseModel
}
func init() {
orm.RegisterModel(new(Role))
}
func GetOneRole(id int64) Role {
o := orm.NewOrm()
role := Role{Id: id}
o.Read(&role)
_, _ = o.LoadRelated(&role, "Menus")
return role
}
// get all
func GetAllRole(base dto.BasePage,query ...interface{}) (int,[]Role) {
var (
tableName = "role"
lists []Role
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 *Role) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
func UpdateByRole(m *Role) (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 role SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
return
}

13
models/role_depts.go

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

30
models/role_menus.go

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

209
models/user.go

@ -0,0 +1,209 @@
package models
import (
"context"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"strconv"
"yixiang.co/yshop/dto"
"yixiang.co/yshop/untils"
)
type User 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 []*Role `json:"roles" orm:"rel(m2m);rel_through(yixiang.co/yshop/models.UsersRoles)"`
Jobs *Job `json:"job" orm:"column(job_id);bigint;rel(one)""`
Depts *Dept `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(User))
}
func FindByUserId(id int64) ([]string,error) {
o := orm.NewOrm()
var roles []Role
_, err := o.Raw("SELECT r.* FROM role r, 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 *User, err error) {
o := orm.NewOrm()
user := &User{}
err = o.QueryTable(new(User)).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 *User, err error) {
//var userlist []User
o := orm.NewOrm()
v = &User{Id: id}
err = o.QueryTable(new(User)).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,[]User) {
var (
tableName = "user"
users []User
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 *User) ( err error) {
o := orm.NewOrm()
_, err = o.Update(m)
return
}
func AddUser(m *User) (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 users_roles (user_id,role_id) VALUES (?,?)", id, roleId).Exec()
}
return ee
})
return 0,err
}
func UpdateByUser(m *User) (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 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 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 user SET is_del = ? WHERE id in("+str+")", 1, ids).Exec()
_, e2 := txOrm.Raw("delete from users_roles WHERE user_id in("+str+")", ids).Exec()
if e1 != nil {
return e1
}
return e2
})
return
}

151
models/user.go-bak

@ -0,0 +1,151 @@
package models
import (
"errors"
"fmt"
"github.com/beego/beego/v2/client/orm"
"reflect"
"strings"
)
type User struct {
Id int64
Avatar string
Email string
Enabled int8
Password string
Username string
DeptId int32
Phone string
JobId int32
NickName string
Sex string
BaseModel
}
func init() {
orm.RegisterModel(new(User))
}
// AddUser insert a new User into database and returns
// last inserted Id on success.
func AddUser(m *User) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetUserById retrieves User by Id. Returns error if
// Id doesn't exist
func GetUserById(id int64) (v *User, err error) {
o := orm.NewOrm()
v = &User{Id: id}
if err = o.QueryTable(new(User)).Filter("Id", id).RelatedSel().One(v); err == nil {
return v, nil
}
return nil, err
}
// GetAllUser retrieves all User matches certain condition. Returns empty list if
// no records exist
func GetAllUser(query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(User))
// query k=v
for k, v := range query {
// rewrite dot-notation to Object__Attribute
k = strings.Replace(k, ".", "__", -1)
qs = qs.Filter(k, v)
}
// order by:
var sortFields []string
if len(sortby) != 0 {
if len(sortby) == len(order) {
// 1) for each sort field, there is an associated order
for i, v := range sortby {
orderby := ""
if order[i] == "desc" {
orderby = "-" + v
} else if order[i] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
orderby := ""
if order[0] == "desc" {
orderby = "-" + v
} else if order[0] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
} else if len(sortby) != len(order) && len(order) != 1 {
return nil, errors.New("Error: 'sortby', 'order' sizes mismatch or 'order' size is not 1")
}
} else {
if len(order) != 0 {
return nil, errors.New("Error: unused 'order' fields")
}
}
var l []User
qs = qs.OrderBy(sortFields...).RelatedSel()
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {
ml = append(ml, v)
}
} else {
// trim unused fields
for _, v := range l {
m := make(map[string]interface{})
val := reflect.ValueOf(v)
for _, fname := range fields {
m[fname] = val.FieldByName(fname).Interface()
}
ml = append(ml, m)
}
}
return ml, nil
}
return nil, err
}
// UpdateUser updates User by Id and returns error if
// the record to be updated doesn't exist
func UpdateUserById(m *User) (err error) {
o := orm.NewOrm()
v := User{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteUser deletes User by Id and returns error if
// the record to be deleted doesn't exist
func DeleteUser(id int64) (err error) {
o := orm.NewOrm()
v := User{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&User{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}

23
models/users_roles.go

@ -0,0 +1,23 @@
package models
import (
"github.com/beego/beego/v2/client/orm"
)
type UsersRoles struct {
Id int64
UserId *User `orm:"column(user_id);rel(fk)"`
RoleId *Role `orm:"column(role_id);rel(fk)"`
}
func init() {
orm.RegisterModel(new(UsersRoles))
}
func AddUserRole(m *UsersRoles) (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
}

163
routers/commentsRouter___________________Users_hupeng_go_src_yixiang_co_yshop_controllers.go

@ -0,0 +1,163 @@
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context/param"
)
func init() {
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"],
beego.ControllerComments{
Method: "GetOne",
Router: "/:id",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"],
beego.ControllerComments{
Method: "Put",
Router: "/:id",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MemberController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:id",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"],
beego.ControllerComments{
Method: "Get",
Router: "/:objectId",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"],
beego.ControllerComments{
Method: "Put",
Router: "/:objectId",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:ObjectController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:objectId",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Get",
Router: "/:uid",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Put",
Router: "/:uid",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:uid",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Login",
Router: "/login",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers:UserController"],
beego.ControllerComments{
Method: "Logout",
Router: "/logout",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

370
routers/commentsRouter_controllers.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["yixiang.co/yshop/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DeptController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:id",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:DictDetailController"],
beego.ControllerComments{
Method: "Delete",
Router: "/:id",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:JobController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Captcha",
Router: "/captcha",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Info",
Router: "/info",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Login",
Router: "/login",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:LoginController"],
beego.ControllerComments{
Method: "Logout",
Router: "/logout",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "Build",
Router: "/build",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:MenuController"],
beego.ControllerComments{
Method: "GetTree",
Router: "/tree",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "GetOne",
Router: "/:id",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:RoleController"],
beego.ControllerComments{
Method: "Menu",
Router: "/menu",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:ToolsController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:ToolsController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Post",
Router: "/",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Put",
Router: "/",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Delete",
Router: "/",
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Center",
Router: "/center",
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Avatar",
Router: "/updateAvatar",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"] = append(beego.GlobalControllerRouter["yixiang.co/yshop/controllers/admin:UserController"],
beego.ControllerComments{
Method: "Pass",
Router: "/updatePass",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

71
routers/router.go

@ -0,0 +1,71 @@
// @APIVersion 1.0.0
// @Title YSHOP-GO API
// @Description YSHOP-GO管理系统API
// @TermsOfServiceUrl https://www.yixiang.co/
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"yixiang.co/yshop/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")
}

419
sql/yshop_go.sql

@ -0,0 +1,419 @@
/*
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: 07/03/2021 10:38:07
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for dept
-- ----------------------------
DROP TABLE IF EXISTS `dept`;
CREATE TABLE `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 dept
-- ----------------------------
BEGIN;
INSERT INTO `dept` VALUES (1, 'YSHOP', 0, 1, '2021-02-26 14:51:14', NULL, 0);
INSERT INTO `dept` VALUES (2, '研发部', 7, 1, '2019-03-25 09:15:32', NULL, 0);
INSERT INTO `dept` VALUES (5, '运维部', 7, 1, '2019-03-25 09:20:44', NULL, 0);
INSERT INTO `dept` VALUES (6, '测试部', 8, 0, '2021-02-25 16:22:53', NULL, 0);
INSERT INTO `dept` VALUES (7, '华南分部', 1, 1, '2019-03-25 11:04:50', NULL, 0);
INSERT INTO `dept` VALUES (8, '华北分部', 1, 1, '2019-03-25 11:04:53', NULL, 0);
INSERT INTO `dept` VALUES (11, '人事部', 8, 1, '2019-03-25 11:07:58', NULL, 0);
INSERT INTO `dept` VALUES (12, '7773888', 1, 1, '2021-02-26 15:04:43', NULL, 1);
INSERT INTO `dept` VALUES (13, '333', 1, 0, '2021-02-26 14:28:26', '2021-02-26 14:28:26', 1);
INSERT INTO `dept` VALUES (14, '9922', 13, 1, '2021-02-26 15:05:05', '2021-02-26 14:29:17', 1);
COMMIT;
-- ----------------------------
-- Table structure for dict
-- ----------------------------
DROP TABLE IF EXISTS `dict`;
CREATE TABLE `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 dict
-- ----------------------------
BEGIN;
INSERT INTO `dict` VALUES (1, 'user_status', '用户状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `dict` VALUES (4, 'dept_status', '部门状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `dict` VALUES (5, 'job_status', '岗位状态', '2019-10-27 20:31:36', NULL, 0);
INSERT INTO `dict` VALUES (6, '33', '3', '2020-05-18 19:55:49', NULL, 1);
INSERT INTO `dict` VALUES (16, 'force_update', '强制升级', '2020-12-09 11:13:21', NULL, 0);
INSERT INTO `dict` VALUES (17, 'is_enable', '是否启用', '2020-12-10 12:02:57', NULL, 0);
INSERT INTO `dict` VALUES (18, 'sex2', '性别', '2021-02-23 15:20:40', '2021-02-23 14:12:04', 0);
INSERT INTO `dict` VALUES (19, 'sex4', '性别', '2021-02-23 15:20:20', '2021-02-23 14:14:29', 0);
COMMIT;
-- ----------------------------
-- Table structure for dict_detail
-- ----------------------------
DROP TABLE IF EXISTS `dict_detail`;
CREATE TABLE `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 `dict` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='数据字典详情';
-- ----------------------------
-- Records of dict_detail
-- ----------------------------
BEGIN;
INSERT INTO `dict_detail` VALUES (1, '激活', '1', 1, 1, '2021-03-04 13:48:42', NULL, 0, 'user_status');
INSERT INTO `dict_detail` VALUES (2, '禁用', '0', 2, 1, '2021-03-04 13:48:49', NULL, 0, 'user_status');
INSERT INTO `dict_detail` VALUES (3, '启用', '1', 1, 4, '2021-02-25 16:12:46', NULL, 0, 'dept_status');
INSERT INTO `dict_detail` VALUES (4, '停用', '0', 2, 4, '2021-02-25 16:12:51', NULL, 0, 'dept_status');
INSERT INTO `dict_detail` VALUES (5, '启用', '1', 1, 5, '2021-02-26 16:23:39', NULL, 0, 'job_status');
INSERT INTO `dict_detail` VALUES (6, '停用', '0', 2, 5, '2021-02-26 16:23:46', NULL, 0, 'job_status');
INSERT INTO `dict_detail` VALUES (20, '', '1', 999, 16, '2020-12-09 11:41:30', NULL, 0, 'force_update');
INSERT INTO `dict_detail` VALUES (21, '', '0', 999, 16, '2020-12-09 11:41:36', NULL, 0, 'force_update');
INSERT INTO `dict_detail` VALUES (22, '', '1', 999, 17, '2021-02-25 15:32:00', NULL, 0, 'is_enable');
INSERT INTO `dict_detail` VALUES (23, '', '0', 999, 17, '2020-12-10 12:03:16', NULL, 0, 'is_enable');
COMMIT;
-- ----------------------------
-- Table structure for job
-- ----------------------------
DROP TABLE IF EXISTS `job`;
CREATE TABLE `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 `dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='岗位';
-- ----------------------------
-- Records of job
-- ----------------------------
BEGIN;
INSERT INTO `job` VALUES (8, '人事专员', 1, 3, 11, '2021-03-07 10:15:49', NULL, 0);
INSERT INTO `job` VALUES (10, '产品经理', 1, 4, 2, '2019-03-29 14:55:51', NULL, 0);
INSERT INTO `job` VALUES (11, '全栈开发2', 1, 2, 2, '2019-03-31 13:39:30', NULL, 0);
INSERT INTO `job` VALUES (12, '软件测试', 1, 5, 2, '2019-03-31 13:39:43', NULL, 0);
INSERT INTO `job` VALUES (13, '6665', 1, 0, 1, '2021-03-02 15:45:16', '2021-03-02 15:42:55', 1);
INSERT INTO `job` VALUES (14, '99', 1, 0, 5, '2021-03-02 15:44:05', '2021-03-02 15:44:05', 1);
COMMIT;
-- ----------------------------
-- Table structure for menu
-- ----------------------------
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `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 menu
-- ----------------------------
BEGIN;
INSERT INTO `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 `menu` VALUES (127, 0, '用户新增', '', 2, 2, '', '', 0, 0, '', '2021-03-06 10:30:11', 'user:add', 2, NULL, 0, '/admin/user', 'post');
INSERT INTO `menu` VALUES (128, 0, '用户编辑', '', 2, 3, '', '', 0, 0, '', '2021-03-06 10:30:38', 'user:edit', 2, NULL, 0, '/admin/user', 'edit');
INSERT INTO `menu` VALUES (129, 0, '用户删除', '', 2, 4, '', '', 0, 0, '', '2021-03-06 10:30:48', 'user:del', 2, NULL, 0, '/admin/user', 'delete');
INSERT INTO `menu` VALUES (130, 0, '角色创建', '', 3, 2, '', '', 0, 0, '', '2021-03-06 10:32:15', 'roles:add', 2, NULL, 0, '/admin/roles', 'post');
INSERT INTO `menu` VALUES (131, 0, '角色修改', '', 3, 3, '', '', 0, 0, '', '2021-03-06 10:32:27', 'roles:edit', 2, NULL, 0, '/admin/roles', 'put');
INSERT INTO `menu` VALUES (132, 0, '角色删除', '', 3, 999, '', '', 0, 0, '', '2021-03-06 10:32:40', 'roles:del', 2, NULL, 0, '/admin/roles', 'delete');
INSERT INTO `menu` VALUES (133, 0, '菜单新增', '', 5, 2, '', '', 0, 0, '', '2021-03-06 10:33:27', 'menu:add', 2, NULL, 0, '/admin/menu', 'post');
INSERT INTO `menu` VALUES (134, 0, '菜单编辑', '', 5, 3, '', '', 0, 0, '', '2021-03-06 10:33:37', 'menu:edit', 2, NULL, 0, '/admin/menu', 'put');
INSERT INTO `menu` VALUES (135, 0, '菜单删除', '', 5, 4, '', '', 0, 0, '', '2021-03-06 10:33:47', 'menu:del', 2, NULL, 0, '/admin/menu', 'delete');
INSERT INTO `menu` VALUES (136, 0, '部门新增', '', 35, 2, '', '', 0, 0, '', '2021-03-06 10:34:58', 'dept:add', 2, NULL, 0, '/admin/dept', 'post');
INSERT INTO `menu` VALUES (137, 0, '部门编辑', '', 35, 3, '', '', 0, 0, '', '2021-03-06 10:35:07', 'dept:edit', 2, NULL, 0, '/admin/dept', 'put');
INSERT INTO `menu` VALUES (138, 0, '部门删除', '', 35, 4, '', '', 0, 0, '', '2021-03-06 10:35:16', 'dept:del', 2, NULL, 0, '/admin/dept', 'delete');
INSERT INTO `menu` VALUES (139, 0, '岗位新增', '', 37, 2, '', '', 0, 0, '', '2021-03-06 10:35:53', 'job:add', 2, NULL, 0, '/admin/job', 'post');
INSERT INTO `menu` VALUES (140, 0, '岗位编辑', '', 37, 3, '', '', 0, 0, '', '2021-03-06 10:36:02', 'job:edit', 2, NULL, 0, '/admin/job', 'put');
INSERT INTO `menu` VALUES (141, 0, '岗位删除', '', 37, 4, '', '', 0, 0, '', '2021-03-06 10:36:10', 'job:del', 2, NULL, 0, '/admin/job', 'delete');
INSERT INTO `menu` VALUES (142, 0, '字典新增', '', 39, 2, '', '', 0, 0, '', '2021-03-06 10:36:51', 'dict:add', 2, NULL, 0, '/admin/dict', 'post');
INSERT INTO `menu` VALUES (143, 0, '字典编辑', '', 39, 3, '', '', 0, 0, '', '2021-03-06 10:36:59', 'dict:edit', 2, NULL, 0, '/admin/dict', 'put');
INSERT INTO `menu` VALUES (144, 0, '字典删除', '', 39, 4, '', '', 0, 0, '', '2021-03-06 10:37:10', 'dict:del', 2, NULL, 0, '/admin/dict', 'delete');
INSERT INTO `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 `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 role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `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 role
-- ----------------------------
BEGIN;
INSERT INTO `role` VALUES (1, '超级管理员', '-', '全部', 1, '2018-11-23 11:04:37', 'admin', NULL, 0);
INSERT INTO `role` VALUES (2, '普通用户', '-555', '本级', 2, '2021-03-07 10:09:08', 'common', NULL, 0);
INSERT INTO `role` VALUES (3, '管理员2', '222', '全部', 3, '2020-01-31 16:53:25', '22', NULL, 0);
INSERT INTO `role` VALUES (4, '667', '66', '全部', 3, '2021-03-02 16:16:43', '666', '2021-03-02 16:15:20', 1);
INSERT INTO `role` VALUES (5, '99', '9', '全部', 3, '2021-03-02 16:16:35', '9', '2021-03-02 16:16:35', 1);
COMMIT;
-- ----------------------------
-- Table structure for roles_depts
-- ----------------------------
DROP TABLE IF EXISTS `roles_depts`;
CREATE TABLE `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 roles_depts
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for roles_menus
-- ----------------------------
DROP TABLE IF EXISTS `roles_menus`;
CREATE TABLE `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=472 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色菜单关联';
-- ----------------------------
-- Records of roles_menus
-- ----------------------------
BEGIN;
INSERT INTO `roles_menus` VALUES (1, 3, 199);
INSERT INTO `roles_menus` VALUES (2, 3, 200);
INSERT INTO `roles_menus` VALUES (127, 3, 201);
INSERT INTO `roles_menus` VALUES (128, 3, 202);
INSERT INTO `roles_menus` VALUES (129, 3, 203);
INSERT INTO `roles_menus` VALUES (3, 3, 204);
INSERT INTO `roles_menus` VALUES (130, 3, 205);
INSERT INTO `roles_menus` VALUES (131, 3, 206);
INSERT INTO `roles_menus` VALUES (132, 3, 207);
INSERT INTO `roles_menus` VALUES (5, 3, 208);
INSERT INTO `roles_menus` VALUES (133, 3, 209);
INSERT INTO `roles_menus` VALUES (134, 3, 210);
INSERT INTO `roles_menus` VALUES (135, 3, 211);
INSERT INTO `roles_menus` VALUES (35, 3, 212);
INSERT INTO `roles_menus` VALUES (136, 3, 213);
INSERT INTO `roles_menus` VALUES (137, 3, 214);
INSERT INTO `roles_menus` VALUES (138, 3, 215);
INSERT INTO `roles_menus` VALUES (37, 3, 216);
INSERT INTO `roles_menus` VALUES (139, 3, 217);
INSERT INTO `roles_menus` VALUES (140, 3, 218);
INSERT INTO `roles_menus` VALUES (141, 3, 219);
INSERT INTO `roles_menus` VALUES (39, 3, 220);
INSERT INTO `roles_menus` VALUES (142, 3, 221);
INSERT INTO `roles_menus` VALUES (143, 3, 222);
INSERT INTO `roles_menus` VALUES (144, 3, 223);
INSERT INTO `roles_menus` VALUES (1, 1, 411);
INSERT INTO `roles_menus` VALUES (2, 1, 412);
INSERT INTO `roles_menus` VALUES (127, 1, 413);
INSERT INTO `roles_menus` VALUES (128, 1, 414);
INSERT INTO `roles_menus` VALUES (129, 1, 415);
INSERT INTO `roles_menus` VALUES (276, 1, 416);
INSERT INTO `roles_menus` VALUES (277, 1, 417);
INSERT INTO `roles_menus` VALUES (278, 1, 418);
INSERT INTO `roles_menus` VALUES (3, 1, 419);
INSERT INTO `roles_menus` VALUES (130, 1, 420);
INSERT INTO `roles_menus` VALUES (131, 1, 421);
INSERT INTO `roles_menus` VALUES (132, 1, 422);
INSERT INTO `roles_menus` VALUES (273, 1, 423);
INSERT INTO `roles_menus` VALUES (274, 1, 424);
INSERT INTO `roles_menus` VALUES (275, 1, 425);
INSERT INTO `roles_menus` VALUES (5, 1, 426);
INSERT INTO `roles_menus` VALUES (133, 1, 427);
INSERT INTO `roles_menus` VALUES (134, 1, 428);
INSERT INTO `roles_menus` VALUES (135, 1, 429);
INSERT INTO `roles_menus` VALUES (35, 1, 430);
INSERT INTO `roles_menus` VALUES (136, 1, 431);
INSERT INTO `roles_menus` VALUES (137, 1, 432);
INSERT INTO `roles_menus` VALUES (138, 1, 433);
INSERT INTO `roles_menus` VALUES (37, 1, 434);
INSERT INTO `roles_menus` VALUES (139, 1, 435);
INSERT INTO `roles_menus` VALUES (140, 1, 436);
INSERT INTO `roles_menus` VALUES (141, 1, 437);
INSERT INTO `roles_menus` VALUES (39, 1, 438);
INSERT INTO `roles_menus` VALUES (142, 1, 439);
INSERT INTO `roles_menus` VALUES (143, 1, 440);
INSERT INTO `roles_menus` VALUES (144, 1, 441);
INSERT INTO `roles_menus` VALUES (269, 1, 442);
INSERT INTO `roles_menus` VALUES (270, 1, 443);
INSERT INTO `roles_menus` VALUES (271, 1, 444);
INSERT INTO `roles_menus` VALUES (272, 1, 445);
INSERT INTO `roles_menus` VALUES (36, 1, 446);
INSERT INTO `roles_menus` VALUES (123, 1, 447);
INSERT INTO `roles_menus` VALUES (1, 2, 461);
INSERT INTO `roles_menus` VALUES (35, 2, 462);
INSERT INTO `roles_menus` VALUES (37, 2, 463);
INSERT INTO `roles_menus` VALUES (136, 2, 464);
INSERT INTO `roles_menus` VALUES (137, 2, 465);
INSERT INTO `roles_menus` VALUES (139, 2, 466);
INSERT INTO `roles_menus` VALUES (140, 2, 467);
INSERT INTO `roles_menus` VALUES (269, 2, 468);
INSERT INTO `roles_menus` VALUES (270, 2, 469);
INSERT INTO `roles_menus` VALUES (271, 2, 470);
INSERT INTO `roles_menus` VALUES (272, 2, 471);
COMMIT;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `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 `dept` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `FKfftoc2abhot8f2wu6cl9a5iky` FOREIGN KEY (`job_id`) REFERENCES `job` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=9998 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `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 `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 `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 `user` VALUES (5, '', '444@qq.com', 1, '$2a$10$f/VH35NBOBszycV9KEA1HenQ0qVjazDm8LacQU9PO.A4UizFxLMuq', 'qqqqq', 11, '15136175249', 8, '2021-03-04 16:22:56', 'eeeeee', '', NULL, 0);
INSERT INTO `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 `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 `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 `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 users_roles
-- ----------------------------
DROP TABLE IF EXISTS `users_roles`;
CREATE TABLE `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 users_roles
-- ----------------------------
BEGIN;
INSERT INTO `users_roles` VALUES (1, 1, 1);
INSERT INTO `users_roles` VALUES (3, 2, 2);
INSERT INTO `users_roles` VALUES (4, 2, 3);
INSERT INTO `users_roles` VALUES (5, 2, 4);
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": "YSHOP-GO API",
"description": "YSHOP-GO管理系统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: YSHOP-GO API
description: YSHOP-GO管理系统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

39
tests/default_test.go

@ -0,0 +1,39 @@
package test
import (
"net/http"
"net/http/httptest"
"testing"
"runtime"
"path/filepath"
_ "yixiang.co/yshop/routers"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/core/logs"
. "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)
})
})
}

69
untils/tools.go

@ -0,0 +1,69 @@
package untils
import (
"fmt"
"golang.org/x/crypto/bcrypt"
"reflect"
"strings"
"yixiang.co/yshop/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/jwt_user.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/login_vo.go

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

18
vo/menu/menu_vo.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"`
}

6
vo/result_list.go

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

BIN
yshop.tar.gz

Binary file not shown.
Loading…
Cancel
Save