@@ -73,6 +73,7 @@ func RSA_Gen(bits int) {
|
|||||||
//3. save to file
|
//3. save to file
|
||||||
pem.Encode(publickeyfile, &publickeyblock)
|
pem.Encode(publickeyfile, &publickeyblock)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
||||||
//open publickeyfile
|
//open publickeyfile
|
||||||
publickeyfile, err := os.Open(publickeypath)
|
publickeyfile, err := os.Open(publickeypath)
|
||||||
|
|||||||
+3
-6
@@ -10,10 +10,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AlbumSearchResult struct {
|
type AlbumRes struct {
|
||||||
UnitId int `xorm:"unit_id"`
|
UnitId int `xorm:"unit_id"`
|
||||||
Rarity int `xorm:"rarity"`
|
Rarity int `xorm:"rarity"`
|
||||||
}
|
}
|
||||||
@@ -26,7 +25,7 @@ func AlbumSeriesAll(ctx *gin.Context) {
|
|||||||
|
|
||||||
albumSeriesAllRes := []model.AlbumSeriesRes{}
|
albumSeriesAllRes := []model.AlbumSeriesRes{}
|
||||||
for _, albumId := range albumIds {
|
for _, albumId := range albumIds {
|
||||||
unitList := []AlbumSearchResult{}
|
unitList := []AlbumRes{}
|
||||||
err = MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList)
|
err = MainEng.Table("unit_m").Where("album_series_id = ?", albumId).Cols("unit_id,rarity").Find(&unitList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
@@ -62,9 +61,7 @@ func AlbumSeriesAll(ctx *gin.Context) {
|
|||||||
albumSeries.HighestLovePerUnit = 1000
|
albumSeries.HighestLovePerUnit = 1000
|
||||||
|
|
||||||
// IsSigned
|
// IsSigned
|
||||||
exists, err := MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist()
|
albumSeries.SignFlag = IsSigned(unit.UnitId)
|
||||||
CheckErr(err)
|
|
||||||
albumSeries.SignFlag = exists
|
|
||||||
}
|
}
|
||||||
|
|
||||||
albumSeriesAll = append(albumSeriesAll, albumSeries)
|
albumSeriesAll = append(albumSeriesAll, albumSeries)
|
||||||
|
|||||||
+69
-66
@@ -17,6 +17,27 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type EventRes struct {
|
||||||
|
EventScenarioId int `xorm:"event_scenario_id"`
|
||||||
|
Chapter int `xorm:"chapter"`
|
||||||
|
ChapterAsset string `xorm:"chapter_asset"`
|
||||||
|
OpenDate string `xorm:"open_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MultiRes struct {
|
||||||
|
MultiUnitScenarioId int `xorm:"multi_unit_scenario_id"`
|
||||||
|
Chapter int `xorm:"chapter"`
|
||||||
|
MultiUnitScenarioBtnAsset string `xorm:"multi_unit_scenario_btn_asset"`
|
||||||
|
OpenDate string `xorm:"open_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MuseumRes struct {
|
||||||
|
MuseumContentsId int `xorm:"museum_contents_id"`
|
||||||
|
SmileBuff int `xorm:"smile_buff"`
|
||||||
|
PureBuff int `xorm:"pure_buff"`
|
||||||
|
CoolBuff int `xorm:"cool_buff"`
|
||||||
|
}
|
||||||
|
|
||||||
func Api(ctx *gin.Context) {
|
func Api(ctx *gin.Context) {
|
||||||
apiReq := []model.ApiReq{}
|
apiReq := []model.ApiReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &apiReq)
|
err := json.Unmarshal([]byte(ctx.GetString("request_data")), &apiReq)
|
||||||
@@ -226,13 +247,13 @@ func Api(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "deckInfo":
|
case "deckInfo":
|
||||||
// key = "unit_deck_result"
|
// key = "unit_deck_result"
|
||||||
userDeck := []tools.UserDeckData{}
|
userDeck := []model.UserDeckData{}
|
||||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck)
|
err = UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
unitDeckInfo := []model.UnitDeckInfoRes{}
|
unitDeckInfo := []model.UnitDeckInfoRes{}
|
||||||
for _, deck := range userDeck {
|
for _, deck := range userDeck {
|
||||||
deckUnit := []tools.UnitDeckData{}
|
deckUnit := []model.UnitDeckData{}
|
||||||
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
@@ -379,7 +400,7 @@ func Api(ctx *gin.Context) {
|
|||||||
case "album":
|
case "album":
|
||||||
// key = "album_unit_result"
|
// key = "album_unit_result"
|
||||||
albumLists := []model.AlbumResult{}
|
albumLists := []model.AlbumResult{}
|
||||||
unitList := []AlbumSearchResult{}
|
unitList := []AlbumRes{}
|
||||||
err = MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
err = MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
for _, unit := range unitList {
|
for _, unit := range unitList {
|
||||||
@@ -411,9 +432,7 @@ func Api(ctx *gin.Context) {
|
|||||||
albumList.TotalLove = 1000
|
albumList.TotalLove = 1000
|
||||||
|
|
||||||
// IsSigned
|
// IsSigned
|
||||||
exists, err := MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist()
|
albumList.SignFlag = IsSigned(unit.UnitId)
|
||||||
CheckErr(err)
|
|
||||||
albumList.SignFlag = exists
|
|
||||||
}
|
}
|
||||||
albumLists = append(albumLists, albumList)
|
albumLists = append(albumLists, albumList)
|
||||||
}
|
}
|
||||||
@@ -478,20 +497,16 @@ func Api(ctx *gin.Context) {
|
|||||||
err = MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds)
|
err = MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventIds)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
for _, id := range eventIds {
|
for _, id := range eventIds {
|
||||||
sql := `SELECT event_scenario_id,chapter,chapter_asset,open_date FROM event_scenario_m WHERE event_id = ? ORDER BY chapter DESC`
|
eventRes := []EventRes{}
|
||||||
chaps, err := MainEng.DB().Query(sql, id)
|
|
||||||
CheckErr(err)
|
|
||||||
defer chaps.Close()
|
|
||||||
chapsList := []model.EventScenarioChapterList{}
|
chapsList := []model.EventScenarioChapterList{}
|
||||||
var open_date string
|
err = MainEng.Table("event_scenario_m").Where("event_id = ?", id).Cols("event_scenario_id,chapter,chapter_asset,open_date").
|
||||||
for chaps.Next() {
|
OrderBy("chapter DESC").Find(&eventRes)
|
||||||
var event_scenario_id, chapter int
|
CheckErr(err)
|
||||||
var chapter_asset interface{}
|
for _, res := range eventRes {
|
||||||
err = chaps.Scan(&event_scenario_id, &chapter, &chapter_asset, &open_date)
|
|
||||||
CheckErr(err)
|
|
||||||
chapList := model.EventScenarioChapterList{
|
chapList := model.EventScenarioChapterList{
|
||||||
EventScenarioID: event_scenario_id,
|
EventScenarioID: res.EventScenarioId,
|
||||||
Chapter: chapter,
|
Chapter: res.Chapter,
|
||||||
|
ChapterAsset: res.ChapterAsset,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
OpenFlashFlag: 0,
|
OpenFlashFlag: 0,
|
||||||
IsReward: false,
|
IsReward: false,
|
||||||
@@ -499,16 +514,12 @@ func Api(ctx *gin.Context) {
|
|||||||
ItemID: 1200,
|
ItemID: 1200,
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
}
|
}
|
||||||
if chapter_asset != nil {
|
|
||||||
chapList.ChapterAsset = chapter_asset.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
chapsList = append(chapsList, chapList)
|
chapsList = append(chapsList, chapList)
|
||||||
}
|
}
|
||||||
|
|
||||||
eventList := model.EventScenarioList{
|
eventList := model.EventScenarioList{
|
||||||
EventID: id,
|
EventID: id,
|
||||||
OpenDate: strings.ReplaceAll(open_date, "/", "-"),
|
OpenDate: strings.ReplaceAll(eventRes[0].OpenDate, "/", "-"),
|
||||||
ChapterList: chapsList,
|
ChapterList: chapsList,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,7 +536,7 @@ func Api(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
eventScenarioResp := model.EventScenarioStatusResp{
|
eventScenarioResp := model.EventScenarioStatusResp{
|
||||||
Result: model.EventScenarioStatusRes{
|
Result: model.EventScenarioStatusRes{
|
||||||
EventScenarioList: eventsList, //
|
EventScenarioList: eventsList,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -540,26 +551,22 @@ func Api(ctx *gin.Context) {
|
|||||||
err = MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds)
|
err = MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&multiIds)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
for _, id := range multiIds {
|
for _, id := range multiIds {
|
||||||
sql := `SELECT multi_unit_scenario_btn_asset,open_date,multi_unit_scenario_id,chapter FROM multi_unit_scenario_m a LEFT JOIN multi_unit_scenario_open_m b ON a.multi_unit_id = b.multi_unit_id WHERE a.multi_unit_id = ?`
|
multiRes := MultiRes{}
|
||||||
units, err := MainEng.DB().Query(sql, id)
|
_, err = 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)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
defer units.Close()
|
|
||||||
var multi_unit_scenario_id, chapter int
|
|
||||||
var multi_unit_scenario_btn_asset, open_date string
|
|
||||||
for units.Next() {
|
|
||||||
err = units.Scan(&multi_unit_scenario_btn_asset, &open_date, &multi_unit_scenario_id, &chapter)
|
|
||||||
CheckErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{
|
multiUnitsList = append(multiUnitsList, model.MultiUnitScenarioStatusList{
|
||||||
MultiUnitID: id,
|
MultiUnitID: id,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
MultiUnitScenarioBtnAsset: multi_unit_scenario_btn_asset,
|
MultiUnitScenarioBtnAsset: multiRes.MultiUnitScenarioBtnAsset,
|
||||||
OpenDate: strings.ReplaceAll(open_date, "/", "-"),
|
OpenDate: strings.ReplaceAll(multiRes.OpenDate, "/", "-"),
|
||||||
ChapterList: []model.MultiUnitScenarioChapterList{
|
ChapterList: []model.MultiUnitScenarioChapterList{
|
||||||
{
|
{
|
||||||
MultiUnitScenarioID: multi_unit_scenario_id,
|
MultiUnitScenarioID: multiRes.MultiUnitScenarioId,
|
||||||
Chapter: chapter,
|
Chapter: multiRes.Chapter,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -827,31 +834,27 @@ func Api(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "museum":
|
case "museum":
|
||||||
// key = "museum_result"
|
// key = "museum_result"
|
||||||
sql := `SELECT museum_contents_id,smile_buff,pure_buff,cool_buff FROM museum_contents_m ORDER BY museum_contents_id ASC`
|
museumRes := []MuseumRes{}
|
||||||
rows, err := MainEng.DB().Query(sql)
|
var museumIds []int
|
||||||
|
var smileBuff, pureBuff, coolBuff int
|
||||||
|
err = MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").
|
||||||
|
OrderBy("museum_contents_id ASC").Find(&museumRes)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
defer rows.Close()
|
for _, res := range museumRes {
|
||||||
var smileBuf, pureBuf, coolBuf int
|
smileBuff += res.SmileBuff
|
||||||
var mIds []int
|
pureBuff += res.PureBuff
|
||||||
for rows.Next() {
|
coolBuff += res.CoolBuff
|
||||||
var museum_contents_id, smile_buff, pure_buff, cool_buff int
|
museumIds = append(museumIds, res.MuseumContentsId)
|
||||||
err = rows.Scan(&museum_contents_id, &smile_buff, &pure_buff, &cool_buff)
|
|
||||||
CheckErr(err)
|
|
||||||
smileBuf += smile_buff
|
|
||||||
pureBuf += pure_buff
|
|
||||||
coolBuf += cool_buff
|
|
||||||
mIds = append(mIds, museum_contents_id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
museumInfoResp := model.MuseumInfoResp{
|
museumInfoResp := model.MuseumInfoResp{
|
||||||
Result: model.MuseumInfoRes{
|
Result: model.MuseumInfoRes{
|
||||||
MuseumInfo: model.Museum{
|
MuseumInfo: model.Museum{
|
||||||
Parameter: model.MuseumParameter{
|
Parameter: model.MuseumParameter{
|
||||||
Smile: smileBuf,
|
Smile: smileBuff,
|
||||||
Pure: pureBuf,
|
Pure: pureBuff,
|
||||||
Cool: coolBuf,
|
Cool: coolBuff,
|
||||||
},
|
},
|
||||||
ContentsIDList: mIds,
|
ContentsIDList: museumIds,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
@@ -863,8 +866,8 @@ func Api(ctx *gin.Context) {
|
|||||||
case "profile":
|
case "profile":
|
||||||
if v.Action == "liveCnt" {
|
if v.Action == "liveCnt" {
|
||||||
// key = "profile_livecnt_result"
|
// key = "profile_livecnt_result"
|
||||||
difficultyResp := tools.DifficultyResp{
|
difficultyResp := model.DifficultyResp{
|
||||||
Result: []tools.DifficultyResult{
|
Result: []model.DifficultyRes{
|
||||||
{
|
{
|
||||||
Difficulty: 1,
|
Difficulty: 1,
|
||||||
ClearCnt: 315,
|
ClearCnt: 315,
|
||||||
@@ -898,7 +901,7 @@ func Api(ctx *gin.Context) {
|
|||||||
love := utils.ReadAllText("assets/love.json")
|
love := utils.ReadAllText("assets/love.json")
|
||||||
err := json.Unmarshal([]byte(love), &result)
|
err := json.Unmarshal([]byte(love), &result)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
loveResp := tools.LoveResp{
|
loveResp := model.LoveResp{
|
||||||
Result: result,
|
Result: result,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -921,7 +924,7 @@ func Api(ctx *gin.Context) {
|
|||||||
userUnit, err := UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Count()
|
userUnit, err := UserEng.Table("user_unit_m").Where("user_id = ?", ctx.GetString("userid")).Count()
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
unitData := tools.UnitData{}
|
unitData := model.UnitData{}
|
||||||
exists, err = MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
exists, err = MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
isCommon := true
|
isCommon := true
|
||||||
@@ -956,7 +959,7 @@ func Api(ctx *gin.Context) {
|
|||||||
_, err = MainEng.Table("common_accessory_m").Where("accessory_owning_user_id = ?", accessoryOwningId).
|
_, err = MainEng.Table("common_accessory_m").Where("accessory_owning_user_id = ?", accessoryOwningId).
|
||||||
Cols("accessory_id,exp").Get(&accessoryId, &exp)
|
Cols("accessory_id,exp").Get(&accessoryId, &exp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
accessoryInfo := tools.AccessoryInfo{
|
accessoryInfo := model.AccessoryInfo{
|
||||||
AccessoryOwningUserID: accessoryOwningId,
|
AccessoryOwningUserID: accessoryOwningId,
|
||||||
AccessoryID: accessoryId,
|
AccessoryID: accessoryId,
|
||||||
Exp: exp,
|
Exp: exp,
|
||||||
@@ -972,9 +975,9 @@ func Api(ctx *gin.Context) {
|
|||||||
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
profileResp := tools.ProfileResp{
|
profileResp := model.ProfileResp{
|
||||||
Result: tools.ProfileResult{
|
Result: model.ProfileRes{
|
||||||
UserInfo: tools.UserInfo{
|
UserInfo: model.ProfileUserInfo{
|
||||||
UserID: pref.UserID,
|
UserID: pref.UserID,
|
||||||
Name: pref.UserName,
|
Name: pref.UserName,
|
||||||
Level: pref.UserLevel,
|
Level: pref.UserLevel,
|
||||||
@@ -987,7 +990,7 @@ func Api(ctx *gin.Context) {
|
|||||||
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
||||||
Introduction: pref.UserDesc,
|
Introduction: pref.UserDesc,
|
||||||
},
|
},
|
||||||
CenterUnitInfo: tools.CenterUnitInfo{
|
CenterUnitInfo: model.CenterUnitInfo{
|
||||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||||
UnitID: unitData.UnitID,
|
UnitID: unitData.UnitID,
|
||||||
Exp: unitData.Exp,
|
Exp: unitData.Exp,
|
||||||
@@ -1017,13 +1020,13 @@ func Api(ctx *gin.Context) {
|
|||||||
SettingAwardID: pref.AwardID,
|
SettingAwardID: pref.AwardID,
|
||||||
RemovableSkillIds: removeSkillIds,
|
RemovableSkillIds: removeSkillIds,
|
||||||
AccessoryInfo: accessoryInfo,
|
AccessoryInfo: accessoryInfo,
|
||||||
Costume: tools.Costume{},
|
Costume: model.Costume{},
|
||||||
TotalSmile: smileMax,
|
TotalSmile: smileMax,
|
||||||
TotalCute: pureMax,
|
TotalCute: pureMax,
|
||||||
TotalCool: coolMax,
|
TotalCool: coolMax,
|
||||||
TotalHp: maxHp,
|
TotalHp: maxHp,
|
||||||
},
|
},
|
||||||
NaviUnitInfo: tools.NaviUnitInfo{
|
NaviUnitInfo: model.NaviUnitInfo{
|
||||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||||
UnitID: unitData.UnitID,
|
UnitID: unitData.UnitID,
|
||||||
Exp: unitData.Exp,
|
Exp: unitData.Exp,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -27,3 +27,10 @@ func CheckErr(err error) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsSigned(unitId int) bool {
|
||||||
|
exists, err := MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unitId).Exist()
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func AuthKey(ctx *gin.Context) {
|
func AuthKey(ctx *gin.Context) {
|
||||||
|
|||||||
+4
-24
@@ -5,40 +5,20 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MultiUnitStartUpResp struct {
|
|
||||||
ResponseData MultiUnitStartUpData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MultiUnitStartUpData struct {
|
|
||||||
MultiUnitScenarioID int `json:"multi_unit_scenario_id"`
|
|
||||||
ScenarioAdjustment int `json:"scenario_adjustment"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MultiUnitStartUpReq struct {
|
|
||||||
Module string `json:"module"`
|
|
||||||
Action string `json:"action"`
|
|
||||||
TimeStamp int `json:"timeStamp"`
|
|
||||||
Mgd int `json:"mgd"`
|
|
||||||
MultiUnitScenarioID int `json:"multi_unit_scenario_id"`
|
|
||||||
CommandNum string `json:"commandNum"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func MultiUnitStartUp(ctx *gin.Context) {
|
func MultiUnitStartUp(ctx *gin.Context) {
|
||||||
startReq := MultiUnitStartUpReq{}
|
startReq := model.MultiUnitStartUpReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
startResp := MultiUnitStartUpResp{
|
startResp := model.MultiUnitStartUpResp{
|
||||||
ResponseData: MultiUnitStartUpData{
|
ResponseData: model.MultiUnitStartUpRes{
|
||||||
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
+5
-28
@@ -5,43 +5,20 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProductResp struct {
|
|
||||||
ResponseData ProductData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
type RestrictionInfo struct {
|
|
||||||
Restricted bool `json:"restricted"`
|
|
||||||
}
|
|
||||||
type UnderAgeInfo struct {
|
|
||||||
BirthSet bool `json:"birth_set"`
|
|
||||||
HasLimit bool `json:"has_limit"`
|
|
||||||
LimitAmount interface{} `json:"limit_amount"`
|
|
||||||
MonthUsed int `json:"month_used"`
|
|
||||||
}
|
|
||||||
type ProductData struct {
|
|
||||||
RestrictionInfo RestrictionInfo `json:"restriction_info"`
|
|
||||||
UnderAgeInfo UnderAgeInfo `json:"under_age_info"`
|
|
||||||
SnsProductList []interface{} `json:"sns_product_list"`
|
|
||||||
ProductList []interface{} `json:"product_list"`
|
|
||||||
SubscriptionList []interface{} `json:"subscription_list"`
|
|
||||||
ShowPointShop bool `json:"show_point_shop"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProductList(ctx *gin.Context) {
|
func ProductList(ctx *gin.Context) {
|
||||||
prodReesp := ProductResp{
|
prodReesp := model.ProductResp{
|
||||||
ResponseData: ProductData{
|
ResponseData: model.ProductRes{
|
||||||
RestrictionInfo: RestrictionInfo{
|
RestrictionInfo: model.RestrictionInfo{
|
||||||
Restricted: false,
|
Restricted: false,
|
||||||
},
|
},
|
||||||
UnderAgeInfo: UnderAgeInfo{
|
UnderAgeInfo: model.UnderAgeInfo{
|
||||||
BirthSet: true,
|
BirthSet: true,
|
||||||
HasLimit: false,
|
HasLimit: false,
|
||||||
LimitAmount: nil,
|
LimitAmount: nil,
|
||||||
|
|||||||
+21
-32
@@ -17,7 +17,6 @@ import (
|
|||||||
|
|
||||||
"github.com/forgoer/openssl"
|
"github.com/forgoer/openssl"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LoginResp struct {
|
type LoginResp struct {
|
||||||
@@ -50,7 +49,7 @@ type LoginAutoResp struct {
|
|||||||
Result int `json:"result"`
|
Result int `json:"result"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Autokey string `json:"autokey"`
|
Autokey string `json:"autokey"`
|
||||||
Userid string `json:"userid"`
|
UserId string `json:"userid"`
|
||||||
Ticket string `json:"ticket"`
|
Ticket string `json:"ticket"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,21 +221,17 @@ func LoginAuto(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt, err := UserEng.DB().Prepare("SELECT userid,ticket AS ct FROM users WHERE autokey = ?")
|
var userId, ticket string
|
||||||
CheckErr(err)
|
_, err = UserEng.Table("users").Cols("userid,ticket").Where("autokey = ?", autoKey).Get(&userId, &ticket)
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
var userid, ticket string
|
|
||||||
err = stmt.QueryRow(autoKey).Scan(&userid, &ticket)
|
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
var resp string
|
var resp string
|
||||||
if userid != "" {
|
if userId != "" {
|
||||||
autoResp := LoginAutoResp{
|
autoResp := LoginAutoResp{
|
||||||
Result: 0,
|
Result: 0,
|
||||||
Message: "ok",
|
Message: "ok",
|
||||||
Autokey: autoKey,
|
Autokey: autoKey,
|
||||||
Userid: userid,
|
UserId: userId,
|
||||||
Ticket: ticket,
|
Ticket: ticket,
|
||||||
}
|
}
|
||||||
data, err := json.Marshal(autoResp)
|
data, err := json.Marshal(autoResp)
|
||||||
@@ -314,18 +309,10 @@ func AccountLogin(ctx *gin.Context) {
|
|||||||
// "userid" INTEGER,
|
// "userid" INTEGER,
|
||||||
// "key" INTEGER
|
// "key" INTEGER
|
||||||
// );`
|
// );`
|
||||||
stmt, err := UserEng.DB().Prepare("SELECT password,autokey,ticket,userid FROM users WHERE phone = ?")
|
var pass, autoKey, ticket, userId string
|
||||||
|
_, err = UserEng.Table("users").Cols("password,autokey,ticket,userid").Where("phone = ?", phone).
|
||||||
|
Get(&pass, &autoKey, &ticket, &userId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
var pass, autokey, ticket, userid string
|
|
||||||
rows, err := stmt.Query(phone)
|
|
||||||
CheckErr(err)
|
|
||||||
defer rows.Close()
|
|
||||||
for rows.Next() {
|
|
||||||
err = rows.Scan(&pass, &autokey, &ticket, &userid)
|
|
||||||
CheckErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
loginResp := LoginResp{}
|
loginResp := LoginResp{}
|
||||||
loginCode := 0
|
loginCode := 0
|
||||||
@@ -336,15 +323,16 @@ func AccountLogin(ctx *gin.Context) {
|
|||||||
session := UserEng.NewSession()
|
session := UserEng.NewSession()
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
|
||||||
|
// 开始会话
|
||||||
if err = session.Begin(); err != nil {
|
if err = session.Begin(); err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pass = openssl.Md5ToString(password)
|
pass = openssl.Md5ToString(password)
|
||||||
autokey = "AUTO" + strings.ToUpper(utils.RandomStr(32))
|
autoKey = "AUTO" + strings.ToUpper(utils.RandomStr(32))
|
||||||
userid = strconv.Itoa(int(loginTime))
|
userId = strconv.Itoa(int(loginTime))
|
||||||
ticket = "9999999" + userid + userid
|
ticket = "9999999" + userId + userId
|
||||||
userStmt, err := session.DB().Prepare("INSERT INTO users(phone,password,autokey,ticket,userid,last_login_time) VALUES (?,?,?,?,?,?)")
|
userStmt, err := session.DB().Prepare("INSERT INTO users(phone,password,autokey,ticket,userid,last_login_time) VALUES (?,?,?,?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
@@ -352,7 +340,7 @@ func AccountLogin(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
defer userStmt.Close()
|
defer userStmt.Close()
|
||||||
|
|
||||||
_, err = userStmt.Exec(phone, pass, autokey, ticket, userid, loginTime)
|
_, err = userStmt.Exec(phone, pass, autoKey, ticket, userId, loginTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -367,12 +355,13 @@ func AccountLogin(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 方便起见初始化 userid 和 key 一样
|
// 方便起见初始化 userid 和 key 一样
|
||||||
// 注意:user_key 表中的 key 是上文生成的用于登录的 userid,而 userid 则是用于 Authorize Token 生成用的
|
// 注意:user_key 表中的 key 是上文生成的用于登录的 userid,而 userid 则是用于 Authorize Token 生成用的
|
||||||
_, err = keyStmt.Exec(userid, userid)
|
_, err = keyStmt.Exec(userId, userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 结束会话
|
||||||
if err = session.Commit(); err != nil {
|
if err = session.Commit(); err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -381,32 +370,32 @@ func AccountLogin(ctx *gin.Context) {
|
|||||||
tools.InitUserData(int(loginTime))
|
tools.InitUserData(int(loginTime))
|
||||||
|
|
||||||
// Login Response
|
// Login Response
|
||||||
loginResp.Autokey = autokey
|
loginResp.Autokey = autoKey
|
||||||
loginResp.HasRealInfo = 1
|
loginResp.HasRealInfo = 1
|
||||||
loginResp.Message = "ok"
|
loginResp.Message = "ok"
|
||||||
loginResp.RealInfoForce = 1
|
loginResp.RealInfoForce = 1
|
||||||
loginResp.Ticket = ticket
|
loginResp.Ticket = ticket
|
||||||
loginResp.UserAttribute = "0"
|
loginResp.UserAttribute = "0"
|
||||||
loginResp.Userid = userid
|
loginResp.Userid = userId
|
||||||
} else {
|
} else {
|
||||||
// 已注册
|
// 已注册
|
||||||
if openssl.Md5ToString(password) == pass {
|
if openssl.Md5ToString(password) == pass {
|
||||||
// 密码正确
|
// 密码正确
|
||||||
// Login Response
|
// Login Response
|
||||||
loginResp.Autokey = autokey // 注意:更换设备(deviceId 发生变化)应重新生成 autokey
|
loginResp.Autokey = autoKey // 注意:更换设备(deviceId 发生变化)应重新生成 autokey
|
||||||
loginResp.HasRealInfo = 1
|
loginResp.HasRealInfo = 1
|
||||||
loginResp.Message = "ok"
|
loginResp.Message = "ok"
|
||||||
loginResp.RealInfoForce = 1
|
loginResp.RealInfoForce = 1
|
||||||
loginResp.Ticket = "9999999" + userid + strconv.Itoa(int(loginTime)) // 实际登录用的密码(每次登录都会重新生成新的)
|
loginResp.Ticket = "9999999" + userId + strconv.Itoa(int(loginTime)) // 实际登录用的密码(每次登录都会重新生成新的)
|
||||||
loginResp.UserAttribute = "0"
|
loginResp.UserAttribute = "0"
|
||||||
loginResp.Userid = userid // 实际登录用的账号
|
loginResp.Userid = userId // 实际登录用的账号
|
||||||
|
|
||||||
// 更新信息
|
// 更新信息
|
||||||
userStmt, err := UserEng.DB().Prepare("UPDATE users SET autokey=?,ticket=?,last_login_time=? WHERE userid=?")
|
userStmt, err := UserEng.DB().Prepare("UPDATE users SET autokey=?,ticket=?,last_login_time=? WHERE userid=?")
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
defer userStmt.Close()
|
defer userStmt.Close()
|
||||||
|
|
||||||
_, err = userStmt.Exec(autokey, ticket, loginTime, userid)
|
_, err = userStmt.Exec(autoKey, ticket, loginTime, userId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
// aff, _ := res.RowsAffected()
|
// aff, _ := res.RowsAffected()
|
||||||
// fmt.Println("RowsAffected:", aff)
|
// fmt.Println("RowsAffected:", aff)
|
||||||
|
|||||||
+4
-24
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -12,34 +13,13 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScenarioResp struct {
|
|
||||||
ResponseData ScenarioData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScenarioData struct {
|
|
||||||
ScenarioID int `json:"scenario_id"`
|
|
||||||
ScenarioAdjustment int `json:"scenario_adjustment"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScenarioReq struct {
|
|
||||||
Module string `json:"module"`
|
|
||||||
Action string `json:"action"`
|
|
||||||
TimeStamp int `json:"timeStamp"`
|
|
||||||
Mgd int `json:"mgd"`
|
|
||||||
CommandNum string `json:"commandNum"`
|
|
||||||
ScenarioID int `json:"scenario_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ScenarioStartup(ctx *gin.Context) {
|
func ScenarioStartup(ctx *gin.Context) {
|
||||||
startReq := ScenarioReq{}
|
startReq := model.ScenarioReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
startResp := ScenarioResp{
|
startResp := model.ScenarioResp{
|
||||||
ResponseData: ScenarioData{
|
ResponseData: model.ScenarioRes{
|
||||||
ScenarioID: startReq.ScenarioID,
|
ScenarioID: startReq.ScenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
+4
-24
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -12,34 +13,13 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SubScenarioResp struct {
|
|
||||||
ResponseData SubScenarioData `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SubScenarioData struct {
|
|
||||||
SubscenarioID int `json:"subscenario_id"`
|
|
||||||
ScenarioAdjustment int `json:"scenario_adjustment"`
|
|
||||||
ServerTimestamp int64 `json:"server_timestamp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SubScenarioReq struct {
|
|
||||||
Module string `json:"module"`
|
|
||||||
Action string `json:"action"`
|
|
||||||
TimeStamp int `json:"timeStamp"`
|
|
||||||
SubscenarioID int `json:"subscenario_id"`
|
|
||||||
Mgd int `json:"mgd"`
|
|
||||||
CommandNum string `json:"commandNum"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func SubScenarioStartup(ctx *gin.Context) {
|
func SubScenarioStartup(ctx *gin.Context) {
|
||||||
startReq := SubScenarioReq{}
|
startReq := model.SubScenarioReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
startResp := SubScenarioResp{
|
startResp := model.SubScenarioResp{
|
||||||
ResponseData: SubScenarioData{
|
ResponseData: model.SubScenarioRes{
|
||||||
SubscenarioID: startReq.SubscenarioID,
|
SubscenarioID: startReq.SubscenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
+11
-6
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -76,7 +75,7 @@ func SetDeck(ctx *gin.Context) {
|
|||||||
// 遍历新队伍
|
// 遍历新队伍
|
||||||
for _, deck := range deckReq.UnitDeckList {
|
for _, deck := range deckReq.UnitDeckList {
|
||||||
// 新队伍信息
|
// 新队伍信息
|
||||||
userDeck := tools.UserDeckData{
|
userDeck := model.UserDeckData{
|
||||||
DeckID: deck.UnitDeckID,
|
DeckID: deck.UnitDeckID,
|
||||||
MainFlag: deck.MainFlag,
|
MainFlag: deck.MainFlag,
|
||||||
DeckName: deck.DeckName,
|
DeckName: deck.DeckName,
|
||||||
@@ -94,7 +93,7 @@ func SetDeck(ctx *gin.Context) {
|
|||||||
// 队伍成员信息
|
// 队伍成员信息
|
||||||
for _, unit := range deck.UnitDeckDetail {
|
for _, unit := range deck.UnitDeckDetail {
|
||||||
// 成员信息
|
// 成员信息
|
||||||
newUnitData := tools.UnitData{}
|
newUnitData := model.UnitData{}
|
||||||
exists, err := session.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
exists, err := session.Table("user_unit_m").Where("unit_owning_user_id = ?", unit.UnitOwningUserID).Exist()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
@@ -129,7 +128,7 @@ func SetDeck(ctx *gin.Context) {
|
|||||||
// fmt.Println("新的成员信息:", newUnitData)
|
// fmt.Println("新的成员信息:", newUnitData)
|
||||||
|
|
||||||
// 插入新成员信息
|
// 插入新成员信息
|
||||||
newUnitDeckData := tools.UnitDeckData{}
|
newUnitDeckData := model.UnitDeckData{}
|
||||||
b, err := json.Marshal(newUnitData)
|
b, err := json.Marshal(newUnitData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
@@ -191,10 +190,10 @@ func SetDeckName(ctx *gin.Context) {
|
|||||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userDeck := tools.UserDeckData{
|
userDeck := model.UserDeckData{
|
||||||
DeckName: deckReq.DeckName,
|
DeckName: deckReq.DeckName,
|
||||||
}
|
}
|
||||||
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &tools.UserDeckData{
|
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &model.UserDeckData{
|
||||||
UserID: userId,
|
UserID: userId,
|
||||||
DeckID: deckReq.UnitDeckID,
|
DeckID: deckReq.UnitDeckID,
|
||||||
})
|
})
|
||||||
@@ -245,6 +244,7 @@ func WearAccessory(ctx *gin.Context) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 佩戴饰品
|
// 佩戴饰品
|
||||||
for _, v := range req.Wear {
|
for _, v := range req.Wear {
|
||||||
fmt.Println("Wear:", v.AccessoryOwningUserID, v.UnitOwningUserID)
|
fmt.Println("Wear:", v.AccessoryOwningUserID, v.UnitOwningUserID)
|
||||||
@@ -256,6 +256,8 @@ func WearAccessory(ctx *gin.Context) {
|
|||||||
_, err := session.Table("accessory_wear_m").Insert(&data)
|
_, err := session.Table("accessory_wear_m").Insert(&data)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 结束事务
|
||||||
if err := session.Commit(); err != nil {
|
if err := session.Commit(); err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -306,6 +308,7 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 佩戴宝石
|
// 佩戴宝石
|
||||||
for _, v := range req.Equip {
|
for _, v := range req.Equip {
|
||||||
fmt.Println("Equip:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
fmt.Println("Equip:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
||||||
@@ -317,6 +320,8 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
|||||||
_, err := session.Table("skill_equip_m").Insert(&data)
|
_, err := session.Table("skill_equip_m").Insert(&data)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 结束事务
|
||||||
if err := session.Commit(); err != nil {
|
if err := session.Commit(); err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
+1
-7
@@ -14,14 +14,8 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NotificationResp struct {
|
|
||||||
ResponseData []interface{} `json:"response_data"`
|
|
||||||
ReleaseInfo []interface{} `json:"release_info"`
|
|
||||||
StatusCode int `json:"status_code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetNotificationToken(ctx *gin.Context) {
|
func SetNotificationToken(ctx *gin.Context) {
|
||||||
notifResp := NotificationResp{
|
notifResp := model.NotificationResp{
|
||||||
ResponseData: []interface{}{},
|
ResponseData: []interface{}{},
|
||||||
ReleaseInfo: []interface{}{},
|
ReleaseInfo: []interface{}{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
@@ -130,7 +129,7 @@ func Upload(ctx *gin.Context) {
|
|||||||
skillExp = 29900
|
skillExp = 29900
|
||||||
}
|
}
|
||||||
|
|
||||||
unitData := tools.UnitData{
|
unitData := model.UnitData{
|
||||||
UserID: ctx.GetInt("userid"),
|
UserID: ctx.GetInt("userid"),
|
||||||
UnitID: unitId,
|
UnitID: unitId,
|
||||||
Exp: unitExp + diffExp,
|
Exp: unitExp + diffExp,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
// module: banner, action: bannerList
|
// BannerList ...
|
||||||
type BannerList struct {
|
type BannerList struct {
|
||||||
BannerType int `json:"banner_type"`
|
BannerType int `json:"banner_type"`
|
||||||
TargetID int `json:"target_id"`
|
TargetID int `json:"target_id"`
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
// Data ...
|
||||||
type Data struct {
|
type Data struct {
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
Team []Team `json:"team"`
|
Team []Team `json:"team"`
|
||||||
@@ -7,11 +8,13 @@ type Data struct {
|
|||||||
Submember []interface{} `json:"submember"`
|
Submember []interface{} `json:"submember"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accessory ...
|
||||||
type Accessory struct {
|
type Accessory struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Level int `json:"level"`
|
Level int `json:"level"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Team ...
|
||||||
type Team struct {
|
type Team struct {
|
||||||
Hp int `json:"hp"`
|
Hp int `json:"hp"`
|
||||||
Smile int `json:"smile"`
|
Smile int `json:"smile"`
|
||||||
|
|||||||
@@ -29,3 +29,27 @@ type MultiUnitScenarioStatusResp struct {
|
|||||||
CommandNum bool `json:"commandNum"`
|
CommandNum bool `json:"commandNum"`
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultiUnitStartUpResp ...
|
||||||
|
type MultiUnitStartUpResp struct {
|
||||||
|
ResponseData MultiUnitStartUpRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MultiUnitStartUpRes ...
|
||||||
|
type MultiUnitStartUpRes struct {
|
||||||
|
MultiUnitScenarioID int `json:"multi_unit_scenario_id"`
|
||||||
|
ScenarioAdjustment int `json:"scenario_adjustment"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MultiUnitStartUpReq ...
|
||||||
|
type MultiUnitStartUpReq struct {
|
||||||
|
Module string `json:"module"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
TimeStamp int `json:"timeStamp"`
|
||||||
|
Mgd int `json:"mgd"`
|
||||||
|
MultiUnitScenarioID int `json:"multi_unit_scenario_id"`
|
||||||
|
CommandNum string `json:"commandNum"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -134,3 +134,21 @@ type ProductListResp struct {
|
|||||||
CommandNum bool `json:"commandNum"`
|
CommandNum bool `json:"commandNum"`
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProductResp ...
|
||||||
|
type ProductResp struct {
|
||||||
|
ResponseData ProductRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProductRes ...
|
||||||
|
type ProductRes struct {
|
||||||
|
RestrictionInfo RestrictionInfo `json:"restriction_info"`
|
||||||
|
UnderAgeInfo UnderAgeInfo `json:"under_age_info"`
|
||||||
|
SnsProductList []interface{} `json:"sns_product_list"`
|
||||||
|
ProductList []interface{} `json:"product_list"`
|
||||||
|
SubscriptionList []interface{} `json:"subscription_list"`
|
||||||
|
ShowPointShop bool `json:"show_point_shop"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,3 +72,27 @@ type EventScenarioStatusResp struct {
|
|||||||
CommandNum bool `json:"commandNum"`
|
CommandNum bool `json:"commandNum"`
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ScenarioResp ...
|
||||||
|
type ScenarioResp struct {
|
||||||
|
ResponseData ScenarioRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScenarioRes ...
|
||||||
|
type ScenarioRes struct {
|
||||||
|
ScenarioID int `json:"scenario_id"`
|
||||||
|
ScenarioAdjustment int `json:"scenario_adjustment"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScenarioReq ...
|
||||||
|
type ScenarioReq struct {
|
||||||
|
Module string `json:"module"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
TimeStamp int `json:"timeStamp"`
|
||||||
|
Mgd int `json:"mgd"`
|
||||||
|
CommandNum string `json:"commandNum"`
|
||||||
|
ScenarioID int `json:"scenario_id"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// SubScenarioResp ...
|
||||||
|
type SubScenarioResp struct {
|
||||||
|
ResponseData SubScenarioRes `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubScenarioRes ...
|
||||||
|
type SubScenarioRes struct {
|
||||||
|
SubscenarioID int `json:"subscenario_id"`
|
||||||
|
ScenarioAdjustment int `json:"scenario_adjustment"`
|
||||||
|
ServerTimestamp int64 `json:"server_timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubScenarioReq ...
|
||||||
|
type SubScenarioReq struct {
|
||||||
|
Module string `json:"module"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
TimeStamp int `json:"timeStamp"`
|
||||||
|
SubscenarioID int `json:"subscenario_id"`
|
||||||
|
Mgd int `json:"mgd"`
|
||||||
|
CommandNum string `json:"commandNum"`
|
||||||
|
}
|
||||||
+200
@@ -0,0 +1,200 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// UnitData ...
|
||||||
|
type UnitData struct {
|
||||||
|
UnitOwningUserID int `xorm:"unit_owning_user_id pk autoincr" json:"unit_owning_user_id"`
|
||||||
|
UserID int `xorm:"user_id" json:"-"`
|
||||||
|
UnitID int `xorm:"unit_id" json:"unit_id"`
|
||||||
|
Exp int `xorm:"exp" json:"exp"`
|
||||||
|
NextExp int `xorm:"next_exp" json:"next_exp"`
|
||||||
|
Level int `xorm:"level" json:"level"`
|
||||||
|
MaxLevel int `xorm:"max_level" json:"max_level"`
|
||||||
|
LevelLimitID int `xorm:"level_limit_id" json:"level_limit_id"`
|
||||||
|
Rank int `xorm:"rank" json:"rank"`
|
||||||
|
MaxRank int `xorm:"max_rank" json:"max_rank"`
|
||||||
|
Love int `xorm:"love" json:"love"`
|
||||||
|
MaxLove int `xorm:"max_love" json:"max_love"`
|
||||||
|
UnitSkillExp int `xorm:"unit_skill_exp" json:"unit_skill_exp"`
|
||||||
|
UnitSkillLevel int `xorm:"unit_skill_level" json:"unit_skill_level"`
|
||||||
|
MaxHp int `xorm:"max_hp" json:"max_hp"`
|
||||||
|
UnitRemovableSkillCapacity int `xorm:"unit_removable_skill_capacity" json:"unit_removable_skill_capacity"`
|
||||||
|
FavoriteFlag bool `xorm:"favorite_flag" json:"favorite_flag"`
|
||||||
|
DisplayRank int `xorm:"display_rank" json:"display_rank"`
|
||||||
|
IsRankMax bool `xorm:"is_rank_max" json:"is_rank_max"`
|
||||||
|
IsLoveMax bool `xorm:"is_love_max" json:"is_love_max"`
|
||||||
|
IsLevelMax bool `xorm:"is_level_max" json:"is_level_max"`
|
||||||
|
IsSigned bool `xorm:"is_signed" json:"is_signed"`
|
||||||
|
IsSkillLevelMax bool `xorm:"is_skill_level_max" json:"is_skill_level_max"`
|
||||||
|
IsRemovableSkillCapacityMax bool `xorm:"is_removable_skill_capacity_max" json:"is_removable_skill_capacity_max"`
|
||||||
|
InsertDate string `xorm:"insert_date" json:"insert_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserDeckData ...
|
||||||
|
type UserDeckData struct {
|
||||||
|
ID int `xorm:"id pk autoincr"`
|
||||||
|
DeckID int `xorm:"deck_id"`
|
||||||
|
MainFlag int `xorm:"main_flag"`
|
||||||
|
DeckName string `xorm:"deck_name"`
|
||||||
|
UserID int `xorm:"user_id"`
|
||||||
|
InsertDate int64 `xorm:"insert_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnitDeckData ...
|
||||||
|
type UnitDeckData struct {
|
||||||
|
ID int `xorm:"id pk autoincr" json:"-"`
|
||||||
|
UserDeckID int `xorm:"user_deck_id" json:"-"`
|
||||||
|
UnitOwningUserID int `xorm:"unit_owning_user_id" json:"unit_owning_user_id"`
|
||||||
|
UnitID int `xorm:"unit_id" json:"unit_id"`
|
||||||
|
Position int `xorm:"position" json:"position"`
|
||||||
|
Level int `xorm:"level" json:"level"`
|
||||||
|
LevelLimitID int `xorm:"level_limit_id" json:"level_limit_id"`
|
||||||
|
DisplayRank int `xorm:"display_rank" json:"display_rank"`
|
||||||
|
Love int `xorm:"love" json:"love"`
|
||||||
|
UnitSkillLevel int `xorm:"unit_skill_level" json:"unit_skill_level"`
|
||||||
|
IsRankMax bool `xorm:"is_rank_max" json:"is_rank_max"`
|
||||||
|
IsLoveMax bool `xorm:"is_love_max" json:"is_love_max"`
|
||||||
|
IsLevelMax bool `xorm:"is_level_max" json:"is_level_max"`
|
||||||
|
IsSigned bool `xorm:"is_signed" json:"is_signed"`
|
||||||
|
BeforeLove int `xorm:"before_love" json:"before_love"`
|
||||||
|
MaxLove int `xorm:"max_love" json:"max_love"`
|
||||||
|
InsertData int64 `xorm:"insert_date" json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DifficultyRes ...
|
||||||
|
type DifficultyRes struct {
|
||||||
|
Difficulty int `json:"difficulty"`
|
||||||
|
ClearCnt int `json:"clear_cnt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DifficultyResp ...
|
||||||
|
type DifficultyResp struct {
|
||||||
|
Result []DifficultyRes `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoveResp ...
|
||||||
|
type LoveResp struct {
|
||||||
|
Result []interface{} `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessoryInfo ...
|
||||||
|
type AccessoryInfo struct {
|
||||||
|
AccessoryOwningUserID int `json:"accessory_owning_user_id"`
|
||||||
|
AccessoryID int `json:"accessory_id"`
|
||||||
|
Exp int `json:"exp"`
|
||||||
|
NextExp int `json:"next_exp"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
MaxLevel int `json:"max_level"`
|
||||||
|
RankUpCount int `json:"rank_up_count"`
|
||||||
|
FavoriteFlag bool `json:"favorite_flag"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfileUserInfo ...
|
||||||
|
type ProfileUserInfo struct {
|
||||||
|
UserID int `json:"user_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
CostMax int `json:"cost_max"`
|
||||||
|
UnitMax int `json:"unit_max"`
|
||||||
|
EnergyMax int `json:"energy_max"`
|
||||||
|
FriendMax int `json:"friend_max"`
|
||||||
|
UnitCnt int `json:"unit_cnt"`
|
||||||
|
InviteCode string `json:"invite_code"`
|
||||||
|
ElapsedTimeFromLogin string `json:"elapsed_time_from_login"`
|
||||||
|
Introduction string `json:"introduction"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CenterUnitInfo ...
|
||||||
|
type CenterUnitInfo struct {
|
||||||
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
|
UnitID int `json:"unit_id"`
|
||||||
|
Exp int `json:"exp"`
|
||||||
|
NextExp int `json:"next_exp"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
LevelLimitID int `json:"level_limit_id"`
|
||||||
|
MaxLevel int `json:"max_level"`
|
||||||
|
Rank int `json:"rank"`
|
||||||
|
MaxRank int `json:"max_rank"`
|
||||||
|
Love int `json:"love"`
|
||||||
|
MaxLove int `json:"max_love"`
|
||||||
|
UnitSkillLevel int `json:"unit_skill_level"`
|
||||||
|
MaxHp int `json:"max_hp"`
|
||||||
|
FavoriteFlag bool `json:"favorite_flag"`
|
||||||
|
DisplayRank int `json:"display_rank"`
|
||||||
|
UnitSkillExp int `json:"unit_skill_exp"`
|
||||||
|
UnitRemovableSkillCapacity int `json:"unit_removable_skill_capacity"`
|
||||||
|
Attribute int `json:"attribute"`
|
||||||
|
Smile int `json:"smile"`
|
||||||
|
Cute int `json:"cute"`
|
||||||
|
Cool int `json:"cool"`
|
||||||
|
IsLoveMax bool `json:"is_love_max"`
|
||||||
|
IsLevelMax bool `json:"is_level_max"`
|
||||||
|
IsRankMax bool `json:"is_rank_max"`
|
||||||
|
IsSigned bool `json:"is_signed"`
|
||||||
|
IsSkillLevelMax bool `json:"is_skill_level_max"`
|
||||||
|
SettingAwardID int `json:"setting_award_id"`
|
||||||
|
RemovableSkillIds []int `json:"removable_skill_ids"`
|
||||||
|
AccessoryInfo AccessoryInfo `json:"accessory_info"`
|
||||||
|
Costume Costume `json:"costume"`
|
||||||
|
TotalSmile int `json:"total_smile"`
|
||||||
|
TotalCute int `json:"total_cute"`
|
||||||
|
TotalCool int `json:"total_cool"`
|
||||||
|
TotalHp int `json:"total_hp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NaviUnitInfo ...
|
||||||
|
type NaviUnitInfo struct {
|
||||||
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
|
UnitID int `json:"unit_id"`
|
||||||
|
Exp int `json:"exp"`
|
||||||
|
NextExp int `json:"next_exp"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
MaxLevel int `json:"max_level"`
|
||||||
|
LevelLimitID int `json:"level_limit_id"`
|
||||||
|
Rank int `json:"rank"`
|
||||||
|
MaxRank int `json:"max_rank"`
|
||||||
|
Love int `json:"love"`
|
||||||
|
MaxLove int `json:"max_love"`
|
||||||
|
UnitSkillExp int `json:"unit_skill_exp"`
|
||||||
|
UnitSkillLevel int `json:"unit_skill_level"`
|
||||||
|
MaxHp int `json:"max_hp"`
|
||||||
|
UnitRemovableSkillCapacity int `json:"unit_removable_skill_capacity"`
|
||||||
|
FavoriteFlag bool `json:"favorite_flag"`
|
||||||
|
DisplayRank int `json:"display_rank"`
|
||||||
|
IsRankMax bool `json:"is_rank_max"`
|
||||||
|
IsLoveMax bool `json:"is_love_max"`
|
||||||
|
IsLevelMax bool `json:"is_level_max"`
|
||||||
|
IsSigned bool `json:"is_signed"`
|
||||||
|
IsSkillLevelMax bool `json:"is_skill_level_max"`
|
||||||
|
IsRemovableSkillCapacityMax bool `json:"is_removable_skill_capacity_max"`
|
||||||
|
InsertDate string `json:"insert_date"`
|
||||||
|
TotalSmile int `json:"total_smile"`
|
||||||
|
TotalCute int `json:"total_cute"`
|
||||||
|
TotalCool int `json:"total_cool"`
|
||||||
|
TotalHp int `json:"total_hp"`
|
||||||
|
RemovableSkillIds []int `json:"removable_skill_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfileRes ...
|
||||||
|
type ProfileRes struct {
|
||||||
|
UserInfo ProfileUserInfo `json:"user_info"`
|
||||||
|
CenterUnitInfo CenterUnitInfo `json:"center_unit_info"`
|
||||||
|
NaviUnitInfo NaviUnitInfo `json:"navi_unit_info"`
|
||||||
|
IsAlliance bool `json:"is_alliance"`
|
||||||
|
FriendStatus int `json:"friend_status"`
|
||||||
|
SettingAwardID int `json:"setting_award_id"`
|
||||||
|
SettingBackgroundID int `json:"setting_background_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfileResp ...
|
||||||
|
type ProfileResp struct {
|
||||||
|
Result ProfileRes `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
@@ -39,3 +39,10 @@ type UserNaviResp struct {
|
|||||||
CommandNum bool `json:"commandNum"`
|
CommandNum bool `json:"commandNum"`
|
||||||
TimeStamp int64 `json:"timeStamp"`
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotificationResp ...
|
||||||
|
type NotificationResp struct {
|
||||||
|
ResponseData []interface{} `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
// Msg ...
|
||||||
type Msg struct {
|
type Msg struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
package tools
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
type AccessoryData struct {
|
|
||||||
AccessoryId int `xorm:"accessory_id"`
|
|
||||||
SmileMax int `xorm:"smile_max"`
|
|
||||||
PureMax int `xorm:"pure_max"`
|
|
||||||
CoolMax int `xorm:"cool_max"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CommonAccessoryData struct {
|
|
||||||
AccessoryOwningUserId int `xorm:"accessory_owning_user_id pk autoincr"`
|
|
||||||
AccessoryId int `xorm:"accessory_id"`
|
|
||||||
Exp int `xorm:"exp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProcessAccessoryData() {
|
|
||||||
var accessoryData []AccessoryData
|
|
||||||
err := MainEng.Table("accessory_m").Where("max_level = 8 AND rarity = 4").Cols("accessory_id,smile_max,pure_max,cool_max").Find(&accessoryData)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
for _, data := range accessoryData {
|
|
||||||
var exp int
|
|
||||||
exists, err := MainEng.Table("accessory_level_m").Where("accessory_id = ?", data.AccessoryId).Select("MAX(next_exp)").Get(&exp)
|
|
||||||
CheckErr(err)
|
|
||||||
if !exists {
|
|
||||||
fmt.Println("LOL")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
commonData := CommonAccessoryData{
|
|
||||||
AccessoryId: data.AccessoryId,
|
|
||||||
Exp: exp,
|
|
||||||
}
|
|
||||||
// fmt.Println(commonData)
|
|
||||||
// 每种饰品生成9个
|
|
||||||
for i := 0; i < 9; i++ {
|
|
||||||
affected, err := MainEng.Table("common_accessory_m").Insert(&commonData)
|
|
||||||
CheckErr(err)
|
|
||||||
fmt.Printf("Time: %d, Aff: %d\n", i, affected)
|
|
||||||
|
|
||||||
commonData.AccessoryOwningUserId += i + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-273
@@ -1,273 +0,0 @@
|
|||||||
package tools
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"honoka-chan/model"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UnitData struct {
|
|
||||||
UnitOwningUserID int `xorm:"unit_owning_user_id pk autoincr" json:"unit_owning_user_id"`
|
|
||||||
UserID int `xorm:"user_id" json:"-"`
|
|
||||||
UnitID int `xorm:"unit_id" json:"unit_id"`
|
|
||||||
Exp int `xorm:"exp" json:"exp"`
|
|
||||||
NextExp int `xorm:"next_exp" json:"next_exp"`
|
|
||||||
Level int `xorm:"level" json:"level"`
|
|
||||||
MaxLevel int `xorm:"max_level" json:"max_level"`
|
|
||||||
LevelLimitID int `xorm:"level_limit_id" json:"level_limit_id"`
|
|
||||||
Rank int `xorm:"rank" json:"rank"`
|
|
||||||
MaxRank int `xorm:"max_rank" json:"max_rank"`
|
|
||||||
Love int `xorm:"love" json:"love"`
|
|
||||||
MaxLove int `xorm:"max_love" json:"max_love"`
|
|
||||||
UnitSkillExp int `xorm:"unit_skill_exp" json:"unit_skill_exp"`
|
|
||||||
UnitSkillLevel int `xorm:"unit_skill_level" json:"unit_skill_level"`
|
|
||||||
MaxHp int `xorm:"max_hp" json:"max_hp"`
|
|
||||||
UnitRemovableSkillCapacity int `xorm:"unit_removable_skill_capacity" json:"unit_removable_skill_capacity"`
|
|
||||||
FavoriteFlag bool `xorm:"favorite_flag" json:"favorite_flag"`
|
|
||||||
DisplayRank int `xorm:"display_rank" json:"display_rank"`
|
|
||||||
IsRankMax bool `xorm:"is_rank_max" json:"is_rank_max"`
|
|
||||||
IsLoveMax bool `xorm:"is_love_max" json:"is_love_max"`
|
|
||||||
IsLevelMax bool `xorm:"is_level_max" json:"is_level_max"`
|
|
||||||
IsSigned bool `xorm:"is_signed" json:"is_signed"`
|
|
||||||
IsSkillLevelMax bool `xorm:"is_skill_level_max" json:"is_skill_level_max"`
|
|
||||||
IsRemovableSkillCapacityMax bool `xorm:"is_removable_skill_capacity_max" json:"is_removable_skill_capacity_max"`
|
|
||||||
InsertDate string `xorm:"insert_date" json:"insert_date"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserDeckData struct {
|
|
||||||
ID int `xorm:"id pk autoincr"`
|
|
||||||
DeckID int `xorm:"deck_id"`
|
|
||||||
MainFlag int `xorm:"main_flag"`
|
|
||||||
DeckName string `xorm:"deck_name"`
|
|
||||||
UserID int `xorm:"user_id"`
|
|
||||||
InsertDate int64 `xorm:"insert_date"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UnitDeckData struct {
|
|
||||||
ID int `xorm:"id pk autoincr" json:"-"`
|
|
||||||
UserDeckID int `xorm:"user_deck_id" json:"-"`
|
|
||||||
UnitOwningUserID int `xorm:"unit_owning_user_id" json:"unit_owning_user_id"`
|
|
||||||
UnitID int `xorm:"unit_id" json:"unit_id"`
|
|
||||||
Position int `xorm:"position" json:"position"`
|
|
||||||
Level int `xorm:"level" json:"level"`
|
|
||||||
LevelLimitID int `xorm:"level_limit_id" json:"level_limit_id"`
|
|
||||||
DisplayRank int `xorm:"display_rank" json:"display_rank"`
|
|
||||||
Love int `xorm:"love" json:"love"`
|
|
||||||
UnitSkillLevel int `xorm:"unit_skill_level" json:"unit_skill_level"`
|
|
||||||
IsRankMax bool `xorm:"is_rank_max" json:"is_rank_max"`
|
|
||||||
IsLoveMax bool `xorm:"is_love_max" json:"is_love_max"`
|
|
||||||
IsLevelMax bool `xorm:"is_level_max" json:"is_level_max"`
|
|
||||||
IsSigned bool `xorm:"is_signed" json:"is_signed"`
|
|
||||||
BeforeLove int `xorm:"before_love" json:"before_love"`
|
|
||||||
MaxLove int `xorm:"max_love" json:"max_love"`
|
|
||||||
InsertData int64 `xorm:"insert_date" json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlbumSeries struct {
|
|
||||||
UnitID int `json:"unit_id"`
|
|
||||||
AlbumSeriesID int `json:"album_series_id"`
|
|
||||||
Rarity int `json:"rarity"`
|
|
||||||
RankMin int `json:"rank_min"`
|
|
||||||
RankMax int `json:"rank_max"`
|
|
||||||
HpMax int `json:"hp_max"`
|
|
||||||
DefaultRemovableSkillCapacity int `json:"default_removable_skill_capacity"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func GenCommonUnitData2() {
|
|
||||||
sql := `SELECT unit_id,album_series_id,rarity,rank_min,rank_max,hp_max,default_removable_skill_capacity FROM unit_m WHERE unit_id NOT IN (SELECT unit_id FROM unit_m WHERE unit_type_id IN (SELECT unit_type_id FROM unit_type_m WHERE image_button_asset IS NULL AND (background_color = 'dcdbe3' AND original_attribute_id IS NULL) OR (unit_type_id IN (10,110,127,128,129) OR unit_type_id BETWEEN 131 AND 140))) ORDER BY unit_number ASC`
|
|
||||||
rows, err := MainEng.QueryInterface(sql)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
rb, err := json.Marshal(rows)
|
|
||||||
CheckErr(err)
|
|
||||||
// fmt.Println(string(rb))
|
|
||||||
|
|
||||||
// 默认卡组
|
|
||||||
userDeck := UserDeckData{
|
|
||||||
DeckID: 1,
|
|
||||||
MainFlag: 1,
|
|
||||||
DeckName: "Default deck",
|
|
||||||
UserID: 1,
|
|
||||||
InsertDate: time.Now().Unix(),
|
|
||||||
}
|
|
||||||
_, err = UserEng.Table("user_deck_m").Insert(&userDeck)
|
|
||||||
CheckErr(err)
|
|
||||||
userDeckId := userDeck.ID
|
|
||||||
fmt.Println("userDeckId:", userDeckId)
|
|
||||||
|
|
||||||
position := 1
|
|
||||||
|
|
||||||
albums := []AlbumSeries{}
|
|
||||||
if err = json.Unmarshal(rb, &albums); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
startTime := time.Now().Add(-time.Hour * 24 * 30)
|
|
||||||
for _, v := range albums {
|
|
||||||
unitData := UnitData{}
|
|
||||||
startTime = startTime.Add(time.Second * 3)
|
|
||||||
|
|
||||||
unitData.UnitID = v.UnitID
|
|
||||||
unitData.NextExp = 0
|
|
||||||
unitData.Rank = v.RankMin
|
|
||||||
unitData.MaxRank = v.RankMax
|
|
||||||
unitData.MaxHp = v.HpMax
|
|
||||||
unitData.DisplayRank = 2
|
|
||||||
unitData.UnitSkillLevel = 8
|
|
||||||
unitData.FavoriteFlag = true
|
|
||||||
unitData.IsRankMax = true
|
|
||||||
unitData.IsLevelMax = true
|
|
||||||
unitData.IsLoveMax = true
|
|
||||||
unitData.IsSkillLevelMax = true
|
|
||||||
unitData.IsRemovableSkillCapacityMax = true
|
|
||||||
unitData.InsertDate = startTime.Local().Format("2006-01-02 03:04:05")
|
|
||||||
if v.Rarity != 4 {
|
|
||||||
unitData.LevelLimitID = 0
|
|
||||||
unitData.UnitRemovableSkillCapacity = v.DefaultRemovableSkillCapacity
|
|
||||||
unitData.IsSigned = false
|
|
||||||
switch v.Rarity {
|
|
||||||
case 1:
|
|
||||||
// N
|
|
||||||
unitData.Exp = 8000
|
|
||||||
unitData.Level = 40
|
|
||||||
unitData.MaxLevel = 40
|
|
||||||
unitData.Love = 50
|
|
||||||
unitData.MaxLove = 50
|
|
||||||
unitData.UnitSkillExp = 0
|
|
||||||
unitData.UnitSkillLevel = 0
|
|
||||||
unitData.FavoriteFlag = false
|
|
||||||
unitData.IsRankMax = false
|
|
||||||
unitData.IsLevelMax = false
|
|
||||||
unitData.IsLoveMax = false
|
|
||||||
unitData.IsSkillLevelMax = false
|
|
||||||
unitData.IsRemovableSkillCapacityMax = false
|
|
||||||
case 2:
|
|
||||||
// R
|
|
||||||
unitData.Exp = 13500
|
|
||||||
unitData.Level = 60
|
|
||||||
unitData.MaxLevel = 60
|
|
||||||
unitData.Love = 200
|
|
||||||
unitData.MaxLove = 200
|
|
||||||
unitData.UnitSkillExp = 490
|
|
||||||
case 3:
|
|
||||||
// SR
|
|
||||||
unitData.Exp = 36800
|
|
||||||
unitData.Level = 80
|
|
||||||
unitData.MaxLevel = 80
|
|
||||||
unitData.Love = 500
|
|
||||||
unitData.MaxLove = 500
|
|
||||||
unitData.UnitSkillExp = 4900
|
|
||||||
case 5:
|
|
||||||
// SSR
|
|
||||||
unitData.Exp = 56657
|
|
||||||
unitData.Level = 90
|
|
||||||
unitData.MaxLevel = 90
|
|
||||||
unitData.Love = 750
|
|
||||||
unitData.MaxLove = 750
|
|
||||||
unitData.UnitSkillExp = 12700
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// UR
|
|
||||||
unitData.Exp = 79700
|
|
||||||
unitData.Level = 100
|
|
||||||
unitData.MaxLevel = 100
|
|
||||||
unitData.LevelLimitID = 1
|
|
||||||
unitData.Love = 1000
|
|
||||||
unitData.MaxLove = 1000
|
|
||||||
unitData.UnitSkillExp = 29900
|
|
||||||
unitData.UnitRemovableSkillCapacity = 8
|
|
||||||
|
|
||||||
stmt, err := MainEng.DB().Prepare("SELECT COUNT(*) AS ct FROM unit_sign_asset_m WHERE unit_id = ?")
|
|
||||||
CheckErr(err)
|
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
var ct int
|
|
||||||
err = stmt.QueryRow(v.UnitID).Scan(&ct)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
if ct > 0 {
|
|
||||||
unitData.IsSigned = true
|
|
||||||
} else {
|
|
||||||
unitData.IsSigned = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = MainEng.Table("common_unit_m").Insert(&unitData)
|
|
||||||
CheckErr(err)
|
|
||||||
// fmt.Println("Inserted ID:", unitData.UnitOwningUserID)
|
|
||||||
|
|
||||||
// 默认卡组
|
|
||||||
if v.AlbumSeriesID == 615 { // 仆光套
|
|
||||||
unitDeckData := UnitDeckData{
|
|
||||||
UserDeckID: userDeckId,
|
|
||||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
|
||||||
UnitID: v.UnitID,
|
|
||||||
Position: position,
|
|
||||||
Level: 100,
|
|
||||||
LevelLimitID: 1,
|
|
||||||
DisplayRank: 2,
|
|
||||||
Love: 1000,
|
|
||||||
UnitSkillLevel: 8,
|
|
||||||
IsRankMax: true,
|
|
||||||
IsLoveMax: true,
|
|
||||||
IsLevelMax: true,
|
|
||||||
IsSigned: unitData.IsSigned,
|
|
||||||
BeforeLove: 1000,
|
|
||||||
MaxLove: 1000,
|
|
||||||
InsertData: time.Now().Unix(),
|
|
||||||
}
|
|
||||||
|
|
||||||
// 入库
|
|
||||||
_, err = UserEng.Table("deck_unit_m").Insert(&unitDeckData)
|
|
||||||
CheckErr(err)
|
|
||||||
deckUnitId := unitDeckData.ID
|
|
||||||
fmt.Println("deckUnitId:", deckUnitId)
|
|
||||||
|
|
||||||
//
|
|
||||||
position++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GenCommonUnitData3() {
|
|
||||||
uId := 1681205441 // Hardcode for now
|
|
||||||
userDeck := []UserDeckData{}
|
|
||||||
err := UserEng.Table("user_deck_m").Where("user_id = ?", uId).Asc("deck_id").Find(&userDeck)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
unitDeckInfo := []model.UnitDeckInfoRes{}
|
|
||||||
for _, deck := range userDeck {
|
|
||||||
deckUnit := []UnitDeckData{}
|
|
||||||
err = UserEng.Table("deck_unit_m").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
oUids := []model.UnitOwningUserIds{}
|
|
||||||
for _, unit := range deckUnit {
|
|
||||||
oUids = append(oUids, model.UnitOwningUserIds{
|
|
||||||
Position: unit.Position,
|
|
||||||
UnitOwningUserID: unit.UnitOwningUserID,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
mainFlag := false
|
|
||||||
if deck.MainFlag == 1 {
|
|
||||||
mainFlag = true
|
|
||||||
}
|
|
||||||
unitDeckInfo = append(unitDeckInfo, model.UnitDeckInfoRes{
|
|
||||||
UnitDeckID: deck.DeckID,
|
|
||||||
MainFlag: mainFlag,
|
|
||||||
DeckName: deck.DeckName,
|
|
||||||
UnitOwningUserIds: oUids,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.Marshal(unitDeckInfo)
|
|
||||||
CheckErr(err)
|
|
||||||
fmt.Println(string(b))
|
|
||||||
}
|
|
||||||
|
|
||||||
func GenCommonUnitData() {
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package tools
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GenDownloadDb() {
|
|
||||||
// Create table
|
|
||||||
// CREATE TABLE "download_m" (
|
|
||||||
// "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
// "pkg_type" integer,
|
|
||||||
// "pkg_id" integer,
|
|
||||||
// "pkg_order" integer,
|
|
||||||
// "pkg_size" integer,
|
|
||||||
// "pkg_os" TEXT
|
|
||||||
// );
|
|
||||||
fileLists, err := os.ReadDir("F:/sif_dl/list_CN_Android")
|
|
||||||
CheckErr(err)
|
|
||||||
for _, v := range fileLists {
|
|
||||||
if v.IsDir() {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fileList := "F:/sif_dl/list_CN_Android/" + v.Name()
|
|
||||||
fileStat, err := os.Stat(fileList)
|
|
||||||
CheckErr(err)
|
|
||||||
pkgSize := fileStat.Size()
|
|
||||||
fileInfo := strings.Split(strings.ReplaceAll(v.Name(), ".zip", ""), "_")
|
|
||||||
pkgType, pkgId, pkgOrder := fileInfo[0], fileInfo[1], fileInfo[2]
|
|
||||||
fmt.Printf("Android: %s - %s - %s - %d\n", pkgType, pkgId, pkgOrder, pkgSize)
|
|
||||||
|
|
||||||
stmt, err := MainEng.DB().Prepare("INSERT INTO download_m(pkg_type,pkg_id,pkg_order,pkg_size,pkg_os) VALUES (?,?,?,?,?)")
|
|
||||||
CheckErr(err)
|
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
res, err := stmt.Exec(pkgType, pkgId, pkgOrder, pkgSize, "Android")
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
id, err := res.LastInsertId()
|
|
||||||
CheckErr(err)
|
|
||||||
fmt.Println("LastInsertId:", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
fileLists, err = os.ReadDir("F:/sif_dl/list_CN_iOS")
|
|
||||||
CheckErr(err)
|
|
||||||
for _, v := range fileLists {
|
|
||||||
if v.IsDir() {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fileList := "F:/sif_dl/list_CN_iOS/" + v.Name()
|
|
||||||
fileStat, err := os.Stat(fileList)
|
|
||||||
CheckErr(err)
|
|
||||||
pkgSize := fileStat.Size()
|
|
||||||
fileInfo := strings.Split(strings.ReplaceAll(v.Name(), ".zip", ""), "_")
|
|
||||||
pkgType, pkgId, pkgOrder := fileInfo[0], fileInfo[1], fileInfo[2]
|
|
||||||
fmt.Printf("iOS: %s - %s - %s - %d\n", pkgType, pkgId, pkgOrder, pkgSize)
|
|
||||||
|
|
||||||
stmt, err := MainEng.DB().Prepare("INSERT INTO download_m(pkg_type,pkg_id,pkg_order,pkg_size,pkg_os) VALUES (?,?,?,?,?)")
|
|
||||||
CheckErr(err)
|
|
||||||
defer stmt.Close()
|
|
||||||
|
|
||||||
res, err := stmt.Exec(pkgType, pkgId, pkgOrder, pkgSize, "iOS")
|
|
||||||
CheckErr(err)
|
|
||||||
|
|
||||||
id, err := res.LastInsertId()
|
|
||||||
CheckErr(err)
|
|
||||||
fmt.Println("LastInsertId:", id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-1134
File diff suppressed because it is too large
Load Diff
+13
-11
@@ -2,6 +2,8 @@ package tools
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"honoka-chan/config"
|
||||||
|
"honoka-chan/model"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,14 +32,14 @@ type UserPref struct {
|
|||||||
func InitUserData(userId int) {
|
func InitUserData(userId int) {
|
||||||
userList := []UserData{}
|
userList := []UserData{}
|
||||||
if userId != 0 {
|
if userId != 0 {
|
||||||
err := UserEng.Table("users").Where("userid = ?", userId).Find(&userList)
|
err := config.UserEng.Table("users").Where("userid = ?", userId).Find(&userList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
} else {
|
} else {
|
||||||
err := UserEng.Table("users").Asc("id").Find(&userList)
|
err := config.UserEng.Table("users").Asc("id").Find(&userList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
session := UserEng.NewSession()
|
session := config.UserEng.NewSession()
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
|
||||||
if err := session.Begin(); err != nil {
|
if err := session.Begin(); err != nil {
|
||||||
@@ -46,13 +48,13 @@ func InitUserData(userId int) {
|
|||||||
|
|
||||||
for _, user := range userList {
|
for _, user := range userList {
|
||||||
// 检查用户配置
|
// 检查用户配置
|
||||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", user.UserID).Exist()
|
exists, err := config.UserEng.Table("user_preference_m").Where("user_id = ?", user.UserID).Exist()
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
// 默认中心成员()
|
// 默认中心成员()
|
||||||
var oId int
|
var oId int
|
||||||
_, err = MainEng.Table("common_unit_m").Cols("unit_owning_user_id").Where("unit_id = ?", 31).Get(&oId)
|
_, err = config.MainEng.Table("common_unit_m").Cols("unit_owning_user_id").Where("unit_id = ?", 31).Get(&oId)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
fmt.Println("Center UnitOwningUserID:", oId)
|
fmt.Println("Center UnitOwningUserID:", oId)
|
||||||
userPref := UserPref{
|
userPref := UserPref{
|
||||||
@@ -71,12 +73,12 @@ func InitUserData(userId int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户卡组配置
|
// 检查用户卡组配置
|
||||||
exists, err = UserEng.Table("user_deck_m").Where("user_id = ?", user.UserID).Asc("deck_id").Exist()
|
exists, err = config.UserEng.Table("user_deck_m").Where("user_id = ?", user.UserID).Asc("deck_id").Exist()
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
fmt.Println("UserDeck exists:", exists)
|
fmt.Println("UserDeck exists:", exists)
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
userDeck := UserDeckData{
|
userDeck := model.UserDeckData{
|
||||||
DeckID: 1,
|
DeckID: 1,
|
||||||
MainFlag: 1,
|
MainFlag: 1,
|
||||||
DeckName: "队伍A",
|
DeckName: "队伍A",
|
||||||
@@ -95,14 +97,14 @@ func InitUserData(userId int) {
|
|||||||
|
|
||||||
// 默认卡组
|
// 默认卡组
|
||||||
unitIds := []int{}
|
unitIds := []int{}
|
||||||
err = MainEng.Table("unit_m").Cols("unit_id").Where("album_series_id = ?", 615).Find(&unitIds)
|
err = config.MainEng.Table("unit_m").Cols("unit_id").Where("album_series_id = ?", 615).Find(&unitIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
unitData := []UnitData{}
|
unitData := []model.UnitData{}
|
||||||
err = MainEng.Table("common_unit_m").In("unit_id", unitIds).Find(&unitData)
|
err = config.MainEng.Table("common_unit_m").In("unit_id", unitIds).Find(&unitData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Rollback()
|
session.Rollback()
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -111,7 +113,7 @@ func InitUserData(userId int) {
|
|||||||
|
|
||||||
position := 1
|
position := 1
|
||||||
for _, unit := range unitData {
|
for _, unit := range unitData {
|
||||||
unitDeckData := UnitDeckData{
|
unitDeckData := model.UnitDeckData{
|
||||||
UserDeckID: userDeckId,
|
UserDeckID: userDeckId,
|
||||||
UnitOwningUserID: unit.UnitOwningUserID,
|
UnitOwningUserID: unit.UnitOwningUserID,
|
||||||
UnitID: unit.UnitID,
|
UnitID: unit.UnitID,
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
package tools
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"honoka-chan/utils"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SyncNotesList() {
|
|
||||||
defer func() {
|
|
||||||
fmt.Println("Sync notes list done!")
|
|
||||||
}()
|
|
||||||
|
|
||||||
sql := `SELECT live_setting_id,notes_setting_asset FROM live_setting_m ORDER BY live_setting_id ASC`
|
|
||||||
rows, err := MainEng.DB().Query(sql)
|
|
||||||
CheckErr(err)
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
liveList := make(map[int]string)
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
var id int
|
|
||||||
var asset string
|
|
||||||
err = rows.Scan(&id, &asset)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
liveList[id] = asset
|
|
||||||
}
|
|
||||||
rows.Close()
|
|
||||||
|
|
||||||
// fmt.Println(liveList)
|
|
||||||
|
|
||||||
for _, asset := range liveList {
|
|
||||||
url := "https://card.niconi.co.ni/live/" + asset
|
|
||||||
fmt.Println(url)
|
|
||||||
|
|
||||||
res, err := http.Get(url)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if res.StatusCode == http.StatusNotFound {
|
|
||||||
fmt.Println(res.StatusCode)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
body, err := io.ReadAll(res.Body)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
_ = res.Body.Close()
|
|
||||||
// fmt.Println(string(body))
|
|
||||||
|
|
||||||
regex := regexp.MustCompile("var lives = (.*?)\n")
|
|
||||||
matchs := regex.FindSubmatch(body)
|
|
||||||
match := string(matchs[len(matchs)-1])
|
|
||||||
|
|
||||||
match = strings.ReplaceAll(match, "{\\\"", "{\"")
|
|
||||||
match = strings.ReplaceAll(match, "\\\":", "\":")
|
|
||||||
match = strings.ReplaceAll(match, ",\\\"", ",\"")
|
|
||||||
match = strings.ReplaceAll(match, "notes_list\":\"", "notes_list\":")
|
|
||||||
match = strings.ReplaceAll(match, "]\"}]", "]}]")
|
|
||||||
|
|
||||||
var notesList string
|
|
||||||
gjson.Parse(match).ForEach(func(key, value gjson.Result) bool {
|
|
||||||
notesList = value.Get("notes_list").String()
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
// fmt.Println(notesList)
|
|
||||||
|
|
||||||
if notesList == "" {
|
|
||||||
fmt.Println("notes_list is null")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
notesDir := "./assets/notes"
|
|
||||||
_, err = os.Stat(notesDir)
|
|
||||||
if err != nil {
|
|
||||||
err = os.MkdirAll(notesDir, 0755)
|
|
||||||
CheckErr(err)
|
|
||||||
}
|
|
||||||
utils.WriteAllText(path.Join(notesDir, asset), notesList)
|
|
||||||
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +1,7 @@
|
|||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
|
||||||
"honoka-chan/config"
|
|
||||||
|
|
||||||
"xorm.io/xorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
MainEng *xorm.Engine
|
|
||||||
UserEng *xorm.Engine
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
MainEng = config.MainEng
|
|
||||||
UserEng = config.UserEng
|
|
||||||
|
|
||||||
// go SyncNotesList()
|
|
||||||
// GenDownloadDb()
|
|
||||||
// GenCommonUnitData()
|
|
||||||
InitUserData(0)
|
InitUserData(0)
|
||||||
// ProcessAccessoryData()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckErr(err error) {
|
func CheckErr(err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user