+14
-12
@@ -1,10 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -15,16 +14,22 @@ type AlbumRes struct {
|
||||
}
|
||||
|
||||
func AlbumSeriesAll(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
var albumIds []int
|
||||
err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
||||
utils.CheckErr(err)
|
||||
// fmt.Println(albumIds)
|
||||
err := ss.MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
albumSeriesAllRes := []model.AlbumSeriesRes{}
|
||||
for _, albumId := range albumIds {
|
||||
unitList := []AlbumRes{}
|
||||
err = MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
albumSeriesAll := []model.AlbumResult{}
|
||||
for _, unit := range unitList {
|
||||
@@ -70,14 +75,11 @@ func AlbumSeriesAll(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
albumResp := model.AlbumSeriesResp{
|
||||
resp := model.AlbumSeriesResp{
|
||||
ResponseData: albumSeriesAllRes,
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(albumResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/internal/session"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -21,7 +20,10 @@ func AnnounceIndex(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
func AnnounceCheckState(ctx *gin.Context) {
|
||||
announceResp := model.AnnounceResp{
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
resp := model.AnnounceResp{
|
||||
ResponseData: model.AnnounceRes{
|
||||
HasUnreadAnnounce: false,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
@@ -29,9 +31,6 @@ func AnnounceCheckState(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(announceResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
+254
-211
@@ -2,10 +2,10 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
@@ -39,16 +39,17 @@ type MuseumRes struct {
|
||||
}
|
||||
|
||||
func Api(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
apiReq := []model.ApiReq{}
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &apiReq)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
results := []any{}
|
||||
for _, v := range apiReq {
|
||||
var res []byte
|
||||
var err error
|
||||
// fmt.Println(v)
|
||||
// fmt.Println(v.Module, v.Action)
|
||||
|
||||
@@ -90,8 +91,7 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(topInfoResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, topInfoResp)
|
||||
case "topInfoOnce":
|
||||
// key = "login_topinfo_once_result"
|
||||
topInfoOnceResp := model.TopInfoOnceResp{
|
||||
@@ -122,8 +122,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(topInfoOnceResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, topInfoOnceResp)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "live":
|
||||
switch v.Action {
|
||||
@@ -131,8 +132,10 @@ func Api(ctx *gin.Context) {
|
||||
// key = "live_status_result"
|
||||
var liveDifficultyId []int
|
||||
normalLives := []model.NormalLiveStatusList{}
|
||||
err = MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyId {
|
||||
normalLive := model.NormalLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
@@ -146,8 +149,10 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
specialLives := []model.SpecialLiveStatusList{}
|
||||
err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyId {
|
||||
specialLive := model.SpecialLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
@@ -173,14 +178,15 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(LiveStatusResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, LiveStatusResp)
|
||||
case "schedule":
|
||||
// key = "live_list_result"
|
||||
var liveDifficultyId []int
|
||||
specialLives := []model.SpecialLiveStatusList{}
|
||||
err = MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for _, id := range liveDifficultyId {
|
||||
specialLive := model.SpecialLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
@@ -216,24 +222,24 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(liveListResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, liveListResp)
|
||||
default:
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "unit":
|
||||
if v.Action == "unitAll" {
|
||||
switch v.Action {
|
||||
case "unitAll":
|
||||
// key = "unit_list_result"
|
||||
unitsData := []model.Active{}
|
||||
err = MainEng.Table("common_unit_m").Find(&unitsData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
err = ss.MainEng.Table("common_unit_m").Find(&unitsData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
userUnits := []model.Active{}
|
||||
err = UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Find(&userUnits)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
err = ss.UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Find(&userUnits)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
unitsData = append(unitsData, userUnits...)
|
||||
|
||||
@@ -246,19 +252,22 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(unitListResp)
|
||||
utils.CheckErr(err)
|
||||
} else if v.Action == "deckInfo" {
|
||||
results = append(results, unitListResp)
|
||||
case "deckInfo":
|
||||
// key = "unit_deck_result"
|
||||
userDeck := []model.UserDeckData{}
|
||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck)
|
||||
utils.CheckErr(err)
|
||||
err = ss.UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
unitDeckInfo := []model.UnitDeckInfoRes{}
|
||||
for _, deck := range userDeck {
|
||||
deckUnit := []model.UnitDeckData{}
|
||||
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||
utils.CheckErr(err)
|
||||
err = ss.UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
oUids := []model.UnitOwningUserIds{}
|
||||
for _, unit := range deckUnit {
|
||||
@@ -285,9 +294,8 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(unitDeckResp)
|
||||
utils.CheckErr(err)
|
||||
} else if v.Action == "supporterAll" {
|
||||
results = append(results, unitDeckResp)
|
||||
case "supporterAll":
|
||||
// key = "unit_support_result"
|
||||
unitSupportResp := model.UnitSupportResp{
|
||||
Result: model.UnitSupportRes{
|
||||
@@ -297,18 +305,21 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(unitSupportResp)
|
||||
utils.CheckErr(err)
|
||||
} else if v.Action == "removableSkillInfo" {
|
||||
results = append(results, unitSupportResp)
|
||||
case "removableSkillInfo":
|
||||
// key = "owning_equip_result"
|
||||
var skillEquipCount []model.SkillEquipCount
|
||||
err := UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||
err := ss.UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||
GroupBy("unit_removable_skill_id").Find(&skillEquipCount)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var rmSkillIds []int
|
||||
err = MainEng.Table("unit_removable_skill_m").Where("effect_range = 1").Cols("unit_removable_skill_id").Find(&rmSkillIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("unit_removable_skill_m").Where("effect_range = 1").Cols("unit_removable_skill_id").Find(&rmSkillIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
owingInfo := []model.OwningInfo{}
|
||||
for _, id := range rmSkillIds {
|
||||
@@ -328,15 +339,19 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
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)
|
||||
utils.CheckErr(err)
|
||||
err = ss.UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Cols("unit_owning_user_id").GroupBy("unit_owning_user_id").Find(&unitOwningIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
equipInfo := map[int]any{}
|
||||
for _, v := range unitOwningIds {
|
||||
detail := []model.SkillEquipDetail{}
|
||||
err = UserEng.Table("skill_equip_m").Where("user_id = ? AND unit_owning_user_id = ?", ctx.GetString("userid"), v).
|
||||
err = ss.UserEng.Table("skill_equip_m").Where("user_id = ? AND unit_owning_user_id = ?", ctx.GetString("userid"), v).
|
||||
Cols("unit_removable_skill_id").Find(&detail)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
equipInfo[v] = model.SkillEquipList{
|
||||
UnitOwningUserID: v,
|
||||
@@ -353,13 +368,14 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(rmSkillResp)
|
||||
utils.CheckErr(err)
|
||||
} else if v.Action == "accessoryAll" {
|
||||
results = append(results, rmSkillResp)
|
||||
case "accessoryAll":
|
||||
// key = "unit_accessory_result"
|
||||
accessoryList := []model.AccessoryList{}
|
||||
err := MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||
utils.CheckErr(err)
|
||||
err := ss.MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
for k := range accessoryList {
|
||||
accessoryList[k].NextExp = 0
|
||||
accessoryList[k].Level = 8
|
||||
@@ -368,8 +384,10 @@ func Api(ctx *gin.Context) {
|
||||
accessoryList[k].FavoriteFlag = true
|
||||
}
|
||||
wearingInfo := []model.WearingInfo{}
|
||||
err = UserEng.Table("accessory_wear_m").Where("user_id = ?", ctx.GetString("userid")).Find(&wearingInfo)
|
||||
utils.CheckErr(err)
|
||||
err = ss.UserEng.Table("accessory_wear_m").Where("user_id = ?", ctx.GetString("userid")).Find(&wearingInfo)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
unitAccResp := model.UnitAccessoryAllResp{
|
||||
Result: model.UnitAccessoryAllResult{
|
||||
AccessoryList: accessoryList,
|
||||
@@ -380,12 +398,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(unitAccResp)
|
||||
utils.CheckErr(err)
|
||||
} else {
|
||||
// case "accessoryTab":
|
||||
// case "accessoryMaterialAll":
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
results = append(results, unitAccResp)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "costume":
|
||||
if v.Action == "costumeList" {
|
||||
@@ -398,18 +413,20 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(costumeListResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, costumeListResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "album":
|
||||
if v.Action == "albumAll" {
|
||||
// key = "album_unit_result"
|
||||
albumLists := []model.AlbumResult{}
|
||||
unitList := []AlbumRes{}
|
||||
err = MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, unit := range unitList {
|
||||
albumList := model.AlbumResult{
|
||||
RankMaxFlag: true,
|
||||
@@ -451,18 +468,20 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(albumResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, albumResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "scenario":
|
||||
if v.Action == "scenarioStatus" {
|
||||
// key = "scenario_status_result"
|
||||
var scenarioIds []int
|
||||
scenarioLists := []model.ScenarioStatusList{}
|
||||
err = MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range scenarioIds {
|
||||
scenarioLists = append(scenarioLists, model.ScenarioStatusList{
|
||||
ScenarioID: id,
|
||||
@@ -477,18 +496,20 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(scenarioResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, scenarioResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "subscenario":
|
||||
if v.Action == "subscenarioStatus" {
|
||||
// key = "subscenario_status_result"
|
||||
var subScenarioIds []int
|
||||
subScenarioLists := []model.SubscenarioStatusList{}
|
||||
err = MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range subScenarioIds {
|
||||
subScenarioLists = append(subScenarioLists, model.SubscenarioStatusList{
|
||||
SubscenarioID: id,
|
||||
@@ -504,24 +525,29 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(subScenarioResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, subScenarioResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "eventscenario":
|
||||
if v.Action == "status" {
|
||||
// key = "event_scenario_result"
|
||||
var eventIds []int
|
||||
eventsList := []model.EventScenarioList{}
|
||||
err = MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range eventIds {
|
||||
eventRes := []EventRes{}
|
||||
chapsList := []model.EventScenarioChapterList{}
|
||||
err = MainEng.Table("event_scenario_m").Where("event_id = ?", id).Cols("event_scenario_id,chapter,chapter_asset,open_date").
|
||||
err = ss.MainEng.Table("event_scenario_m").Where("event_id = ?", id).Cols("event_scenario_id,chapter,chapter_asset,open_date").
|
||||
OrderBy("chapter DESC").Find(&eventRes)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, res := range eventRes {
|
||||
chapList := model.EventScenarioChapterList{
|
||||
EventScenarioID: res.EventScenarioId,
|
||||
@@ -563,25 +589,29 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(eventScenarioResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, eventScenarioResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "multiunit":
|
||||
if v.Action == "multiunitscenarioStatus" {
|
||||
// key = "multi_unit_scenario_result"
|
||||
var multiIds []int
|
||||
multiUnitsList := []model.MultiUnitScenarioStatusList{}
|
||||
err = MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range multiIds {
|
||||
multiRes := MultiRes{}
|
||||
_, err = MainEng.Table("multi_unit_scenario_m").
|
||||
_, err = ss.MainEng.Table("multi_unit_scenario_m").
|
||||
Join("LEFT", "multi_unit_scenario_open_m", "multi_unit_scenario_m.multi_unit_id = multi_unit_scenario_open_m.multi_unit_id").
|
||||
Cols("multi_unit_scenario_btn_asset,open_date,multi_unit_scenario_id,chapter").
|
||||
Where("multi_unit_scenario_m.multi_unit_id = ?", id).Get(&multiRes)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{
|
||||
MultiUnitID: id,
|
||||
@@ -606,10 +636,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(unitsResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, unitsResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "payment":
|
||||
if v.Action == "productList" {
|
||||
@@ -634,10 +663,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(productResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, productResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "banner":
|
||||
if v.Action == "bannerList" {
|
||||
@@ -707,10 +735,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(bannerResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, bannerResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "notice":
|
||||
if v.Action == "noticeMarquee" {
|
||||
@@ -724,18 +751,20 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(marqueeResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, marqueeResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "user":
|
||||
switch v.Action {
|
||||
case "getNavi":
|
||||
// key = "user_intro_result"
|
||||
var uId, oId int
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_id,unit_owning_user_id").Get(&uId, &oId)
|
||||
utils.CheckErr(err)
|
||||
_, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_id,unit_owning_user_id").Get(&uId, &oId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
userIntroResp := model.UserNaviResp{
|
||||
Result: model.UserNaviRes{
|
||||
User: model.User{
|
||||
@@ -747,15 +776,18 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(userIntroResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, userIntroResp)
|
||||
case "userInfo":
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
pref := tools.UserPref{}
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
@@ -796,10 +828,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(userInfoResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, userInfoResp)
|
||||
default:
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "navigation":
|
||||
if v.Action == "specialCutin" {
|
||||
@@ -812,20 +843,24 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(cutinResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, cutinResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "award":
|
||||
if v.Action == "awardInfo" {
|
||||
// key = "award_result"
|
||||
var aIdList []int
|
||||
err := MainEng.Table("award_m").Cols("award_id").Find(&aIdList)
|
||||
utils.CheckErr(err)
|
||||
err := ss.MainEng.Table("award_m").Cols("award_id").Find(&aIdList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var aId int
|
||||
_, err = UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("award_id").Get(&aId)
|
||||
utils.CheckErr(err)
|
||||
_, err = ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("award_id").Get(&aId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
awardsList := []model.AwardInfo{}
|
||||
for _, id := range aIdList {
|
||||
@@ -848,20 +883,24 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(awardResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, awardResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "background":
|
||||
if v.Action == "backgroundInfo" {
|
||||
// key = "background_result"
|
||||
var bIdList []int
|
||||
err := MainEng.Table("background_m").Cols("background_id").Find(&bIdList)
|
||||
utils.CheckErr(err)
|
||||
err := ss.MainEng.Table("background_m").Cols("background_id").Find(&bIdList)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var bId int
|
||||
_, err = UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("background_id").Get(&bId)
|
||||
utils.CheckErr(err)
|
||||
_, err = ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("background_id").Get(&bId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
backgroundsList := []model.BackgroundInfo{}
|
||||
for _, id := range bIdList {
|
||||
@@ -884,10 +923,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(backgroundResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, backgroundResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "stamp":
|
||||
if v.Action == "stampInfo" {
|
||||
@@ -895,19 +933,23 @@ func Api(ctx *gin.Context) {
|
||||
stampResp := honokautils.ReadAllText("assets/serverdata/stamp.json")
|
||||
var mStampResp any
|
||||
err = json.Unmarshal([]byte(stampResp), &mStampResp)
|
||||
utils.CheckErr(err)
|
||||
res, err = json.Marshal(mStampResp)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
results = append(results, mStampResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "exchange":
|
||||
if v.Action == "owningPoint" {
|
||||
// key = "exchange_point_result"
|
||||
var exchangeIds []int
|
||||
exPointsList := []model.ExchangePointList{}
|
||||
err = MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeIds)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeIds)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range exchangeIds {
|
||||
exPointsList = append(exPointsList, model.ExchangePointList{
|
||||
Rarity: id,
|
||||
@@ -922,10 +964,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(exPointsResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, exPointsResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "livese":
|
||||
if v.Action == "liveseInfo" {
|
||||
@@ -938,10 +979,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(liveSeResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, liveSeResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "liveicon":
|
||||
if v.Action == "liveiconInfo" {
|
||||
@@ -954,10 +994,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(liveIconResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, liveIconResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "item":
|
||||
if v.Action == "list" {
|
||||
@@ -965,11 +1004,12 @@ func Api(ctx *gin.Context) {
|
||||
itemResp := honokautils.ReadAllText("assets/serverdata/item.json")
|
||||
var mItemResp any
|
||||
err = json.Unmarshal([]byte(itemResp), &mItemResp)
|
||||
utils.CheckErr(err)
|
||||
res, err = json.Marshal(mItemResp)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
results = append(results, mItemResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "marathon":
|
||||
if v.Action == "marathonInfo" {
|
||||
@@ -980,10 +1020,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(marathonResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, marathonResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "challenge":
|
||||
if v.Action == "challengeInfo" {
|
||||
@@ -994,10 +1033,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(challengeResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, challengeResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "museum":
|
||||
if v.Action == "info" {
|
||||
@@ -1005,9 +1043,12 @@ func Api(ctx *gin.Context) {
|
||||
museumRes := []MuseumRes{}
|
||||
var museumIds []int
|
||||
var smileBuff, pureBuff, coolBuff int
|
||||
err = MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").
|
||||
err = ss.MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").
|
||||
OrderBy("museum_contents_id ASC").Find(&museumRes)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, res := range museumRes {
|
||||
smileBuff += res.SmileBuff
|
||||
pureBuff += res.PureBuff
|
||||
@@ -1029,10 +1070,9 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(museumInfoResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, museumInfoResp)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
case "profile":
|
||||
switch v.Action {
|
||||
@@ -1065,45 +1105,57 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(difficultyResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, difficultyResp)
|
||||
case "cardRanking":
|
||||
// key = "profile_card_ranking_result"
|
||||
var result []any
|
||||
love := honokautils.ReadAllText("assets/serverdata/love.json")
|
||||
err := json.Unmarshal([]byte(love), &result)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
loveResp := model.LoveResp{
|
||||
Result: result,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(loveResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, loveResp)
|
||||
case "profileInfo":
|
||||
// key = "profile_info_result"
|
||||
pref := tools.UserPref{}
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Get(&pref)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Get(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
commonUnit, err := MainEng.Table("common_unit_m").Count()
|
||||
utils.CheckErr(err)
|
||||
userUnit, err := UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Count()
|
||||
utils.CheckErr(err)
|
||||
commonUnit, err := ss.MainEng.Table("common_unit_m").Count()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
userUnit, err := ss.UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Count()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
unitData := model.UnitData{}
|
||||
exists, err = MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
||||
utils.CheckErr(err)
|
||||
exists, err = ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
isCommon := true
|
||||
if !exists {
|
||||
_, err = UserEng.Table("user_unit_m").
|
||||
_, err = ss.UserEng.Table("user_unit_m").
|
||||
Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ctx.GetString("userid")).Get(&unitData)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
isCommon = false
|
||||
}
|
||||
|
||||
@@ -1111,7 +1163,7 @@ func Api(ctx *gin.Context) {
|
||||
var smileMax, pureMax, coolMax int
|
||||
if isCommon {
|
||||
// 公共卡片仅为100级属性
|
||||
_, err = MainEng.Table("unit_m").Where("unit_id = ?", unitData.UnitID).
|
||||
_, err = ss.MainEng.Table("unit_m").Where("unit_id = ?", unitData.UnitID).
|
||||
Cols("attribute_id,hp_max,smile_max,pure_max,cool_max").Get(&attrId, &maxHp, &baseSmile, &basePure, &baseCool)
|
||||
utils.CheckErr(err)
|
||||
|
||||
@@ -1125,12 +1177,16 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
var accessoryOwningId, accessoryId, exp int
|
||||
_, err = UserEng.Table("accessory_wear_m").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ctx.GetString("userid")).
|
||||
_, err = ss.UserEng.Table("accessory_wear_m").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ctx.GetString("userid")).
|
||||
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
||||
utils.CheckErr(err)
|
||||
_, err = MainEng.Table("common_accessory_m").Where("accessory_owning_user_id = ?", accessoryOwningId).
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
_, err = ss.MainEng.Table("common_accessory_m").Where("accessory_owning_user_id = ?", accessoryOwningId).
|
||||
Cols("accessory_id,exp").Get(&accessoryId, &exp)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
accessoryInfo := model.AccessoryInfo{
|
||||
AccessoryOwningUserID: accessoryOwningId,
|
||||
AccessoryID: accessoryId,
|
||||
@@ -1143,12 +1199,17 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
removeSkillIds := []int{}
|
||||
err = UserEng.Table("skill_equip_m").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ctx.GetString("userid")).
|
||||
err = ss.UserEng.Table("skill_equip_m").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ctx.GetString("userid")).
|
||||
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
userId, err := strconv.Atoi(config.Conf.UserPrefs.InviteCode)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
profileResp := model.ProfileResp{
|
||||
Result: model.ProfileRes{
|
||||
UserInfo: model.ProfileUserInfo{
|
||||
@@ -1240,42 +1301,24 @@ func Api(ctx *gin.Context) {
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(profileResp)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, profileResp)
|
||||
default:
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "secretbox":
|
||||
if v.Action == "all" {
|
||||
res = []byte(honokautils.ReadAllText("111.json"))
|
||||
// fmt.Println(apiReq)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module+":"+v.Action)
|
||||
}
|
||||
default:
|
||||
// fmt.Println(ErrorMsg)
|
||||
// fmt.Println(v)
|
||||
err = errors.New("invalid option")
|
||||
utils.CheckErr(err)
|
||||
err = fmt.Errorf("unimplemented: %s", v.Module)
|
||||
}
|
||||
|
||||
var result any
|
||||
err = json.Unmarshal([]byte(res), &result)
|
||||
utils.CheckErr(err)
|
||||
results = append(results, result)
|
||||
}
|
||||
// fmt.Println(results)
|
||||
b, err := json.Marshal(results)
|
||||
utils.CheckErr(err)
|
||||
rp := model.ApiResp{
|
||||
ResponseData: b,
|
||||
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
apiResp := model.ApiResp{
|
||||
ResponseData: results,
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
b, err = json.Marshal(rp)
|
||||
utils.CheckErr(err)
|
||||
// fmt.Println(string(b))
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(b))
|
||||
ctx.String(http.StatusOK, string(b))
|
||||
ss.Respond(apiResp)
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func AwardSet(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
pref := tools.UserPref{
|
||||
AwardID: int(req.Get("award_id").Int()),
|
||||
}
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
utils.CheckErr(err)
|
||||
|
||||
_, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
awardResp := model.AwardSetResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(awardResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(awardResp)
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func BackgroundSet(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
pref := tools.UserPref{
|
||||
BackgroundID: int(req.Get("background_id").Int()),
|
||||
}
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
utils.CheckErr(err)
|
||||
|
||||
_, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
backgroundResp := model.BackgroundSetResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(backgroundResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(backgroundResp)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/internal/session"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -21,18 +21,25 @@ type PkgInfo struct {
|
||||
}
|
||||
|
||||
func DownloadAdditional(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
downloadReq := model.AdditionalReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
pkgList := []model.AdditionalRes{}
|
||||
if SifCdnServer != "" {
|
||||
pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID
|
||||
var pkgInfo []PkgInfo
|
||||
err := MainEng.Table("download_m").Where("pkg_type = ? AND pkg_id = ? AND pkg_os = ?", pkgType, pkgId, downloadReq.TargetOs).
|
||||
err := ss.MainEng.Table("download_m").Where("pkg_type = ? AND pkg_id = ? AND pkg_os = ?", pkgType, pkgId, downloadReq.TargetOs).
|
||||
Cols("pkg_id,pkg_order,pkg_size").
|
||||
OrderBy("pkg_id ASC, pkg_order ASC").Find(&pkgInfo)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, pkg := range pkgInfo {
|
||||
pkgList = append(pkgList, model.AdditionalRes{
|
||||
@@ -47,26 +54,30 @@ func DownloadAdditional(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(addResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(addResp)
|
||||
}
|
||||
|
||||
func DownloadBatch(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
downloadReq := model.BatchReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
pkgList := []model.BatchRes{}
|
||||
if downloadReq.ClientVersion == config.PackageVersion && SifCdnServer != "" {
|
||||
pkgType := downloadReq.PackageType
|
||||
var pkgInfo []PkgInfo
|
||||
err := MainEng.Table("download_m").Where(builder.NotIn("pkg_id", downloadReq.ExcludedPackageIds)).Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.Os).
|
||||
err := ss.MainEng.Table("download_m").Where(builder.NotIn("pkg_id", downloadReq.ExcludedPackageIds)).Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.Os).
|
||||
Cols("pkg_id,pkg_order,pkg_size").
|
||||
OrderBy("pkg_id ASC, pkg_order ASC").Find(&pkgInfo)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, pkg := range pkgInfo {
|
||||
pkgList = append(pkgList, model.BatchRes{
|
||||
@@ -81,26 +92,30 @@ func DownloadBatch(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(batchResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(batchResp)
|
||||
}
|
||||
|
||||
func DownloadUpdate(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
downloadReq := model.UpdateReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
pkgList := []model.UpdateRes{}
|
||||
if downloadReq.ExternalVersion != config.PackageVersion && SifCdnServer != "" {
|
||||
pkgType := 99
|
||||
var pkgInfo []PkgInfo
|
||||
err := MainEng.Table("download_m").Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.TargetOs).
|
||||
err := ss.MainEng.Table("download_m").Where("pkg_type = ? AND pkg_os = ?", pkgType, downloadReq.TargetOs).
|
||||
Cols("pkg_id,pkg_order,pkg_size").
|
||||
OrderBy("pkg_id ASC, pkg_order ASC").Find(&pkgInfo)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, pkg := range pkgInfo {
|
||||
pkgList = append(pkgList, model.UpdateRes{
|
||||
@@ -130,20 +145,22 @@ func DownloadUpdate(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(updateResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(updateResp)
|
||||
}
|
||||
|
||||
func DownloadUrl(ctx *gin.Context) {
|
||||
// Extract SQL: SELECT CAST(pkg_type AS TEXT) || '_' || CAST(pkg_id AS TEXT) || '_' || CAST(pkg_order AS TEXT) || '.zip' AS zip_name FROM download_m ORDER BY pkg_type ASC,pkg_id ASC, pkg_order ASC;
|
||||
// Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
downloadReq := model.UrlReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &downloadReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
urlList := []string{}
|
||||
for _, v := range downloadReq.PathList {
|
||||
urlList = append(urlList, fmt.Sprintf("%s/%s/extracted/%s", SifCdnServer, downloadReq.Os, strings.ReplaceAll(v, "\\", "")))
|
||||
@@ -155,22 +172,19 @@ func DownloadUrl(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(urlResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(urlResp)
|
||||
}
|
||||
|
||||
func DownloadEvent(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
eventResp := model.EventResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(eventResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(eventResp)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func EventList(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
targets := []model.TargetList{}
|
||||
for i := 0; i < 6; i++ {
|
||||
for i := range 6 {
|
||||
targets = append(targets, model.TargetList{
|
||||
Position: i + 1,
|
||||
IsDisplayable: false,
|
||||
@@ -26,9 +27,6 @@ func EventList(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(eventsResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(eventsResp)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Gdpr(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
gdprResp := model.GdprResp{
|
||||
ResponseData: model.GdprRes{
|
||||
EnableGdpr: true,
|
||||
@@ -20,9 +21,6 @@ func Gdpr(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(gdprResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(gdprResp)
|
||||
}
|
||||
|
||||
@@ -2,22 +2,13 @@ package handler
|
||||
|
||||
import (
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/pkg/db"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
var (
|
||||
SifCdnServer string
|
||||
AsCdnServer string
|
||||
ErrorMsg = `{"code":20001,"message":""}`
|
||||
MainEng *xorm.Engine
|
||||
UserEng *xorm.Engine
|
||||
)
|
||||
|
||||
func init() {
|
||||
SifCdnServer = config.Conf.Settings.SifCdnServer
|
||||
|
||||
MainEng = db.MainEng
|
||||
UserEng = db.UserEng
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func LBonusExecute(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
weeks := map[string]int{
|
||||
"Monday": 1,
|
||||
"Tuesday": 2,
|
||||
@@ -148,9 +149,5 @@ func LBonusExecute(ctx *gin.Context) {
|
||||
StatusCode: 200,
|
||||
}
|
||||
|
||||
resp, err := json.Marshal(LbRes)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(LbRes)
|
||||
}
|
||||
|
||||
+149
-80
@@ -2,13 +2,13 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/pkg/db"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -17,34 +17,52 @@ import (
|
||||
)
|
||||
|
||||
func PartyList(ctx *gin.Context) {
|
||||
resp := honokautils.ReadAllText("assets/serverdata/partylist.json")
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
data := honokautils.ReadAllText("assets/serverdata/partylist.json")
|
||||
var partyResp map[string]any
|
||||
err := json.Unmarshal([]byte(data), &partyResp)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(partyResp)
|
||||
}
|
||||
|
||||
func PlayLive(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
playReq := model.PlayReq{}
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
tDifficultyId := playReq.LiveDifficultyID
|
||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
deckId := playReq.UnitDeckID
|
||||
|
||||
// Save Deck Id for /live/reward
|
||||
key := "live_deck_" + ctx.GetString("userid")
|
||||
err = db.DB.Set([]byte(key), []byte(strconv.Itoa(deckId)))
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// Song type: normal / special
|
||||
// sqlite3 doesn't support FULL OUTER JOIN so use UNION ALL here.
|
||||
sql := `SELECT notes_setting_asset,c_rank_score,b_rank_score,a_rank_score,s_rank_score,ac_flag,swing_flag FROM live_setting_m WHERE live_setting_id IN (SELECT live_setting_id FROM normal_live_m WHERE live_difficulty_id = ? UNION ALL SELECT live_setting_id FROM special_live_m WHERE live_difficulty_id = ?)`
|
||||
var notes_setting_asset string
|
||||
var c_rank_score, b_rank_score, a_rank_score, s_rank_score, ac_flag, swing_flag int
|
||||
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(¬es_setting_asset, &c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &ac_flag, &swing_flag)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(¬es_setting_asset, &c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &ac_flag, &swing_flag)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// fmt.Println(notes_setting_asset)
|
||||
// fmt.Println(c_rank_score, b_rank_score, a_rank_score, s_rank_score)
|
||||
@@ -53,7 +71,9 @@ func PlayLive(ctx *gin.Context) {
|
||||
// fmt.Println("./assets/notes/" + notes_setting_asset)
|
||||
notes_list := honokautils.ReadAllText("./assets/serverdata/notes/" + notes_setting_asset)
|
||||
err = json.Unmarshal([]byte(notes_list), ¬es)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ranks := []model.RankInfo{}
|
||||
ranks = append(ranks, model.RankInfo{
|
||||
@@ -78,69 +98,88 @@ func PlayLive(ctx *gin.Context) {
|
||||
RankMax: 0,
|
||||
})
|
||||
|
||||
// UserEng.ShowSQL(true)
|
||||
// MainEng.ShowSQL(true)
|
||||
// ss.UserEng.ShowSQL(true)
|
||||
// ss.MainEng.ShowSQL(true)
|
||||
owningIdList := []int{}
|
||||
err = UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
err = ss.UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
Where("user_id = ? AND deck_id = ?", ctx.GetString("userid"), deckId).Cols("unit_owning_user_id").
|
||||
OrderBy("deck_unit_m.position ASC").Find(&owningIdList)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
unitList := []model.UnitList{}
|
||||
var totalSmile, totalPure, totalCool, maxLove float64
|
||||
var totalHp int
|
||||
for _, owningId := range owningIdList {
|
||||
var uId int
|
||||
exists, err := MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var maxHp, attrId, unitTypeId int
|
||||
var baseSmile, basePure, baseCool, smileMax, pureMax, coolMax float64
|
||||
if exists {
|
||||
// 公共卡片仅为100级属性
|
||||
_, err = MainEng.Table("unit_m").Where("unit_id = ?", uId).
|
||||
_, err = ss.MainEng.Table("unit_m").Where("unit_id = ?", uId).
|
||||
Join("LEFT", "unit_rarity_m", "unit_m.rarity = unit_rarity_m.rarity").
|
||||
Cols("attribute_id,hp_max,smile_max,pure_max,cool_max,after_love_max,unit_type_id").
|
||||
Get(&attrId, &maxHp, &baseSmile, &basePure, &baseCool, &maxLove, &unitTypeId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 用户卡片暂时固定为满级350级
|
||||
exists, err := UserEng.Table("user_unit_m").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_unit_m").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
if exists {
|
||||
// 卡片100级基础属性
|
||||
_, err = MainEng.Table("unit_m").Where("unit_id = ?", uId).
|
||||
_, err = ss.MainEng.Table("unit_m").Where("unit_id = ?", uId).
|
||||
Join("LEFT", "unit_rarity_m", "unit_m.rarity = unit_rarity_m.rarity").
|
||||
Cols("attribute_id,hp_max,smile_max,pure_max,cool_max,after_love_max,unit_type_id").
|
||||
Get(&attrId, &maxHp, &baseSmile, &basePure, &baseCool, &maxLove, &unitTypeId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 增量属性
|
||||
var diffSmile, diffPure, diffCool float64
|
||||
_, err = MainEng.Table("unit_level_limit_pattern_m").Where("unit_level_limit_id = 1 AND unit_level = 350").
|
||||
_, err = ss.MainEng.Table("unit_level_limit_pattern_m").Where("unit_level_limit_id = 1 AND unit_level = 350").
|
||||
Cols("smile_diff,pure_diff,cool_diff").Get(&diffSmile, &diffPure, &diffCool)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 更新卡片属性(注意这里是负数,要用减号)
|
||||
baseSmile -= diffSmile
|
||||
basePure -= diffPure
|
||||
baseCool -= diffCool
|
||||
} else {
|
||||
panic("no such unit")
|
||||
err = fmt.Errorf("no such unit owning id: %d", owningId)
|
||||
}
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 饰品属性加成(满级)
|
||||
var accessoryOwningId int
|
||||
_, err = UserEng.Table("accessory_wear_m").Where("unit_owning_user_id = ?", owningId).
|
||||
_, err = ss.UserEng.Table("accessory_wear_m").Where("unit_owning_user_id = ?", owningId).
|
||||
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
var smileAccessory, pureAccessory, coolAccessory float64
|
||||
_, err = MainEng.Table("common_accessory_m").Join("LEFT", "accessory_m", "common_accessory_m.accessory_id = accessory_m.accessory_id").
|
||||
_, err = ss.MainEng.Table("common_accessory_m").Join("LEFT", "accessory_m", "common_accessory_m.accessory_id = accessory_m.accessory_id").
|
||||
Where("accessory_owning_user_id = ?", accessoryOwningId).Cols("smile_max,pure_max,cool_max").
|
||||
Get(&smileAccessory, &pureAccessory, &coolAccessory)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
// fmt.Println("基础属性:", baseSmile, basePure, baseCool)
|
||||
|
||||
// 饰品属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
||||
@@ -152,8 +191,10 @@ func PlayLive(ctx *gin.Context) {
|
||||
|
||||
// 回忆画廊属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
||||
var smileBuff, pureBuff, coolBuff float64
|
||||
_, err = MainEng.Table("museum_contents_m").Select("SUM(smile_buff),SUM(pure_buff),SUM(cool_buff)").Get(&smileBuff, &pureBuff, &coolBuff)
|
||||
utils.CheckErr(err)
|
||||
_, err = ss.MainEng.Table("museum_contents_m").Select("SUM(smile_buff),SUM(pure_buff),SUM(cool_buff)").Get(&smileBuff, &pureBuff, &coolBuff)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
baseSmile += smileBuff
|
||||
basePure += pureBuff
|
||||
baseCool += coolBuff
|
||||
@@ -180,18 +221,22 @@ func PlayLive(ctx *gin.Context) {
|
||||
|
||||
// 宝石加成(满级)
|
||||
removableSkillIds := []int{}
|
||||
err = UserEng.Table("skill_equip_m").Where("unit_owning_user_id = ? AND user_id = ?", owningId, ctx.GetString("userid")).
|
||||
err = ss.UserEng.Table("skill_equip_m").Where("unit_owning_user_id = ? AND user_id = ?", owningId, ctx.GetString("userid")).
|
||||
Cols("unit_removable_skill_id").Find(&removableSkillIds)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, sk := range removableSkillIds {
|
||||
// 判断宝石效果类型(效果范围、效果类型、效果值、是否固定数值)
|
||||
var effectRange, effectType, fixedValueFlag, refType int
|
||||
var effectValue float64
|
||||
_, err = MainEng.Table("unit_removable_skill_m").Where("unit_removable_skill_id = ?", sk).
|
||||
_, err = ss.MainEng.Table("unit_removable_skill_m").Where("unit_removable_skill_id = ?", sk).
|
||||
Cols("effect_range,effect_type,effect_value,fixed_value_flag,target_reference_type").
|
||||
Get(&effectRange, &effectType, &effectValue, &fixedValueFlag, &refType)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
if fixedValueFlag == 1 {
|
||||
// 吻、眼神属性加成(固定数值)
|
||||
@@ -244,19 +289,23 @@ func PlayLive(ctx *gin.Context) {
|
||||
|
||||
// 主唱技能加成
|
||||
var myCenterUnitId int
|
||||
_, err = UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
_, err = ss.UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
Where("user_deck_m.deck_id = ? AND user_deck_m.user_id = ? AND deck_unit_m.position = 5", playReq.UnitDeckID, ctx.GetString("userid")).
|
||||
Cols("deck_unit_m.unit_id").Get(&myCenterUnitId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 主唱技能加成:主C技能(这里不使用新C技能,即以某属性的百分比提升另一属性)
|
||||
var myAttrId int
|
||||
var myEffectValue float64
|
||||
_, err = MainEng.Table("unit_m").
|
||||
_, err = ss.MainEng.Table("unit_m").
|
||||
Join("LEFT", "unit_leader_skill_m", "unit_m.default_leader_skill_id = unit_leader_skill_m.unit_leader_skill_id").
|
||||
Where("unit_m.unit_id = ?", myCenterUnitId).
|
||||
Cols("unit_m.attribute_id,unit_leader_skill_m.effect_value").Get(&myAttrId, &myEffectValue)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
var myCenterSmile, myCenterPure, myCenterCool float64
|
||||
switch myAttrId {
|
||||
case 1:
|
||||
@@ -271,15 +320,19 @@ func PlayLive(ctx *gin.Context) {
|
||||
// 主唱技能加成:副C技能
|
||||
var mySubEffectValue float64
|
||||
var myMemberTagId int
|
||||
_, err = MainEng.Table("unit_m").
|
||||
_, err = ss.MainEng.Table("unit_m").
|
||||
Join("LEFT", "unit_leader_skill_extra_m", "unit_m.default_leader_skill_id = unit_leader_skill_extra_m.unit_leader_skill_id").
|
||||
Where("unit_m.unit_id = ?", myCenterUnitId).
|
||||
Cols("unit_leader_skill_extra_m.effect_value,unit_leader_skill_extra_m.member_tag_id").Get(&mySubEffectValue, &myMemberTagId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
exists, err = MainEng.Table("unit_type_member_tag_m").
|
||||
exists, err = ss.MainEng.Table("unit_type_member_tag_m").
|
||||
Where("unit_type_id = ? AND member_tag_id = ?", unitTypeId, myMemberTagId).Exist()
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
var mySubSmile, mySubPure, mySubCool float64
|
||||
if exists {
|
||||
switch myAttrId {
|
||||
@@ -309,11 +362,13 @@ func PlayLive(ctx *gin.Context) {
|
||||
// 好友主唱技能加成:主C技能(这里不使用新C技能,即以某属性的百分比提升另一属性)
|
||||
var tomoAttrId int
|
||||
var tomoEffectValue float64
|
||||
_, err = MainEng.Table("unit_m").
|
||||
_, err = ss.MainEng.Table("unit_m").
|
||||
Join("LEFT", "unit_leader_skill_m", "unit_m.default_leader_skill_id = unit_leader_skill_m.unit_leader_skill_id").
|
||||
Where("unit_m.unit_id = ?", tomoUnitId).
|
||||
Cols("unit_m.attribute_id,unit_leader_skill_m.effect_value").Get(&tomoAttrId, &tomoEffectValue)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
var tomoCenterSmile, tomoCenterPure, tomoCenterCool float64
|
||||
switch myAttrId {
|
||||
case 1:
|
||||
@@ -328,15 +383,19 @@ func PlayLive(ctx *gin.Context) {
|
||||
// 好友主唱技能加成:副C技能
|
||||
var tomoSubEffectValue float64
|
||||
var tomoMemberTagId int
|
||||
_, err = MainEng.Table("unit_m").
|
||||
_, err = ss.MainEng.Table("unit_m").
|
||||
Join("LEFT", "unit_leader_skill_extra_m", "unit_m.default_leader_skill_id = unit_leader_skill_extra_m.unit_leader_skill_id").
|
||||
Where("unit_m.unit_id = ?", tomoUnitId).
|
||||
Cols("unit_leader_skill_extra_m.effect_value,unit_leader_skill_extra_m.member_tag_id").Get(&tomoSubEffectValue, &tomoMemberTagId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
exists, err = MainEng.Table("unit_type_member_tag_m").
|
||||
exists, err = ss.MainEng.Table("unit_type_member_tag_m").
|
||||
Where("unit_type_id = ? AND member_tag_id = ?", unitTypeId, tomoMemberTagId).Exist()
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
var tomoSubSmile, tomoSubPure, tomoSubCool float64
|
||||
if exists {
|
||||
switch myAttrId {
|
||||
@@ -412,42 +471,47 @@ func PlayLive(ctx *gin.Context) {
|
||||
StatusCode: 200,
|
||||
}
|
||||
|
||||
resp, err := json.Marshal(playResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(playResp)
|
||||
}
|
||||
|
||||
func GameOver(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
overResp := model.GameOverResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(overResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(overResp)
|
||||
}
|
||||
|
||||
func PlayScore(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
playScoreReq := model.PlayScoreReq{}
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playScoreReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
tDifficultyId := playScoreReq.LiveDifficultyID
|
||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// Song type: normal / special
|
||||
// sqlite3 doesn't support FULL OUTER JOIN so use UNION ALL here.
|
||||
sql := `SELECT notes_setting_asset,c_rank_score,b_rank_score,a_rank_score,s_rank_score,ac_flag,swing_flag FROM live_setting_m WHERE live_setting_id IN (SELECT live_setting_id FROM normal_live_m WHERE live_difficulty_id = ? UNION ALL SELECT live_setting_id FROM special_live_m WHERE live_difficulty_id = ?)`
|
||||
var notes_setting_asset string
|
||||
var c_rank_score, b_rank_score, a_rank_score, s_rank_score, ac_flag, swing_flag int
|
||||
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(¬es_setting_asset, &c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &ac_flag, &swing_flag)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(¬es_setting_asset, &c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &ac_flag, &swing_flag)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// fmt.Println(notes_setting_asset)
|
||||
// fmt.Println(c_rank_score, b_rank_score, a_rank_score, s_rank_score)
|
||||
@@ -456,7 +520,9 @@ func PlayScore(ctx *gin.Context) {
|
||||
// fmt.Println("./assets/notes/" + notes_setting_asset)
|
||||
notes_list := honokautils.ReadAllText("./assets/serverdata/notes/" + notes_setting_asset)
|
||||
err = json.Unmarshal([]byte(notes_list), ¬es)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ranks := []model.RankInfo{}
|
||||
ranks = append(ranks, model.RankInfo{
|
||||
@@ -511,17 +577,18 @@ func PlayScore(ctx *gin.Context) {
|
||||
StatusCode: 200,
|
||||
}
|
||||
|
||||
resp, err := json.Marshal(playResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(playResp)
|
||||
}
|
||||
|
||||
func PlayReward(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
playRewardReq := model.PlayRewardReq{}
|
||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &playRewardReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
difficultyId := playRewardReq.LiveDifficultyID
|
||||
|
||||
@@ -529,16 +596,22 @@ func PlayReward(ctx *gin.Context) {
|
||||
// sqlite3 doesn't support FULL OUTER JOIN so use UNION ALL here.
|
||||
sql := `SELECT c_rank_score,b_rank_score,a_rank_score,s_rank_score,c_rank_combo,b_rank_combo,a_rank_combo,s_rank_combo,ac_flag,swing_flag FROM live_setting_m WHERE live_setting_id IN (SELECT live_setting_id FROM normal_live_m WHERE live_difficulty_id = ? UNION ALL SELECT live_setting_id FROM special_live_m WHERE live_difficulty_id = ?)`
|
||||
var c_rank_score, b_rank_score, a_rank_score, s_rank_score, c_rank_combo, b_rank_combo, a_rank_combo, s_rank_combo, ac_flag, swing_flag int
|
||||
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(&c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &c_rank_combo, &b_rank_combo, &a_rank_combo, &s_rank_combo, &ac_flag, &swing_flag)
|
||||
utils.CheckErr(err)
|
||||
err = ss.MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(&c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &c_rank_combo, &b_rank_combo, &a_rank_combo, &s_rank_combo, &ac_flag, &swing_flag)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
key := "live_deck_" + ctx.GetString("userid")
|
||||
deckId, err := db.DB.Get([]byte(key))
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
unitsList := []model.PlayRewardUnitList{}
|
||||
err = UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
err = ss.UserEng.Table("deck_unit_m").Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
Where("user_id = ? AND deck_id = ?", ctx.GetString("userid"), string(deckId)).Find(&unitsList)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
||||
playResp := model.RewardResp{
|
||||
@@ -692,9 +765,5 @@ func PlayReward(ctx *gin.Context) {
|
||||
playResp.ResponseData.Rank = 5
|
||||
}
|
||||
|
||||
resp, err := json.Marshal(playResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(playResp)
|
||||
}
|
||||
|
||||
+16
-14
@@ -1,11 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/pkg/db"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -13,6 +11,9 @@ import (
|
||||
)
|
||||
|
||||
func AuthKey(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
authResp := model.AuthKeyResp{
|
||||
ResponseData: model.AuthKeyRes{
|
||||
AuthorizeToken: ctx.GetString("authorize_token"),
|
||||
@@ -21,18 +22,20 @@ func AuthKey(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(authResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.JSON(http.StatusOK, authResp)
|
||||
ss.Respond(authResp)
|
||||
}
|
||||
|
||||
func Login(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
loginKey := ctx.GetString("login_key")
|
||||
var userId int
|
||||
exists, err := UserEng.Table("user_key").Where("key = ?", loginKey).Cols("userid").Get(&userId)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_key").Where("key = ?", loginKey).Cols("userid").Get(&userId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
if !exists || userId == 0 {
|
||||
userId = 9999999
|
||||
@@ -40,7 +43,9 @@ func Login(ctx *gin.Context) {
|
||||
ctx.Set("userid", userId)
|
||||
|
||||
err = db.DB.Set([]byte(strconv.Itoa(userId)), []byte(ctx.GetString("authorize_token")))
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
loginResp := model.LoginResp{
|
||||
ResponseData: model.LoginRes{
|
||||
@@ -52,9 +57,6 @@ func Login(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(loginResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.JSON(http.StatusOK, loginResp)
|
||||
ss.Respond(loginResp)
|
||||
}
|
||||
|
||||
@@ -3,17 +3,21 @@ package handler
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MultiUnitStartUp(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
startReq := model.MultiUnitStartUpReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
startResp := model.MultiUnitStartUpResp{
|
||||
ResponseData: model.MultiUnitStartUpRes{
|
||||
@@ -24,9 +28,6 @@ func MultiUnitStartUp(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(startResp)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -18,9 +16,15 @@ type MuseumContent struct {
|
||||
}
|
||||
|
||||
func MuseumInfo(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
var contents []MuseumContent
|
||||
err := MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").Find(&contents)
|
||||
utils.CheckErr(err)
|
||||
err := ss.MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").Find(&contents)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
var smileBuff, pureBuff, coolBuff int
|
||||
var contentsList []int
|
||||
for _, content := range contents {
|
||||
@@ -44,9 +48,6 @@ func MuseumInfo(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(museumResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(museumResp)
|
||||
}
|
||||
|
||||
+13
-15
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func NoticeFriendVariety(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
noticeResp := model.NoticeFriendVarietyResp{
|
||||
ResponseData: model.NoticeFriendVarietyRes{
|
||||
ItemCount: 1,
|
||||
@@ -20,14 +21,14 @@ func NoticeFriendVariety(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(noticeResp)
|
||||
}
|
||||
|
||||
func NoticeFriendGreeting(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
noticeResp := model.NoticeFriendGreetingResp{
|
||||
ResponseData: model.NoticeFriendGreetingRes{
|
||||
NextId: 0,
|
||||
@@ -37,14 +38,14 @@ func NoticeFriendGreeting(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(noticeResp)
|
||||
}
|
||||
|
||||
func NoticeUserGreeting(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
noticeResp := model.NoticeUserGreetingResp{
|
||||
ResponseData: model.NoticeUserGreetingRes{
|
||||
ItemCount: 0,
|
||||
@@ -55,9 +56,6 @@ func NoticeUserGreeting(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(noticeResp)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ProductList(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
prodReesp := model.ProductResp{
|
||||
ResponseData: model.ProductRes{
|
||||
RestrictionInfo: model.RestrictionInfo{
|
||||
@@ -31,9 +32,6 @@ func ProductList(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(prodReesp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(prodReesp)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func PersonalNotice(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
noticeResp := model.PersonalNoticeResp{
|
||||
ResponseData: model.PersonalNoticeRes{
|
||||
HasNotice: false,
|
||||
@@ -23,9 +24,6 @@ func PersonalNotice(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(noticeResp)
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ func LoginAuto(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
var userId, ticket string
|
||||
_, err = UserEng.Table("users").Cols("userid,ticket").Where("autokey = ?", autoKey).Get(&userId, &ticket)
|
||||
_, err = db.UserEng.Table("users").Cols("userid,ticket").Where("autokey = ?", autoKey).Get(&userId, &ticket)
|
||||
utils.CheckErr(err)
|
||||
|
||||
var resp string
|
||||
@@ -312,7 +312,7 @@ func AccountLogin(ctx *gin.Context) {
|
||||
// "key" INTEGER
|
||||
// );`
|
||||
var pass, autoKey, ticket, userId string
|
||||
_, err = UserEng.Table("users").Cols("password,autokey,ticket,userid").Where("phone = ?", phone).
|
||||
_, err = db.UserEng.Table("users").Cols("password,autokey,ticket,userid").Where("phone = ?", phone).
|
||||
Get(&pass, &autoKey, &ticket, &userId)
|
||||
utils.CheckErr(err)
|
||||
|
||||
@@ -322,7 +322,7 @@ func AccountLogin(ctx *gin.Context) {
|
||||
loginTime := time.Now().Unix()
|
||||
if pass == "" {
|
||||
// 未注册 - 自动注册
|
||||
session := UserEng.NewSession()
|
||||
session := db.UserEng.NewSession()
|
||||
defer session.Close()
|
||||
|
||||
// 开始会话
|
||||
@@ -393,7 +393,7 @@ func AccountLogin(ctx *gin.Context) {
|
||||
loginResp.Userid = userId // 实际登录用的账号
|
||||
|
||||
// 更新信息
|
||||
userStmt, err := UserEng.DB().Prepare("UPDATE users SET autokey=?,ticket=?,last_login_time=? WHERE userid=?")
|
||||
userStmt, err := db.UserEng.DB().Prepare("UPDATE users SET autokey=?,ticket=?,last_login_time=? WHERE userid=?")
|
||||
utils.CheckErr(err)
|
||||
defer userStmt.Close()
|
||||
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func ProfileRegister(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
pref := tools.UserPref{
|
||||
UserDesc: req.Get("introduction").String(),
|
||||
}
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
utils.CheckErr(err)
|
||||
|
||||
_, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
profileResp := model.ProfileRegisterResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(profileResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(profileResp)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/pkg/encrypt"
|
||||
"honoka-chan/internal/session"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ScenarioStartup(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
startReq := model.ScenarioReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
startResp := model.ScenarioResp{
|
||||
ResponseData: model.ScenarioRes{
|
||||
@@ -28,22 +29,20 @@ func ScenarioStartup(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp)))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(startResp)
|
||||
}
|
||||
|
||||
func ScenarioReward(ctx *gin.Context) {
|
||||
resp := honokautils.ReadAllText("assets/serverdata/reward.json")
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
data := honokautils.ReadAllText("assets/serverdata/reward.json")
|
||||
var resp map[string]any
|
||||
err := json.Unmarshal([]byte(data), &resp)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/pkg/encrypt"
|
||||
"honoka-chan/internal/session"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SubScenarioStartup(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
startReq := model.SubScenarioReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
startResp := model.SubScenarioResp{
|
||||
ResponseData: model.SubScenarioRes{
|
||||
@@ -28,22 +29,20 @@ func SubScenarioStartup(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp)))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(startResp)
|
||||
}
|
||||
|
||||
func SubScenarioReward(ctx *gin.Context) {
|
||||
resp := honokautils.ReadAllText("assets/serverdata/subreward.json")
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
data := honokautils.ReadAllText("assets/serverdata/subreward.json")
|
||||
var resp map[string]any
|
||||
err := json.Unmarshal([]byte(data), &resp)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(resp)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TosCheck(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
tosResp := model.TosResp{
|
||||
ResponseData: model.TosRes{
|
||||
TosID: 1,
|
||||
@@ -21,9 +22,6 @@ func TosCheck(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(tosResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(tosResp)
|
||||
}
|
||||
|
||||
+100
-141
@@ -2,9 +2,10 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/internal/session"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -13,56 +14,50 @@ import (
|
||||
)
|
||||
|
||||
func SetDisplayRank(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
dispResp := model.SetDisplayRankResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(dispResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(dispResp)
|
||||
}
|
||||
|
||||
func SetDeck(ctx *gin.Context) {
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
utils.CheckErr(err)
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
deckReq := model.UnitDeckReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||
panic(err)
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
// UserEng.ShowSQL(true)
|
||||
session := UserEng.NewSession()
|
||||
defer session.Close()
|
||||
if err := session.Begin(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
deckReq := model.UnitDeckReq{}
|
||||
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 原有队伍信息
|
||||
var userDeckId []int
|
||||
err = session.Table("user_deck_m").Cols("id").Where("user_id = ?", userId).Find(&userDeckId)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
err = ss.UserEng.Table("user_deck_m").Cols("id").Where("user_id = ?", userId).Find(&userDeckId)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 删除全部原有队伍成员
|
||||
_, err = session.Table("deck_unit_m").In("user_deck_id", userDeckId).Delete()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.UserEng.Table("deck_unit_m").In("user_deck_id", userDeckId).Delete()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 删除全部原有队伍
|
||||
_, err = session.Table("user_deck_m").In("id", userDeckId).Delete()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.UserEng.Table("user_deck_m").In("id", userDeckId).Delete()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 遍历新队伍
|
||||
@@ -75,10 +70,9 @@ func SetDeck(ctx *gin.Context) {
|
||||
UserID: userId,
|
||||
InsertDate: time.Now().Unix(),
|
||||
}
|
||||
_, err = session.Table("user_deck_m").Insert(&userDeck)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.UserEng.Table("user_deck_m").Insert(&userDeck)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
userDeckId := userDeck.ID
|
||||
// fmt.Println("新队伍 ID:", userDeckId)
|
||||
@@ -87,35 +81,33 @@ func SetDeck(ctx *gin.Context) {
|
||||
for _, unit := range deck.UnitDeckDetail {
|
||||
// 成员信息
|
||||
newUnitData := model.UnitData{}
|
||||
exists, err := session.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
exists, err := ss.UserEng.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
// fmt.Println("新成员为用户增加成员")
|
||||
_, err = session.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Get(&newUnitData)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.UserEng.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Get(&newUnitData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
exists, err := MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
// fmt.Println("新成员为公共成员")
|
||||
_, err = MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Get(&newUnitData)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Get(&newUnitData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// fmt.Println("新成员不存在")
|
||||
session.Rollback()
|
||||
panic("unexpected operation")
|
||||
err = errors.New("新成员不存在")
|
||||
}
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// fmt.Println("新的成员信息:", newUnitData)
|
||||
@@ -123,56 +115,53 @@ func SetDeck(ctx *gin.Context) {
|
||||
// 插入新成员信息
|
||||
newUnitDeckData := model.UnitDeckData{}
|
||||
b, err := json.Marshal(newUnitData)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(b, &newUnitDeckData); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
err = json.Unmarshal(b, &newUnitDeckData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
newUnitDeckData.BeforeLove = newUnitDeckData.MaxLove
|
||||
newUnitDeckData.Position = unit.Position
|
||||
newUnitDeckData.UserDeckID = userDeckId
|
||||
newUnitDeckData.InsertData = time.Now().Unix()
|
||||
|
||||
_, err = session.Table("deck_unit_m").Insert(&newUnitDeckData)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err = ss.UserEng.Table("deck_unit_m").Insert(&newUnitDeckData)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 结束事务
|
||||
if err = session.Commit(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
}
|
||||
|
||||
dispResp := model.SetDeckResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(dispResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(dispResp)
|
||||
}
|
||||
|
||||
func SetDeckName(ctx *gin.Context) {
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
utils.CheckErr(err)
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
deckReq := model.DeckNameReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||
panic(err)
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
exists, err := UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", userId, deckReq.UnitDeckID).Exist()
|
||||
utils.CheckErr(err)
|
||||
deckReq := model.DeckNameReq{}
|
||||
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
exists, err := ss.UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", userId, deckReq.UnitDeckID).Exist()
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
@@ -180,49 +169,41 @@ func SetDeckName(ctx *gin.Context) {
|
||||
userDeck := model.UserDeckData{
|
||||
DeckName: deckReq.DeckName,
|
||||
}
|
||||
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &model.UserDeckData{
|
||||
_, err = ss.UserEng.Table("user_deck_m").Update(&userDeck, &model.UserDeckData{
|
||||
UserID: userId,
|
||||
DeckID: deckReq.UnitDeckID,
|
||||
})
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
dispResp := model.SetDeckResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(dispResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(dispResp)
|
||||
}
|
||||
|
||||
func WearAccessory(ctx *gin.Context) {
|
||||
fmt.Println(ctx.PostForm("request_data"))
|
||||
req := model.WearAccessoryReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &req); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
// UserEng.ShowSQL(true)
|
||||
// 开始事务
|
||||
session := UserEng.NewSession()
|
||||
defer session.Close()
|
||||
if err := session.Begin(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
req := model.WearAccessoryReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &req)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 取下饰品
|
||||
for _, v := range req.Remove {
|
||||
fmt.Println("Remove:", v.AccessoryOwningUserID, v.UnitOwningUserID)
|
||||
_, err := session.Table("accessory_wear_m").
|
||||
_, err := ss.UserEng.Table("accessory_wear_m").
|
||||
Where("accessory_owning_user_id = ? AND unit_owning_user_id = ? AND user_id = ?", v.AccessoryOwningUserID, v.UnitOwningUserID, ctx.GetString("userid")).
|
||||
Delete()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,14 +215,10 @@ func WearAccessory(ctx *gin.Context) {
|
||||
UnitOwningUserID: v.UnitOwningUserID,
|
||||
UserId: ctx.GetString("userid"),
|
||||
}
|
||||
_, err := session.Table("accessory_wear_m").Insert(&data)
|
||||
utils.CheckErr(err)
|
||||
}
|
||||
|
||||
// 结束事务
|
||||
if err := session.Commit(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err := ss.UserEng.Table("accessory_wear_m").Insert(&data)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
wearResp := model.AwardSetResp{
|
||||
@@ -249,38 +226,28 @@ func WearAccessory(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(wearResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(wearResp)
|
||||
}
|
||||
|
||||
func RemoveSkillEquip(ctx *gin.Context) {
|
||||
fmt.Println(ctx.PostForm("request_data"))
|
||||
req := model.SkillEquipReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &req); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
// UserEng.ShowSQL(true)
|
||||
// 开始事务
|
||||
session := UserEng.NewSession()
|
||||
defer session.Close()
|
||||
if err := session.Begin(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
req := model.SkillEquipReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &req)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
// 取下宝石
|
||||
for _, v := range req.Remove {
|
||||
fmt.Println("Remove:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
||||
_, err := session.Table("skill_equip_m").
|
||||
_, err := ss.UserEng.Table("skill_equip_m").
|
||||
Where("unit_removable_skill_id = ? AND unit_owning_user_id = ? AND user_id = ?", v.UnitRemovableSkillID, v.UnitOwningUserID, ctx.GetString("userid")).
|
||||
Delete()
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,14 +259,10 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
||||
UnitOwningUserID: v.UnitOwningUserID,
|
||||
UserId: ctx.GetString("userid"),
|
||||
}
|
||||
_, err := session.Table("skill_equip_m").Insert(&data)
|
||||
utils.CheckErr(err)
|
||||
}
|
||||
|
||||
// 结束事务
|
||||
if err := session.Commit(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
_, err := ss.UserEng.Table("skill_equip_m").Insert(&data)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
wearResp := model.AwardSetResp{
|
||||
@@ -307,10 +270,6 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(wearResp)
|
||||
utils.CheckErr(err)
|
||||
fmt.Println(string(resp))
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(wearResp)
|
||||
}
|
||||
|
||||
+26
-20
@@ -1,10 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -13,42 +12,50 @@ import (
|
||||
)
|
||||
|
||||
func SetNotificationToken(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
notifResp := model.NotificationResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(notifResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(notifResp)
|
||||
}
|
||||
|
||||
func ChangeNavi(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
pref := tools.UserPref{
|
||||
UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()),
|
||||
}
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
utils.CheckErr(err)
|
||||
_, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
naviResp := model.UserNaviChangeResp{
|
||||
ResponseData: []any{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(naviResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(naviResp)
|
||||
}
|
||||
|
||||
func ChangeName(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
var oldName string
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_name").Get(&oldName)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_name").Get(&oldName)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
@@ -56,8 +63,10 @@ func ChangeName(ctx *gin.Context) {
|
||||
pref := tools.UserPref{
|
||||
UserName: req.Get("name").String(),
|
||||
}
|
||||
_, err = UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
utils.CheckErr(err)
|
||||
_, err = ss.UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Update(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
nameResp := model.UserNameChangeResp{
|
||||
ResponseData: model.UserNameChangeRes{
|
||||
BeforeName: oldName,
|
||||
@@ -67,9 +76,6 @@ func ChangeName(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(nameResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(nameResp)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -14,12 +13,19 @@ import (
|
||||
)
|
||||
|
||||
func UserInfo(ctx *gin.Context) {
|
||||
ss := session.New(ctx)
|
||||
defer ss.Finalize()
|
||||
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
utils.CheckErr(err)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
pref := tools.UserPref{}
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
utils.CheckErr(err)
|
||||
exists, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
@@ -66,9 +72,6 @@ func UserInfo(ctx *gin.Context) {
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(userResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
ss.Respond(userResp)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/csv"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/pkg/db"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -35,7 +36,7 @@ func WebLogin(ctx *gin.Context) {
|
||||
|
||||
userName := " " + area + "-" + user
|
||||
var userId int
|
||||
exists, err := UserEng.Table("users").Where("phone = ? AND password = ?", userName, openssl.Md5ToString(pass)).Cols("userid").Get(&userId)
|
||||
exists, err := db.UserEng.Table("users").Where("phone = ? AND password = ?", userName, openssl.Md5ToString(pass)).Cols("userid").Get(&userId)
|
||||
utils.CheckErr(err)
|
||||
if !exists {
|
||||
ctx.JSON(http.StatusOK, model.Msg{
|
||||
@@ -80,7 +81,7 @@ func Upload(ctx *gin.Context) {
|
||||
err = ctx.SaveUploadedFile(file, tmpPath)
|
||||
utils.CheckErr(err)
|
||||
|
||||
session := UserEng.NewSession()
|
||||
session := db.UserEng.NewSession()
|
||||
defer session.Close()
|
||||
if err = session.Begin(); err != nil {
|
||||
session.Rollback()
|
||||
@@ -113,7 +114,7 @@ func Upload(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
var unitId, unitExp, unitRarity, unitHp, unitSigned int
|
||||
exists, err := MainEng.Table("common_unit_m").Join("LEFT", "unit_m", "common_unit_m.unit_id = unit_m.unit_id").
|
||||
exists, err := db.MainEng.Table("common_unit_m").Join("LEFT", "unit_m", "common_unit_m.unit_id = unit_m.unit_id").
|
||||
Where("unit_m.unit_number = ?", rr[0]).
|
||||
Cols("common_unit_m.unit_id,common_unit_m.exp,unit_m.rarity,common_unit_m.max_hp,common_unit_m.is_signed").
|
||||
Get(&unitId, &unitExp, &unitRarity, &unitHp, &unitSigned)
|
||||
@@ -138,7 +139,7 @@ func Upload(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
var diffExp, diffSmile, diffPure, diffCool int
|
||||
_, err = MainEng.Table("unit_level_limit_pattern_m").Where("unit_level_limit_id = 1 AND unit_level = 350").
|
||||
_, err = db.MainEng.Table("unit_level_limit_pattern_m").Where("unit_level_limit_id = 1 AND unit_level = 350").
|
||||
Cols("next_exp,smile_diff,pure_diff,cool_diff").Get(&diffExp, &diffSmile, &diffPure, &diffCool)
|
||||
utils.CheckErr(err)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// ApiReq ...
|
||||
type ApiReq struct {
|
||||
Module string `json:"module"`
|
||||
@@ -11,9 +9,9 @@ type ApiReq struct {
|
||||
|
||||
// ApiResp ...
|
||||
type ApiResp struct {
|
||||
ResponseData json.RawMessage `json:"response_data"`
|
||||
ReleaseInfo []any `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
ResponseData any `json:"response_data"`
|
||||
ReleaseInfo any `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// ApiUserInfoResp ...
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/utils"
|
||||
"honoka-chan/pkg/db"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
Ctx *gin.Context
|
||||
MainEng *xorm.Session
|
||||
UserEng *xorm.Session
|
||||
}
|
||||
|
||||
func New(ctx *gin.Context) *Session {
|
||||
ss := &Session{
|
||||
Ctx: ctx,
|
||||
}
|
||||
|
||||
ss.MainEng = db.MainEng.NewSession()
|
||||
|
||||
ss.UserEng = db.UserEng.NewSession()
|
||||
ss.UserEng.Begin()
|
||||
|
||||
return ss
|
||||
}
|
||||
|
||||
func (ss *Session) Finalize() {
|
||||
ss.MainEng.Close()
|
||||
|
||||
ss.UserEng.Commit()
|
||||
ss.UserEng.Close()
|
||||
}
|
||||
|
||||
func (ss *Session) Abort(err error) {
|
||||
ss.MainEng.Close()
|
||||
|
||||
ss.UserEng.Rollback()
|
||||
ss.UserEng.Close()
|
||||
|
||||
ss.Ctx.JSON(500, gin.H{"error": err.Error()})
|
||||
ss.Ctx.Abort()
|
||||
}
|
||||
|
||||
func (ss *Session) CheckErr(err error) bool {
|
||||
if err != nil {
|
||||
ss.Abort(err)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (ss *Session) Respond(resp any) {
|
||||
data, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
ss.Abort(err)
|
||||
return
|
||||
}
|
||||
|
||||
ss.Ctx.Header("X-Message-Sign", utils.GenXMS(data))
|
||||
ss.Ctx.String(200, string(data))
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func InitUserData(userId int) {
|
||||
}
|
||||
_, err = session.Table("user_preference_m").Insert(&userPref)
|
||||
utils.CheckErr(err)
|
||||
fmt.Println("UserPref ID", userPref.ID)
|
||||
// fmt.Println("UserPref ID", userPref.ID)
|
||||
}
|
||||
|
||||
// 检查用户卡组配置
|
||||
@@ -94,7 +94,7 @@ func InitUserData(userId int) {
|
||||
panic(err)
|
||||
}
|
||||
userDeckId := userDeck.ID
|
||||
fmt.Println("New UserDeck:", userDeckId)
|
||||
// fmt.Println("New UserDeck:", userDeckId)
|
||||
|
||||
// 默认卡组
|
||||
unitIds := []int{}
|
||||
@@ -137,7 +137,7 @@ func InitUserData(userId int) {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("New DeckUnit:", unitDeckData.ID)
|
||||
// fmt.Println("New DeckUnit:", unitDeckData.ID)
|
||||
|
||||
position++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user