Skip to content

Commit 6a72306

Browse files
authored
Merge pull request #68 from CocaineCong/v3
更新postman接口文档 & mq秒杀尝试
2 parents 624215a + c573e6a commit 6a72306

File tree

19 files changed

+1205
-607
lines changed

19 files changed

+1205
-607
lines changed

api/v1/skill.go

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,69 @@
11
package v1
22

33
import (
4-
"net/http"
5-
64
"github.com/gin-gonic/gin"
7-
8-
"github.com/CocaineCong/gin-mall/pkg/utils/ctl"
9-
"github.com/CocaineCong/gin-mall/pkg/utils/log"
10-
"github.com/CocaineCong/gin-mall/service"
11-
"github.com/CocaineCong/gin-mall/types"
125
)
136

147
func ImportSkillProductHandler() gin.HandlerFunc {
158
return func(ctx *gin.Context) {
16-
var req types.SkillProductImportReq
17-
if err := ctx.ShouldBind(&req); err != nil {
18-
// 参数校验
19-
log.LogrusObj.Infoln(err)
20-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
21-
return
22-
}
23-
24-
file, _, _ := ctx.Request.FormFile("file")
25-
l := service.GetSkillProductSrv()
26-
resp, err := l.Import(ctx.Request.Context(), file)
27-
if err != nil {
28-
log.LogrusObj.Infoln(err)
29-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
30-
return
31-
}
32-
ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
9+
// var req types.SkillProductImportReq
10+
// if err := ctx.ShouldBind(&req); err != nil {
11+
// // 参数校验
12+
// log.LogrusObj.Infoln(err)
13+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
14+
// return
15+
// }
16+
//
17+
// file, _, _ := ctx.Request.FormFile("file")
18+
// l := service.GetSkillProductSrv()
19+
// resp, err := l.Import(ctx.Request.Context(), file)
20+
// if err != nil {
21+
// log.LogrusObj.Infoln(err)
22+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
23+
// return
24+
// }
25+
// ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
3326
}
3427
}
3528

3629
func InitSkillProductHandler() gin.HandlerFunc {
3730
return func(ctx *gin.Context) {
38-
var req types.SkillProductImportReq
39-
if err := ctx.ShouldBind(&req); err != nil {
40-
// 参数校验
41-
log.LogrusObj.Infoln(err)
42-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
43-
return
44-
}
45-
46-
l := service.GetSkillProductSrv()
47-
resp, err := l.InitSkillGoods(ctx.Request.Context())
48-
if err != nil {
49-
log.LogrusObj.Infoln(err)
50-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
51-
return
52-
}
53-
ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
31+
// var req types.SkillProductImportReq
32+
// if err := ctx.ShouldBind(&req); err != nil {
33+
// // 参数校验
34+
// log.LogrusObj.Infoln(err)
35+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
36+
// return
37+
// }
38+
//
39+
// l := service.GetSkillProductSrv()
40+
// resp, err := l.InitSkillGoods(ctx.Request.Context())
41+
// if err != nil {
42+
// log.LogrusObj.Infoln(err)
43+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
44+
// return
45+
// }
46+
// ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
5447
}
5548
}
5649

5750
func SkillProductHandler() gin.HandlerFunc {
5851
return func(ctx *gin.Context) {
59-
var req types.SkillProductServiceReq
60-
if err := ctx.ShouldBind(&req); err != nil {
61-
// 参数校验
62-
log.LogrusObj.Infoln(err)
63-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
64-
return
65-
}
66-
67-
l := service.GetSkillProductSrv()
68-
resp, err := l.SkillProduct(ctx.Request.Context(), &req)
69-
if err != nil {
70-
log.LogrusObj.Infoln(err)
71-
ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
72-
return
73-
}
74-
ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
52+
// var req types.SkillProductServiceReq
53+
// if err := ctx.ShouldBind(&req); err != nil {
54+
// // 参数校验
55+
// log.LogrusObj.Infoln(err)
56+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
57+
// return
58+
// }
59+
//
60+
// l := service.GetSkillProductSrv()
61+
// resp, err := l.SkillProduct(ctx.Request.Context(), &req)
62+
// if err != nil {
63+
// log.LogrusObj.Infoln(err)
64+
// ctx.JSON(http.StatusOK, ErrorResponse(ctx, err))
65+
// return
66+
// }
67+
// ctx.JSON(http.StatusOK, ctl.RespSuccess(ctx, resp))
7568
}
7669
}

cmd/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/CocaineCong/gin-mall/repository/db/dao"
1111
"github.com/CocaineCong/gin-mall/repository/es"
1212
"github.com/CocaineCong/gin-mall/repository/kafka"
13+
"github.com/CocaineCong/gin-mall/repository/rabbitmq"
1314
"github.com/CocaineCong/gin-mall/routes"
1415

1516
_ "github.com/apache/skywalking-go"
@@ -27,8 +28,8 @@ func loading() {
2728
conf.InitConfig()
2829
dao.InitMySQL()
2930
cache.InitCache()
30-
// rabbitmq.InitRabbitMQ() // 如果需要接入RabbitMQ可以打开这个注释
31-
es.InitEs() // 如果需要接入ELK可以打开这个注释
31+
rabbitmq.InitRabbitMQ() // 如果需要接入RabbitMQ可以打开这个注释
32+
es.InitEs() // 如果需要接入ELK可以打开这个注释
3233
kafka.InitKafka()
3334
track.InitJaeger()
3435
util.InitLog() // 如果接入ELK请进入这个func打开注释

consts/product.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
package consts
22

33
const BaseProductPageSize = 15
4+
5+
const SkillProductQueues = "rabbitmq-skill-product-queues"

0 commit comments

Comments
 (0)