router.go 3.82 KB
Newer Older
chenweijian's avatar
chenweijian committed
1 2 3
package route

import (
hujiebin's avatar
hujiebin committed
4 5 6
	"fmt"
	"git.hilo.cn/hilo-common/domain"
	"git.hilo.cn/hilo-common/mycontext"
chenweijian's avatar
chenweijian committed
7 8 9
	"github.com/gin-gonic/gin"
	ginSwagger "github.com/swaggo/gin-swagger"
	"github.com/swaggo/gin-swagger/swaggerFiles"
hujiebin's avatar
hujiebin committed
10
	"hilo-user/_const/enum/msg_e"
chenweijian's avatar
chenweijian committed
11
	_ "hilo-user/docs"
hujiebin's avatar
hujiebin committed
12 13
	"hilo-user/domain/model/msg_m"
	"hilo-user/resp"
hujiebin's avatar
hujiebin committed
14
	"hilo-user/route/cp_r"
chenweijian's avatar
chenweijian committed
15
	"hilo-user/route/invite_r"
hujiebin's avatar
hujiebin committed
16
	"hilo-user/route/recommend_r"
chenweijian's avatar
chenweijian committed
17 18 19 20 21 22 23 24 25 26 27
	"hilo-user/route/user_r"
)

func InitRouter() *gin.Engine {
	var r = gin.Default()

	r.GET("/user-swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	needLogin := r.Group("")
	needLogin.Use(ExceptionHandle, LoggerHandle, JWTApiHandle)
	v1 := needLogin.Group("/v1")
hujiebin's avatar
hujiebin committed
28
	v2 := needLogin.Group("/v2")
chenweijian's avatar
chenweijian committed
29 30 31
	user := v1.Group("/user")
	{
		user.GET("/nameplate", wrapper(user_r.UserNameplate))
hujiebin's avatar
hujiebin committed
32
		user.GET("/bag/:resType", wrapper(user_r.UserBag))
hujiebin's avatar
hujiebin committed
33 34
		user.GET("/detail", EncryptHandle, wrapper(user_r.UserDetail))
		user.GET("/detail/:userExternalId", EncryptHandle, wrapper(user_r.UserDetailByExternalId))
chenweijian's avatar
chenweijian committed
35
	}
hujiebin's avatar
hujiebin committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	cp := v2.Group("/cp")
	{
		cp.GET("/space", wrapper(cp_r.CpSpace))
		cp.PUT("/privilege/openClose", wrapper(cp_r.CpPrivilegeOpenClose))
		cp.GET("/rank/:queryType", wrapper(cp_r.CpRank))
		cp.GET("/my/:queryType", wrapper(cp_r.CpMy))
		cp.GET("/achievement", wrapper(cp_r.CpAchievement))
		cp.GET("/top3", wrapper(cp_r.CpTop3))

		cp.POST("/anniversary", wrapper(cp_r.PostAnniversary))
		cp.PUT("/anniversary/:id", wrapper(cp_r.PutAnniversary))
		cp.GET("/anniversary", wrapper(cp_r.PageAnniversary))
		cp.DELETE("/anniversary/:id", wrapper(cp_r.DelAnniversary))

		cp.GET("/relation/check", wrapper(cp_r.CheckUserCpRelation))
		cp.POST("/relation", wrapper(cp_r.CpRelation))
		cp.POST("/relation/invite/reply", wrapper(cp_r.ReplyCpInvite))
		cp.POST("/relation/cancel/reply", wrapper(cp_r.ReplyCpCancel))
		//cp.GET("/relation/detail", wrapper(cp_r.CpDetailPage))
		cp.GET("/im/check", wrapper(cp_r.CheckCpImExpire))
	}
hujiebin's avatar
hujiebin committed
57 58 59 60 61
	recommend := v1.Group("recommend")
	{
		recommend.GET("/user/gift", wrapper(recommend_r.UserRecommendGift))
	}

chenweijian's avatar
chenweijian committed
62 63 64 65 66 67 68
	userV2 := v2.Group("/user")
	{
		userV2.POST("/invite/apply", wrapper(invite_r.InviteApply))
		userV2.GET("/invite/apply", wrapper(invite_r.InviteApplyList))
		userV2.GET("/invite/platform", wrapper(invite_r.PromotionPlatform))
		userV2.GET("/invite/period", wrapper(invite_r.AgentPeriod))
	}
chenweijian's avatar
chenweijian committed
69 70
	inner := r.Group("/inner")
	inner.Use(ExceptionHandle, LoggerHandle)
hujiebin's avatar
hujiebin committed
71
	innerUser := inner.Group("/user")
chenweijian's avatar
chenweijian committed
72
	{
hujiebin's avatar
hujiebin committed
73 74
		innerUser.GET("/levels", wrapper(user_r.MGetUserLevels))
		innerUser.GET("/bag/id", wrapper(user_r.GetUserBagId))
hujiebin's avatar
hujiebin committed
75 76 77
		innerUser.GET("/cp", wrapper(user_r.GetUserCp))
		innerUser.GET("/cpRelations", wrapper(user_r.MGetUserCpRelation))
		innerUser.GET("/cp/pair", wrapper(user_r.GetUserCpPair))
hujiebin's avatar
hujiebin committed
78
		innerUser.GET("/cp/entryEffect", wrapper(user_r.GetUserCpEntryEffect)) // 获取cp进场特效信息,高频接口,需要额外处理
hujiebin's avatar
hujiebin committed
79 80 81 82 83 84 85 86
	}
	// 道具相关
	innerProp := inner.Group("/prop")
	{
		innerProp.POST("/bag/send", wrapper(user_r.SendUserBag))           // 下发背包道具,暂礼物
		innerProp.POST("/noble/send", wrapper(user_r.SendUserNoble))       // 下发贵族
		innerProp.POST("/headwear/send", wrapper(user_r.SendUserHeadwear)) // 下发头饰
		innerProp.POST("/ride/send", wrapper(user_r.SendUserRide))         // 下发座驾
chenweijian's avatar
chenweijian committed
87
	}
hujiebin's avatar
hujiebin committed
88
	r.GET("/test", wrapper(Test))
chenweijian's avatar
chenweijian committed
89 90
	return r
}
hujiebin's avatar
hujiebin committed
91 92 93 94 95 96 97 98 99 100 101 102 103

func Test(c *gin.Context) (*mycontext.MyContext, error) {
	var model = domain.CreateModelContext(nil)
	myCtx := mycontext.CreateMyContext(c.Keys)
	// 下发hilo小助手通知
	if err := msg_m.NewUserRecord(model, 4549, msg_e.AddProps, "", 0, "", fmt.Sprintf("%d", 10), "https://image.whoisamy.shop/hilo/manager/1b95e0e63b814261acccc6e1f1736627.png", "", "").Persistent(); err != nil {
		model.Log.Errorf("NewUserRecord fail")
	} else {
		msg_m.SendEmasMsgAssistant(model, "f98c7fe5698e447c998615332eb660d1", "iOS")
	}
	resp.ResponseOk(c, struct{}{})
	return myCtx, nil
}