+9
-45
@@ -4,11 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -17,39 +14,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func AlbumSeriesAllHandler(ctx *gin.Context) {
|
func AlbumSeriesAllHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
var albumIds []int
|
var albumIds []int
|
||||||
err = MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(albumIds)
|
// fmt.Println(albumIds)
|
||||||
|
|
||||||
@@ -122,22 +88,20 @@ func AlbumSeriesAllHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := model.AlbumSeriesResp{
|
albumResp := model.AlbumSeriesResp{
|
||||||
ResponseData: albumSeriesAllRes,
|
ResponseData: albumSeriesAllRes,
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
}
|
}
|
||||||
respb, err := json.Marshal(resp)
|
resp, err := json.Marshal(albumResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(respb))
|
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(respb, "privatekey.pem")
|
nonce := ctx.GetInt("nonce")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
nonce++
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
ctx.Header("user_id", userId[0])
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(respb))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-52
@@ -4,10 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -15,16 +13,6 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AnnounceResp struct {
|
|
||||||
ResponseData AnnounceData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
type AnnounceData struct {
|
|
||||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func AnnounceIndexHandler(ctx *gin.Context) {
|
func AnnounceIndexHandler(ctx *gin.Context) {
|
||||||
ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{
|
ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{
|
||||||
"title": "Love Live! 学园偶像祭 非官方服务器",
|
"title": "Love Live! 学园偶像祭 非官方服务器",
|
||||||
@@ -33,39 +21,8 @@ func AnnounceIndexHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AnnounceCheckStateHandler(ctx *gin.Context) {
|
func AnnounceCheckStateHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
announceResp := model.AnnounceResp{
|
||||||
|
ResponseData: model.AnnounceRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
announceResp := AnnounceResp{
|
|
||||||
ResponseData: AnnounceData{
|
|
||||||
HasUnreadAnnounce: false,
|
HasUnreadAnnounce: false,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
},
|
},
|
||||||
@@ -74,12 +31,13 @@ func AnnounceCheckStateHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(announceResp)
|
resp, err := json.Marshal(announceResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-145
@@ -5,13 +5,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -19,15 +18,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ApiHandler(ctx *gin.Context) {
|
func ApiHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||||
// fmt.Println(ctx.PostForm("request_data"))
|
CheckErr(err)
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var formdata []model.SifApi
|
var formdata []model.SifApi
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata)
|
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
@@ -35,7 +30,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
var results []interface{}
|
var results []interface{}
|
||||||
for _, v := range formdata {
|
for _, v := range formdata {
|
||||||
var res []byte
|
var res []byte
|
||||||
var key string
|
|
||||||
var err error
|
var err error
|
||||||
// fmt.Println(v)
|
// fmt.Println(v)
|
||||||
// fmt.Println(v.Module, v.Action)
|
// fmt.Println(v.Module, v.Action)
|
||||||
@@ -43,10 +37,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
switch v.Module {
|
switch v.Module {
|
||||||
case "login":
|
case "login":
|
||||||
if v.Action == "topInfo" {
|
if v.Action == "topInfo" {
|
||||||
// fmt.Println("topInfo")
|
// key = "login_topinfo_result"
|
||||||
key = "login_topinfo_result"
|
|
||||||
topInfoResp := model.TopInfoResp{
|
topInfoResp := model.TopInfoResp{
|
||||||
// _ = model.TopInfoResp{
|
|
||||||
Result: model.TopInfoResult{
|
Result: model.TopInfoResult{
|
||||||
FriendActionCnt: 0,
|
FriendActionCnt: 0,
|
||||||
FriendGreetCnt: 0,
|
FriendGreetCnt: 0,
|
||||||
@@ -82,10 +74,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(topInfoResp)
|
res, err = json.Marshal(topInfoResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
} else if v.Action == "topInfoOnce" {
|
} else if v.Action == "topInfoOnce" {
|
||||||
// fmt.Println("topInfoOnce")
|
// key = "login_topinfo_once_result"
|
||||||
key = "login_topinfo_once_result"
|
|
||||||
topInfoOnceResp := model.TopInfoOnceResp{
|
topInfoOnceResp := model.TopInfoOnceResp{
|
||||||
// _ = model.TopInfoOnceResp{
|
|
||||||
Result: model.TopInfoOnceResult{
|
Result: model.TopInfoOnceResult{
|
||||||
NewAchievementCnt: 0,
|
NewAchievementCnt: 0,
|
||||||
UnaccomplishedAchievementCnt: 0,
|
UnaccomplishedAchievementCnt: 0,
|
||||||
@@ -118,8 +108,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
case "live":
|
case "live":
|
||||||
if v.Action == "liveStatus" {
|
if v.Action == "liveStatus" {
|
||||||
// fmt.Println("liveStatus")
|
// key = "live_status_result"
|
||||||
key = "live_status_result"
|
|
||||||
var liveDifficultyId int
|
var liveDifficultyId int
|
||||||
normalLives := []model.NormalLiveStatusList{}
|
normalLives := []model.NormalLiveStatusList{}
|
||||||
sql := `SELECT live_difficulty_id FROM normal_live_m ORDER BY live_difficulty_id ASC`
|
sql := `SELECT live_difficulty_id FROM normal_live_m ORDER BY live_difficulty_id ASC`
|
||||||
@@ -162,7 +151,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LiveStatusResp := model.LiveStatusResp{
|
LiveStatusResp := model.LiveStatusResp{
|
||||||
// _ = model.LiveStatusResp{
|
|
||||||
Result: model.LiveStatusResult{
|
Result: model.LiveStatusResult{
|
||||||
NormalLiveStatusList: normalLives,
|
NormalLiveStatusList: normalLives,
|
||||||
SpecialLiveStatusList: specialLives,
|
SpecialLiveStatusList: specialLives,
|
||||||
@@ -178,8 +166,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(LiveStatusResp)
|
res, err = json.Marshal(LiveStatusResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
} else if v.Action == "schedule" {
|
} else if v.Action == "schedule" {
|
||||||
// fmt.Println("schedule")
|
// key = "live_list_result"
|
||||||
key = "live_list_result"
|
|
||||||
var liveDifficultyId int
|
var liveDifficultyId int
|
||||||
specialLives := []model.SpecialLiveStatusList{}
|
specialLives := []model.SpecialLiveStatusList{}
|
||||||
sql := `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC`
|
sql := `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC`
|
||||||
@@ -211,7 +198,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
liveListResp := model.LiveScheduleResp{
|
liveListResp := model.LiveScheduleResp{
|
||||||
// _ = model.LiveScheduleResp{
|
|
||||||
Result: model.LiveScheduleResult{
|
Result: model.LiveScheduleResult{
|
||||||
EventList: []interface{}{},
|
EventList: []interface{}{},
|
||||||
LiveList: livesList,
|
LiveList: livesList,
|
||||||
@@ -231,8 +217,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
case "unit":
|
case "unit":
|
||||||
switch v.Action {
|
switch v.Action {
|
||||||
case "unitAll":
|
case "unitAll":
|
||||||
// fmt.Println("unitAll")
|
// key = "unit_list_result"
|
||||||
key = "unit_list_result"
|
|
||||||
unitsData := []model.Active{}
|
unitsData := []model.Active{}
|
||||||
err = MainEng.Table("common_unit_m").Select("*").Find(&unitsData)
|
err = MainEng.Table("common_unit_m").Select("*").Find(&unitsData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -248,7 +233,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
unitsData = append(unitsData, userUnits...)
|
unitsData = append(unitsData, userUnits...)
|
||||||
|
|
||||||
unitListResp := model.UnitAllResp{
|
unitListResp := model.UnitAllResp{
|
||||||
// _ = model.UnitAllResp{
|
|
||||||
Result: model.UnitAllResult{
|
Result: model.UnitAllResult{
|
||||||
Active: unitsData,
|
Active: unitsData,
|
||||||
Waiting: []model.Waiting{},
|
Waiting: []model.Waiting{},
|
||||||
@@ -260,10 +244,9 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(unitListResp)
|
res, err = json.Marshal(unitListResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "deckInfo":
|
case "deckInfo":
|
||||||
// fmt.Println("deckInfo")
|
// key = "unit_deck_result"
|
||||||
key = "unit_deck_result"
|
|
||||||
userDeck := []tools.UserDeckData{}
|
userDeck := []tools.UserDeckData{}
|
||||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", userId[0]).Asc("deck_id").Find(&userDeck)
|
err = UserEng.Table("user_deck_m").Where("user_id = ?", userId).Asc("deck_id").Find(&userDeck)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
unitDeckInfo := []model.UnitDeckInfo{}
|
unitDeckInfo := []model.UnitDeckInfo{}
|
||||||
@@ -292,7 +275,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
unitDeckResp := model.UnitDeckInfoResp{
|
unitDeckResp := model.UnitDeckInfoResp{
|
||||||
// _ = model.UnitDeckInfoResp{
|
|
||||||
Result: unitDeckInfo,
|
Result: unitDeckInfo,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -301,10 +283,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(unitDeckResp)
|
res, err = json.Marshal(unitDeckResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "supporterAll":
|
case "supporterAll":
|
||||||
// fmt.Println("supporterAll")
|
// key = "unit_support_result"
|
||||||
key = "unit_support_result"
|
|
||||||
unitSupportResp := model.UnitSupportResp{
|
unitSupportResp := model.UnitSupportResp{
|
||||||
// _ = model.UnitSupportResp{
|
|
||||||
Result: model.UnitSupportResult{
|
Result: model.UnitSupportResult{
|
||||||
UnitSupportList: []model.UnitSupportList{},
|
UnitSupportList: []model.UnitSupportList{},
|
||||||
}, // 练习道具
|
}, // 练习道具
|
||||||
@@ -315,10 +295,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(unitSupportResp)
|
res, err = json.Marshal(unitSupportResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "removableSkillInfo":
|
case "removableSkillInfo":
|
||||||
// fmt.Println("removableSkillInfo")
|
// key = "owning_equip_result"
|
||||||
key = "owning_equip_result"
|
|
||||||
rmSkillResp := model.RemovableSkillResp{
|
rmSkillResp := model.RemovableSkillResp{
|
||||||
// _ = model.RemovableSkillResp{
|
|
||||||
Result: model.RemovableSkillResult{
|
Result: model.RemovableSkillResult{
|
||||||
OwningInfo: []model.OwningInfo{},
|
OwningInfo: []model.OwningInfo{},
|
||||||
EquipmentInfo: []interface{}{},
|
EquipmentInfo: []interface{}{},
|
||||||
@@ -330,10 +308,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(rmSkillResp)
|
res, err = json.Marshal(rmSkillResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "accessoryAll":
|
case "accessoryAll":
|
||||||
// fmt.Println("accessoryAll")
|
// key = "unit_accessory_result"
|
||||||
key = "unit_accessory_result"
|
|
||||||
unitAccResp := model.UnitAccessoryAllResp{
|
unitAccResp := model.UnitAccessoryAllResp{
|
||||||
// _ = model.UnitAccessoryAllResp{
|
|
||||||
Result: model.UnitAccessoryAllResult{
|
Result: model.UnitAccessoryAllResult{
|
||||||
AccessoryList: []interface{}{},
|
AccessoryList: []interface{}{},
|
||||||
WearingInfo: []interface{}{},
|
WearingInfo: []interface{}{},
|
||||||
@@ -347,10 +323,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
}
|
}
|
||||||
case "costume":
|
case "costume":
|
||||||
// fmt.Println("costumeList")
|
// key = "costume_list_result"
|
||||||
key = "costume_list_result"
|
|
||||||
costumeListResp := model.CostumeListResp{
|
costumeListResp := model.CostumeListResp{
|
||||||
// _ = model.CostumeListResp{
|
|
||||||
Result: model.CostumeListResult{
|
Result: model.CostumeListResult{
|
||||||
CostumeList: []model.CostumeList{},
|
CostumeList: []model.CostumeList{},
|
||||||
},
|
},
|
||||||
@@ -361,8 +335,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(costumeListResp)
|
res, err = json.Marshal(costumeListResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "album":
|
case "album":
|
||||||
// fmt.Println("albumAll")
|
// key = "album_unit_result"
|
||||||
key = "album_unit_result"
|
|
||||||
albumLists := []model.AlbumResult{}
|
albumLists := []model.AlbumResult{}
|
||||||
sql := `SELECT unit_id,rarity FROM unit_m ORDER BY unit_id ASC`
|
sql := `SELECT unit_id,rarity FROM unit_m ORDER BY unit_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
@@ -417,7 +390,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
albumResp := model.AlbumResp{
|
albumResp := model.AlbumResp{
|
||||||
// _ = model.AlbumResp{
|
|
||||||
Result: albumLists,
|
Result: albumLists,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -426,8 +398,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(albumResp)
|
res, err = json.Marshal(albumResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "scenario":
|
case "scenario":
|
||||||
// fmt.Println("scenarioStatus")
|
// key = "scenario_status_result"
|
||||||
key = "scenario_status_result"
|
|
||||||
sql := `SELECT scenario_id FROM scenario_m ORDER BY scenario_id ASC`
|
sql := `SELECT scenario_id FROM scenario_m ORDER BY scenario_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -443,7 +414,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
scenarioResp := model.ScenarioStatusResp{
|
scenarioResp := model.ScenarioStatusResp{
|
||||||
// _ = model.ScenarioStatusResp{
|
|
||||||
Result: model.ScenarioStatusResult{
|
Result: model.ScenarioStatusResult{
|
||||||
ScenarioStatusList: scenarioLists,
|
ScenarioStatusList: scenarioLists,
|
||||||
},
|
},
|
||||||
@@ -454,8 +424,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(scenarioResp)
|
res, err = json.Marshal(scenarioResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "subscenario":
|
case "subscenario":
|
||||||
// fmt.Println("subscenarioStatus")
|
// key = "subscenario_status_result"
|
||||||
key = "subscenario_status_result"
|
|
||||||
sql := `SELECT subscenario_id FROM subscenario_m ORDER BY subscenario_id ASC`
|
sql := `SELECT subscenario_id FROM subscenario_m ORDER BY subscenario_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -471,7 +440,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
subScenarioResp := model.SubscenarioStatusResp{
|
subScenarioResp := model.SubscenarioStatusResp{
|
||||||
// _ = model.SubscenarioStatusResp{
|
|
||||||
Result: model.SubscenarioStatusResult{
|
Result: model.SubscenarioStatusResult{
|
||||||
SubscenarioStatusList: subScenarioLists,
|
SubscenarioStatusList: subScenarioLists,
|
||||||
UnlockedSubscenarioIds: []interface{}{},
|
UnlockedSubscenarioIds: []interface{}{},
|
||||||
@@ -483,8 +451,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(subScenarioResp)
|
res, err = json.Marshal(subScenarioResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "eventscenario":
|
case "eventscenario":
|
||||||
// fmt.Println("status")
|
// key = "event_scenario_result"
|
||||||
key = "event_scenario_result"
|
|
||||||
eventsList := []model.EventScenarioList{}
|
eventsList := []model.EventScenarioList{}
|
||||||
sql := `SELECT event_id FROM event_scenario_m GROUP BY event_id ORDER BY event_id DESC`
|
sql := `SELECT event_id FROM event_scenario_m GROUP BY event_id ORDER BY event_id DESC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
@@ -541,7 +508,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
eventsList = append(eventsList, eventList)
|
eventsList = append(eventsList, eventList)
|
||||||
}
|
}
|
||||||
eventScenarioResp := model.EventScenarioStatusResp{
|
eventScenarioResp := model.EventScenarioStatusResp{
|
||||||
// _ = model.EventScenarioStatusResp{
|
|
||||||
Result: model.EventScenarioStatusResult{
|
Result: model.EventScenarioStatusResult{
|
||||||
EventScenarioList: eventsList, //
|
EventScenarioList: eventsList, //
|
||||||
},
|
},
|
||||||
@@ -552,8 +518,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(eventScenarioResp)
|
res, err = json.Marshal(eventScenarioResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "multiunit":
|
case "multiunit":
|
||||||
// fmt.Println("multiunitscenarioStatus")
|
// key = "multi_unit_scenario_result"
|
||||||
key = "multi_unit_scenario_result"
|
|
||||||
sql := `SELECT multi_unit_id FROM multi_unit_scenario_m GROUP BY multi_unit_id ORDER BY multi_unit_id ASC`
|
sql := `SELECT multi_unit_id FROM multi_unit_scenario_m GROUP BY multi_unit_id ORDER BY multi_unit_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -590,7 +555,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
unitsResp := model.MultiUnitScenarioStatusResp{
|
unitsResp := model.MultiUnitScenarioStatusResp{
|
||||||
// _ = model.MultiUnitScenarioStatusResp{
|
|
||||||
Result: model.MultiUnitScenarioStatusResult{
|
Result: model.MultiUnitScenarioStatusResult{
|
||||||
MultiUnitScenarioStatusList: multiUnitsList,
|
MultiUnitScenarioStatusList: multiUnitsList,
|
||||||
UnlockedMultiUnitScenarioIds: []interface{}{},
|
UnlockedMultiUnitScenarioIds: []interface{}{},
|
||||||
@@ -602,10 +566,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(unitsResp)
|
res, err = json.Marshal(unitsResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "payment":
|
case "payment":
|
||||||
// fmt.Println("productList")
|
// key = "product_result"
|
||||||
key = "product_result"
|
|
||||||
productResp := model.ProductListResp{
|
productResp := model.ProductListResp{
|
||||||
// _ = model.ProductListResp{
|
|
||||||
Result: model.ProductListResult{
|
Result: model.ProductListResult{
|
||||||
RestrictionInfo: model.RestrictionInfo{
|
RestrictionInfo: model.RestrictionInfo{
|
||||||
Restricted: false,
|
Restricted: false,
|
||||||
@@ -628,10 +590,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(productResp)
|
res, err = json.Marshal(productResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "banner":
|
case "banner":
|
||||||
// fmt.Println("bannerList")
|
// key = "banner_result"
|
||||||
key = "banner_result"
|
|
||||||
bannerResp := model.BannerListResp{
|
bannerResp := model.BannerListResp{
|
||||||
// _ = model.BannerListResp{
|
|
||||||
Result: model.BannerListResult{
|
Result: model.BannerListResult{
|
||||||
TimeLimit: "2037-12-31 23:59:59",
|
TimeLimit: "2037-12-31 23:59:59",
|
||||||
BannerList: []model.BannerList{
|
BannerList: []model.BannerList{
|
||||||
@@ -666,10 +626,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(bannerResp)
|
res, err = json.Marshal(bannerResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "notice":
|
case "notice":
|
||||||
// fmt.Println("noticeMarquee")
|
// key = "item_marquee_result"
|
||||||
key = "item_marquee_result"
|
|
||||||
marqueeResp := model.NoticeMarqueeResp{
|
marqueeResp := model.NoticeMarqueeResp{
|
||||||
// _ = model.NoticeMarqueeResp{
|
|
||||||
Result: model.NoticeMarqueeResult{
|
Result: model.NoticeMarqueeResult{
|
||||||
ItemCount: 0,
|
ItemCount: 0,
|
||||||
MarqueeList: []interface{}{},
|
MarqueeList: []interface{}{},
|
||||||
@@ -681,10 +639,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(marqueeResp)
|
res, err = json.Marshal(marqueeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "user":
|
case "user":
|
||||||
// fmt.Println("getNavi")
|
// key = "user_intro_result"
|
||||||
key = "user_intro_result"
|
|
||||||
userIntroResp := model.UserNaviResp{
|
userIntroResp := model.UserNaviResp{
|
||||||
// _ = model.UserNaviResp{
|
|
||||||
Result: model.UserNaviResult{
|
Result: model.UserNaviResult{
|
||||||
User: model.User{
|
User: model.User{
|
||||||
UserID: 9999999,
|
UserID: 9999999,
|
||||||
@@ -698,10 +654,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(userIntroResp)
|
res, err = json.Marshal(userIntroResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "navigation":
|
case "navigation":
|
||||||
// fmt.Println("specialCutin")
|
// key = "special_cutin_result"
|
||||||
key = "special_cutin_result"
|
|
||||||
cutinResp := model.SpecialCutinResp{
|
cutinResp := model.SpecialCutinResp{
|
||||||
// _ = model.SpecialCutinResp{
|
|
||||||
Result: model.SpecialCutinResult{
|
Result: model.SpecialCutinResult{
|
||||||
SpecialCutinList: []interface{}{},
|
SpecialCutinList: []interface{}{},
|
||||||
},
|
},
|
||||||
@@ -712,8 +666,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(cutinResp)
|
res, err = json.Marshal(cutinResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "award":
|
case "award":
|
||||||
// fmt.Println("awardInfo")
|
// key = "award_result"
|
||||||
key = "award_result"
|
|
||||||
sql := `SELECT award_id FROM award_m ORDER BY award_id ASC`
|
sql := `SELECT award_id FROM award_m ORDER BY award_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -734,7 +687,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
awardResp := model.AwardInfoResp{
|
awardResp := model.AwardInfoResp{
|
||||||
// _ = model.AwardInfoResp{
|
|
||||||
Result: model.AwardInfoResult{
|
Result: model.AwardInfoResult{
|
||||||
AwardInfo: awardsList,
|
AwardInfo: awardsList,
|
||||||
},
|
},
|
||||||
@@ -745,8 +697,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(awardResp)
|
res, err = json.Marshal(awardResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "background":
|
case "background":
|
||||||
// fmt.Println("backgroundInfo")
|
// key = "background_result"
|
||||||
key = "background_result"
|
|
||||||
sql := `SELECT background_id FROM background_m ORDER BY background_id ASC`
|
sql := `SELECT background_id FROM background_m ORDER BY background_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -767,7 +718,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
backgroundResp := model.BackgroundInfoResp{
|
backgroundResp := model.BackgroundInfoResp{
|
||||||
// _ = model.BackgroundInfoResp{
|
|
||||||
Result: model.BackgroundInfoResult{
|
Result: model.BackgroundInfoResult{
|
||||||
BackgroundInfo: backgroundsList,
|
BackgroundInfo: backgroundsList,
|
||||||
},
|
},
|
||||||
@@ -778,8 +728,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(backgroundResp)
|
res, err = json.Marshal(backgroundResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "stamp":
|
case "stamp":
|
||||||
// fmt.Println("stampInfo")
|
// key = "stamp_result"
|
||||||
key = "stamp_result"
|
|
||||||
stampResp := utils.ReadAllText("assets/stamp.json")
|
stampResp := utils.ReadAllText("assets/stamp.json")
|
||||||
var mStampResp interface{}
|
var mStampResp interface{}
|
||||||
err = json.Unmarshal([]byte(stampResp), &mStampResp)
|
err = json.Unmarshal([]byte(stampResp), &mStampResp)
|
||||||
@@ -787,8 +736,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(mStampResp)
|
res, err = json.Marshal(mStampResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "exchange":
|
case "exchange":
|
||||||
// fmt.Println("owningPoint")
|
// key = "exchange_point_result"
|
||||||
key = "exchange_point_result"
|
|
||||||
sql := `SELECT exchange_point_id FROM exchange_point_m ORDER BY exchange_point_id ASC`
|
sql := `SELECT exchange_point_id FROM exchange_point_m ORDER BY exchange_point_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -804,7 +752,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
exPointsResp := model.ExchangePointResp{
|
exPointsResp := model.ExchangePointResp{
|
||||||
// _ = model.ExchangePointResp{
|
|
||||||
Result: model.ExchangePointResult{
|
Result: model.ExchangePointResult{
|
||||||
ExchangePointList: exPointsList,
|
ExchangePointList: exPointsList,
|
||||||
},
|
},
|
||||||
@@ -815,10 +762,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(exPointsResp)
|
res, err = json.Marshal(exPointsResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "livese":
|
case "livese":
|
||||||
// fmt.Println("liveseInfo")
|
// key = "live_se_result"
|
||||||
key = "live_se_result"
|
|
||||||
liveSeResp := model.LiveSeInfoResp{
|
liveSeResp := model.LiveSeInfoResp{
|
||||||
// _ = model.LiveSeInfoResp{
|
|
||||||
Result: model.LiveSeInfoResult{
|
Result: model.LiveSeInfoResult{
|
||||||
LiveSeList: []int{1, 2, 3},
|
LiveSeList: []int{1, 2, 3},
|
||||||
},
|
},
|
||||||
@@ -829,10 +774,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(liveSeResp)
|
res, err = json.Marshal(liveSeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "liveicon":
|
case "liveicon":
|
||||||
// fmt.Println("liveiconInfo")
|
// key = "live_icon_result"
|
||||||
key = "live_icon_result"
|
|
||||||
liveIconResp := model.LiveIconInfoResp{
|
liveIconResp := model.LiveIconInfoResp{
|
||||||
// _ = model.LiveIconInfoResp{
|
|
||||||
Result: model.LiveIconInfoResult{
|
Result: model.LiveIconInfoResult{
|
||||||
LiveNotesIconList: []int{1, 2, 3},
|
LiveNotesIconList: []int{1, 2, 3},
|
||||||
},
|
},
|
||||||
@@ -843,20 +786,16 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(liveIconResp)
|
res, err = json.Marshal(liveIconResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "item":
|
case "item":
|
||||||
// fmt.Println("list")
|
// key = "item_list_result"
|
||||||
key = "item_list_result"
|
|
||||||
itemResp := utils.ReadAllText("assets/item.json")
|
itemResp := utils.ReadAllText("assets/item.json")
|
||||||
// _ = utils.ReadAllText("assets/item.json")
|
|
||||||
var mItemResp interface{}
|
var mItemResp interface{}
|
||||||
err = json.Unmarshal([]byte(itemResp), &mItemResp)
|
err = json.Unmarshal([]byte(itemResp), &mItemResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
res, err = json.Marshal(mItemResp)
|
res, err = json.Marshal(mItemResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "marathon":
|
case "marathon":
|
||||||
// fmt.Println("marathonInfo")
|
// key = "marathon_result"
|
||||||
key = "marathon_result"
|
|
||||||
marathonResp := model.MarathonInfoResp{
|
marathonResp := model.MarathonInfoResp{
|
||||||
// _ = model.MarathonInfoResp{
|
|
||||||
Result: []interface{}{},
|
Result: []interface{}{},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -865,10 +804,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(marathonResp)
|
res, err = json.Marshal(marathonResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "challenge":
|
case "challenge":
|
||||||
// fmt.Println("challengeInfo")
|
// key = "challenge_result"
|
||||||
key = "challenge_result"
|
|
||||||
challengeResp := model.ChallengeInfoResp{
|
challengeResp := model.ChallengeInfoResp{
|
||||||
// _ = model.ChallengeInfoResp{
|
|
||||||
Result: []interface{}{},
|
Result: []interface{}{},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -877,8 +814,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(challengeResp)
|
res, err = json.Marshal(challengeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "museum":
|
case "museum":
|
||||||
// fmt.Println("info")
|
// key = "museum_result"
|
||||||
key = "museum_result"
|
|
||||||
sql := `SELECT museum_contents_id,smile_buff,pure_buff,cool_buff FROM museum_contents_m ORDER BY museum_contents_id ASC`
|
sql := `SELECT museum_contents_id,smile_buff,pure_buff,cool_buff FROM museum_contents_m ORDER BY museum_contents_id ASC`
|
||||||
rows, err := MainEng.DB().Query(sql)
|
rows, err := MainEng.DB().Query(sql)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -914,10 +850,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "profile":
|
case "profile":
|
||||||
if v.Action == "liveCnt" {
|
if v.Action == "liveCnt" {
|
||||||
// fmt.Println("liveCnt")
|
// key = "profile_livecnt_result"
|
||||||
key = "profile_livecnt_result"
|
|
||||||
difficultyResp := tools.DifficultyResp{
|
difficultyResp := tools.DifficultyResp{
|
||||||
// _ = DifficultyResp{
|
|
||||||
Result: []tools.DifficultyResult{
|
Result: []tools.DifficultyResult{
|
||||||
{
|
{
|
||||||
Difficulty: 1,
|
Difficulty: 1,
|
||||||
@@ -947,14 +881,12 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(difficultyResp)
|
res, err = json.Marshal(difficultyResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
} else if v.Action == "cardRanking" {
|
} else if v.Action == "cardRanking" {
|
||||||
// fmt.Println("cardRanking")
|
// key = "profile_card_ranking_result"
|
||||||
key = "profile_card_ranking_result"
|
|
||||||
var result []interface{}
|
var result []interface{}
|
||||||
love := utils.ReadAllText("assets/love.json")
|
love := utils.ReadAllText("assets/love.json")
|
||||||
err := json.Unmarshal([]byte(love), &result)
|
err := json.Unmarshal([]byte(love), &result)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
loveResp := tools.LoveResp{
|
loveResp := tools.LoveResp{
|
||||||
// _ = LoveResp{
|
|
||||||
Result: result,
|
Result: result,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -963,8 +895,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
res, err = json.Marshal(loveResp)
|
res, err = json.Marshal(loveResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
} else if v.Action == "profileInfo" {
|
} else if v.Action == "profileInfo" {
|
||||||
// fmt.Println("profileInfo")
|
// key = "profile_info_result"
|
||||||
key = "profile_info_result"
|
|
||||||
profileResp := tools.ProfileResp{
|
profileResp := tools.ProfileResp{
|
||||||
Result: tools.ProfileResult{
|
Result: tools.ProfileResult{
|
||||||
UserInfo: tools.UserInfo{
|
UserInfo: tools.UserInfo{
|
||||||
@@ -1066,14 +997,6 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println(key)
|
|
||||||
_ = key
|
|
||||||
|
|
||||||
// if key != "login_topinfo_result" && key != "login_topinfo_once_result" {
|
|
||||||
// res, err = database.LevelDb.Get([]byte(key))
|
|
||||||
// CheckErr(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
var result interface{}
|
var result interface{}
|
||||||
err = json.Unmarshal([]byte(res), &result)
|
err = json.Unmarshal([]byte(res), &result)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -1089,38 +1012,13 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
b, err = json.Marshal(rp)
|
b, err = json.Marshal(rp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(b))
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
nonce := ctx.GetInt("nonce")
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
nonce++
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
// fmt.Println(newAuthorizeStr)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(b, "privatekey.pem")))
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(b, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.String(http.StatusOK, string(b))
|
ctx.String(http.StatusOK, string(b))
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-186
@@ -4,10 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -17,37 +15,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func DownloadAdditionalHandler(ctx *gin.Context) {
|
func DownloadAdditionalHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
downloadReq := model.AdditionalReq{}
|
downloadReq := model.AdditionalReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -78,48 +45,18 @@ func DownloadAdditionalHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(addResp)
|
resp, err := json.Marshal(addResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadBatchHandler(ctx *gin.Context) {
|
func DownloadBatchHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
downloadReq := model.BatchReq{}
|
downloadReq := model.BatchReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -158,48 +95,18 @@ func DownloadBatchHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(batchResp)
|
resp, err := json.Marshal(batchResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadUpdateHandler(ctx *gin.Context) {
|
func DownloadUpdateHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
downloadReq := model.UpdateReq{}
|
downloadReq := model.UpdateReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -228,50 +135,20 @@ func DownloadUpdateHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(updateResp)
|
resp, err := json.Marshal(updateResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadUrlHandler(ctx *gin.Context) {
|
func DownloadUrlHandler(ctx *gin.Context) {
|
||||||
// Extract SQL: SELECT CAST(pkg_type AS TEXT) || '_' || CAST(pkg_id AS TEXT) || '_' || CAST(pkg_order AS TEXT) || '.zip' AS zip_name FROM download_db ORDER BY pkg_type ASC,pkg_id ASC, pkg_order ASC;
|
// Extract SQL: SELECT CAST(pkg_type AS TEXT) || '_' || CAST(pkg_id AS TEXT) || '_' || CAST(pkg_order AS TEXT) || '.zip' AS zip_name FROM download_db ORDER BY pkg_type ASC,pkg_id ASC, pkg_order ASC;
|
||||||
// Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done
|
// Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
downloadReq := model.UrlReq{}
|
downloadReq := model.UrlReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -289,48 +166,18 @@ func DownloadUrlHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(urlResp)
|
resp, err := json.Marshal(urlResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadEventHandler(ctx *gin.Context) {
|
func DownloadEventHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
eventResp := model.EventResp{
|
eventResp := model.EventResp{
|
||||||
ResponseData: []interface{}{},
|
ResponseData: []interface{}{},
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
@@ -338,11 +185,13 @@ func DownloadEventHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(eventResp)
|
resp, err := json.Marshal(eventResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-60
@@ -4,73 +4,24 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventsResp struct {
|
|
||||||
ResponseData EventsData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TargetList struct {
|
|
||||||
Position int `json:"position"`
|
|
||||||
IsDisplayable bool `json:"is_displayable"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EventsData struct {
|
|
||||||
TargetList []TargetList `json:"target_list"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func EventListHandler(ctx *gin.Context) {
|
func EventListHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
targets := []model.TargetList{}
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
targets := []TargetList{}
|
|
||||||
for i := 0; i < 6; i++ {
|
for i := 0; i < 6; i++ {
|
||||||
targets = append(targets, TargetList{
|
targets = append(targets, model.TargetList{
|
||||||
Position: i + 1,
|
Position: i + 1,
|
||||||
IsDisplayable: false,
|
IsDisplayable: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
eventsResp := EventsResp{
|
eventsResp := model.EventsResp{
|
||||||
ResponseData: EventsData{
|
ResponseData: model.EventsRes{
|
||||||
TargetList: targets,
|
TargetList: targets,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
},
|
},
|
||||||
@@ -79,12 +30,13 @@ func EventListHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(eventsResp)
|
resp, err := json.Marshal(eventsResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-54
@@ -4,62 +4,17 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GdprResp struct {
|
|
||||||
ResponseData GdprData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GdprData struct {
|
|
||||||
EnableGdpr bool `json:"enable_gdpr"`
|
|
||||||
IsEea bool `json:"is_eea"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func GdprHandler(ctx *gin.Context) {
|
func GdprHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
gdprResp := model.GdprResp{
|
||||||
|
ResponseData: model.GdprRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
gdprResp := GdprResp{
|
|
||||||
ResponseData: GdprData{
|
|
||||||
EnableGdpr: true,
|
EnableGdpr: true,
|
||||||
IsEea: false,
|
IsEea: false,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
@@ -69,12 +24,13 @@ func GdprHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(gdprResp)
|
resp, err := json.Marshal(gdprResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
nonce = 0
|
// nonce = 0
|
||||||
PackageVersion = "97.4.6"
|
PackageVersion = "97.4.6"
|
||||||
CdnUrl string
|
CdnUrl string
|
||||||
ErrorMsg = `{"code":20001,"message":""}`
|
ErrorMsg = `{"code":20001,"message":""}`
|
||||||
|
|||||||
+9
-42
@@ -4,11 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -16,37 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func LBonusExecuteHandler(ctx *gin.Context) {
|
func LBonusExecuteHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
weeks := map[string]int{
|
weeks := map[string]int{
|
||||||
"Monday": 1,
|
"Monday": 1,
|
||||||
"Tuesday": 2,
|
"Tuesday": 2,
|
||||||
@@ -127,7 +93,7 @@ func LBonusExecuteHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res := model.LbResp{
|
LbRes := model.LbResp{
|
||||||
ResponseData: model.LbRes{
|
ResponseData: model.LbRes{
|
||||||
Sheets: []interface{}{},
|
Sheets: []interface{}{},
|
||||||
CalendarInfo: model.CalendarInfo{
|
CalendarInfo: model.CalendarInfo{
|
||||||
@@ -184,14 +150,15 @@ func LBonusExecuteHandler(ctx *gin.Context) {
|
|||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := json.Marshal(res)
|
resp, err := json.Marshal(LbRes)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-187
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
"honoka-chan/database"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
@@ -24,91 +23,30 @@ type GameOverResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PartyListHandler(ctx *gin.Context) {
|
func PartyListHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
resp := utils.ReadAllText("assets/partylist.json")
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
nonce := ctx.GetInt("nonce")
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
nonce++
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
// fmt.Println(newAuthorizeStr)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||||
|
|
||||||
resp := utils.ReadAllText("assets/partylist.json")
|
|
||||||
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlayLiveHandler(ctx *gin.Context) {
|
func PlayLiveHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
playReq := model.PlayReq{}
|
playReq := model.PlayReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
tDifficultyId := playReq.LiveDifficultyID
|
tDifficultyId := playReq.LiveDifficultyID
|
||||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
deckId := playReq.UnitDeckID
|
deckId := playReq.UnitDeckID
|
||||||
|
|
||||||
// Save Deck Id for /live/reward
|
// Save Deck Id for /live/reward
|
||||||
key := "live_deck_" + userId[0]
|
key := "live_deck_" + ctx.GetString("userid")
|
||||||
err = database.LevelDb.Put([]byte(key), []byte(strconv.Itoa(deckId)))
|
err = database.LevelDb.Put([]byte(key), []byte(strconv.Itoa(deckId)))
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
@@ -206,48 +144,17 @@ func PlayLiveHandler(ctx *gin.Context) {
|
|||||||
mm, err := json.Marshal(res)
|
mm, err := json.Marshal(res)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
nonce := ctx.GetInt("nonce")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
nonce++
|
||||||
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.String(http.StatusOK, string(mm))
|
ctx.String(http.StatusOK, string(mm))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GameOverHandler(ctx *gin.Context) {
|
func GameOverHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
overResp := GameOverResp{
|
overResp := GameOverResp{
|
||||||
ResponseData: []interface{}{},
|
ResponseData: []interface{}{},
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
@@ -255,52 +162,22 @@ func GameOverHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(overResp)
|
resp, err := json.Marshal(overResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlayScoreHandler(ctx *gin.Context) {
|
func PlayScoreHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
playScoreReq := model.PlayScoreReq{}
|
playScoreReq := model.PlayScoreReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playScoreReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playScoreReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
tDifficultyId := playScoreReq.LiveDifficultyID
|
tDifficultyId := playScoreReq.LiveDifficultyID
|
||||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -384,52 +261,21 @@ func PlayScoreHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(mm))
|
// fmt.Println(string(mm))
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
nonce := ctx.GetInt("nonce")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
nonce++
|
||||||
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.String(http.StatusOK, string(mm))
|
ctx.String(http.StatusOK, string(mm))
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlayRewardHandler(ctx *gin.Context) {
|
func PlayRewardHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
playRewardReq := model.PlayRewardReq{}
|
playRewardReq := model.PlayRewardReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playRewardReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playRewardReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
difficultyId := playRewardReq.LiveDifficultyID
|
difficultyId := playRewardReq.LiveDifficultyID
|
||||||
|
|
||||||
// Song type: normal / special
|
// Song type: normal / special
|
||||||
@@ -439,13 +285,13 @@ func PlayRewardHandler(ctx *gin.Context) {
|
|||||||
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(&c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &c_rank_combo, &b_rank_combo, &a_rank_combo, &s_rank_combo, &ac_flag, &swing_flag)
|
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(&c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &c_rank_combo, &b_rank_combo, &a_rank_combo, &s_rank_combo, &ac_flag, &swing_flag)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
key := "live_deck_" + userId[0]
|
key := "live_deck_" + ctx.GetString("userid")
|
||||||
deckId, err := database.LevelDb.Get([]byte(key))
|
deckId, err := database.LevelDb.Get([]byte(key))
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
unitsList := []model.PlayRewardUnitList{}
|
unitsList := []model.PlayRewardUnitList{}
|
||||||
err = UserEng.Table("deck_unit_m").Select("*").
|
err = UserEng.Table("deck_unit_m").Select("*").
|
||||||
Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||||
Where("user_id = ? AND deck_id = ?", userId[0], string(deckId)).Find(&unitsList)
|
Where("user_id = ? AND deck_id = ?", ctx.GetString("userid"), string(deckId)).Find(&unitsList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
||||||
@@ -609,12 +455,12 @@ func PlayRewardHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(mm))
|
// fmt.Println(string(mm))
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
nonce := ctx.GetInt("nonce")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
nonce++
|
||||||
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.String(http.StatusOK, string(mm))
|
ctx.String(http.StatusOK, string(mm))
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-117
@@ -7,151 +7,63 @@ import (
|
|||||||
"honoka-chan/database"
|
"honoka-chan/database"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func AuthKeyHandler(ctx *gin.Context) {
|
func AuthKey(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
authResp := model.AuthKeyResp{
|
||||||
|
ResponseData: model.AuthKeyRes{
|
||||||
authReq := model.AuthKeyReq{}
|
AuthorizeToken: ctx.GetString("authorize_token"),
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &authReq)
|
DummyToken: ctx.GetString("dummy_token"),
|
||||||
CheckErr(err)
|
},
|
||||||
|
ReleaseInfo: []interface{}{},
|
||||||
dummyToken64, err := base64.StdEncoding.DecodeString(authReq.DummyToken)
|
StatusCode: 200,
|
||||||
CheckErr(err)
|
|
||||||
dummyTokenDecrypted := encrypt.RSA_Decrypt(dummyToken64, "privatekey.pem")
|
|
||||||
|
|
||||||
// aesKey := dummyTokenDecrypted[0:16]
|
|
||||||
// data64, err := base64.StdEncoding.DecodeString(authReq.AuthData)
|
|
||||||
// CheckErr(err)
|
|
||||||
// dataDecrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(data64, aesKey))
|
|
||||||
// fmt.Println(string(dataDecrypted))
|
|
||||||
|
|
||||||
mRandStr := utils.RandomStr(32)
|
|
||||||
serverToken := base64.RawStdEncoding.EncodeToString([]byte(mRandStr))
|
|
||||||
|
|
||||||
authorizeToken := utils.RandomBase64Token(32)
|
|
||||||
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
clientToken := base64.RawStdEncoding.EncodeToString(dummyTokenDecrypted)
|
|
||||||
authData := map[string]interface{}{
|
|
||||||
"client_token": clientToken,
|
|
||||||
"server_token": serverToken,
|
|
||||||
}
|
}
|
||||||
authJson, err := json.Marshal(authData)
|
|
||||||
CheckErr(err)
|
|
||||||
database.LevelDb.Put([]byte(authorizeToken), authJson)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
authResp := model.AuthKeyResp{}
|
|
||||||
authResp.ResponseData.DummyToken = serverToken
|
|
||||||
authResp.ResponseData.AuthorizeToken = authorizeToken
|
|
||||||
authResp.StatusCode = 200
|
|
||||||
resp, err := json.Marshal(authResp)
|
resp, err := json.Marshal(authResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
xMessageSign := base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem"))
|
||||||
authorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&nonce=%d&requestTimeStamp=%d", respTime, nonce, reqTime)
|
|
||||||
// fmt.Println(authorizeStr)
|
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
ctx.Header("X-Message-Sign", xMessageSign)
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", "")
|
|
||||||
ctx.Header("authorize", authorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
ctx.JSON(http.StatusOK, authResp)
|
ctx.JSON(http.StatusOK, authResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoginHandler(ctx *gin.Context) {
|
func Login(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
loginKey := ctx.GetString("login_key")
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
authData, err := database.LevelDb.Get([]byte(authToken))
|
|
||||||
CheckErr(err)
|
|
||||||
// fmt.Println(authData)
|
|
||||||
|
|
||||||
clientToken := gjson.Get(string(authData), "client_token").String()
|
|
||||||
serverToken := gjson.Get(string(authData), "server_token").String()
|
|
||||||
clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken)
|
|
||||||
CheckErr(err)
|
|
||||||
serverToken64, err := base64.RawStdEncoding.DecodeString(serverToken)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
xmcKey := utils.SliceXor([]byte(clientToken64), []byte(serverToken64))
|
|
||||||
aesKey := xmcKey[0:16]
|
|
||||||
|
|
||||||
loginReq := model.LoginReq{}
|
|
||||||
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &loginReq)
|
|
||||||
CheckErr(err)
|
|
||||||
key64, err := base64.StdEncoding.DecodeString(loginReq.LoginKey)
|
|
||||||
CheckErr(err)
|
|
||||||
// pass64, err := base64.StdEncoding.DecodeString(loginReq.LoginPasswd)
|
|
||||||
// CheckErr(err)
|
|
||||||
keyDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(key64, aesKey))
|
|
||||||
// fmt.Println(string(keyDescrypted))
|
|
||||||
// passDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(pass64, aesKey))
|
|
||||||
// fmt.Println(string(passDescrypted))
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
stmt, err := UserEng.DB().Prepare("SELECT userid FROM user_key WHERE key = ?")
|
|
||||||
CheckErr(err)
|
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
var userId int
|
var userId int
|
||||||
err = stmt.QueryRow(string(keyDescrypted)).Scan(&userId)
|
exists, err := UserEng.Table("user_key").Where("key = ?", loginKey).Cols("userid").Get(&userId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
if userId == 0 {
|
if !exists || userId == 0 {
|
||||||
userId = 9999999
|
userId = 9999999
|
||||||
}
|
}
|
||||||
sUserId := strconv.Itoa(userId)
|
ctx.Set("userid", userId)
|
||||||
authorizeToken := utils.RandomBase64Token(32)
|
|
||||||
|
|
||||||
err = database.LevelDb.Put([]byte(sUserId), []byte(authorizeToken))
|
err = database.LevelDb.Put([]byte(strconv.Itoa(userId)), []byte(ctx.GetString("authorize_token")))
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
loginResp := model.LoginResp{}
|
loginResp := model.LoginResp{
|
||||||
loginResp.ResponseData.AuthorizeToken = authorizeToken
|
ResponseData: model.LoginRes{
|
||||||
loginResp.ResponseData.UserId = userId
|
AuthorizeToken: ctx.GetString("authorize_token"),
|
||||||
loginResp.ResponseData.ServerTimestamp = time.Now().Unix()
|
UserId: userId,
|
||||||
loginResp.ResponseData.AdultFlag = 2
|
ServerTimestamp: time.Now().Unix(),
|
||||||
loginResp.StatusCode = 200
|
AdultFlag: 2,
|
||||||
|
},
|
||||||
|
ReleaseInfo: []interface{}{},
|
||||||
|
StatusCode: 200,
|
||||||
|
}
|
||||||
resp, err := json.Marshal(loginResp)
|
resp, err := json.Marshal(loginResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// fmt.Println(string(resp))
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%d&requestTimeStamp=%d", respTime, authorizeToken, nonce, userId, reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", "")
|
ctx.Header("user_id", "")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("authorize_token"), ctx.GetInt("nonce"), ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, loginResp)
|
ctx.JSON(http.StatusOK, loginResp)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-40
@@ -4,10 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -36,41 +33,10 @@ type MultiUnitStartUpReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MultiUnitStartUpHandler(ctx *gin.Context) {
|
func MultiUnitStartUpHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
startReq := MultiUnitStartUpReq{}
|
startReq := MultiUnitStartUpReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
startResp := MultiUnitStartUpResp{
|
startResp := MultiUnitStartUpResp{
|
||||||
ResponseData: MultiUnitStartUpData{
|
ResponseData: MultiUnitStartUpData{
|
||||||
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
||||||
@@ -82,13 +48,13 @@ func MultiUnitStartUpHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(startResp)
|
resp, err := json.Marshal(startResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-157
@@ -4,87 +4,17 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NoticeFriendVarietyResp struct {
|
|
||||||
ResponseData NoticeFriendVarietyData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoticeFriendVarietyData struct {
|
|
||||||
ItemCount int `json:"item_count"`
|
|
||||||
NoticeList []interface{} `json:"notice_list"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoticeFriendGreetingResp struct {
|
|
||||||
ResponseData NoticeFriendGreetingData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoticeFriendGreetingData struct {
|
|
||||||
NextId int `json:"next_id"`
|
|
||||||
NoticeList []interface{} `json:"notice_list"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoticeUserGreetingResp struct {
|
|
||||||
ResponseData NoticeUserGreetingData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoticeUserGreetingData struct {
|
|
||||||
ItemCount int `json:"item_count"`
|
|
||||||
HasNext bool `json:"has_next"`
|
|
||||||
NoticeList []interface{} `json:"notice_list"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NoticeFriendVarietyHandler(ctx *gin.Context) {
|
func NoticeFriendVarietyHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
noticeResp := model.NoticeFriendVarietyResp{
|
||||||
|
ResponseData: model.NoticeFriendVarietyRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
noticeResp := NoticeFriendVarietyResp{
|
|
||||||
ResponseData: NoticeFriendVarietyData{
|
|
||||||
ItemCount: 1,
|
ItemCount: 1,
|
||||||
NoticeList: []interface{}{},
|
NoticeList: []interface{}{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
@@ -94,50 +24,20 @@ func NoticeFriendVarietyHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NoticeFriendGreetingHandler(ctx *gin.Context) {
|
func NoticeFriendGreetingHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
noticeResp := model.NoticeFriendGreetingResp{
|
||||||
|
ResponseData: model.NoticeFriendGreetingRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
noticeResp := NoticeFriendGreetingResp{
|
|
||||||
ResponseData: NoticeFriendGreetingData{
|
|
||||||
NextId: 0,
|
NextId: 0,
|
||||||
NoticeList: []interface{}{},
|
NoticeList: []interface{}{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
@@ -147,50 +47,20 @@ func NoticeFriendGreetingHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NoticeUserGreetingHandler(ctx *gin.Context) {
|
func NoticeUserGreetingHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
noticeResp := model.NoticeUserGreetingResp{
|
||||||
|
ResponseData: model.NoticeUserGreetingRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
noticeResp := NoticeUserGreetingResp{
|
|
||||||
ResponseData: NoticeUserGreetingData{
|
|
||||||
ItemCount: 0,
|
ItemCount: 0,
|
||||||
HasNext: false,
|
HasNext: false,
|
||||||
NoticeList: []interface{}{},
|
NoticeList: []interface{}{},
|
||||||
@@ -201,12 +71,13 @@ func NoticeUserGreetingHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-40
@@ -4,10 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -39,37 +36,6 @@ type ProductData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProductListHandler(ctx *gin.Context) {
|
func ProductListHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
prodReesp := ProductResp{
|
prodReesp := ProductResp{
|
||||||
ResponseData: ProductData{
|
ResponseData: ProductData{
|
||||||
RestrictionInfo: RestrictionInfo{
|
RestrictionInfo: RestrictionInfo{
|
||||||
@@ -92,12 +58,13 @@ func ProductListHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(prodReesp)
|
resp, err := json.Marshal(prodReesp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-57
@@ -4,65 +4,17 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PersonalNoticeResp struct {
|
|
||||||
ResponseData PersonalNoticeData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PersonalNoticeData struct {
|
|
||||||
HasNotice bool `json:"has_notice"`
|
|
||||||
NoticeID int `json:"notice_id"`
|
|
||||||
Type int `json:"type"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Contents string `json:"contents"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func PersonalNoticeHandler(ctx *gin.Context) {
|
func PersonalNoticeHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
noticeResp := model.PersonalNoticeResp{
|
||||||
|
ResponseData: model.PersonalNoticeRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
noticeResp := PersonalNoticeResp{
|
|
||||||
ResponseData: PersonalNoticeData{
|
|
||||||
HasNotice: false,
|
HasNotice: false,
|
||||||
NoticeID: 0,
|
NoticeID: 0,
|
||||||
Type: 0,
|
Type: 0,
|
||||||
@@ -75,12 +27,13 @@ func PersonalNoticeHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-75
@@ -4,8 +4,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -36,41 +34,10 @@ type ScenarioReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ScenarioStartupHandler(ctx *gin.Context) {
|
func ScenarioStartupHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
startReq := ScenarioReq{}
|
startReq := ScenarioReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
startResp := ScenarioResp{
|
startResp := ScenarioResp{
|
||||||
ResponseData: ScenarioData{
|
ResponseData: ScenarioData{
|
||||||
ScenarioID: startReq.ScenarioID,
|
ScenarioID: startReq.ScenarioID,
|
||||||
@@ -82,57 +49,28 @@ func ScenarioStartupHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(startResp)
|
resp, err := json.Marshal(startResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
|
ctx.String(http.StatusOK, string(resp))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScenarioRewardHandler(ctx *gin.Context) {
|
func ScenarioRewardHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
resp := utils.ReadAllText("assets/reward.json")
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
nonce := ctx.GetInt("nonce")
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
nonce++
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
// fmt.Println(newAuthorizeStr)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||||
|
|
||||||
resp := utils.ReadAllText("assets/reward.json")
|
|
||||||
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
|
||||||
ctx.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-75
@@ -4,8 +4,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -36,41 +34,10 @@ type SubScenarioReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SubScenarioStartupHandler(ctx *gin.Context) {
|
func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
startReq := SubScenarioReq{}
|
startReq := SubScenarioReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
startResp := SubScenarioResp{
|
startResp := SubScenarioResp{
|
||||||
ResponseData: SubScenarioData{
|
ResponseData: SubScenarioData{
|
||||||
SubscenarioID: startReq.SubscenarioID,
|
SubscenarioID: startReq.SubscenarioID,
|
||||||
@@ -82,57 +49,26 @@ func SubScenarioStartupHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(startResp)
|
resp, err := json.Marshal(startResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SubScenarioRewardHandler(ctx *gin.Context) {
|
func SubScenarioRewardHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
resp := utils.ReadAllText("assets/subreward.json")
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
nonce := ctx.GetInt("nonce")
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
nonce++
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
// fmt.Println(newAuthorizeStr)
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||||
|
|
||||||
resp := utils.ReadAllText("assets/subreward.json")
|
|
||||||
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
|
||||||
ctx.Header("user_id", userId[0])
|
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
|
||||||
ctx.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-53
@@ -4,62 +4,17 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TosResp struct {
|
|
||||||
ResponseData TosData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TosData struct {
|
|
||||||
TosID int `json:"tos_id"`
|
|
||||||
TosType int `json:"tos_type"`
|
|
||||||
IsAgreed bool `json:"is_agreed"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func TosCheckHandler(ctx *gin.Context) {
|
func TosCheckHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
tosResp := model.TosResp{
|
||||||
|
ResponseData: model.TosRes{
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
tosResp := TosResp{
|
|
||||||
ResponseData: TosData{
|
|
||||||
TosID: 1,
|
TosID: 1,
|
||||||
TosType: 1,
|
TosType: 1,
|
||||||
IsAgreed: true,
|
IsAgreed: true,
|
||||||
@@ -70,11 +25,13 @@ func TosCheckHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(tosResp)
|
resp, err := json.Marshal(tosResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("user_id", userId[0])
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
nonce++
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-79
@@ -73,37 +73,8 @@ func SetDisplayRankHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetDeckHandler(ctx *gin.Context) {
|
func SetDeckHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||||
|
CheckErr(err)
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uId, _ := strconv.Atoi(userId[0])
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
deckReq := model.UnitDeckReq{}
|
deckReq := model.UnitDeckReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||||
@@ -114,14 +85,14 @@ func SetDeckHandler(ctx *gin.Context) {
|
|||||||
// UserEng.ShowSQL(true)
|
// UserEng.ShowSQL(true)
|
||||||
session := UserEng.NewSession()
|
session := UserEng.NewSession()
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
if err = session.Begin(); err != nil {
|
if err := session.Begin(); err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 原有队伍信息
|
// 原有队伍信息
|
||||||
var userDeckId []int
|
var userDeckId []int
|
||||||
err = session.Table("user_deck_m").Cols("id").Where("user_id = ?", uId).Find(&userDeckId)
|
err = session.Table("user_deck_m").Cols("id").Where("user_id = ?", userId).Find(&userDeckId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -148,7 +119,7 @@ func SetDeckHandler(ctx *gin.Context) {
|
|||||||
DeckID: deck.UnitDeckID,
|
DeckID: deck.UnitDeckID,
|
||||||
MainFlag: deck.MainFlag,
|
MainFlag: deck.MainFlag,
|
||||||
DeckName: deck.DeckName,
|
DeckName: deck.DeckName,
|
||||||
UserID: uId,
|
UserID: userId,
|
||||||
InsertDate: time.Now().Unix(),
|
InsertDate: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
_, err = session.Table("user_deck_m").Insert(&userDeck)
|
_, err = session.Table("user_deck_m").Insert(&userDeck)
|
||||||
@@ -233,55 +204,27 @@ func SetDeckHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(dispResp)
|
resp, err := json.Marshal(dispResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDeckNameHandler(ctx *gin.Context) {
|
func SetDeckNameHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||||
|
CheckErr(err)
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uId, _ := strconv.Atoi(userId[0])
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
deckReq := model.DeckNameReq{}
|
deckReq := model.DeckNameReq{}
|
||||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
exists, err := UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", uId, deckReq.UnitDeckID).Exist()
|
exists, err := UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", userId, deckReq.UnitDeckID).Exist()
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
if !exists {
|
if !exists {
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
@@ -291,7 +234,7 @@ func SetDeckNameHandler(ctx *gin.Context) {
|
|||||||
DeckName: deckReq.DeckName,
|
DeckName: deckReq.DeckName,
|
||||||
}
|
}
|
||||||
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &tools.UserDeckData{
|
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &tools.UserDeckData{
|
||||||
UserID: uId,
|
UserID: userId,
|
||||||
DeckID: deckReq.UnitDeckID,
|
DeckID: deckReq.UnitDeckID,
|
||||||
})
|
})
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
@@ -303,12 +246,13 @@ func SetDeckNameHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(dispResp)
|
resp, err := json.Marshal(dispResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-77
@@ -4,10 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -21,37 +18,6 @@ type NotificationResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetNotificationTokenHandler(ctx *gin.Context) {
|
func SetNotificationTokenHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
notifResp := NotificationResp{
|
notifResp := NotificationResp{
|
||||||
ResponseData: []interface{}{},
|
ResponseData: []interface{}{},
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
@@ -59,48 +25,18 @@ func SetNotificationTokenHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(notifResp)
|
resp, err := json.Marshal(notifResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangeNaviHandler(ctx *gin.Context) {
|
func ChangeNaviHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
notifResp := NotificationResp{
|
notifResp := NotificationResp{
|
||||||
ResponseData: []interface{}{},
|
ResponseData: []interface{}{},
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
@@ -108,12 +44,13 @@ func ChangeNaviHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(notifResp)
|
resp, err := json.Marshal(notifResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-98
@@ -4,105 +4,23 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserInfoResp struct {
|
|
||||||
ResponseData UserInfoData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LpRecoveryItem struct {
|
|
||||||
ItemID int `json:"item_id"`
|
|
||||||
Amount int `json:"amount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
UserID int `json:"user_id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Level int `json:"level"`
|
|
||||||
Exp int `json:"exp"`
|
|
||||||
PreviousExp int `json:"previous_exp"`
|
|
||||||
NextExp int `json:"next_exp"`
|
|
||||||
GameCoin int `json:"game_coin"`
|
|
||||||
SnsCoin int `json:"sns_coin"`
|
|
||||||
FreeSnsCoin int `json:"free_sns_coin"`
|
|
||||||
PaidSnsCoin int `json:"paid_sns_coin"`
|
|
||||||
SocialPoint int `json:"social_point"`
|
|
||||||
UnitMax int `json:"unit_max"`
|
|
||||||
WaitingUnitMax int `json:"waiting_unit_max"`
|
|
||||||
EnergyMax int `json:"energy_max"`
|
|
||||||
EnergyFullTime string `json:"energy_full_time"`
|
|
||||||
LicenseLiveEnergyRecoverlyTime int `json:"license_live_energy_recoverly_time"`
|
|
||||||
EnergyFullNeedTime int `json:"energy_full_need_time"`
|
|
||||||
OverMaxEnergy int `json:"over_max_energy"`
|
|
||||||
TrainingEnergy int `json:"training_energy"`
|
|
||||||
TrainingEnergyMax int `json:"training_energy_max"`
|
|
||||||
FriendMax int `json:"friend_max"`
|
|
||||||
InviteCode string `json:"invite_code"`
|
|
||||||
InsertDate string `json:"insert_date"`
|
|
||||||
UpdateDate string `json:"update_date"`
|
|
||||||
TutorialState int `json:"tutorial_state"`
|
|
||||||
DiamondCoin int `json:"diamond_coin"`
|
|
||||||
CrystalCoin int `json:"crystal_coin"`
|
|
||||||
LpRecoveryItem []LpRecoveryItem `json:"lp_recovery_item"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Birth struct {
|
|
||||||
BirthMonth int `json:"birth_month"`
|
|
||||||
BirthDay int `json:"birth_day"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserInfoData struct {
|
|
||||||
User User `json:"user"`
|
|
||||||
Birth Birth `json:"birth"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func UserInfoHandler(ctx *gin.Context) {
|
func UserInfoHandler(ctx *gin.Context) {
|
||||||
reqTime := time.Now().Unix()
|
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
userResp := model.UserInfoResp{
|
||||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
ResponseData: model.UserInfoRes{
|
||||||
if err != nil {
|
User: model.UserInfo{
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
UserID: userId,
|
||||||
return
|
|
||||||
}
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) == 0 {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nonce++
|
|
||||||
|
|
||||||
respTime := time.Now().Unix()
|
|
||||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
|
||||||
// fmt.Println(newAuthorizeStr)
|
|
||||||
|
|
||||||
userResp := UserInfoResp{
|
|
||||||
ResponseData: UserInfoData{
|
|
||||||
User: User{
|
|
||||||
UserID: 9999999,
|
|
||||||
Name: "\u68a6\u8def @\u65c5\u7acb\u3061\u306e\u65e5\u306b",
|
Name: "\u68a6\u8def @\u65c5\u7acb\u3061\u306e\u65e5\u306b",
|
||||||
Level: 1028,
|
Level: 1028,
|
||||||
Exp: 28824396,
|
Exp: 28824396,
|
||||||
@@ -129,9 +47,9 @@ func UserInfoHandler(ctx *gin.Context) {
|
|||||||
TutorialState: -1,
|
TutorialState: -1,
|
||||||
DiamondCoin: 0,
|
DiamondCoin: 0,
|
||||||
CrystalCoin: 0,
|
CrystalCoin: 0,
|
||||||
LpRecoveryItem: []LpRecoveryItem{},
|
LpRecoveryItem: []model.LpRecoveryItem{},
|
||||||
},
|
},
|
||||||
Birth: Birth{
|
Birth: model.Birth{
|
||||||
BirthMonth: 10,
|
BirthMonth: 10,
|
||||||
BirthDay: 18,
|
BirthDay: 18,
|
||||||
},
|
},
|
||||||
@@ -142,12 +60,13 @@ func UserInfoHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp, err := json.Marshal(userResp)
|
resp, err := json.Marshal(userResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
|
||||||
|
|
||||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
nonce := ctx.GetInt("nonce")
|
||||||
ctx.Header("user_id", userId[0])
|
nonce++
|
||||||
ctx.Header("authorize", newAuthorizeStr)
|
|
||||||
ctx.Header("X-Message-Sign", xms64)
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ func main() {
|
|||||||
// Private APIs
|
// Private APIs
|
||||||
|
|
||||||
// Server APIs
|
// Server APIs
|
||||||
m := r.Group("main.php").Use(middleware.CommonMid)
|
m := r.Group("main.php").Use(middleware.Common)
|
||||||
{
|
{
|
||||||
m.POST("/login/authkey", handler.AuthKeyHandler)
|
m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey)
|
||||||
m.POST("/login/login", handler.LoginHandler)
|
m.POST("/login/login", middleware.Login, handler.Login)
|
||||||
m.POST("/user/userInfo", handler.UserInfoHandler)
|
m.POST("/user/userInfo", handler.UserInfoHandler)
|
||||||
m.POST("/gdpr/get", handler.GdprHandler)
|
m.POST("/gdpr/get", handler.GdprHandler)
|
||||||
m.POST("/personalnotice/get", handler.PersonalNoticeHandler)
|
m.POST("/personalnotice/get", handler.PersonalNoticeHandler)
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"honoka-chan/database"
|
||||||
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/utils"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AuthKey(ctx *gin.Context) {
|
||||||
|
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||||
|
tDummyToken, err := base64.StdEncoding.DecodeString(req.Get("dummy_token").String())
|
||||||
|
CheckErr(err)
|
||||||
|
dummyToken := encrypt.RSA_Decrypt(tDummyToken, "privatekey.pem")
|
||||||
|
|
||||||
|
// aesKey := dummyToken[0:16]
|
||||||
|
// tAuthData, err := base64.StdEncoding.DecodeString(req.Get("auth_data").String())
|
||||||
|
// CheckErr(err)
|
||||||
|
// authData := utils.Sub16(encrypt.AES_CBC_Decrypt(tAuthData, aesKey))
|
||||||
|
// fmt.Println(string(authData))
|
||||||
|
|
||||||
|
clientToken := base64.StdEncoding.EncodeToString(dummyToken)
|
||||||
|
serverToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||||
|
authorizeToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||||
|
|
||||||
|
ctx.Set("dummy_token", serverToken)
|
||||||
|
ctx.Set("authorize_token", authorizeToken)
|
||||||
|
|
||||||
|
authJson, err := json.Marshal(map[string]interface{}{
|
||||||
|
"client_token": clientToken,
|
||||||
|
"server_token": serverToken,
|
||||||
|
})
|
||||||
|
CheckErr(err)
|
||||||
|
err = database.LevelDb.Put([]byte(authorizeToken), authJson)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
nonce := ctx.GetInt("nonce")
|
||||||
|
nonce++
|
||||||
|
ctx.Set("nonce", nonce)
|
||||||
|
|
||||||
|
authorize := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&nonce=%d&requestTimeStamp=%d", time.Now().Unix(), nonce, ctx.GetInt64("req_time"))
|
||||||
|
|
||||||
|
ctx.Header("user_id", "")
|
||||||
|
ctx.Header("authorize", authorize)
|
||||||
|
|
||||||
|
ctx.Next()
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"honoka-chan/database"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrorMsg = `{"code":20001,"message":""}`
|
||||||
|
)
|
||||||
|
|
||||||
|
func CheckErr(err error) {
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Common(ctx *gin.Context) {
|
||||||
|
ctx.Set("req_time", time.Now().Unix())
|
||||||
|
|
||||||
|
authorize := ctx.Request.Header.Get("Authorize")
|
||||||
|
if authorize == "" {
|
||||||
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
ctx.Set("authorize", authorize)
|
||||||
|
|
||||||
|
params, err := url.ParseQuery(authorize)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
nonce, err := strconv.Atoi(params.Get("nonce"))
|
||||||
|
CheckErr(err)
|
||||||
|
nonce++
|
||||||
|
ctx.Set("nonce", nonce)
|
||||||
|
|
||||||
|
token := params.Get("token")
|
||||||
|
ctx.Set("token", token)
|
||||||
|
|
||||||
|
if ctx.Request.URL.String() == "/main.php/login/authkey" ||
|
||||||
|
ctx.Request.URL.String() == "/main.php/login/login" {
|
||||||
|
// 特殊请求
|
||||||
|
fmt.Println("========")
|
||||||
|
} else {
|
||||||
|
userId := ctx.Request.Header.Get("User-ID")
|
||||||
|
if userId == "" {
|
||||||
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
ctx.Set("userid", userId)
|
||||||
|
|
||||||
|
rToken, err := database.LevelDb.Get([]byte(userId))
|
||||||
|
CheckErr(err)
|
||||||
|
if token != string(rToken) {
|
||||||
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
if !database.MatchTokenUid(token, userId) {
|
||||||
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Header("Content-Type", "application/json; charset=utf-8")
|
||||||
|
ctx.Header("X-Powered-By", "KLab Native APP Platform")
|
||||||
|
ctx.Header("server_version", "20120129")
|
||||||
|
ctx.Header("Server-Version", "97.4.6")
|
||||||
|
ctx.Header("version_up", "0")
|
||||||
|
ctx.Header("status_code", "200")
|
||||||
|
|
||||||
|
ctx.Next()
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"honoka-chan/database"
|
||||||
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/utils"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Login(ctx *gin.Context) {
|
||||||
|
authData, err := database.LevelDb.Get([]byte(ctx.GetString("token")))
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
clientToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "client_token").String())
|
||||||
|
CheckErr(err)
|
||||||
|
serverToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "server_token").String())
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
xmcKey := utils.SliceXor(clientToken, serverToken)
|
||||||
|
aesKey := xmcKey[0:16]
|
||||||
|
|
||||||
|
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||||
|
tKey, err := base64.StdEncoding.DecodeString(req.Get("login_key").String())
|
||||||
|
CheckErr(err)
|
||||||
|
loginKey := utils.Sub16(encrypt.AES_CBC_Decrypt(tKey, aesKey))
|
||||||
|
ctx.Set("login_key", string(loginKey))
|
||||||
|
|
||||||
|
tPasswd, err := base64.StdEncoding.DecodeString(req.Get("login_passwd").String())
|
||||||
|
CheckErr(err)
|
||||||
|
loginPasswd := utils.Sub16(encrypt.AES_CBC_Decrypt(tPasswd, aesKey))
|
||||||
|
ctx.Set("login_passwd", string(loginPasswd))
|
||||||
|
|
||||||
|
nonce := ctx.GetInt("nonce")
|
||||||
|
nonce++
|
||||||
|
ctx.Set("nonce", nonce)
|
||||||
|
|
||||||
|
authorizeToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||||
|
ctx.Set("authorize_token", authorizeToken)
|
||||||
|
|
||||||
|
ctx.Next()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"honoka-chan/config"
|
|
||||||
"honoka-chan/database"
|
|
||||||
"honoka-chan/handler"
|
|
||||||
"honoka-chan/utils"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CommonMid(ctx *gin.Context) {
|
|
||||||
authorizeStr := ctx.Request.Header["Authorize"]
|
|
||||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
|
||||||
if len(userId) > 0 {
|
|
||||||
authStr, _ := utils.GetAuthorizeToken(authorizeStr)
|
|
||||||
res, _ := database.LevelDb.Get([]byte(userId[0]))
|
|
||||||
if authStr != string(res) {
|
|
||||||
ctx.String(http.StatusForbidden, handler.ErrorMsg)
|
|
||||||
ctx.Abort()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.Header("Content-Type", "application/json; charset=utf-8")
|
|
||||||
ctx.Header("X-Powered-By", config.Conf.Server.PoweredBy)
|
|
||||||
ctx.Header("server_version", config.Conf.Server.VersionDate)
|
|
||||||
ctx.Header("version_up", config.Conf.Server.VersionUp)
|
|
||||||
ctx.Header("status_code", "200")
|
|
||||||
|
|
||||||
ctx.Next()
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// AnnounceResp ...
|
||||||
|
type AnnounceResp struct {
|
||||||
|
ResponseData AnnounceRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnnounceRes ...
|
||||||
|
type AnnounceRes struct {
|
||||||
|
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type SifApi struct {
|
||||||
|
Module string `json:"module"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
Timestamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
type SifApi struct {
|
|
||||||
Module string `json:"module"`
|
|
||||||
Action string `json:"action"`
|
|
||||||
Timestamp int64 `json:"timeStamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthKeyReq struct {
|
|
||||||
DummyToken string `json:"dummy_token"`
|
|
||||||
AuthData string `json:"auth_data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthKeyResp struct {
|
|
||||||
ResponseData struct {
|
|
||||||
AuthorizeToken string `json:"authorize_token"`
|
|
||||||
DummyToken string `json:"dummy_token"`
|
|
||||||
} `json:"response_data"`
|
|
||||||
ReleaseInfo [0]interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LoginReq struct {
|
|
||||||
LoginKey string `json:"login_key"`
|
|
||||||
LoginPasswd string `json:"login_passwd"`
|
|
||||||
DevToken string `json:"devtoken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LoginResp struct {
|
|
||||||
ResponseData struct {
|
|
||||||
AuthorizeToken string `json:"authorize_token"`
|
|
||||||
UserId int `json:"user_id"`
|
|
||||||
ReviewVersion string `json:"review_version"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
IdfaEnabled bool `json:"idfa_enabled"`
|
|
||||||
SkipLoginNews bool `json:"skip_login_news"`
|
|
||||||
AdultFlag int `json:"adult_flag"`
|
|
||||||
} `json:"response_data"`
|
|
||||||
ReleaseInfo [0]interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// AuthKeyRes ...
|
||||||
|
type AuthKeyRes struct {
|
||||||
|
AuthorizeToken string `json:"authorize_token"`
|
||||||
|
DummyToken string `json:"dummy_token"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthKeyResp ...
|
||||||
|
type AuthKeyResp struct {
|
||||||
|
ResponseData AuthKeyRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// EventsResp ...
|
||||||
|
type EventsResp struct {
|
||||||
|
ResponseData EventsRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventsRes ...
|
||||||
|
type EventsRes struct {
|
||||||
|
TargetList []TargetList `json:"target_list"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TargetList ...
|
||||||
|
type TargetList struct {
|
||||||
|
Position int `json:"position"`
|
||||||
|
IsDisplayable bool `json:"is_displayable"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// GdprResp ...
|
||||||
|
type GdprResp struct {
|
||||||
|
ResponseData GdprRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GdprRes ...
|
||||||
|
type GdprRes struct {
|
||||||
|
EnableGdpr bool `json:"enable_gdpr"`
|
||||||
|
IsEea bool `json:"is_eea"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
+14
-67
@@ -1,72 +1,19 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type TopInfoLicenseInfo struct {
|
// LoginRes ...
|
||||||
LicenseList []interface{} `json:"license_list"`
|
type LoginRes struct {
|
||||||
LicensedInfo []interface{} `json:"licensed_info"`
|
AuthorizeToken string `json:"authorize_token"`
|
||||||
ExpiredInfo []interface{} `json:"expired_info"`
|
UserId int `json:"user_id"`
|
||||||
BadgeFlag bool `json:"badge_flag"`
|
ReviewVersion string `json:"review_version"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
IdfaEnabled bool `json:"idfa_enabled"`
|
||||||
|
SkipLoginNews bool `json:"skip_login_news"`
|
||||||
|
AdultFlag int `json:"adult_flag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopInfoResult struct {
|
// LoginResp ...
|
||||||
FriendActionCnt int `json:"friend_action_cnt"`
|
type LoginResp struct {
|
||||||
FriendGreetCnt int `json:"friend_greet_cnt"`
|
ResponseData LoginRes `json:"response_data"`
|
||||||
FriendVarietyCnt int `json:"friend_variety_cnt"`
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
FriendNewCnt int `json:"friend_new_cnt"`
|
StatusCode int `json:"status_code"`
|
||||||
PresentCnt int `json:"present_cnt"`
|
|
||||||
SecretBoxBadgeFlag bool `json:"secret_box_badge_flag"`
|
|
||||||
ServerDatetime string `json:"server_datetime"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
NoticeFriendDatetime string `json:"notice_friend_datetime"`
|
|
||||||
NoticeMailDatetime string `json:"notice_mail_datetime"`
|
|
||||||
FriendsApprovalWaitCnt int `json:"friends_approval_wait_cnt"`
|
|
||||||
FriendsRequestCnt int `json:"friends_request_cnt"`
|
|
||||||
IsTodayBirthday bool `json:"is_today_birthday"`
|
|
||||||
LicenseInfo TopInfoLicenseInfo `json:"license_info"`
|
|
||||||
UsingBuffInfo []interface{} `json:"using_buff_info"`
|
|
||||||
IsKlabIDTaskFlag bool `json:"is_klab_id_task_flag"`
|
|
||||||
KlabIDTaskCanSync bool `json:"klab_id_task_can_sync"`
|
|
||||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
|
||||||
ExchangeBadgeCnt []int `json:"exchange_badge_cnt"`
|
|
||||||
AdFlag bool `json:"ad_flag"`
|
|
||||||
HasAdReward bool `json:"has_ad_reward"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TopInfoResp struct {
|
|
||||||
Result TopInfoResult `json:"result"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
CommandNum bool `json:"commandNum"`
|
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TopInfoOnceNotification struct {
|
|
||||||
Push bool `json:"push"`
|
|
||||||
Lp bool `json:"lp"`
|
|
||||||
UpdateInfo bool `json:"update_info"`
|
|
||||||
Campaign bool `json:"campaign"`
|
|
||||||
Live bool `json:"live"`
|
|
||||||
Lbonus bool `json:"lbonus"`
|
|
||||||
Event bool `json:"event"`
|
|
||||||
Secretbox bool `json:"secretbox"`
|
|
||||||
Birthday bool `json:"birthday"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TopInfoOnceResult struct {
|
|
||||||
NewAchievementCnt int `json:"new_achievement_cnt"`
|
|
||||||
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
|
|
||||||
LiveDailyRewardExist bool `json:"live_daily_reward_exist"`
|
|
||||||
TrainingEnergy int `json:"training_energy"`
|
|
||||||
TrainingEnergyMax int `json:"training_energy_max"`
|
|
||||||
Notification TopInfoOnceNotification `json:"notification"`
|
|
||||||
OpenArena bool `json:"open_arena"`
|
|
||||||
CostumeStatus bool `json:"costume_status"`
|
|
||||||
OpenAccessory bool `json:"open_accessory"`
|
|
||||||
ArenaSiSkillUniqueCheck bool `json:"arena_si_skill_unique_check"`
|
|
||||||
OpenV98 bool `json:"open_v98"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TopInfoOnceResp struct {
|
|
||||||
Result TopInfoOnceResult `json:"result"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
CommandNum bool `json:"commandNum"`
|
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// NoticeFriendVarietyResp ...
|
||||||
|
type NoticeFriendVarietyResp struct {
|
||||||
|
ResponseData NoticeFriendVarietyRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoticeFriendVarietyRes ...
|
||||||
|
type NoticeFriendVarietyRes struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
NoticeList []interface{} `json:"notice_list"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoticeFriendGreetingResp ...
|
||||||
|
type NoticeFriendGreetingResp struct {
|
||||||
|
ResponseData NoticeFriendGreetingRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoticeFriendGreetingRes ...
|
||||||
|
type NoticeFriendGreetingRes struct {
|
||||||
|
NextId int `json:"next_id"`
|
||||||
|
NoticeList []interface{} `json:"notice_list"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoticeUserGreetingResp ...
|
||||||
|
type NoticeUserGreetingResp struct {
|
||||||
|
ResponseData NoticeUserGreetingRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoticeUserGreetingRes ...
|
||||||
|
type NoticeUserGreetingRes struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
HasNext bool `json:"has_next"`
|
||||||
|
NoticeList []interface{} `json:"notice_list"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// PersonalNoticeResp ...
|
||||||
|
type PersonalNoticeResp struct {
|
||||||
|
ResponseData PersonalNoticeRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PersonalNoticeRes ...
|
||||||
|
type PersonalNoticeRes struct {
|
||||||
|
HasNotice bool `json:"has_notice"`
|
||||||
|
NoticeID int `json:"notice_id"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Contents string `json:"contents"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type TopInfoLicenseInfo struct {
|
||||||
|
LicenseList []interface{} `json:"license_list"`
|
||||||
|
LicensedInfo []interface{} `json:"licensed_info"`
|
||||||
|
ExpiredInfo []interface{} `json:"expired_info"`
|
||||||
|
BadgeFlag bool `json:"badge_flag"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TopInfoResult struct {
|
||||||
|
FriendActionCnt int `json:"friend_action_cnt"`
|
||||||
|
FriendGreetCnt int `json:"friend_greet_cnt"`
|
||||||
|
FriendVarietyCnt int `json:"friend_variety_cnt"`
|
||||||
|
FriendNewCnt int `json:"friend_new_cnt"`
|
||||||
|
PresentCnt int `json:"present_cnt"`
|
||||||
|
SecretBoxBadgeFlag bool `json:"secret_box_badge_flag"`
|
||||||
|
ServerDatetime string `json:"server_datetime"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
NoticeFriendDatetime string `json:"notice_friend_datetime"`
|
||||||
|
NoticeMailDatetime string `json:"notice_mail_datetime"`
|
||||||
|
FriendsApprovalWaitCnt int `json:"friends_approval_wait_cnt"`
|
||||||
|
FriendsRequestCnt int `json:"friends_request_cnt"`
|
||||||
|
IsTodayBirthday bool `json:"is_today_birthday"`
|
||||||
|
LicenseInfo TopInfoLicenseInfo `json:"license_info"`
|
||||||
|
UsingBuffInfo []interface{} `json:"using_buff_info"`
|
||||||
|
IsKlabIDTaskFlag bool `json:"is_klab_id_task_flag"`
|
||||||
|
KlabIDTaskCanSync bool `json:"klab_id_task_can_sync"`
|
||||||
|
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||||
|
ExchangeBadgeCnt []int `json:"exchange_badge_cnt"`
|
||||||
|
AdFlag bool `json:"ad_flag"`
|
||||||
|
HasAdReward bool `json:"has_ad_reward"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TopInfoResp struct {
|
||||||
|
Result TopInfoResult `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TopInfoOnceNotification struct {
|
||||||
|
Push bool `json:"push"`
|
||||||
|
Lp bool `json:"lp"`
|
||||||
|
UpdateInfo bool `json:"update_info"`
|
||||||
|
Campaign bool `json:"campaign"`
|
||||||
|
Live bool `json:"live"`
|
||||||
|
Lbonus bool `json:"lbonus"`
|
||||||
|
Event bool `json:"event"`
|
||||||
|
Secretbox bool `json:"secretbox"`
|
||||||
|
Birthday bool `json:"birthday"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TopInfoOnceResult struct {
|
||||||
|
NewAchievementCnt int `json:"new_achievement_cnt"`
|
||||||
|
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
|
||||||
|
LiveDailyRewardExist bool `json:"live_daily_reward_exist"`
|
||||||
|
TrainingEnergy int `json:"training_energy"`
|
||||||
|
TrainingEnergyMax int `json:"training_energy_max"`
|
||||||
|
Notification TopInfoOnceNotification `json:"notification"`
|
||||||
|
OpenArena bool `json:"open_arena"`
|
||||||
|
CostumeStatus bool `json:"costume_status"`
|
||||||
|
OpenAccessory bool `json:"open_accessory"`
|
||||||
|
ArenaSiSkillUniqueCheck bool `json:"arena_si_skill_unique_check"`
|
||||||
|
OpenV98 bool `json:"open_v98"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TopInfoOnceResp struct {
|
||||||
|
Result TopInfoOnceResult `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// TosResp ...
|
||||||
|
type TosResp struct {
|
||||||
|
ResponseData TosRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TosResp ...
|
||||||
|
type TosRes struct {
|
||||||
|
TosID int `json:"tos_id"`
|
||||||
|
TosType int `json:"tos_type"`
|
||||||
|
IsAgreed bool `json:"is_agreed"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// UserInfoResp ...
|
||||||
|
type UserInfoResp struct {
|
||||||
|
ResponseData UserInfoRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserInfoRes ...
|
||||||
|
type UserInfoRes struct {
|
||||||
|
User UserInfo `json:"user"`
|
||||||
|
Birth Birth `json:"birth"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LpRecoveryItem ...
|
||||||
|
type LpRecoveryItem struct {
|
||||||
|
ItemID int `json:"item_id"`
|
||||||
|
Amount int `json:"amount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserInfo ...
|
||||||
|
type UserInfo struct {
|
||||||
|
UserID int `json:"user_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
Exp int `json:"exp"`
|
||||||
|
PreviousExp int `json:"previous_exp"`
|
||||||
|
NextExp int `json:"next_exp"`
|
||||||
|
GameCoin int `json:"game_coin"`
|
||||||
|
SnsCoin int `json:"sns_coin"`
|
||||||
|
FreeSnsCoin int `json:"free_sns_coin"`
|
||||||
|
PaidSnsCoin int `json:"paid_sns_coin"`
|
||||||
|
SocialPoint int `json:"social_point"`
|
||||||
|
UnitMax int `json:"unit_max"`
|
||||||
|
WaitingUnitMax int `json:"waiting_unit_max"`
|
||||||
|
EnergyMax int `json:"energy_max"`
|
||||||
|
EnergyFullTime string `json:"energy_full_time"`
|
||||||
|
LicenseLiveEnergyRecoverlyTime int `json:"license_live_energy_recoverly_time"`
|
||||||
|
EnergyFullNeedTime int `json:"energy_full_need_time"`
|
||||||
|
OverMaxEnergy int `json:"over_max_energy"`
|
||||||
|
TrainingEnergy int `json:"training_energy"`
|
||||||
|
TrainingEnergyMax int `json:"training_energy_max"`
|
||||||
|
FriendMax int `json:"friend_max"`
|
||||||
|
InviteCode string `json:"invite_code"`
|
||||||
|
InsertDate string `json:"insert_date"`
|
||||||
|
UpdateDate string `json:"update_date"`
|
||||||
|
TutorialState int `json:"tutorial_state"`
|
||||||
|
DiamondCoin int `json:"diamond_coin"`
|
||||||
|
CrystalCoin int `json:"crystal_coin"`
|
||||||
|
LpRecoveryItem []LpRecoveryItem `json:"lp_recovery_item"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Birth ...
|
||||||
|
type Birth struct {
|
||||||
|
BirthMonth int `json:"birth_month"`
|
||||||
|
BirthDay int `json:"birth_day"`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user