Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
是阿延啊
gin-vue-admin
提交
6fbb6f23
G
gin-vue-admin
项目概览
是阿延啊
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6fbb6f23
编写于
3月 28, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加了前端api模板
上级
82d16032
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
515 addition
and
32 deletion
+515
-32
QMPlusServer/autoCode/fe/autocode/api/api.js
QMPlusServer/autoCode/fe/autocode/api/api.js
+84
-0
QMPlusServer/autoCode/te/autocode/api/api.go
QMPlusServer/autoCode/te/autocode/api/api.go
+118
-0
QMPlusServer/autoCode/te/autocode/model/model.go
QMPlusServer/autoCode/te/autocode/model/model.go
+52
-0
QMPlusServer/autoCode/te/autocode/router/router.go
QMPlusServer/autoCode/te/autocode/router/router.go
+18
-0
QMPlusServer/model/autoCodeModel/autoCode.go
QMPlusServer/model/autoCodeModel/autoCode.go
+51
-31
QMPlusServer/tpl/fe/api.js.tpl
QMPlusServer/tpl/fe/api.js.tpl
+84
-0
QMPlusServer/tpl/te/api.go.tpl
QMPlusServer/tpl/te/api.go.tpl
+90
-1
QMPlusServer/tpl/te/router.go.tpl
QMPlusServer/tpl/te/router.go.tpl
+18
-0
未找到文件。
QMPlusServer/autoCode/fe/autocode/api/api.js
0 → 100644
浏览文件 @
6fbb6f23
import
service
from
'
@/utils/request
'
// @Tags Test
// @Summary 创建Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "创建Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/createTest [post]
export
const
createTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/createTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 删除Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "删除Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /t/deleteTest [post]
export
const
deleteTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/deleteTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 更新Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "更新Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /t/updateTest [post]
export
const
updateTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/updateTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 用id查询Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "用id查询Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /t/findTest [post]
export
const
findTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/findTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 分页获取Test列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/getTestList [post]
export
const
getTestList
=
(
data
)
=>
{
return
service
({
url
:
"
/t/getTestList
"
,
method
:
'
post
'
,
data
})
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/api/api.go
0 → 100644
浏览文件 @
6fbb6f23
package
api
import
(
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/model/modelInterface"
// 请自行引入model路径
"github.com/gin-gonic/gin"
)
// @Tags Test
// @Summary 创建Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "创建Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/createTest [post]
func
CreateTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
:=
t
.
CreateTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags Test
// @Summary 删除Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "删除Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /t/deleteTest [post]
func
DeleteTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
:=
t
.
DeleteTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"删除失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags Test
// @Summary 更新Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "更新Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /t/updateTest [post]
func
UpdateTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
,
ret
:=
t
.
UpdateTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"更新失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"更新成功"
,
gin
.
H
{
"ret"
:
ret
,
})
}
}
// @Tags Test
// @Summary 用id查询Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "用id查询Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /t/findTest [post]
func
FindTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
,
ret
:=
t
.
FindById
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"查询失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"查询成功"
,
gin
.
H
{
"ret"
:
ret
,
})
}
}
// @Tags Test
// @Summary 分页获取Test列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/getTestList [post]
func
GetTestList
(
c
*
gin
.
Context
)
{
var
pageInfo
modelInterface
.
PageInfo
_
=
c
.
ShouldBindJSON
(
&
pageInfo
)
err
,
list
,
total
:=
new
(
autocode
.
Test
)
.
GetInfoList
(
pageInfo
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"获取数据失败,%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"获取数据成功"
,
gin
.
H
{
"autocodeList"
:
list
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
})
}
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/model/model.go
0 → 100644
浏览文件 @
6fbb6f23
// 自动生成模板Test
package
autocode
import
(
"gin-vue-admin/controller/servers"
"gin-vue-admin/init/qmsql"
"gin-vue-admin/model/modelInterface"
"github.com/jinzhu/gorm"
)
type
Test
struct
{
gorm
.
Model
TestComponent
string
`json:"testComponent"`
TestBigComponent
int
`json:"testBigComponent"`
}
// 创建Test
func
(
t
*
Test
)
CreateTest
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Create
(
t
)
.
Error
return
err
}
// 删除Test
func
(
t
*
Test
)
DeleteTest
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Delete
(
t
)
.
Error
return
err
}
// 更新Test
func
(
t
*
Test
)
UpdateTest
()(
err
error
,
ret
Test
){
err
=
qmsql
.
DEFAULTDB
.
Save
(
t
)
.
Error
return
err
,
*
t
}
// 根据ID查看单条Test
func
(
t
*
Test
)
FindById
()(
err
error
,
ret
Test
){
err
=
qmsql
.
DEFAULTDB
.
Where
(
"id = ?"
,
t
.
ID
)
.
First
(
&
ret
)
.
Error
return
err
,
ret
}
// 分页获取Test
func
(
t
*
Test
)
GetInfoList
(
info
modelInterface
.
PageInfo
)(
err
error
,
list
interface
{},
total
int
){
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
err
,
db
,
total
:=
servers
.
PagingServer
(
t
,
info
)
if
err
!=
nil
{
return
}
else
{
var
reTestList
[]
Test
err
=
db
.
Find
(
&
reTestList
)
.
Error
return
err
,
reTestList
,
total
}
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/router/router.go
0 → 100644
浏览文件 @
6fbb6f23
package
router
import
(
"gin-vue-admin/controller/api"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func
InitTestRouter
(
Router
*
gin
.
RouterGroup
)
{
TestRouter
:=
Router
.
Group
(
"t"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
TestRouter
.
POST
(
"createTest"
,
api
.
CreateTest
)
// 新建Test
TestRouter
.
POST
(
"deleteTest"
,
api
.
DeleteTest
)
//删除Test
TestRouter
.
POST
(
"updateTest"
,
api
.
UpdateTest
)
//更新Test
TestRouter
.
POST
(
"findTest "
,
api
.
FindTest
)
// 根据ID获取Test
TestRouter
.
POST
(
"getTestList"
,
api
.
GetTestList
)
//获取Test列表
}
}
QMPlusServer/model/autoCodeModel/autoCode.go
浏览文件 @
6fbb6f23
...
...
@@ -2,6 +2,7 @@ package autoCodeModel
import
(
"fmt"
"gin-vue-admin/tools"
"html/template"
"os"
)
...
...
@@ -31,8 +32,13 @@ type Dictionary struct {
}
func
Temp
()
{
tmpl
,
err
:=
template
.
ParseFiles
(
"../../tpl/te/struct.go.tpl"
)
fmt
.
Println
(
tmpl
,
err
)
modelTmpl
,
modelTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/model.go.tpl"
)
apiTmpl
,
apiTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/api.go.tpl"
)
routerTmpl
,
routerTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/router.go.tpl"
)
feapiTmpl
,
feapiTplErr
:=
template
.
ParseFiles
(
"../../tpl/fe/api.js.tpl"
)
fmt
.
Println
(
modelTplErr
,
apiTplErr
,
routerTplErr
,
feapiTplErr
)
a1
:=
Component
{
ComponentName
:
"TestComponent"
,
ComponentType
:
"string"
,
...
...
@@ -59,37 +65,51 @@ func Temp() {
Abbreviation
:
"t"
,
Components
:
[]
Component
{
a1
,
a2
},
}
_autoCode
:=
"../../autoCode/"
_te
:=
"../../autoCode/te/"
_dir
:=
"../../autoCode/te/"
+
a
.
PackageName
_modeldir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/model"
_apidir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/api"
_routerdir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/router"
_fe
:=
"../../autoCode/fe/"
_fe_dir
:=
"../../autoCode/fe/"
+
a
.
PackageName
_fe_apidir
:=
"../../autoCode/fe/"
+
a
.
PackageName
+
"/api"
mkerr
:=
createDir
(
_autoCode
,
_te
,
_dir
,
_modeldir
,
_apidir
,
_routerdir
,
_fe
,
_fe_dir
,
_fe_apidir
)
fmt
.
Print
(
mkerr
)
model
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/model/model.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
api
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/api/api.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
router
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/router/router.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
feapi
,
_
:=
os
.
OpenFile
(
"../../autoCode/fe/"
+
a
.
PackageName
+
"/api/api.js"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
modelErr
:=
modelTmpl
.
Execute
(
model
,
a
)
apiErr
:=
apiTmpl
.
Execute
(
api
,
a
)
routerErr
:=
routerTmpl
.
Execute
(
router
,
a
)
feapiErr
:=
feapiTmpl
.
Execute
(
feapi
,
a
)
fmt
.
Println
(
modelErr
,
apiErr
,
routerErr
,
feapiErr
)
}
_dir
:=
"../"
+
a
.
PackageName
exist
,
err
:=
pathExists
(
_dir
)
//批量创建文件夹
func
createDir
(
dirs
...
string
)(
err
error
){
for
_
,
v
:=
range
dirs
{
exist
,
err
:=
tools
.
PathExists
(
v
)
if
err
!=
nil
{
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
return
return
err
}
if
exist
{
//log.L.Info(fmt.Sprintf("has dir![%v]\n"+_dir))
}
else
{
//log.L.Info(fmt.Sprintf("no dir![%v]\n"+_dir))
// 创建文件夹
err
:=
os
.
Mkdir
(
_dir
,
os
.
ModePerm
)
err
=
os
.
Mkdir
(
v
,
os
.
ModePerm
)
if
err
!=
nil
{
//log.L.Error(fmt.Sprintf("mkdir error![%v]\n",err))
}
else
{
//log.L.Info("mkdir success!\n")
}
}
file
,
err
:=
os
.
OpenFile
(
"../"
+
a
.
PackageName
+
"/struct.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
err
=
tmpl
.
Execute
(
file
,
a
)
}
// 判断文件夹是否存在
func
pathExists
(
path
string
)
(
bool
,
error
)
{
_
,
err
:=
os
.
Stat
(
path
)
if
err
==
nil
{
return
true
,
nil
}
if
os
.
IsNotExist
(
err
)
{
return
false
,
nil
}
return
false
,
err
return
err
}
\ No newline at end of file
QMPlusServer/tpl/fe/api.js.tpl
0 → 100644
浏览文件 @
6fbb6f23
import service from '@/utils/request'
// @Tags {{.StructName}}
// @Summary 创建{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "创建{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"获取成功"
}
"
// @Router /{{.Abbreviation}}/create{{.StructName}} [post]
export const create{{.StructName}} = (data) => {
return service({
url: "/{{.Abbreviation}}/create{{.StructName}}",
method: 'post',
data
})
}
// @Tags {{.StructName}}
// @Summary 删除{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "删除{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"删除成功"
}
"
// @Router /{{.Abbreviation}}/delete{{.StructName}} [post]
export const delete{{.StructName}} = (data) => {
return service({
url: "/{{.Abbreviation}}/delete{{.StructName}}",
method: 'post',
data
})
}
// @Tags {{.StructName}}
// @Summary 更新{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "更新{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"更新成功"
}
"
// @Router /{{.Abbreviation}}/update{{.StructName}} [post]
export const update{{.StructName}} = (data) => {
return service({
url: "/{{.Abbreviation}}/update{{.StructName}}",
method: 'post',
data
})
}
// @Tags {{.StructName}}
// @Summary 用id查询{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "用id查询{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"查询成功"
}
"
// @Router /{{.Abbreviation}}/find{{.StructName}} [post]
export const find{{.StructName}} = (data) => {
return service({
url: "/{{.Abbreviation}}/find{{.StructName}}",
method: 'post',
data
})
}
// @Tags {{.StructName}}
// @Summary 分页获取{{.StructName}}列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取{{.StructName}}列表"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"获取成功"
}
"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [post]
export const get{{.StructName}}List = (data) => {
return service({
url: "/{{.Abbreviation}}/get{{.StructName}}List",
method: 'post',
data
})
}
\ No newline at end of file
QMPlusServer/tpl/te/api.go.tpl
浏览文件 @
6fbb6f23
...
...
@@ -4,7 +4,7 @@ import (
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/model/modelInterface"
"gin-vue-admin/model/sysModel"
// 请自行引入model路径
"github.com/gin-gonic/gin"
)
...
...
@@ -27,3 +27,92 @@ func Create{{.StructName}}(c *gin.Context) {
servers.ReportFormat(c, true, "创建成功", gin.H{})
}
}
// @Tags {{.StructName}}
// @Summary 删除{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "删除{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"删除成功"
}
"
// @Router /{{.Abbreviation}}/delete{{.StructName}} [post]
func Delete{{.StructName}}(c *gin.Context) {
var {{.Abbreviation}} {{.PackageName}}.{{.StructName}}
_ = c.ShouldBindJSON(
&
{{.Abbreviation}})
err := {{.Abbreviation}}.Delete{{.StructName}}()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "创建成功", gin.H{})
}
}
// @Tags {{.StructName}}
// @Summary 更新{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "更新{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"更新成功"
}
"
// @Router /{{.Abbreviation}}/update{{.StructName}} [post]
func Update{{.StructName}}(c *gin.Context) {
var {{.Abbreviation}} {{.PackageName}}.{{.StructName}}
_ = c.ShouldBindJSON(
&
{{.Abbreviation}})
err,re{{.Abbreviation}} := {{.Abbreviation}}.Update{{.StructName}}()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("更新失败:%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "更新成功", gin.H{
"re{{.Abbreviation}}":re{{.Abbreviation}},
})
}
}
// @Tags {{.StructName}}
// @Summary 用id查询{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "用id查询{{.StructName}}"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"查询成功"
}
"
// @Router /{{.Abbreviation}}/find{{.StructName}} [post]
func Find{{.StructName}}(c *gin.Context) {
var {{.Abbreviation}} {{.PackageName}}.{{.StructName}}
_ = c.ShouldBindJSON(
&
{{.Abbreviation}})
err,re{{.Abbreviation}} := {{.Abbreviation}}.FindById()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("查询失败:%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "查询成功", gin.H{
"re{{.Abbreviation}}":re{{.Abbreviation}},
})
}
}
// @Tags {{.StructName}}
// @Summary 分页获取{{.StructName}}列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取{{.StructName}}列表"
// @Success 200
{
string
}
string "
{
"success"
:
true
,
"data"
:
{}
,
"msg"
:
"获取成功"
}
"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [post]
func Get{{.StructName}}List(c *gin.Context) {
var pageInfo modelInterface.PageInfo
_ = c.ShouldBindJSON(
&
pageInfo)
err, list, total := new({{.PackageName}}.{{.StructName}}).GetInfoList(pageInfo)
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "获取数据成功", gin.H{
"{{.PackageName}}List": list,
"total": total,
"page": pageInfo.Page,
"pageSize": pageInfo.PageSize,
})
}
}
\ No newline at end of file
QMPlusServer/tpl/te/router.go.tpl
浏览文件 @
6fbb6f23
package router
import (
"gin-vue-admin/controller/api"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func Init{{.StructName}}Router(Router *gin.RouterGroup) {
{{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
{{.StructName}}Router.POST("create{{.StructName}}", api.Create{{.StructName}}) // 新建{{.StructName}}
{{.StructName}}Router.POST("delete{{.StructName}}", api.Delete{{.StructName}}) //删除{{.StructName}}
{{.StructName}}Router.POST("update{{.StructName}}", api.Update{{.StructName}}) //更新{{.StructName}}
{{.StructName}}Router.POST("find{{.StructName}} ", api.Find{{.StructName}}) // 根据ID获取{{.StructName}}
{{.StructName}}Router.POST("get{{.StructName}}List", api.Get{{.StructName}}List) //获取{{.StructName}}列表
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录