12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package adapter
- import (
- "Cold_Logistic/internal/server/adapter/http/v1/common"
- "Cold_Logistic/internal/server/adapter/http/v1/insider"
- "Cold_Logistic/internal/server/adapter/http/v1/manage"
- "Cold_Logistic/internal/server/adapter/http/v1/myself"
- "Cold_Logistic/internal/server/adapter/http/v1/public"
- "Cold_Logistic/internal/server/adapter/http/v1/swagger"
- "Cold_Logistic/internal/server/adapter/job/ordercron"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/watcher"
- "github.com/gin-gonic/gin"
- _ "Cold_Logistic/docs"
- "Cold_Logistic/internal/server/adapter/http/v1/auth"
- )
- func HttpRoutes() func(r *gin.Engine) {
- return func(r *gin.Engine) {
- //Swagger文档
- swagger.RegisterSwagger(r)
- // 用户端
- app := r.Group("/clodLogistic/api/v1/app")
- auth.Register(app)
- // 我的
- myself.Register(app)
- // 开放接口
- public.Register(app)
- // 司机、仓管
- insider.Register(app)
- // 地区下拉列表
- common.Register(app)
- // 管理后台
- admin := r.Group("/clodLogistic/api/v1/manage")
- manage.Register(admin)
- }
- }
- // RegisterCron 注册周期任务
- func RegisterCron() func(c *watcher.MyCronJob) {
- return func(c *watcher.MyCronJob) {
- var err error
- orderNoJob := ordercron.NewOrderNoJob()
- _, err = c.RegisterJob("0 0 */2 * * ?", // 每隔两小时触发
- watcher.NewJob(orderNoJob, watcher.WithSkipRunningJobV2()), // 若上次任务未结束就跳过,遇panic可以下一轮调度
- watcher.WithRegisterStop(orderNoJob))
- if err != nil {
- panic(err)
- }
- }
- }
|