Version: 0.2.1.dev.260210
feat: 🚦 新增基于 Redis 令牌桶的限流中间件 - 使用 Redis 实现令牌桶算法进行限流 🪣 - 覆盖除登录、注册、刷新 token 以外的所有接口 🔒 fix: 🐛 修复任务块添加到日程接口可修改已安排任务时间的问题 - 禁止通过该接口直接修改已安排任务块的时间 - 修正不合理的业务逻辑,保证数据一致性 ✅
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/LoveLosita/smartflow/backend/api"
|
||||
"github.com/LoveLosita/smartflow/backend/dao"
|
||||
"github.com/LoveLosita/smartflow/backend/inits"
|
||||
"github.com/LoveLosita/smartflow/backend/pkg"
|
||||
"github.com/LoveLosita/smartflow/backend/routers"
|
||||
"github.com/LoveLosita/smartflow/backend/service"
|
||||
"github.com/spf13/viper"
|
||||
@@ -39,6 +40,8 @@ func Start() {
|
||||
log.Fatalf("Failed to connect to database: %v", err)
|
||||
}
|
||||
rdb := inits.InitRedis()
|
||||
//工具包
|
||||
limiter := pkg.NewRateLimiter(rdb)
|
||||
//dao 层
|
||||
userRepo := dao.NewUserDAO(db)
|
||||
cacheRepo := dao.NewCacheDAO(rdb)
|
||||
@@ -59,7 +62,6 @@ func Start() {
|
||||
courseApi := api.NewCourseHandler(courseService)
|
||||
taskClassApi := api.NewTaskClassHandler(taskClassService)
|
||||
scheduleApi := api.NewScheduleAPI(scheduleService)
|
||||
|
||||
handlers := &api.ApiHandlers{
|
||||
UserHandler: userApi,
|
||||
TaskHandler: taskApi,
|
||||
@@ -67,6 +69,6 @@ func Start() {
|
||||
CourseHandler: courseApi,
|
||||
ScheduleHandler: scheduleApi,
|
||||
}
|
||||
r := routers.RegisterRouters(handlers, cacheRepo)
|
||||
r := routers.RegisterRouters(handlers, cacheRepo, limiter)
|
||||
routers.StartEngine(r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user