Code cleanup

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-04-24 17:50:39 +08:00
parent e1e0e8c27d
commit 327b4a222b
56 changed files with 907 additions and 1610 deletions
-1
View File
@@ -2,7 +2,6 @@ honoka-chan
honoka-chan.exe honoka-chan.exe
data data
logs
assets/data.db assets/data.db
assets/unit.sd assets/unit.sd
-9
View File
@@ -1,13 +1,4 @@
app_name: LL! SIF Private Server 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: leveldb:
data_path: ./data/honoka-chan.db data_path: ./data/honoka-chan.db
cdn: cdn:
+5 -2
View File
@@ -12,13 +12,16 @@ import (
) )
var ( var (
ConfName = "config.yml" ConfName = "config.yml"
Conf = &AppConfigs{} Conf = &AppConfigs{}
ExampleDb = "assets/data.example.db" ExampleDb = "assets/data.example.db"
MainDb = "assets/main.db" MainDb = "assets/main.db"
UserDb = "assets/data.db" UserDb = "assets/data.db"
MainEng *xorm.Engine MainEng *xorm.Engine
UserEng *xorm.Engine UserEng *xorm.Engine
PackageVersion = "97.4.6"
) )
func init() { func init() {
+4 -30
View File
@@ -4,8 +4,8 @@
package config package config
import ( import (
"fmt"
"honoka-chan/utils" "honoka-chan/utils"
"honoka-chan/xclog"
"os" "os"
"strconv" "strconv"
"time" "time"
@@ -15,25 +15,10 @@ import (
type AppConfigs struct { type AppConfigs struct {
AppName string `yaml:"app_name"` AppName string `yaml:"app_name"`
Server ServerConfigs `yaml:"server"`
Log LogConfigs `yaml:"log"`
LevelDb LevelDbConfigs `yaml:"leveldb"` LevelDb LevelDbConfigs `yaml:"leveldb"`
Cdn CdnConfigs `yaml:"cdn"` 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 { type LevelDbConfigs struct {
DataPath string `yaml:"data_path"` DataPath string `yaml:"data_path"`
} }
@@ -45,17 +30,6 @@ type CdnConfigs struct {
func DefaultConfigs() *AppConfigs { func DefaultConfigs() *AppConfigs {
return &AppConfigs{ return &AppConfigs{
AppName: "LL! SIF Private Server", 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{ LevelDb: LevelDbConfigs{
DataPath: "./data/honoka-chan.db", DataPath: "./data/honoka-chan.db",
}, },
@@ -72,20 +46,20 @@ func Load(p string) *AppConfigs {
c := AppConfigs{} c := AppConfigs{}
err := yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c) err := yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c)
if err != nil { 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)) _ = os.Rename(p, p+".backup"+strconv.FormatInt(time.Now().Unix(), 10))
_ = DefaultConfigs().Save(p) _ = DefaultConfigs().Save(p)
} }
c = AppConfigs{} c = AppConfigs{}
_ = yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c) _ = yaml.Unmarshal([]byte(utils.ReadAllText(p)), &c)
xclog.Info(ConfName + " loaded!") fmt.Println(ConfName + "loaded!")
return &c return &c
} }
func (c *AppConfigs) Save(p string) error { func (c *AppConfigs) Save(p string) error {
data, err := yaml.Marshal(c) data, err := yaml.Marshal(c)
if err != nil { if err != nil {
xclog.Error("Failed to save " + ConfName + ": " + err.Error()) fmt.Println("Failed to save" + ConfName + ":" + err.Error())
return err return err
} }
utils.WriteAllText(p, string(data)) utils.WriteAllText(p, string(data))
+14 -26
View File
@@ -13,7 +13,12 @@ import (
_ "github.com/mattn/go-sqlite3" _ "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 var albumIds []int
err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds) err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
CheckErr(err) CheckErr(err)
@@ -21,21 +26,14 @@ func AlbumSeriesAllHandler(ctx *gin.Context) {
albumSeriesAllRes := []model.AlbumSeriesRes{} albumSeriesAllRes := []model.AlbumSeriesRes{}
for _, albumId := range albumIds { for _, albumId := range albumIds {
AlbumStmt, err := MainEng.DB().Prepare("SELECT unit_id,rarity FROM unit_m WHERE album_series_id = ?") unitList := []AlbumSearchResult{}
CheckErr(err) err = MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList)
defer AlbumStmt.Close()
rows, err := AlbumStmt.Query(albumId)
CheckErr(err) CheckErr(err)
albumSeriesAll := []model.AlbumResult{} albumSeriesAll := []model.AlbumResult{}
for rows.Next() { for _, unit := range unitList {
var unitId, rarity int
err = rows.Scan(&unitId, &rarity)
CheckErr(err)
albumSeries := model.AlbumResult{ albumSeries := model.AlbumResult{
UnitID: unitId, UnitID: unit.UnitId,
RankMaxFlag: true, RankMaxFlag: true,
LoveMaxFlag: true, LoveMaxFlag: true,
RankLevelMaxFlag: true, RankLevelMaxFlag: true,
@@ -44,8 +42,8 @@ func AlbumSeriesAllHandler(ctx *gin.Context) {
FavoritePoint: 1000, FavoritePoint: 1000,
} }
if rarity != 4 { if unit.Rarity != 4 {
switch rarity { switch unit.Rarity {
case 1: case 1:
// N // N
albumSeries.HighestLovePerUnit = 50 albumSeries.HighestLovePerUnit = 50
@@ -64,19 +62,9 @@ func AlbumSeriesAllHandler(ctx *gin.Context) {
albumSeries.HighestLovePerUnit = 1000 albumSeries.HighestLovePerUnit = 1000
// IsSigned // 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) CheckErr(err)
defer signStmt.Close() albumSeries.SignFlag = exists
var count int
err = signStmt.QueryRow(unitId).Scan(&count)
CheckErr(err)
if count > 0 {
albumSeries.SignFlag = true
} else {
albumSeries.SignFlag = false
}
} }
albumSeriesAll = append(albumSeriesAll, albumSeries) albumSeriesAll = append(albumSeriesAll, albumSeries)
+2 -2
View File
@@ -13,14 +13,14 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func AnnounceIndexHandler(ctx *gin.Context) { func AnnounceIndex(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{ ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{
"title": "Love Live! 学园偶像祭 非官方服务器", "title": "Love Live! 学园偶像祭 非官方服务器",
"content": template.HTML("目前开发完毕的功能包括:登录、相册、Live、个人信息。<br>其他功能仍在开发中,有报错属于正常现象。"), "content": template.HTML("目前开发完毕的功能包括:登录、相册、Live、个人信息。<br>其他功能仍在开发中,有报错属于正常现象。"),
}) })
} }
func AnnounceCheckStateHandler(ctx *gin.Context) { func AnnounceCheckState(ctx *gin.Context) {
announceResp := model.AnnounceResp{ announceResp := model.AnnounceResp{
ResponseData: model.AnnounceRes{ ResponseData: model.AnnounceRes{
HasUnreadAnnounce: false, HasUnreadAnnounce: false,
+89 -147
View File
@@ -17,29 +17,26 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func ApiHandler(ctx *gin.Context) { func Api(ctx *gin.Context) {
userId, err := strconv.Atoi(ctx.GetString("userid")) apiReq := []model.ApiReq{}
CheckErr(err) err := json.Unmarshal([]byte(ctx.GetString("request_data")), &apiReq)
var formdata []model.SifApi
err = json.Unmarshal([]byte(ctx.GetString("request_data")), &formdata)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
var results []interface{} results := []interface{}{}
for _, v := range formdata { for _, v := range apiReq {
var res []byte var res []byte
var err error var err error
// fmt.Println(v) // fmt.Println(v)
fmt.Println(v.Module, v.Action) // fmt.Println(v.Module, v.Action)
switch v.Module { switch v.Module {
case "login": case "login":
if v.Action == "topInfo" { if v.Action == "topInfo" {
// key = "login_topinfo_result" // key = "login_topinfo_result"
topInfoResp := model.TopInfoResp{ topInfoResp := model.TopInfoResp{
Result: model.TopInfoResult{ Result: model.TopInfoRes{
FriendActionCnt: 0, FriendActionCnt: 0,
FriendGreetCnt: 0, FriendGreetCnt: 0,
FriendVarietyCnt: 0, FriendVarietyCnt: 0,
@@ -76,7 +73,7 @@ func ApiHandler(ctx *gin.Context) {
} else if v.Action == "topInfoOnce" { } else if v.Action == "topInfoOnce" {
// key = "login_topinfo_once_result" // key = "login_topinfo_once_result"
topInfoOnceResp := model.TopInfoOnceResp{ topInfoOnceResp := model.TopInfoOnceResp{
Result: model.TopInfoOnceResult{ Result: model.TopInfoOnceRes{
NewAchievementCnt: 0, NewAchievementCnt: 0,
UnaccomplishedAchievementCnt: 0, UnaccomplishedAchievementCnt: 0,
LiveDailyRewardExist: false, LiveDailyRewardExist: false,
@@ -109,18 +106,13 @@ func ApiHandler(ctx *gin.Context) {
case "live": case "live":
if v.Action == "liveStatus" { if v.Action == "liveStatus" {
// key = "live_status_result" // key = "live_status_result"
var liveDifficultyId int var liveDifficultyId []int
normalLives := []model.NormalLiveStatusList{} normalLives := []model.NormalLiveStatusList{}
sql := `SELECT live_difficulty_id FROM normal_live_m ORDER BY live_difficulty_id ASC` err = MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
rows, err := MainEng.DB().Query(sql)
CheckErr(err) CheckErr(err)
defer rows.Close() for _, id := range liveDifficultyId {
for rows.Next() {
err = rows.Scan(&liveDifficultyId)
CheckErr(err)
normalLive := model.NormalLiveStatusList{ normalLive := model.NormalLiveStatusList{
LiveDifficultyID: liveDifficultyId, LiveDifficultyID: id,
Status: 1, Status: 1,
HiScore: 0, HiScore: 0,
HiComboCount: 0, HiComboCount: 0,
@@ -131,16 +123,11 @@ func ApiHandler(ctx *gin.Context) {
} }
specialLives := []model.SpecialLiveStatusList{} specialLives := []model.SpecialLiveStatusList{}
sql = `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC` err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
rows, err = MainEng.DB().Query(sql)
CheckErr(err) CheckErr(err)
defer rows.Close() for _, id := range liveDifficultyId {
for rows.Next() {
err = rows.Scan(&liveDifficultyId)
CheckErr(err)
specialLive := model.SpecialLiveStatusList{ specialLive := model.SpecialLiveStatusList{
LiveDifficultyID: liveDifficultyId, LiveDifficultyID: id,
Status: 1, Status: 1,
HiScore: 0, HiScore: 0,
HiComboCount: 0, HiComboCount: 0,
@@ -151,7 +138,7 @@ func ApiHandler(ctx *gin.Context) {
} }
LiveStatusResp := model.LiveStatusResp{ LiveStatusResp := model.LiveStatusResp{
Result: model.LiveStatusResult{ Result: model.LiveStatusRes{
NormalLiveStatusList: normalLives, NormalLiveStatusList: normalLives,
SpecialLiveStatusList: specialLives, SpecialLiveStatusList: specialLives,
TrainingLiveStatusList: []model.TrainingLiveStatusList{}, TrainingLiveStatusList: []model.TrainingLiveStatusList{},
@@ -167,18 +154,13 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
} else if v.Action == "schedule" { } else if v.Action == "schedule" {
// key = "live_list_result" // key = "live_list_result"
var liveDifficultyId int var liveDifficultyId []int
specialLives := []model.SpecialLiveStatusList{} specialLives := []model.SpecialLiveStatusList{}
sql := `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC` err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
rows, err := MainEng.DB().Query(sql)
CheckErr(err) CheckErr(err)
defer rows.Close() for _, id := range liveDifficultyId {
for rows.Next() {
err = rows.Scan(&liveDifficultyId)
CheckErr(err)
specialLive := model.SpecialLiveStatusList{ specialLive := model.SpecialLiveStatusList{
LiveDifficultyID: liveDifficultyId, LiveDifficultyID: id,
Status: 1, Status: 1,
HiScore: 0, HiScore: 0,
HiComboCount: 0, HiComboCount: 0,
@@ -198,7 +180,7 @@ func ApiHandler(ctx *gin.Context) {
}) })
} }
liveListResp := model.LiveScheduleResp{ liveListResp := model.LiveScheduleResp{
Result: model.LiveScheduleResult{ Result: model.LiveScheduleRes{
EventList: []interface{}{}, EventList: []interface{}{},
LiveList: livesList, LiveList: livesList,
LimitedBonusList: []interface{}{}, LimitedBonusList: []interface{}{},
@@ -229,11 +211,10 @@ func ApiHandler(ctx *gin.Context) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
unitsData = append(unitsData, userUnits...) unitsData = append(unitsData, userUnits...)
unitListResp := model.UnitAllResp{ unitListResp := model.UnitAllResp{
Result: model.UnitAllResult{ Result: model.UnitAllRes{
Active: unitsData, Active: unitsData,
Waiting: []model.Waiting{}, Waiting: []model.Waiting{},
}, },
@@ -246,10 +227,10 @@ func ApiHandler(ctx *gin.Context) {
case "deckInfo": case "deckInfo":
// key = "unit_deck_result" // key = "unit_deck_result"
userDeck := []tools.UserDeckData{} 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) CheckErr(err)
unitDeckInfo := []model.UnitDeckInfo{} unitDeckInfo := []model.UnitDeckInfoRes{}
for _, deck := range userDeck { for _, deck := range userDeck {
deckUnit := []tools.UnitDeckData{} deckUnit := []tools.UnitDeckData{}
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) 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 { if deck.MainFlag == 1 {
mainFlag = true mainFlag = true
} }
unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{
UnitDeckID: deck.DeckID, UnitDeckID: deck.DeckID,
MainFlag: mainFlag, MainFlag: mainFlag,
DeckName: deck.DeckName, DeckName: deck.DeckName,
@@ -285,7 +266,7 @@ func ApiHandler(ctx *gin.Context) {
case "supporterAll": case "supporterAll":
// key = "unit_support_result" // key = "unit_support_result"
unitSupportResp := model.UnitSupportResp{ unitSupportResp := model.UnitSupportResp{
Result: model.UnitSupportResult{ Result: model.UnitSupportRes{
UnitSupportList: []model.UnitSupportList{}, UnitSupportList: []model.UnitSupportList{},
}, // 练习道具 }, // 练习道具
Status: 200, Status: 200,
@@ -322,10 +303,6 @@ func ApiHandler(ctx *gin.Context) {
owingInfo = append(owingInfo, info) 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 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) 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) CheckErr(err)
@@ -344,7 +321,7 @@ func ApiHandler(ctx *gin.Context) {
} }
rmSkillResp := model.RemovableSkillResp{ rmSkillResp := model.RemovableSkillResp{
Result: model.RemovableSkillResult{ Result: model.RemovableSkillRes{
OwningInfo: owingInfo, OwningInfo: owingInfo,
EquipmentInfo: equipInfo, EquipmentInfo: equipInfo,
}, // 宝石 }, // 宝石
@@ -390,7 +367,7 @@ func ApiHandler(ctx *gin.Context) {
case "costume": case "costume":
// key = "costume_list_result" // key = "costume_list_result"
costumeListResp := model.CostumeListResp{ costumeListResp := model.CostumeListResp{
Result: model.CostumeListResult{ Result: model.CostumeListRes{
CostumeList: []model.CostumeList{}, CostumeList: []model.CostumeList{},
}, },
Status: 200, Status: 200,
@@ -402,11 +379,10 @@ func ApiHandler(ctx *gin.Context) {
case "album": case "album":
// key = "album_unit_result" // key = "album_unit_result"
albumLists := []model.AlbumResult{} albumLists := []model.AlbumResult{}
sql := `SELECT unit_id,rarity FROM unit_m ORDER BY unit_id ASC` unitList := []AlbumSearchResult{}
rows, err := MainEng.DB().Query(sql) err = MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
CheckErr(err) CheckErr(err)
defer rows.Close() for _, unit := range unitList {
for rows.Next() {
albumList := model.AlbumResult{ albumList := model.AlbumResult{
RankMaxFlag: true, RankMaxFlag: true,
LoveMaxFlag: true, LoveMaxFlag: true,
@@ -414,22 +390,19 @@ func ApiHandler(ctx *gin.Context) {
AllMaxFlag: true, AllMaxFlag: true,
FavoritePoint: 1000, FavoritePoint: 1000,
} }
var uid, rit int albumList.UnitID = unit.UnitId
err = rows.Scan(&uid, &rit) if unit.Rarity != 4 {
CheckErr(err)
albumList.UnitID = uid
if rit != 4 {
albumList.SignFlag = false albumList.SignFlag = false
if rit == 1 { if unit.Rarity == 1 {
albumList.HighestLovePerUnit = 50 albumList.HighestLovePerUnit = 50
albumList.TotalLove = 50 albumList.TotalLove = 50
} else if rit == 2 { } else if unit.Rarity == 2 {
albumList.HighestLovePerUnit = 200 albumList.HighestLovePerUnit = 200
albumList.TotalLove = 200 albumList.TotalLove = 200
} else if rit == 3 { } else if unit.Rarity == 3 {
albumList.HighestLovePerUnit = 500 albumList.HighestLovePerUnit = 500
albumList.TotalLove = 500 albumList.TotalLove = 500
} else if rit == 5 { } else if unit.Rarity == 5 {
albumList.HighestLovePerUnit = 750 albumList.HighestLovePerUnit = 750
albumList.TotalLove = 750 albumList.TotalLove = 750
} }
@@ -437,19 +410,10 @@ func ApiHandler(ctx *gin.Context) {
albumList.HighestLovePerUnit = 1000 albumList.HighestLovePerUnit = 1000
albumList.TotalLove = 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) CheckErr(err)
defer stmt.Close() albumList.SignFlag = exists
var count int
err = stmt.QueryRow(uid).Scan(&count)
CheckErr(err)
if count > 0 {
albumList.SignFlag = true
} else {
albumList.SignFlag = false
}
} }
albumLists = append(albumLists, albumList) albumLists = append(albumLists, albumList)
} }
@@ -464,22 +428,18 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
case "scenario": case "scenario":
// key = "scenario_status_result" // key = "scenario_status_result"
sql := `SELECT scenario_id FROM scenario_m ORDER BY scenario_id ASC` var scenarioIds []int
rows, err := MainEng.DB().Query(sql)
CheckErr(err)
defer rows.Close()
scenarioLists := []model.ScenarioStatusList{} scenarioLists := []model.ScenarioStatusList{}
for rows.Next() { err = MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioIds)
var sid int CheckErr(err)
err = rows.Scan(&sid) for _, id := range scenarioIds {
CheckErr(err)
scenarioLists = append(scenarioLists, model.ScenarioStatusList{ scenarioLists = append(scenarioLists, model.ScenarioStatusList{
ScenarioID: sid, ScenarioID: id,
Status: 2, Status: 2,
}) })
} }
scenarioResp := model.ScenarioStatusResp{ scenarioResp := model.ScenarioStatusResp{
Result: model.ScenarioStatusResult{ Result: model.ScenarioStatusRes{
ScenarioStatusList: scenarioLists, ScenarioStatusList: scenarioLists,
}, },
Status: 200, Status: 200,
@@ -490,22 +450,18 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
case "subscenario": case "subscenario":
// key = "subscenario_status_result" // key = "subscenario_status_result"
sql := `SELECT subscenario_id FROM subscenario_m ORDER BY subscenario_id ASC` var subScenarioIds []int
rows, err := MainEng.DB().Query(sql)
CheckErr(err)
defer rows.Close()
subScenarioLists := []model.SubscenarioStatusList{} subScenarioLists := []model.SubscenarioStatusList{}
for rows.Next() { err = MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioIds)
var sid int CheckErr(err)
err = rows.Scan(&sid) for _, id := range subScenarioIds {
CheckErr(err)
subScenarioLists = append(subScenarioLists, model.SubscenarioStatusList{ subScenarioLists = append(subScenarioLists, model.SubscenarioStatusList{
SubscenarioID: sid, SubscenarioID: id,
Status: 2, Status: 2,
}) })
} }
subScenarioResp := model.SubscenarioStatusResp{ subScenarioResp := model.SubscenarioStatusResp{
Result: model.SubscenarioStatusResult{ Result: model.SubscenarioStatusRes{
SubscenarioStatusList: subScenarioLists, SubscenarioStatusList: subScenarioLists,
UnlockedSubscenarioIds: []interface{}{}, UnlockedSubscenarioIds: []interface{}{},
}, },
@@ -517,18 +473,13 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
case "eventscenario": case "eventscenario":
// key = "event_scenario_result" // key = "event_scenario_result"
var eventIds []int
eventsList := []model.EventScenarioList{} eventsList := []model.EventScenarioList{}
sql := `SELECT event_id FROM event_scenario_m GROUP BY event_id ORDER BY event_id DESC` err = MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds)
rows, err := MainEng.DB().Query(sql)
CheckErr(err) CheckErr(err)
defer rows.Close() for _, id := range eventIds {
for rows.Next() { sql := `SELECT event_scenario_id,chapter,chapter_asset,open_date FROM event_scenario_m WHERE event_id = ? ORDER BY chapter DESC`
var eventId int chaps, err := MainEng.DB().Query(sql, id)
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)
CheckErr(err) CheckErr(err)
defer chaps.Close() defer chaps.Close()
chapsList := []model.EventScenarioChapterList{} chapsList := []model.EventScenarioChapterList{}
@@ -556,24 +507,24 @@ func ApiHandler(ctx *gin.Context) {
} }
eventList := model.EventScenarioList{ eventList := model.EventScenarioList{
EventID: eventId, EventID: id,
OpenDate: strings.ReplaceAll(open_date, "/", "-"), OpenDate: strings.ReplaceAll(open_date, "/", "-"),
ChapterList: chapsList, ChapterList: chapsList,
} }
// HACK event_scenario_btn_asset // HACK event_scenario_btn_asset
if eventId == 10001 { if id == 10001 {
eventList.EventScenarioBtnAsset = "assets/image/ui/eventscenario/38_se_ba_t.png" 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" eventList.EventScenarioBtnAsset = "assets/image/ui/eventscenario/215_se_ba_t.png"
} else { } 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) eventsList = append(eventsList, eventList)
} }
eventScenarioResp := model.EventScenarioStatusResp{ eventScenarioResp := model.EventScenarioStatusResp{
Result: model.EventScenarioStatusResult{ Result: model.EventScenarioStatusRes{
EventScenarioList: eventsList, // EventScenarioList: eventsList, //
}, },
Status: 200, Status: 200,
@@ -584,18 +535,13 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
case "multiunit": case "multiunit":
// key = "multi_unit_scenario_result" // 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` var multiIds []int
rows, err := MainEng.DB().Query(sql)
CheckErr(err)
defer rows.Close()
var mId int
multiUnitsList := []model.MultiUnitScenarioStatusList{} multiUnitsList := []model.MultiUnitScenarioStatusList{}
for rows.Next() { err = MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds)
err = rows.Scan(&mId) CheckErr(err)
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 = ?`
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)
units, err := MainEng.DB().Query(sql, mId)
CheckErr(err) CheckErr(err)
defer units.Close() defer units.Close()
var multi_unit_scenario_id, chapter int var multi_unit_scenario_id, chapter int
@@ -606,7 +552,7 @@ func ApiHandler(ctx *gin.Context) {
} }
multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{ multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{
MultiUnitID: mId, MultiUnitID: id,
Status: 2, Status: 2,
MultiUnitScenarioBtnAsset: multi_unit_scenario_btn_asset, MultiUnitScenarioBtnAsset: multi_unit_scenario_btn_asset,
OpenDate: strings.ReplaceAll(open_date, "/", "-"), OpenDate: strings.ReplaceAll(open_date, "/", "-"),
@@ -620,7 +566,7 @@ func ApiHandler(ctx *gin.Context) {
}) })
} }
unitsResp := model.MultiUnitScenarioStatusResp{ unitsResp := model.MultiUnitScenarioStatusResp{
Result: model.MultiUnitScenarioStatusResult{ Result: model.MultiUnitScenarioStatusRes{
MultiUnitScenarioStatusList: multiUnitsList, MultiUnitScenarioStatusList: multiUnitsList,
UnlockedMultiUnitScenarioIds: []interface{}{}, UnlockedMultiUnitScenarioIds: []interface{}{},
}, },
@@ -633,7 +579,7 @@ func ApiHandler(ctx *gin.Context) {
case "payment": case "payment":
// key = "product_result" // key = "product_result"
productResp := model.ProductListResp{ productResp := model.ProductListResp{
Result: model.ProductListResult{ Result: model.ProductListRes{
RestrictionInfo: model.RestrictionInfo{ RestrictionInfo: model.RestrictionInfo{
Restricted: false, Restricted: false,
}, },
@@ -657,7 +603,7 @@ func ApiHandler(ctx *gin.Context) {
case "banner": case "banner":
// key = "banner_result" // key = "banner_result"
bannerResp := model.BannerListResp{ bannerResp := model.BannerListResp{
Result: model.BannerListResult{ Result: model.BannerListRes{
TimeLimit: "2037-12-31 23:59:59", TimeLimit: "2037-12-31 23:59:59",
BannerList: []model.BannerList{ BannerList: []model.BannerList{
{ {
@@ -693,7 +639,7 @@ func ApiHandler(ctx *gin.Context) {
case "notice": case "notice":
// key = "item_marquee_result" // key = "item_marquee_result"
marqueeResp := model.NoticeMarqueeResp{ marqueeResp := model.NoticeMarqueeResp{
Result: model.NoticeMarqueeResult{ Result: model.NoticeMarqueeRes{
ItemCount: 0, ItemCount: 0,
MarqueeList: []interface{}{}, 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) _, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_id,unit_owning_user_id").Get(&uId, &oId)
CheckErr(err) CheckErr(err)
userIntroResp := model.UserNaviResp{ userIntroResp := model.UserNaviResp{
Result: model.UserNaviResult{ Result: model.UserNaviRes{
User: model.User{ User: model.User{
UserID: uId, UserID: uId,
UnitOwningUserID: oId, UnitOwningUserID: oId,
@@ -724,7 +670,7 @@ func ApiHandler(ctx *gin.Context) {
case "navigation": case "navigation":
// key = "special_cutin_result" // key = "special_cutin_result"
cutinResp := model.SpecialCutinResp{ cutinResp := model.SpecialCutinResp{
Result: model.SpecialCutinResult{ Result: model.SpecialCutinRes{
SpecialCutinList: []interface{}{}, SpecialCutinList: []interface{}{},
}, },
Status: 200, Status: 200,
@@ -756,7 +702,7 @@ func ApiHandler(ctx *gin.Context) {
} }
awardResp := model.AwardInfoResp{ awardResp := model.AwardInfoResp{
Result: model.AwardInfoResult{ Result: model.AwardInfoRes{
AwardInfo: awardsList, AwardInfo: awardsList,
}, },
Status: 200, Status: 200,
@@ -788,7 +734,7 @@ func ApiHandler(ctx *gin.Context) {
} }
backgroundResp := model.BackgroundInfoResp{ backgroundResp := model.BackgroundInfoResp{
Result: model.BackgroundInfoResult{ Result: model.BackgroundInfoRes{
BackgroundInfo: backgroundsList, BackgroundInfo: backgroundsList,
}, },
Status: 200, Status: 200,
@@ -807,22 +753,18 @@ func ApiHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
case "exchange": case "exchange":
// key = "exchange_point_result" // key = "exchange_point_result"
sql := `SELECT exchange_point_id FROM exchange_point_m ORDER BY exchange_point_id ASC` var exchangeIds []int
rows, err := MainEng.DB().Query(sql)
CheckErr(err)
defer rows.Close()
exPointsList := []model.ExchangePointList{} exPointsList := []model.ExchangePointList{}
for rows.Next() { err = MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeIds)
var eId int CheckErr(err)
err = rows.Scan(&eId) for _, id := range exchangeIds {
CheckErr(err)
exPointsList = append(exPointsList, model.ExchangePointList{ exPointsList = append(exPointsList, model.ExchangePointList{
Rarity: eId, Rarity: id,
ExchangePoint: 9999, ExchangePoint: 9999,
}) })
} }
exPointsResp := model.ExchangePointResp{ exPointsResp := model.ExchangePointResp{
Result: model.ExchangePointResult{ Result: model.ExchangePointRes{
ExchangePointList: exPointsList, ExchangePointList: exPointsList,
}, },
Status: 200, Status: 200,
@@ -834,7 +776,7 @@ func ApiHandler(ctx *gin.Context) {
case "livese": case "livese":
// key = "live_se_result" // key = "live_se_result"
liveSeResp := model.LiveSeInfoResp{ liveSeResp := model.LiveSeInfoResp{
Result: model.LiveSeInfoResult{ Result: model.LiveSeInfoRes{
LiveSeList: []int{1, 2, 3}, LiveSeList: []int{1, 2, 3},
}, },
Status: 200, Status: 200,
@@ -846,7 +788,7 @@ func ApiHandler(ctx *gin.Context) {
case "liveicon": case "liveicon":
// key = "live_icon_result" // key = "live_icon_result"
liveIconResp := model.LiveIconInfoResp{ liveIconResp := model.LiveIconInfoResp{
Result: model.LiveIconInfoResult{ Result: model.LiveIconInfoRes{
LiveNotesIconList: []int{1, 2, 3}, LiveNotesIconList: []int{1, 2, 3},
}, },
Status: 200, Status: 200,
@@ -902,9 +844,9 @@ func ApiHandler(ctx *gin.Context) {
} }
museumInfoResp := model.MuseumInfoResp{ museumInfoResp := model.MuseumInfoResp{
Result: model.MuseumInfoResult{ Result: model.MuseumInfoRes{
MuseumInfo: model.MuseumInfo{ MuseumInfo: model.Museum{
Parameter: model.MuseumInfoParameter{ Parameter: model.MuseumParameter{
Smile: smileBuf, Smile: smileBuf,
Pure: pureBuf, Pure: pureBuf,
Cool: coolBuf, Cool: coolBuf,
@@ -1139,7 +1081,7 @@ func ApiHandler(ctx *gin.Context) {
// fmt.Println(results) // fmt.Println(results)
b, err := json.Marshal(results) b, err := json.Marshal(results)
CheckErr(err) CheckErr(err)
rp := model.Response{ rp := model.ApiResp{
ResponseData: b, ResponseData: b,
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
+16 -15
View File
@@ -4,6 +4,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"honoka-chan/config"
"honoka-chan/encrypt" "honoka-chan/encrypt"
"honoka-chan/model" "honoka-chan/model"
"net/http" "net/http"
@@ -21,12 +22,12 @@ type PkgInfo struct {
Size int `xorm:"pkg_size"` Size int `xorm:"pkg_size"`
} }
func DownloadAdditionalHandler(ctx *gin.Context) { func DownloadAdditional(ctx *gin.Context) {
downloadReq := model.AdditionalReq{} downloadReq := model.AdditionalReq{}
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
panic(err) panic(err)
} }
pkgList := []model.AdditionalResult{} pkgList := []model.AdditionalRes{}
if CdnUrl != "" { if CdnUrl != "" {
pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID
var pkgInfo []PkgInfo var pkgInfo []PkgInfo
@@ -36,7 +37,7 @@ func DownloadAdditionalHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
for _, pkg := range pkgInfo { for _, pkg := range pkgInfo {
pkgList = append(pkgList, model.AdditionalResult{ pkgList = append(pkgList, model.AdditionalRes{
Size: pkg.Size, Size: pkg.Size,
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order), 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)) ctx.String(http.StatusOK, string(resp))
} }
func DownloadBatchHandler(ctx *gin.Context) { func DownloadBatch(ctx *gin.Context) {
downloadReq := model.BatchReq{} downloadReq := model.BatchReq{}
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
panic(err) panic(err)
} }
pkgList := []model.BatchResult{} pkgList := []model.BatchRes{}
if downloadReq.ClientVersion == PackageVersion && CdnUrl != "" { if downloadReq.ClientVersion == config.PackageVersion && CdnUrl != "" {
pkgType := downloadReq.PackageType pkgType := downloadReq.PackageType
var pkgInfo []PkgInfo var pkgInfo []PkgInfo
err := MainEng.Table("download_m").Where(builder.NotIn("pkg_id", downloadReq.ExcludedPackageIds)).Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.Os). 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) CheckErr(err)
for _, pkg := range pkgInfo { for _, pkg := range pkgInfo {
pkgList = append(pkgList, model.BatchResult{ pkgList = append(pkgList, model.BatchRes{
Size: pkg.Size, Size: pkg.Size,
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.Os, pkgType, pkg.Id, pkg.Order), 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)) ctx.String(http.StatusOK, string(resp))
} }
func DownloadUpdateHandler(ctx *gin.Context) { func DownloadUpdate(ctx *gin.Context) {
downloadReq := model.UpdateReq{} downloadReq := model.UpdateReq{}
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil { if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
panic(err) panic(err)
} }
pkgList := []model.UpdateResult{} pkgList := []model.UpdateRes{}
if downloadReq.ExternalVersion != PackageVersion && CdnUrl != "" { if downloadReq.ExternalVersion != config.PackageVersion && CdnUrl != "" {
pkgType := 99 pkgType := 99
var pkgInfo []PkgInfo var pkgInfo []PkgInfo
err := MainEng.Table("download_m").Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.TargetOs). 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) CheckErr(err)
for _, pkg := range pkgInfo { for _, pkg := range pkgInfo {
pkgList = append(pkgList, model.UpdateResult{ pkgList = append(pkgList, model.UpdateRes{
Size: pkg.Size, Size: pkg.Size,
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip", CdnUrl, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order), 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)) 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 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 // Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done
downloadReq := model.UrlReq{} 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, "\\", ""))) urlList = append(urlList, fmt.Sprintf("%s/%s/extracted/%s", CdnUrl, downloadReq.Os, strings.ReplaceAll(v, "\\", "")))
} }
urlResp := model.UrlResp{ urlResp := model.UrlResp{
ResponseData: model.UrlResult{ ResponseData: model.UrlRes{
UrlList: urlList, UrlList: urlList,
}, },
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
@@ -173,7 +174,7 @@ func DownloadUrlHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func DownloadEventHandler(ctx *gin.Context) { func DownloadEvent(ctx *gin.Context) {
eventResp := model.EventResp{ eventResp := model.EventResp{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func EventListHandler(ctx *gin.Context) { func EventList(ctx *gin.Context) {
targets := []model.TargetList{} targets := []model.TargetList{}
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
targets = append(targets, model.TargetList{ targets = append(targets, model.TargetList{
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func GdprHandler(ctx *gin.Context) { func Gdpr(ctx *gin.Context) {
gdprResp := model.GdprResp{ gdprResp := model.GdprResp{
ResponseData: model.GdprRes{ ResponseData: model.GdprRes{
EnableGdpr: true, EnableGdpr: true,
+4 -6
View File
@@ -7,12 +7,10 @@ import (
) )
var ( var (
// nonce = 0 CdnUrl string
PackageVersion = "97.4.6" ErrorMsg = `{"code":20001,"message":""}`
CdnUrl string MainEng *xorm.Engine
ErrorMsg = `{"code":20001,"message":""}` UserEng *xorm.Engine
MainEng *xorm.Engine
UserEng *xorm.Engine
) )
func init() { func init() {
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func LBonusExecuteHandler(ctx *gin.Context) { func LBonusExecute(ctx *gin.Context) {
weeks := map[string]int{ weeks := map[string]int{
"Monday": 1, "Monday": 1,
"Tuesday": 2, "Tuesday": 2,
@@ -142,7 +142,7 @@ func LBonusExecuteHandler(ctx *gin.Context) {
}, },
}, },
LimitedEffortBox: []interface{}{}, LimitedEffortBox: []interface{}{},
MuseumInfo: model.MuseumInfo{}, MuseumInfo: model.Museum{},
ServerTimestamp: time.Now().Unix(), ServerTimestamp: time.Now().Unix(),
PresentCnt: 0, PresentCnt: 0,
}, },
+183 -207
View File
@@ -18,13 +18,7 @@ import (
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
) )
type GameOverResp struct { func PartyList(ctx *gin.Context) {
ResponseData []interface{} `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"`
}
func PartyListHandler(ctx *gin.Context) {
resp := utils.ReadAllText("assets/partylist.json") resp := utils.ReadAllText("assets/partylist.json")
nonce := ctx.GetInt("nonce") nonce := ctx.GetInt("nonce")
@@ -37,7 +31,7 @@ func PartyListHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func PlayLiveHandler(ctx *gin.Context) { func PlayLive(ctx *gin.Context) {
playReq := model.PlayReq{} playReq := model.PlayReq{}
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playReq) err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playReq)
CheckErr(err) CheckErr(err)
@@ -402,44 +396,38 @@ func PlayLiveHandler(ctx *gin.Context) {
}, },
}) })
resp := model.PlayResponseData{ playResp := model.PlayResp{
RankInfo: ranks, ResponseData: model.PlayRes{
EnergyFullTime: "2023-03-20 01:28:55", RankInfo: ranks,
OverMaxEnergy: 0, EnergyFullTime: "2023-03-20 01:28:55",
AvailableLiveResume: false, OverMaxEnergy: 0,
LiveList: lives, AvailableLiveResume: false,
IsMarathonEvent: false, LiveList: lives,
MarathonEventID: nil, IsMarathonEvent: false,
NoSkill: false, MarathonEventID: nil,
CanActivateEffect: true, NoSkill: false,
ServerTimestamp: time.Now().Unix(), CanActivateEffect: true,
ServerTimestamp: time.Now().Unix(),
},
ReleaseInfo: []interface{}{},
StatusCode: 200,
} }
m, err := json.Marshal(resp) resp, err := json.Marshal(playResp)
CheckErr(err) 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.GetInt("nonce")
nonce++ nonce++
ctx.Header("user_id", ctx.GetString("userid")) 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("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) { func GameOver(ctx *gin.Context) {
overResp := GameOverResp{ overResp := model.GameOverResp{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
@@ -457,7 +445,7 @@ func GameOverHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func PlayScoreHandler(ctx *gin.Context) { func PlayScore(ctx *gin.Context) {
playScoreReq := model.PlayScoreReq{} playScoreReq := model.PlayScoreReq{}
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playScoreReq) err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playScoreReq)
CheckErr(err) CheckErr(err)
@@ -506,56 +494,50 @@ func PlayScoreHandler(ctx *gin.Context) {
RankMax: 0, RankMax: 0,
}) })
resp := model.PlayScoreResponseData{ playResp := model.PlayScoreResp{
On: model.On{ ResponseData: model.PlayScoreRes{
HasRecord: false, On: model.On{
LiveInfo: model.LiveInfo{ HasRecord: false,
LiveDifficultyID: difficultyId, LiveInfo: model.LiveInfo{
IsRandom: false, LiveDifficultyID: difficultyId,
AcFlag: ac_flag, IsRandom: false,
SwingFlag: swing_flag, AcFlag: ac_flag,
NotesList: notes, SwingFlag: swing_flag,
NotesList: notes,
},
}, },
}, Off: model.Off{
Off: model.Off{ HasRecord: false,
HasRecord: false, LiveInfo: model.LiveInfo{
LiveInfo: model.LiveInfo{ LiveDifficultyID: difficultyId,
LiveDifficultyID: difficultyId, IsRandom: false,
IsRandom: false, AcFlag: ac_flag,
AcFlag: ac_flag, SwingFlag: swing_flag,
SwingFlag: swing_flag, NotesList: notes,
NotesList: notes, },
}, },
RankInfo: ranks,
CanActivateEffect: true,
ServerTimestamp: int(time.Now().Unix()),
}, },
RankInfo: ranks, ReleaseInfo: []interface{}{},
CanActivateEffect: true, StatusCode: 200,
ServerTimestamp: int(time.Now().Unix()),
} }
m, err := json.Marshal(resp) resp, err := json.Marshal(playResp)
CheckErr(err) 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.GetInt("nonce")
nonce++ nonce++
ctx.Header("user_id", ctx.GetString("userid")) 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("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{} playRewardReq := model.PlayRewardReq{}
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playRewardReq) err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playRewardReq)
CheckErr(err) CheckErr(err)
@@ -578,172 +560,166 @@ func PlayRewardHandler(ctx *gin.Context) {
CheckErr(err) CheckErr(err)
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
resp := model.RewardResponseData{ playResp := model.RewardResp{
LiveInfo: []model.RewardLiveInfo{ ResponseData: model.RewardRes{
{ LiveInfo: []model.RewardLiveInfo{
LiveDifficultyID: difficultyId, {
IsRandom: false, LiveDifficultyID: difficultyId,
AcFlag: ac_flag, IsRandom: false,
SwingFlag: swing_flag, AcFlag: ac_flag,
SwingFlag: swing_flag,
},
}, },
}, TotalLove: 0,
TotalLove: 0, IsHighScore: true,
IsHighScore: true, HiScore: totalScore,
HiScore: totalScore, BaseRewardInfo: model.BaseRewardInfo{
BaseRewardInfo: model.BaseRewardInfo{ PlayerExp: 830,
PlayerExp: 830, PlayerExpUnitMax: model.PlayerExpUnitMax{
PlayerExpUnitMax: model.PlayerExpUnitMax{ Before: 900,
Before: 900, After: 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{ RewardUnitList: model.RewardUnitList{
Before: 99, LiveClear: []model.LiveClear{},
After: 99, LiveRank: []model.LiveRank{},
LiveCombo: []interface{}{},
}, },
PlayerExpLpMax: model.PlayerExpLpMax{ UnlockedSubscenarioIds: []interface{}{},
Before: 417, UnlockedMultiUnitScenarioIds: []interface{}{},
After: 417, 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, AfterUserInfo: model.AfterUserInfo{
GameCoinRewardBoxFlag: false, Level: 1028,
SocialPoint: 10, Exp: 28824396,
}, PreviousExp: 27734700,
RewardUnitList: model.RewardUnitList{ NextExp: 28941885,
LiveClear: []model.LiveClear{}, GameCoin: 86520044,
LiveRank: []model.LiveRank{}, SnsCoin: 50,
LiveCombo: []interface{}{}, FreeSnsCoin: 49,
}, PaidSnsCoin: 1,
UnlockedSubscenarioIds: []interface{}{}, SocialPoint: 1438375,
UnlockedMultiUnitScenarioIds: []interface{}{}, UnitMax: 5000,
EffortPoint: []model.EffortPoint{}, WaitingUnitMax: 1000,
IsEffortPointVisible: false, CurrentEnergy: 392,
LimitedEffortBox: []interface{}{}, EnergyMax: 417,
UnitList: unitsList, TrainingEnergy: 9,
BeforeUserInfo: model.BeforeUserInfo{ TrainingEnergyMax: 10,
Level: 1028, EnergyFullTime: "2023-03-20 01:28:55",
Exp: 28823566, LicenseLiveEnergyRecoverlyTime: 60,
PreviousExp: 27734700, FriendMax: 99,
NextExp: 28941885, TutorialState: -1,
GameCoin: 86505544, OverMaxEnergy: 0,
SnsCoin: 49, UnlockRandomLiveMuse: 1,
FreeSnsCoin: 48, UnlockRandomLiveAqours: 1,
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,
}, },
}, NextLevelInfo: []model.NextLevelInfo{
GoalAccompInfo: model.GoalAccompInfo{ {
AchievedIds: []interface{}{}, Level: 1028,
Rewards: []interface{}{}, FromExp: 28823566,
}, },
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, GoalAccompInfo: model.GoalAccompInfo{
IsOpened: true, AchievedIds: []interface{}{},
IsVisible: true, 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{}, ReleaseInfo: []interface{}{},
UnaccomplishedAchievementCnt: 15, StatusCode: 200,
AddedAchievementList: []interface{}{},
MuseumInfo: model.RewardMuseumInfo{},
UnitSupportList: []model.RewardUnitSupportList{},
ServerTimestamp: 1679238066,
PresentCnt: 2159,
} }
if playRewardReq.MaxCombo > s_rank_combo { if playRewardReq.MaxCombo > s_rank_combo {
resp.ComboRank = 1 playResp.ResponseData.ComboRank = 1
} else if playRewardReq.MaxCombo > a_rank_combo { } else if playRewardReq.MaxCombo > a_rank_combo {
resp.ComboRank = 2 playResp.ResponseData.ComboRank = 2
} else if playRewardReq.MaxCombo > b_rank_combo { } else if playRewardReq.MaxCombo > b_rank_combo {
resp.ComboRank = 3 playResp.ResponseData.ComboRank = 3
} else if playRewardReq.MaxCombo > c_rank_combo { } else if playRewardReq.MaxCombo > c_rank_combo {
resp.ComboRank = 4 playResp.ResponseData.ComboRank = 4
} else { } else {
resp.ComboRank = 5 playResp.ResponseData.ComboRank = 5
} }
if totalScore > s_rank_score { if totalScore > s_rank_score {
resp.Rank = 1 playResp.ResponseData.Rank = 1
} else if totalScore > a_rank_score { } else if totalScore > a_rank_score {
resp.Rank = 2 playResp.ResponseData.Rank = 2
} else if totalScore > b_rank_score { } else if totalScore > b_rank_score {
resp.Rank = 3 playResp.ResponseData.Rank = 3
} else if totalScore > c_rank_score { } else if totalScore > c_rank_score {
resp.Rank = 4 playResp.ResponseData.Rank = 4
} else { } else {
resp.Rank = 5 playResp.ResponseData.Rank = 5
} }
m, err := json.Marshal(resp) resp, err := json.Marshal(playResp)
CheckErr(err) 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.GetInt("nonce")
nonce++ nonce++
ctx.Header("user_id", ctx.GetString("userid")) 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("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))
} }
+1 -1
View File
@@ -32,7 +32,7 @@ type MultiUnitStartUpReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
func MultiUnitStartUpHandler(ctx *gin.Context) { func MultiUnitStartUp(ctx *gin.Context) {
startReq := MultiUnitStartUpReq{} startReq := MultiUnitStartUpReq{}
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
CheckErr(err) CheckErr(err)
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func NoticeFriendVarietyHandler(ctx *gin.Context) { func NoticeFriendVariety(ctx *gin.Context) {
noticeResp := model.NoticeFriendVarietyResp{ noticeResp := model.NoticeFriendVarietyResp{
ResponseData: model.NoticeFriendVarietyRes{ ResponseData: model.NoticeFriendVarietyRes{
ItemCount: 1, ItemCount: 1,
@@ -35,7 +35,7 @@ func NoticeFriendVarietyHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func NoticeFriendGreetingHandler(ctx *gin.Context) { func NoticeFriendGreeting(ctx *gin.Context) {
noticeResp := model.NoticeFriendGreetingResp{ noticeResp := model.NoticeFriendGreetingResp{
ResponseData: model.NoticeFriendGreetingRes{ ResponseData: model.NoticeFriendGreetingRes{
NextId: 0, NextId: 0,
@@ -58,7 +58,7 @@ func NoticeFriendGreetingHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func NoticeUserGreetingHandler(ctx *gin.Context) { func NoticeUserGreeting(ctx *gin.Context) {
noticeResp := model.NoticeUserGreetingResp{ noticeResp := model.NoticeUserGreetingResp{
ResponseData: model.NoticeUserGreetingRes{ ResponseData: model.NoticeUserGreetingRes{
ItemCount: 0, ItemCount: 0,
+1 -1
View File
@@ -35,7 +35,7 @@ type ProductData struct {
ServerTimestamp int64 `json:"server_timestamp"` ServerTimestamp int64 `json:"server_timestamp"`
} }
func ProductListHandler(ctx *gin.Context) { func ProductList(ctx *gin.Context) {
prodReesp := ProductResp{ prodReesp := ProductResp{
ResponseData: ProductData{ ResponseData: ProductData{
RestrictionInfo: RestrictionInfo{ RestrictionInfo: RestrictionInfo{
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func PersonalNoticeHandler(ctx *gin.Context) { func PersonalNotice(ctx *gin.Context) {
noticeResp := model.PersonalNoticeResp{ noticeResp := model.PersonalNoticeResp{
ResponseData: model.PersonalNoticeRes{ ResponseData: model.PersonalNoticeRes{
HasNotice: false, HasNotice: false,
+12 -12
View File
@@ -88,7 +88,7 @@ type InitializeResp struct {
WeixinKey string `json:"weixin_key"` WeixinKey string `json:"weixin_key"`
} }
func ActiveHandler(ctx *gin.Context) { func Active(ctx *gin.Context) {
// body, err := io.ReadAll(ctx.Request.Body) // body, err := io.ReadAll(ctx.Request.Body)
// CheckErr(err) // CheckErr(err)
// defer ctx.Request.Body.Close() // 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 } }`) 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 := utils.ReadAllText("publickey.pem")
publicKey = strings.ReplaceAll(publicKey, "\n", "") publicKey = strings.ReplaceAll(publicKey, "\n", "")
publicKey = strings.ReplaceAll(publicKey, "-----BEGIN PUBLIC KEY-----", "") publicKey = strings.ReplaceAll(publicKey, "-----BEGIN PUBLIC KEY-----", "")
@@ -110,7 +110,7 @@ func PublicKeyHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func HandshakeHandler(ctx *gin.Context) { func Handshake(ctx *gin.Context) {
body, err := io.ReadAll(ctx.Request.Body) body, err := io.ReadAll(ctx.Request.Body)
CheckErr(err) CheckErr(err)
defer ctx.Request.Body.Close() defer ctx.Request.Body.Close()
@@ -148,7 +148,7 @@ func HandshakeHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func InitializeHandler(ctx *gin.Context) { func Initialize(ctx *gin.Context) {
// body, err := io.ReadAll(ctx.Request.Body) // body, err := io.ReadAll(ctx.Request.Body)
// CheckErr(err) // CheckErr(err)
// defer ctx.Request.Body.Close() // defer ctx.Request.Body.Close()
@@ -191,13 +191,13 @@ func InitializeHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) 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" } }` 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.Header("Content-Type", "text/html;charset=utf-8")
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func LoginAutoHandler(ctx *gin.Context) { func LoginAuto(ctx *gin.Context) {
body, err := io.ReadAll(ctx.Request.Body) body, err := io.ReadAll(ctx.Request.Body)
CheckErr(err) CheckErr(err)
defer ctx.Request.Body.Close() defer ctx.Request.Body.Close()
@@ -265,7 +265,7 @@ func LoginAutoHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func LoginAreaHandler(ctx *gin.Context) { func LoginArea(ctx *gin.Context) {
userId := ctx.PostForm("userid") userId := ctx.PostForm("userid")
if userId != "" { if userId != "" {
// fmt.Println(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) body, err := io.ReadAll(ctx.Request.Body)
CheckErr(err) CheckErr(err)
defer ctx.Request.Body.Close() defer ctx.Request.Body.Close()
@@ -434,7 +434,7 @@ func AccountLoginHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func ReportRoleHandler(ctx *gin.Context) { func ReportRole(ctx *gin.Context) {
// body, err := io.ReadAll(ctx.Request.Body) // body, err := io.ReadAll(ctx.Request.Body)
// CheckErr(err) // CheckErr(err)
// defer ctx.Request.Body.Close() // defer ctx.Request.Body.Close()
@@ -469,13 +469,13 @@ func ReportRoleHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
} }
func GetProductListHandler(ctx *gin.Context) { func GetProductList(ctx *gin.Context) {
resp := `{ "code": 0, "msg": "ok", "data": { "message": [ ], "result": 0 } }` resp := `{ "code": 0, "msg": "ok", "data": { "message": [ ], "result": 0 } }`
ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.Header("Content-Type", "text/html;charset=utf-8")
ctx.String(http.StatusOK, resp) 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}}` resp := `{"code":0,"msg":"ok","data":{"disablead":1,"loginswitch":1,"message":"ok","result":0}}`
ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.Header("Content-Type", "text/html;charset=utf-8")
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
@@ -500,7 +500,7 @@ func ReportApp(ctx *gin.Context) {
ctx.String(http.StatusOK, resp) 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": { } }` resp := `{ "return_code": 0, "error_type": 0, "return_message": "", "data": { } }`
ctx.Header("Content-Type", "text/html;charset=utf-8") ctx.Header("Content-Type", "text/html;charset=utf-8")
ctx.String(http.StatusOK, resp) ctx.String(http.StatusOK, resp)
+2 -2
View File
@@ -33,7 +33,7 @@ type ScenarioReq struct {
ScenarioID int `json:"scenario_id"` ScenarioID int `json:"scenario_id"`
} }
func ScenarioStartupHandler(ctx *gin.Context) { func ScenarioStartup(ctx *gin.Context) {
startReq := ScenarioReq{} startReq := ScenarioReq{}
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
CheckErr(err) CheckErr(err)
@@ -62,7 +62,7 @@ func ScenarioStartupHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func ScenarioRewardHandler(ctx *gin.Context) { func ScenarioReward(ctx *gin.Context) {
resp := utils.ReadAllText("assets/reward.json") resp := utils.ReadAllText("assets/reward.json")
nonce := ctx.GetInt("nonce") nonce := ctx.GetInt("nonce")
+2 -2
View File
@@ -33,7 +33,7 @@ type SubScenarioReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
func SubScenarioStartupHandler(ctx *gin.Context) { func SubScenarioStartup(ctx *gin.Context) {
startReq := SubScenarioReq{} startReq := SubScenarioReq{}
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq) err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
CheckErr(err) CheckErr(err)
@@ -60,7 +60,7 @@ func SubScenarioStartupHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func SubScenarioRewardHandler(ctx *gin.Context) { func SubScenarioReward(ctx *gin.Context) {
resp := utils.ReadAllText("assets/subreward.json") resp := utils.ReadAllText("assets/subreward.json")
nonce := ctx.GetInt("nonce") nonce := ctx.GetInt("nonce")
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func TosCheckHandler(ctx *gin.Context) { func TosCheck(ctx *gin.Context) {
tosResp := model.TosResp{ tosResp := model.TosResp{
ResponseData: model.TosRes{ ResponseData: model.TosRes{
TosID: 1, TosID: 1,
+13 -52
View File
@@ -4,12 +4,9 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt" "honoka-chan/encrypt"
"honoka-chan/model" "honoka-chan/model"
"honoka-chan/tools" "honoka-chan/tools"
"honoka-chan/utils"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@@ -17,62 +14,26 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
type SetDisplayRankResp struct { func SetDisplayRank(ctx *gin.Context) {
ResponseData []interface{} `json:"response_data"` dispResp := model.SetDisplayRankResp{
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{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
} }
resp, err := json.Marshal(dispResp) resp, err := json.Marshal(dispResp)
CheckErr(err) CheckErr(err)
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber) nonce := ctx.GetInt("nonce")
ctx.Header("user_id", userId[0]) nonce++
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64) 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)) ctx.String(http.StatusOK, string(resp))
} }
func SetDeckHandler(ctx *gin.Context) { func SetDeck(ctx *gin.Context) {
userId, err := strconv.Atoi(ctx.GetString("userid")) userId, err := strconv.Atoi(ctx.GetString("userid"))
CheckErr(err) CheckErr(err)
@@ -197,7 +158,7 @@ func SetDeckHandler(ctx *gin.Context) {
panic(err) panic(err)
} }
dispResp := SetDisplayRankResp{ dispResp := model.SetDeckResp{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
@@ -215,7 +176,7 @@ func SetDeckHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func SetDeckNameHandler(ctx *gin.Context) { func SetDeckName(ctx *gin.Context) {
userId, err := strconv.Atoi(ctx.GetString("userid")) userId, err := strconv.Atoi(ctx.GetString("userid"))
CheckErr(err) CheckErr(err)
@@ -239,7 +200,7 @@ func SetDeckNameHandler(ctx *gin.Context) {
}) })
CheckErr(err) CheckErr(err)
dispResp := SetDisplayRankResp{ dispResp := model.SetDeckResp{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
+3 -3
View File
@@ -20,7 +20,7 @@ type NotificationResp struct {
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
func SetNotificationTokenHandler(ctx *gin.Context) { func SetNotificationToken(ctx *gin.Context) {
notifResp := NotificationResp{ notifResp := NotificationResp{
ResponseData: []interface{}{}, ResponseData: []interface{}{},
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
@@ -39,7 +39,7 @@ func SetNotificationTokenHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func ChangeNaviHandler(ctx *gin.Context) { func ChangeNavi(ctx *gin.Context) {
req := gjson.Parse(ctx.PostForm("request_data")) req := gjson.Parse(ctx.PostForm("request_data"))
pref := tools.UserPref{ pref := tools.UserPref{
UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()), UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()),
@@ -64,7 +64,7 @@ func ChangeNaviHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, string(resp)) ctx.String(http.StatusOK, string(resp))
} }
func ChangeNameHandler(ctx *gin.Context) { func ChangeName(ctx *gin.Context) {
req := gjson.Parse(ctx.PostForm("request_data")) req := gjson.Parse(ctx.PostForm("request_data"))
var oldName string var oldName string
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_name").Get(&oldName) exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_name").Get(&oldName)
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func UserInfoHandler(ctx *gin.Context) { func UserInfo(ctx *gin.Context) {
userId, err := strconv.Atoi(ctx.GetString("userid")) userId, err := strconv.Atoi(ctx.GetString("userid"))
CheckErr(err) CheckErr(err)
+50 -52
View File
@@ -1,19 +1,17 @@
package main package main
import ( import (
"honoka-chan/config"
"honoka-chan/handler" "honoka-chan/handler"
_ "honoka-chan/llhelper" _ "honoka-chan/llhelper"
"honoka-chan/middleware" "honoka-chan/middleware"
_ "honoka-chan/tools" _ "honoka-chan/tools"
"honoka-chan/xclog"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func init() { func init() {
xclog.Init(config.Conf.Log.LogDir, "", config.Conf.Log.LogLevel, config.Conf.Log.LogSave)
} }
func main() { func main() {
@@ -30,20 +28,20 @@ func main() {
// Private APIs // Private APIs
v1 := r.Group("v1") v1 := r.Group("v1")
{ {
v1.GET("/basic/getcode", handler.GetCodeHandler) v1.GET("/basic/getcode", handler.GetCode)
v1.POST("/basic/getcode", handler.GetCodeHandler) v1.POST("/account/active", handler.Active)
v1.POST("/account/active", handler.ActiveHandler) v1.POST("/account/initialize", handler.Initialize)
v1.POST("/basic/publickey", handler.PublicKeyHandler) v1.POST("/account/loginauto", handler.LoginAuto)
v1.POST("/basic/handshake", handler.HandshakeHandler) v1.POST("/account/login", handler.AccountLogin)
v1.POST("/account/initialize", handler.InitializeHandler) v1.POST("/account/reportRole", handler.ReportRole)
v1.POST("/account/login", handler.AccountLoginHandler) v1.POST("/basic/getcode", handler.GetCode)
v1.POST("/account/loginauto", handler.LoginAutoHandler) v1.POST("/basic/getProductList", handler.GetProductList)
v1.POST("/basic/loginarea", handler.LoginAreaHandler) v1.POST("/basic/handshake", handler.Handshake)
v1.POST("/account/reportRole", handler.ReportRoleHandler) v1.POST("/basic/loginarea", handler.LoginArea)
v1.POST("/basic/getProductList", handler.GetProductListHandler) v1.POST("/basic/publickey", handler.PublicKey)
v1.POST("/guest/status", handler.GuestStatusHandler) 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.GET("/integration/appReport/initialize", handler.ReportApp)
r.POST("/report/ge/app", handler.ReportLog) r.POST("/report/ge/app", handler.ReportLog)
// Private APIs // Private APIs
@@ -51,51 +49,51 @@ func main() {
// Server APIs // Server APIs
m := r.Group("main.php").Use(middleware.Common) m := r.Group("main.php").Use(middleware.Common)
{ {
m.POST("/album/seriesAll", middleware.ParseMultipartForm, handler.AlbumSeriesAllHandler) m.POST("/album/seriesAll", middleware.ParseMultipartForm, handler.AlbumSeriesAll)
m.POST("/announce/checkState", middleware.ParseMultipartForm, handler.AnnounceCheckStateHandler) m.POST("/announce/checkState", middleware.ParseMultipartForm, handler.AnnounceCheckState)
m.POST("/api", middleware.ParseMultipartForm, handler.ApiHandler) m.POST("/api", middleware.ParseMultipartForm, handler.Api)
m.POST("/award/set", handler.AwardSet) m.POST("/award/set", handler.AwardSet)
m.POST("/background/set", handler.BackgroundSet) m.POST("/background/set", handler.BackgroundSet)
m.POST("/download/additional", handler.DownloadAdditionalHandler) m.POST("/download/additional", handler.DownloadAdditional)
m.POST("/download/batch", handler.DownloadBatchHandler) m.POST("/download/batch", handler.DownloadBatch)
m.POST("/download/event", handler.DownloadEventHandler) m.POST("/download/event", handler.DownloadEvent)
m.POST("/download/getUrl", handler.DownloadUrlHandler) m.POST("/download/getUrl", handler.DownloadUrl)
m.POST("/download/update", handler.DownloadUpdateHandler) m.POST("/download/update", handler.DownloadUpdate)
m.POST("/event/eventList", middleware.ParseMultipartForm, handler.EventListHandler) m.POST("/event/eventList", middleware.ParseMultipartForm, handler.EventList)
m.POST("/gdpr/get", middleware.ParseMultipartForm, handler.GdprHandler) m.POST("/gdpr/get", middleware.ParseMultipartForm, handler.Gdpr)
m.POST("/lbonus/execute", handler.LBonusExecuteHandler) m.POST("/lbonus/execute", handler.LBonusExecute)
m.POST("/live/gameover", handler.GameOverHandler) m.POST("/live/gameover", handler.GameOver)
m.POST("/live/partyList", handler.PartyListHandler) m.POST("/live/partyList", handler.PartyList)
m.POST("/live/play", middleware.ParseMultipartForm, handler.PlayLiveHandler) m.POST("/live/play", middleware.ParseMultipartForm, handler.PlayLive)
m.POST("/live/preciseScore", middleware.ParseMultipartForm, handler.PlayScoreHandler) m.POST("/live/preciseScore", middleware.ParseMultipartForm, handler.PlayScore)
m.POST("/live/reward", middleware.ParseMultipartForm, handler.PlayRewardHandler) m.POST("/live/reward", middleware.ParseMultipartForm, handler.PlayReward)
m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey) m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey)
m.POST("/login/login", middleware.Login, handler.Login) 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("/museum/info", middleware.ParseMultipartForm, handler.MuseumInfo)
m.POST("/notice/noticeFriendGreeting", middleware.ParseMultipartForm, handler.NoticeFriendGreetingHandler) m.POST("/notice/noticeFriendGreeting", middleware.ParseMultipartForm, handler.NoticeFriendGreeting)
m.POST("/notice/noticeFriendVariety", middleware.ParseMultipartForm, handler.NoticeFriendVarietyHandler) m.POST("/notice/noticeFriendVariety", middleware.ParseMultipartForm, handler.NoticeFriendVariety)
m.POST("/notice/noticeUserGreetingHistory", handler.NoticeUserGreetingHandler) m.POST("/notice/noticeUserGreetingHistory", handler.NoticeUserGreeting)
m.POST("/payment/productList", middleware.ParseMultipartForm, handler.ProductListHandler) m.POST("/payment/productList", middleware.ParseMultipartForm, handler.ProductList)
m.POST("/personalnotice/get", middleware.ParseMultipartForm, handler.PersonalNoticeHandler) m.POST("/personalnotice/get", middleware.ParseMultipartForm, handler.PersonalNotice)
m.POST("/profile/profileRegister", handler.ProfileRegister) m.POST("/profile/profileRegister", handler.ProfileRegister)
m.POST("/scenario/reward", handler.ScenarioRewardHandler) m.POST("/scenario/reward", handler.ScenarioReward)
m.POST("/scenario/startup", handler.ScenarioStartupHandler) m.POST("/scenario/startup", handler.ScenarioStartup)
m.POST("/subscenario/reward", handler.SubScenarioStartupHandler) m.POST("/subscenario/reward", handler.SubScenarioStartup)
m.POST("/subscenario/startup", handler.SubScenarioStartupHandler) m.POST("/subscenario/startup", handler.SubScenarioStartup)
m.POST("/tos/tosCheck", middleware.ParseMultipartForm, handler.TosCheckHandler) m.POST("/tos/tosCheck", middleware.ParseMultipartForm, handler.TosCheck)
m.POST("/unit/deck", handler.SetDeckHandler) m.POST("/unit/deck", handler.SetDeck)
m.POST("/unit/deckName", handler.SetDeckNameHandler) m.POST("/unit/deckName", handler.SetDeckName)
m.POST("/unit/favorite", handler.SetDisplayRankHandler) m.POST("/unit/favorite", handler.SetDisplayRank)
m.POST("/unit/removableSkillEquipment", handler.RemoveSkillEquip) 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("/unit/wearAccessory", handler.WearAccessory)
m.POST("/user/changeName", handler.ChangeNameHandler) m.POST("/user/changeName", handler.ChangeName)
m.POST("/user/changeNavi", handler.ChangeNaviHandler) m.POST("/user/changeNavi", handler.ChangeNavi)
m.POST("/user/setNotificationToken", handler.SetNotificationTokenHandler) m.POST("/user/setNotificationToken", handler.SetNotificationToken)
m.POST("/user/userInfo", middleware.ParseMultipartForm, handler.UserInfoHandler) 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 // Server APIs
// Web // Web
+4 -2
View File
@@ -1,6 +1,6 @@
package model package model
// module: album, action: albumAll // AlbumResult ...
type AlbumResult struct { type AlbumResult struct {
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
RankMaxFlag bool `json:"rank_max_flag"` RankMaxFlag bool `json:"rank_max_flag"`
@@ -13,6 +13,7 @@ type AlbumResult struct {
SignFlag bool `json:"sign_flag"` SignFlag bool `json:"sign_flag"`
} }
// AlbumResp ...
type AlbumResp struct { type AlbumResp struct {
Result []AlbumResult `json:"result"` Result []AlbumResult `json:"result"`
Status int `json:"status"` Status int `json:"status"`
@@ -20,12 +21,13 @@ type AlbumResp struct {
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// albumSeries // AlbumSeriesRes ...
type AlbumSeriesRes struct { type AlbumSeriesRes struct {
SeriesID int `json:"series_id"` SeriesID int `json:"series_id"`
UnitList []AlbumResult `json:"unit_list"` UnitList []AlbumResult `json:"unit_list"`
} }
// AlbumSeriesResp ...
type AlbumSeriesResp struct { type AlbumSeriesResp struct {
ResponseData []AlbumSeriesRes `json:"response_data"` ResponseData []AlbumSeriesRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
+9 -21
View File
@@ -1,29 +1,17 @@
package model package model
type SifApi struct { import "encoding/json"
// ApiReq ...
type ApiReq struct {
Module string `json:"module"` Module string `json:"module"`
Action string `json:"action"` Action string `json:"action"`
Timestamp int64 `json:"timeStamp"` Timestamp int64 `json:"timeStamp"`
} }
type MuseumInfoParameter struct { // ApiResp ...
Smile int `json:"smile"` type ApiResp struct {
Pure int `json:"pure"` ResponseData json.RawMessage `json:"response_data"`
Cool int `json:"cool"` ReleaseInfo []interface{} `json:"release_info"`
} StatusCode int `json:"status_code"`
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"`
} }
+20
View File
@@ -6,3 +6,23 @@ type AwardSetResp struct {
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` 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"`
}
+20
View File
@@ -6,3 +6,23 @@ type BackgroundSetResp struct {
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` 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"`
}
+7 -5
View File
@@ -14,14 +14,16 @@ type BannerList struct {
WebviewURL string `json:"webview_url,omitempty"` WebviewURL string `json:"webview_url,omitempty"`
} }
type BannerListResult struct { // BannerListRes ...
type BannerListRes struct {
TimeLimit string `json:"time_limit"` TimeLimit string `json:"time_limit"`
BannerList []BannerList `json:"banner_list"` BannerList []BannerList `json:"banner_list"`
} }
// BannerListResp ...
type BannerListResp struct { type BannerListResp struct {
Result BannerListResult `json:"result"` Result BannerListRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
+9
View File
@@ -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"`
}
+8 -6
View File
@@ -1,19 +1,21 @@
package model package model
// module: costume, action: costumeList // CostumeList ...
type CostumeList struct { type CostumeList struct {
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
IsRankMax bool `json:"is_rank_max"` IsRankMax bool `json:"is_rank_max"`
IsSigned bool `json:"is_signed"` IsSigned bool `json:"is_signed"`
} }
type CostumeListResult struct { // CostumeListRes ...
type CostumeListRes struct {
CostumeList []CostumeList `json:"costume_list"` CostumeList []CostumeList `json:"costume_list"`
} }
// CostumeListResp ...
type CostumeListResp struct { type CostumeListResp struct {
Result CostumeListResult `json:"result"` Result CostumeListRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
+25 -12
View File
@@ -1,5 +1,6 @@
package model package model
// AdditionalReq ...
type AdditionalReq struct { type AdditionalReq struct {
Module string `json:"module"` Module string `json:"module"`
Mgd int `json:"mgd"` Mgd int `json:"mgd"`
@@ -11,17 +12,20 @@ type AdditionalReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
type AdditionalResult struct { // AdditionalRes ...
type AdditionalRes struct {
Size int `json:"size"` Size int `json:"size"`
URL string `json:"url"` URL string `json:"url"`
} }
// AdditionalResp ...
type AdditionalResp struct { type AdditionalResp struct {
ResponseData []AdditionalResult `json:"response_data"` ResponseData []AdditionalRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
// BatchReq ...
type BatchReq struct { type BatchReq struct {
ClientVersion string `json:"client_version"` ClientVersion string `json:"client_version"`
Os string `json:"os"` Os string `json:"os"`
@@ -30,17 +34,20 @@ type BatchReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
type BatchResult struct { // BatchRes ...
type BatchRes struct {
Size int `json:"size"` Size int `json:"size"`
URL string `json:"url"` URL string `json:"url"`
} }
// BatchResp ...
type BatchResp struct { type BatchResp struct {
ResponseData []BatchResult `json:"response_data"` ResponseData []BatchRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
// UpdateReq ...
type UpdateReq struct { type UpdateReq struct {
Module string `json:"module"` Module string `json:"module"`
TargetOs string `json:"target_os"` TargetOs string `json:"target_os"`
@@ -52,18 +59,21 @@ type UpdateReq struct {
ExternalVersion string `json:"external_version"` ExternalVersion string `json:"external_version"`
} }
type UpdateResult struct { // UpdateRes ...
type UpdateRes struct {
Size int `json:"size"` Size int `json:"size"`
URL string `json:"url"` URL string `json:"url"`
Version string `json:"version"` Version string `json:"version"`
} }
// UpdateResp ...
type UpdateResp struct { type UpdateResp struct {
ResponseData []UpdateResult `json:"response_data"` ResponseData []UpdateRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
// UrlReq ...
type UrlReq struct { type UrlReq struct {
Module string `json:"module"` Module string `json:"module"`
Os string `json:"os"` Os string `json:"os"`
@@ -72,16 +82,19 @@ type UrlReq struct {
Action string `json:"action"` Action string `json:"action"`
} }
type UrlResult struct { // UrlRes ...
type UrlRes struct {
UrlList []string `json:"url_list"` UrlList []string `json:"url_list"`
} }
// UrlResp ...
type UrlResp struct { type UrlResp struct {
ResponseData UrlResult `json:"response_data"` ResponseData UrlRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
// EventResp ...
type EventResp struct { type EventResp struct {
ResponseData []interface{} `json:"response_data"` ResponseData []interface{} `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
+20
View File
@@ -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"`
}
+13 -1
View File
@@ -1,11 +1,13 @@
package model package model
// LbDayItem ...
type LbDayItem struct { type LbDayItem struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
Amount int `json:"amount"` Amount int `json:"amount"`
} }
// LbDays ...
type LbDays struct { type LbDays struct {
Day int `json:"day"` Day int `json:"day"`
DayOfTheWeek int `json:"day_of_the_week"` DayOfTheWeek int `json:"day_of_the_week"`
@@ -16,34 +18,42 @@ type LbDays struct {
Item LbDayItem `json:"item"` Item LbDayItem `json:"item"`
} }
// LbMonth ...
type LbMonth struct { type LbMonth struct {
Year int `json:"year"` Year int `json:"year"`
Month int `json:"month"` Month int `json:"month"`
Days []LbDays `json:"days"` Days []LbDays `json:"days"`
} }
// CalendarInfo ...
type CalendarInfo struct { type CalendarInfo struct {
CurrentDate string `json:"current_date"` CurrentDate string `json:"current_date"`
CurrentMonth LbMonth `json:"current_month"` CurrentMonth LbMonth `json:"current_month"`
NextMonth LbMonth `json:"next_month"` NextMonth LbMonth `json:"next_month"`
} }
// Reward ...
type Reward struct { type Reward struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
Amount int `json:"amount"` Amount int `json:"amount"`
} }
// TotalLoginInfo ...
type TotalLoginInfo struct { type TotalLoginInfo struct {
LoginCount int `json:"login_count"` LoginCount int `json:"login_count"`
RemainingCount int `json:"remaining_count"` RemainingCount int `json:"remaining_count"`
Reward []Reward `json:"reward"` Reward []Reward `json:"reward"`
} }
// LbRankInfo ...
type LbRankInfo struct { type LbRankInfo struct {
BeforeClassRankID int `json:"before_class_rank_id"` BeforeClassRankID int `json:"before_class_rank_id"`
AfterClassRankID int `json:"after_class_rank_id"` AfterClassRankID int `json:"after_class_rank_id"`
RankUpDate string `json:"rank_up_date"` RankUpDate string `json:"rank_up_date"`
} }
// LbClassSystem ...
type LbClassSystem struct { type LbClassSystem struct {
RankInfo LbRankInfo `json:"rank_info"` RankInfo LbRankInfo `json:"rank_info"`
CompleteFlag bool `json:"complete_flag"` CompleteFlag bool `json:"complete_flag"`
@@ -51,6 +61,7 @@ type LbClassSystem struct {
IsVisible bool `json:"is_visible"` IsVisible bool `json:"is_visible"`
} }
// LbRes ...
type LbRes struct { type LbRes struct {
Sheets []interface{} `json:"sheets"` Sheets []interface{} `json:"sheets"`
CalendarInfo CalendarInfo `json:"calendar_info"` CalendarInfo CalendarInfo `json:"calendar_info"`
@@ -60,11 +71,12 @@ type LbRes struct {
StartDashSheets []interface{} `json:"start_dash_sheets"` StartDashSheets []interface{} `json:"start_dash_sheets"`
EffortPoint []EffortPoint `json:"effort_point"` EffortPoint []EffortPoint `json:"effort_point"`
LimitedEffortBox []interface{} `json:"limited_effort_box"` LimitedEffortBox []interface{} `json:"limited_effort_box"`
MuseumInfo MuseumInfo `json:"museum_info"` MuseumInfo Museum `json:"museum_info"`
ServerTimestamp int64 `json:"server_timestamp"` ServerTimestamp int64 `json:"server_timestamp"`
PresentCnt int `json:"present_cnt"` PresentCnt int `json:"present_cnt"`
} }
// LbResp ...
type LbResp struct { type LbResp struct {
ResponseData LbRes `json:"response_data"` ResponseData LbRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
+125 -52
View File
@@ -1,6 +1,13 @@
package model 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 { type NormalLiveStatusList struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
Status int `json:"status"` Status int `json:"status"`
@@ -10,6 +17,7 @@ type NormalLiveStatusList struct {
AchievedGoalIDList []int `json:"achieved_goal_id_list"` AchievedGoalIDList []int `json:"achieved_goal_id_list"`
} }
// SpecialLiveStatusList ...
type SpecialLiveStatusList struct { type SpecialLiveStatusList struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
Status int `json:"status"` Status int `json:"status"`
@@ -19,6 +27,7 @@ type SpecialLiveStatusList struct {
AchievedGoalIDList []int `json:"achieved_goal_id_list"` AchievedGoalIDList []int `json:"achieved_goal_id_list"`
} }
// TrainingLiveStatusList ...
type TrainingLiveStatusList struct { type TrainingLiveStatusList struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
Status int `json:"status"` Status int `json:"status"`
@@ -28,7 +37,8 @@ type TrainingLiveStatusList struct {
AchievedGoalIDList []int `json:"achieved_goal_id_list"` AchievedGoalIDList []int `json:"achieved_goal_id_list"`
} }
type LiveStatusResult struct { // LiveStatusRes ...
type LiveStatusRes struct {
NormalLiveStatusList []NormalLiveStatusList `json:"normal_live_status_list"` NormalLiveStatusList []NormalLiveStatusList `json:"normal_live_status_list"`
SpecialLiveStatusList []SpecialLiveStatusList `json:"special_live_status_list"` SpecialLiveStatusList []SpecialLiveStatusList `json:"special_live_status_list"`
TrainingLiveStatusList []TrainingLiveStatusList `json:"training_live_status_list"` TrainingLiveStatusList []TrainingLiveStatusList `json:"training_live_status_list"`
@@ -37,14 +47,15 @@ type LiveStatusResult struct {
CanResumeLive bool `json:"can_resume_live"` CanResumeLive bool `json:"can_resume_live"`
} }
// LiveStatusResp ...
type LiveStatusResp struct { type LiveStatusResp struct {
Result LiveStatusResult `json:"result"` Result LiveStatusRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// module: live, action: schedule // LiveList ...
type LiveList struct { type LiveList struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
StartDate string `json:"start_date"` StartDate string `json:"start_date"`
@@ -52,6 +63,7 @@ type LiveList struct {
IsRandom bool `json:"is_random"` IsRandom bool `json:"is_random"`
} }
// LimitedBonusCommonList ...
type LimitedBonusCommonList struct { type LimitedBonusCommonList struct {
LiveType int `json:"live_type"` LiveType int `json:"live_type"`
LimitedBonusType int `json:"limited_bonus_type"` LimitedBonusType int `json:"limited_bonus_type"`
@@ -60,19 +72,22 @@ type LimitedBonusCommonList struct {
EndDate string `json:"end_date"` EndDate string `json:"end_date"`
} }
// RandomLiveList ...
type RandomLiveList struct { type RandomLiveList struct {
AttributeID int `json:"attribute_id"` AttributeID int `json:"attribute_id"`
StartDate string `json:"start_date"` StartDate string `json:"start_date"`
EndDate string `json:"end_date"` EndDate string `json:"end_date"`
} }
// TrainingLiveList ...
type TrainingLiveList struct { type TrainingLiveList struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
StartDate string `json:"start_date"` StartDate string `json:"start_date"`
IsRandom bool `json:"is_random"` IsRandom bool `json:"is_random"`
} }
type LiveScheduleResult struct { // LiveScheduleRes ...
type LiveScheduleRes struct {
EventList []interface{} `json:"event_list"` EventList []interface{} `json:"event_list"`
LiveList []LiveList `json:"live_list"` LiveList []LiveList `json:"live_list"`
LimitedBonusList []interface{} `json:"limited_bonus_list"` LimitedBonusList []interface{} `json:"limited_bonus_list"`
@@ -82,14 +97,15 @@ type LiveScheduleResult struct {
TrainingLiveList []TrainingLiveList `json:"training_live_list"` TrainingLiveList []TrainingLiveList `json:"training_live_list"`
} }
// LiveScheduleResp ...
type LiveScheduleResp struct { type LiveScheduleResp struct {
Result LiveScheduleResult `json:"result"` Result LiveScheduleRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// Play // PlayReq ...
type PlayReq struct { type PlayReq struct {
Module string `json:"module"` Module string `json:"module"`
PartyUserID int64 `json:"party_user_id"` PartyUserID int64 `json:"party_user_id"`
@@ -103,12 +119,14 @@ type PlayReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
// RankInfo ...
type RankInfo struct { type RankInfo struct {
Rank int `json:"rank"` Rank int `json:"rank"`
RankMin int `json:"rank_min"` RankMin int `json:"rank_min"`
RankMax int `json:"rank_max"` RankMax int `json:"rank_max"`
} }
// NotesList ...
type NotesList struct { type NotesList struct {
TimingSec float64 `json:"timing_sec"` TimingSec float64 `json:"timing_sec"`
NotesAttribute int `json:"notes_attribute"` NotesAttribute int `json:"notes_attribute"`
@@ -118,6 +136,7 @@ type NotesList struct {
Position int `json:"position"` Position int `json:"position"`
} }
// LiveInfo ...
type LiveInfo struct { type LiveInfo struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
IsRandom bool `json:"is_random"` IsRandom bool `json:"is_random"`
@@ -126,19 +145,22 @@ type LiveInfo struct {
NotesList []NotesList `json:"notes_list"` NotesList []NotesList `json:"notes_list"`
} }
// PlayCostume ...
type PlayCostume struct { type PlayCostume struct {
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
IsRankMax bool `json:"is_rank_max"` IsRankMax bool `json:"is_rank_max"`
IsSigned bool `json:"is_signed"` IsSigned bool `json:"is_signed"`
} }
// UnitList ...
type UnitList struct { type UnitList struct {
Smile int `json:"smile"` Smile int `json:"smile"`
Cute int `json:"cute"` Cute int `json:"cute"`
Cool int `json:"cool"` Cool int `json:"cool"`
// Costume PlayCostume `json:"costume,omitempty"` Costume PlayCostume `json:"costume,omitempty"`
} }
// DeckInfo ...
type DeckInfo struct { type DeckInfo struct {
UnitDeckID int `json:"unit_deck_id"` UnitDeckID int `json:"unit_deck_id"`
TotalSmile int `json:"total_smile"` TotalSmile int `json:"total_smile"`
@@ -149,12 +171,14 @@ type DeckInfo struct {
UnitList []UnitList `json:"unit_list"` UnitList []UnitList `json:"unit_list"`
} }
// PlayLiveList ...
type PlayLiveList struct { type PlayLiveList struct {
LiveInfo LiveInfo `json:"live_info"` LiveInfo LiveInfo `json:"live_info"`
DeckInfo DeckInfo `json:"deck_info"` DeckInfo DeckInfo `json:"deck_info"`
} }
type PlayResponseData struct { // PlayRes ...
type PlayRes struct {
RankInfo []RankInfo `json:"rank_info"` RankInfo []RankInfo `json:"rank_info"`
EnergyFullTime string `json:"energy_full_time"` EnergyFullTime string `json:"energy_full_time"`
OverMaxEnergy int `json:"over_max_energy"` OverMaxEnergy int `json:"over_max_energy"`
@@ -167,7 +191,14 @@ type PlayResponseData struct {
ServerTimestamp int64 `json:"server_timestamp"` 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 { type PlayScoreReq struct {
Module string `json:"module"` Module string `json:"module"`
Action string `json:"action"` Action string `json:"action"`
@@ -177,6 +208,7 @@ type PlayScoreReq struct {
CommandNum string `json:"commandNum"` CommandNum string `json:"commandNum"`
} }
// On ...
type On struct { type On struct {
HasRecord bool `json:"has_record"` HasRecord bool `json:"has_record"`
LiveInfo LiveInfo `json:"live_info"` LiveInfo LiveInfo `json:"live_info"`
@@ -189,6 +221,7 @@ type On struct {
CanReplay bool `json:"can_replay"` CanReplay bool `json:"can_replay"`
} }
// Off ...
type Off struct { type Off struct {
HasRecord bool `json:"has_record"` HasRecord bool `json:"has_record"`
LiveInfo LiveInfo `json:"live_info"` LiveInfo LiveInfo `json:"live_info"`
@@ -201,7 +234,8 @@ type Off struct {
CanReplay bool `json:"can_replay"` CanReplay bool `json:"can_replay"`
} }
type PlayScoreResponseData struct { // PlayScoreRes ...
type PlayScoreRes struct {
On On `json:"on"` On On `json:"on"`
Off Off `json:"off"` Off Off `json:"off"`
RankInfo []RankInfo `json:"rank_info"` RankInfo []RankInfo `json:"rank_info"`
@@ -209,7 +243,14 @@ type PlayScoreResponseData struct {
ServerTimestamp int `json:"server_timestamp"` 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 { type PlayRewardReq struct {
Module string `json:"module"` Module string `json:"module"`
Action string `json:"action"` Action string `json:"action"`
@@ -234,12 +275,14 @@ type PlayRewardReq struct {
ScoreCool int `json:"score_cool"` ScoreCool int `json:"score_cool"`
} }
// Icon ...
type Icon struct { type Icon struct {
SlideID int `json:"slide_id"` SlideID int `json:"slide_id"`
JustID int `json:"just_id"` JustID int `json:"just_id"`
NormalID int `json:"normal_id"` NormalID int `json:"normal_id"`
} }
// LiveSetting ...
type LiveSetting struct { type LiveSetting struct {
StringSize int `json:"string_size"` StringSize int `json:"string_size"`
PreciseScoreAutoUpdateFlag bool `json:"precise_score_auto_update_flag"` PreciseScoreAutoUpdateFlag bool `json:"precise_score_auto_update_flag"`
@@ -253,6 +296,7 @@ type LiveSetting struct {
CutinType int `json:"cutin_type"` CutinType int `json:"cutin_type"`
} }
// PreciseList ...
type PreciseList struct { type PreciseList struct {
Effect int `json:"effect"` Effect int `json:"effect"`
Count int `json:"count"` Count int `json:"count"`
@@ -263,16 +307,20 @@ type PreciseList struct {
IsSame bool `json:"is_same"` IsSame bool `json:"is_same"`
} }
// BackgroundScore ...
type BackgroundScore struct { type BackgroundScore struct {
Smile int `json:"smile"` Smile int `json:"smile"`
Cute int `json:"cute"` Cute int `json:"cute"`
Cool int `json:"cool"` Cool int `json:"cool"`
} }
// TriggerLog ...
type TriggerLog struct { type TriggerLog struct {
ActivationRate int `json:"activation_rate"` ActivationRate int `json:"activation_rate"`
Position int `json:"position"` Position int `json:"position"`
} }
// PreciseScoreLog ...
type PreciseScoreLog struct { type PreciseScoreLog struct {
LiveSetting LiveSetting `json:"live_setting"` LiveSetting LiveSetting `json:"live_setting"`
TapAdjust int `json:"tap_adjust"` TapAdjust int `json:"tap_adjust"`
@@ -285,6 +333,7 @@ type PreciseScoreLog struct {
RandomSeed int `json:"random_seed"` RandomSeed int `json:"random_seed"`
} }
// RewardLiveInfo ...
type RewardLiveInfo struct { type RewardLiveInfo struct {
LiveDifficultyID int `json:"live_difficulty_id"` LiveDifficultyID int `json:"live_difficulty_id"`
IsRandom bool `json:"is_random"` IsRandom bool `json:"is_random"`
@@ -292,21 +341,25 @@ type RewardLiveInfo struct {
SwingFlag int `json:"swing_flag"` SwingFlag int `json:"swing_flag"`
} }
// PlayerExpUnitMax ...
type PlayerExpUnitMax struct { type PlayerExpUnitMax struct {
Before int `json:"before"` Before int `json:"before"`
After int `json:"after"` After int `json:"after"`
} }
// PlayerExpFriendMax ...
type PlayerExpFriendMax struct { type PlayerExpFriendMax struct {
Before int `json:"before"` Before int `json:"before"`
After int `json:"after"` After int `json:"after"`
} }
// PlayerExpLpMax ...
type PlayerExpLpMax struct { type PlayerExpLpMax struct {
Before int `json:"before"` Before int `json:"before"`
After int `json:"after"` After int `json:"after"`
} }
// BaseRewardInfo ...
type BaseRewardInfo struct { type BaseRewardInfo struct {
PlayerExp int `json:"player_exp"` PlayerExp int `json:"player_exp"`
PlayerExpUnitMax PlayerExpUnitMax `json:"player_exp_unit_max"` PlayerExpUnitMax PlayerExpUnitMax `json:"player_exp_unit_max"`
@@ -317,6 +370,7 @@ type BaseRewardInfo struct {
SocialPoint int `json:"social_point"` SocialPoint int `json:"social_point"`
} }
// LiveClear ...
type LiveClear struct { type LiveClear struct {
AddType int `json:"add_type"` AddType int `json:"add_type"`
Amount int `json:"amount"` Amount int `json:"amount"`
@@ -345,6 +399,7 @@ type LiveClear struct {
RemovableSkillIds []interface{} `json:"removable_skill_ids"` RemovableSkillIds []interface{} `json:"removable_skill_ids"`
} }
// LiveRank ...
type LiveRank struct { type LiveRank struct {
AddType int `json:"add_type"` AddType int `json:"add_type"`
Amount int `json:"amount"` Amount int `json:"amount"`
@@ -373,12 +428,14 @@ type LiveRank struct {
RemovableSkillIds []interface{} `json:"removable_skill_ids"` RemovableSkillIds []interface{} `json:"removable_skill_ids"`
} }
// RewardUnitList ...
type RewardUnitList struct { type RewardUnitList struct {
LiveClear []LiveClear `json:"live_clear"` LiveClear []LiveClear `json:"live_clear"`
LiveRank []LiveRank `json:"live_rank"` LiveRank []LiveRank `json:"live_rank"`
LiveCombo []interface{} `json:"live_combo"` LiveCombo []interface{} `json:"live_combo"`
} }
// Rewards ...
type Rewards struct { type Rewards struct {
Rarity int `json:"rarity"` Rarity int `json:"rarity"`
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
@@ -389,6 +446,7 @@ type Rewards struct {
InsertDate string `json:"insert_date"` InsertDate string `json:"insert_date"`
} }
// EffortPoint ...
type EffortPoint struct { type EffortPoint struct {
LiveEffortPointBoxSpecID int `json:"live_effort_point_box_spec_id"` LiveEffortPointBoxSpecID int `json:"live_effort_point_box_spec_id"`
Capacity int `json:"capacity"` Capacity int `json:"capacity"`
@@ -397,24 +455,7 @@ type EffortPoint struct {
Rewards []Rewards `json:"rewards"` Rewards []Rewards `json:"rewards"`
} }
// type PlayRewardUnitList struct { // PlayRewardUnitList ...
// 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"`
// }
type PlayRewardUnitList struct { type PlayRewardUnitList struct {
ID int `xorm:"id pk autoincr" json:"-"` ID int `xorm:"id pk autoincr" json:"-"`
UserDeckID int `xorm:"user_deck_id" json:"-"` UserDeckID int `xorm:"user_deck_id" json:"-"`
@@ -435,6 +476,7 @@ type PlayRewardUnitList struct {
InsertData int64 `xorm:"insert_date" json:"-"` InsertData int64 `xorm:"insert_date" json:"-"`
} }
// BeforeUserInfo ...
type BeforeUserInfo struct { type BeforeUserInfo struct {
Level int `json:"level"` Level int `json:"level"`
Exp int `json:"exp"` Exp int `json:"exp"`
@@ -460,6 +502,7 @@ type BeforeUserInfo struct {
UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"` UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"`
} }
// AfterUserInfo ...
type AfterUserInfo struct { type AfterUserInfo struct {
Level int `json:"level"` Level int `json:"level"`
Exp int `json:"exp"` Exp int `json:"exp"`
@@ -485,22 +528,26 @@ type AfterUserInfo struct {
UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"` UnlockRandomLiveAqours int `json:"unlock_random_live_aqours"`
} }
// NextLevelInfo ...
type NextLevelInfo struct { type NextLevelInfo struct {
Level int `json:"level"` Level int `json:"level"`
FromExp int `json:"from_exp"` FromExp int `json:"from_exp"`
} }
// GoalAccompInfo ...
type GoalAccompInfo struct { type GoalAccompInfo struct {
AchievedIds []interface{} `json:"achieved_ids"` AchievedIds []interface{} `json:"achieved_ids"`
Rewards []interface{} `json:"rewards"` Rewards []interface{} `json:"rewards"`
} }
// RewardRankInfo ...
type RewardRankInfo struct { type RewardRankInfo struct {
BeforeClassRankID int `json:"before_class_rank_id"` BeforeClassRankID int `json:"before_class_rank_id"`
AfterClassRankID int `json:"after_class_rank_id"` AfterClassRankID int `json:"after_class_rank_id"`
RankUpDate string `json:"rank_up_date"` RankUpDate string `json:"rank_up_date"`
} }
// ClassSystem ...
type ClassSystem struct { type ClassSystem struct {
RankInfo RewardRankInfo `json:"rank_info"` RankInfo RewardRankInfo `json:"rank_info"`
CompleteFlag bool `json:"complete_flag"` CompleteFlag bool `json:"complete_flag"`
@@ -508,6 +555,7 @@ type ClassSystem struct {
IsVisible bool `json:"is_visible"` IsVisible bool `json:"is_visible"`
} }
// PlayRewardList ...
type PlayRewardList struct { type PlayRewardList struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
@@ -516,6 +564,7 @@ type PlayRewardList struct {
RewardBoxFlag bool `json:"reward_box_flag"` RewardBoxFlag bool `json:"reward_box_flag"`
} }
// AccomplishedAchievementList ...
type AccomplishedAchievementList struct { type AccomplishedAchievementList struct {
AchievementID int `json:"achievement_id"` AchievementID int `json:"achievement_id"`
Count int `json:"count"` Count int `json:"count"`
@@ -531,23 +580,14 @@ type AccomplishedAchievementList struct {
RewardList []PlayRewardList `json:"reward_list"` RewardList []PlayRewardList `json:"reward_list"`
} }
type Parameter struct { // RewardUnitSupportList ...
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"`
}
type RewardUnitSupportList struct { type RewardUnitSupportList struct {
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
Amount int `json:"amount"` Amount int `json:"amount"`
} }
type RewardResponseData struct { // RewardRes ...
type RewardRes struct {
LiveInfo []RewardLiveInfo `json:"live_info"` LiveInfo []RewardLiveInfo `json:"live_info"`
Rank int `json:"rank"` Rank int `json:"rank"`
ComboRank int `json:"combo_rank"` ComboRank int `json:"combo_rank"`
@@ -575,8 +615,41 @@ type RewardResponseData struct {
AccomplishedAchievementList []AccomplishedAchievementList `json:"accomplished_achievement_list"` AccomplishedAchievementList []AccomplishedAchievementList `json:"accomplished_achievement_list"`
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"` UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
AddedAchievementList []interface{} `json:"added_achievement_list"` AddedAchievementList []interface{} `json:"added_achievement_list"`
MuseumInfo RewardMuseumInfo `json:"museum_info"` MuseumInfo Museum `json:"museum_info"`
UnitSupportList []RewardUnitSupportList `json:"unit_support_list"` UnitSupportList []RewardUnitSupportList `json:"unit_support_list"`
ServerTimestamp int `json:"server_timestamp"` ServerTimestamp int `json:"server_timestamp"`
PresentCnt int `json:"present_cnt"` 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"`
}
+9
View File
@@ -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"`
}
+9 -6
View File
@@ -1,12 +1,13 @@
package model package model
// module: multiunit, action: multiunitscenarioStatus // MultiUnitScenarioChapterList ...
type MultiUnitScenarioChapterList struct { type MultiUnitScenarioChapterList struct {
MultiUnitScenarioID int `json:"multi_unit_scenario_id"` MultiUnitScenarioID int `json:"multi_unit_scenario_id"`
Chapter int `json:"chapter"` Chapter int `json:"chapter"`
Status int `json:"status"` Status int `json:"status"`
} }
// MultiUnitScenarioStatusList ...
type MultiUnitScenarioStatusList struct { type MultiUnitScenarioStatusList struct {
MultiUnitID int `json:"multi_unit_id"` MultiUnitID int `json:"multi_unit_id"`
Status int `json:"status"` Status int `json:"status"`
@@ -15,14 +16,16 @@ type MultiUnitScenarioStatusList struct {
ChapterList []MultiUnitScenarioChapterList `json:"chapter_list"` ChapterList []MultiUnitScenarioChapterList `json:"chapter_list"`
} }
type MultiUnitScenarioStatusResult struct { // MultiUnitScenarioStatusRes ...
type MultiUnitScenarioStatusRes struct {
MultiUnitScenarioStatusList []MultiUnitScenarioStatusList `json:"multi_unit_scenario_status_list"` MultiUnitScenarioStatusList []MultiUnitScenarioStatusList `json:"multi_unit_scenario_status_list"`
UnlockedMultiUnitScenarioIds []interface{} `json:"unlocked_multi_unit_scenario_ids"` UnlockedMultiUnitScenarioIds []interface{} `json:"unlocked_multi_unit_scenario_ids"`
} }
// MultiUnitScenarioStatusResp ...
type MultiUnitScenarioStatusResp struct { type MultiUnitScenarioStatusResp struct {
Result MultiUnitScenarioStatusResult `json:"result"` Result MultiUnitScenarioStatusRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
+17
View File
@@ -1,23 +1,40 @@
package model package model
// MuseumResp ...
type MuseumResp struct { type MuseumResp struct {
ResponseData MuseumRes `json:"response_data"` ResponseData MuseumRes `json:"response_data"`
ReleaseInfo []interface{} `json:"release_info"` ReleaseInfo []interface{} `json:"release_info"`
StatusCode int `json:"status_code"` StatusCode int `json:"status_code"`
} }
// MuseumParameter ...
type MuseumParameter struct { type MuseumParameter struct {
Smile int `json:"smile"` Smile int `json:"smile"`
Pure int `json:"pure"` Pure int `json:"pure"`
Cool int `json:"cool"` Cool int `json:"cool"`
} }
// Museum ...
type Museum struct { type Museum struct {
Parameter MuseumParameter `json:"parameter"` Parameter MuseumParameter `json:"parameter"`
ContentsIDList []int `json:"contents_id_list"` ContentsIDList []int `json:"contents_id_list"`
} }
// MuseumRes ...
type MuseumRes struct { type MuseumRes struct {
MuseumInfo Museum `json:"museum_info"` MuseumInfo Museum `json:"museum_info"`
ServerTimestamp int64 `json:"server_timestamp"` 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"`
}
+14
View File
@@ -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"`
}
+14
View File
@@ -42,3 +42,17 @@ type NoticeUserGreetingRes struct {
NoticeList []interface{} `json:"notice_list"` NoticeList []interface{} `json:"notice_list"`
ServerTimestamp int64 `json:"server_timestamp"` 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"`
}
-172
View File
@@ -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"`
}
+21 -6
View File
@@ -1,10 +1,11 @@
package model package model
// module: payment, action: productList // RestrictionInfo ...
type RestrictionInfo struct { type RestrictionInfo struct {
Restricted bool `json:"restricted"` Restricted bool `json:"restricted"`
} }
// UnderAgeInfo ...
type UnderAgeInfo struct { type UnderAgeInfo struct {
BirthSet bool `json:"birth_set"` BirthSet bool `json:"birth_set"`
HasLimit bool `json:"has_limit"` HasLimit bool `json:"has_limit"`
@@ -12,6 +13,7 @@ type UnderAgeInfo struct {
MonthUsed int `json:"month_used"` MonthUsed int `json:"month_used"`
} }
// SnsProductItemList ...
type SnsProductItemList struct { type SnsProductItemList struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
@@ -19,6 +21,7 @@ type SnsProductItemList struct {
IsFreebie bool `json:"is_freebie"` IsFreebie bool `json:"is_freebie"`
} }
// SnsProductList ...
type SnsProductList struct { type SnsProductList struct {
ProductID string `json:"product_id"` ProductID string `json:"product_id"`
Name string `json:"name"` Name string `json:"name"`
@@ -28,6 +31,7 @@ type SnsProductList struct {
ItemList []SnsProductItemList `json:"item_list"` ItemList []SnsProductItemList `json:"item_list"`
} }
// ProductItemList ...
type ProductItemList struct { type ProductItemList struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
@@ -36,12 +40,14 @@ type ProductItemList struct {
IsRankMax bool `json:"is_rank_max,omitempty"` IsRankMax bool `json:"is_rank_max,omitempty"`
} }
// LimitStatus ...
type LimitStatus struct { type LimitStatus struct {
TermStartDate string `json:"term_start_date"` TermStartDate string `json:"term_start_date"`
RemainingTime string `json:"remaining_time"` RemainingTime string `json:"remaining_time"`
RemainingCount int `json:"remaining_count"` RemainingCount int `json:"remaining_count"`
} }
// ProductList ...
type ProductList struct { type ProductList struct {
ProductID string `json:"product_id"` ProductID string `json:"product_id"`
Name string `json:"name"` Name string `json:"name"`
@@ -55,6 +61,7 @@ type ProductList struct {
LimitStatus LimitStatus `json:"limit_status"` LimitStatus LimitStatus `json:"limit_status"`
} }
// SubscriptionItemList ...
type SubscriptionItemList struct { type SubscriptionItemList struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
@@ -62,26 +69,31 @@ type SubscriptionItemList struct {
IsFreebie bool `json:"is_freebie"` IsFreebie bool `json:"is_freebie"`
} }
// RewardList ...
type RewardList struct { type RewardList struct {
ItemID int `json:"item_id"` ItemID int `json:"item_id"`
AddType int `json:"add_type"` AddType int `json:"add_type"`
Amount int `json:"amount"` Amount int `json:"amount"`
} }
// Items ...
type Items struct { type Items struct {
Seq int `json:"seq"` Seq int `json:"seq"`
RewardList []RewardList `json:"reward_list"` RewardList []RewardList `json:"reward_list"`
} }
// LicenseInfo ...
type LicenseInfo struct { type LicenseInfo struct {
Name string `json:"name"` Name string `json:"name"`
Items []Items `json:"items"` Items []Items `json:"items"`
} }
// UserStatus ...
type UserStatus struct { type UserStatus struct {
IsLicensed bool `json:"is_licensed"` IsLicensed bool `json:"is_licensed"`
} }
// SubscriptionStatus ...
type SubscriptionStatus struct { type SubscriptionStatus struct {
LicenseID int `json:"license_id"` LicenseID int `json:"license_id"`
LicenseType int `json:"license_type"` LicenseType int `json:"license_type"`
@@ -91,6 +103,7 @@ type SubscriptionStatus struct {
BadgeFlag bool `json:"badge_flag"` BadgeFlag bool `json:"badge_flag"`
} }
// SubscriptionList ...
type SubscriptionList struct { type SubscriptionList struct {
ProductID string `json:"product_id"` ProductID string `json:"product_id"`
Name string `json:"name"` Name string `json:"name"`
@@ -104,7 +117,8 @@ type SubscriptionList struct {
SubscriptionStatus SubscriptionStatus `json:"subscription_status"` SubscriptionStatus SubscriptionStatus `json:"subscription_status"`
} }
type ProductListResult struct { // ProductListRes ...
type ProductListRes struct {
RestrictionInfo RestrictionInfo `json:"restriction_info"` RestrictionInfo RestrictionInfo `json:"restriction_info"`
UnderAgeInfo UnderAgeInfo `json:"under_age_info"` UnderAgeInfo UnderAgeInfo `json:"under_age_info"`
SnsProductList []SnsProductList `json:"sns_product_list"` SnsProductList []SnsProductList `json:"sns_product_list"`
@@ -113,9 +127,10 @@ type ProductListResult struct {
ShowPointShop bool `json:"show_point_shop"` ShowPointShop bool `json:"show_point_shop"`
} }
// ProductListResp ...
type ProductListResp struct { type ProductListResp struct {
Result ProductListResult `json:"result"` Result ProductListRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
-10
View File
@@ -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"`
}
+25 -18
View File
@@ -1,41 +1,45 @@
package model package model
// module: scenario, action: scenarioStatus // ScenarioStatusList ...
type ScenarioStatusList struct { type ScenarioStatusList struct {
ScenarioID int `json:"scenario_id"` ScenarioID int `json:"scenario_id"`
Status int `json:"status"` Status int `json:"status"`
} }
type ScenarioStatusResult struct { // ScenarioStatusRes ...
type ScenarioStatusRes struct {
ScenarioStatusList []ScenarioStatusList `json:"scenario_status_list"` ScenarioStatusList []ScenarioStatusList `json:"scenario_status_list"`
} }
// ScenarioStatusResp ...
type ScenarioStatusResp struct { type ScenarioStatusResp struct {
Result ScenarioStatusResult `json:"result"` Result ScenarioStatusRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// module: subscenario, action: subscenarioStatus // SubscenarioStatusList ...
type SubscenarioStatusList struct { type SubscenarioStatusList struct {
SubscenarioID int `json:"subscenario_id"` SubscenarioID int `json:"subscenario_id"`
Status int `json:"status"` Status int `json:"status"`
} }
type SubscenarioStatusResult struct { // SubscenarioStatusRes ...
type SubscenarioStatusRes struct {
SubscenarioStatusList []SubscenarioStatusList `json:"subscenario_status_list"` SubscenarioStatusList []SubscenarioStatusList `json:"subscenario_status_list"`
UnlockedSubscenarioIds []interface{} `json:"unlocked_subscenario_ids"` UnlockedSubscenarioIds []interface{} `json:"unlocked_subscenario_ids"`
} }
// SubscenarioStatusResp ...
type SubscenarioStatusResp struct { type SubscenarioStatusResp struct {
Result SubscenarioStatusResult `json:"result"` Result SubscenarioStatusRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// module: eventscenario, action: status // EventScenarioChapterList ...
type EventScenarioChapterList struct { type EventScenarioChapterList struct {
EventScenarioID int `json:"event_scenario_id"` EventScenarioID int `json:"event_scenario_id"`
Chapter int `json:"chapter"` Chapter int `json:"chapter"`
@@ -48,6 +52,7 @@ type EventScenarioChapterList struct {
Amount int `json:"amount"` Amount int `json:"amount"`
} }
// EventScenarioList ...
type EventScenarioList struct { type EventScenarioList struct {
EventID int `json:"event_id"` EventID int `json:"event_id"`
EventScenarioBtnAsset string `json:"event_scenario_btn_asset"` EventScenarioBtnAsset string `json:"event_scenario_btn_asset"`
@@ -55,13 +60,15 @@ type EventScenarioList struct {
ChapterList []EventScenarioChapterList `json:"chapter_list"` ChapterList []EventScenarioChapterList `json:"chapter_list"`
} }
type EventScenarioStatusResult struct { // EventScenarioStatusRes ...
type EventScenarioStatusRes struct {
EventScenarioList []EventScenarioList `json:"event_scenario_list"` EventScenarioList []EventScenarioList `json:"event_scenario_list"`
} }
// EventScenarioStatusResp ...
type EventScenarioStatusResp struct { type EventScenarioStatusResp struct {
Result EventScenarioStatusResult `json:"result"` Result EventScenarioStatusRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
-23
View File
@@ -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"`
}
+16 -10
View File
@@ -1,5 +1,6 @@
package model package model
// TopInfoLicenseInfo ...
type TopInfoLicenseInfo struct { type TopInfoLicenseInfo struct {
LicenseList []interface{} `json:"license_list"` LicenseList []interface{} `json:"license_list"`
LicensedInfo []interface{} `json:"licensed_info"` LicensedInfo []interface{} `json:"licensed_info"`
@@ -7,7 +8,8 @@ type TopInfoLicenseInfo struct {
BadgeFlag bool `json:"badge_flag"` BadgeFlag bool `json:"badge_flag"`
} }
type TopInfoResult struct { // TopInfoRes ...
type TopInfoRes struct {
FriendActionCnt int `json:"friend_action_cnt"` FriendActionCnt int `json:"friend_action_cnt"`
FriendGreetCnt int `json:"friend_greet_cnt"` FriendGreetCnt int `json:"friend_greet_cnt"`
FriendVarietyCnt int `json:"friend_variety_cnt"` FriendVarietyCnt int `json:"friend_variety_cnt"`
@@ -31,13 +33,15 @@ type TopInfoResult struct {
HasAdReward bool `json:"has_ad_reward"` HasAdReward bool `json:"has_ad_reward"`
} }
// TopInfoResp ...
type TopInfoResp struct { type TopInfoResp struct {
Result TopInfoResult `json:"result"` Result TopInfoRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// TopInfoOnceNotification ...
type TopInfoOnceNotification struct { type TopInfoOnceNotification struct {
Push bool `json:"push"` Push bool `json:"push"`
Lp bool `json:"lp"` Lp bool `json:"lp"`
@@ -50,7 +54,8 @@ type TopInfoOnceNotification struct {
Birthday bool `json:"birthday"` Birthday bool `json:"birthday"`
} }
type TopInfoOnceResult struct { // TopInfoOnceRes ...
type TopInfoOnceRes struct {
NewAchievementCnt int `json:"new_achievement_cnt"` NewAchievementCnt int `json:"new_achievement_cnt"`
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"` UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
LiveDailyRewardExist bool `json:"live_daily_reward_exist"` LiveDailyRewardExist bool `json:"live_daily_reward_exist"`
@@ -64,9 +69,10 @@ type TopInfoOnceResult struct {
OpenV98 bool `json:"open_v98"` OpenV98 bool `json:"open_v98"`
} }
// TopInfoOnceResp ...
type TopInfoOnceResp struct { type TopInfoOnceResp struct {
Result TopInfoOnceResult `json:"result"` Result TopInfoOnceRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
+60 -34
View File
@@ -126,13 +126,28 @@ type SkillEquipResp struct {
StatusCode int `json:"status_code"` 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 { type Costume struct {
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
IsRankMax bool `json:"is_rank_max"` IsRankMax bool `json:"is_rank_max"`
IsSigned bool `json:"is_signed"` IsSigned bool `json:"is_signed"`
} }
// Active ...
type Active struct { type Active struct {
UnitOwningUserID int `xorm:"unit_owning_user_id pk autoincr" json:"unit_owning_user_id"` UnitOwningUserID int `xorm:"unit_owning_user_id pk autoincr" json:"unit_owning_user_id"`
UserID int `xorm:"user_id" json:"-"` UserID int `xorm:"user_id" json:"-"`
@@ -162,6 +177,7 @@ type Active struct {
// Costume Costume `json:"costume,omitempty"` // Costume Costume `json:"costume,omitempty"`
} }
// Waiting ...
type Waiting struct { type Waiting struct {
UnitOwningUserID int64 `json:"unit_owning_user_id"` UnitOwningUserID int64 `json:"unit_owning_user_id"`
UnitID int `json:"unit_id"` UnitID int `json:"unit_id"`
@@ -189,56 +205,62 @@ type Waiting struct {
InsertDate string `json:"insert_date"` InsertDate string `json:"insert_date"`
} }
type UnitAllResult struct { // UnitAllRes ...
type UnitAllRes struct {
Active []Active `json:"active"` Active []Active `json:"active"`
Waiting []Waiting `json:"waiting"` Waiting []Waiting `json:"waiting"`
} }
// UnitAllResp ...
type UnitAllResp struct { type UnitAllResp struct {
Result UnitAllResult `json:"result"` Result UnitAllRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// module: unit, action: deckInfo // UnitOwningUserIds ...
type UnitOwningUserIds struct { type UnitOwningUserIds struct {
Position int `json:"position"` Position int `json:"position"`
UnitOwningUserID int `json:"unit_owning_user_id"` UnitOwningUserID int `json:"unit_owning_user_id"`
} }
type UnitDeckInfo struct { // UnitDeckInfoRes ...
type UnitDeckInfoRes struct {
UnitDeckID int `json:"unit_deck_id"` UnitDeckID int `json:"unit_deck_id"`
MainFlag bool `json:"main_flag"` MainFlag bool `json:"main_flag"`
DeckName string `json:"deck_name"` DeckName string `json:"deck_name"`
UnitOwningUserIds []UnitOwningUserIds `json:"unit_owning_user_ids"` UnitOwningUserIds []UnitOwningUserIds `json:"unit_owning_user_ids"`
} }
// UnitDeckInfoResp ...
type UnitDeckInfoResp struct { type UnitDeckInfoResp struct {
Result []UnitDeckInfo `json:"result"` Result []UnitDeckInfoRes `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"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` 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 { type OwningInfo struct {
UnitRemovableSkillID int `json:"unit_removable_skill_id"` UnitRemovableSkillID int `json:"unit_removable_skill_id"`
TotalAmount int `json:"total_amount"` TotalAmount int `json:"total_amount"`
@@ -246,19 +268,21 @@ type OwningInfo struct {
InsertDate string `json:"insert_date"` InsertDate string `json:"insert_date"`
} }
type RemovableSkillResult struct { // RemovableSkillRes ...
type RemovableSkillRes struct {
OwningInfo []OwningInfo `json:"owning_info"` OwningInfo []OwningInfo `json:"owning_info"`
EquipmentInfo map[int]interface{} `json:"equipment_info"` EquipmentInfo map[int]interface{} `json:"equipment_info"`
} }
// RemovableSkillResp ...
type RemovableSkillResp struct { type RemovableSkillResp struct {
Result RemovableSkillResult `json:"result"` Result RemovableSkillRes `json:"result"`
Status int `json:"status"` Status int `json:"status"`
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// module: unit, action: deck // UnitDeckReq ...
type UnitDeckReq struct { type UnitDeckReq struct {
Module string `json:"module"` Module string `json:"module"`
UnitDeckList []UnitDeckList `json:"unit_deck_list"` UnitDeckList []UnitDeckList `json:"unit_deck_list"`
@@ -266,11 +290,13 @@ type UnitDeckReq struct {
Mgd int `json:"mgd"` Mgd int `json:"mgd"`
} }
// UnitDeckDetail ...
type UnitDeckDetail struct { type UnitDeckDetail struct {
Position int `json:"position"` Position int `json:"position"`
UnitOwningUserID int `json:"unit_owning_user_id"` UnitOwningUserID int `json:"unit_owning_user_id"`
} }
// UnitDeckList ...
type UnitDeckList struct { type UnitDeckList struct {
UnitDeckDetail []UnitDeckDetail `json:"unit_deck_detail"` UnitDeckDetail []UnitDeckDetail `json:"unit_deck_detail"`
UnitDeckID int `json:"unit_deck_id"` UnitDeckID int `json:"unit_deck_id"`
@@ -278,7 +304,7 @@ type UnitDeckList struct {
DeckName string `json:"deck_name"` DeckName string `json:"deck_name"`
} }
// module: unit, action: deckName // DeckNameReq ...
type DeckNameReq struct { type DeckNameReq struct {
Module string `json:"module"` Module string `json:"module"`
UnitDeckID int `json:"unit_deck_id"` UnitDeckID int `json:"unit_deck_id"`
+19
View File
@@ -20,3 +20,22 @@ type UserNameChangeRes struct {
AfterName string `json:"after_name"` AfterName string `json:"after_name"`
ServerTimestamp int64 `json:"server_timestamp"` 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"`
}
-171
View File
@@ -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)
}
}
}
}
+2 -2
View File
@@ -238,7 +238,7 @@ func GenCommonUnitData3() {
err := UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck) err := UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck)
CheckErr(err) CheckErr(err)
unitDeckInfo := []model.UnitDeckInfo{} unitDeckInfo := []model.UnitDeckInfoRes{}
for _, deck := range userDeck { for _, deck := range userDeck {
deckUnit := []UnitDeckData{} deckUnit := []UnitDeckData{}
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) 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 { if deck.MainFlag == 1 {
mainFlag = true mainFlag = true
} }
unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{
UnitDeckID: deck.DeckID, UnitDeckID: deck.DeckID,
MainFlag: mainFlag, MainFlag: mainFlag,
DeckName: deck.DeckName, DeckName: deck.DeckName,
+30 -30
View File
@@ -199,7 +199,7 @@ func GenApi1Data() {
LiveStatusResp := model.LiveStatusResp{ LiveStatusResp := model.LiveStatusResp{
// _ = model.LiveStatusResp{ // _ = model.LiveStatusResp{
Result: model.LiveStatusResult{ Result: model.LiveStatusRes{
NormalLiveStatusList: normalLives, NormalLiveStatusList: normalLives,
SpecialLiveStatusList: specialLives, SpecialLiveStatusList: specialLives,
TrainingLiveStatusList: []model.TrainingLiveStatusList{}, TrainingLiveStatusList: []model.TrainingLiveStatusList{},
@@ -225,7 +225,7 @@ func GenApi1Data() {
} }
liveListResp := model.LiveScheduleResp{ liveListResp := model.LiveScheduleResp{
// _ = model.LiveScheduleResp{ // _ = model.LiveScheduleResp{
Result: model.LiveScheduleResult{ Result: model.LiveScheduleRes{
EventList: []interface{}{}, EventList: []interface{}{},
LiveList: livesList, LiveList: livesList,
LimitedBonusList: []interface{}{}, LimitedBonusList: []interface{}{},
@@ -257,7 +257,7 @@ func GenApi1Data() {
unitListResp := model.UnitAllResp{ unitListResp := model.UnitAllResp{
// _ = model.UnitAllResp{ // _ = model.UnitAllResp{
Result: model.UnitAllResult{ Result: model.UnitAllRes{
Active: unitsData, Active: unitsData,
Waiting: []model.Waiting{}, Waiting: []model.Waiting{},
}, },
@@ -273,7 +273,7 @@ func GenApi1Data() {
err = UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck) err = UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck)
CheckErr(err) CheckErr(err)
unitDeckInfo := []model.UnitDeckInfo{} unitDeckInfo := []model.UnitDeckInfoRes{}
for _, deck := range userDeck { for _, deck := range userDeck {
deckUnit := []UnitDeckData{} deckUnit := []UnitDeckData{}
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit) 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 { if deck.MainFlag == 1 {
mainFlag = true mainFlag = true
} }
unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfo{ unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{
UnitDeckID: deck.DeckID, UnitDeckID: deck.DeckID,
MainFlag: mainFlag, MainFlag: mainFlag,
DeckName: deck.DeckName, DeckName: deck.DeckName,
@@ -310,7 +310,7 @@ func GenApi1Data() {
// unit_support_result // unit_support_result
unitSupportResp := model.UnitSupportResp{ unitSupportResp := model.UnitSupportResp{
// _ = model.UnitSupportResp{ // _ = model.UnitSupportResp{
Result: model.UnitSupportResult{ Result: model.UnitSupportRes{
UnitSupportList: []model.UnitSupportList{}, UnitSupportList: []model.UnitSupportList{},
}, // 练习道具 }, // 练习道具
Status: 200, Status: 200,
@@ -322,7 +322,7 @@ func GenApi1Data() {
// owning_equip_result // owning_equip_result
rmSkillResp := model.RemovableSkillResp{ rmSkillResp := model.RemovableSkillResp{
// _ = model.RemovableSkillResp{ // _ = model.RemovableSkillResp{
Result: model.RemovableSkillResult{ Result: model.RemovableSkillRes{
OwningInfo: []model.OwningInfo{}, OwningInfo: []model.OwningInfo{},
EquipmentInfo: map[int]interface{}{}, EquipmentInfo: map[int]interface{}{},
}, // 宝石 }, // 宝石
@@ -335,7 +335,7 @@ func GenApi1Data() {
// costume_list_result // costume_list_result
costumeListResp := model.CostumeListResp{ costumeListResp := model.CostumeListResp{
// _ = model.CostumeListResp{ // _ = model.CostumeListResp{
Result: model.CostumeListResult{ Result: model.CostumeListRes{
CostumeList: []model.CostumeList{}, CostumeList: []model.CostumeList{},
}, },
Status: 200, Status: 200,
@@ -425,7 +425,7 @@ func GenApi1Data() {
} }
scenarioResp := model.ScenarioStatusResp{ scenarioResp := model.ScenarioStatusResp{
// _ = model.ScenarioStatusResp{ // _ = model.ScenarioStatusResp{
Result: model.ScenarioStatusResult{ Result: model.ScenarioStatusRes{
ScenarioStatusList: scenarioLists, ScenarioStatusList: scenarioLists,
}, },
Status: 200, Status: 200,
@@ -451,7 +451,7 @@ func GenApi1Data() {
} }
subScenarioResp := model.SubscenarioStatusResp{ subScenarioResp := model.SubscenarioStatusResp{
// _ = model.SubscenarioStatusResp{ // _ = model.SubscenarioStatusResp{
Result: model.SubscenarioStatusResult{ Result: model.SubscenarioStatusRes{
SubscenarioStatusList: subScenarioLists, SubscenarioStatusList: subScenarioLists,
UnlockedSubscenarioIds: []interface{}{}, UnlockedSubscenarioIds: []interface{}{},
}, },
@@ -519,7 +519,7 @@ func GenApi1Data() {
} }
eventScenarioResp := model.EventScenarioStatusResp{ eventScenarioResp := model.EventScenarioStatusResp{
// _ = model.EventScenarioStatusResp{ // _ = model.EventScenarioStatusResp{
Result: model.EventScenarioStatusResult{ Result: model.EventScenarioStatusRes{
EventScenarioList: eventsList, // EventScenarioList: eventsList, //
}, },
Status: 200, Status: 200,
@@ -566,7 +566,7 @@ func GenApi1Data() {
} }
unitsResp := model.MultiUnitScenarioStatusResp{ unitsResp := model.MultiUnitScenarioStatusResp{
// _ = model.MultiUnitScenarioStatusResp{ // _ = model.MultiUnitScenarioStatusResp{
Result: model.MultiUnitScenarioStatusResult{ Result: model.MultiUnitScenarioStatusRes{
MultiUnitScenarioStatusList: multiUnitsList, MultiUnitScenarioStatusList: multiUnitsList,
UnlockedMultiUnitScenarioIds: []interface{}{}, UnlockedMultiUnitScenarioIds: []interface{}{},
}, },
@@ -579,7 +579,7 @@ func GenApi1Data() {
// product_result // product_result
productResp := model.ProductListResp{ productResp := model.ProductListResp{
// _ = model.ProductListResp{ // _ = model.ProductListResp{
Result: model.ProductListResult{ Result: model.ProductListRes{
RestrictionInfo: model.RestrictionInfo{ RestrictionInfo: model.RestrictionInfo{
Restricted: false, Restricted: false,
}, },
@@ -603,7 +603,7 @@ func GenApi1Data() {
// banner_result // banner_result
bannerResp := model.BannerListResp{ bannerResp := model.BannerListResp{
// _ = model.BannerListResp{ // _ = model.BannerListResp{
Result: model.BannerListResult{ Result: model.BannerListRes{
TimeLimit: "2037-12-31 23:59:59", TimeLimit: "2037-12-31 23:59:59",
BannerList: []model.BannerList{ BannerList: []model.BannerList{
{ {
@@ -639,7 +639,7 @@ func GenApi1Data() {
// item_marquee_result // item_marquee_result
marqueeResp := model.NoticeMarqueeResp{ marqueeResp := model.NoticeMarqueeResp{
// _ = model.NoticeMarqueeResp{ // _ = model.NoticeMarqueeResp{
Result: model.NoticeMarqueeResult{ Result: model.NoticeMarqueeRes{
ItemCount: 0, ItemCount: 0,
MarqueeList: []interface{}{}, MarqueeList: []interface{}{},
}, },
@@ -652,7 +652,7 @@ func GenApi1Data() {
// user_intro_result // user_intro_result
userIntroResp := model.UserNaviResp{ userIntroResp := model.UserNaviResp{
// _ = model.UserNaviResp{ // _ = model.UserNaviResp{
Result: model.UserNaviResult{ Result: model.UserNaviRes{
User: model.User{ User: model.User{
UserID: 9999999, UserID: 9999999,
UnitOwningUserID: CenterId, UnitOwningUserID: CenterId,
@@ -667,7 +667,7 @@ func GenApi1Data() {
// special_cutin_result // special_cutin_result
cutinResp := model.SpecialCutinResp{ cutinResp := model.SpecialCutinResp{
// _ = model.SpecialCutinResp{ // _ = model.SpecialCutinResp{
Result: model.SpecialCutinResult{ Result: model.SpecialCutinRes{
SpecialCutinList: []interface{}{}, SpecialCutinList: []interface{}{},
}, },
Status: 200, Status: 200,
@@ -698,7 +698,7 @@ func GenApi1Data() {
} }
awardResp := model.AwardInfoResp{ awardResp := model.AwardInfoResp{
// _ = model.AwardInfoResp{ // _ = model.AwardInfoResp{
Result: model.AwardInfoResult{ Result: model.AwardInfoRes{
AwardInfo: awardsList, AwardInfo: awardsList,
}, },
Status: 200, Status: 200,
@@ -729,7 +729,7 @@ func GenApi1Data() {
} }
backgroundResp := model.BackgroundInfoResp{ backgroundResp := model.BackgroundInfoResp{
// _ = model.BackgroundInfoResp{ // _ = model.BackgroundInfoResp{
Result: model.BackgroundInfoResult{ Result: model.BackgroundInfoRes{
BackgroundInfo: backgroundsList, BackgroundInfo: backgroundsList,
}, },
Status: 200, Status: 200,
@@ -763,7 +763,7 @@ func GenApi1Data() {
} }
exPointsResp := model.ExchangePointResp{ exPointsResp := model.ExchangePointResp{
// _ = model.ExchangePointResp{ // _ = model.ExchangePointResp{
Result: model.ExchangePointResult{ Result: model.ExchangePointRes{
ExchangePointList: exPointsList, ExchangePointList: exPointsList,
}, },
Status: 200, Status: 200,
@@ -775,7 +775,7 @@ func GenApi1Data() {
// live_se_result // live_se_result
liveSeResp := model.LiveSeInfoResp{ liveSeResp := model.LiveSeInfoResp{
// _ = model.LiveSeInfoResp{ // _ = model.LiveSeInfoResp{
Result: model.LiveSeInfoResult{ Result: model.LiveSeInfoRes{
LiveSeList: []int{1, 2, 3}, LiveSeList: []int{1, 2, 3},
}, },
Status: 200, Status: 200,
@@ -787,7 +787,7 @@ func GenApi1Data() {
// live_icon_result // live_icon_result
liveIconResp := model.LiveIconInfoResp{ liveIconResp := model.LiveIconInfoResp{
// _ = model.LiveIconInfoResp{ // _ = model.LiveIconInfoResp{
Result: model.LiveIconInfoResult{ Result: model.LiveIconInfoRes{
LiveNotesIconList: []int{1, 2, 3}, LiveNotesIconList: []int{1, 2, 3},
}, },
Status: 200, Status: 200,
@@ -827,7 +827,7 @@ func GenApi1Data() {
// Final // Final
k, err := json.Marshal(respAll) k, err := json.Marshal(respAll)
CheckErr(err) CheckErr(err)
resp := model.Response{ resp := model.ApiResp{
ResponseData: k, ResponseData: k,
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
@@ -846,7 +846,7 @@ func GenApi2Data() {
// login_topinfo_result // login_topinfo_result
topInfoResp := model.TopInfoResp{ topInfoResp := model.TopInfoResp{
// _ = model.TopInfoResp{ // _ = model.TopInfoResp{
Result: model.TopInfoResult{ Result: model.TopInfoRes{
FriendActionCnt: 0, FriendActionCnt: 0,
FriendGreetCnt: 0, FriendGreetCnt: 0,
FriendVarietyCnt: 0, FriendVarietyCnt: 0,
@@ -883,7 +883,7 @@ func GenApi2Data() {
// login_topinfo_once_result // login_topinfo_once_result
topInfoOnceResp := model.TopInfoOnceResp{ topInfoOnceResp := model.TopInfoOnceResp{
// _ = model.TopInfoOnceResp{ // _ = model.TopInfoOnceResp{
Result: model.TopInfoOnceResult{ Result: model.TopInfoOnceRes{
NewAchievementCnt: 0, NewAchievementCnt: 0,
UnaccomplishedAchievementCnt: 0, UnaccomplishedAchievementCnt: 0,
LiveDailyRewardExist: false, LiveDailyRewardExist: false,
@@ -944,9 +944,9 @@ func GenApi2Data() {
} }
museumInfoResp := model.MuseumInfoResp{ museumInfoResp := model.MuseumInfoResp{
Result: model.MuseumInfoResult{ Result: model.MuseumInfoRes{
MuseumInfo: model.MuseumInfo{ MuseumInfo: model.Museum{
Parameter: model.MuseumInfoParameter{ Parameter: model.MuseumParameter{
Smile: smileBuf, Smile: smileBuf,
Pure: pureBuf, Pure: pureBuf,
Cool: coolBuf, Cool: coolBuf,
@@ -963,7 +963,7 @@ func GenApi2Data() {
// Final // Final
k, err := json.Marshal(respAll) k, err := json.Marshal(respAll)
CheckErr(err) CheckErr(err)
resp := model.Response{ resp := model.ApiResp{
ResponseData: k, ResponseData: k,
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
@@ -1121,7 +1121,7 @@ func GenApi3Data() {
// Final // Final
k, err := json.Marshal(respAll) k, err := json.Marshal(respAll)
CheckErr(err) CheckErr(err)
resp := model.Response{ resp := model.ApiResp{
ResponseData: k, ResponseData: k,
ReleaseInfo: []interface{}{}, ReleaseInfo: []interface{}{},
StatusCode: 200, StatusCode: 200,
-7
View File
@@ -15,13 +15,6 @@ func init() {
MainEng = config.MainEng MainEng = config.MainEng
UserEng = config.UserEng UserEng = config.UserEng
// GenApi1Data()
// GenApi2Data()
// GenApi3Data()
// LoadApi1Data("assets/api1.json")
// LoadApi2Data("assets/api2.json")
// LoadApi3Data("assets/api3.json")
// ListUnitData()
// go SyncNotesList() // go SyncNotesList()
// GenDownloadDb() // GenDownloadDb()
// GenCommonUnitData() // GenCommonUnitData()
-125
View File
@@ -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))
}
-60
View File
@@ -4,13 +4,9 @@
package utils package utils
import ( import (
"encoding/base64"
"encoding/hex" "encoding/hex"
"errors"
"math/rand" "math/rand"
"net/url"
"os" "os"
"strconv"
"time" "time"
) )
@@ -52,59 +48,3 @@ func RandomStr(len int) string {
return mRandStr 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
}
-257
View File
@@ -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...)
}
}