Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Junebao
JuneGoBlog
提交
4448e3b1
J
JuneGoBlog
项目概览
Junebao
/
JuneGoBlog
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JuneGoBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4448e3b1
编写于
8月 09, 2020
作者:
5
520MianXiangDuiXiang520
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
:art:Improve structure
上级
70d84c9f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
19 deletion
+14
-19
routes.go
routes.go
+1
-0
src/check/article.go
src/check/article.go
+1
-1
src/routes/article.go
src/routes/article.go
+5
-5
src/utils/context.go
src/utils/context.go
+7
-13
未找到文件。
routes.go
浏览文件 @
4448e3b1
...
...
@@ -11,5 +11,6 @@ func Register(c *gin.Engine) {
utils
.
HandlerRoute
(
c
,
"api/tag"
,
routes
.
TagRegister
)
utils
.
HandlerRoute
(
c
,
"api/talking"
,
routes
.
TalkingRegister
)
utils
.
HandlerRoute
(
c
,
"api/admin"
,
routes
.
AdminRegister
)
utils
.
HandlerRoute
(
c
,
"api/friendship"
,
routes
.
FriendShipRoutes
)
}
src/check/
check
.go
→
src/check/
article
.go
浏览文件 @
4448e3b1
...
...
@@ -9,7 +9,7 @@ import (
"net/http"
)
func
CheckList
(
ctx
*
gin
.
Context
)
(
utils
.
RespHeader
,
error
)
{
func
ListCheck
(
ctx
*
gin
.
Context
)
(
utils
.
RespHeader
,
error
)
{
req
:=
new
(
message
.
ListReq
)
var
resp
*
message
.
BaseRespHeader
err
:=
ctx
.
ShouldBindJSON
(
&
req
)
...
...
src/routes/article.go
浏览文件 @
4448e3b1
...
...
@@ -8,9 +8,9 @@ import (
)
func
ArticleRegister
(
rg
*
gin
.
RouterGroup
)
{
rg
.
POST
(
"/list"
,
utils
.
EasyHandler
(
&
utils
.
LogicContext
{
CheckFunc
:
check
.
CheckList
,
LogicFunc
:
server
.
ListLogic
}
))
rg
.
POST
(
"/add"
,
utils
.
EasyHandler
(
&
utils
.
LogicContext
{
CheckFunc
:
check
.
CheckList
,
LogicFunc
:
server
.
ListLogic
}
))
rg
.
POST
(
"/update"
,
utils
.
EasyHandler
(
&
utils
.
LogicContext
{
CheckFunc
:
check
.
CheckList
,
LogicFunc
:
server
.
ListLogic
}
))
rg
.
POST
(
"/delete"
,
utils
.
EasyHandler
(
&
utils
.
LogicContext
{
CheckFunc
:
check
.
CheckList
,
LogicFunc
:
server
.
ListLogic
}
))
rg
.
POST
(
"/detail"
,
utils
.
EasyHandler
(
&
utils
.
LogicContext
{
CheckFunc
:
check
.
CheckList
,
LogicFunc
:
server
.
ListLogic
}
))
rg
.
POST
(
"/list"
,
utils
.
EasyHandler
(
check
.
ListCheck
,
server
.
ListLogic
))
rg
.
POST
(
"/add"
,
utils
.
EasyHandler
(
check
.
ListCheck
,
server
.
ListLogic
))
rg
.
POST
(
"/update"
,
utils
.
EasyHandler
(
check
.
ListCheck
,
server
.
ListLogic
))
rg
.
POST
(
"/delete"
,
utils
.
EasyHandler
(
check
.
ListCheck
,
server
.
ListLogic
))
rg
.
POST
(
"/detail"
,
utils
.
EasyHandler
(
check
.
ListCheck
,
server
.
ListLogic
))
}
src/utils/context.go
浏览文件 @
4448e3b1
...
...
@@ -5,25 +5,19 @@ import (
"net/http"
)
type
RespHeader
interface
{}
type
RespHeader
interface
{}
type
LogicContext
struct
{
CheckFunc
func
(
ctx
*
gin
.
Context
)
(
RespHeader
,
error
)
LogicFunc
func
(
ctx
*
gin
.
Context
)
RespHeader
}
type
CheckFunc
func
(
ctx
*
gin
.
Context
)
(
RespHeader
,
error
)
type
LogicFunc
func
(
ctx
*
gin
.
Context
)
RespHeader
func
(
lc
*
LogicContext
)
do
(
)
gin
.
HandlerFunc
{
return
func
(
context
*
gin
.
Context
)
{
func
EasyHandler
(
cf
CheckFunc
,
lf
LogicFunc
)
gin
.
HandlerFunc
{
return
func
(
context
*
gin
.
Context
)
{
var
resp
interface
{}
if
checkResp
,
err
:=
lc
.
CheckFunc
(
context
);
err
!=
nil
{
if
checkResp
,
err
:=
cf
(
context
);
err
!=
nil
{
resp
=
checkResp
}
else
{
resp
=
l
c
.
LogicFunc
(
context
)
resp
=
l
f
(
context
)
}
context
.
JSON
(
http
.
StatusOK
,
resp
)
}
}
func
EasyHandler
(
lc
*
LogicContext
)
gin
.
HandlerFunc
{
return
lc
.
do
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录