@@ -0,0 +1,17 @@
|
||||
package album
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AlbumApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "albumAll":
|
||||
res, err = albumAll(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: album: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package album
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/album"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func albumAll(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
albumLists := []album.UnitList{}
|
||||
var unitList []struct {
|
||||
UnitId int `xorm:"unit_id"`
|
||||
Rarity int `xorm:"rarity"`
|
||||
}
|
||||
err = ss.MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, unit := range unitList {
|
||||
albumList := album.UnitList{
|
||||
RankMaxFlag: true,
|
||||
LoveMaxFlag: true,
|
||||
RankLevelMaxFlag: true,
|
||||
AllMaxFlag: true,
|
||||
FavoritePoint: 1000,
|
||||
}
|
||||
albumList.UnitID = unit.UnitId
|
||||
if unit.Rarity != 4 {
|
||||
albumList.SignFlag = false
|
||||
switch unit.Rarity {
|
||||
case 1:
|
||||
albumList.HighestLovePerUnit = 50
|
||||
albumList.TotalLove = 50
|
||||
case 2:
|
||||
albumList.HighestLovePerUnit = 200
|
||||
albumList.TotalLove = 200
|
||||
case 3:
|
||||
albumList.HighestLovePerUnit = 500
|
||||
albumList.TotalLove = 500
|
||||
case 5:
|
||||
albumList.HighestLovePerUnit = 750
|
||||
albumList.TotalLove = 750
|
||||
}
|
||||
} else {
|
||||
albumList.HighestLovePerUnit = 1000
|
||||
albumList.TotalLove = 1000
|
||||
|
||||
// IsSigned
|
||||
albumList.SignFlag, err = ss.MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
albumLists = append(albumLists, albumList)
|
||||
}
|
||||
|
||||
res = album.AllResp{
|
||||
Result: albumLists,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/internal/handler/api/album"
|
||||
"honoka-chan/internal/handler/api/award"
|
||||
"honoka-chan/internal/handler/api/background"
|
||||
"honoka-chan/internal/handler/api/banner"
|
||||
"honoka-chan/internal/handler/api/challenge"
|
||||
"honoka-chan/internal/handler/api/costume"
|
||||
"honoka-chan/internal/handler/api/eventscenario"
|
||||
"honoka-chan/internal/handler/api/exchange"
|
||||
"honoka-chan/internal/handler/api/item"
|
||||
"honoka-chan/internal/handler/api/live"
|
||||
"honoka-chan/internal/handler/api/liveicon"
|
||||
"honoka-chan/internal/handler/api/livese"
|
||||
"honoka-chan/internal/handler/api/login"
|
||||
"honoka-chan/internal/handler/api/marathon"
|
||||
"honoka-chan/internal/handler/api/multiunit"
|
||||
"honoka-chan/internal/handler/api/museum"
|
||||
"honoka-chan/internal/handler/api/navigation"
|
||||
"honoka-chan/internal/handler/api/notice"
|
||||
"honoka-chan/internal/handler/api/payment"
|
||||
"honoka-chan/internal/handler/api/profile"
|
||||
"honoka-chan/internal/handler/api/scenario"
|
||||
"honoka-chan/internal/handler/api/stamp"
|
||||
"honoka-chan/internal/handler/api/subscenario"
|
||||
"honoka-chan/internal/handler/api/unit"
|
||||
"honoka-chan/internal/handler/api/user"
|
||||
"honoka-chan/internal/middleware"
|
||||
"honoka-chan/internal/router"
|
||||
apischema "honoka-chan/internal/schema/api"
|
||||
"honoka-chan/internal/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func api(ctx *gin.Context) {
|
||||
ss := session.Get(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
apiReq := []apischema.ApiReq{}
|
||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &apiReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var result any
|
||||
var results []any
|
||||
for _, v := range apiReq {
|
||||
// fmt.Println(v.Module, v.Action)
|
||||
switch v.Module {
|
||||
case "album":
|
||||
result, err = album.AlbumApi(ctx, v.Action)
|
||||
case "award":
|
||||
result, err = award.AwardApi(ctx, v.Action)
|
||||
case "background":
|
||||
result, err = background.BackgroundApi(ctx, v.Action)
|
||||
case "banner":
|
||||
result, err = banner.BannerApi(v.Action)
|
||||
case "challenge":
|
||||
result, err = challenge.ChallengeApi(v.Action)
|
||||
case "costume":
|
||||
result, err = costume.CostumeApi(v.Action)
|
||||
case "eventscenario":
|
||||
result, err = eventscenario.EventScenarioApi(ctx, v.Action)
|
||||
case "exchange":
|
||||
result, err = exchange.ExchangeApi(ctx, v.Action)
|
||||
case "item":
|
||||
result, err = item.ItemApi(v.Action)
|
||||
case "live":
|
||||
result, err = live.LiveApi(ctx, v.Action)
|
||||
case "liveicon":
|
||||
result, err = liveicon.LiveIconApi(v.Action)
|
||||
case "livese":
|
||||
result, err = livese.LiveSeApi(v.Action)
|
||||
case "login":
|
||||
result, err = login.LoginApi(v.Action)
|
||||
case "marathon":
|
||||
result, err = marathon.MarathonApi(v.Action)
|
||||
case "multiunit":
|
||||
result, err = multiunit.MultiUnitApi(ctx, v.Action)
|
||||
case "museum":
|
||||
result, err = museum.MuseumApi(ctx, v.Action)
|
||||
case "navigation":
|
||||
result, err = navigation.NavigationApi(v.Action)
|
||||
case "notice":
|
||||
result, err = notice.NoticeApi(v.Action)
|
||||
case "payment":
|
||||
result, err = payment.PaymentApi(v.Action)
|
||||
case "profile":
|
||||
result, err = profile.ProfileApi(ctx, v.Action)
|
||||
case "scenario":
|
||||
result, err = scenario.ScenarioApi(ctx, v.Action)
|
||||
case "stamp":
|
||||
result, err = stamp.StampApi(v.Action)
|
||||
case "subscenario":
|
||||
result, err = subscenario.SubscenarioApi(ctx, v.Action)
|
||||
case "unit":
|
||||
result, err = unit.UnitApi(ctx, v.Action)
|
||||
case "user":
|
||||
result, err = user.UserApi(ctx, v.Action)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented api module: %s", v.Module)
|
||||
}
|
||||
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
results = append(results, result)
|
||||
}
|
||||
|
||||
apiResp := apischema.ApiResp{
|
||||
ResponseData: results,
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
|
||||
ss.Respond(apiResp)
|
||||
}
|
||||
|
||||
func init() {
|
||||
router.AddHandler("main.php", "POST", "/api", middleware.Common, api)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package award
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AwardApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "awardInfo":
|
||||
res, err = awardInfo(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: award: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package award
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/award"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func awardInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var awardList []int
|
||||
err = ss.MainEng.Table("award_m").Cols("award_id").Find(&awardList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var awardID int
|
||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Cols("award_id").Get(&awardID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
awardsList := []award.Info{}
|
||||
for _, id := range awardList {
|
||||
isSet := false
|
||||
if id == awardID {
|
||||
isSet = true
|
||||
}
|
||||
awardsList = append(awardsList, award.Info{
|
||||
AwardID: id,
|
||||
IsSet: isSet,
|
||||
InsertDate: time.Now().Format("2006-01-02 03:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
res = award.InfoResp{
|
||||
Result: award.InfoData{
|
||||
AwardInfo: awardsList,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package background
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func BackgroundApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "backgroundInfo":
|
||||
res, err = backgroundInfo(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: background: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package background
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/background"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func backgroundInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var backgroundList []int
|
||||
err = ss.MainEng.Table("background_m").Cols("background_id").Find(&backgroundList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var backgroundID int
|
||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Cols("background_id").Get(&backgroundID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
backgroundsList := []background.Info{}
|
||||
for _, id := range backgroundList {
|
||||
isSet := false
|
||||
if id == backgroundID {
|
||||
isSet = true
|
||||
}
|
||||
backgroundsList = append(backgroundsList, background.Info{
|
||||
BackgroundID: id,
|
||||
IsSet: isSet,
|
||||
InsertDate: time.Now().Format("2006-01-02 03:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
res = background.InfoResp{
|
||||
Result: background.InfoData{
|
||||
BackgroundInfo: backgroundsList,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package banner
|
||||
|
||||
import "fmt"
|
||||
|
||||
func BannerApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "bannerList":
|
||||
res, err = bannerList()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: banner: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package banner
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/banner"
|
||||
"time"
|
||||
)
|
||||
|
||||
func bannerList() (res any, err error) {
|
||||
res = banner.ListResp{
|
||||
Result: banner.ListData{
|
||||
TimeLimit: "2037-12-31 23:59:59",
|
||||
BannerList: []banner.BannerList{
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1743,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1718_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101151,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1741,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1719_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101150,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1740,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1720_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101149,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1739,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1721_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101144,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 2,
|
||||
TargetID: 1,
|
||||
AssetPath: "assets/image/webview/wv_ba_01.png",
|
||||
WebviewURL: "/manga",
|
||||
FixedFlag: false,
|
||||
BackSide: true,
|
||||
BannerID: 200001,
|
||||
StartDate: "2016-10-15 15:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package challenge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func ChallengeApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "challengeInfo":
|
||||
res, err = challengeInfo()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: challenge: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package challenge
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/challenge"
|
||||
"time"
|
||||
)
|
||||
|
||||
func challengeInfo() (res any, err error) {
|
||||
res = challenge.InfoResp{
|
||||
Result: []any{},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package costume
|
||||
|
||||
import "fmt"
|
||||
|
||||
func CostumeApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "costumeList":
|
||||
res, err = costumeList()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: costume: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package costume
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/costume"
|
||||
"time"
|
||||
)
|
||||
|
||||
func costumeList() (res any, err error) {
|
||||
res = costume.ListResp{
|
||||
Result: costume.ListData{
|
||||
CostumeList: []costume.CostumeList{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package eventscenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func EventScenarioApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "status":
|
||||
res, err = eventScenarioStatus(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: costume: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package eventscenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"honoka-chan/internal/schema/api/eventscenario"
|
||||
"honoka-chan/internal/session"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var eventID []int
|
||||
eventsList := []eventscenario.EventScenarioList{}
|
||||
err = ss.MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range eventID {
|
||||
var eventRes []struct {
|
||||
EventScenarioId int `xorm:"event_scenario_id"`
|
||||
Chapter int `xorm:"chapter"`
|
||||
ChapterAsset string `xorm:"chapter_asset"`
|
||||
OpenDate string `xorm:"open_date"`
|
||||
}
|
||||
chapsList := []eventscenario.ChapterList{}
|
||||
err = ss.MainEng.Table("event_scenario_m").Where("event_id = ?", id).Cols("event_scenario_id,chapter,chapter_asset,open_date").
|
||||
OrderBy("chapter DESC").Find(&eventRes)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, res := range eventRes {
|
||||
chapList := eventscenario.ChapterList{
|
||||
EventScenarioID: res.EventScenarioId,
|
||||
Chapter: res.Chapter,
|
||||
ChapterAsset: res.ChapterAsset,
|
||||
Status: 2,
|
||||
OpenFlashFlag: 0,
|
||||
IsReward: false,
|
||||
CostType: 1000,
|
||||
ItemID: 1200,
|
||||
Amount: 1,
|
||||
}
|
||||
chapsList = append(chapsList, chapList)
|
||||
}
|
||||
|
||||
event := eventscenario.EventScenarioList{
|
||||
EventID: id,
|
||||
OpenDate: strings.ReplaceAll(eventRes[0].OpenDate, "/", "-"),
|
||||
ChapterList: chapsList,
|
||||
}
|
||||
|
||||
// HACK event_scenario_btn_asset
|
||||
switch id {
|
||||
case 10001:
|
||||
event.EventScenarioBtnAsset = "assets/image/ui/eventscenario/38_se_ba_t.png"
|
||||
case 221:
|
||||
event.EventScenarioBtnAsset = "assets/image/ui/eventscenario/215_se_ba_t.png"
|
||||
default:
|
||||
event.EventScenarioBtnAsset = fmt.Sprintf("assets/image/ui/eventscenario/%d_se_ba_t.png", id)
|
||||
}
|
||||
|
||||
eventsList = append(eventsList, event)
|
||||
}
|
||||
res = eventscenario.StatusResp{
|
||||
Result: eventscenario.StatusData{
|
||||
EventScenarioList: eventsList,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ExchangeApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "owningPoint":
|
||||
res, err = owningPoint(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: exchange: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/exchange"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func owningPoint(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var exchangeID []int
|
||||
exPointsList := []exchange.ExchangePointList{}
|
||||
err = ss.MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range exchangeID {
|
||||
exPointsList = append(exPointsList, exchange.ExchangePointList{
|
||||
Rarity: id,
|
||||
ExchangePoint: 9999,
|
||||
})
|
||||
}
|
||||
res = exchange.OwningPointResp{
|
||||
Result: exchange.OwningPointData{
|
||||
ExchangePointList: exPointsList,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package item
|
||||
|
||||
import "fmt"
|
||||
|
||||
func ItemApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "list":
|
||||
res, err = itemList()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: item: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package item
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
)
|
||||
|
||||
func itemList() (res any, err error) {
|
||||
itemResp := honokautils.ReadAllText("assets/serverdata/item.json")
|
||||
err = json.Unmarshal([]byte(itemResp), &res)
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func LiveApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "liveStatus":
|
||||
res, err = liveStatus(ctx)
|
||||
case "schedule":
|
||||
res, err = liveSchedule(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: live: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/live"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func liveSchedule(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var liveDifficultyID []int
|
||||
specialLives := []live.SpecialLiveStatusList{}
|
||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyID {
|
||||
specialLive := live.SpecialLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
}
|
||||
specialLives = append(specialLives, specialLive)
|
||||
}
|
||||
|
||||
livesList := []live.LiveList{}
|
||||
for _, v := range specialLives {
|
||||
livesList = append(livesList, live.LiveList{
|
||||
LiveDifficultyID: v.LiveDifficultyID,
|
||||
StartDate: "2023-01-01 00:00:00",
|
||||
EndDate: "2037-01-01 00:00:00",
|
||||
IsRandom: false,
|
||||
})
|
||||
}
|
||||
res = live.ScheduleResp{
|
||||
Result: live.ScheduleData{
|
||||
EventList: []any{},
|
||||
LiveList: livesList,
|
||||
LimitedBonusList: []any{},
|
||||
LimitedBonusCommonList: []live.LimitedBonusCommonList{}, // 特效道具
|
||||
RandomLiveList: []live.RandomLiveList{}, // 随机歌曲
|
||||
FreeLiveList: []any{},
|
||||
TrainingLiveList: []live.TrainingLiveList{}, // 挑战歌曲
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/live"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func liveStatus(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var liveDifficultyID []int
|
||||
normalLives := []live.NormalLiveStatusList{}
|
||||
err = ss.MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyID {
|
||||
normalLive := live.NormalLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
}
|
||||
normalLives = append(normalLives, normalLive)
|
||||
}
|
||||
|
||||
specialLives := []live.SpecialLiveStatusList{}
|
||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyID {
|
||||
specialLive := live.SpecialLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
}
|
||||
specialLives = append(specialLives, specialLive)
|
||||
}
|
||||
|
||||
res = live.StatusResp{
|
||||
Result: live.StatusData{
|
||||
NormalLiveStatusList: normalLives,
|
||||
SpecialLiveStatusList: specialLives,
|
||||
TrainingLiveStatusList: []live.TrainingLiveStatusList{},
|
||||
MarathonLiveStatusList: []any{},
|
||||
FreeLiveStatusList: []any{},
|
||||
CanResumeLive: false,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package liveicon
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/liveicon"
|
||||
"time"
|
||||
)
|
||||
|
||||
func liveIconInfo() (res any, err error) {
|
||||
res = liveicon.InfoResp{
|
||||
Result: liveicon.InfoData{
|
||||
LiveNotesIconList: []int{1, 2, 3},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package liveicon
|
||||
|
||||
import "fmt"
|
||||
|
||||
func LiveIconApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "liveiconInfo":
|
||||
res, err = liveIconInfo()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: liveicon: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package livese
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/livese"
|
||||
"time"
|
||||
)
|
||||
|
||||
func LiveSeInfo() (res any, err error) {
|
||||
res = livese.InfoResp{
|
||||
Result: livese.InfoData{
|
||||
LiveSeList: []int{1, 2, 3},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package livese
|
||||
|
||||
import "fmt"
|
||||
|
||||
func LiveSeApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "liveseInfo":
|
||||
res, err = LiveSeInfo()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: livese: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func LoginApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "topInfo":
|
||||
res, err = loginTopInfo()
|
||||
case "topInfoOnce":
|
||||
res, err = loginTopInfoOnce()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: login: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/login"
|
||||
"time"
|
||||
)
|
||||
|
||||
func loginTopInfo() (res any, err error) {
|
||||
res = login.TopInfoResp{
|
||||
Result: login.TopInfoData{
|
||||
FriendActionCnt: 0,
|
||||
FriendGreetCnt: 0,
|
||||
FriendVarietyCnt: 0,
|
||||
FriendNewCnt: 0,
|
||||
PresentCnt: 0,
|
||||
SecretBoxBadgeFlag: false,
|
||||
ServerDatetime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
NoticeFriendDatetime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
NoticeMailDatetime: "2000-01-01 12:00:00",
|
||||
FriendsApprovalWaitCnt: 0,
|
||||
FriendsRequestCnt: 0,
|
||||
IsTodayBirthday: false,
|
||||
LicenseInfo: login.LicenseInfo{
|
||||
LicenseList: []any{},
|
||||
LicensedInfo: []any{},
|
||||
ExpiredInfo: []any{},
|
||||
BadgeFlag: false,
|
||||
},
|
||||
UsingBuffInfo: []any{},
|
||||
IsKlabIDTaskFlag: false,
|
||||
KlabIDTaskCanSync: false,
|
||||
HasUnreadAnnounce: false,
|
||||
ExchangeBadgeCnt: []int{0, 0, 0},
|
||||
AdFlag: false,
|
||||
HasAdReward: false,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/login"
|
||||
"time"
|
||||
)
|
||||
|
||||
func loginTopInfoOnce() (res any, err error) {
|
||||
res = login.TopInfoOnceResp{
|
||||
Result: login.TopInfoOnceData{
|
||||
NewAchievementCnt: 0,
|
||||
UnaccomplishedAchievementCnt: 0,
|
||||
LiveDailyRewardExist: false,
|
||||
TrainingEnergy: 10,
|
||||
TrainingEnergyMax: 10,
|
||||
Notification: login.Notification{
|
||||
Push: false,
|
||||
Lp: false,
|
||||
UpdateInfo: false,
|
||||
Campaign: false,
|
||||
Live: false,
|
||||
Lbonus: false,
|
||||
Event: false,
|
||||
Secretbox: false,
|
||||
Birthday: true,
|
||||
},
|
||||
OpenArena: true,
|
||||
CostumeStatus: true,
|
||||
OpenAccessory: true,
|
||||
ArenaSiSkillUniqueCheck: true,
|
||||
OpenV98: true,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package marathon
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/marathon"
|
||||
"time"
|
||||
)
|
||||
|
||||
func marathonInfo() (res any, err error) {
|
||||
res = marathon.InfoResp{
|
||||
Result: []any{},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package marathon
|
||||
|
||||
import "fmt"
|
||||
|
||||
func MarathonApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "marathonInfo":
|
||||
res, err = marathonInfo()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: marathon: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package multiunit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MultiUnitApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "multiunitscenarioStatus":
|
||||
res, err = MultiUnitScenarioStatus(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: multiunit: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package multiunit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/multiunit"
|
||||
"honoka-chan/internal/session"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MultiUnitScenarioStatus(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var statusID []int
|
||||
multiUnitsList := []multiunit.StatusList{}
|
||||
err = ss.MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&statusID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range statusID {
|
||||
var multiRes struct {
|
||||
MultiUnitScenarioId int `xorm:"multi_unit_scenario_id"`
|
||||
Chapter int `xorm:"chapter"`
|
||||
MultiUnitScenarioBtnAsset string `xorm:"multi_unit_scenario_btn_asset"`
|
||||
OpenDate string `xorm:"open_date"`
|
||||
}
|
||||
_, err = ss.MainEng.Table("multi_unit_scenario_m").
|
||||
Join("LEFT", "multi_unit_scenario_open_m", "multi_unit_scenario_m.multi_unit_id = multi_unit_scenario_open_m.multi_unit_id").
|
||||
Cols("multi_unit_scenario_btn_asset,open_date,multi_unit_scenario_id,chapter").
|
||||
Where("multi_unit_scenario_m.multi_unit_id = ?", id).Get(&multiRes)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
multiUnitsList = append(multiUnitsList, multiunit.StatusList{
|
||||
MultiUnitID: id,
|
||||
Status: 2,
|
||||
MultiUnitScenarioBtnAsset: multiRes.MultiUnitScenarioBtnAsset,
|
||||
OpenDate: strings.ReplaceAll(multiRes.OpenDate, "/", "-"),
|
||||
ChapterList: []multiunit.ChapterList{
|
||||
{
|
||||
MultiUnitScenarioID: multiRes.MultiUnitScenarioId,
|
||||
Chapter: multiRes.Chapter,
|
||||
Status: 2,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
res = multiunit.StatusResp{
|
||||
Result: multiunit.StatusData{
|
||||
MultiUnitScenarioStatusList: multiUnitsList,
|
||||
UnlockedMultiUnitScenarioIds: []any{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package museum
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/museum"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func museumInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var museumRes []struct {
|
||||
MuseumContentsId int `xorm:"museum_contents_id"`
|
||||
SmileBuff int `xorm:"smile_buff"`
|
||||
PureBuff int `xorm:"pure_buff"`
|
||||
CoolBuff int `xorm:"cool_buff"`
|
||||
}
|
||||
var museumID []int
|
||||
var smileBuff, pureBuff, coolBuff int
|
||||
err = ss.MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").
|
||||
OrderBy("museum_contents_id ASC").Find(&museumRes)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, res := range museumRes {
|
||||
smileBuff += res.SmileBuff
|
||||
pureBuff += res.PureBuff
|
||||
coolBuff += res.CoolBuff
|
||||
museumID = append(museumID, res.MuseumContentsId)
|
||||
}
|
||||
res = museum.InfoResp{
|
||||
Result: museum.InfoData{
|
||||
MuseumInfo: museum.Info{
|
||||
Parameter: museum.Parameter{
|
||||
Smile: smileBuff,
|
||||
Pure: pureBuff,
|
||||
Cool: coolBuff,
|
||||
},
|
||||
ContentsIDList: museumID,
|
||||
},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package museum
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MuseumApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "info":
|
||||
res, err = museumInfo(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: museum: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package navigation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func NavigationApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "specialCutin":
|
||||
res, err = SpecialCutin()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: navigation: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package navigation
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/navigation"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SpecialCutin() (res any, err error) {
|
||||
res = navigation.SpecialCutinResp{
|
||||
Result: navigation.SpecialCutinData{
|
||||
SpecialCutinList: []any{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package notice
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/notice"
|
||||
"time"
|
||||
)
|
||||
|
||||
func noticeMarquee() (res any, err error) {
|
||||
res = notice.MarqueeResp{
|
||||
Result: notice.MarqueeData{
|
||||
ItemCount: 0,
|
||||
MarqueeList: []any{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package notice
|
||||
|
||||
import "fmt"
|
||||
|
||||
func NoticeApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "noticeMarquee":
|
||||
res, err = noticeMarquee()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: notice: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package payment
|
||||
|
||||
import "fmt"
|
||||
|
||||
func PaymentApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "productList":
|
||||
res, err = productList()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: payment: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package payment
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/payment"
|
||||
"time"
|
||||
)
|
||||
|
||||
func productList() (res any, err error) {
|
||||
res = payment.ProductListResp{
|
||||
Result: payment.ProductListData{
|
||||
RestrictionInfo: payment.RestrictionInfo{
|
||||
Restricted: false,
|
||||
},
|
||||
UnderAgeInfo: payment.UnderAgeInfo{
|
||||
BirthSet: false,
|
||||
HasLimit: false,
|
||||
LimitAmount: nil,
|
||||
MonthUsed: 0,
|
||||
},
|
||||
SnsProductList: []payment.SnsProduct{},
|
||||
ProductList: []payment.Product{},
|
||||
SubscriptionList: []payment.Subscription{},
|
||||
ShowPointShop: false,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/schema/api/profile"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func cardRanking() (res any, err error) {
|
||||
var result []any
|
||||
love := honokautils.ReadAllText("assets/serverdata/love.json")
|
||||
err = json.Unmarshal([]byte(love), &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = profile.CardRankingResp{
|
||||
Result: result,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/model/user"
|
||||
"honoka-chan/internal/schema/api/profile"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func profileInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
pref := user.UserPref{}
|
||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commonUnit, err := ss.MainEng.Table("common_unit_m").Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userUnit, err := ss.UserEng.Table("user_unit").Where("user_id = ?", ss.UserID).Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unitData := profile.UnitData{}
|
||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
isCommon := true
|
||||
if !exists {
|
||||
_, err = ss.UserEng.Table("user_unit").
|
||||
Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).Get(&unitData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
isCommon = false
|
||||
}
|
||||
|
||||
var attrId, maxHp, baseSmile, basePure, baseCool int
|
||||
var smileMax, pureMax, coolMax int
|
||||
if isCommon {
|
||||
// 公共卡片仅为100级属性
|
||||
_, err = ss.MainEng.Table("unit_m").Where("unit_id = ?", unitData.UnitID).
|
||||
Cols("attribute_id,hp_max,smile_max,pure_max,cool_max").Get(&attrId, &maxHp, &baseSmile, &basePure, &baseCool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 偷懒起见不计算饰品、宝石、回忆画廊等属性加成
|
||||
smileMax = baseSmile
|
||||
pureMax = basePure
|
||||
coolMax = baseCool
|
||||
// } else {
|
||||
// // 用户卡片需要根据等级计算属性
|
||||
// // TODO
|
||||
}
|
||||
|
||||
var accessoryOwningId, accessoryId, exp int
|
||||
_, err = ss.UserEng.Table("user_accessory_wear").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).
|
||||
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = ss.MainEng.Table("common_accessory_m").Where("accessory_owning_user_id = ?", accessoryOwningId).
|
||||
Cols("accessory_id,exp").Get(&accessoryId, &exp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
accessoryInfo := profile.AccessoryInfo{
|
||||
AccessoryOwningUserID: accessoryOwningId,
|
||||
AccessoryID: accessoryId,
|
||||
Exp: exp,
|
||||
NextExp: 0,
|
||||
Level: 8,
|
||||
MaxLevel: 8,
|
||||
RankUpCount: 4,
|
||||
FavoriteFlag: true,
|
||||
}
|
||||
|
||||
removeSkillIds := []int{}
|
||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).
|
||||
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = profile.InfoResp{
|
||||
Result: profile.InfoData{
|
||||
UserInfo: profile.UserInfo{
|
||||
UserID: pref.UserID,
|
||||
Name: pref.UserName,
|
||||
Level: pref.UserLevel,
|
||||
CostMax: 100,
|
||||
UnitMax: 5000,
|
||||
EnergyMax: 417,
|
||||
FriendMax: 99,
|
||||
UnitCnt: int(commonUnit + userUnit),
|
||||
InviteCode: pref.InviteCode,
|
||||
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
||||
Introduction: pref.UserDesc,
|
||||
},
|
||||
CenterUnitInfo: profile.CenterUnitInfo{
|
||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||
UnitID: unitData.UnitID,
|
||||
Exp: unitData.Exp,
|
||||
NextExp: unitData.NextExp,
|
||||
Level: unitData.Level,
|
||||
LevelLimitID: unitData.LevelLimitID,
|
||||
MaxLevel: unitData.MaxLevel,
|
||||
Rank: unitData.Rank,
|
||||
MaxRank: unitData.MaxRank,
|
||||
Love: unitData.Love,
|
||||
MaxLove: unitData.MaxLove,
|
||||
UnitSkillLevel: unitData.UnitSkillLevel,
|
||||
MaxHp: unitData.MaxHp,
|
||||
FavoriteFlag: unitData.FavoriteFlag,
|
||||
DisplayRank: unitData.DisplayRank,
|
||||
UnitSkillExp: unitData.UnitSkillExp,
|
||||
UnitRemovableSkillCapacity: unitData.UnitRemovableSkillCapacity,
|
||||
Attribute: attrId,
|
||||
Smile: baseSmile,
|
||||
Cute: basePure,
|
||||
Cool: baseCool,
|
||||
IsLoveMax: unitData.IsLoveMax,
|
||||
IsLevelMax: unitData.IsLevelMax,
|
||||
IsRankMax: unitData.IsRankMax,
|
||||
IsSigned: unitData.IsSigned,
|
||||
IsSkillLevelMax: unitData.IsSkillLevelMax,
|
||||
SettingAwardID: pref.AwardID,
|
||||
RemovableSkillIds: removeSkillIds,
|
||||
AccessoryInfo: accessoryInfo,
|
||||
Costume: profile.Costume{},
|
||||
TotalSmile: smileMax,
|
||||
TotalCute: pureMax,
|
||||
TotalCool: coolMax,
|
||||
TotalHp: maxHp,
|
||||
},
|
||||
NaviUnitInfo: profile.NaviUnitInfo{
|
||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||
UnitID: unitData.UnitID,
|
||||
Exp: unitData.Exp,
|
||||
NextExp: unitData.NextExp,
|
||||
Level: unitData.Level,
|
||||
MaxLevel: unitData.MaxLevel,
|
||||
LevelLimitID: unitData.LevelLimitID,
|
||||
Rank: unitData.Rank,
|
||||
MaxRank: unitData.MaxRank,
|
||||
Love: unitData.Love,
|
||||
MaxLove: unitData.MaxLove,
|
||||
UnitSkillExp: unitData.UnitSkillExp,
|
||||
UnitSkillLevel: unitData.UnitSkillLevel,
|
||||
MaxHp: unitData.MaxHp,
|
||||
UnitRemovableSkillCapacity: unitData.UnitRemovableSkillCapacity,
|
||||
FavoriteFlag: unitData.FavoriteFlag,
|
||||
DisplayRank: unitData.DisplayRank,
|
||||
IsLoveMax: unitData.IsLoveMax,
|
||||
IsLevelMax: unitData.IsLevelMax,
|
||||
IsRankMax: unitData.IsRankMax,
|
||||
IsSigned: unitData.IsSigned,
|
||||
IsSkillLevelMax: unitData.IsSkillLevelMax,
|
||||
IsRemovableSkillCapacityMax: unitData.IsRemovableSkillCapacityMax,
|
||||
InsertDate: "2016-10-11 10:33:03",
|
||||
TotalSmile: smileMax,
|
||||
TotalCute: pureMax,
|
||||
TotalCool: coolMax,
|
||||
TotalHp: maxHp,
|
||||
RemovableSkillIds: removeSkillIds,
|
||||
},
|
||||
IsAlliance: false,
|
||||
FriendStatus: 0,
|
||||
SettingAwardID: pref.AwardID,
|
||||
SettingBackgroundID: pref.BackgroundID,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/profile"
|
||||
"time"
|
||||
)
|
||||
|
||||
func liveCnt() (res any, err error) {
|
||||
res = profile.LiveCntResp{
|
||||
Result: []profile.LiveCntData{
|
||||
{
|
||||
Difficulty: 1,
|
||||
ClearCnt: 315,
|
||||
},
|
||||
{
|
||||
Difficulty: 2,
|
||||
ClearCnt: 310,
|
||||
},
|
||||
{
|
||||
Difficulty: 3,
|
||||
ClearCnt: 314,
|
||||
},
|
||||
{
|
||||
Difficulty: 4,
|
||||
ClearCnt: 455,
|
||||
},
|
||||
{
|
||||
Difficulty: 6,
|
||||
ClearCnt: 233,
|
||||
},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ProfileApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "cardRanking":
|
||||
res, err = cardRanking()
|
||||
case "liveCnt":
|
||||
res, err = liveCnt()
|
||||
case "profileInfo":
|
||||
res, err = profileInfo(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: profile: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package scenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ScenarioApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "scenarioStatus":
|
||||
res, err = scenarioStatus(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: scenario: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package scenario
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/scenario"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func scenarioStatus(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var scenarioID []int
|
||||
scenarioLists := []scenario.StatusList{}
|
||||
err = ss.MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range scenarioID {
|
||||
scenarioLists = append(scenarioLists, scenario.StatusList{
|
||||
ScenarioID: id,
|
||||
Status: 2,
|
||||
})
|
||||
}
|
||||
res = scenario.StatusResp{
|
||||
Result: scenario.StatusData{
|
||||
ScenarioStatusList: scenarioLists,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package stamp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
)
|
||||
|
||||
func stampInfo() (res any, err error) {
|
||||
stampResp := honokautils.ReadAllText("assets/serverdata/stamp.json")
|
||||
err = json.Unmarshal([]byte(stampResp), &res)
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package stamp
|
||||
|
||||
import "fmt"
|
||||
|
||||
func StampApi(action string) (res any, err error) {
|
||||
switch action {
|
||||
case "stampInfo":
|
||||
res, err = stampInfo()
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: stamp: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package subscenario
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/subscenario"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func subscenarioStatus(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var subScenarioID []int
|
||||
subScenarioLists := []subscenario.StatusList{}
|
||||
err = ss.MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range subScenarioID {
|
||||
subScenarioLists = append(subScenarioLists, subscenario.StatusList{
|
||||
SubscenarioID: id,
|
||||
Status: 2,
|
||||
})
|
||||
}
|
||||
res = subscenario.StatusResp{
|
||||
Result: subscenario.StatusData{
|
||||
SubscenarioStatusList: subScenarioLists,
|
||||
UnlockedSubscenarioIds: []any{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package subscenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SubscenarioApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "subscenarioStatus":
|
||||
res, err = subscenarioStatus(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: subscenario: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/unit"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func unitAccessoryAll(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
accessoryList := []unit.AccessoryList{}
|
||||
err = ss.MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for k := range accessoryList {
|
||||
accessoryList[k].NextExp = 0
|
||||
accessoryList[k].Level = 8
|
||||
accessoryList[k].MaxLevel = 8
|
||||
accessoryList[k].RankUpCount = 4
|
||||
accessoryList[k].FavoriteFlag = true
|
||||
}
|
||||
wearingInfo := []unit.WearingInfo{}
|
||||
err = ss.UserEng.Table("user_accessory_wear").Where("user_id = ?", ss.UserID).Find(&wearingInfo)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
res = unit.AccessoryAllResp{
|
||||
Result: unit.AccessoryAllData{
|
||||
AccessoryList: accessoryList,
|
||||
WearingInfo: wearingInfo,
|
||||
EspecialCreateFlag: false,
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/unit"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func unitAll(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
unitsData := []unit.Active{}
|
||||
err = ss.MainEng.Table("common_unit_m").Find(&unitsData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
userUnits := []unit.Active{}
|
||||
err = ss.UserEng.Table("user_unit").Where("user_id = ?", ss.UserID).Find(&userUnits)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
unitsData = append(unitsData, userUnits...)
|
||||
|
||||
res = unit.AllResp{
|
||||
Result: unit.AllData{
|
||||
Active: unitsData,
|
||||
Waiting: []unit.Waiting{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/unit"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func unitDeckInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
userDeck := []unit.UserDeckData{}
|
||||
err = ss.UserEng.Table("user_deck").Where("user_id = ?", ss.UserID).Asc("deck_id").Find(&userDeck)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
unitDeckInfo := []unit.DeckInfoData{}
|
||||
for _, deck := range userDeck {
|
||||
deckUnit := []unit.UnitDeckData{}
|
||||
err = ss.UserEng.Table("user_deck_unit").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
oUID := []unit.UnitOwningUserIds{}
|
||||
for _, u := range deckUnit {
|
||||
oUID = append(oUID, unit.UnitOwningUserIds{
|
||||
Position: u.Position,
|
||||
UnitOwningUserID: u.UnitOwningUserID,
|
||||
})
|
||||
}
|
||||
|
||||
mainFlag := false
|
||||
if deck.MainFlag == 1 {
|
||||
mainFlag = true
|
||||
}
|
||||
unitDeckInfo = append(unitDeckInfo, unit.DeckInfoData{
|
||||
UnitDeckID: deck.DeckID,
|
||||
MainFlag: mainFlag,
|
||||
DeckName: deck.DeckName,
|
||||
UnitOwningUserIds: oUID,
|
||||
})
|
||||
}
|
||||
res = unit.DeckInfoResp{
|
||||
Result: unitDeckInfo,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/unit"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func unitRemovableSkillInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var skillEquipCount []unit.SkillEquipCount
|
||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ?", ss.UserID).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||
GroupBy("unit_removable_skill_id").Find(&skillEquipCount)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var rmSkillIds []int
|
||||
err = ss.MainEng.Table("unit_removable_skill_m").Where("effect_range = 1").Cols("unit_removable_skill_id").Find(&rmSkillIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
owingInfo := []unit.OwningInfo{}
|
||||
for _, id := range rmSkillIds {
|
||||
info := unit.OwningInfo{
|
||||
UnitRemovableSkillID: id,
|
||||
TotalAmount: 9,
|
||||
EquippedAmount: 0,
|
||||
InsertDate: "2023-01-01 12:00:00",
|
||||
}
|
||||
for _, sk := range skillEquipCount {
|
||||
if id == sk.UnitRemovableSkillId {
|
||||
info.EquippedAmount = sk.Count
|
||||
break
|
||||
}
|
||||
}
|
||||
owingInfo = append(owingInfo, info)
|
||||
}
|
||||
|
||||
var unitOwningIds []int
|
||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ?", ss.UserID).Cols("unit_owning_user_id").GroupBy("unit_owning_user_id").Find(&unitOwningIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
equipInfo := map[int]any{}
|
||||
for _, v := range unitOwningIds {
|
||||
detail := []unit.SkillEquipDetail{}
|
||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ? AND unit_owning_user_id = ?", ss.UserID, v).
|
||||
Cols("unit_removable_skill_id").Find(&detail)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
equipInfo[v] = unit.SkillEquipList{
|
||||
UnitOwningUserID: v,
|
||||
Detail: detail,
|
||||
}
|
||||
}
|
||||
|
||||
res = unit.RemovableSkillInfoResp{
|
||||
Result: unit.RemovableSkillInfoData{
|
||||
OwningInfo: owingInfo,
|
||||
EquipmentInfo: equipInfo,
|
||||
}, // 宝石
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/unit"
|
||||
"time"
|
||||
)
|
||||
|
||||
func unitSupporterAll() (res any, err error) {
|
||||
res = unit.SupporterAllResp{
|
||||
Result: unit.SupporterAllData{
|
||||
UnitSupportList: []unit.SupporterList{},
|
||||
}, // 练习道具
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func UnitApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "accessoryAll":
|
||||
res, err = unitAccessoryAll(ctx)
|
||||
case "deckInfo":
|
||||
res, err = unitDeckInfo(ctx)
|
||||
case "removableSkillInfo":
|
||||
res, err = unitRemovableSkillInfo(ctx)
|
||||
case "supporterAll":
|
||||
res, err = unitSupporterAll()
|
||||
case "unitAll":
|
||||
res, err = unitAll(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: unit: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/user"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func userGetNavi(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
var uID, oID int
|
||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Cols("user_id,unit_owning_user_id").Get(&uID, &oID)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
res = user.GetNaviResp{
|
||||
Result: user.GetNaviData{
|
||||
User: user.User{
|
||||
UserID: uID,
|
||||
UnitOwningUserID: oID,
|
||||
},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/model/user"
|
||||
userapischema "honoka-chan/internal/schema/api/user"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func userInfo(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
pref := user.UserPref{}
|
||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = userapischema.InfoResp{
|
||||
Result: userapischema.UserInfo{
|
||||
UserID: ss.UserID,
|
||||
Name: pref.UserName,
|
||||
Level: pref.UserLevel,
|
||||
Exp: 1089696,
|
||||
PreviousExp: 0,
|
||||
NextExp: 1207185,
|
||||
GameCoin: 999999999,
|
||||
SnsCoin: 100000,
|
||||
FreeSnsCoin: 50000,
|
||||
PaidSnsCoin: 50000,
|
||||
SocialPoint: 1438395,
|
||||
UnitMax: 5000,
|
||||
WaitingUnitMax: 1000,
|
||||
EnergyMax: 417,
|
||||
EnergyFullTime: "2023-03-20 03:58:55",
|
||||
LicenseLiveEnergyRecoverlyTime: 60,
|
||||
EnergyFullNeedTime: 0,
|
||||
OverMaxEnergy: 417,
|
||||
TrainingEnergy: 100,
|
||||
TrainingEnergyMax: 100,
|
||||
FriendMax: 99,
|
||||
InviteCode: pref.InviteCode,
|
||||
InsertDate: "2015-08-10 18:58:30",
|
||||
UpdateDate: "2018-08-09 18:13:12",
|
||||
TutorialState: -1,
|
||||
DiamondCoin: 0,
|
||||
CrystalCoin: 0,
|
||||
LpRecoveryItem: []userapischema.LpRecoveryItem{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func UserApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "getNavi":
|
||||
res, err = userGetNavi(ctx)
|
||||
case "userInfo":
|
||||
res, err = userInfo(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: user: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user