@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user