@@ -1,13 +1,23 @@
|
||||
package item
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/pkg/utils"
|
||||
itemapischema "honoka-chan/internal/schema/api/item"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func itemList() (res any, err error) {
|
||||
itemResp := utils.ReadAllText("assets/serverdata/item.json")
|
||||
err = json.Unmarshal([]byte(itemResp), &res)
|
||||
itemData, err := honokautils.LoadServerData[itemapischema.ListData]("item_data.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = itemapischema.ListResp{
|
||||
Result: itemData,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func loginTopInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
now := time.Now()
|
||||
|
||||
friendsRequestCnt64, err := ss.UserEng.Table(new(usermodel.UserFriend)).
|
||||
friendsRequestCnt, err := ss.UserEng.Table(new(usermodel.UserFriend)).
|
||||
Where("user_id = ?", ss.UserID).
|
||||
Where("status = ?", usermodel.FriendStatusAwaitingApproval).
|
||||
Where("is_new = ?", true).
|
||||
@@ -22,7 +22,7 @@ func loginTopInfo(ctx *gin.Context) (res any, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
friendsApprovalWaitCnt64, err := ss.UserEng.Table(new(usermodel.UserFriend)).
|
||||
friendsApprovalWaitCnt, err := ss.UserEng.Table(new(usermodel.UserFriend)).
|
||||
Where("user_id = ?", ss.UserID).
|
||||
Where("status = ?", usermodel.FriendStatusPending).
|
||||
Count()
|
||||
@@ -30,7 +30,7 @@ func loginTopInfo(ctx *gin.Context) (res any, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
friendGreetCnt64, err := ss.UserEng.Table(new(usermodel.UserGreet)).
|
||||
friendGreetCnt, err := ss.UserEng.Table(new(usermodel.UserGreet)).
|
||||
Where("receiver_id = ?", ss.UserID).
|
||||
Where("deleted_from_receiver = ?", false).
|
||||
Where("readed = ?", false).
|
||||
@@ -39,10 +39,6 @@ func loginTopInfo(ctx *gin.Context) (res any, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
friendsRequestCnt := int(friendsRequestCnt64)
|
||||
friendsApprovalWaitCnt := int(friendsApprovalWaitCnt64)
|
||||
friendGreetCnt := int(friendGreetCnt64)
|
||||
|
||||
res = loginapischema.TopInfoResp{
|
||||
Result: loginapischema.TopInfoData{
|
||||
FriendActionCnt: friendGreetCnt,
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
profileapischema "honoka-chan/internal/schema/api/profile"
|
||||
"honoka-chan/pkg/utils"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func cardRanking() (res any, err error) {
|
||||
var result []any
|
||||
love := utils.ReadAllText("assets/serverdata/love.json")
|
||||
err = json.Unmarshal([]byte(love), &result)
|
||||
cardRankingData, err := honokautils.LoadServerData[[]profileapischema.CardRankingData]("card_ranking_data.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = profileapischema.CardRankingResp{
|
||||
Result: result,
|
||||
Result: cardRankingData,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
|
||||
@@ -72,7 +72,7 @@ func profileInfo(ctx *gin.Context, targetUserID int) (res any, err error) {
|
||||
UnitMax: 5000,
|
||||
EnergyMax: targetPref.EffectiveEnergyMax(),
|
||||
FriendMax: 99,
|
||||
UnitCnt: int(unitCount),
|
||||
UnitCnt: unitCount,
|
||||
InviteCode: targetPref.InviteCode,
|
||||
ElapsedTimeFromLogin: formatProfileElapsedTime(lastLoginTime),
|
||||
Introduction: targetPref.UserDesc,
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
package stamp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/pkg/utils"
|
||||
stampapischema "honoka-chan/internal/schema/api/stamp"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func stampInfo() (res any, err error) {
|
||||
stampResp := utils.ReadAllText("assets/serverdata/stamp.json")
|
||||
err = json.Unmarshal([]byte(stampResp), &res)
|
||||
stampData, err := honokautils.LoadServerData[stampapischema.InfoData]("stamp_data.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = stampapischema.InfoResp{
|
||||
Result: stampData,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||
"honoka-chan/pkg/utils"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func unitAccessoryTab() (res any, err error) {
|
||||
data := utils.ReadAllText("assets/serverdata/accessoryTab.json")
|
||||
resp := unitapischema.AccessoryTabResp{}
|
||||
err = json.Unmarshal([]byte(data), &resp)
|
||||
tabList, err := honokautils.LoadServerData[[]unitapischema.TabList]("accessory_tab_list.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.TimeStamp = time.Now().Unix()
|
||||
|
||||
return resp, err
|
||||
res = unitapischema.AccessoryTabResp{
|
||||
Result: unitapischema.AccessoryTabData{
|
||||
TabList: tabList,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package eventscenario
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/middleware"
|
||||
"honoka-chan/internal/router"
|
||||
eventscenarioschema "honoka-chan/internal/schema/eventscenario"
|
||||
"honoka-chan/internal/session"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func startup(ctx *gin.Context) {
|
||||
ss := session.Get(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
startReq := eventscenarioschema.StartUpReq{}
|
||||
err := honokautils.ParseRequestData(ctx, &startReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(eventscenarioschema.StartUpResp{
|
||||
ResponseData: eventscenarioschema.StartUpData{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
router.AddHandler("main.php", "POST", "/eventscenario/startup", middleware.Common, startup)
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func list(ctx *gin.Context) {
|
||||
|
||||
ss.Respond(friendschema.ListResp{
|
||||
ResponseData: friendschema.ListData{
|
||||
ItemCount: int(totalCount),
|
||||
ItemCount: totalCount,
|
||||
FriendList: friendList,
|
||||
NewFriendList: []any{},
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
|
||||
@@ -96,7 +96,7 @@ func search(ctx *gin.Context) {
|
||||
UnitMax: 5000,
|
||||
EnergyMax: positiveIntOrDefault(row.EnergyMax, usermodel.DefaultUserEnergyMax),
|
||||
FriendMax: 99,
|
||||
UnitCnt: int(unitCount),
|
||||
UnitCnt: unitCount,
|
||||
ElapsedTimeFromLogin: formatElapsedTime(row.LastLoginTime),
|
||||
Comment: row.UserDesc,
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
_ "honoka-chan/internal/handler/background"
|
||||
_ "honoka-chan/internal/handler/download"
|
||||
_ "honoka-chan/internal/handler/event"
|
||||
_ "honoka-chan/internal/handler/eventscenario"
|
||||
_ "honoka-chan/internal/handler/friend"
|
||||
_ "honoka-chan/internal/handler/gdpr"
|
||||
_ "honoka-chan/internal/handler/ghome"
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/constant"
|
||||
"honoka-chan/internal/middleware"
|
||||
usermodel "honoka-chan/internal/model/user"
|
||||
"honoka-chan/internal/router"
|
||||
commonschema "honoka-chan/internal/schema/common"
|
||||
liveschema "honoka-chan/internal/schema/live"
|
||||
liverecordschema "honoka-chan/internal/schema/liverecord"
|
||||
"honoka-chan/internal/session"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"honoka-chan/pkg/utils"
|
||||
@@ -173,7 +173,7 @@ func preciseScore(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
// DeckInfo
|
||||
var deckInfo usermodel.DeckInfo
|
||||
var deckInfo liverecordschema.DeckInfo
|
||||
err = json.Unmarshal([]byte(record.DeckInfoJSON), &deckInfo)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
|
||||
@@ -25,11 +25,10 @@ func reward(ctx *gin.Context) {
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
// fmt.Println(ctx.MustGet("request_data").(string))
|
||||
|
||||
difficultyID := playRewardReq.LiveDifficultyID
|
||||
_, liveInfo := ss.GetLiveInfo(difficultyID)
|
||||
_, progress := ss.GetLiveInProgress() // TODO: 添加返回指定状态码的方法
|
||||
_, progress := ss.GetLiveInProgress()
|
||||
_, deckInfo := ss.GetDeckInfo(progress.DeckID)
|
||||
deckInfo.LiveDifficultyID = difficultyID
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func userGreetingHistory(ctx *gin.Context) {
|
||||
|
||||
ss.Respond(noticeschema.UserGreetingResp{
|
||||
ResponseData: noticeschema.UserGreetingData{
|
||||
ItemCount: int(totalCount),
|
||||
ItemCount: totalCount,
|
||||
HasNext: totalCount > int64(len(rows)),
|
||||
NoticeList: noticeList,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package scenario
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/middleware"
|
||||
"honoka-chan/internal/router"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/pkg/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func reward(ctx *gin.Context) {
|
||||
ss := session.Get(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
data := utils.ReadAllText("assets/serverdata/reward.json")
|
||||
var resp map[string]any
|
||||
err := json.Unmarshal([]byte(data), &resp)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
func init() {
|
||||
router.AddHandler("main.php", "POST", "/scenario/reward", middleware.Common, reward)
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package subscenario
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/middleware"
|
||||
"honoka-chan/internal/router"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/pkg/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func reward(ctx *gin.Context) {
|
||||
ss := session.Get(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
data := utils.ReadAllText("assets/serverdata/subreward.json")
|
||||
var resp map[string]any
|
||||
err := json.Unmarshal([]byte(data), &resp)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
func init() {
|
||||
router.AddHandler("main.php", "POST", "/subscenario/reward", middleware.Common, reward)
|
||||
}
|
||||
Reference in New Issue
Block a user