diff --git a/.gitignore b/.gitignore index b407a8b..1cfdd69 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ honoka-chan honoka-chan.exe data -logs assets/data.db assets/unit.sd diff --git a/config.yml b/config.yml index 5e33582..ad6afdc 100644 --- a/config.yml +++ b/config.yml @@ -1,13 +1,4 @@ app_name: LL! SIF Private Server -server: - powered_by: KLab Native APP Platform - version_date: "20120129" - version_number: 97.4.6 - version_up: "0" -log: - log_dir: logs - log_level: 5 - log_save: true leveldb: data_path: ./data/honoka-chan.db cdn: diff --git a/config/config.go b/config/config.go index 49c280f..a056207 100644 --- a/config/config.go +++ b/config/config.go @@ -12,13 +12,16 @@ import ( ) var ( - ConfName = "config.yml" - Conf = &AppConfigs{} + ConfName = "config.yml" + Conf = &AppConfigs{} + ExampleDb = "assets/data.example.db" MainDb = "assets/main.db" UserDb = "assets/data.db" MainEng *xorm.Engine UserEng *xorm.Engine + + PackageVersion = "97.4.6" ) func init() { diff --git a/config/yaml.go b/config/yaml.go index 1b95bc9..7d2f5a6 100644 --- a/config/yaml.go +++ b/config/yaml.go @@ -4,8 +4,8 @@ package config import ( + "fmt" "honoka-chan/utils" - "honoka-chan/xclog" "os" "strconv" "time" @@ -15,25 +15,10 @@ import ( type AppConfigs struct { AppName string `yaml:"app_name"` - Server ServerConfigs `yaml:"server"` - Log LogConfigs `yaml:"log"` LevelDb LevelDbConfigs `yaml:"leveldb"` Cdn CdnConfigs `yaml:"cdn"` } -type ServerConfigs struct { - PoweredBy string `yaml:"powered_by"` - VersionDate string `yaml:"version_date"` - VersionNumber string `yaml:"version_number"` - VersionUp string `yaml:"version_up"` -} - -type LogConfigs struct { - LogDir string `yaml:"log_dir"` - LogLevel int `yaml:"log_level"` - LogSave bool `yaml:"log_save"` -} - type LevelDbConfigs struct { DataPath string `yaml:"data_path"` } @@ -45,17 +30,6 @@ type CdnConfigs struct { func DefaultConfigs() *AppConfigs { return &AppConfigs{ AppName: "LL! SIF Private Server", - Server: ServerConfigs{ - PoweredBy: "KLab Native APP Platform", - VersionDate: "20120129", - VersionNumber: "97.4.6", - VersionUp: "0", - }, - Log: LogConfigs{ - LogDir: "logs", - LogLevel: 5, - LogSave: true, - }, LevelDb: LevelDbConfigs{ DataPath: "./data/honoka-chan.db", }, @@ -72,20 +46,20 @@ func Load(p string) *AppConfigs { c := AppConfigs{} err := yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c) if err != nil { - xclog.Error("Failed to load " + ConfName + ": " + err.Error()) + fmt.Println("Failed to load" + ConfName + ":" + err.Error()) _ = os.Rename(p, p+".backup"+strconv.FormatInt(time.Now().Unix(), 10)) _ = DefaultConfigs().Save(p) } c = AppConfigs{} _ = yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c) - xclog.Info(ConfName + " loaded!") + fmt.Println(ConfName + "loaded!") return &c } func (c *AppConfigs) Save(p string) error { data, err := yaml.Marshal(c) if err != nil { - xclog.Error("Failed to save " + ConfName + ": " + err.Error()) + fmt.Println("Failed to save" + ConfName + ":" + err.Error()) return err } utils.WriteAllText(p, string(data)) diff --git a/handler/album.go b/handler/album.go index cf2ddff..d7ea68a 100644 --- a/handler/album.go +++ b/handler/album.go @@ -13,7 +13,12 @@ import ( _ "github.com/mattn/go-sqlite3" ) -func AlbumSeriesAllHandler(ctx *gin.Context) { +type AlbumSearchResult struct { + UnitId int `xorm:"unit_id"` + Rarity int `xorm:"rarity"` +} + +func AlbumSeriesAll(ctx *gin.Context) { var albumIds []int err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds) CheckErr(err) @@ -21,21 +26,14 @@ func AlbumSeriesAllHandler(ctx *gin.Context) { albumSeriesAllRes := []model.AlbumSeriesRes{} for _, albumId := range albumIds { - AlbumStmt, err := MainEng.DB().Prepare("SELECT unit_id,rarity FROM unit_m WHERE album_series_id = ?") - CheckErr(err) - defer AlbumStmt.Close() - - rows, err := AlbumStmt.Query(albumId) + unitList := []AlbumSearchResult{} + err = MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList) CheckErr(err) albumSeriesAll := []model.AlbumResult{} - for rows.Next() { - var unitId, rarity int - err = rows.Scan(&unitId, &rarity) - CheckErr(err) - + for _, unit := range unitList { albumSeries := model.AlbumResult{ - UnitID: unitId, + UnitID: unit.UnitId, RankMaxFlag: true, LoveMaxFlag: true, RankLevelMaxFlag: true, @@ -44,8 +42,8 @@ func AlbumSeriesAllHandler(ctx *gin.Context) { FavoritePoint: 1000, } - if rarity != 4 { - switch rarity { + if unit.Rarity != 4 { + switch unit.Rarity { case 1: // N albumSeries.HighestLovePerUnit = 50 @@ -64,19 +62,9 @@ func AlbumSeriesAllHandler(ctx *gin.Context) { albumSeries.HighestLovePerUnit = 1000 // IsSigned - signStmt, err := MainEng.DB().Prepare("SELECT COUNT(*) AS ct FROM unit_sign_asset_m WHERE unit_id = ?") + exists, err := MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist() CheckErr(err) - defer signStmt.Close() - - var count int - err = signStmt.QueryRow(unitId).Scan(&count) - CheckErr(err) - - if count > 0 { - albumSeries.SignFlag = true - } else { - albumSeries.SignFlag = false - } + albumSeries.SignFlag = exists } albumSeriesAll = append(albumSeriesAll, albumSeries) diff --git a/handler/announce.go b/handler/announce.go index 5896641..3bfc8a2 100644 --- a/handler/announce.go +++ b/handler/announce.go @@ -13,14 +13,14 @@ import ( "github.com/gin-gonic/gin" ) -func AnnounceIndexHandler(ctx *gin.Context) { +func AnnounceIndex(ctx *gin.Context) { ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{ "title": "Love Live! 学园偶像祭 非官方服务器", "content": template.HTML("目前开发完毕的功能包括:登录、相册、Live、个人信息。
其他功能仍在开发中,有报错属于正常现象。"), }) } -func AnnounceCheckStateHandler(ctx *gin.Context) { +func AnnounceCheckState(ctx *gin.Context) { announceResp := model.AnnounceResp{ ResponseData: model.AnnounceRes{ HasUnreadAnnounce: false, diff --git a/handler/api.go b/handler/api.go index 04edef2..1e4a7fb 100644 --- a/handler/api.go +++ b/handler/api.go @@ -17,29 +17,26 @@ import ( "github.com/gin-gonic/gin" ) -func ApiHandler(ctx *gin.Context) { - userId, err := strconv.Atoi(ctx.GetString("userid")) - CheckErr(err) - - var formdata []model.SifApi - err = json.Unmarshal([]byte(ctx.GetString("request_data")), &formdata) +func Api(ctx *gin.Context) { + apiReq := []model.ApiReq{} + err := json.Unmarshal([]byte(ctx.GetString("request_data")), &apiReq) if err != nil { fmt.Println(err) return } - var results []interface{} - for _, v := range formdata { + results := []interface{}{} + for _, v := range apiReq { var res []byte var err error // fmt.Println(v) - fmt.Println(v.Module, v.Action) + // fmt.Println(v.Module, v.Action) switch v.Module { case "login": if v.Action == "topInfo" { // key = "login_topinfo_result" topInfoResp := model.TopInfoResp{ - Result: model.TopInfoResult{ + Result: model.TopInfoRes{ FriendActionCnt: 0, FriendGreetCnt: 0, FriendVarietyCnt: 0, @@ -76,7 +73,7 @@ func ApiHandler(ctx *gin.Context) { } else if v.Action == "topInfoOnce" { // key = "login_topinfo_once_result" topInfoOnceResp := model.TopInfoOnceResp{ - Result: model.TopInfoOnceResult{ + Result: model.TopInfoOnceRes{ NewAchievementCnt: 0, UnaccomplishedAchievementCnt: 0, LiveDailyRewardExist: false, @@ -109,18 +106,13 @@ func ApiHandler(ctx *gin.Context) { case "live": if v.Action == "liveStatus" { // key = "live_status_result" - var liveDifficultyId int + var liveDifficultyId []int normalLives := []model.NormalLiveStatusList{} - sql := `SELECT live_difficulty_id FROM normal_live_m ORDER BY live_difficulty_id ASC` - rows, err := MainEng.DB().Query(sql) + err = MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId) CheckErr(err) - defer rows.Close() - for rows.Next() { - err = rows.Scan(&liveDifficultyId) - CheckErr(err) - + for _, id := range liveDifficultyId { normalLive := model.NormalLiveStatusList{ - LiveDifficultyID: liveDifficultyId, + LiveDifficultyID: id, Status: 1, HiScore: 0, HiComboCount: 0, @@ -131,16 +123,11 @@ func ApiHandler(ctx *gin.Context) { } specialLives := []model.SpecialLiveStatusList{} - sql = `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC` - rows, err = MainEng.DB().Query(sql) + err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId) CheckErr(err) - defer rows.Close() - for rows.Next() { - err = rows.Scan(&liveDifficultyId) - CheckErr(err) - + for _, id := range liveDifficultyId { specialLive := model.SpecialLiveStatusList{ - LiveDifficultyID: liveDifficultyId, + LiveDifficultyID: id, Status: 1, HiScore: 0, HiComboCount: 0, @@ -151,7 +138,7 @@ func ApiHandler(ctx *gin.Context) { } LiveStatusResp := model.LiveStatusResp{ - Result: model.LiveStatusResult{ + Result: model.LiveStatusRes{ NormalLiveStatusList: normalLives, SpecialLiveStatusList: specialLives, TrainingLiveStatusList: []model.TrainingLiveStatusList{}, @@ -167,18 +154,13 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) } else if v.Action == "schedule" { // key = "live_list_result" - var liveDifficultyId int + var liveDifficultyId []int specialLives := []model.SpecialLiveStatusList{} - sql := `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC` - rows, err := MainEng.DB().Query(sql) + err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId) CheckErr(err) - defer rows.Close() - for rows.Next() { - err = rows.Scan(&liveDifficultyId) - CheckErr(err) - + for _, id := range liveDifficultyId { specialLive := model.SpecialLiveStatusList{ - LiveDifficultyID: liveDifficultyId, + LiveDifficultyID: id, Status: 1, HiScore: 0, HiComboCount: 0, @@ -198,7 +180,7 @@ func ApiHandler(ctx *gin.Context) { }) } liveListResp := model.LiveScheduleResp{ - Result: model.LiveScheduleResult{ + Result: model.LiveScheduleRes{ EventList: []interface{}{}, LiveList: livesList, LimitedBonusList: []interface{}{}, @@ -229,11 +211,10 @@ func ApiHandler(ctx *gin.Context) { if err != nil { panic(err) } - unitsData = append(unitsData, userUnits...) unitListResp := model.UnitAllResp{ - Result: model.UnitAllResult{ + Result: model.UnitAllRes{ Active: unitsData, Waiting: []model.Waiting{}, }, @@ -246,10 +227,10 @@ func ApiHandler(ctx *gin.Context) { case "deckInfo": // key = "unit_deck_result" userDeck := []tools.UserDeckData{} - err = UserEng.Table("user_deck_m").Where("user_id = ?", userId).Asc("deck_id").Find(&userDeck) + err = UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck) CheckErr(err) - unitDeckInfo := []model.UnitDeckInfo{} + unitDeckInfo := []model.UnitDeckInfoRes{} for _, deck := range userDeck { deckUnit := []tools.UnitDeckData{} err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) @@ -267,7 +248,7 @@ func ApiHandler(ctx *gin.Context) { if deck.MainFlag == 1 { mainFlag = true } - unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ + unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{ UnitDeckID: deck.DeckID, MainFlag: mainFlag, DeckName: deck.DeckName, @@ -285,7 +266,7 @@ func ApiHandler(ctx *gin.Context) { case "supporterAll": // key = "unit_support_result" unitSupportResp := model.UnitSupportResp{ - Result: model.UnitSupportResult{ + Result: model.UnitSupportRes{ UnitSupportList: []model.UnitSupportList{}, }, // 练习道具 Status: 200, @@ -322,10 +303,6 @@ func ApiHandler(ctx *gin.Context) { owingInfo = append(owingInfo, info) } - // equipInfo := []model.SkillEquip{} - // err = UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Cols("unit_removable_skill_id,unit_owning_user_id").Find(&equipInfo) - // CheckErr(err) - var unitOwningIds []int err = UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Cols("unit_owning_user_id").GroupBy("unit_owning_user_id").Find(&unitOwningIds) CheckErr(err) @@ -344,7 +321,7 @@ func ApiHandler(ctx *gin.Context) { } rmSkillResp := model.RemovableSkillResp{ - Result: model.RemovableSkillResult{ + Result: model.RemovableSkillRes{ OwningInfo: owingInfo, EquipmentInfo: equipInfo, }, // 宝石 @@ -390,7 +367,7 @@ func ApiHandler(ctx *gin.Context) { case "costume": // key = "costume_list_result" costumeListResp := model.CostumeListResp{ - Result: model.CostumeListResult{ + Result: model.CostumeListRes{ CostumeList: []model.CostumeList{}, }, Status: 200, @@ -402,11 +379,10 @@ func ApiHandler(ctx *gin.Context) { case "album": // key = "album_unit_result" albumLists := []model.AlbumResult{} - sql := `SELECT unit_id,rarity FROM unit_m ORDER BY unit_id ASC` - rows, err := MainEng.DB().Query(sql) + unitList := []AlbumSearchResult{} + err = MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList) CheckErr(err) - defer rows.Close() - for rows.Next() { + for _, unit := range unitList { albumList := model.AlbumResult{ RankMaxFlag: true, LoveMaxFlag: true, @@ -414,22 +390,19 @@ func ApiHandler(ctx *gin.Context) { AllMaxFlag: true, FavoritePoint: 1000, } - var uid, rit int - err = rows.Scan(&uid, &rit) - CheckErr(err) - albumList.UnitID = uid - if rit != 4 { + albumList.UnitID = unit.UnitId + if unit.Rarity != 4 { albumList.SignFlag = false - if rit == 1 { + if unit.Rarity == 1 { albumList.HighestLovePerUnit = 50 albumList.TotalLove = 50 - } else if rit == 2 { + } else if unit.Rarity == 2 { albumList.HighestLovePerUnit = 200 albumList.TotalLove = 200 - } else if rit == 3 { + } else if unit.Rarity == 3 { albumList.HighestLovePerUnit = 500 albumList.TotalLove = 500 - } else if rit == 5 { + } else if unit.Rarity == 5 { albumList.HighestLovePerUnit = 750 albumList.TotalLove = 750 } @@ -437,19 +410,10 @@ func ApiHandler(ctx *gin.Context) { albumList.HighestLovePerUnit = 1000 albumList.TotalLove = 1000 - stmt, err := MainEng.DB().Prepare("SELECT COUNT(*) AS ct FROM unit_sign_asset_m WHERE unit_id = ?") + // IsSigned + exists, err := MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist() CheckErr(err) - defer stmt.Close() - - var count int - err = stmt.QueryRow(uid).Scan(&count) - CheckErr(err) - - if count > 0 { - albumList.SignFlag = true - } else { - albumList.SignFlag = false - } + albumList.SignFlag = exists } albumLists = append(albumLists, albumList) } @@ -464,22 +428,18 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) case "scenario": // key = "scenario_status_result" - sql := `SELECT scenario_id FROM scenario_m ORDER BY scenario_id ASC` - rows, err := MainEng.DB().Query(sql) - CheckErr(err) - defer rows.Close() + var scenarioIds []int scenarioLists := []model.ScenarioStatusList{} - for rows.Next() { - var sid int - err = rows.Scan(&sid) - CheckErr(err) + err = MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioIds) + CheckErr(err) + for _, id := range scenarioIds { scenarioLists = append(scenarioLists, model.ScenarioStatusList{ - ScenarioID: sid, + ScenarioID: id, Status: 2, }) } scenarioResp := model.ScenarioStatusResp{ - Result: model.ScenarioStatusResult{ + Result: model.ScenarioStatusRes{ ScenarioStatusList: scenarioLists, }, Status: 200, @@ -490,22 +450,18 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) case "subscenario": // key = "subscenario_status_result" - sql := `SELECT subscenario_id FROM subscenario_m ORDER BY subscenario_id ASC` - rows, err := MainEng.DB().Query(sql) - CheckErr(err) - defer rows.Close() + var subScenarioIds []int subScenarioLists := []model.SubscenarioStatusList{} - for rows.Next() { - var sid int - err = rows.Scan(&sid) - CheckErr(err) + err = MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioIds) + CheckErr(err) + for _, id := range subScenarioIds { subScenarioLists = append(subScenarioLists, model.SubscenarioStatusList{ - SubscenarioID: sid, + SubscenarioID: id, Status: 2, }) } subScenarioResp := model.SubscenarioStatusResp{ - Result: model.SubscenarioStatusResult{ + Result: model.SubscenarioStatusRes{ SubscenarioStatusList: subScenarioLists, UnlockedSubscenarioIds: []interface{}{}, }, @@ -517,18 +473,13 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) case "eventscenario": // key = "event_scenario_result" + var eventIds []int eventsList := []model.EventScenarioList{} - sql := `SELECT event_id FROM event_scenario_m GROUP BY event_id ORDER BY event_id DESC` - rows, err := MainEng.DB().Query(sql) + err = MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds) CheckErr(err) - defer rows.Close() - for rows.Next() { - var eventId int - err = rows.Scan(&eventId) - CheckErr(err) - - sql = `SELECT event_scenario_id,chapter,chapter_asset,open_date FROM event_scenario_m WHERE event_id = ? ORDER BY chapter DESC` - chaps, err := MainEng.DB().Query(sql, eventId) + for _, id := range eventIds { + sql := `SELECT event_scenario_id,chapter,chapter_asset,open_date FROM event_scenario_m WHERE event_id = ? ORDER BY chapter DESC` + chaps, err := MainEng.DB().Query(sql, id) CheckErr(err) defer chaps.Close() chapsList := []model.EventScenarioChapterList{} @@ -556,24 +507,24 @@ func ApiHandler(ctx *gin.Context) { } eventList := model.EventScenarioList{ - EventID: eventId, + EventID: id, OpenDate: strings.ReplaceAll(open_date, "/", "-"), ChapterList: chapsList, } // HACK event_scenario_btn_asset - if eventId == 10001 { + if id == 10001 { eventList.EventScenarioBtnAsset = "assets/image/ui/eventscenario/38_se_ba_t.png" - } else if eventId == 221 { + } else if id == 221 { eventList.EventScenarioBtnAsset = "assets/image/ui/eventscenario/215_se_ba_t.png" } else { - eventList.EventScenarioBtnAsset = fmt.Sprintf("assets/image/ui/eventscenario/%d_se_ba_t.png", eventId) + eventList.EventScenarioBtnAsset = fmt.Sprintf("assets/image/ui/eventscenario/%d_se_ba_t.png", id) } eventsList = append(eventsList, eventList) } eventScenarioResp := model.EventScenarioStatusResp{ - Result: model.EventScenarioStatusResult{ + Result: model.EventScenarioStatusRes{ EventScenarioList: eventsList, // }, Status: 200, @@ -584,18 +535,13 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) case "multiunit": // 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` - rows, err := MainEng.DB().Query(sql) - CheckErr(err) - defer rows.Close() - var mId int + var multiIds []int multiUnitsList := []model.MultiUnitScenarioStatusList{} - for rows.Next() { - err = rows.Scan(&mId) - CheckErr(err) - - sql = `SELECT multi_unit_scenario_btn_asset,open_date,multi_unit_scenario_id,chapter FROM multi_unit_scenario_m a LEFT JOIN multi_unit_scenario_open_m b ON a.multi_unit_id = b.multi_unit_id WHERE a.multi_unit_id = ?` - units, err := MainEng.DB().Query(sql, mId) + err = MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds) + CheckErr(err) + for _, id := range multiIds { + sql := `SELECT multi_unit_scenario_btn_asset,open_date,multi_unit_scenario_id,chapter FROM multi_unit_scenario_m a LEFT JOIN multi_unit_scenario_open_m b ON a.multi_unit_id = b.multi_unit_id WHERE a.multi_unit_id = ?` + units, err := MainEng.DB().Query(sql, id) CheckErr(err) defer units.Close() var multi_unit_scenario_id, chapter int @@ -606,7 +552,7 @@ func ApiHandler(ctx *gin.Context) { } multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{ - MultiUnitID: mId, + MultiUnitID: id, Status: 2, MultiUnitScenarioBtnAsset: multi_unit_scenario_btn_asset, OpenDate: strings.ReplaceAll(open_date, "/", "-"), @@ -620,7 +566,7 @@ func ApiHandler(ctx *gin.Context) { }) } unitsResp := model.MultiUnitScenarioStatusResp{ - Result: model.MultiUnitScenarioStatusResult{ + Result: model.MultiUnitScenarioStatusRes{ MultiUnitScenarioStatusList: multiUnitsList, UnlockedMultiUnitScenarioIds: []interface{}{}, }, @@ -633,7 +579,7 @@ func ApiHandler(ctx *gin.Context) { case "payment": // key = "product_result" productResp := model.ProductListResp{ - Result: model.ProductListResult{ + Result: model.ProductListRes{ RestrictionInfo: model.RestrictionInfo{ Restricted: false, }, @@ -657,7 +603,7 @@ func ApiHandler(ctx *gin.Context) { case "banner": // key = "banner_result" bannerResp := model.BannerListResp{ - Result: model.BannerListResult{ + Result: model.BannerListRes{ TimeLimit: "2037-12-31 23:59:59", BannerList: []model.BannerList{ { @@ -693,7 +639,7 @@ func ApiHandler(ctx *gin.Context) { case "notice": // key = "item_marquee_result" marqueeResp := model.NoticeMarqueeResp{ - Result: model.NoticeMarqueeResult{ + Result: model.NoticeMarqueeRes{ ItemCount: 0, MarqueeList: []interface{}{}, }, @@ -709,7 +655,7 @@ func ApiHandler(ctx *gin.Context) { _, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_id,unit_owning_user_id").Get(&uId, &oId) CheckErr(err) userIntroResp := model.UserNaviResp{ - Result: model.UserNaviResult{ + Result: model.UserNaviRes{ User: model.User{ UserID: uId, UnitOwningUserID: oId, @@ -724,7 +670,7 @@ func ApiHandler(ctx *gin.Context) { case "navigation": // key = "special_cutin_result" cutinResp := model.SpecialCutinResp{ - Result: model.SpecialCutinResult{ + Result: model.SpecialCutinRes{ SpecialCutinList: []interface{}{}, }, Status: 200, @@ -756,7 +702,7 @@ func ApiHandler(ctx *gin.Context) { } awardResp := model.AwardInfoResp{ - Result: model.AwardInfoResult{ + Result: model.AwardInfoRes{ AwardInfo: awardsList, }, Status: 200, @@ -788,7 +734,7 @@ func ApiHandler(ctx *gin.Context) { } backgroundResp := model.BackgroundInfoResp{ - Result: model.BackgroundInfoResult{ + Result: model.BackgroundInfoRes{ BackgroundInfo: backgroundsList, }, Status: 200, @@ -807,22 +753,18 @@ func ApiHandler(ctx *gin.Context) { CheckErr(err) case "exchange": // key = "exchange_point_result" - sql := `SELECT exchange_point_id FROM exchange_point_m ORDER BY exchange_point_id ASC` - rows, err := MainEng.DB().Query(sql) - CheckErr(err) - defer rows.Close() + var exchangeIds []int exPointsList := []model.ExchangePointList{} - for rows.Next() { - var eId int - err = rows.Scan(&eId) - CheckErr(err) + err = MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeIds) + CheckErr(err) + for _, id := range exchangeIds { exPointsList = append(exPointsList, model.ExchangePointList{ - Rarity: eId, + Rarity: id, ExchangePoint: 9999, }) } exPointsResp := model.ExchangePointResp{ - Result: model.ExchangePointResult{ + Result: model.ExchangePointRes{ ExchangePointList: exPointsList, }, Status: 200, @@ -834,7 +776,7 @@ func ApiHandler(ctx *gin.Context) { case "livese": // key = "live_se_result" liveSeResp := model.LiveSeInfoResp{ - Result: model.LiveSeInfoResult{ + Result: model.LiveSeInfoRes{ LiveSeList: []int{1, 2, 3}, }, Status: 200, @@ -846,7 +788,7 @@ func ApiHandler(ctx *gin.Context) { case "liveicon": // key = "live_icon_result" liveIconResp := model.LiveIconInfoResp{ - Result: model.LiveIconInfoResult{ + Result: model.LiveIconInfoRes{ LiveNotesIconList: []int{1, 2, 3}, }, Status: 200, @@ -902,9 +844,9 @@ func ApiHandler(ctx *gin.Context) { } museumInfoResp := model.MuseumInfoResp{ - Result: model.MuseumInfoResult{ - MuseumInfo: model.MuseumInfo{ - Parameter: model.MuseumInfoParameter{ + Result: model.MuseumInfoRes{ + MuseumInfo: model.Museum{ + Parameter: model.MuseumParameter{ Smile: smileBuf, Pure: pureBuf, Cool: coolBuf, @@ -1139,7 +1081,7 @@ func ApiHandler(ctx *gin.Context) { // fmt.Println(results) b, err := json.Marshal(results) CheckErr(err) - rp := model.Response{ + rp := model.ApiResp{ ResponseData: b, ReleaseInfo: []interface{}{}, StatusCode: 200, diff --git a/handler/download.go b/handler/download.go index 3048693..1bf8954 100644 --- a/handler/download.go +++ b/handler/download.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "honoka-chan/config" "honoka-chan/encrypt" "honoka-chan/model" "net/http" @@ -21,12 +22,12 @@ type PkgInfo struct { Size int `xorm:"pkg_size"` } -func DownloadAdditionalHandler(ctx *gin.Context) { +func DownloadAdditional(ctx *gin.Context) { downloadReq := model.AdditionalReq{} if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { panic(err) } - pkgList := []model.AdditionalResult{} + pkgList := []model.AdditionalRes{} if CdnUrl != "" { pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID var pkgInfo []PkgInfo @@ -36,7 +37,7 @@ func DownloadAdditionalHandler(ctx *gin.Context) { CheckErr(err) for _, pkg := range pkgInfo { - pkgList = append(pkgList, model.AdditionalResult{ + pkgList = append(pkgList, model.AdditionalRes{ Size: pkg.Size, URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order), }) @@ -61,13 +62,13 @@ func DownloadAdditionalHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func DownloadBatchHandler(ctx *gin.Context) { +func DownloadBatch(ctx *gin.Context) { downloadReq := model.BatchReq{} if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { panic(err) } - pkgList := []model.BatchResult{} - if downloadReq.ClientVersion == PackageVersion && CdnUrl != "" { + pkgList := []model.BatchRes{} + if downloadReq.ClientVersion == config.PackageVersion && CdnUrl != "" { pkgType := downloadReq.PackageType var pkgInfo []PkgInfo err := MainEng.Table("download_m").Where(builder.NotIn("pkg_id", downloadReq.ExcludedPackageIds)).Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.Os). @@ -76,7 +77,7 @@ func DownloadBatchHandler(ctx *gin.Context) { CheckErr(err) for _, pkg := range pkgInfo { - pkgList = append(pkgList, model.BatchResult{ + pkgList = append(pkgList, model.BatchRes{ Size: pkg.Size, URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.Os, pkgType, pkg.Id, pkg.Order), }) @@ -101,13 +102,13 @@ func DownloadBatchHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func DownloadUpdateHandler(ctx *gin.Context) { +func DownloadUpdate(ctx *gin.Context) { downloadReq := model.UpdateReq{} if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { panic(err) } - pkgList := []model.UpdateResult{} - if downloadReq.ExternalVersion != PackageVersion && CdnUrl != "" { + pkgList := []model.UpdateRes{} + if downloadReq.ExternalVersion != config.PackageVersion && CdnUrl != "" { pkgType := 99 var pkgInfo []PkgInfo err := MainEng.Table("download_m").Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.TargetOs). @@ -116,10 +117,10 @@ func DownloadUpdateHandler(ctx *gin.Context) { CheckErr(err) for _, pkg := range pkgInfo { - pkgList = append(pkgList, model.UpdateResult{ + pkgList = append(pkgList, model.UpdateRes{ Size: pkg.Size, URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order), - Version: PackageVersion, + Version: config.PackageVersion, }) } } @@ -142,7 +143,7 @@ func DownloadUpdateHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func DownloadUrlHandler(ctx *gin.Context) { +func DownloadUrl(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_m ORDER BY pkg_type ASC,pkg_id ASC, pkg_order ASC; // Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done downloadReq := model.UrlReq{} @@ -154,7 +155,7 @@ func DownloadUrlHandler(ctx *gin.Context) { urlList = append(urlList, fmt.Sprintf("%s/%s/extracted/%s", CdnUrl, downloadReq.Os, strings.ReplaceAll(v, "\\", ""))) } urlResp := model.UrlResp{ - ResponseData: model.UrlResult{ + ResponseData: model.UrlRes{ UrlList: urlList, }, ReleaseInfo: []interface{}{}, @@ -173,7 +174,7 @@ func DownloadUrlHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func DownloadEventHandler(ctx *gin.Context) { +func DownloadEvent(ctx *gin.Context) { eventResp := model.EventResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, diff --git a/handler/event.go b/handler/event.go index f1da4a1..d47ff20 100644 --- a/handler/event.go +++ b/handler/event.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func EventListHandler(ctx *gin.Context) { +func EventList(ctx *gin.Context) { targets := []model.TargetList{} for i := 0; i < 6; i++ { targets = append(targets, model.TargetList{ diff --git a/handler/gdpr.go b/handler/gdpr.go index edd76e9..8941a4d 100644 --- a/handler/gdpr.go +++ b/handler/gdpr.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func GdprHandler(ctx *gin.Context) { +func Gdpr(ctx *gin.Context) { gdprResp := model.GdprResp{ ResponseData: model.GdprRes{ EnableGdpr: true, diff --git a/handler/global.go b/handler/global.go index d65c150..b5b27d3 100644 --- a/handler/global.go +++ b/handler/global.go @@ -7,12 +7,10 @@ import ( ) var ( - // nonce = 0 - PackageVersion = "97.4.6" - CdnUrl string - ErrorMsg = `{"code":20001,"message":""}` - MainEng *xorm.Engine - UserEng *xorm.Engine + CdnUrl string + ErrorMsg = `{"code":20001,"message":""}` + MainEng *xorm.Engine + UserEng *xorm.Engine ) func init() { diff --git a/handler/lbonus.go b/handler/lbonus.go index 9e61f16..2f6d50f 100644 --- a/handler/lbonus.go +++ b/handler/lbonus.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func LBonusExecuteHandler(ctx *gin.Context) { +func LBonusExecute(ctx *gin.Context) { weeks := map[string]int{ "Monday": 1, "Tuesday": 2, @@ -142,7 +142,7 @@ func LBonusExecuteHandler(ctx *gin.Context) { }, }, LimitedEffortBox: []interface{}{}, - MuseumInfo: model.MuseumInfo{}, + MuseumInfo: model.Museum{}, ServerTimestamp: time.Now().Unix(), PresentCnt: 0, }, diff --git a/handler/live.go b/handler/live.go index 9fb580e..1957cc1 100644 --- a/handler/live.go +++ b/handler/live.go @@ -18,13 +18,7 @@ import ( "github.com/tidwall/gjson" ) -type GameOverResp struct { - ResponseData []interface{} `json:"response_data"` - ReleaseInfo []interface{} `json:"release_info"` - StatusCode int `json:"status_code"` -} - -func PartyListHandler(ctx *gin.Context) { +func PartyList(ctx *gin.Context) { resp := utils.ReadAllText("assets/partylist.json") nonce := ctx.GetInt("nonce") @@ -37,7 +31,7 @@ func PartyListHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func PlayLiveHandler(ctx *gin.Context) { +func PlayLive(ctx *gin.Context) { playReq := model.PlayReq{} err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playReq) CheckErr(err) @@ -402,44 +396,38 @@ func PlayLiveHandler(ctx *gin.Context) { }, }) - resp := model.PlayResponseData{ - RankInfo: ranks, - EnergyFullTime: "2023-03-20 01:28:55", - OverMaxEnergy: 0, - AvailableLiveResume: false, - LiveList: lives, - IsMarathonEvent: false, - MarathonEventID: nil, - NoSkill: false, - CanActivateEffect: true, - ServerTimestamp: time.Now().Unix(), + playResp := model.PlayResp{ + ResponseData: model.PlayRes{ + RankInfo: ranks, + EnergyFullTime: "2023-03-20 01:28:55", + OverMaxEnergy: 0, + AvailableLiveResume: false, + LiveList: lives, + IsMarathonEvent: false, + MarathonEventID: nil, + NoSkill: false, + CanActivateEffect: true, + ServerTimestamp: time.Now().Unix(), + }, + ReleaseInfo: []interface{}{}, + StatusCode: 200, } - m, err := json.Marshal(resp) + resp, err := json.Marshal(playResp) CheckErr(err) - res := model.Response{ - ResponseData: m, - ReleaseInfo: []interface{}{}, - StatusCode: 200, - } - - mm, err := json.Marshal(res) - CheckErr(err) - // fmt.Println(string(mm)) - 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(mm, "privatekey.pem"))) + ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem"))) - ctx.String(http.StatusOK, string(mm)) + ctx.String(http.StatusOK, string(resp)) } -func GameOverHandler(ctx *gin.Context) { - overResp := GameOverResp{ +func GameOver(ctx *gin.Context) { + overResp := model.GameOverResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, StatusCode: 200, @@ -457,7 +445,7 @@ func GameOverHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func PlayScoreHandler(ctx *gin.Context) { +func PlayScore(ctx *gin.Context) { playScoreReq := model.PlayScoreReq{} err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playScoreReq) CheckErr(err) @@ -506,56 +494,50 @@ func PlayScoreHandler(ctx *gin.Context) { RankMax: 0, }) - resp := model.PlayScoreResponseData{ - On: model.On{ - HasRecord: false, - LiveInfo: model.LiveInfo{ - LiveDifficultyID: difficultyId, - IsRandom: false, - AcFlag: ac_flag, - SwingFlag: swing_flag, - NotesList: notes, + playResp := model.PlayScoreResp{ + ResponseData: model.PlayScoreRes{ + On: model.On{ + HasRecord: false, + LiveInfo: model.LiveInfo{ + LiveDifficultyID: difficultyId, + IsRandom: false, + AcFlag: ac_flag, + SwingFlag: swing_flag, + NotesList: notes, + }, }, - }, - Off: model.Off{ - HasRecord: false, - LiveInfo: model.LiveInfo{ - LiveDifficultyID: difficultyId, - IsRandom: false, - AcFlag: ac_flag, - SwingFlag: swing_flag, - NotesList: notes, + Off: model.Off{ + HasRecord: false, + LiveInfo: model.LiveInfo{ + LiveDifficultyID: difficultyId, + IsRandom: false, + AcFlag: ac_flag, + SwingFlag: swing_flag, + NotesList: notes, + }, }, + RankInfo: ranks, + CanActivateEffect: true, + ServerTimestamp: int(time.Now().Unix()), }, - RankInfo: ranks, - CanActivateEffect: true, - ServerTimestamp: int(time.Now().Unix()), + ReleaseInfo: []interface{}{}, + StatusCode: 200, } - m, err := json.Marshal(resp) + resp, err := json.Marshal(playResp) CheckErr(err) - res := model.Response{ - ResponseData: m, - ReleaseInfo: []interface{}{}, - StatusCode: 200, - } - - mm, err := json.Marshal(res) - CheckErr(err) - // fmt.Println(string(mm)) - 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(mm, "privatekey.pem"))) + ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem"))) - ctx.String(http.StatusOK, string(mm)) + ctx.String(http.StatusOK, string(resp)) } -func PlayRewardHandler(ctx *gin.Context) { +func PlayReward(ctx *gin.Context) { playRewardReq := model.PlayRewardReq{} err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playRewardReq) CheckErr(err) @@ -578,172 +560,166 @@ func PlayRewardHandler(ctx *gin.Context) { CheckErr(err) totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute - resp := model.RewardResponseData{ - LiveInfo: []model.RewardLiveInfo{ - { - LiveDifficultyID: difficultyId, - IsRandom: false, - AcFlag: ac_flag, - SwingFlag: swing_flag, + playResp := model.RewardResp{ + ResponseData: model.RewardRes{ + LiveInfo: []model.RewardLiveInfo{ + { + LiveDifficultyID: difficultyId, + IsRandom: false, + AcFlag: ac_flag, + SwingFlag: swing_flag, + }, }, - }, - TotalLove: 0, - IsHighScore: true, - HiScore: totalScore, - BaseRewardInfo: model.BaseRewardInfo{ - PlayerExp: 830, - PlayerExpUnitMax: model.PlayerExpUnitMax{ - Before: 900, - After: 900, + TotalLove: 0, + IsHighScore: true, + HiScore: totalScore, + BaseRewardInfo: model.BaseRewardInfo{ + PlayerExp: 830, + PlayerExpUnitMax: model.PlayerExpUnitMax{ + Before: 900, + After: 900, + }, + PlayerExpFriendMax: model.PlayerExpFriendMax{ + Before: 99, + After: 99, + }, + PlayerExpLpMax: model.PlayerExpLpMax{ + Before: 417, + After: 417, + }, + GameCoin: 4500, + GameCoinRewardBoxFlag: false, + SocialPoint: 10, }, - PlayerExpFriendMax: model.PlayerExpFriendMax{ - Before: 99, - After: 99, + RewardUnitList: model.RewardUnitList{ + LiveClear: []model.LiveClear{}, + LiveRank: []model.LiveRank{}, + LiveCombo: []interface{}{}, }, - PlayerExpLpMax: model.PlayerExpLpMax{ - Before: 417, - After: 417, + UnlockedSubscenarioIds: []interface{}{}, + UnlockedMultiUnitScenarioIds: []interface{}{}, + EffortPoint: []model.EffortPoint{}, + IsEffortPointVisible: false, + LimitedEffortBox: []interface{}{}, + UnitList: unitsList, + BeforeUserInfo: model.BeforeUserInfo{ + Level: 1028, + Exp: 28823566, + PreviousExp: 27734700, + NextExp: 28941885, + GameCoin: 86505544, + SnsCoin: 49, + FreeSnsCoin: 48, + PaidSnsCoin: 1, + SocialPoint: 1438165, + UnitMax: 5000, + WaitingUnitMax: 1000, + CurrentEnergy: 392, + EnergyMax: 417, + TrainingEnergy: 9, + TrainingEnergyMax: 10, + EnergyFullTime: "2023-03-20 01:28:55", + LicenseLiveEnergyRecoverlyTime: 60, + FriendMax: 99, + TutorialState: -1, + OverMaxEnergy: 0, + UnlockRandomLiveMuse: 1, + UnlockRandomLiveAqours: 1, }, - GameCoin: 4500, - GameCoinRewardBoxFlag: false, - SocialPoint: 10, - }, - RewardUnitList: model.RewardUnitList{ - LiveClear: []model.LiveClear{}, - LiveRank: []model.LiveRank{}, - LiveCombo: []interface{}{}, - }, - UnlockedSubscenarioIds: []interface{}{}, - UnlockedMultiUnitScenarioIds: []interface{}{}, - EffortPoint: []model.EffortPoint{}, - IsEffortPointVisible: false, - LimitedEffortBox: []interface{}{}, - UnitList: unitsList, - BeforeUserInfo: model.BeforeUserInfo{ - Level: 1028, - Exp: 28823566, - PreviousExp: 27734700, - NextExp: 28941885, - GameCoin: 86505544, - SnsCoin: 49, - FreeSnsCoin: 48, - PaidSnsCoin: 1, - SocialPoint: 1438165, - UnitMax: 5000, - WaitingUnitMax: 1000, - CurrentEnergy: 392, - EnergyMax: 417, - TrainingEnergy: 9, - TrainingEnergyMax: 10, - EnergyFullTime: "2023-03-20 01:28:55", - LicenseLiveEnergyRecoverlyTime: 60, - FriendMax: 99, - TutorialState: -1, - OverMaxEnergy: 0, - UnlockRandomLiveMuse: 1, - UnlockRandomLiveAqours: 1, - }, - AfterUserInfo: model.AfterUserInfo{ - Level: 1028, - Exp: 28824396, - PreviousExp: 27734700, - NextExp: 28941885, - GameCoin: 86520044, - SnsCoin: 50, - FreeSnsCoin: 49, - PaidSnsCoin: 1, - SocialPoint: 1438375, - UnitMax: 5000, - WaitingUnitMax: 1000, - CurrentEnergy: 392, - EnergyMax: 417, - TrainingEnergy: 9, - TrainingEnergyMax: 10, - EnergyFullTime: "2023-03-20 01:28:55", - LicenseLiveEnergyRecoverlyTime: 60, - FriendMax: 99, - TutorialState: -1, - OverMaxEnergy: 0, - UnlockRandomLiveMuse: 1, - UnlockRandomLiveAqours: 1, - }, - NextLevelInfo: []model.NextLevelInfo{ - { - Level: 1028, - FromExp: 28823566, + AfterUserInfo: model.AfterUserInfo{ + Level: 1028, + Exp: 28824396, + PreviousExp: 27734700, + NextExp: 28941885, + GameCoin: 86520044, + SnsCoin: 50, + FreeSnsCoin: 49, + PaidSnsCoin: 1, + SocialPoint: 1438375, + UnitMax: 5000, + WaitingUnitMax: 1000, + CurrentEnergy: 392, + EnergyMax: 417, + TrainingEnergy: 9, + TrainingEnergyMax: 10, + EnergyFullTime: "2023-03-20 01:28:55", + LicenseLiveEnergyRecoverlyTime: 60, + FriendMax: 99, + TutorialState: -1, + OverMaxEnergy: 0, + UnlockRandomLiveMuse: 1, + UnlockRandomLiveAqours: 1, }, - }, - GoalAccompInfo: model.GoalAccompInfo{ - AchievedIds: []interface{}{}, - Rewards: []interface{}{}, - }, - SpecialRewardInfo: []interface{}{}, - EventInfo: []interface{}{}, - DailyRewardInfo: []interface{}{}, - CanSendFriendRequest: false, - UsingBuffInfo: []interface{}{}, - ClassSystem: model.ClassSystem{ - RankInfo: model.RewardRankInfo{ - BeforeClassRankID: 10, - AfterClassRankID: 10, - RankUpDate: "2020-02-12 11:57:15", + NextLevelInfo: []model.NextLevelInfo{ + { + Level: 1028, + FromExp: 28823566, + }, }, - CompleteFlag: false, - IsOpened: true, - IsVisible: true, + GoalAccompInfo: model.GoalAccompInfo{ + AchievedIds: []interface{}{}, + Rewards: []interface{}{}, + }, + SpecialRewardInfo: []interface{}{}, + EventInfo: []interface{}{}, + DailyRewardInfo: []interface{}{}, + CanSendFriendRequest: false, + UsingBuffInfo: []interface{}{}, + ClassSystem: model.ClassSystem{ + RankInfo: model.RewardRankInfo{ + BeforeClassRankID: 10, + AfterClassRankID: 10, + RankUpDate: "2020-02-12 11:57:15", + }, + CompleteFlag: false, + IsOpened: true, + IsVisible: true, + }, + AccomplishedAchievementList: []model.AccomplishedAchievementList{}, + UnaccomplishedAchievementCnt: 15, + AddedAchievementList: []interface{}{}, + MuseumInfo: model.Museum{}, + UnitSupportList: []model.RewardUnitSupportList{}, + ServerTimestamp: 1679238066, + PresentCnt: 2159, }, - AccomplishedAchievementList: []model.AccomplishedAchievementList{}, - UnaccomplishedAchievementCnt: 15, - AddedAchievementList: []interface{}{}, - MuseumInfo: model.RewardMuseumInfo{}, - UnitSupportList: []model.RewardUnitSupportList{}, - ServerTimestamp: 1679238066, - PresentCnt: 2159, + ReleaseInfo: []interface{}{}, + StatusCode: 200, } if playRewardReq.MaxCombo > s_rank_combo { - resp.ComboRank = 1 + playResp.ResponseData.ComboRank = 1 } else if playRewardReq.MaxCombo > a_rank_combo { - resp.ComboRank = 2 + playResp.ResponseData.ComboRank = 2 } else if playRewardReq.MaxCombo > b_rank_combo { - resp.ComboRank = 3 + playResp.ResponseData.ComboRank = 3 } else if playRewardReq.MaxCombo > c_rank_combo { - resp.ComboRank = 4 + playResp.ResponseData.ComboRank = 4 } else { - resp.ComboRank = 5 + playResp.ResponseData.ComboRank = 5 } if totalScore > s_rank_score { - resp.Rank = 1 + playResp.ResponseData.Rank = 1 } else if totalScore > a_rank_score { - resp.Rank = 2 + playResp.ResponseData.Rank = 2 } else if totalScore > b_rank_score { - resp.Rank = 3 + playResp.ResponseData.Rank = 3 } else if totalScore > c_rank_score { - resp.Rank = 4 + playResp.ResponseData.Rank = 4 } else { - resp.Rank = 5 + playResp.ResponseData.Rank = 5 } - m, err := json.Marshal(resp) + resp, err := json.Marshal(playResp) CheckErr(err) - res := model.Response{ - ResponseData: m, - ReleaseInfo: []interface{}{}, - StatusCode: 200, - } - - mm, err := json.Marshal(res) - CheckErr(err) - // fmt.Println(string(mm)) - 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(mm, "privatekey.pem"))) + ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem"))) - ctx.String(http.StatusOK, string(mm)) + ctx.String(http.StatusOK, string(resp)) } diff --git a/handler/multiunit.go b/handler/multiunit.go index ac3a04c..7af77bf 100644 --- a/handler/multiunit.go +++ b/handler/multiunit.go @@ -32,7 +32,7 @@ type MultiUnitStartUpReq struct { CommandNum string `json:"commandNum"` } -func MultiUnitStartUpHandler(ctx *gin.Context) { +func MultiUnitStartUp(ctx *gin.Context) { startReq := MultiUnitStartUpReq{} err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) CheckErr(err) diff --git a/handler/notice.go b/handler/notice.go index 59b3bc5..a5006d3 100644 --- a/handler/notice.go +++ b/handler/notice.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func NoticeFriendVarietyHandler(ctx *gin.Context) { +func NoticeFriendVariety(ctx *gin.Context) { noticeResp := model.NoticeFriendVarietyResp{ ResponseData: model.NoticeFriendVarietyRes{ ItemCount: 1, @@ -35,7 +35,7 @@ func NoticeFriendVarietyHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func NoticeFriendGreetingHandler(ctx *gin.Context) { +func NoticeFriendGreeting(ctx *gin.Context) { noticeResp := model.NoticeFriendGreetingResp{ ResponseData: model.NoticeFriendGreetingRes{ NextId: 0, @@ -58,7 +58,7 @@ func NoticeFriendGreetingHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func NoticeUserGreetingHandler(ctx *gin.Context) { +func NoticeUserGreeting(ctx *gin.Context) { noticeResp := model.NoticeUserGreetingResp{ ResponseData: model.NoticeUserGreetingRes{ ItemCount: 0, diff --git a/handler/payment.go b/handler/payment.go index b5292ef..b7f5ffc 100644 --- a/handler/payment.go +++ b/handler/payment.go @@ -35,7 +35,7 @@ type ProductData struct { ServerTimestamp int64 `json:"server_timestamp"` } -func ProductListHandler(ctx *gin.Context) { +func ProductList(ctx *gin.Context) { prodReesp := ProductResp{ ResponseData: ProductData{ RestrictionInfo: RestrictionInfo{ diff --git a/handler/personalnotice.go b/handler/personalnotice.go index ddf3ff3..4032e17 100644 --- a/handler/personalnotice.go +++ b/handler/personalnotice.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func PersonalNoticeHandler(ctx *gin.Context) { +func PersonalNotice(ctx *gin.Context) { noticeResp := model.PersonalNoticeResp{ ResponseData: model.PersonalNoticeRes{ HasNotice: false, diff --git a/handler/private.go b/handler/private.go index b7d862b..c6fa831 100644 --- a/handler/private.go +++ b/handler/private.go @@ -88,7 +88,7 @@ type InitializeResp struct { WeixinKey string `json:"weixin_key"` } -func ActiveHandler(ctx *gin.Context) { +func Active(ctx *gin.Context) { // body, err := io.ReadAll(ctx.Request.Body) // CheckErr(err) // defer ctx.Request.Body.Close() @@ -98,7 +98,7 @@ func ActiveHandler(ctx *gin.Context) { ctx.String(http.StatusOK, `{ "code": 0, "msg": "ok", "data": { "message": "ok", "result": 0 } }`) } -func PublicKeyHandler(ctx *gin.Context) { +func PublicKey(ctx *gin.Context) { publicKey := utils.ReadAllText("publickey.pem") publicKey = strings.ReplaceAll(publicKey, "\n", "") publicKey = strings.ReplaceAll(publicKey, "-----BEGIN PUBLIC KEY-----", "") @@ -110,7 +110,7 @@ func PublicKeyHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func HandshakeHandler(ctx *gin.Context) { +func Handshake(ctx *gin.Context) { body, err := io.ReadAll(ctx.Request.Body) CheckErr(err) defer ctx.Request.Body.Close() @@ -148,7 +148,7 @@ func HandshakeHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func InitializeHandler(ctx *gin.Context) { +func Initialize(ctx *gin.Context) { // body, err := io.ReadAll(ctx.Request.Body) // CheckErr(err) // defer ctx.Request.Body.Close() @@ -191,13 +191,13 @@ func InitializeHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func GetCodeHandler(ctx *gin.Context) { +func GetCode(ctx *gin.Context) { resp := `{ "code": 0, "msg": "ok", "data": { "codeArray": [ { "btntext": "好的", "code": "-10264022", "msg_from": 2, "text": "", "title": "短信验证码被阻止", "type": 1 }, { "btntext": " ", "code": "-10869623", "msg_from": 2, "text": "", "title": "网络连接失败,无法一键登录", "type": 2 }, { "btntext": " ", "code": "10298300", "msg_from": 2, "text": "", "title": " ", "type": 3 }, { "btntext": "", "code": "10298311", "msg_from": 2, "text": "", "title": "", "type": 3 }, { "btntext": " ", "code": "10298312", "msg_from": 2, "text": "", "title": " ", "type": 3 }, { "btntext": " ", "code": "10298313", "msg_from": 2, "text": "", "title": " ", "type": 1 }, { "btntext": " ", "code": "10298321", "msg_from": 2, "text": "", "title": " ", "type": 3 }, { "btntext": " ", "code": "10298322", "msg_from": 2, "text": "", "title": " ", "type": 3 } ], "codeVersion": "1.0.5" } }` ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.String(http.StatusOK, resp) } -func LoginAutoHandler(ctx *gin.Context) { +func LoginAuto(ctx *gin.Context) { body, err := io.ReadAll(ctx.Request.Body) CheckErr(err) defer ctx.Request.Body.Close() @@ -265,7 +265,7 @@ func LoginAutoHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func LoginAreaHandler(ctx *gin.Context) { +func LoginArea(ctx *gin.Context) { userId := ctx.PostForm("userid") if userId != "" { // fmt.Println(userId) @@ -275,7 +275,7 @@ func LoginAreaHandler(ctx *gin.Context) { } } -func AccountLoginHandler(ctx *gin.Context) { +func AccountLogin(ctx *gin.Context) { body, err := io.ReadAll(ctx.Request.Body) CheckErr(err) defer ctx.Request.Body.Close() @@ -434,7 +434,7 @@ func AccountLoginHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func ReportRoleHandler(ctx *gin.Context) { +func ReportRole(ctx *gin.Context) { // body, err := io.ReadAll(ctx.Request.Body) // CheckErr(err) // defer ctx.Request.Body.Close() @@ -469,13 +469,13 @@ func ReportRoleHandler(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func GetProductListHandler(ctx *gin.Context) { +func GetProductList(ctx *gin.Context) { resp := `{ "code": 0, "msg": "ok", "data": { "message": [ ], "result": 0 } }` ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.String(http.StatusOK, resp) } -func GuestStatusHandler(ctx *gin.Context) { +func GuestStatus(ctx *gin.Context) { resp := `{"code":0,"msg":"ok","data":{"disablead":1,"loginswitch":1,"message":"ok","result":0}}` ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.String(http.StatusOK, resp) @@ -500,7 +500,7 @@ func ReportApp(ctx *gin.Context) { ctx.String(http.StatusOK, resp) } -func AgreementHandler(ctx *gin.Context) { +func Agreement(ctx *gin.Context) { resp := `{ "return_code": 0, "error_type": 0, "return_message": "", "data": { } }` ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.String(http.StatusOK, resp) diff --git a/handler/scenario.go b/handler/scenario.go index 156be63..0d383ee 100644 --- a/handler/scenario.go +++ b/handler/scenario.go @@ -33,7 +33,7 @@ type ScenarioReq struct { ScenarioID int `json:"scenario_id"` } -func ScenarioStartupHandler(ctx *gin.Context) { +func ScenarioStartup(ctx *gin.Context) { startReq := ScenarioReq{} err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) CheckErr(err) @@ -62,7 +62,7 @@ func ScenarioStartupHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func ScenarioRewardHandler(ctx *gin.Context) { +func ScenarioReward(ctx *gin.Context) { resp := utils.ReadAllText("assets/reward.json") nonce := ctx.GetInt("nonce") diff --git a/handler/subscenario.go b/handler/subscenario.go index e11a10b..e69a28b 100644 --- a/handler/subscenario.go +++ b/handler/subscenario.go @@ -33,7 +33,7 @@ type SubScenarioReq struct { CommandNum string `json:"commandNum"` } -func SubScenarioStartupHandler(ctx *gin.Context) { +func SubScenarioStartup(ctx *gin.Context) { startReq := SubScenarioReq{} err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) CheckErr(err) @@ -60,7 +60,7 @@ func SubScenarioStartupHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func SubScenarioRewardHandler(ctx *gin.Context) { +func SubScenarioReward(ctx *gin.Context) { resp := utils.ReadAllText("assets/subreward.json") nonce := ctx.GetInt("nonce") diff --git a/handler/tos.go b/handler/tos.go index c28dc44..9fd23bd 100644 --- a/handler/tos.go +++ b/handler/tos.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -func TosCheckHandler(ctx *gin.Context) { +func TosCheck(ctx *gin.Context) { tosResp := model.TosResp{ ResponseData: model.TosRes{ TosID: 1, diff --git a/handler/unit.go b/handler/unit.go index f97b4c0..5868ed4 100644 --- a/handler/unit.go +++ b/handler/unit.go @@ -4,12 +4,9 @@ import ( "encoding/base64" "encoding/json" "fmt" - "honoka-chan/config" - "honoka-chan/database" "honoka-chan/encrypt" "honoka-chan/model" "honoka-chan/tools" - "honoka-chan/utils" "net/http" "strconv" "time" @@ -17,62 +14,26 @@ import ( "github.com/gin-gonic/gin" ) -type SetDisplayRankResp struct { - ResponseData []interface{} `json:"response_data"` - ReleaseInfo []interface{} `json:"release_info"` - StatusCode int `json:"status_code"` -} - -func SetDisplayRankHandler(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) - - dispResp := SetDisplayRankResp{ +func SetDisplayRank(ctx *gin.Context) { + dispResp := model.SetDisplayRankResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, StatusCode: 200, } resp, err := json.Marshal(dispResp) CheckErr(err) - xms := encrypt.RSA_Sign_SHA1(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) + 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)) } -func SetDeckHandler(ctx *gin.Context) { +func SetDeck(ctx *gin.Context) { userId, err := strconv.Atoi(ctx.GetString("userid")) CheckErr(err) @@ -197,7 +158,7 @@ func SetDeckHandler(ctx *gin.Context) { panic(err) } - dispResp := SetDisplayRankResp{ + dispResp := model.SetDeckResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, StatusCode: 200, @@ -215,7 +176,7 @@ func SetDeckHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func SetDeckNameHandler(ctx *gin.Context) { +func SetDeckName(ctx *gin.Context) { userId, err := strconv.Atoi(ctx.GetString("userid")) CheckErr(err) @@ -239,7 +200,7 @@ func SetDeckNameHandler(ctx *gin.Context) { }) CheckErr(err) - dispResp := SetDisplayRankResp{ + dispResp := model.SetDeckResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, StatusCode: 200, diff --git a/handler/user.go b/handler/user.go index bfa8964..dd616c5 100644 --- a/handler/user.go +++ b/handler/user.go @@ -20,7 +20,7 @@ type NotificationResp struct { StatusCode int `json:"status_code"` } -func SetNotificationTokenHandler(ctx *gin.Context) { +func SetNotificationToken(ctx *gin.Context) { notifResp := NotificationResp{ ResponseData: []interface{}{}, ReleaseInfo: []interface{}{}, @@ -39,7 +39,7 @@ func SetNotificationTokenHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func ChangeNaviHandler(ctx *gin.Context) { +func ChangeNavi(ctx *gin.Context) { req := gjson.Parse(ctx.PostForm("request_data")) pref := tools.UserPref{ UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()), @@ -64,7 +64,7 @@ func ChangeNaviHandler(ctx *gin.Context) { ctx.String(http.StatusOK, string(resp)) } -func ChangeNameHandler(ctx *gin.Context) { +func ChangeName(ctx *gin.Context) { req := gjson.Parse(ctx.PostForm("request_data")) var oldName string exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_name").Get(&oldName) diff --git a/handler/userinfo.go b/handler/userinfo.go index 84ed294..8ec3b69 100644 --- a/handler/userinfo.go +++ b/handler/userinfo.go @@ -13,7 +13,7 @@ import ( "github.com/gin-gonic/gin" ) -func UserInfoHandler(ctx *gin.Context) { +func UserInfo(ctx *gin.Context) { userId, err := strconv.Atoi(ctx.GetString("userid")) CheckErr(err) diff --git a/main.go b/main.go index 5c461df..749dc37 100644 --- a/main.go +++ b/main.go @@ -1,19 +1,17 @@ package main import ( - "honoka-chan/config" "honoka-chan/handler" _ "honoka-chan/llhelper" "honoka-chan/middleware" _ "honoka-chan/tools" - "honoka-chan/xclog" "net/http" "github.com/gin-gonic/gin" ) func init() { - xclog.Init(config.Conf.Log.LogDir, "", config.Conf.Log.LogLevel, config.Conf.Log.LogSave) + } func main() { @@ -30,20 +28,20 @@ func main() { // Private APIs v1 := r.Group("v1") { - v1.GET("/basic/getcode", handler.GetCodeHandler) - v1.POST("/basic/getcode", handler.GetCodeHandler) - v1.POST("/account/active", handler.ActiveHandler) - v1.POST("/basic/publickey", handler.PublicKeyHandler) - v1.POST("/basic/handshake", handler.HandshakeHandler) - v1.POST("/account/initialize", handler.InitializeHandler) - v1.POST("/account/login", handler.AccountLoginHandler) - v1.POST("/account/loginauto", handler.LoginAutoHandler) - v1.POST("/basic/loginarea", handler.LoginAreaHandler) - v1.POST("/account/reportRole", handler.ReportRoleHandler) - v1.POST("/basic/getProductList", handler.GetProductListHandler) - v1.POST("/guest/status", handler.GuestStatusHandler) + v1.GET("/basic/getcode", handler.GetCode) + v1.POST("/account/active", handler.Active) + v1.POST("/account/initialize", handler.Initialize) + v1.POST("/account/loginauto", handler.LoginAuto) + v1.POST("/account/login", handler.AccountLogin) + v1.POST("/account/reportRole", handler.ReportRole) + v1.POST("/basic/getcode", handler.GetCode) + v1.POST("/basic/getProductList", handler.GetProductList) + v1.POST("/basic/handshake", handler.Handshake) + v1.POST("/basic/loginarea", handler.LoginArea) + v1.POST("/basic/publickey", handler.PublicKey) + v1.POST("/guest/status", handler.GuestStatus) } - r.GET("/agreement/all", handler.AgreementHandler) + r.GET("/agreement/all", handler.Agreement) r.GET("/integration/appReport/initialize", handler.ReportApp) r.POST("/report/ge/app", handler.ReportLog) // Private APIs @@ -51,51 +49,51 @@ func main() { // Server APIs m := r.Group("main.php").Use(middleware.Common) { - m.POST("/album/seriesAll", middleware.ParseMultipartForm, handler.AlbumSeriesAllHandler) - m.POST("/announce/checkState", middleware.ParseMultipartForm, handler.AnnounceCheckStateHandler) - m.POST("/api", middleware.ParseMultipartForm, handler.ApiHandler) + m.POST("/album/seriesAll", middleware.ParseMultipartForm, handler.AlbumSeriesAll) + m.POST("/announce/checkState", middleware.ParseMultipartForm, handler.AnnounceCheckState) + m.POST("/api", middleware.ParseMultipartForm, handler.Api) m.POST("/award/set", handler.AwardSet) m.POST("/background/set", handler.BackgroundSet) - m.POST("/download/additional", handler.DownloadAdditionalHandler) - m.POST("/download/batch", handler.DownloadBatchHandler) - m.POST("/download/event", handler.DownloadEventHandler) - m.POST("/download/getUrl", handler.DownloadUrlHandler) - m.POST("/download/update", handler.DownloadUpdateHandler) - m.POST("/event/eventList", middleware.ParseMultipartForm, handler.EventListHandler) - m.POST("/gdpr/get", middleware.ParseMultipartForm, handler.GdprHandler) - m.POST("/lbonus/execute", handler.LBonusExecuteHandler) - m.POST("/live/gameover", handler.GameOverHandler) - m.POST("/live/partyList", handler.PartyListHandler) - m.POST("/live/play", middleware.ParseMultipartForm, handler.PlayLiveHandler) - m.POST("/live/preciseScore", middleware.ParseMultipartForm, handler.PlayScoreHandler) - m.POST("/live/reward", middleware.ParseMultipartForm, handler.PlayRewardHandler) + m.POST("/download/additional", handler.DownloadAdditional) + m.POST("/download/batch", handler.DownloadBatch) + m.POST("/download/event", handler.DownloadEvent) + m.POST("/download/getUrl", handler.DownloadUrl) + m.POST("/download/update", handler.DownloadUpdate) + m.POST("/event/eventList", middleware.ParseMultipartForm, handler.EventList) + m.POST("/gdpr/get", middleware.ParseMultipartForm, handler.Gdpr) + m.POST("/lbonus/execute", handler.LBonusExecute) + m.POST("/live/gameover", handler.GameOver) + m.POST("/live/partyList", handler.PartyList) + m.POST("/live/play", middleware.ParseMultipartForm, handler.PlayLive) + m.POST("/live/preciseScore", middleware.ParseMultipartForm, handler.PlayScore) + m.POST("/live/reward", middleware.ParseMultipartForm, handler.PlayReward) m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey) m.POST("/login/login", middleware.Login, handler.Login) - m.POST("/multiunit/scenarioStartup", handler.MultiUnitStartUpHandler) + m.POST("/multiunit/scenarioStartup", handler.MultiUnitStartUp) m.POST("/museum/info", middleware.ParseMultipartForm, handler.MuseumInfo) - m.POST("/notice/noticeFriendGreeting", middleware.ParseMultipartForm, handler.NoticeFriendGreetingHandler) - m.POST("/notice/noticeFriendVariety", middleware.ParseMultipartForm, handler.NoticeFriendVarietyHandler) - m.POST("/notice/noticeUserGreetingHistory", handler.NoticeUserGreetingHandler) - m.POST("/payment/productList", middleware.ParseMultipartForm, handler.ProductListHandler) - m.POST("/personalnotice/get", middleware.ParseMultipartForm, handler.PersonalNoticeHandler) + m.POST("/notice/noticeFriendGreeting", middleware.ParseMultipartForm, handler.NoticeFriendGreeting) + m.POST("/notice/noticeFriendVariety", middleware.ParseMultipartForm, handler.NoticeFriendVariety) + m.POST("/notice/noticeUserGreetingHistory", handler.NoticeUserGreeting) + m.POST("/payment/productList", middleware.ParseMultipartForm, handler.ProductList) + m.POST("/personalnotice/get", middleware.ParseMultipartForm, handler.PersonalNotice) m.POST("/profile/profileRegister", handler.ProfileRegister) - m.POST("/scenario/reward", handler.ScenarioRewardHandler) - m.POST("/scenario/startup", handler.ScenarioStartupHandler) - m.POST("/subscenario/reward", handler.SubScenarioStartupHandler) - m.POST("/subscenario/startup", handler.SubScenarioStartupHandler) - m.POST("/tos/tosCheck", middleware.ParseMultipartForm, handler.TosCheckHandler) - m.POST("/unit/deck", handler.SetDeckHandler) - m.POST("/unit/deckName", handler.SetDeckNameHandler) - m.POST("/unit/favorite", handler.SetDisplayRankHandler) + m.POST("/scenario/reward", handler.ScenarioReward) + m.POST("/scenario/startup", handler.ScenarioStartup) + m.POST("/subscenario/reward", handler.SubScenarioStartup) + m.POST("/subscenario/startup", handler.SubScenarioStartup) + m.POST("/tos/tosCheck", middleware.ParseMultipartForm, handler.TosCheck) + m.POST("/unit/deck", handler.SetDeck) + m.POST("/unit/deckName", handler.SetDeckName) + m.POST("/unit/favorite", handler.SetDisplayRank) m.POST("/unit/removableSkillEquipment", handler.RemoveSkillEquip) - m.POST("/unit/setDisplayRank", handler.SetDisplayRankHandler) + m.POST("/unit/setDisplayRank", handler.SetDisplayRank) m.POST("/unit/wearAccessory", handler.WearAccessory) - m.POST("/user/changeName", handler.ChangeNameHandler) - m.POST("/user/changeNavi", handler.ChangeNaviHandler) - m.POST("/user/setNotificationToken", handler.SetNotificationTokenHandler) - m.POST("/user/userInfo", middleware.ParseMultipartForm, handler.UserInfoHandler) + m.POST("/user/changeName", handler.ChangeName) + m.POST("/user/changeNavi", handler.ChangeNavi) + m.POST("/user/setNotificationToken", handler.SetNotificationToken) + m.POST("/user/userInfo", middleware.ParseMultipartForm, handler.UserInfo) } - r.GET("/webview.php/announce/index", handler.AnnounceIndexHandler) + r.GET("/webview.php/announce/index", handler.AnnounceIndex) // Server APIs // Web diff --git a/model/album.go b/model/album.go index 3b59118..4beba9e 100644 --- a/model/album.go +++ b/model/album.go @@ -1,6 +1,6 @@ package model -// module: album, action: albumAll +// AlbumResult ... type AlbumResult struct { UnitID int `json:"unit_id"` RankMaxFlag bool `json:"rank_max_flag"` @@ -13,6 +13,7 @@ type AlbumResult struct { SignFlag bool `json:"sign_flag"` } +// AlbumResp ... type AlbumResp struct { Result []AlbumResult `json:"result"` Status int `json:"status"` @@ -20,12 +21,13 @@ type AlbumResp struct { TimeStamp int64 `json:"timeStamp"` } -// albumSeries +// AlbumSeriesRes ... type AlbumSeriesRes struct { SeriesID int `json:"series_id"` UnitList []AlbumResult `json:"unit_list"` } +// AlbumSeriesResp ... type AlbumSeriesResp struct { ResponseData []AlbumSeriesRes `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` diff --git a/model/api.go b/model/api.go index 956f7df..b4c0173 100644 --- a/model/api.go +++ b/model/api.go @@ -1,29 +1,17 @@ package model -type SifApi struct { +import "encoding/json" + +// ApiReq ... +type ApiReq struct { Module string `json:"module"` 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"` +// ApiResp ... +type ApiResp struct { + ResponseData json.RawMessage `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` } diff --git a/model/award.go b/model/award.go index d396b26..111e107 100644 --- a/model/award.go +++ b/model/award.go @@ -6,3 +6,23 @@ type AwardSetResp struct { ReleaseInfo []interface{} `json:"release_info"` StatusCode int `json:"status_code"` } + +// AwardInfo ... +type AwardInfo struct { + AwardID int `json:"award_id"` + IsSet bool `json:"is_set"` + InsertDate string `json:"insert_date"` +} + +// AwardInfoRes ... +type AwardInfoRes struct { + AwardInfo []AwardInfo `json:"award_info"` +} + +// AwardInfoResp ... +type AwardInfoResp struct { + Result AwardInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/background.go b/model/background.go index da06818..65f3ed8 100644 --- a/model/background.go +++ b/model/background.go @@ -6,3 +6,23 @@ type BackgroundSetResp struct { ReleaseInfo []interface{} `json:"release_info"` StatusCode int `json:"status_code"` } + +// BackgroundInfo ... +type BackgroundInfo struct { + BackgroundID int `json:"background_id"` + IsSet bool `json:"is_set"` + InsertDate string `json:"insert_date"` +} + +// BackgroundInfoRes ... +type BackgroundInfoRes struct { + BackgroundInfo []BackgroundInfo `json:"background_info"` +} + +// BackgroundInfoResp ... +type BackgroundInfoResp struct { + Result BackgroundInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/banner.go b/model/banner.go index c6abfe6..9552c3c 100644 --- a/model/banner.go +++ b/model/banner.go @@ -14,14 +14,16 @@ type BannerList struct { WebviewURL string `json:"webview_url,omitempty"` } -type BannerListResult struct { +// BannerListRes ... +type BannerListRes struct { TimeLimit string `json:"time_limit"` BannerList []BannerList `json:"banner_list"` } +// BannerListResp ... type BannerListResp struct { - Result BannerListResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result BannerListRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/challenge.go b/model/challenge.go new file mode 100644 index 0000000..eacf79c --- /dev/null +++ b/model/challenge.go @@ -0,0 +1,9 @@ +package model + +// ChallengeInfoResp ... +type ChallengeInfoResp struct { + Result []interface{} `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/costume.go b/model/costume.go index b6e9471..9ce14b7 100644 --- a/model/costume.go +++ b/model/costume.go @@ -1,19 +1,21 @@ package model -// module: costume, action: costumeList +// CostumeList ... type CostumeList struct { UnitID int `json:"unit_id"` IsRankMax bool `json:"is_rank_max"` IsSigned bool `json:"is_signed"` } -type CostumeListResult struct { +// CostumeListRes ... +type CostumeListRes struct { CostumeList []CostumeList `json:"costume_list"` } +// CostumeListResp ... type CostumeListResp struct { - Result CostumeListResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result CostumeListRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/download.go b/model/download.go index 7c5bd8d..ba32701 100644 --- a/model/download.go +++ b/model/download.go @@ -1,5 +1,6 @@ package model +// AdditionalReq ... type AdditionalReq struct { Module string `json:"module"` Mgd int `json:"mgd"` @@ -11,17 +12,20 @@ type AdditionalReq struct { CommandNum string `json:"commandNum"` } -type AdditionalResult struct { +// AdditionalRes ... +type AdditionalRes struct { Size int `json:"size"` URL string `json:"url"` } +// AdditionalResp ... type AdditionalResp struct { - ResponseData []AdditionalResult `json:"response_data"` - ReleaseInfo []interface{} `json:"release_info"` - StatusCode int `json:"status_code"` + ResponseData []AdditionalRes `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` } +// BatchReq ... type BatchReq struct { ClientVersion string `json:"client_version"` Os string `json:"os"` @@ -30,17 +34,20 @@ type BatchReq struct { CommandNum string `json:"commandNum"` } -type BatchResult struct { +// BatchRes ... +type BatchRes struct { Size int `json:"size"` URL string `json:"url"` } +// BatchResp ... type BatchResp struct { - ResponseData []BatchResult `json:"response_data"` + ResponseData []BatchRes `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` StatusCode int `json:"status_code"` } +// UpdateReq ... type UpdateReq struct { Module string `json:"module"` TargetOs string `json:"target_os"` @@ -52,18 +59,21 @@ type UpdateReq struct { ExternalVersion string `json:"external_version"` } -type UpdateResult struct { +// UpdateRes ... +type UpdateRes struct { Size int `json:"size"` URL string `json:"url"` Version string `json:"version"` } +// UpdateResp ... type UpdateResp struct { - ResponseData []UpdateResult `json:"response_data"` - ReleaseInfo []interface{} `json:"release_info"` - StatusCode int `json:"status_code"` + ResponseData []UpdateRes `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` } +// UrlReq ... type UrlReq struct { Module string `json:"module"` Os string `json:"os"` @@ -72,16 +82,19 @@ type UrlReq struct { Action string `json:"action"` } -type UrlResult struct { +// UrlRes ... +type UrlRes struct { UrlList []string `json:"url_list"` } +// UrlResp ... type UrlResp struct { - ResponseData UrlResult `json:"response_data"` + ResponseData UrlRes `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` StatusCode int `json:"status_code"` } +// EventResp ... type EventResp struct { ResponseData []interface{} `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` diff --git a/model/exchange.go b/model/exchange.go new file mode 100644 index 0000000..4861be1 --- /dev/null +++ b/model/exchange.go @@ -0,0 +1,20 @@ +package model + +// ExchangePointList ... +type ExchangePointList struct { + Rarity int `json:"rarity"` + ExchangePoint int `json:"exchange_point"` +} + +// ExchangePointRes ... +type ExchangePointRes struct { + ExchangePointList []ExchangePointList `json:"exchange_point_list"` +} + +// ExchangePointResp ... +type ExchangePointResp struct { + Result ExchangePointRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/lbonus.go b/model/lbonus.go index d22c2c4..ef9c01b 100644 --- a/model/lbonus.go +++ b/model/lbonus.go @@ -1,11 +1,13 @@ package model +// LbDayItem ... type LbDayItem struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` Amount int `json:"amount"` } +// LbDays ... type LbDays struct { Day int `json:"day"` DayOfTheWeek int `json:"day_of_the_week"` @@ -16,34 +18,42 @@ type LbDays struct { Item LbDayItem `json:"item"` } +// LbMonth ... type LbMonth struct { Year int `json:"year"` Month int `json:"month"` Days []LbDays `json:"days"` } +// CalendarInfo ... type CalendarInfo struct { CurrentDate string `json:"current_date"` CurrentMonth LbMonth `json:"current_month"` NextMonth LbMonth `json:"next_month"` } +// Reward ... type Reward struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` Amount int `json:"amount"` } + +// TotalLoginInfo ... type TotalLoginInfo struct { LoginCount int `json:"login_count"` RemainingCount int `json:"remaining_count"` Reward []Reward `json:"reward"` } +// LbRankInfo ... type LbRankInfo struct { BeforeClassRankID int `json:"before_class_rank_id"` AfterClassRankID int `json:"after_class_rank_id"` RankUpDate string `json:"rank_up_date"` } + +// LbClassSystem ... type LbClassSystem struct { RankInfo LbRankInfo `json:"rank_info"` CompleteFlag bool `json:"complete_flag"` @@ -51,6 +61,7 @@ type LbClassSystem struct { IsVisible bool `json:"is_visible"` } +// LbRes ... type LbRes struct { Sheets []interface{} `json:"sheets"` CalendarInfo CalendarInfo `json:"calendar_info"` @@ -60,11 +71,12 @@ type LbRes struct { StartDashSheets []interface{} `json:"start_dash_sheets"` EffortPoint []EffortPoint `json:"effort_point"` LimitedEffortBox []interface{} `json:"limited_effort_box"` - MuseumInfo MuseumInfo `json:"museum_info"` + MuseumInfo Museum `json:"museum_info"` ServerTimestamp int64 `json:"server_timestamp"` PresentCnt int `json:"present_cnt"` } +// LbResp ... type LbResp struct { ResponseData LbRes `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` diff --git a/model/live.go b/model/live.go index 2f5f55a..45369f5 100644 --- a/model/live.go +++ b/model/live.go @@ -1,6 +1,13 @@ package model -// module: live, action: liveStatus +// GameOverResp ... +type GameOverResp struct { + ResponseData []interface{} `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// NormalLiveStatusList ... type NormalLiveStatusList struct { LiveDifficultyID int `json:"live_difficulty_id"` Status int `json:"status"` @@ -10,6 +17,7 @@ type NormalLiveStatusList struct { AchievedGoalIDList []int `json:"achieved_goal_id_list"` } +// SpecialLiveStatusList ... type SpecialLiveStatusList struct { LiveDifficultyID int `json:"live_difficulty_id"` Status int `json:"status"` @@ -19,6 +27,7 @@ type SpecialLiveStatusList struct { AchievedGoalIDList []int `json:"achieved_goal_id_list"` } +// TrainingLiveStatusList ... type TrainingLiveStatusList struct { LiveDifficultyID int `json:"live_difficulty_id"` Status int `json:"status"` @@ -28,7 +37,8 @@ type TrainingLiveStatusList struct { AchievedGoalIDList []int `json:"achieved_goal_id_list"` } -type LiveStatusResult struct { +// LiveStatusRes ... +type LiveStatusRes struct { NormalLiveStatusList []NormalLiveStatusList `json:"normal_live_status_list"` SpecialLiveStatusList []SpecialLiveStatusList `json:"special_live_status_list"` TrainingLiveStatusList []TrainingLiveStatusList `json:"training_live_status_list"` @@ -37,14 +47,15 @@ type LiveStatusResult struct { CanResumeLive bool `json:"can_resume_live"` } +// LiveStatusResp ... type LiveStatusResp struct { - Result LiveStatusResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result LiveStatusRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// module: live, action: schedule +// LiveList ... type LiveList struct { LiveDifficultyID int `json:"live_difficulty_id"` StartDate string `json:"start_date"` @@ -52,6 +63,7 @@ type LiveList struct { IsRandom bool `json:"is_random"` } +// LimitedBonusCommonList ... type LimitedBonusCommonList struct { LiveType int `json:"live_type"` LimitedBonusType int `json:"limited_bonus_type"` @@ -60,19 +72,22 @@ type LimitedBonusCommonList struct { EndDate string `json:"end_date"` } +// RandomLiveList ... type RandomLiveList struct { AttributeID int `json:"attribute_id"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` } +// TrainingLiveList ... type TrainingLiveList struct { LiveDifficultyID int `json:"live_difficulty_id"` StartDate string `json:"start_date"` IsRandom bool `json:"is_random"` } -type LiveScheduleResult struct { +// LiveScheduleRes ... +type LiveScheduleRes struct { EventList []interface{} `json:"event_list"` LiveList []LiveList `json:"live_list"` LimitedBonusList []interface{} `json:"limited_bonus_list"` @@ -82,14 +97,15 @@ type LiveScheduleResult struct { TrainingLiveList []TrainingLiveList `json:"training_live_list"` } +// LiveScheduleResp ... type LiveScheduleResp struct { - Result LiveScheduleResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result LiveScheduleRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// Play +// PlayReq ... type PlayReq struct { Module string `json:"module"` PartyUserID int64 `json:"party_user_id"` @@ -103,12 +119,14 @@ type PlayReq struct { CommandNum string `json:"commandNum"` } +// RankInfo ... type RankInfo struct { Rank int `json:"rank"` RankMin int `json:"rank_min"` RankMax int `json:"rank_max"` } +// NotesList ... type NotesList struct { TimingSec float64 `json:"timing_sec"` NotesAttribute int `json:"notes_attribute"` @@ -118,6 +136,7 @@ type NotesList struct { Position int `json:"position"` } +// LiveInfo ... type LiveInfo struct { LiveDifficultyID int `json:"live_difficulty_id"` IsRandom bool `json:"is_random"` @@ -126,19 +145,22 @@ type LiveInfo struct { NotesList []NotesList `json:"notes_list"` } +// PlayCostume ... type PlayCostume struct { UnitID int `json:"unit_id"` IsRankMax bool `json:"is_rank_max"` IsSigned bool `json:"is_signed"` } +// UnitList ... type UnitList struct { - Smile int `json:"smile"` - Cute int `json:"cute"` - Cool int `json:"cool"` - // Costume PlayCostume `json:"costume,omitempty"` + Smile int `json:"smile"` + Cute int `json:"cute"` + Cool int `json:"cool"` + Costume PlayCostume `json:"costume,omitempty"` } +// DeckInfo ... type DeckInfo struct { UnitDeckID int `json:"unit_deck_id"` TotalSmile int `json:"total_smile"` @@ -149,12 +171,14 @@ type DeckInfo struct { UnitList []UnitList `json:"unit_list"` } +// PlayLiveList ... type PlayLiveList struct { LiveInfo LiveInfo `json:"live_info"` DeckInfo DeckInfo `json:"deck_info"` } -type PlayResponseData struct { +// PlayRes ... +type PlayRes struct { RankInfo []RankInfo `json:"rank_info"` EnergyFullTime string `json:"energy_full_time"` OverMaxEnergy int `json:"over_max_energy"` @@ -167,7 +191,14 @@ type PlayResponseData struct { ServerTimestamp int64 `json:"server_timestamp"` } -// preciseScore +// PlayResp ... +type PlayResp struct { + ResponseData PlayRes `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// PlayScoreReq ... type PlayScoreReq struct { Module string `json:"module"` Action string `json:"action"` @@ -177,6 +208,7 @@ type PlayScoreReq struct { CommandNum string `json:"commandNum"` } +// On ... type On struct { HasRecord bool `json:"has_record"` LiveInfo LiveInfo `json:"live_info"` @@ -189,6 +221,7 @@ type On struct { CanReplay bool `json:"can_replay"` } +// Off ... type Off struct { HasRecord bool `json:"has_record"` LiveInfo LiveInfo `json:"live_info"` @@ -201,7 +234,8 @@ type Off struct { CanReplay bool `json:"can_replay"` } -type PlayScoreResponseData struct { +// PlayScoreRes ... +type PlayScoreRes struct { On On `json:"on"` Off Off `json:"off"` RankInfo []RankInfo `json:"rank_info"` @@ -209,7 +243,14 @@ type PlayScoreResponseData struct { ServerTimestamp int `json:"server_timestamp"` } -// reward +// PlayScoreResp ... +type PlayScoreResp struct { + ResponseData PlayScoreRes `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// PlayRewardReq ... type PlayRewardReq struct { Module string `json:"module"` Action string `json:"action"` @@ -234,12 +275,14 @@ type PlayRewardReq struct { ScoreCool int `json:"score_cool"` } +// Icon ... type Icon struct { SlideID int `json:"slide_id"` JustID int `json:"just_id"` NormalID int `json:"normal_id"` } +// LiveSetting ... type LiveSetting struct { StringSize int `json:"string_size"` PreciseScoreAutoUpdateFlag bool `json:"precise_score_auto_update_flag"` @@ -253,6 +296,7 @@ type LiveSetting struct { CutinType int `json:"cutin_type"` } +// PreciseList ... type PreciseList struct { Effect int `json:"effect"` Count int `json:"count"` @@ -263,16 +307,20 @@ type PreciseList struct { IsSame bool `json:"is_same"` } +// BackgroundScore ... type BackgroundScore struct { Smile int `json:"smile"` Cute int `json:"cute"` Cool int `json:"cool"` } +// TriggerLog ... type TriggerLog struct { ActivationRate int `json:"activation_rate"` Position int `json:"position"` } + +// PreciseScoreLog ... type PreciseScoreLog struct { LiveSetting LiveSetting `json:"live_setting"` TapAdjust int `json:"tap_adjust"` @@ -285,6 +333,7 @@ type PreciseScoreLog struct { RandomSeed int `json:"random_seed"` } +// RewardLiveInfo ... type RewardLiveInfo struct { LiveDifficultyID int `json:"live_difficulty_id"` IsRandom bool `json:"is_random"` @@ -292,21 +341,25 @@ type RewardLiveInfo struct { SwingFlag int `json:"swing_flag"` } +// PlayerExpUnitMax ... type PlayerExpUnitMax struct { Before int `json:"before"` After int `json:"after"` } +// PlayerExpFriendMax ... type PlayerExpFriendMax struct { Before int `json:"before"` After int `json:"after"` } +// PlayerExpLpMax ... type PlayerExpLpMax struct { Before int `json:"before"` After int `json:"after"` } +// BaseRewardInfo ... type BaseRewardInfo struct { PlayerExp int `json:"player_exp"` PlayerExpUnitMax PlayerExpUnitMax `json:"player_exp_unit_max"` @@ -317,6 +370,7 @@ type BaseRewardInfo struct { SocialPoint int `json:"social_point"` } +// LiveClear ... type LiveClear struct { AddType int `json:"add_type"` Amount int `json:"amount"` @@ -345,6 +399,7 @@ type LiveClear struct { RemovableSkillIds []interface{} `json:"removable_skill_ids"` } +// LiveRank ... type LiveRank struct { AddType int `json:"add_type"` Amount int `json:"amount"` @@ -373,12 +428,14 @@ type LiveRank struct { RemovableSkillIds []interface{} `json:"removable_skill_ids"` } +// RewardUnitList ... type RewardUnitList struct { LiveClear []LiveClear `json:"live_clear"` LiveRank []LiveRank `json:"live_rank"` LiveCombo []interface{} `json:"live_combo"` } +// Rewards ... type Rewards struct { Rarity int `json:"rarity"` ItemID int `json:"item_id"` @@ -389,6 +446,7 @@ type Rewards struct { InsertDate string `json:"insert_date"` } +// EffortPoint ... type EffortPoint struct { LiveEffortPointBoxSpecID int `json:"live_effort_point_box_spec_id"` Capacity int `json:"capacity"` @@ -397,24 +455,7 @@ type EffortPoint struct { Rewards []Rewards `json:"rewards"` } -// type PlayRewardUnitList struct { -// UnitOwningUserID int `json:"unit_owning_user_id"` -// UnitID int `json:"unit_id"` -// Position int `json:"position"` -// Level int `json:"level"` -// LevelLimitID int `json:"level_limit_id"` -// DisplayRank int `json:"display_rank"` -// Love int `json:"love"` -// UnitSkillLevel int `json:"unit_skill_level"` -// IsRankMax bool `json:"is_rank_max"` -// IsLoveMax bool `json:"is_love_max"` -// IsLevelMax bool `json:"is_level_max"` -// IsSigned bool `json:"is_signed"` -// BeforeLove int `json:"before_love"` -// MaxLove int `json:"max_love"` -// // Costume Costume `json:"costume,omitempty"` -// } - +// PlayRewardUnitList ... type PlayRewardUnitList struct { ID int `xorm:"id pk autoincr" json:"-"` UserDeckID int `xorm:"user_deck_id" json:"-"` @@ -435,6 +476,7 @@ type PlayRewardUnitList struct { InsertData int64 `xorm:"insert_date" json:"-"` } +// BeforeUserInfo ... type BeforeUserInfo struct { Level int `json:"level"` Exp int `json:"exp"` @@ -460,6 +502,7 @@ type BeforeUserInfo struct { UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"` } +// AfterUserInfo ... type AfterUserInfo struct { Level int `json:"level"` Exp int `json:"exp"` @@ -485,22 +528,26 @@ type AfterUserInfo struct { UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"` } +// NextLevelInfo ... type NextLevelInfo struct { Level int `json:"level"` FromExp int `json:"from_exp"` } +// GoalAccompInfo ... type GoalAccompInfo struct { AchievedIds []interface{} `json:"achieved_ids"` Rewards []interface{} `json:"rewards"` } +// RewardRankInfo ... type RewardRankInfo struct { BeforeClassRankID int `json:"before_class_rank_id"` AfterClassRankID int `json:"after_class_rank_id"` RankUpDate string `json:"rank_up_date"` } +// ClassSystem ... type ClassSystem struct { RankInfo RewardRankInfo `json:"rank_info"` CompleteFlag bool `json:"complete_flag"` @@ -508,6 +555,7 @@ type ClassSystem struct { IsVisible bool `json:"is_visible"` } +// PlayRewardList ... type PlayRewardList struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` @@ -516,6 +564,7 @@ type PlayRewardList struct { RewardBoxFlag bool `json:"reward_box_flag"` } +// AccomplishedAchievementList ... type AccomplishedAchievementList struct { AchievementID int `json:"achievement_id"` Count int `json:"count"` @@ -531,23 +580,14 @@ type AccomplishedAchievementList struct { RewardList []PlayRewardList `json:"reward_list"` } -type Parameter struct { - Smile int `json:"smile"` - Pure int `json:"pure"` - Cool int `json:"cool"` -} - -type RewardMuseumInfo struct { - Parameter Parameter `json:"parameter"` - ContentsIDList []int `json:"contents_id_list"` -} - +// RewardUnitSupportList ... type RewardUnitSupportList struct { UnitID int `json:"unit_id"` Amount int `json:"amount"` } -type RewardResponseData struct { +// RewardRes ... +type RewardRes struct { LiveInfo []RewardLiveInfo `json:"live_info"` Rank int `json:"rank"` ComboRank int `json:"combo_rank"` @@ -575,8 +615,41 @@ type RewardResponseData struct { AccomplishedAchievementList []AccomplishedAchievementList `json:"accomplished_achievement_list"` UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"` AddedAchievementList []interface{} `json:"added_achievement_list"` - MuseumInfo RewardMuseumInfo `json:"museum_info"` + MuseumInfo Museum `json:"museum_info"` UnitSupportList []RewardUnitSupportList `json:"unit_support_list"` ServerTimestamp int `json:"server_timestamp"` PresentCnt int `json:"present_cnt"` } + +// RewardResp ... +type RewardResp struct { + ResponseData RewardRes `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// LiveSeInfoRes ... +type LiveSeInfoRes struct { + LiveSeList []int `json:"live_se_list"` +} + +// LiveSeInfoResp ... +type LiveSeInfoResp struct { + Result LiveSeInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} + +// LiveIconInfoRes ... +type LiveIconInfoRes struct { + LiveNotesIconList []int `json:"live_notes_icon_list"` +} + +// LiveIconInfoResp ... +type LiveIconInfoResp struct { + Result LiveIconInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/marathon.go b/model/marathon.go new file mode 100644 index 0000000..2c72d4b --- /dev/null +++ b/model/marathon.go @@ -0,0 +1,9 @@ +package model + +// MarathonInfoResp ... +type MarathonInfoResp struct { + Result []interface{} `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/multiunit.go b/model/multiunit.go index 2164e26..0574663 100644 --- a/model/multiunit.go +++ b/model/multiunit.go @@ -1,12 +1,13 @@ package model -// module: multiunit, action: multiunitscenarioStatus +// MultiUnitScenarioChapterList ... type MultiUnitScenarioChapterList struct { MultiUnitScenarioID int `json:"multi_unit_scenario_id"` Chapter int `json:"chapter"` Status int `json:"status"` } +// MultiUnitScenarioStatusList ... type MultiUnitScenarioStatusList struct { MultiUnitID int `json:"multi_unit_id"` Status int `json:"status"` @@ -15,14 +16,16 @@ type MultiUnitScenarioStatusList struct { ChapterList []MultiUnitScenarioChapterList `json:"chapter_list"` } -type MultiUnitScenarioStatusResult struct { +// MultiUnitScenarioStatusRes ... +type MultiUnitScenarioStatusRes struct { MultiUnitScenarioStatusList []MultiUnitScenarioStatusList `json:"multi_unit_scenario_status_list"` UnlockedMultiUnitScenarioIds []interface{} `json:"unlocked_multi_unit_scenario_ids"` } +// MultiUnitScenarioStatusResp ... type MultiUnitScenarioStatusResp struct { - Result MultiUnitScenarioStatusResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result MultiUnitScenarioStatusRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/museum.go b/model/museum.go index 5a42b76..10f642f 100644 --- a/model/museum.go +++ b/model/museum.go @@ -1,23 +1,40 @@ package model +// MuseumResp ... type MuseumResp struct { ResponseData MuseumRes `json:"response_data"` ReleaseInfo []interface{} `json:"release_info"` StatusCode int `json:"status_code"` } +// MuseumParameter ... type MuseumParameter struct { Smile int `json:"smile"` Pure int `json:"pure"` Cool int `json:"cool"` } +// Museum ... type Museum struct { Parameter MuseumParameter `json:"parameter"` ContentsIDList []int `json:"contents_id_list"` } +// MuseumRes ... type MuseumRes struct { MuseumInfo Museum `json:"museum_info"` ServerTimestamp int64 `json:"server_timestamp"` } + +// MuseumInfoRes ... +type MuseumInfoRes struct { + MuseumInfo Museum `json:"museum_info"` +} + +// MuseumInfoResp ... +type MuseumInfoResp struct { + Result MuseumInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/navigation.go b/model/navigation.go new file mode 100644 index 0000000..25d0806 --- /dev/null +++ b/model/navigation.go @@ -0,0 +1,14 @@ +package model + +// SpecialCutinRes ... +type SpecialCutinRes struct { + SpecialCutinList []interface{} `json:"special_cutin_list"` +} + +// SpecialCutinResp ... +type SpecialCutinResp struct { + Result SpecialCutinRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/notice.go b/model/notice.go index 00447e1..25b3914 100644 --- a/model/notice.go +++ b/model/notice.go @@ -42,3 +42,17 @@ type NoticeUserGreetingRes struct { NoticeList []interface{} `json:"notice_list"` ServerTimestamp int64 `json:"server_timestamp"` } + +// NoticeMarqueeRes ... +type NoticeMarqueeRes struct { + ItemCount int `json:"item_count"` + MarqueeList []interface{} `json:"marquee_list"` +} + +// NoticeMarqueeResp ... +type NoticeMarqueeResp struct { + Result NoticeMarqueeRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/model/others.go b/model/others.go deleted file mode 100644 index 903a6f6..0000000 --- a/model/others.go +++ /dev/null @@ -1,172 +0,0 @@ -package model - -// module: notice, action: noticeMarquee -type NoticeMarqueeResult struct { - ItemCount int `json:"item_count"` - MarqueeList []interface{} `json:"marquee_list"` -} - -type NoticeMarqueeResp struct { - Result NoticeMarqueeResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: user, action: getNavi -type User struct { - UserID int `json:"user_id"` - UnitOwningUserID int `json:"unit_owning_user_id"` -} - -type UserNaviResult struct { - User User `json:"user"` -} - -type UserNaviResp struct { - Result UserNaviResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: navigation, action: specialCutin -type SpecialCutinResult struct { - SpecialCutinList []interface{} `json:"special_cutin_list"` -} - -type SpecialCutinResp struct { - Result SpecialCutinResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: award, action: awardInfo -type AwardInfo struct { - AwardID int `json:"award_id"` - IsSet bool `json:"is_set"` - InsertDate string `json:"insert_date"` -} - -type AwardInfoResult struct { - AwardInfo []AwardInfo `json:"award_info"` -} - -type AwardInfoResp struct { - Result AwardInfoResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: background, action: backgroundInfo -type BackgroundInfo struct { - BackgroundID int `json:"background_id"` - IsSet bool `json:"is_set"` - InsertDate string `json:"insert_date"` -} - -type BackgroundInfoResult struct { - BackgroundInfo []BackgroundInfo `json:"background_info"` -} - -type BackgroundInfoResp struct { - Result BackgroundInfoResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: exchange, action: owningPoint -type ExchangePointList struct { - Rarity int `json:"rarity"` - ExchangePoint int `json:"exchange_point"` -} - -type ExchangePointResult struct { - ExchangePointList []ExchangePointList `json:"exchange_point_list"` -} - -type ExchangePointResp struct { - Result ExchangePointResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: livese, action: liveseInfo -type LiveSeInfoResult struct { - LiveSeList []int `json:"live_se_list"` -} - -type LiveSeInfoResp struct { - Result LiveSeInfoResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: liveicon, action: liveiconInfo -type LiveIconInfoResult struct { - LiveNotesIconList []int `json:"live_notes_icon_list"` -} - -type LiveIconInfoResp struct { - Result LiveIconInfoResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: item, action: list -type GeneralItemList struct { - ItemID int `json:"item_id"` - Amount int `json:"amount"` - UseButtonFlag bool `json:"use_button_flag"` - GeneralItemType int `json:"general_item_type"` -} - -type BuffItemList struct { - ItemID int `json:"item_id"` - Amount int `json:"amount"` - BuffType int `json:"buff_type"` -} - -type ReinforceItemList struct { - ItemID int `json:"item_id"` - ReinforceType int `json:"reinforce_type"` - AdditionValue int `json:"addition_value"` - Amount int `json:"amount"` - EventID int `json:"event_id"` -} - -type ItemResult struct { - GeneralItemList []GeneralItemList `json:"general_item_list"` - BuffItemList []BuffItemList `json:"buff_item_list"` - ReinforceItemList []ReinforceItemList `json:"reinforce_item_list"` - ReinforceInfo interface{} `json:"reinforce_info"` -} - -type ItemResp struct { - Result ItemResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: marathon, action: marathonInfo -type MarathonInfoResp struct { - Result []interface{} `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: challenge, action: challengeInfo -type ChallengeInfoResp struct { - Result []interface{} `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} diff --git a/model/payment.go b/model/payment.go index 9be0065..1fa7f20 100644 --- a/model/payment.go +++ b/model/payment.go @@ -1,10 +1,11 @@ package model -// module: payment, action: productList +// RestrictionInfo ... type RestrictionInfo struct { Restricted bool `json:"restricted"` } +// UnderAgeInfo ... type UnderAgeInfo struct { BirthSet bool `json:"birth_set"` HasLimit bool `json:"has_limit"` @@ -12,6 +13,7 @@ type UnderAgeInfo struct { MonthUsed int `json:"month_used"` } +// SnsProductItemList ... type SnsProductItemList struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` @@ -19,6 +21,7 @@ type SnsProductItemList struct { IsFreebie bool `json:"is_freebie"` } +// SnsProductList ... type SnsProductList struct { ProductID string `json:"product_id"` Name string `json:"name"` @@ -28,6 +31,7 @@ type SnsProductList struct { ItemList []SnsProductItemList `json:"item_list"` } +// ProductItemList ... type ProductItemList struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` @@ -36,12 +40,14 @@ type ProductItemList struct { IsRankMax bool `json:"is_rank_max,omitempty"` } +// LimitStatus ... type LimitStatus struct { TermStartDate string `json:"term_start_date"` RemainingTime string `json:"remaining_time"` RemainingCount int `json:"remaining_count"` } +// ProductList ... type ProductList struct { ProductID string `json:"product_id"` Name string `json:"name"` @@ -55,6 +61,7 @@ type ProductList struct { LimitStatus LimitStatus `json:"limit_status"` } +// SubscriptionItemList ... type SubscriptionItemList struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` @@ -62,26 +69,31 @@ type SubscriptionItemList struct { IsFreebie bool `json:"is_freebie"` } +// RewardList ... type RewardList struct { ItemID int `json:"item_id"` AddType int `json:"add_type"` Amount int `json:"amount"` } +// Items ... type Items struct { Seq int `json:"seq"` RewardList []RewardList `json:"reward_list"` } +// LicenseInfo ... type LicenseInfo struct { Name string `json:"name"` Items []Items `json:"items"` } +// UserStatus ... type UserStatus struct { IsLicensed bool `json:"is_licensed"` } +// SubscriptionStatus ... type SubscriptionStatus struct { LicenseID int `json:"license_id"` LicenseType int `json:"license_type"` @@ -91,6 +103,7 @@ type SubscriptionStatus struct { BadgeFlag bool `json:"badge_flag"` } +// SubscriptionList ... type SubscriptionList struct { ProductID string `json:"product_id"` Name string `json:"name"` @@ -104,7 +117,8 @@ type SubscriptionList struct { SubscriptionStatus SubscriptionStatus `json:"subscription_status"` } -type ProductListResult struct { +// ProductListRes ... +type ProductListRes struct { RestrictionInfo RestrictionInfo `json:"restriction_info"` UnderAgeInfo UnderAgeInfo `json:"under_age_info"` SnsProductList []SnsProductList `json:"sns_product_list"` @@ -113,9 +127,10 @@ type ProductListResult struct { ShowPointShop bool `json:"show_point_shop"` } +// ProductListResp ... type ProductListResp struct { - Result ProductListResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result ProductListRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/response.go b/model/response.go deleted file mode 100644 index b8c1bfb..0000000 --- a/model/response.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -import "encoding/json" - -// response_data -type Response struct { - ResponseData json.RawMessage `json:"response_data"` - ReleaseInfo []interface{} `json:"release_info"` - StatusCode int `json:"status_code"` -} diff --git a/model/scenario.go b/model/scenario.go index c24d967..c78480c 100644 --- a/model/scenario.go +++ b/model/scenario.go @@ -1,41 +1,45 @@ package model -// module: scenario, action: scenarioStatus +// ScenarioStatusList ... type ScenarioStatusList struct { ScenarioID int `json:"scenario_id"` Status int `json:"status"` } -type ScenarioStatusResult struct { +// ScenarioStatusRes ... +type ScenarioStatusRes struct { ScenarioStatusList []ScenarioStatusList `json:"scenario_status_list"` } +// ScenarioStatusResp ... type ScenarioStatusResp struct { - Result ScenarioStatusResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result ScenarioStatusRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// module: subscenario, action: subscenarioStatus +// SubscenarioStatusList ... type SubscenarioStatusList struct { SubscenarioID int `json:"subscenario_id"` Status int `json:"status"` } -type SubscenarioStatusResult struct { +// SubscenarioStatusRes ... +type SubscenarioStatusRes struct { SubscenarioStatusList []SubscenarioStatusList `json:"subscenario_status_list"` UnlockedSubscenarioIds []interface{} `json:"unlocked_subscenario_ids"` } +// SubscenarioStatusResp ... type SubscenarioStatusResp struct { - Result SubscenarioStatusResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result SubscenarioStatusRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// module: eventscenario, action: status +// EventScenarioChapterList ... type EventScenarioChapterList struct { EventScenarioID int `json:"event_scenario_id"` Chapter int `json:"chapter"` @@ -48,6 +52,7 @@ type EventScenarioChapterList struct { Amount int `json:"amount"` } +// EventScenarioList ... type EventScenarioList struct { EventID int `json:"event_id"` EventScenarioBtnAsset string `json:"event_scenario_btn_asset"` @@ -55,13 +60,15 @@ type EventScenarioList struct { ChapterList []EventScenarioChapterList `json:"chapter_list"` } -type EventScenarioStatusResult struct { +// EventScenarioStatusRes ... +type EventScenarioStatusRes struct { EventScenarioList []EventScenarioList `json:"event_scenario_list"` } +// EventScenarioStatusResp ... type EventScenarioStatusResp struct { - Result EventScenarioStatusResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result EventScenarioStatusRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/stamp.go b/model/stamp.go deleted file mode 100644 index 0a749ff..0000000 --- a/model/stamp.go +++ /dev/null @@ -1,23 +0,0 @@ -package model - -// module: stamp, action: stampInfo -type StampList struct { - Position int `json:"position"` - StampID int `json:"stamp_id"` -} - -type SettingList struct { - StampSettingID int `json:"stamp_setting_id"` - MainFlag int `json:"main_flag"` - StampList []StampList `json:"stamp_list"` -} - -type StampSetting struct { - StampType int `json:"stamp_type"` - SettingList []SettingList `json:"setting_list"` -} - -type StampInfoResult struct { - OwningStampIds []int `json:"owning_stamp_ids"` - StampSetting []StampSetting `json:"stamp_setting"` -} diff --git a/model/topinfo.go b/model/topinfo.go index c05612b..3ed52e3 100644 --- a/model/topinfo.go +++ b/model/topinfo.go @@ -1,5 +1,6 @@ package model +// TopInfoLicenseInfo ... type TopInfoLicenseInfo struct { LicenseList []interface{} `json:"license_list"` LicensedInfo []interface{} `json:"licensed_info"` @@ -7,7 +8,8 @@ type TopInfoLicenseInfo struct { BadgeFlag bool `json:"badge_flag"` } -type TopInfoResult struct { +// TopInfoRes ... +type TopInfoRes struct { FriendActionCnt int `json:"friend_action_cnt"` FriendGreetCnt int `json:"friend_greet_cnt"` FriendVarietyCnt int `json:"friend_variety_cnt"` @@ -31,13 +33,15 @@ type TopInfoResult struct { HasAdReward bool `json:"has_ad_reward"` } +// TopInfoResp ... type TopInfoResp struct { - Result TopInfoResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result TopInfoRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } +// TopInfoOnceNotification ... type TopInfoOnceNotification struct { Push bool `json:"push"` Lp bool `json:"lp"` @@ -50,7 +54,8 @@ type TopInfoOnceNotification struct { Birthday bool `json:"birthday"` } -type TopInfoOnceResult struct { +// TopInfoOnceRes ... +type TopInfoOnceRes struct { NewAchievementCnt int `json:"new_achievement_cnt"` UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"` LiveDailyRewardExist bool `json:"live_daily_reward_exist"` @@ -64,9 +69,10 @@ type TopInfoOnceResult struct { OpenV98 bool `json:"open_v98"` } +// TopInfoOnceResp ... type TopInfoOnceResp struct { - Result TopInfoOnceResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result TopInfoOnceRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } diff --git a/model/unit.go b/model/unit.go index 48698b6..69edb9c 100644 --- a/model/unit.go +++ b/model/unit.go @@ -126,13 +126,28 @@ type SkillEquipResp struct { StatusCode int `json:"status_code"` } -// module: unit, action: unitAll +// SetDisplayRankResp ... +type SetDisplayRankResp struct { + ResponseData []interface{} `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// SetDeckResp ... +type SetDeckResp struct { + ResponseData []interface{} `json:"response_data"` + ReleaseInfo []interface{} `json:"release_info"` + StatusCode int `json:"status_code"` +} + +// Costume ... type Costume struct { UnitID int `json:"unit_id"` IsRankMax bool `json:"is_rank_max"` IsSigned bool `json:"is_signed"` } +// Active ... type Active struct { UnitOwningUserID int `xorm:"unit_owning_user_id pk autoincr" json:"unit_owning_user_id"` UserID int `xorm:"user_id" json:"-"` @@ -162,6 +177,7 @@ type Active struct { // Costume Costume `json:"costume,omitempty"` } +// Waiting ... type Waiting struct { UnitOwningUserID int64 `json:"unit_owning_user_id"` UnitID int `json:"unit_id"` @@ -189,56 +205,62 @@ type Waiting struct { InsertDate string `json:"insert_date"` } -type UnitAllResult struct { +// UnitAllRes ... +type UnitAllRes struct { Active []Active `json:"active"` Waiting []Waiting `json:"waiting"` } +// UnitAllResp ... type UnitAllResp struct { - Result UnitAllResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result UnitAllRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// module: unit, action: deckInfo +// UnitOwningUserIds ... type UnitOwningUserIds struct { Position int `json:"position"` UnitOwningUserID int `json:"unit_owning_user_id"` } -type UnitDeckInfo struct { +// UnitDeckInfoRes ... +type UnitDeckInfoRes struct { UnitDeckID int `json:"unit_deck_id"` MainFlag bool `json:"main_flag"` DeckName string `json:"deck_name"` UnitOwningUserIds []UnitOwningUserIds `json:"unit_owning_user_ids"` } +// UnitDeckInfoResp ... type UnitDeckInfoResp struct { - Result []UnitDeckInfo `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` -} - -// module: unit, action: supporterAll -type UnitSupportList struct { - UnitID int `json:"unit_id"` - Amount int `json:"amount"` -} - -type UnitSupportResult struct { - UnitSupportList []UnitSupportList `json:"unit_support_list"` -} - -type UnitSupportResp struct { - Result UnitSupportResult `json:"result"` + Result []UnitDeckInfoRes `json:"result"` Status int `json:"status"` CommandNum bool `json:"commandNum"` TimeStamp int64 `json:"timeStamp"` } -// module: unit, action: removableSkillInfo +// UnitSupportList ... +type UnitSupportList struct { + UnitID int `json:"unit_id"` + Amount int `json:"amount"` +} + +// UnitSupportRes ... +type UnitSupportRes struct { + UnitSupportList []UnitSupportList `json:"unit_support_list"` +} + +// UnitSupportResp ... +type UnitSupportResp struct { + Result UnitSupportRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} + +// OwningInfo ... type OwningInfo struct { UnitRemovableSkillID int `json:"unit_removable_skill_id"` TotalAmount int `json:"total_amount"` @@ -246,19 +268,21 @@ type OwningInfo struct { InsertDate string `json:"insert_date"` } -type RemovableSkillResult struct { +// RemovableSkillRes ... +type RemovableSkillRes struct { OwningInfo []OwningInfo `json:"owning_info"` EquipmentInfo map[int]interface{} `json:"equipment_info"` } +// RemovableSkillResp ... type RemovableSkillResp struct { - Result RemovableSkillResult `json:"result"` - Status int `json:"status"` - CommandNum bool `json:"commandNum"` - TimeStamp int64 `json:"timeStamp"` + Result RemovableSkillRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` } -// module: unit, action: deck +// UnitDeckReq ... type UnitDeckReq struct { Module string `json:"module"` UnitDeckList []UnitDeckList `json:"unit_deck_list"` @@ -266,11 +290,13 @@ type UnitDeckReq struct { Mgd int `json:"mgd"` } +// UnitDeckDetail ... type UnitDeckDetail struct { Position int `json:"position"` UnitOwningUserID int `json:"unit_owning_user_id"` } +// UnitDeckList ... type UnitDeckList struct { UnitDeckDetail []UnitDeckDetail `json:"unit_deck_detail"` UnitDeckID int `json:"unit_deck_id"` @@ -278,7 +304,7 @@ type UnitDeckList struct { DeckName string `json:"deck_name"` } -// module: unit, action: deckName +// DeckNameReq ... type DeckNameReq struct { Module string `json:"module"` UnitDeckID int `json:"unit_deck_id"` diff --git a/model/user.go b/model/user.go index 69dde13..1a1f21b 100644 --- a/model/user.go +++ b/model/user.go @@ -20,3 +20,22 @@ type UserNameChangeRes struct { AfterName string `json:"after_name"` ServerTimestamp int64 `json:"server_timestamp"` } + +// User ... +type User struct { + UserID int `json:"user_id"` + UnitOwningUserID int `json:"unit_owning_user_id"` +} + +// UserNaviRes ... +type UserNaviRes struct { + User User `json:"user"` +} + +// UserNaviResp ... +type UserNaviResp struct { + Result UserNaviRes `json:"result"` + Status int `json:"status"` + CommandNum bool `json:"commandNum"` + TimeStamp int64 `json:"timeStamp"` +} diff --git a/tools/api.go b/tools/api.go deleted file mode 100644 index ea17415..0000000 --- a/tools/api.go +++ /dev/null @@ -1,171 +0,0 @@ -package tools - -import ( - "encoding/json" - "honoka-chan/database" - "honoka-chan/model" - "honoka-chan/utils" -) - -func LoadApi1Data(path string) { - apiData := utils.ReadAllText(path) - if apiData != "" { - var obj model.Response - err := json.Unmarshal([]byte(apiData), &obj) - CheckErr(err) - - var data interface{} - if err = json.Unmarshal(obj.ResponseData, &data); err != nil { - panic(err) - } - // resultType := reflect.TypeOf(data) - // if resultType.Kind() == reflect.Map { - // data = data.(map[string]interface{}) - // } - result := data.([]interface{}) - for k, v := range result { - m, err := json.Marshal(v) - CheckErr(err) - - key := "" - switch k { - case 0: - key = "live_status_result" - case 1: - key = "live_list_result" - case 2: - key = "unit_list_result" - case 3: - key = "unit_deck_result" - case 4: - key = "unit_support_result" - case 5: - key = "owning_equip_result" - case 6: - key = "costume_list_result" - case 7: - key = "album_unit_result" - case 8: - key = "scenario_status_result" - case 9: - key = "subscenario_status_result" - case 10: - key = "event_scenario_result" - case 11: - key = "multi_unit_scenario_result" - case 12: - key = "product_result" - case 13: - key = "banner_result" - case 14: - key = "item_marquee_result" - case 15: - key = "user_intro_result" - case 16: - key = "special_cutin_result" - case 17: - key = "award_result" - case 18: - key = "background_result" - case 19: - key = "stamp_result" - case 20: - key = "exchange_point_result" - case 21: - key = "live_se_result" - case 22: - key = "live_icon_result" - case 23: - key = "item_list_result" - case 24: - key = "marathon_result" - case 25: - key = "challenge_result" - } - - if key != "" { - // database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m)) - err = database.LevelDb.Put([]byte(key), m) - CheckErr(err) - } - } - } -} - -func LoadApi2Data(path string) { - apiData := utils.ReadAllText(path) - if apiData != "" { - var obj model.Response - err := json.Unmarshal([]byte(apiData), &obj) - CheckErr(err) - - var data interface{} - err = json.Unmarshal(obj.ResponseData, &data) - CheckErr(err) - // resultType := reflect.TypeOf(data) - // if resultType.Kind() == reflect.Map { - // data = data.(map[string]interface{}) - // } - result := data.([]interface{}) - for k, v := range result { - m, err := json.Marshal(v) - CheckErr(err) - - key := "" - switch k { - case 0: - key = "login_topinfo_result" - case 1: - key = "login_topinfo_once_result" - case 2: - key = "unit_accessory_result" - case 3: - key = "museum_result" - } - - if key != "" { - // database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m)) - err = database.LevelDb.Put([]byte(key), m) - CheckErr(err) - } - } - } -} - -func LoadApi3Data(path string) { - apiData := utils.ReadAllText(path) - if apiData != "" { - var obj model.Response - err := json.Unmarshal([]byte(apiData), &obj) - CheckErr(err) - - var data interface{} - err = json.Unmarshal(obj.ResponseData, &data) - CheckErr(err) - // resultType := reflect.TypeOf(data) - // if resultType.Kind() == reflect.Map { - // data = data.(map[string]interface{}) - // } - result := data.([]interface{}) - for k, v := range result { - m, err := json.Marshal(v) - CheckErr(err) - - key := "" - switch k { - case 0: - key = "profile_livecnt_result" - case 1: - key = "profile_card_ranking_result" - case 2: - key = "profile_info_result" - } - - if key != "" { - // database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m)) - err = database.LevelDb.Put([]byte(key), m) - CheckErr(err) - } - } - } -} diff --git a/tools/create.go b/tools/create.go index c467357..501ec09 100644 --- a/tools/create.go +++ b/tools/create.go @@ -238,7 +238,7 @@ func GenCommonUnitData3() { err := UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck) CheckErr(err) - unitDeckInfo := []model.UnitDeckInfo{} + unitDeckInfo := []model.UnitDeckInfoRes{} for _, deck := range userDeck { deckUnit := []UnitDeckData{} err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) @@ -256,7 +256,7 @@ func GenCommonUnitData3() { if deck.MainFlag == 1 { mainFlag = true } - unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ + unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{ UnitDeckID: deck.DeckID, MainFlag: mainFlag, DeckName: deck.DeckName, diff --git a/tools/gen.go b/tools/gen.go index 7cdf76d..4cd4b2b 100644 --- a/tools/gen.go +++ b/tools/gen.go @@ -199,7 +199,7 @@ func GenApi1Data() { LiveStatusResp := model.LiveStatusResp{ // _ = model.LiveStatusResp{ - Result: model.LiveStatusResult{ + Result: model.LiveStatusRes{ NormalLiveStatusList: normalLives, SpecialLiveStatusList: specialLives, TrainingLiveStatusList: []model.TrainingLiveStatusList{}, @@ -225,7 +225,7 @@ func GenApi1Data() { } liveListResp := model.LiveScheduleResp{ // _ = model.LiveScheduleResp{ - Result: model.LiveScheduleResult{ + Result: model.LiveScheduleRes{ EventList: []interface{}{}, LiveList: livesList, LimitedBonusList: []interface{}{}, @@ -257,7 +257,7 @@ func GenApi1Data() { unitListResp := model.UnitAllResp{ // _ = model.UnitAllResp{ - Result: model.UnitAllResult{ + Result: model.UnitAllRes{ Active: unitsData, Waiting: []model.Waiting{}, }, @@ -273,7 +273,7 @@ func GenApi1Data() { err = UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck) CheckErr(err) - unitDeckInfo := []model.UnitDeckInfo{} + unitDeckInfo := []model.UnitDeckInfoRes{} for _, deck := range userDeck { deckUnit := []UnitDeckData{} err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) @@ -291,7 +291,7 @@ func GenApi1Data() { if deck.MainFlag == 1 { mainFlag = true } - unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ + unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{ UnitDeckID: deck.DeckID, MainFlag: mainFlag, DeckName: deck.DeckName, @@ -310,7 +310,7 @@ func GenApi1Data() { // unit_support_result unitSupportResp := model.UnitSupportResp{ // _ = model.UnitSupportResp{ - Result: model.UnitSupportResult{ + Result: model.UnitSupportRes{ UnitSupportList: []model.UnitSupportList{}, }, // 练习道具 Status: 200, @@ -322,7 +322,7 @@ func GenApi1Data() { // owning_equip_result rmSkillResp := model.RemovableSkillResp{ // _ = model.RemovableSkillResp{ - Result: model.RemovableSkillResult{ + Result: model.RemovableSkillRes{ OwningInfo: []model.OwningInfo{}, EquipmentInfo: map[int]interface{}{}, }, // 宝石 @@ -335,7 +335,7 @@ func GenApi1Data() { // costume_list_result costumeListResp := model.CostumeListResp{ // _ = model.CostumeListResp{ - Result: model.CostumeListResult{ + Result: model.CostumeListRes{ CostumeList: []model.CostumeList{}, }, Status: 200, @@ -425,7 +425,7 @@ func GenApi1Data() { } scenarioResp := model.ScenarioStatusResp{ // _ = model.ScenarioStatusResp{ - Result: model.ScenarioStatusResult{ + Result: model.ScenarioStatusRes{ ScenarioStatusList: scenarioLists, }, Status: 200, @@ -451,7 +451,7 @@ func GenApi1Data() { } subScenarioResp := model.SubscenarioStatusResp{ // _ = model.SubscenarioStatusResp{ - Result: model.SubscenarioStatusResult{ + Result: model.SubscenarioStatusRes{ SubscenarioStatusList: subScenarioLists, UnlockedSubscenarioIds: []interface{}{}, }, @@ -519,7 +519,7 @@ func GenApi1Data() { } eventScenarioResp := model.EventScenarioStatusResp{ // _ = model.EventScenarioStatusResp{ - Result: model.EventScenarioStatusResult{ + Result: model.EventScenarioStatusRes{ EventScenarioList: eventsList, // }, Status: 200, @@ -566,7 +566,7 @@ func GenApi1Data() { } unitsResp := model.MultiUnitScenarioStatusResp{ // _ = model.MultiUnitScenarioStatusResp{ - Result: model.MultiUnitScenarioStatusResult{ + Result: model.MultiUnitScenarioStatusRes{ MultiUnitScenarioStatusList: multiUnitsList, UnlockedMultiUnitScenarioIds: []interface{}{}, }, @@ -579,7 +579,7 @@ func GenApi1Data() { // product_result productResp := model.ProductListResp{ // _ = model.ProductListResp{ - Result: model.ProductListResult{ + Result: model.ProductListRes{ RestrictionInfo: model.RestrictionInfo{ Restricted: false, }, @@ -603,7 +603,7 @@ func GenApi1Data() { // banner_result bannerResp := model.BannerListResp{ // _ = model.BannerListResp{ - Result: model.BannerListResult{ + Result: model.BannerListRes{ TimeLimit: "2037-12-31 23:59:59", BannerList: []model.BannerList{ { @@ -639,7 +639,7 @@ func GenApi1Data() { // item_marquee_result marqueeResp := model.NoticeMarqueeResp{ // _ = model.NoticeMarqueeResp{ - Result: model.NoticeMarqueeResult{ + Result: model.NoticeMarqueeRes{ ItemCount: 0, MarqueeList: []interface{}{}, }, @@ -652,7 +652,7 @@ func GenApi1Data() { // user_intro_result userIntroResp := model.UserNaviResp{ // _ = model.UserNaviResp{ - Result: model.UserNaviResult{ + Result: model.UserNaviRes{ User: model.User{ UserID: 9999999, UnitOwningUserID: CenterId, @@ -667,7 +667,7 @@ func GenApi1Data() { // special_cutin_result cutinResp := model.SpecialCutinResp{ // _ = model.SpecialCutinResp{ - Result: model.SpecialCutinResult{ + Result: model.SpecialCutinRes{ SpecialCutinList: []interface{}{}, }, Status: 200, @@ -698,7 +698,7 @@ func GenApi1Data() { } awardResp := model.AwardInfoResp{ // _ = model.AwardInfoResp{ - Result: model.AwardInfoResult{ + Result: model.AwardInfoRes{ AwardInfo: awardsList, }, Status: 200, @@ -729,7 +729,7 @@ func GenApi1Data() { } backgroundResp := model.BackgroundInfoResp{ // _ = model.BackgroundInfoResp{ - Result: model.BackgroundInfoResult{ + Result: model.BackgroundInfoRes{ BackgroundInfo: backgroundsList, }, Status: 200, @@ -763,7 +763,7 @@ func GenApi1Data() { } exPointsResp := model.ExchangePointResp{ // _ = model.ExchangePointResp{ - Result: model.ExchangePointResult{ + Result: model.ExchangePointRes{ ExchangePointList: exPointsList, }, Status: 200, @@ -775,7 +775,7 @@ func GenApi1Data() { // live_se_result liveSeResp := model.LiveSeInfoResp{ // _ = model.LiveSeInfoResp{ - Result: model.LiveSeInfoResult{ + Result: model.LiveSeInfoRes{ LiveSeList: []int{1, 2, 3}, }, Status: 200, @@ -787,7 +787,7 @@ func GenApi1Data() { // live_icon_result liveIconResp := model.LiveIconInfoResp{ // _ = model.LiveIconInfoResp{ - Result: model.LiveIconInfoResult{ + Result: model.LiveIconInfoRes{ LiveNotesIconList: []int{1, 2, 3}, }, Status: 200, @@ -827,7 +827,7 @@ func GenApi1Data() { // Final k, err := json.Marshal(respAll) CheckErr(err) - resp := model.Response{ + resp := model.ApiResp{ ResponseData: k, ReleaseInfo: []interface{}{}, StatusCode: 200, @@ -846,7 +846,7 @@ func GenApi2Data() { // login_topinfo_result topInfoResp := model.TopInfoResp{ // _ = model.TopInfoResp{ - Result: model.TopInfoResult{ + Result: model.TopInfoRes{ FriendActionCnt: 0, FriendGreetCnt: 0, FriendVarietyCnt: 0, @@ -883,7 +883,7 @@ func GenApi2Data() { // login_topinfo_once_result topInfoOnceResp := model.TopInfoOnceResp{ // _ = model.TopInfoOnceResp{ - Result: model.TopInfoOnceResult{ + Result: model.TopInfoOnceRes{ NewAchievementCnt: 0, UnaccomplishedAchievementCnt: 0, LiveDailyRewardExist: false, @@ -944,9 +944,9 @@ func GenApi2Data() { } museumInfoResp := model.MuseumInfoResp{ - Result: model.MuseumInfoResult{ - MuseumInfo: model.MuseumInfo{ - Parameter: model.MuseumInfoParameter{ + Result: model.MuseumInfoRes{ + MuseumInfo: model.Museum{ + Parameter: model.MuseumParameter{ Smile: smileBuf, Pure: pureBuf, Cool: coolBuf, @@ -963,7 +963,7 @@ func GenApi2Data() { // Final k, err := json.Marshal(respAll) CheckErr(err) - resp := model.Response{ + resp := model.ApiResp{ ResponseData: k, ReleaseInfo: []interface{}{}, StatusCode: 200, @@ -1121,7 +1121,7 @@ func GenApi3Data() { // Final k, err := json.Marshal(respAll) CheckErr(err) - resp := model.Response{ + resp := model.ApiResp{ ResponseData: k, ReleaseInfo: []interface{}{}, StatusCode: 200, diff --git a/tools/tools.go b/tools/tools.go index f7633bc..1d641c5 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -15,13 +15,6 @@ func init() { MainEng = config.MainEng UserEng = config.UserEng - // GenApi1Data() - // GenApi2Data() - // GenApi3Data() - // LoadApi1Data("assets/api1.json") - // LoadApi2Data("assets/api2.json") - // LoadApi3Data("assets/api3.json") - // ListUnitData() // go SyncNotesList() // GenDownloadDb() // GenCommonUnitData() diff --git a/tools/unit.go b/tools/unit.go deleted file mode 100644 index c914b3b..0000000 --- a/tools/unit.go +++ /dev/null @@ -1,125 +0,0 @@ -package tools - -import ( - "encoding/json" - "fmt" - "honoka-chan/model" - "time" - - _ "github.com/mattn/go-sqlite3" -) - -func ListUnitData() { - sql := `SELECT unit_id,rarity,rank_min,rank_max,hp_max,default_removable_skill_capacity FROM unit_m WHERE unit_id NOT IN (SELECT unit_id FROM unit_m WHERE unit_type_id IN (SELECT unit_type_id FROM unit_type_m WHERE image_button_asset IS NULL AND (background_color = 'dcdbe3' AND original_attribute_id IS NULL) OR (unit_type_id IN (10,110,127,128,129) OR unit_type_id BETWEEN 131 AND 140))) ORDER BY unit_number ASC;` - rows, err := MainEng.DB().Query(sql) - CheckErr(err) - defer rows.Close() - - unitsData := []model.Active{} - oId := 3071290948 - sdt := time.Now().Add(-time.Hour * 24 * 30) - - for rows.Next() { - unitData := model.Active{} - var uid, rit, rank, max_rank, hp_max, skill_capacity int - err = rows.Scan(&uid, &rit, &rank, &max_rank, &hp_max, &skill_capacity) - if err != nil { - fmt.Println(err) - continue - } - oId++ - sdt = sdt.Add(time.Second * 3) - - unitData.UnitOwningUserID = oId - unitData.UnitID = uid - unitData.NextExp = 0 - unitData.Rank = rank - unitData.MaxRank = max_rank - unitData.MaxHp = hp_max - unitData.DisplayRank = 2 - unitData.UnitSkillLevel = 8 - unitData.FavoriteFlag = true - unitData.IsRankMax = true - unitData.IsLevelMax = true - unitData.IsLoveMax = true - unitData.IsSkillLevelMax = true - unitData.IsRemovableSkillCapacityMax = true - unitData.InsertDate = sdt.Local().Format("2006-01-02 03:04:05") - if rit != 4 { - unitData.LevelLimitID = 0 - unitData.UnitRemovableSkillCapacity = skill_capacity - unitData.IsSigned = false - switch rit { - case 1: - // N - unitData.Exp = 8000 - unitData.Level = 40 - unitData.MaxLevel = 40 - unitData.Love = 50 - unitData.MaxLove = 50 - unitData.UnitSkillExp = 0 - unitData.UnitSkillLevel = 0 - unitData.FavoriteFlag = false - unitData.IsRankMax = false - unitData.IsLevelMax = false - unitData.IsLoveMax = false - unitData.IsSkillLevelMax = false - unitData.IsRemovableSkillCapacityMax = false - case 2: - // R - unitData.Exp = 13500 - unitData.Level = 60 - unitData.MaxLevel = 60 - unitData.Love = 200 - unitData.MaxLove = 200 - unitData.UnitSkillExp = 490 - case 3: - // SR - unitData.Exp = 36800 - unitData.Level = 80 - unitData.MaxLevel = 80 - unitData.Love = 500 - unitData.MaxLove = 500 - unitData.UnitSkillExp = 4900 - case 5: - // SSR - unitData.Exp = 56657 - unitData.Level = 90 - unitData.MaxLevel = 90 - unitData.Love = 750 - unitData.MaxLove = 750 - unitData.UnitSkillExp = 12700 - } - } else { - // UR - unitData.Exp = 79700 - unitData.Level = 100 - unitData.MaxLevel = 100 - unitData.LevelLimitID = 1 - unitData.Love = 1000 - unitData.MaxLove = 1000 - unitData.UnitSkillExp = 29900 - unitData.UnitRemovableSkillCapacity = 8 - - stmt, err := MainEng.DB().Prepare("SELECT COUNT(*) AS ct FROM unit_sign_asset_m WHERE unit_id = ?") - CheckErr(err) - defer stmt.Close() - - var count int - err = stmt.QueryRow(uid).Scan(&count) - CheckErr(err) - - if count > 0 { - unitData.IsSigned = true - } else { - unitData.IsSigned = false - } - } - - unitsData = append(unitsData, unitData) - } - - data, err := json.Marshal(unitsData) - CheckErr(err) - fmt.Println(string(data)) -} diff --git a/utils/utils.go b/utils/utils.go index 3bf40dc..f0ac614 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,13 +4,9 @@ package utils import ( - "encoding/base64" "encoding/hex" - "errors" "math/rand" - "net/url" "os" - "strconv" "time" ) @@ -52,59 +48,3 @@ func RandomStr(len int) string { return mRandStr } - -func RandomBase64Token(len int) string { - rand.NewSource(time.Now().UnixNano()) - mRand := make([]byte, len) - rand.Read(mRand) - mRandStr := hex.EncodeToString(mRand)[0:len] - - return base64.RawStdEncoding.EncodeToString([]byte(mRandStr)) -} - -func ParseAuthorizeStr(authorize []string) (url.Values, error) { - if len(authorize) == 0 { - return nil, errors.New("authorize is null") - } - urlParams, err := url.ParseQuery(authorize[0]) - if err != nil { - return nil, err - } - - return urlParams, nil -} - -func GetAuthorizeToken(authorize []string) (string, error) { - params, err := ParseAuthorizeStr(authorize) - if err != nil { - return "", err - } - token := params["token"] - if len(token) == 0 { - return "", errors.New("token is null") - } - - return token[0], nil -} - -func GetAuthorizeNonce(authorize []string) (int, error) { - params, err := ParseAuthorizeStr(authorize) - if err != nil { - return 0, err - } - nonce := params["nonce"] - if len(nonce) == 0 { - return 0, errors.New("nonce is null") - } - - n_nonce, err := strconv.Atoi(nonce[0]) - if err != nil { - return 0, err - } - - if n_nonce == 0 { - return 0, errors.New("nonce is 0") - } - - return n_nonce, nil -} diff --git a/xclog/xclog.go b/xclog/xclog.go deleted file mode 100644 index e1d773a..0000000 --- a/xclog/xclog.go +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (C) 2022 YumeMichi -// -// SPDX-License-Identifier: Apache-2.0 -package xclog - -import ( - "errors" - "fmt" - "log" - "os" - "runtime" - "strconv" - "strings" - "time" -) - -// Logg 日志 -type Logg struct { - fileDir string - fileName string - filePre string - saveFile bool - level int - date string - log *log.Logger -} - -// LogConf config struct of log -type LogConf struct { - FileDir string `json:"file_dir"` - FilePre string `json:"file_pre"` - Level int `json:"level"` - SaveFile bool `json:"save_file"` -} - -var ( - lgg *Logg - levelLinePre = map[int]string{ - 1: "[F]", - 2: "[E]", - 3: "[W]", - 4: "[I]", - 5: "[D]", - } -) - -// 为防止未初始化调用奔溃,使用init默认参数初始化 -func init() { - lgg, _ = New("./", "", "", 5, false) -} - -// Init 使用参数初始化 -func Init(fileDir, filePre string, level int, saveFile bool) (*Logg, error) { - var fileName string - - if level > 5 || level < 1 { - level = 5 - } - - if !strings.HasSuffix(fileDir, "/") { - fileDir = fileDir + "/" - } else if fileDir == "" { - fileDir = "./" - } - - date := getNowDate() - - if filePre != "" { - filePre = filePre + "_" - } - stat, err := os.Stat(fileDir) - if err != nil && os.IsNotExist(err) { - os.MkdirAll(fileDir, 0777) - } else if err != nil { - return nil, err - } else if !stat.IsDir() { - return nil, errors.New("log_dir is not dir:" + fileDir) - } - fileName = fileDir + filePre + date + ".log" - newLogg, err := New(fileDir, filePre, fileName, level, saveFile) - if err != nil { - fmt.Println("Init log error:", err.Error()) - return nil, err - } - - lgg = newLogg - return lgg, nil -} - -// InitByLogConf -func InitByLogConf(lc LogConf) (*Logg, error) { - return Init(lc.FileDir, lc.FilePre, lc.Level, lc.SaveFile) -} - -// New 返回一个日志实体,与默认不同的独立的日志,通过返回的Logg调用方法 -func New(fileDir, filePre, fileName string, level int, saveFile bool) (*Logg, error) { - // file, err := os.Create(fileName) - var newLogg = &Logg{ - fileDir: fileDir, - filePre: filePre, - date: getNowDate(), - level: level, - fileName: fileName, - saveFile: saveFile, - } - - if saveFile { - file, err := os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModeAppend) - if err != nil { - return nil, err - } - os.Chmod(fileName, 0777) - newLogg.log = log.New(file, "", 0) - } - - return newLogg, nil -} - -func getNowDate() string { - return time.Now().Format("2006-01-02") -} - -// Debug Debug -func Debug(args ...interface{}) { - lgg.Debug(args...) -} - -// Debugf Debugf -func Debugf(format string, args ...interface{}) { - lgg.Debugf(format, args...) -} - -// Debug Debug -func (lg *Logg) Debug(args ...interface{}) { - lg.writeLine(5, args...) -} - -// Debugf format debug -func (lg *Logg) Debugf(format string, args ...interface{}) { - lg.writeLine(5, fmt.Sprintf(format, args...)) -} - -// Info Info -func Info(args ...interface{}) { - lgg.Info(args...) -} - -// Infof Infof -func Infof(format string, args ...interface{}) { - lgg.Infof(format, args...) -} - -// Info Info -func (lg *Logg) Info(args ...interface{}) { - lg.writeLine(4, args...) -} - -// Infof format debug -func (lg *Logg) Infof(format string, args ...interface{}) { - lg.writeLine(4, fmt.Sprintf(format, args...)) -} - -// Warn Warn -func Warn(args ...interface{}) { - lgg.Warn(args...) -} - -// Warnf Warnf -func Warnf(format string, args ...interface{}) { - lgg.Warnf(format, args...) -} - -// Warn Warn -func (lg *Logg) Warn(args ...interface{}) { - lg.writeLine(3, args...) -} - -// Warnf format debug -func (lg *Logg) Warnf(format string, args ...interface{}) { - lg.writeLine(3, fmt.Sprintf(format, args...)) -} - -// Error Error -func Error(args ...interface{}) { - lgg.Error(args...) -} - -// Errorf Errorf -func Errorf(format string, args ...interface{}) { - lgg.Errorf(format, args...) -} - -// Error Error -func (lg *Logg) Error(args ...interface{}) { - lg.writeLine(2, args...) -} - -// Errorf format debug -func (lg *Logg) Errorf(format string, args ...interface{}) { - lg.writeLine(2, fmt.Sprintf(format, args...)) -} - -// Fatal Fatal -func Fatal(args ...interface{}) { - lgg.Fatal(args...) -} - -// Fatalf Fatalf -func Fatalf(format string, args ...interface{}) { - lgg.Fatalf(format, args...) -} - -// Fatal Fatal -func (lg *Logg) Fatal(args ...interface{}) { - lg.writeLine(1, args...) -} - -// Fatalf format debug -func (lg *Logg) Fatalf(format string, args ...interface{}) { - lg.writeLine(1, fmt.Sprintf(format, args...)) -} - -// writeLine ... -func (lg *Logg) writeLine(level int, args ...interface{}) { - _, file, line, _ := runtime.Caller(3) - fileArr := strings.Split(file, "/") - a := []interface{}{time.Now().Format("2006/01/02 15:04:05"), fileArr[len(fileArr)-1] + ":" + strconv.Itoa(line) + ":", levelLinePre[level]} - a = append(a, args...) - if !lg.saveFile { - fmt.Println(a...) - if level == 1 { - os.Exit(1) - } - return - } - nowDate := getNowDate() - if nowDate != lg.date { - // 切割日志文件 - newFile := lg.fileDir + lg.filePre + nowDate + ".log" - f, err := os.OpenFile(newFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModeAppend) - if err != nil { - lg.log.Println("[E]", "create new log file:", err.Error()) - } else { - lg.log.SetOutput(f) - lg.date = nowDate - lg.fileName = newFile - } - } - - if level == 1 { - lg.log.Fatal(a...) - } - - if level <= lg.level { - lg.log.Println(a...) - } -}