@@ -0,0 +1,60 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MuseumContent struct {
|
||||
MuseumContentsId int `xorm:"museum_contents_id"`
|
||||
SmileBuff int `xorm:"smile_buff"`
|
||||
PureBuff int `xorm:"pure_buff"`
|
||||
CoolBuff int `xorm:"cool_buff"`
|
||||
}
|
||||
|
||||
func MuseumInfo(ctx *gin.Context) {
|
||||
var contents []MuseumContent
|
||||
err := MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").Find(&contents)
|
||||
CheckErr(err)
|
||||
var smileBuff, pureBuff, coolBuff int
|
||||
var contentsList []int
|
||||
for _, content := range contents {
|
||||
smileBuff += content.SmileBuff
|
||||
pureBuff += content.PureBuff
|
||||
coolBuff += content.CoolBuff
|
||||
contentsList = append(contentsList, content.MuseumContentsId)
|
||||
}
|
||||
museumResp := model.MuseumResp{
|
||||
ResponseData: model.MuseumRes{
|
||||
MuseumInfo: model.Museum{
|
||||
Parameter: model.MuseumParameter{
|
||||
Smile: smileBuff,
|
||||
Pure: pureBuff,
|
||||
Cool: coolBuff,
|
||||
},
|
||||
ContentsIDList: contentsList,
|
||||
},
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
},
|
||||
ReleaseInfo: []interface{}{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(museumResp)
|
||||
CheckErr(err)
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
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(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
@@ -69,6 +69,7 @@ func main() {
|
||||
m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey)
|
||||
m.POST("/login/login", middleware.Login, handler.Login)
|
||||
m.POST("/multiunit/scenarioStartup", handler.MultiUnitStartUpHandler)
|
||||
m.POST("/museum/info", handler.MuseumInfo)
|
||||
m.POST("/notice/noticeFriendGreeting", handler.NoticeFriendGreetingHandler)
|
||||
m.POST("/notice/noticeFriendVariety", handler.NoticeFriendVarietyHandler)
|
||||
m.POST("/notice/noticeUserGreetingHistory", handler.NoticeUserGreetingHandler)
|
||||
|
||||
@@ -5,3 +5,25 @@ type SifApi struct {
|
||||
Action string `json:"action"`
|
||||
Timestamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
type MuseumInfoParameter struct {
|
||||
Smile int `json:"smile"`
|
||||
Pure int `json:"pure"`
|
||||
Cool int `json:"cool"`
|
||||
}
|
||||
|
||||
type MuseumInfo struct {
|
||||
Parameter MuseumInfoParameter `json:"parameter"`
|
||||
ContentsIDList []int `json:"contents_id_list"`
|
||||
}
|
||||
|
||||
type MuseumInfoResult struct {
|
||||
MuseumInfo MuseumInfo `json:"museum_info"`
|
||||
}
|
||||
|
||||
type MuseumInfoResp struct {
|
||||
Result MuseumInfoResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,23 +1,23 @@
|
||||
package model
|
||||
|
||||
type MuseumInfoParameter struct {
|
||||
type MuseumResp struct {
|
||||
ResponseData MuseumRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type MuseumParameter struct {
|
||||
Smile int `json:"smile"`
|
||||
Pure int `json:"pure"`
|
||||
Cool int `json:"cool"`
|
||||
}
|
||||
|
||||
type MuseumInfo struct {
|
||||
Parameter MuseumInfoParameter `json:"parameter"`
|
||||
type Museum struct {
|
||||
Parameter MuseumParameter `json:"parameter"`
|
||||
ContentsIDList []int `json:"contents_id_list"`
|
||||
}
|
||||
|
||||
type MuseumInfoResult struct {
|
||||
MuseumInfo MuseumInfo `json:"museum_info"`
|
||||
}
|
||||
|
||||
type MuseumInfoResp struct {
|
||||
Result MuseumInfoResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
type MuseumRes struct {
|
||||
MuseumInfo Museum `json:"museum_info"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user