切换导航条
此项目
正在载入...
登录
allied-creation
/
sumifcc-discuss
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
yangfu
about a year ago
提交
cbbf068bde8b7ca867f79a64b9859d4f3cefd152
1 个父辈
d2ff8b11
master
...
dev
test
用例模板
隐藏空白字符变更
内嵌
并排对比
正在显示
14 个修改的文件
包含
185 行增加
和
83 行删除
Makefile
cmd/discuss/api/core.go
cmd/discuss/api/dsl/core.api
cmd/discuss/api/dsl/core.json
cmd/discuss/api/dsl/core/test.api → cmd/discuss/api/dsl/core/comment.api
cmd/discuss/api/etc/core.yaml
cmd/discuss/api/internal/config/config.go
cmd/discuss/api/internal/handler/tool/mini_health_handler.go → cmd/discuss/api/internal/handler/comment/mini_comment_handler.go
cmd/discuss/api/internal/handler/comment/system_comment_handler.go
cmd/discuss/api/internal/handler/routes.go
cmd/discuss/api/internal/logic/tool/mini_health_logic.go → cmd/discuss/api/internal/logic/comment/mini_comment_logic.go
cmd/discuss/api/internal/logic/comment/system_comment_logic.go
cmd/discuss/api/internal/types/types.go
pkg/config/config.go
Makefile
查看文件 @
cbbf068
...
...
@@ -4,7 +4,7 @@ model:
.PHONY
:
api
api
:
goctl api go -api .
\c
md
\d
iscuss
\
m
in
i
\d
sl
\c
ore.api -dir cmd/discuss/api -style go_zero
goctl api go -api .
\c
md
\d
iscuss
\
a
p
i
\d
sl
\c
ore.api -dir cmd/discuss/api -style go_zero
.PHONY
:
swagger
swagger
:
...
...
cmd/discuss/api/core.go
查看文件 @
cbbf068
...
...
@@ -46,7 +46,6 @@ func main() {
})
opts
=
append
(
opts
,
opt
)
server
:=
rest
.
MustNewServer
(
c
.
RestConf
,
opts
...
)
defer
server
.
Stop
()
...
...
cmd/discuss/api/dsl/core.api
查看文件 @
cbbf068
import "core/test.api"
\ No newline at end of file
import "core/comment.api"
\ No newline at end of file
...
...
cmd/discuss/api/dsl/core.json
查看文件 @
cbbf068
...
...
@@ -15,41 +15,65 @@
"application/json"
],
"paths"
:
{
"v1/
health
"
:
{
"v1/
mini/comment
"
:
{
"get"
:
{
"summary"
:
"健康"
,
"operationId"
:
"miniHealth"
,
"summary"
:
"小程序评论"
,
"operationId"
:
"miniComment"
,
"responses"
:
{
"200"
:
{
"description"
:
"A successful response."
,
"schema"
:
{
"$ref"
:
"#/definitions/
MiniHealth
Resposne"
"$ref"
:
"#/definitions/
Comment
Resposne"
}
}
},
"requestBody"
:
{},
"tags"
:
[
"tool"
"comment"
]
}
},
"v1/system/comment"
:
{
"get"
:
{
"summary"
:
"系统评论"
,
"operationId"
:
"systemComment"
,
"responses"
:
{
"200"
:
{
"description"
:
"A successful response."
,
"schema"
:
{
"$ref"
:
"#/definitions/CommentResposne"
}
}
},
"requestBody"
:
{},
"tags"
:
[
"comment"
]
}
}
},
"definitions"
:
{
"MiniHealthRequest"
:
{
"Comment"
:
{
"type"
:
"object"
,
"title"
:
"Comment"
},
"CommentRequest"
:
{
"type"
:
"object"
,
"title"
:
"
MiniHealth
Request"
"title"
:
"
Comment
Request"
},
"
MiniHealth
Resposne"
:
{
"
Comment
Resposne"
:
{
"type"
:
"object"
,
"properties"
:
{
"ok"
:
{
"type"
:
"boolean"
,
"format"
:
"boolean"
"list"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/definitions/Comment"
}
}
},
"title"
:
"
MiniHealth
Resposne"
,
"title"
:
"
Comment
Resposne"
,
"required"
:
[
"
ok
"
"
list
"
]
}
},
...
...
cmd/discuss/api/dsl/core/
tes
t.api → cmd/discuss/api/dsl/core/
commen
t.api
查看文件 @
cbbf068
...
...
@@ -3,26 +3,46 @@ syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "
小火箭
"
author: "
email
"
email: "email"
version: "v1"
)
// 小程序接口
@server(
prefix: v1
group: comment
jwt: MiniAuth
)
service Core {
@doc "小程序评论"
@handler miniComment
get /mini/comment (CommentRequest) returns (CommentResposne)
}
// 后台接口
@server(
prefix: v1
group: tool
group: comment
jwt: SystemAuth
)
service Core {
@doc "健康"
@handler miniHealth
get /health (MiniHealthRequest) returns (MiniHealthResposne)
@doc "系统评论"
@handler systemComment
get /system/comment (CommentRequest) returns (CommentResposne)
}
type(
MiniHealthRequest struct{
CommentRequest struct{
}
MiniHealthResposne struct{
Ok bool `json:"ok"`
CommentResposne struct{
List []Comment `json:"list"`
}
Comment struct{
}
)
\ No newline at end of file
...
...
cmd/discuss/api/etc/core.yaml
查看文件 @
cbbf068
...
...
@@ -10,9 +10,13 @@ Log:
MaxSize
:
1
# 2MB
TimeFormat
:
2006-01-02 15:04:05.000
JwtAuth
:
AccessSecret
:
digital-platform
Expire
:
360000
SystemAuth
:
AccessSecret
:
discuss-secret
AccessExpire
:
360000
MiniAuth
:
AccessSecret
:
discuss-secret
AccessExpire
:
360000
Redis
:
Host
:
127.0.0.1:6379
...
...
cmd/discuss/api/internal/config/config.go
查看文件 @
cbbf068
...
...
@@ -9,5 +9,7 @@ import (
type
Config
struct
{
rest
.
RestConf
config
.
Config
Redis
redis
.
RedisConf
`json:",optional"`
Redis
redis
.
RedisConf
`json:",optional"`
SystemAuth
config
.
Auth
MiniAuth
config
.
Auth
}
...
...
cmd/discuss/api/internal/handler/
tool/mini_health
_handler.go → cmd/discuss/api/internal/handler/
comment/mini_comment
_handler.go
查看文件 @
cbbf068
package
tool
package
comment
import
(
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/
tool
"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/
comment
"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func
Mini
Health
Handler
(
svcCtx
*
svc
.
ServiceContext
)
http
.
HandlerFunc
{
func
Mini
Comment
Handler
(
svcCtx
*
svc
.
ServiceContext
)
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
req
types
.
MiniHealth
Request
var
req
types
.
Comment
Request
if
err
:=
httpx
.
Parse
(
r
,
&
req
);
err
!=
nil
{
httpx
.
ErrorCtx
(
r
.
Context
(),
w
,
err
)
return
}
l
:=
tool
.
NewMiniHealthLogic
(
r
.
Context
(),
svcCtx
)
resp
,
err
:=
l
.
MiniHealth
(
&
req
)
result
.
HttpResult
(
r
,
w
,
resp
,
err
)
l
:=
comment
.
NewMiniCommentLogic
(
r
.
Context
(),
svcCtx
)
resp
,
err
:=
l
.
MiniComment
(
&
req
)
if
err
!=
nil
{
httpx
.
ErrorCtx
(
r
.
Context
(),
w
,
err
)
}
else
{
httpx
.
OkJsonCtx
(
r
.
Context
(),
w
,
resp
)
}
}
}
...
...
cmd/discuss/api/internal/handler/comment/system_comment_handler.go
0 → 100644
查看文件 @
cbbf068
package
comment
import
(
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func
SystemCommentHandler
(
svcCtx
*
svc
.
ServiceContext
)
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
req
types
.
CommentRequest
if
err
:=
httpx
.
Parse
(
r
,
&
req
);
err
!=
nil
{
httpx
.
ErrorCtx
(
r
.
Context
(),
w
,
err
)
return
}
l
:=
comment
.
NewSystemCommentLogic
(
r
.
Context
(),
svcCtx
)
resp
,
err
:=
l
.
SystemComment
(
&
req
)
if
err
!=
nil
{
httpx
.
ErrorCtx
(
r
.
Context
(),
w
,
err
)
}
else
{
httpx
.
OkJsonCtx
(
r
.
Context
(),
w
,
resp
)
}
}
}
...
...
cmd/discuss/api/internal/handler/routes.go
查看文件 @
cbbf068
...
...
@@ -4,7 +4,7 @@ package handler
import
(
"net/http"
tool
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tool
"
comment
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment
"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"github.com/zeromicro/go-zero/rest"
...
...
@@ -15,10 +15,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]
rest
.
Route
{
{
Method
:
http
.
MethodGet
,
Path
:
"/health"
,
Handler
:
tool
.
MiniHealthHandler
(
serverCtx
),
Path
:
"/mini/comment"
,
Handler
:
comment
.
MiniCommentHandler
(
serverCtx
),
},
},
rest
.
WithJwt
(
serverCtx
.
Config
.
MiniAuth
.
AccessSecret
),
rest
.
WithPrefix
(
"/v1"
),
)
server
.
AddRoutes
(
[]
rest
.
Route
{
{
Method
:
http
.
MethodGet
,
Path
:
"/system/comment"
,
Handler
:
comment
.
SystemCommentHandler
(
serverCtx
),
},
},
rest
.
WithJwt
(
serverCtx
.
Config
.
SystemAuth
.
AccessSecret
),
rest
.
WithPrefix
(
"/v1"
),
)
}
...
...
cmd/discuss/api/internal/logic/
tool/mini_health
_logic.go → cmd/discuss/api/internal/logic/
comment/mini_comment
_logic.go
查看文件 @
cbbf068
package
tool
package
comment
import
(
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
...
...
@@ -11,31 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type
Mini
Health
Logic
struct
{
type
Mini
Comment
Logic
struct
{
logx
.
Logger
ctx
context
.
Context
svcCtx
*
svc
.
ServiceContext
}
func
NewMiniHealthLogic
(
ctx
context
.
Context
,
svcCtx
*
svc
.
ServiceContext
)
*
MiniHealthLogic
{
return
&
MiniHealthLogic
{
func
NewMiniCommentLogic
(
ctx
context
.
Context
,
svcCtx
*
svc
.
ServiceContext
)
*
MiniCommentLogic
{
return
&
MiniCommentLogic
{
Logger
:
logx
.
WithContext
(
ctx
),
ctx
:
ctx
,
svcCtx
:
svcCtx
,
}
}
func
(
l
*
MiniHealthLogic
)
MiniHealth
(
req
*
types
.
MiniHealthRequest
)
(
resp
*
types
.
MiniHealthResposne
,
err
error
)
{
// 普通查询
var
conn
=
l
.
svcCtx
.
DefaultDBConn
()
l
.
svcCtx
.
CommentRepository
.
FindOne
(
l
.
ctx
,
conn
,
0
)
func
(
l
*
MiniCommentLogic
)
MiniComment
(
req
*
types
.
CommentRequest
)
(
resp
*
types
.
CommentResposne
,
err
error
)
{
// todo: add your logic here and delete this line
// 事务查询
if
err
=
transaction
.
UseTrans
(
l
.
ctx
,
l
.
svcCtx
.
DB
,
func
(
ctx
context
.
Context
,
conn
transaction
.
Conn
)
error
{
l
.
svcCtx
.
CommentRepository
.
FindOne
(
ctx
,
l
.
svcCtx
.
DefaultDBConn
(),
0
)
return
nil
},
true
);
err
!=
nil
{
return
nil
,
xerr
.
NewErrMsgErr
(
"健康检查失败"
,
err
)
}
return
}
...
...
cmd/discuss/api/internal/logic/comment/system_comment_logic.go
0 → 100644
查看文件 @
cbbf068
package
comment
import
(
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type
SystemCommentLogic
struct
{
logx
.
Logger
ctx
context
.
Context
svcCtx
*
svc
.
ServiceContext
}
func
NewSystemCommentLogic
(
ctx
context
.
Context
,
svcCtx
*
svc
.
ServiceContext
)
*
SystemCommentLogic
{
return
&
SystemCommentLogic
{
Logger
:
logx
.
WithContext
(
ctx
),
ctx
:
ctx
,
svcCtx
:
svcCtx
,
}
}
func
(
l
*
SystemCommentLogic
)
SystemComment
(
req
*
types
.
CommentRequest
)
(
resp
*
types
.
CommentResposne
,
err
error
)
{
// todo: add your logic here and delete this line
return
}
...
...
cmd/discuss/api/internal/types/types.go
查看文件 @
cbbf068
// Code generated by goctl. DO NOT EDIT.
package
types
type
MiniHealth
Request
struct
{
type
Comment
Request
struct
{
}
type
MiniHealthResposne
struct
{
Ok
bool
`json:"ok"`
type
CommentResposne
struct
{
List
[]
Comment
`json:"list"`
}
type
Comment
struct
{
Id
int64
`json:"id"`
Content
string
`json:"content"`
}
...
...
pkg/config/config.go
查看文件 @
cbbf068
...
...
@@ -2,36 +2,21 @@ package config
import
(
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
"time"
)
type
JWT
struct
{
Secret
string
`json:",optional"`
Expires
time
.
Duration
`json:",optional"`
}
type
JwtAuth
struct
{
type
Auth
struct
{
AccessSecret
string
Expire
int64
AccessExpire
int64
}
type
Config
struct
{
JwtAuth
JwtAuth
`json:",optional"`
UserRpc
zrpc
.
RpcClientConf
`json:",optional"`
AuthRpc
zrpc
.
RpcClientConf
`json:",optional"`
PostRpc
zrpc
.
RpcClientConf
`json:",optional"`
CommentRpc
zrpc
.
RpcClientConf
`json:",optional"`
JWT
JWT
`json:",optional"`
DB
struct
{
DB
struct
{
DataSource
string
}
`json:",optional"`
Cache
cache
.
CacheConf
`json:",optional"`
DTM
DTM
`json:",optional"`
Sms
Sms
`json:",optional"`
Oss
Oss
`json:",optional"`
Wechat
Wechat
`json:",optional"`
// 学员端微信
CoachClient
Wechat
`json:",optional"`
// 教练端微信
OfficialAccount
Wechat
`json:",optional"`
ThirdWechatApps
[]
Wechat
`json:",optional"`
Cache
cache
.
CacheConf
`json:",optional"`
DTM
DTM
`json:",optional"`
Sms
Sms
`json:",optional"`
Oss
Oss
`json:",optional"`
Wechat
Wechat
`json:",optional"`
}
type
DTM
struct
{
...
...
请
注册
或
登录
后发表评论