Implement more endpoints & overhaul [2/n]
Drop LevelDB and move all the things to SQLite. Implemented endpoints: /api <unit, accessoryMaterialAll> /api <unit, accessoryTab> /live/continue /live/partyList /unit/favoriteAccessory (WIP) /unit/sale Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -14,6 +14,4 @@ LoveLive! 学园偶像祭 自用私服。
|
|||||||
- 虹原翼 (yazawa@niconi.co.ni) @ [LLSIF 查卡器
|
- 虹原翼 (yazawa@niconi.co.ni) @ [LLSIF 查卡器
|
||||||
](https://card.niconi.co.ni/) 的技术支持。
|
](https://card.niconi.co.ni/) 的技术支持。
|
||||||
- tungnotpunk @ LL Hax 在 iOS 客户端修改方面的支持。
|
- tungnotpunk @ LL Hax 在 iOS 客户端修改方面的支持。
|
||||||
- reversing-sifas (https://github.com/Francesco149/reversing-sifas) 项目的灵感和技术细节。
|
|
||||||
- LLAS WiKi (https://wiki.loveliv.es/) 提供的全量 AS Live Stage 信息。
|
|
||||||
- 其他可能一时没想起来的大佬们和项目。
|
- 其他可能一时没想起来的大佬们和项目。
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
data.db
|
data.db
|
||||||
|
load.db
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,185 @@
|
|||||||
|
{
|
||||||
|
"result": {
|
||||||
|
"tab_list": [
|
||||||
|
{
|
||||||
|
"tab_name": "μ’s",
|
||||||
|
"asset_list": [
|
||||||
|
{
|
||||||
|
"unit_type_id": 1,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_1.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 2,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_2.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 3,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_3.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 4,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_4.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 5,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_5.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 6,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_6.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 7,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_7.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 8,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_8.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 9,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_9.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tab_name": "Aqours",
|
||||||
|
"asset_list": [
|
||||||
|
{
|
||||||
|
"unit_type_id": 101,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_10.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 102,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_11.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 103,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_12.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 104,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_13.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 105,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_14.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 106,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_15.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 107,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_16.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 108,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_17.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 109,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_18.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tab_name": "虹咲",
|
||||||
|
"asset_list": [
|
||||||
|
{
|
||||||
|
"unit_type_id": 201,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_24.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 202,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_25.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 203,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_26.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 204,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_27.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 205,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_28.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 206,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_29.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 207,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_30.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 208,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_31.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 209,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_32.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 212,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_33.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 213,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_34.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 214,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_35.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tab_name": "Liella!",
|
||||||
|
"asset_list": [
|
||||||
|
{
|
||||||
|
"unit_type_id": 301,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_19.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 302,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_20.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 303,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_21.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 304,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_22.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 305,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_23.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 306,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_36.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 307,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_37.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 308,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_38.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unit_type_id": 309,
|
||||||
|
"asset_path": "assets/image/accessory/list/list_39.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": 200,
|
||||||
|
"commandNum": false,
|
||||||
|
"timeStamp": 1679237529
|
||||||
|
}
|
||||||
@@ -14495,4 +14495,4 @@
|
|||||||
"rank": 2416,
|
"rank": 2416,
|
||||||
"sign_flag": false
|
"sign_flag": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,215 +0,0 @@
|
|||||||
{
|
|
||||||
"response_data": {
|
|
||||||
"party_list": [
|
|
||||||
{
|
|
||||||
"user_info": {
|
|
||||||
"user_id": 5762285,
|
|
||||||
"name": "SDS Nico",
|
|
||||||
"level": 21
|
|
||||||
},
|
|
||||||
"center_unit_info": {
|
|
||||||
"unit_owning_user_id": 1000880096808,
|
|
||||||
"unit_id": 4001,
|
|
||||||
"exp": 79700,
|
|
||||||
"next_exp": 0,
|
|
||||||
"level": 100,
|
|
||||||
"level_limit_id": 1,
|
|
||||||
"max_level": 100,
|
|
||||||
"rank": 2,
|
|
||||||
"max_rank": 2,
|
|
||||||
"love": 1000,
|
|
||||||
"max_love": 1000,
|
|
||||||
"unit_skill_level": 8,
|
|
||||||
"max_hp": 4,
|
|
||||||
"favorite_flag": false,
|
|
||||||
"display_rank": 2,
|
|
||||||
"unit_skill_exp": 29900,
|
|
||||||
"unit_removable_skill_capacity": 8,
|
|
||||||
"attribute": 2,
|
|
||||||
"smile": 7210,
|
|
||||||
"cute": 7870,
|
|
||||||
"cool": 7430,
|
|
||||||
"is_love_max": true,
|
|
||||||
"is_level_max": true,
|
|
||||||
"is_rank_max": true,
|
|
||||||
"is_signed": true,
|
|
||||||
"is_skill_level_max": true,
|
|
||||||
"setting_award_id": 121,
|
|
||||||
"removable_skill_ids": []
|
|
||||||
},
|
|
||||||
"setting_award_id": 121,
|
|
||||||
"available_social_point": 10,
|
|
||||||
"friend_status": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user_info": {
|
|
||||||
"user_id": 5400659,
|
|
||||||
"name": "\u9ed1\u6850-",
|
|
||||||
"level": 37
|
|
||||||
},
|
|
||||||
"center_unit_info": {
|
|
||||||
"unit_owning_user_id": 1001193273786,
|
|
||||||
"unit_id": 13,
|
|
||||||
"exp": 0,
|
|
||||||
"next_exp": 6,
|
|
||||||
"level": 1,
|
|
||||||
"level_limit_id": 0,
|
|
||||||
"max_level": 30,
|
|
||||||
"rank": 1,
|
|
||||||
"max_rank": 2,
|
|
||||||
"love": 25,
|
|
||||||
"max_love": 25,
|
|
||||||
"unit_skill_level": 1,
|
|
||||||
"max_hp": 2,
|
|
||||||
"favorite_flag": false,
|
|
||||||
"display_rank": 1,
|
|
||||||
"unit_skill_exp": 0,
|
|
||||||
"unit_removable_skill_capacity": 0,
|
|
||||||
"attribute": 1,
|
|
||||||
"smile": 1520,
|
|
||||||
"cute": 550,
|
|
||||||
"cool": 308,
|
|
||||||
"is_love_max": false,
|
|
||||||
"is_level_max": false,
|
|
||||||
"is_rank_max": false,
|
|
||||||
"is_signed": false,
|
|
||||||
"is_skill_level_max": true,
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"removable_skill_ids": []
|
|
||||||
},
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"available_social_point": 10,
|
|
||||||
"friend_status": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user_info": {
|
|
||||||
"user_id": 7663163,
|
|
||||||
"name": "\u82b1\u82b1\u82b1\u6912",
|
|
||||||
"level": 30
|
|
||||||
},
|
|
||||||
"center_unit_info": {
|
|
||||||
"unit_owning_user_id": 1002061904425,
|
|
||||||
"unit_id": 1131,
|
|
||||||
"exp": 8400,
|
|
||||||
"next_exp": 8659,
|
|
||||||
"level": 18,
|
|
||||||
"level_limit_id": 1,
|
|
||||||
"max_level": 100,
|
|
||||||
"rank": 2,
|
|
||||||
"max_rank": 2,
|
|
||||||
"love": 1000,
|
|
||||||
"max_love": 1000,
|
|
||||||
"unit_skill_level": 1,
|
|
||||||
"max_hp": 5,
|
|
||||||
"favorite_flag": true,
|
|
||||||
"display_rank": 2,
|
|
||||||
"unit_skill_exp": 0,
|
|
||||||
"unit_removable_skill_capacity": 4,
|
|
||||||
"attribute": 3,
|
|
||||||
"smile": 3195,
|
|
||||||
"cute": 2925,
|
|
||||||
"cool": 4085,
|
|
||||||
"is_love_max": true,
|
|
||||||
"is_level_max": false,
|
|
||||||
"is_rank_max": true,
|
|
||||||
"is_signed": false,
|
|
||||||
"is_skill_level_max": false,
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"removable_skill_ids": []
|
|
||||||
},
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"available_social_point": 5,
|
|
||||||
"friend_status": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user_info": {
|
|
||||||
"user_id": 7663313,
|
|
||||||
"name": "\u67f3\u4e95\u4e0e\u5b50",
|
|
||||||
"level": 34
|
|
||||||
},
|
|
||||||
"center_unit_info": {
|
|
||||||
"unit_owning_user_id": 1002062097329,
|
|
||||||
"unit_id": 1372,
|
|
||||||
"exp": 79700,
|
|
||||||
"next_exp": 0,
|
|
||||||
"level": 100,
|
|
||||||
"level_limit_id": 1,
|
|
||||||
"max_level": 100,
|
|
||||||
"rank": 2,
|
|
||||||
"max_rank": 2,
|
|
||||||
"love": 1000,
|
|
||||||
"max_love": 1000,
|
|
||||||
"unit_skill_level": 1,
|
|
||||||
"max_hp": 6,
|
|
||||||
"favorite_flag": true,
|
|
||||||
"display_rank": 2,
|
|
||||||
"unit_skill_exp": 0,
|
|
||||||
"unit_removable_skill_capacity": 4,
|
|
||||||
"attribute": 1,
|
|
||||||
"smile": 5370,
|
|
||||||
"cute": 4080,
|
|
||||||
"cool": 4500,
|
|
||||||
"is_love_max": true,
|
|
||||||
"is_level_max": true,
|
|
||||||
"is_rank_max": true,
|
|
||||||
"is_signed": false,
|
|
||||||
"is_skill_level_max": false,
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"removable_skill_ids": [
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"setting_award_id": 17,
|
|
||||||
"available_social_point": 5,
|
|
||||||
"friend_status": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user_info": {
|
|
||||||
"user_id": 7663527,
|
|
||||||
"name": "\u6211\u63a8\u5c06\u519b",
|
|
||||||
"level": 15
|
|
||||||
},
|
|
||||||
"center_unit_info": {
|
|
||||||
"unit_owning_user_id": 1002062228744,
|
|
||||||
"unit_id": 1912,
|
|
||||||
"exp": 0,
|
|
||||||
"next_exp": 201,
|
|
||||||
"level": 1,
|
|
||||||
"level_limit_id": 1,
|
|
||||||
"max_level": 100,
|
|
||||||
"rank": 2,
|
|
||||||
"max_rank": 2,
|
|
||||||
"love": 444,
|
|
||||||
"max_love": 1000,
|
|
||||||
"unit_skill_level": 1,
|
|
||||||
"max_hp": 5,
|
|
||||||
"favorite_flag": false,
|
|
||||||
"display_rank": 2,
|
|
||||||
"unit_skill_exp": 0,
|
|
||||||
"unit_removable_skill_capacity": 4,
|
|
||||||
"attribute": 1,
|
|
||||||
"smile": 3870,
|
|
||||||
"cute": 3090,
|
|
||||||
"cool": 2470,
|
|
||||||
"is_love_max": false,
|
|
||||||
"is_level_max": false,
|
|
||||||
"is_rank_max": true,
|
|
||||||
"is_signed": false,
|
|
||||||
"is_skill_level_max": false,
|
|
||||||
"setting_award_id": 1,
|
|
||||||
"removable_skill_ids": []
|
|
||||||
},
|
|
||||||
"setting_award_id": 1,
|
|
||||||
"available_social_point": 5,
|
|
||||||
"friend_status": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"training_energy": 999,
|
|
||||||
"training_energy_max": 999,
|
|
||||||
"server_timestamp": 1679802984
|
|
||||||
},
|
|
||||||
"release_info": [],
|
|
||||||
"status_code": 200
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ require (
|
|||||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||||
github.com/golang/snappy v1.0.0 // indirect
|
github.com/golang/snappy v1.0.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
@@ -55,7 +55,7 @@ require (
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/syndtr/goleveldb v1.0.0
|
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||||
golang.org/x/crypto v0.47.0 // indirect
|
golang.org/x/crypto v0.47.0 // indirect
|
||||||
golang.org/x/net v0.49.0 // indirect
|
golang.org/x/net v0.49.0 // indirect
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
github.com/gin-contrib/sessions v1.0.4 h1:ha6CNdpYiTOK/hTp05miJLbpTSNfOnFg5Jm2kbcqy8U=
|
github.com/gin-contrib/sessions v1.0.4 h1:ha6CNdpYiTOK/hTp05miJLbpTSNfOnFg5Jm2kbcqy8U=
|
||||||
github.com/gin-contrib/sessions v1.0.4/go.mod h1:ccmkrb2z6iU2osiAHZG3x3J4suJK+OU27oqzlWOqQgs=
|
github.com/gin-contrib/sessions v1.0.4/go.mod h1:ccmkrb2z6iU2osiAHZG3x3J4suJK+OU27oqzlWOqQgs=
|
||||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
type LiveGoalType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
LiveGoalTypeScore LiveGoalType = iota + 1
|
||||||
|
LiveGoalTypeCombo
|
||||||
|
LiveGoalTypeClear
|
||||||
|
)
|
||||||
|
|
||||||
|
type PreciseScoreUpdateType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
PreciseScoreUpdateTypePerfect PreciseScoreUpdateType = iota + 1
|
||||||
|
PreciseScoreUpdateTypeScore
|
||||||
|
PreciseScoreUpdateTypeAlways
|
||||||
|
)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
type ErrorCode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ErrorCodeLivePreciseListNotFound ErrorCode = 3421
|
||||||
|
)
|
||||||
@@ -3,7 +3,7 @@ package album
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/album"
|
albumschema "honoka-chan/internal/schema/album"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -19,7 +19,7 @@ func seriesAll(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
albumSeriesAllRes := []album.SeriesAllData{}
|
albumSeriesAllRes := []albumschema.SeriesAllData{}
|
||||||
for _, id := range albumID {
|
for _, id := range albumID {
|
||||||
var unitList []struct {
|
var unitList []struct {
|
||||||
UnitId int `xorm:"unit_id"`
|
UnitId int `xorm:"unit_id"`
|
||||||
@@ -30,9 +30,9 @@ func seriesAll(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
albumSeriesAll := []album.UnitList{}
|
albumSeriesAll := []albumschema.UnitList{}
|
||||||
for _, unit := range unitList {
|
for _, unit := range unitList {
|
||||||
albumSeries := album.UnitList{
|
albumSeries := albumschema.UnitList{
|
||||||
UnitID: unit.UnitId,
|
UnitID: unit.UnitId,
|
||||||
RankMaxFlag: true,
|
RankMaxFlag: true,
|
||||||
LoveMaxFlag: true,
|
LoveMaxFlag: true,
|
||||||
@@ -72,13 +72,13 @@ func seriesAll(ctx *gin.Context) {
|
|||||||
albumSeriesAll = append(albumSeriesAll, albumSeries)
|
albumSeriesAll = append(albumSeriesAll, albumSeries)
|
||||||
}
|
}
|
||||||
|
|
||||||
albumSeriesAllRes = append(albumSeriesAllRes, album.SeriesAllData{
|
albumSeriesAllRes = append(albumSeriesAllRes, albumschema.SeriesAllData{
|
||||||
SeriesID: id,
|
SeriesID: id,
|
||||||
UnitList: albumSeriesAll,
|
UnitList: albumSeriesAll,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(album.SeriesAllResp{
|
ss.Respond(albumschema.SeriesAllResp{
|
||||||
ResponseData: albumSeriesAllRes,
|
ResponseData: albumSeriesAllRes,
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package announce
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/announce"
|
announceschema "honoka-chan/internal/schema/announce"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func checkState(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(announce.CheckStateDataResp{
|
ss.Respond(announceschema.CheckStateDataResp{
|
||||||
ResponseData: announce.CheckStateData{
|
ResponseData: announceschema.CheckStateData{
|
||||||
HasUnreadAnnounce: false,
|
HasUnreadAnnounce: false,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package album
|
package album
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/album"
|
albumapischema "honoka-chan/internal/schema/api/album"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func albumAll(ctx *gin.Context) (res any, err error) {
|
func albumAll(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
albumLists := []album.UnitList{}
|
albumLists := []albumapischema.UnitList{}
|
||||||
var unitList []struct {
|
var unitList []struct {
|
||||||
UnitId int `xorm:"unit_id"`
|
UnitId int `xorm:"unit_id"`
|
||||||
Rarity int `xorm:"rarity"`
|
Rarity int `xorm:"rarity"`
|
||||||
@@ -22,7 +22,7 @@ func albumAll(ctx *gin.Context) (res any, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, unit := range unitList {
|
for _, unit := range unitList {
|
||||||
albumList := album.UnitList{
|
albumList := albumapischema.UnitList{
|
||||||
RankMaxFlag: true,
|
RankMaxFlag: true,
|
||||||
LoveMaxFlag: true,
|
LoveMaxFlag: true,
|
||||||
RankLevelMaxFlag: true,
|
RankLevelMaxFlag: true,
|
||||||
@@ -59,7 +59,7 @@ func albumAll(ctx *gin.Context) (res any, err error) {
|
|||||||
albumLists = append(albumLists, albumList)
|
albumLists = append(albumLists, albumList)
|
||||||
}
|
}
|
||||||
|
|
||||||
res = album.AllResp{
|
res = albumapischema.AllResp{
|
||||||
Result: albumLists,
|
Result: albumLists,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package award
|
package award
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/award"
|
awardapischema "honoka-chan/internal/schema/api/award"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -23,21 +23,21 @@ func awardInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
awardsList := []award.Info{}
|
awardsList := []awardapischema.Info{}
|
||||||
for _, id := range awardList {
|
for _, id := range awardList {
|
||||||
isSet := false
|
isSet := false
|
||||||
if id == awardID {
|
if id == awardID {
|
||||||
isSet = true
|
isSet = true
|
||||||
}
|
}
|
||||||
awardsList = append(awardsList, award.Info{
|
awardsList = append(awardsList, awardapischema.Info{
|
||||||
AwardID: id,
|
AwardID: id,
|
||||||
IsSet: isSet,
|
IsSet: isSet,
|
||||||
InsertDate: time.Now().Format("2006-01-02 03:04:05"),
|
InsertDate: "2023-03-20 03:58:55",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
res = award.InfoResp{
|
res = awardapischema.InfoResp{
|
||||||
Result: award.InfoData{
|
Result: awardapischema.InfoData{
|
||||||
AwardInfo: awardsList,
|
AwardInfo: awardsList,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package background
|
package background
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/background"
|
backgroundapischema "honoka-chan/internal/schema/api/background"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -23,21 +23,21 @@ func backgroundInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
backgroundsList := []background.Info{}
|
backgroundsList := []backgroundapischema.Info{}
|
||||||
for _, id := range backgroundList {
|
for _, id := range backgroundList {
|
||||||
isSet := false
|
isSet := false
|
||||||
if id == backgroundID {
|
if id == backgroundID {
|
||||||
isSet = true
|
isSet = true
|
||||||
}
|
}
|
||||||
backgroundsList = append(backgroundsList, background.Info{
|
backgroundsList = append(backgroundsList, backgroundapischema.Info{
|
||||||
BackgroundID: id,
|
BackgroundID: id,
|
||||||
IsSet: isSet,
|
IsSet: isSet,
|
||||||
InsertDate: time.Now().Format("2006-01-02 03:04:05"),
|
InsertDate: "2023-03-20 03:58:55",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
res = background.InfoResp{
|
res = backgroundapischema.InfoResp{
|
||||||
Result: background.InfoData{
|
Result: backgroundapischema.InfoData{
|
||||||
BackgroundInfo: backgroundsList,
|
BackgroundInfo: backgroundsList,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package banner
|
package banner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/banner"
|
bannerapischema "honoka-chan/internal/schema/api/banner"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bannerList() (res any, err error) {
|
func bannerList() (res any, err error) {
|
||||||
res = banner.ListResp{
|
res = bannerapischema.ListResp{
|
||||||
Result: banner.ListData{
|
Result: bannerapischema.ListData{
|
||||||
TimeLimit: "2037-12-31 23:59:59",
|
TimeLimit: "2037-12-31 23:59:59",
|
||||||
BannerList: []banner.BannerList{
|
BannerList: []bannerapischema.BannerList{
|
||||||
{
|
{
|
||||||
BannerType: 1,
|
BannerType: 1,
|
||||||
TargetID: 1743,
|
TargetID: 1743,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package challenge
|
package challenge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/challenge"
|
challengeapischema "honoka-chan/internal/schema/api/challenge"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func challengeInfo() (res any, err error) {
|
func challengeInfo() (res any, err error) {
|
||||||
res = challenge.InfoResp{
|
res = challengeapischema.InfoResp{
|
||||||
Result: []any{},
|
Result: []any{},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package costume
|
package costume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/costume"
|
costumeapischema "honoka-chan/internal/schema/api/costume"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func costumeList() (res any, err error) {
|
func costumeList() (res any, err error) {
|
||||||
res = costume.ListResp{
|
res = costumeapischema.ListResp{
|
||||||
Result: costume.ListData{
|
Result: costumeapischema.ListData{
|
||||||
CostumeList: []costume.CostumeList{},
|
CostumeList: []costumeapischema.CostumeList{},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package eventscenario
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/internal/schema/api/eventscenario"
|
eventscenarioapischema "honoka-chan/internal/schema/api/eventscenario"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -14,7 +14,7 @@ func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var eventID []int
|
var eventID []int
|
||||||
eventsList := []eventscenario.EventScenarioList{}
|
eventsList := []eventscenarioapischema.EventScenarioList{}
|
||||||
err = ss.MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventID)
|
err = ss.MainEng.Table("event_scenario_m").Cols("event_id").GroupBy("event_id").OrderBy("event_id DESC").Find(&eventID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -27,7 +27,7 @@ func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ChapterAsset string `xorm:"chapter_asset"`
|
ChapterAsset string `xorm:"chapter_asset"`
|
||||||
OpenDate string `xorm:"open_date"`
|
OpenDate string `xorm:"open_date"`
|
||||||
}
|
}
|
||||||
chapsList := []eventscenario.ChapterList{}
|
chapsList := []eventscenarioapischema.ChapterList{}
|
||||||
err = ss.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)
|
OrderBy("chapter DESC").Find(&eventRes)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
@@ -35,7 +35,7 @@ func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, res := range eventRes {
|
for _, res := range eventRes {
|
||||||
chapList := eventscenario.ChapterList{
|
chapList := eventscenarioapischema.ChapterList{
|
||||||
EventScenarioID: res.EventScenarioId,
|
EventScenarioID: res.EventScenarioId,
|
||||||
Chapter: res.Chapter,
|
Chapter: res.Chapter,
|
||||||
ChapterAsset: res.ChapterAsset,
|
ChapterAsset: res.ChapterAsset,
|
||||||
@@ -49,7 +49,7 @@ func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
chapsList = append(chapsList, chapList)
|
chapsList = append(chapsList, chapList)
|
||||||
}
|
}
|
||||||
|
|
||||||
event := eventscenario.EventScenarioList{
|
event := eventscenarioapischema.EventScenarioList{
|
||||||
EventID: id,
|
EventID: id,
|
||||||
OpenDate: strings.ReplaceAll(eventRes[0].OpenDate, "/", "-"),
|
OpenDate: strings.ReplaceAll(eventRes[0].OpenDate, "/", "-"),
|
||||||
ChapterList: chapsList,
|
ChapterList: chapsList,
|
||||||
@@ -67,8 +67,8 @@ func eventScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
|
|
||||||
eventsList = append(eventsList, event)
|
eventsList = append(eventsList, event)
|
||||||
}
|
}
|
||||||
res = eventscenario.StatusResp{
|
res = eventscenarioapischema.StatusResp{
|
||||||
Result: eventscenario.StatusData{
|
Result: eventscenarioapischema.StatusData{
|
||||||
EventScenarioList: eventsList,
|
EventScenarioList: eventsList,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package exchange
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/exchange"
|
exchangeapischema "honoka-chan/internal/schema/api/exchange"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -12,20 +12,20 @@ func owningPoint(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var exchangeID []int
|
var exchangeID []int
|
||||||
exPointsList := []exchange.ExchangePointList{}
|
exPointsList := []exchangeapischema.ExchangePointList{}
|
||||||
err = ss.MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeID)
|
err = ss.MainEng.Table("exchange_point_m").Cols("exchange_point_id").OrderBy("exchange_point_id ASC").Find(&exchangeID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, id := range exchangeID {
|
for _, id := range exchangeID {
|
||||||
exPointsList = append(exPointsList, exchange.ExchangePointList{
|
exPointsList = append(exPointsList, exchangeapischema.ExchangePointList{
|
||||||
Rarity: id,
|
Rarity: id,
|
||||||
ExchangePoint: 9999,
|
ExchangePoint: 9999,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = exchange.OwningPointResp{
|
res = exchangeapischema.OwningPointResp{
|
||||||
Result: exchange.OwningPointData{
|
Result: exchangeapischema.OwningPointData{
|
||||||
ExchangePointList: exPointsList,
|
ExchangePointList: exPointsList,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package live
|
package live
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/live"
|
liveapischema "honoka-chan/internal/schema/api/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,42 +11,32 @@ import (
|
|||||||
func liveSchedule(ctx *gin.Context) (res any, err error) {
|
func liveSchedule(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var liveDifficultyID []int
|
var liveID []int
|
||||||
specialLives := []live.SpecialLiveStatusList{}
|
err = ss.MainEng.Table("special_live_m").
|
||||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, id := range liveDifficultyID {
|
|
||||||
specialLive := live.SpecialLiveStatusList{
|
|
||||||
LiveDifficultyID: id,
|
|
||||||
Status: 1,
|
|
||||||
HiScore: 0,
|
|
||||||
HiComboCount: 0,
|
|
||||||
ClearCnt: 0,
|
|
||||||
AchievedGoalIDList: []int{},
|
|
||||||
}
|
|
||||||
specialLives = append(specialLives, specialLive)
|
|
||||||
}
|
|
||||||
|
|
||||||
livesList := []live.LiveList{}
|
liveList := []liveapischema.LiveList{}
|
||||||
for _, v := range specialLives {
|
for _, id := range liveID {
|
||||||
livesList = append(livesList, live.LiveList{
|
liveList = append(liveList, liveapischema.LiveList{
|
||||||
LiveDifficultyID: v.LiveDifficultyID,
|
LiveDifficultyID: id,
|
||||||
StartDate: "2023-01-01 00:00:00",
|
StartDate: "2023-01-01 00:00:00",
|
||||||
EndDate: "2037-01-01 00:00:00",
|
EndDate: "2037-01-01 00:00:00",
|
||||||
IsRandom: false,
|
IsRandom: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = live.ScheduleResp{
|
|
||||||
Result: live.ScheduleData{
|
res = liveapischema.ScheduleResp{
|
||||||
|
Result: liveapischema.ScheduleData{
|
||||||
EventList: []any{},
|
EventList: []any{},
|
||||||
LiveList: livesList,
|
LiveList: liveList,
|
||||||
LimitedBonusList: []any{},
|
LimitedBonusList: []any{},
|
||||||
LimitedBonusCommonList: []live.LimitedBonusCommonList{}, // 特效道具
|
LimitedBonusCommonList: []liveapischema.LimitedBonusCommonList{},
|
||||||
RandomLiveList: []live.RandomLiveList{}, // 随机歌曲
|
RandomLiveList: []liveapischema.RandomLiveList{},
|
||||||
FreeLiveList: []any{},
|
FreeLiveList: []any{},
|
||||||
TrainingLiveList: []live.TrainingLiveList{}, // 挑战歌曲
|
TrainingLiveList: []liveapischema.TrainingLiveList{},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package live
|
package live
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/live"
|
liveapischema "honoka-chan/internal/schema/api/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -12,13 +12,13 @@ func liveStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var liveDifficultyID []int
|
var liveDifficultyID []int
|
||||||
normalLives := []live.NormalLiveStatusList{}
|
normalLives := []liveapischema.NormalLiveStatusList{}
|
||||||
err = ss.MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
err = ss.MainEng.Table("normal_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, id := range liveDifficultyID {
|
for _, id := range liveDifficultyID {
|
||||||
normalLive := live.NormalLiveStatusList{
|
normalLive := liveapischema.NormalLiveStatusList{
|
||||||
LiveDifficultyID: id,
|
LiveDifficultyID: id,
|
||||||
Status: 1,
|
Status: 1,
|
||||||
HiScore: 0,
|
HiScore: 0,
|
||||||
@@ -29,13 +29,13 @@ func liveStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
normalLives = append(normalLives, normalLive)
|
normalLives = append(normalLives, normalLive)
|
||||||
}
|
}
|
||||||
|
|
||||||
specialLives := []live.SpecialLiveStatusList{}
|
specialLives := []liveapischema.SpecialLiveStatusList{}
|
||||||
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
err = ss.MainEng.Table("special_live_m").Cols("live_difficulty_id").OrderBy("live_difficulty_id ASC").Find(&liveDifficultyID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, id := range liveDifficultyID {
|
for _, id := range liveDifficultyID {
|
||||||
specialLive := live.SpecialLiveStatusList{
|
specialLive := liveapischema.SpecialLiveStatusList{
|
||||||
LiveDifficultyID: id,
|
LiveDifficultyID: id,
|
||||||
Status: 1,
|
Status: 1,
|
||||||
HiScore: 0,
|
HiScore: 0,
|
||||||
@@ -46,11 +46,11 @@ func liveStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
specialLives = append(specialLives, specialLive)
|
specialLives = append(specialLives, specialLive)
|
||||||
}
|
}
|
||||||
|
|
||||||
res = live.StatusResp{
|
res = liveapischema.StatusResp{
|
||||||
Result: live.StatusData{
|
Result: liveapischema.StatusData{
|
||||||
NormalLiveStatusList: normalLives,
|
NormalLiveStatusList: normalLives,
|
||||||
SpecialLiveStatusList: specialLives,
|
SpecialLiveStatusList: specialLives,
|
||||||
TrainingLiveStatusList: []live.TrainingLiveStatusList{},
|
TrainingLiveStatusList: []liveapischema.TrainingLiveStatusList{},
|
||||||
MarathonLiveStatusList: []any{},
|
MarathonLiveStatusList: []any{},
|
||||||
FreeLiveStatusList: []any{},
|
FreeLiveStatusList: []any{},
|
||||||
CanResumeLive: false,
|
CanResumeLive: false,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package liveicon
|
package liveicon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/liveicon"
|
liveiconapischema "honoka-chan/internal/schema/api/liveicon"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func liveIconInfo() (res any, err error) {
|
func liveIconInfo() (res any, err error) {
|
||||||
res = liveicon.InfoResp{
|
res = liveiconapischema.InfoResp{
|
||||||
Result: liveicon.InfoData{
|
Result: liveiconapischema.InfoData{
|
||||||
LiveNotesIconList: []int{1, 2, 3},
|
LiveNotesIconList: []int{1, 2, 3},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package livese
|
package livese
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/livese"
|
liveseapischema "honoka-chan/internal/schema/api/livese"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LiveSeInfo() (res any, err error) {
|
func LiveSeInfo() (res any, err error) {
|
||||||
res = livese.InfoResp{
|
res = liveseapischema.InfoResp{
|
||||||
Result: livese.InfoData{
|
Result: liveseapischema.InfoData{
|
||||||
LiveSeList: []int{1, 2, 3},
|
LiveSeList: []int{1, 2, 3},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package login
|
package login
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/login"
|
loginapischema "honoka-chan/internal/schema/api/login"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func loginTopInfo() (res any, err error) {
|
func loginTopInfo() (res any, err error) {
|
||||||
res = login.TopInfoResp{
|
res = loginapischema.TopInfoResp{
|
||||||
Result: login.TopInfoData{
|
Result: loginapischema.TopInfoData{
|
||||||
FriendActionCnt: 0,
|
FriendActionCnt: 0,
|
||||||
FriendGreetCnt: 0,
|
FriendGreetCnt: 0,
|
||||||
FriendVarietyCnt: 0,
|
FriendVarietyCnt: 0,
|
||||||
@@ -21,7 +21,7 @@ func loginTopInfo() (res any, err error) {
|
|||||||
FriendsApprovalWaitCnt: 0,
|
FriendsApprovalWaitCnt: 0,
|
||||||
FriendsRequestCnt: 0,
|
FriendsRequestCnt: 0,
|
||||||
IsTodayBirthday: false,
|
IsTodayBirthday: false,
|
||||||
LicenseInfo: login.LicenseInfo{
|
LicenseInfo: loginapischema.LicenseInfo{
|
||||||
LicenseList: []any{},
|
LicenseList: []any{},
|
||||||
LicensedInfo: []any{},
|
LicensedInfo: []any{},
|
||||||
ExpiredInfo: []any{},
|
ExpiredInfo: []any{},
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
package login
|
package login
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/login"
|
loginapischema "honoka-chan/internal/schema/api/login"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func loginTopInfoOnce() (res any, err error) {
|
func loginTopInfoOnce() (res any, err error) {
|
||||||
res = login.TopInfoOnceResp{
|
res = loginapischema.TopInfoOnceResp{
|
||||||
Result: login.TopInfoOnceData{
|
Result: loginapischema.TopInfoOnceData{
|
||||||
NewAchievementCnt: 0,
|
NewAchievementCnt: 0,
|
||||||
UnaccomplishedAchievementCnt: 0,
|
UnaccomplishedAchievementCnt: 0,
|
||||||
LiveDailyRewardExist: false,
|
LiveDailyRewardExist: false,
|
||||||
TrainingEnergy: 10,
|
TrainingEnergy: 10,
|
||||||
TrainingEnergyMax: 10,
|
TrainingEnergyMax: 10,
|
||||||
Notification: login.Notification{
|
Notification: loginapischema.Notification{
|
||||||
Push: false,
|
Push: false,
|
||||||
Lp: false,
|
Lp: false,
|
||||||
UpdateInfo: false,
|
UpdateInfo: false,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package marathon
|
package marathon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/marathon"
|
marathonapischema "honoka-chan/internal/schema/api/marathon"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func marathonInfo() (res any, err error) {
|
func marathonInfo() (res any, err error) {
|
||||||
res = marathon.InfoResp{
|
res = marathonapischema.InfoResp{
|
||||||
Result: []any{},
|
Result: []any{},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package multiunit
|
package multiunit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/multiunit"
|
multiunitapischema "honoka-chan/internal/schema/api/multiunit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -13,7 +13,7 @@ func MultiUnitScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var statusID []int
|
var statusID []int
|
||||||
multiUnitsList := []multiunit.StatusList{}
|
multiUnitsList := []multiunitapischema.StatusList{}
|
||||||
err = ss.MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&statusID)
|
err = ss.MainEng.Table("multi_unit_scenario_m").Cols("multi_unit_id").GroupBy("multi_unit_id").OrderBy("multi_unit_id ASC").Find(&statusID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -34,12 +34,12 @@ func MultiUnitScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
multiUnitsList = append(multiUnitsList, multiunit.StatusList{
|
multiUnitsList = append(multiUnitsList, multiunitapischema.StatusList{
|
||||||
MultiUnitID: id,
|
MultiUnitID: id,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
MultiUnitScenarioBtnAsset: multiRes.MultiUnitScenarioBtnAsset,
|
MultiUnitScenarioBtnAsset: multiRes.MultiUnitScenarioBtnAsset,
|
||||||
OpenDate: strings.ReplaceAll(multiRes.OpenDate, "/", "-"),
|
OpenDate: strings.ReplaceAll(multiRes.OpenDate, "/", "-"),
|
||||||
ChapterList: []multiunit.ChapterList{
|
ChapterList: []multiunitapischema.ChapterList{
|
||||||
{
|
{
|
||||||
MultiUnitScenarioID: multiRes.MultiUnitScenarioId,
|
MultiUnitScenarioID: multiRes.MultiUnitScenarioId,
|
||||||
Chapter: multiRes.Chapter,
|
Chapter: multiRes.Chapter,
|
||||||
@@ -48,8 +48,8 @@ func MultiUnitScenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = multiunit.StatusResp{
|
res = multiunitapischema.StatusResp{
|
||||||
Result: multiunit.StatusData{
|
Result: multiunitapischema.StatusData{
|
||||||
MultiUnitScenarioStatusList: multiUnitsList,
|
MultiUnitScenarioStatusList: multiUnitsList,
|
||||||
UnlockedMultiUnitScenarioIds: []any{},
|
UnlockedMultiUnitScenarioIds: []any{},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package museum
|
package museum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/museum"
|
museumapischema "honoka-chan/internal/schema/api/museum"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -31,10 +31,10 @@ func museumInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
coolBuff += res.CoolBuff
|
coolBuff += res.CoolBuff
|
||||||
museumID = append(museumID, res.MuseumContentsId)
|
museumID = append(museumID, res.MuseumContentsId)
|
||||||
}
|
}
|
||||||
res = museum.InfoResp{
|
res = museumapischema.InfoResp{
|
||||||
Result: museum.InfoData{
|
Result: museumapischema.InfoData{
|
||||||
MuseumInfo: museum.Info{
|
MuseumInfo: museumapischema.Info{
|
||||||
Parameter: museum.Parameter{
|
Parameter: museumapischema.Parameter{
|
||||||
Smile: smileBuff,
|
Smile: smileBuff,
|
||||||
Pure: pureBuff,
|
Pure: pureBuff,
|
||||||
Cool: coolBuff,
|
Cool: coolBuff,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package navigation
|
package navigation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/navigation"
|
navigationapischema "honoka-chan/internal/schema/api/navigation"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SpecialCutin() (res any, err error) {
|
func SpecialCutin() (res any, err error) {
|
||||||
res = navigation.SpecialCutinResp{
|
res = navigationapischema.SpecialCutinResp{
|
||||||
Result: navigation.SpecialCutinData{
|
Result: navigationapischema.SpecialCutinData{
|
||||||
SpecialCutinList: []any{},
|
SpecialCutinList: []any{},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package notice
|
package notice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/notice"
|
noticeapischema "honoka-chan/internal/schema/api/notice"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func noticeMarquee() (res any, err error) {
|
func noticeMarquee() (res any, err error) {
|
||||||
res = notice.MarqueeResp{
|
res = noticeapischema.MarqueeResp{
|
||||||
Result: notice.MarqueeData{
|
Result: noticeapischema.MarqueeData{
|
||||||
ItemCount: 0,
|
ItemCount: 0,
|
||||||
MarqueeList: []any{},
|
MarqueeList: []any{},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
package payment
|
package payment
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/payment"
|
paymentapischema "honoka-chan/internal/schema/api/payment"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func productList() (res any, err error) {
|
func productList() (res any, err error) {
|
||||||
res = payment.ProductListResp{
|
res = paymentapischema.ProductListResp{
|
||||||
Result: payment.ProductListData{
|
Result: paymentapischema.ProductListData{
|
||||||
RestrictionInfo: payment.RestrictionInfo{
|
RestrictionInfo: paymentapischema.RestrictionInfo{
|
||||||
Restricted: false,
|
Restricted: false,
|
||||||
},
|
},
|
||||||
UnderAgeInfo: payment.UnderAgeInfo{
|
UnderAgeInfo: paymentapischema.UnderAgeInfo{
|
||||||
BirthSet: false,
|
BirthSet: false,
|
||||||
HasLimit: false,
|
HasLimit: false,
|
||||||
LimitAmount: nil,
|
LimitAmount: nil,
|
||||||
MonthUsed: 0,
|
MonthUsed: 0,
|
||||||
},
|
},
|
||||||
SnsProductList: []payment.SnsProduct{},
|
SnsProductList: []paymentapischema.SnsProduct{},
|
||||||
ProductList: []payment.Product{},
|
ProductList: []paymentapischema.Product{},
|
||||||
SubscriptionList: []payment.Subscription{},
|
SubscriptionList: []paymentapischema.Subscription{},
|
||||||
ShowPointShop: false,
|
ShowPointShop: false,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package profile
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/schema/api/profile"
|
profileapischema "honoka-chan/internal/schema/api/profile"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ func cardRanking() (res any, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res = profile.CardRankingResp{
|
res = profileapischema.CardRankingResp{
|
||||||
Result: result,
|
Result: result,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package profile
|
package profile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/model/user"
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
"honoka-chan/internal/schema/api/profile"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
|
profileapischema "honoka-chan/internal/schema/api/profile"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -12,57 +13,25 @@ import (
|
|||||||
func profileInfo(ctx *gin.Context) (res any, err error) {
|
func profileInfo(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
pref := user.UserPref{}
|
pref := usermodel.UserPref{}
|
||||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
commonUnit, err := ss.MainEng.Table("common_unit_m").Count()
|
unitCount, err := ss.UserEng.Table(new(usermodel.UserUnitData)).
|
||||||
|
Where("user_id = ?", ss.UserID).Count()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
userUnit, err := ss.UserEng.Table("user_unit").Where("user_id = ?", ss.UserID).Count()
|
unitData := unitmodel.UnitDataMap{}
|
||||||
|
_, err = ss.GetBasicUnitInfo().
|
||||||
|
Where("a.unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
unitData := profile.UnitData{}
|
|
||||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", pref.UnitOwningUserID).Get(&unitData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
isCommon := true
|
|
||||||
if !exists {
|
|
||||||
_, err = ss.UserEng.Table("user_unit").
|
|
||||||
Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).Get(&unitData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
isCommon = false
|
|
||||||
}
|
|
||||||
|
|
||||||
var attrId, maxHp, baseSmile, basePure, baseCool int
|
|
||||||
var smileMax, pureMax, coolMax int
|
|
||||||
if isCommon {
|
|
||||||
// 公共卡片仅为100级属性
|
|
||||||
_, err = ss.MainEng.Table("unit_m").Where("unit_id = ?", unitData.UnitID).
|
|
||||||
Cols("attribute_id,hp_max,smile_max,pure_max,cool_max").Get(&attrId, &maxHp, &baseSmile, &basePure, &baseCool)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 偷懒起见不计算饰品、宝石、回忆画廊等属性加成
|
|
||||||
smileMax = baseSmile
|
|
||||||
pureMax = basePure
|
|
||||||
coolMax = baseCool
|
|
||||||
// } else {
|
|
||||||
// // 用户卡片需要根据等级计算属性
|
|
||||||
// // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
var accessoryOwningId, accessoryId, exp int
|
var accessoryOwningId, accessoryId, exp int
|
||||||
_, err = ss.UserEng.Table("user_accessory_wear").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).
|
_, err = ss.UserEng.Table("user_accessory_wear").Where("unit_owning_user_id = ? AND user_id = ?", pref.UnitOwningUserID, ss.UserID).
|
||||||
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
||||||
@@ -74,7 +43,7 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
accessoryInfo := profile.AccessoryInfo{
|
accessoryInfo := profileapischema.AccessoryInfo{
|
||||||
AccessoryOwningUserID: accessoryOwningId,
|
AccessoryOwningUserID: accessoryOwningId,
|
||||||
AccessoryID: accessoryId,
|
AccessoryID: accessoryId,
|
||||||
Exp: exp,
|
Exp: exp,
|
||||||
@@ -92,9 +61,9 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res = profile.InfoResp{
|
res = profileapischema.InfoResp{
|
||||||
Result: profile.InfoData{
|
Result: profileapischema.InfoData{
|
||||||
UserInfo: profile.UserInfo{
|
UserInfo: profileapischema.UserInfo{
|
||||||
UserID: pref.UserID,
|
UserID: pref.UserID,
|
||||||
Name: pref.UserName,
|
Name: pref.UserName,
|
||||||
Level: pref.UserLevel,
|
Level: pref.UserLevel,
|
||||||
@@ -102,16 +71,17 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
UnitMax: 5000,
|
UnitMax: 5000,
|
||||||
EnergyMax: 417,
|
EnergyMax: 417,
|
||||||
FriendMax: 99,
|
FriendMax: 99,
|
||||||
UnitCnt: int(commonUnit + userUnit),
|
UnitCnt: int(unitCount),
|
||||||
InviteCode: pref.InviteCode,
|
InviteCode: pref.InviteCode,
|
||||||
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
||||||
Introduction: pref.UserDesc,
|
Introduction: pref.UserDesc,
|
||||||
},
|
},
|
||||||
CenterUnitInfo: profile.CenterUnitInfo{
|
// TODO: 区分队伍中心卡片和看板卡片
|
||||||
|
CenterUnitInfo: profileapischema.CenterUnitInfo{
|
||||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||||
UnitID: unitData.UnitID,
|
UnitID: unitData.UnitID,
|
||||||
Exp: unitData.Exp,
|
Exp: unitData.Exp,
|
||||||
NextExp: unitData.NextExp,
|
NextExp: 0,
|
||||||
Level: unitData.Level,
|
Level: unitData.Level,
|
||||||
LevelLimitID: unitData.LevelLimitID,
|
LevelLimitID: unitData.LevelLimitID,
|
||||||
MaxLevel: unitData.MaxLevel,
|
MaxLevel: unitData.MaxLevel,
|
||||||
@@ -125,10 +95,10 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
DisplayRank: unitData.DisplayRank,
|
DisplayRank: unitData.DisplayRank,
|
||||||
UnitSkillExp: unitData.UnitSkillExp,
|
UnitSkillExp: unitData.UnitSkillExp,
|
||||||
UnitRemovableSkillCapacity: unitData.UnitRemovableSkillCapacity,
|
UnitRemovableSkillCapacity: unitData.UnitRemovableSkillCapacity,
|
||||||
Attribute: attrId,
|
Attribute: unitData.Attribute,
|
||||||
Smile: baseSmile,
|
Smile: unitData.Smile,
|
||||||
Cute: basePure,
|
Cute: unitData.Cute,
|
||||||
Cool: baseCool,
|
Cool: unitData.Cool,
|
||||||
IsLoveMax: unitData.IsLoveMax,
|
IsLoveMax: unitData.IsLoveMax,
|
||||||
IsLevelMax: unitData.IsLevelMax,
|
IsLevelMax: unitData.IsLevelMax,
|
||||||
IsRankMax: unitData.IsRankMax,
|
IsRankMax: unitData.IsRankMax,
|
||||||
@@ -137,17 +107,17 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
SettingAwardID: pref.AwardID,
|
SettingAwardID: pref.AwardID,
|
||||||
RemovableSkillIds: removeSkillIds,
|
RemovableSkillIds: removeSkillIds,
|
||||||
AccessoryInfo: accessoryInfo,
|
AccessoryInfo: accessoryInfo,
|
||||||
Costume: profile.Costume{},
|
Costume: profileapischema.Costume{},
|
||||||
TotalSmile: smileMax,
|
TotalSmile: unitData.Smile, // TODO: 加成计算
|
||||||
TotalCute: pureMax,
|
TotalCute: unitData.Cute, // 同上
|
||||||
TotalCool: coolMax,
|
TotalCool: unitData.Cool, // 同上
|
||||||
TotalHp: maxHp,
|
TotalHp: unitData.MaxHp,
|
||||||
},
|
},
|
||||||
NaviUnitInfo: profile.NaviUnitInfo{
|
NaviUnitInfo: profileapischema.NaviUnitInfo{
|
||||||
UnitOwningUserID: unitData.UnitOwningUserID,
|
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||||
UnitID: unitData.UnitID,
|
UnitID: unitData.UnitID,
|
||||||
Exp: unitData.Exp,
|
Exp: unitData.Exp,
|
||||||
NextExp: unitData.NextExp,
|
NextExp: 0,
|
||||||
Level: unitData.Level,
|
Level: unitData.Level,
|
||||||
MaxLevel: unitData.MaxLevel,
|
MaxLevel: unitData.MaxLevel,
|
||||||
LevelLimitID: unitData.LevelLimitID,
|
LevelLimitID: unitData.LevelLimitID,
|
||||||
@@ -168,10 +138,10 @@ func profileInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
IsSkillLevelMax: unitData.IsSkillLevelMax,
|
IsSkillLevelMax: unitData.IsSkillLevelMax,
|
||||||
IsRemovableSkillCapacityMax: unitData.IsRemovableSkillCapacityMax,
|
IsRemovableSkillCapacityMax: unitData.IsRemovableSkillCapacityMax,
|
||||||
InsertDate: "2016-10-11 10:33:03",
|
InsertDate: "2016-10-11 10:33:03",
|
||||||
TotalSmile: smileMax,
|
TotalSmile: unitData.Smile, // TODO: 加成计算
|
||||||
TotalCute: pureMax,
|
TotalCute: unitData.Cute, // 同上
|
||||||
TotalCool: coolMax,
|
TotalCool: unitData.Cool, // 同上
|
||||||
TotalHp: maxHp,
|
TotalHp: unitData.MaxHp,
|
||||||
RemovableSkillIds: removeSkillIds,
|
RemovableSkillIds: removeSkillIds,
|
||||||
},
|
},
|
||||||
IsAlliance: false,
|
IsAlliance: false,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package profile
|
package profile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/profile"
|
profileapischema "honoka-chan/internal/schema/api/profile"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func liveCnt() (res any, err error) {
|
func liveCnt() (res any, err error) {
|
||||||
res = profile.LiveCntResp{
|
res = profileapischema.LiveCntResp{
|
||||||
Result: []profile.LiveCntData{
|
Result: []profileapischema.LiveCntData{
|
||||||
{
|
{
|
||||||
Difficulty: 1,
|
Difficulty: 1,
|
||||||
ClearCnt: 315,
|
ClearCnt: 315,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package scenario
|
package scenario
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/scenario"
|
scenarioapischema "honoka-chan/internal/schema/api/scenario"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -12,20 +12,20 @@ func scenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var scenarioID []int
|
var scenarioID []int
|
||||||
scenarioLists := []scenario.StatusList{}
|
scenarioLists := []scenarioapischema.StatusList{}
|
||||||
err = ss.MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioID)
|
err = ss.MainEng.Table("scenario_m").Cols("scenario_id").OrderBy("scenario_id ASC").Find(&scenarioID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, id := range scenarioID {
|
for _, id := range scenarioID {
|
||||||
scenarioLists = append(scenarioLists, scenario.StatusList{
|
scenarioLists = append(scenarioLists, scenarioapischema.StatusList{
|
||||||
ScenarioID: id,
|
ScenarioID: id,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = scenario.StatusResp{
|
res = scenarioapischema.StatusResp{
|
||||||
Result: scenario.StatusData{
|
Result: scenarioapischema.StatusData{
|
||||||
ScenarioStatusList: scenarioLists,
|
ScenarioStatusList: scenarioLists,
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package subscenario
|
package subscenario
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/subscenario"
|
subscenarioapischema "honoka-chan/internal/schema/api/subscenario"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -12,20 +12,20 @@ func subscenarioStatus(ctx *gin.Context) (res any, err error) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var subScenarioID []int
|
var subScenarioID []int
|
||||||
subScenarioLists := []subscenario.StatusList{}
|
subScenarioLists := []subscenarioapischema.StatusList{}
|
||||||
err = ss.MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioID)
|
err = ss.MainEng.Table("subscenario_m").Cols("subscenario_id").OrderBy("subscenario_id ASC").Find(&subScenarioID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, id := range subScenarioID {
|
for _, id := range subScenarioID {
|
||||||
subScenarioLists = append(subScenarioLists, subscenario.StatusList{
|
subScenarioLists = append(subScenarioLists, subscenarioapischema.StatusList{
|
||||||
SubscenarioID: id,
|
SubscenarioID: id,
|
||||||
Status: 2,
|
Status: 2,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = subscenario.StatusResp{
|
res = subscenarioapischema.StatusResp{
|
||||||
Result: subscenario.StatusData{
|
Result: subscenarioapischema.StatusData{
|
||||||
SubscenarioStatusList: subScenarioLists,
|
SubscenarioStatusList: subScenarioLists,
|
||||||
UnlockedSubscenarioIds: []any{},
|
UnlockedSubscenarioIds: []any{},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func unitAccessoryAll(ctx *gin.Context) (res any, err error) {
|
func unitAccessoryAll(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
accessoryList := []unit.AccessoryList{}
|
accessoryList := []unitapischema.AccessoryList{}
|
||||||
err = ss.MainEng.Table("common_accessory_m").Find(&accessoryList)
|
err = ss.MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -23,13 +23,13 @@ func unitAccessoryAll(ctx *gin.Context) (res any, err error) {
|
|||||||
accessoryList[k].RankUpCount = 4
|
accessoryList[k].RankUpCount = 4
|
||||||
accessoryList[k].FavoriteFlag = true
|
accessoryList[k].FavoriteFlag = true
|
||||||
}
|
}
|
||||||
wearingInfo := []unit.WearingInfo{}
|
wearingInfo := []unitapischema.WearingInfo{}
|
||||||
err = ss.UserEng.Table("user_accessory_wear").Where("user_id = ?", ss.UserID).Find(&wearingInfo)
|
err = ss.UserEng.Table("user_accessory_wear").Where("user_id = ?", ss.UserID).Find(&wearingInfo)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res = unit.AccessoryAllResp{
|
res = unitapischema.AccessoryAllResp{
|
||||||
Result: unit.AccessoryAllData{
|
Result: unitapischema.AccessoryAllData{
|
||||||
AccessoryList: accessoryList,
|
AccessoryList: accessoryList,
|
||||||
WearingInfo: wearingInfo,
|
WearingInfo: wearingInfo,
|
||||||
EspecialCreateFlag: false,
|
EspecialCreateFlag: false,
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unitAccessoryMaterialAll() (res any, err error) {
|
||||||
|
res = unitapischema.AccessoryMaterialAllResp{
|
||||||
|
Result: unitapischema.AccessoryMaterialAllData{},
|
||||||
|
Status: 200,
|
||||||
|
CommandNum: false,
|
||||||
|
TimeStamp: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
|
honokautils "honoka-chan/pkg/utils"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unitAccessoryTab() (res any, err error) {
|
||||||
|
data := honokautils.ReadAllText("assets/serverdata/accessoryTab.json")
|
||||||
|
resp := unitapischema.AccessoryTabResp{}
|
||||||
|
err = json.Unmarshal([]byte(data), &resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.TimeStamp = time.Now().Unix()
|
||||||
|
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/unit"
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,23 +12,48 @@ import (
|
|||||||
func unitAll(ctx *gin.Context) (res any, err error) {
|
func unitAll(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
unitsData := []unit.Active{}
|
unitMap := []unitmodel.UnitDataMap{}
|
||||||
err = ss.MainEng.Table("common_unit_m").Find(&unitsData)
|
err = ss.GetBasicUnitInfo().
|
||||||
|
Where("a.user_id = ?", ss.UserID).Find(&unitMap)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userUnits := []unit.Active{}
|
unitsData := []unitapischema.Active{}
|
||||||
err = ss.UserEng.Table("user_unit").Where("user_id = ?", ss.UserID).Find(&userUnits)
|
for _, u := range unitMap {
|
||||||
if ss.CheckErr(err) {
|
unitsData = append(unitsData, unitapischema.Active{
|
||||||
return
|
UnitOwningUserID: u.UnitOwningUserID,
|
||||||
|
UserID: ss.UserID,
|
||||||
|
UnitID: u.UnitID,
|
||||||
|
Exp: u.Exp,
|
||||||
|
NextExp: 0,
|
||||||
|
Level: u.Level,
|
||||||
|
MaxLevel: u.MaxLevel,
|
||||||
|
LevelLimitID: u.LevelLimitID,
|
||||||
|
Rank: u.Rank,
|
||||||
|
MaxRank: u.MaxRank,
|
||||||
|
Love: u.Love,
|
||||||
|
MaxLove: u.MaxLove,
|
||||||
|
UnitSkillExp: u.UnitSkillExp,
|
||||||
|
UnitSkillLevel: u.UnitSkillLevel,
|
||||||
|
MaxHp: u.MaxHp,
|
||||||
|
UnitRemovableSkillCapacity: u.UnitRemovableSkillCapacity,
|
||||||
|
FavoriteFlag: u.FavoriteFlag,
|
||||||
|
DisplayRank: u.DisplayRank,
|
||||||
|
IsRankMax: u.IsRankMax,
|
||||||
|
IsLoveMax: u.IsLoveMax,
|
||||||
|
IsLevelMax: u.IsLevelMax,
|
||||||
|
IsSigned: u.IsSigned,
|
||||||
|
IsSkillLevelMax: u.IsSkillLevelMax,
|
||||||
|
IsRemovableSkillCapacityMax: u.IsRemovableSkillCapacityMax,
|
||||||
|
InsertDate: "2023-03-20 03:58:55",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
unitsData = append(unitsData, userUnits...)
|
|
||||||
|
|
||||||
res = unit.AllResp{
|
res = unitapischema.AllResp{
|
||||||
Result: unit.AllData{
|
Result: unitapischema.AllData{
|
||||||
Active: unitsData,
|
Active: unitsData,
|
||||||
Waiting: []unit.Waiting{},
|
Waiting: []unitapischema.Waiting{},
|
||||||
},
|
},
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,23 +11,23 @@ import (
|
|||||||
func unitDeckInfo(ctx *gin.Context) (res any, err error) {
|
func unitDeckInfo(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
userDeck := []unit.UserDeckData{}
|
userDeck := []unitapischema.UserDeckData{}
|
||||||
err = ss.UserEng.Table("user_deck").Where("user_id = ?", ss.UserID).Asc("deck_id").Find(&userDeck)
|
err = ss.UserEng.Table("user_deck").Where("user_id = ?", ss.UserID).Asc("deck_id").Find(&userDeck)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
unitDeckInfo := []unit.DeckInfoData{}
|
unitDeckInfo := []unitapischema.DeckInfoData{}
|
||||||
for _, deck := range userDeck {
|
for _, deck := range userDeck {
|
||||||
deckUnit := []unit.UnitDeckData{}
|
deckUnit := []unitapischema.UnitDeckData{}
|
||||||
err = ss.UserEng.Table("user_deck_unit").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
err = ss.UserEng.Table("user_deck_unit").Where("user_deck_id = ?", deck.ID).Asc("position").Find(&deckUnit)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oUID := []unit.UnitOwningUserIds{}
|
oUID := []unitapischema.UnitOwningUserIds{}
|
||||||
for _, u := range deckUnit {
|
for _, u := range deckUnit {
|
||||||
oUID = append(oUID, unit.UnitOwningUserIds{
|
oUID = append(oUID, unitapischema.UnitOwningUserIds{
|
||||||
Position: u.Position,
|
Position: u.Position,
|
||||||
UnitOwningUserID: u.UnitOwningUserID,
|
UnitOwningUserID: u.UnitOwningUserID,
|
||||||
})
|
})
|
||||||
@@ -37,14 +37,14 @@ func unitDeckInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
if deck.MainFlag == 1 {
|
if deck.MainFlag == 1 {
|
||||||
mainFlag = true
|
mainFlag = true
|
||||||
}
|
}
|
||||||
unitDeckInfo = append(unitDeckInfo, unit.DeckInfoData{
|
unitDeckInfo = append(unitDeckInfo, unitapischema.DeckInfoData{
|
||||||
UnitDeckID: deck.DeckID,
|
UnitDeckID: deck.DeckID,
|
||||||
MainFlag: mainFlag,
|
MainFlag: mainFlag,
|
||||||
DeckName: deck.DeckName,
|
DeckName: deck.DeckName,
|
||||||
UnitOwningUserIds: oUID,
|
UnitOwningUserIds: oUID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res = unit.DeckInfoResp{
|
res = unitapischema.DeckInfoResp{
|
||||||
Result: unitDeckInfo,
|
Result: unitDeckInfo,
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func unitRemovableSkillInfo(ctx *gin.Context) (res any, err error) {
|
func unitRemovableSkillInfo(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
var skillEquipCount []unit.SkillEquipCount
|
var skillEquipCount []unitapischema.SkillEquipCount
|
||||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ?", ss.UserID).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ?", ss.UserID).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||||
GroupBy("unit_removable_skill_id").Find(&skillEquipCount)
|
GroupBy("unit_removable_skill_id").Find(&skillEquipCount)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
@@ -24,12 +24,12 @@ func unitRemovableSkillInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
owingInfo := []unit.OwningInfo{}
|
owingInfo := []unitapischema.OwningInfo{}
|
||||||
for _, id := range rmSkillIds {
|
for _, id := range rmSkillIds {
|
||||||
info := unit.OwningInfo{
|
info := unitapischema.OwningInfo{
|
||||||
UnitRemovableSkillID: id,
|
UnitRemovableSkillID: id,
|
||||||
TotalAmount: 9,
|
TotalAmount: 999,
|
||||||
EquippedAmount: 0,
|
EquippedAmount: 0, // TODO: 计算实际数量
|
||||||
InsertDate: "2023-01-01 12:00:00",
|
InsertDate: "2023-01-01 12:00:00",
|
||||||
}
|
}
|
||||||
for _, sk := range skillEquipCount {
|
for _, sk := range skillEquipCount {
|
||||||
@@ -49,21 +49,21 @@ func unitRemovableSkillInfo(ctx *gin.Context) (res any, err error) {
|
|||||||
|
|
||||||
equipInfo := map[int]any{}
|
equipInfo := map[int]any{}
|
||||||
for _, v := range unitOwningIds {
|
for _, v := range unitOwningIds {
|
||||||
detail := []unit.SkillEquipDetail{}
|
detail := []unitapischema.SkillEquipDetail{}
|
||||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ? AND unit_owning_user_id = ?", ss.UserID, v).
|
err = ss.UserEng.Table("user_unit_skill_equip").Where("user_id = ? AND unit_owning_user_id = ?", ss.UserID, v).
|
||||||
Cols("unit_removable_skill_id").Find(&detail)
|
Cols("unit_removable_skill_id").Find(&detail)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
equipInfo[v] = unit.SkillEquipList{
|
equipInfo[v] = unitapischema.SkillEquipList{
|
||||||
UnitOwningUserID: v,
|
UnitOwningUserID: v,
|
||||||
Detail: detail,
|
Detail: detail,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = unit.RemovableSkillInfoResp{
|
res = unitapischema.RemovableSkillInfoResp{
|
||||||
Result: unit.RemovableSkillInfoData{
|
Result: unitapischema.RemovableSkillInfoData{
|
||||||
OwningInfo: owingInfo,
|
OwningInfo: owingInfo,
|
||||||
EquipmentInfo: equipInfo,
|
EquipmentInfo: equipInfo,
|
||||||
}, // 宝石
|
}, // 宝石
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func unitSupporterAll() (res any, err error) {
|
func unitSupporterAll() (res any, err error) {
|
||||||
res = unit.SupporterAllResp{
|
res = unitapischema.SupporterAllResp{
|
||||||
Result: unit.SupporterAllData{
|
Result: unitapischema.SupporterAllData{
|
||||||
UnitSupportList: []unit.SupporterList{},
|
UnitSupportList: []unitapischema.SupporterList{},
|
||||||
}, // 练习道具
|
}, // 练习道具
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ func UnitApi(ctx *gin.Context, action string) (res any, err error) {
|
|||||||
switch action {
|
switch action {
|
||||||
case "accessoryAll":
|
case "accessoryAll":
|
||||||
res, err = unitAccessoryAll(ctx)
|
res, err = unitAccessoryAll(ctx)
|
||||||
|
case "accessoryMaterialAll":
|
||||||
|
res, err = unitAccessoryMaterialAll()
|
||||||
|
case "accessoryTab":
|
||||||
|
res, err = unitAccessoryTab()
|
||||||
case "deckInfo":
|
case "deckInfo":
|
||||||
res, err = unitDeckInfo(ctx)
|
res, err = unitDeckInfo(ctx)
|
||||||
case "removableSkillInfo":
|
case "removableSkillInfo":
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/schema/api/user"
|
userapischema "honoka-chan/internal/schema/api/user"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ func userGetNavi(ctx *gin.Context) (res any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res = user.GetNaviResp{
|
res = userapischema.GetNaviResp{
|
||||||
Result: user.GetNaviData{
|
Result: userapischema.GetNaviData{
|
||||||
User: user.User{
|
User: userapischema.User{
|
||||||
UserID: uID,
|
UserID: uID,
|
||||||
UnitOwningUserID: oID,
|
UnitOwningUserID: oID,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
userapischema "honoka-chan/internal/schema/api/user"
|
userapischema "honoka-chan/internal/schema/api/user"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
@@ -12,43 +12,14 @@ import (
|
|||||||
func userInfo(ctx *gin.Context) (res any, err error) {
|
func userInfo(ctx *gin.Context) (res any, err error) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
|
|
||||||
pref := user.UserPref{}
|
pref := usermodel.UserPref{}
|
||||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res = userapischema.InfoResp{
|
res = userapischema.InfoResp{
|
||||||
Result: userapischema.UserInfo{
|
Result: ss.GetUserInfo(),
|
||||||
UserID: ss.UserID,
|
|
||||||
Name: pref.UserName,
|
|
||||||
Level: pref.UserLevel,
|
|
||||||
Exp: 1089696,
|
|
||||||
PreviousExp: 0,
|
|
||||||
NextExp: 1207185,
|
|
||||||
GameCoin: 999999999,
|
|
||||||
SnsCoin: 100000,
|
|
||||||
FreeSnsCoin: 50000,
|
|
||||||
PaidSnsCoin: 50000,
|
|
||||||
SocialPoint: 1438395,
|
|
||||||
UnitMax: 5000,
|
|
||||||
WaitingUnitMax: 1000,
|
|
||||||
EnergyMax: 417,
|
|
||||||
EnergyFullTime: "2023-03-20 03:58:55",
|
|
||||||
LicenseLiveEnergyRecoverlyTime: 60,
|
|
||||||
EnergyFullNeedTime: 0,
|
|
||||||
OverMaxEnergy: 417,
|
|
||||||
TrainingEnergy: 100,
|
|
||||||
TrainingEnergyMax: 100,
|
|
||||||
FriendMax: 99,
|
|
||||||
InviteCode: pref.InviteCode,
|
|
||||||
InsertDate: "2015-08-10 18:58:30",
|
|
||||||
UpdateDate: "2018-08-09 18:13:12",
|
|
||||||
TutorialState: -1,
|
|
||||||
DiamondCoin: 0,
|
|
||||||
CrystalCoin: 0,
|
|
||||||
LpRecoveryItem: []userapischema.LpRecoveryItem{},
|
|
||||||
},
|
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
TimeStamp: time.Now().Unix(),
|
TimeStamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package award
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/award"
|
awardschema "honoka-chan/internal/schema/award"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -16,7 +16,7 @@ func set(ctx *gin.Context) {
|
|||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
reqData := gjson.Parse(ctx.MustGet("request_data").(string))
|
reqData := gjson.Parse(ctx.MustGet("request_data").(string))
|
||||||
pref := user.UserPref{
|
pref := usermodel.UserPref{
|
||||||
AwardID: int(reqData.Get("award_id").Int()),
|
AwardID: int(reqData.Get("award_id").Int()),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func set(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(award.SetResp{
|
ss.Respond(awardschema.SetResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package background
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/background"
|
backgroundschema "honoka-chan/internal/schema/background"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -16,7 +16,7 @@ func set(ctx *gin.Context) {
|
|||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
reqData := gjson.Parse(ctx.MustGet("request_data").(string))
|
reqData := gjson.Parse(ctx.MustGet("request_data").(string))
|
||||||
pref := user.UserPref{
|
pref := usermodel.UserPref{
|
||||||
BackgroundID: int(reqData.Get("background_id").Int()),
|
BackgroundID: int(reqData.Get("background_id").Int()),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func set(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(background.SetResp{
|
ss.Respond(backgroundschema.SetResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/download"
|
downloadschema "honoka-chan/internal/schema/download"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -22,13 +22,13 @@ func additional(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
downloadReq := download.AdditionalReq{}
|
downloadReq := downloadschema.AdditionalReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgList := []download.AdditionalData{}
|
pkgList := []downloadschema.AdditionalData{}
|
||||||
pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID
|
pkgType, pkgId := downloadReq.PackageType, downloadReq.PackageID
|
||||||
var pkgInfo []PkgInfo
|
var pkgInfo []PkgInfo
|
||||||
err = ss.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).
|
||||||
@@ -39,14 +39,14 @@ func additional(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range pkgInfo {
|
for _, pkg := range pkgInfo {
|
||||||
pkgList = append(pkgList, download.AdditionalData{
|
pkgList = append(pkgList, downloadschema.AdditionalData{
|
||||||
Size: pkg.Size,
|
Size: pkg.Size,
|
||||||
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
||||||
config.Conf.Settings.CdnServer, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order),
|
config.Conf.Settings.CdnServer, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(download.AdditionalResp{
|
ss.Respond(downloadschema.AdditionalResp{
|
||||||
ResponseData: pkgList,
|
ResponseData: pkgList,
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/download"
|
downloadschema "honoka-chan/internal/schema/download"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -17,13 +17,13 @@ func batch(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
downloadReq := download.BatchReq{}
|
downloadReq := downloadschema.BatchReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgList := []download.BatchData{}
|
pkgList := []downloadschema.BatchData{}
|
||||||
if downloadReq.ClientVersion == config.PackageVersion {
|
if downloadReq.ClientVersion == config.PackageVersion {
|
||||||
pkgType := downloadReq.PackageType
|
pkgType := downloadReq.PackageType
|
||||||
var pkgInfo []PkgInfo
|
var pkgInfo []PkgInfo
|
||||||
@@ -35,7 +35,7 @@ func batch(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range pkgInfo {
|
for _, pkg := range pkgInfo {
|
||||||
pkgList = append(pkgList, download.BatchData{
|
pkgList = append(pkgList, downloadschema.BatchData{
|
||||||
Size: pkg.Size,
|
Size: pkg.Size,
|
||||||
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
||||||
config.Conf.Settings.CdnServer, downloadReq.Os, pkgType, pkg.Id, pkg.Order),
|
config.Conf.Settings.CdnServer, downloadReq.Os, pkgType, pkg.Id, pkg.Order),
|
||||||
@@ -43,7 +43,7 @@ func batch(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(download.BatchResp{
|
ss.Respond(downloadschema.BatchResp{
|
||||||
ResponseData: pkgList,
|
ResponseData: pkgList,
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package download
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/download"
|
downloadschema "honoka-chan/internal/schema/download"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -13,7 +13,7 @@ func event(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(download.EventResp{
|
ss.Respond(downloadschema.EventResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/download"
|
downloadschema "honoka-chan/internal/schema/download"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -18,13 +18,13 @@ func update(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
downloadReq := download.UpdateReq{}
|
downloadReq := downloadschema.UpdateReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgList := []download.UpdateData{}
|
pkgList := []downloadschema.UpdateData{}
|
||||||
if downloadReq.ExternalVersion != config.PackageVersion {
|
if downloadReq.ExternalVersion != config.PackageVersion {
|
||||||
pkgType := 99
|
pkgType := 99
|
||||||
var pkgInfo []PkgInfo
|
var pkgInfo []PkgInfo
|
||||||
@@ -36,7 +36,7 @@ func update(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range pkgInfo {
|
for _, pkg := range pkgInfo {
|
||||||
pkgList = append(pkgList, download.UpdateData{
|
pkgList = append(pkgList, downloadschema.UpdateData{
|
||||||
Size: pkg.Size,
|
Size: pkg.Size,
|
||||||
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
URL: fmt.Sprintf("%s/%s/archives/%d_%d_%d.zip",
|
||||||
config.Conf.Settings.CdnServer, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order),
|
config.Conf.Settings.CdnServer, downloadReq.TargetOs, pkgType, pkg.Id, pkg.Order),
|
||||||
@@ -60,7 +60,7 @@ func update(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(download.UpdateResp{
|
ss.Respond(downloadschema.UpdateResp{
|
||||||
ResponseData: pkgList,
|
ResponseData: pkgList,
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/download"
|
downloadschema "honoka-chan/internal/schema/download"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ func url(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
downloadReq := download.UrlReq{}
|
downloadReq := downloadschema.UrlReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &downloadReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -34,8 +34,8 @@ func url(ctx *gin.Context) {
|
|||||||
cdnServer, downloadReq.Os, strings.ReplaceAll(v, "\\", "")))
|
cdnServer, downloadReq.Os, strings.ReplaceAll(v, "\\", "")))
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(download.UrlResp{
|
ss.Respond(downloadschema.UrlResp{
|
||||||
ResponseData: download.UrlData{
|
ResponseData: downloadschema.UrlData{
|
||||||
UrlList: urlList,
|
UrlList: urlList,
|
||||||
},
|
},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package event
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/event"
|
eventschema "honoka-chan/internal/schema/event"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ func list(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
targets := []event.TargetList{}
|
targets := []eventschema.TargetList{}
|
||||||
for i := range 6 {
|
for i := range 6 {
|
||||||
targets = append(targets, event.TargetList{
|
targets = append(targets, eventschema.TargetList{
|
||||||
Position: i + 1,
|
Position: i + 1,
|
||||||
IsDisplayable: false,
|
IsDisplayable: false,
|
||||||
})
|
})
|
||||||
@@ -30,8 +30,8 @@ func list(ctx *gin.Context) {
|
|||||||
// StatusCode: 600,
|
// StatusCode: 600,
|
||||||
// })
|
// })
|
||||||
|
|
||||||
ss.Respond(event.ListResp{
|
ss.Respond(eventschema.ListResp{
|
||||||
ResponseData: event.ListData{
|
ResponseData: eventschema.ListData{
|
||||||
TargetList: targets,
|
TargetList: targets,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package gdpr
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/gdpr"
|
gdprschema "honoka-chan/internal/schema/gdpr"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func get(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(gdpr.GetResp{
|
ss.Respond(gdprschema.GetResp{
|
||||||
ResponseData: gdpr.GetData{
|
ResponseData: gdprschema.GetData{
|
||||||
EnableGdpr: true,
|
EnableGdpr: true,
|
||||||
IsEea: false,
|
IsEea: false,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package account
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,10 +12,10 @@ func active(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(ghome.ActiveResp{
|
ss.Respond(ghomeschema.ActiveResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: ghome.ActiveData{
|
Data: ghomeschema.ActiveData{
|
||||||
Message: "ok",
|
Message: "ok",
|
||||||
Result: 0,
|
Result: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ func initialize(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
initData := ghome.InitializeData{
|
initData := ghomeschema.InitializeData{
|
||||||
BrandLogo: "http://gskd.sdo.com/ghome/ztc/logo/og/logo_xhdpi.png",
|
BrandLogo: "http://gskd.sdo.com/ghome/ztc/logo/og/logo_xhdpi.png",
|
||||||
BrandName: "盛趣游戏",
|
BrandName: "盛趣游戏",
|
||||||
ForceShowAgreement: 1,
|
ForceShowAgreement: 1,
|
||||||
@@ -38,7 +38,7 @@ func initialize(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.InitializeResp{
|
ss.Respond(ghomeschema.InitializeResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: base64.StdEncoding.EncodeToString(encryptedData),
|
Data: base64.StdEncoding.EncodeToString(encryptedData),
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/internal/model/user"
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/api/profile"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/schema/api/unit"
|
|
||||||
ghomeschema "honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
"honoka-chan/pkg/utils"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -62,10 +62,10 @@ func login(ctx *gin.Context) {
|
|||||||
userID, _ = checkUserID(ss, int(loginTime))
|
userID, _ = checkUserID(ss, int(loginTime))
|
||||||
|
|
||||||
pass = openssl.Md5ToString(password)
|
pass = openssl.Md5ToString(password)
|
||||||
autoKey = "AUTO" + strings.ToUpper(honokautils.RandomStr(32))
|
autoKey = "AUTO" + strings.ToUpper(utils.RandomStr(32))
|
||||||
ticket = fmt.Sprintf("9999999%d%d", userID, userID)
|
ticket = fmt.Sprintf("9999999%d%d", userID, userID)
|
||||||
|
|
||||||
userData := user.Users{
|
userData := usermodel.Users{
|
||||||
Phone: phone,
|
Phone: phone,
|
||||||
Password: pass,
|
Password: pass,
|
||||||
Autokey: autoKey,
|
Autokey: autoKey,
|
||||||
@@ -80,7 +80,7 @@ func login(ctx *gin.Context) {
|
|||||||
|
|
||||||
// 方便起见初始化 userid 和 key 一样
|
// 方便起见初始化 userid 和 key 一样
|
||||||
// 注意:user_key 表中的 key 是上文生成的用于登录的 userid,而 userid 则是用于 Authorize Token 生成用的
|
// 注意:user_key 表中的 key 是上文生成的用于登录的 userid,而 userid 则是用于 Authorize Token 生成用的
|
||||||
userKey := user.UserKey{
|
userKey := usermodel.UserKey{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
Key: userID,
|
Key: userID,
|
||||||
}
|
}
|
||||||
@@ -96,20 +96,59 @@ func login(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
// 默认中心成员
|
// 生成用于卡片
|
||||||
var unitOwningUserID int
|
var unitData []unitmodel.CommonUnitData
|
||||||
_, err = ss.MainEng.Table("common_unit_m").Cols("unit_owning_user_id").Where("unit_id = ?", 31).Get(&unitOwningUserID)
|
err = ss.UserEng.Table(new(unitmodel.CommonUnitData)).Find(&unitData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userPref := user.UserPref{
|
checked := false
|
||||||
|
for _, u := range unitData {
|
||||||
|
userUnit := usermodel.UserUnitData{
|
||||||
|
UnitID: u.UnitID,
|
||||||
|
FavoriteFlag: false,
|
||||||
|
DisplayRank: u.MaxRank,
|
||||||
|
UserID: userID,
|
||||||
|
InsertDate: time.Now().Unix(),
|
||||||
|
UpdateDate: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表里是否已经有数据
|
||||||
|
if !checked {
|
||||||
|
ct, err := ss.UserEng.Table(new(usermodel.UserUnitData)).Count()
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ct == 0 {
|
||||||
|
userUnit.UnitOwningUserID = 38383
|
||||||
|
}
|
||||||
|
|
||||||
|
checked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitData)).Insert(&userUnit)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认中心成员
|
||||||
|
var unitOwningUserID int
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitData)).
|
||||||
|
Cols("unit_owning_user_id").Where("unit_id = ?", 31).Get(&unitOwningUserID)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userPref := usermodel.UserPref{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
AwardID: 1, // 音乃木坂学生
|
AwardID: 1, // 音乃木坂学生
|
||||||
BackgroundID: 1, // 初始背景
|
BackgroundID: 1, // 初始背景
|
||||||
UnitOwningUserID: unitOwningUserID,
|
UnitOwningUserID: unitOwningUserID,
|
||||||
UserName: "音乃木坂学生",
|
UserName: "音乃木坂学生",
|
||||||
UserLevel: 1,
|
UserLevel: 1028,
|
||||||
UserDesc: "你好。",
|
UserDesc: "你好。",
|
||||||
InviteCode: strconv.Itoa(userID),
|
InviteCode: strconv.Itoa(userID),
|
||||||
UpdateTime: time.Now().Unix(),
|
UpdateTime: time.Now().Unix(),
|
||||||
@@ -128,7 +167,7 @@ func login(ctx *gin.Context) {
|
|||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
// 默认队伍
|
// 默认队伍
|
||||||
userDeck := unit.UserDeckData{
|
userDeck := unitapischema.UserDeckData{
|
||||||
DeckID: 1,
|
DeckID: 1,
|
||||||
MainFlag: 1,
|
MainFlag: 1,
|
||||||
DeckName: "队伍A",
|
DeckName: "队伍A",
|
||||||
@@ -139,44 +178,37 @@ func login(ctx *gin.Context) {
|
|||||||
userDeckID := userDeck.ID
|
userDeckID := userDeck.ID
|
||||||
|
|
||||||
// 默认卡组 - 仆光
|
// 默认卡组 - 仆光
|
||||||
unitID := []int{}
|
unitID := []int{3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473}
|
||||||
err = ss.MainEng.Table("unit_m").Cols("unit_id").Where("album_series_id = ?", 615).Find(&unitID)
|
var unitData []unitmodel.UnitDataMap
|
||||||
|
err = ss.GetBasicUnitInfo().In("a.unit_id", unitID).Find(&unitData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
unitData := []profile.UnitData{}
|
for i, u := range unitData {
|
||||||
err = ss.MainEng.Table("common_unit_m").In("unit_id", unitID).Find(&unitData)
|
unitDeckData := usermodel.UserDeckUnit{
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
position := 1
|
|
||||||
for _, u := range unitData {
|
|
||||||
unitDeckData := unit.UnitDeckData{
|
|
||||||
UserDeckID: userDeckID,
|
UserDeckID: userDeckID,
|
||||||
UnitOwningUserID: u.UnitOwningUserID,
|
UnitOwningUserID: u.UnitOwningUserID,
|
||||||
UnitID: u.UnitID,
|
UnitID: u.UnitID,
|
||||||
Position: position,
|
Position: i + 1,
|
||||||
Level: 100,
|
Level: u.Level,
|
||||||
LevelLimitID: 1,
|
LevelLimitID: u.LevelLimitID,
|
||||||
DisplayRank: 2,
|
DisplayRank: u.DisplayRank,
|
||||||
Love: 1000,
|
Love: u.MaxLove,
|
||||||
UnitSkillLevel: 8,
|
UnitSkillLevel: u.UnitSkillLevel,
|
||||||
IsRankMax: true,
|
IsRankMax: u.IsRankMax,
|
||||||
IsLoveMax: true,
|
IsLoveMax: u.IsLoveMax,
|
||||||
IsLevelMax: true,
|
IsLevelMax: u.IsLevelMax,
|
||||||
IsSigned: u.IsSigned,
|
IsSigned: u.IsSigned,
|
||||||
BeforeLove: 1000,
|
BeforeLove: u.MaxLove,
|
||||||
MaxLove: 1000,
|
MaxLove: u.MaxLove,
|
||||||
InsertData: time.Now().Unix(),
|
UserID: userID,
|
||||||
|
InsertDate: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
_, err = ss.UserEng.Table("user_deck_unit").Insert(&unitDeckData)
|
_, err = ss.UserEng.Table("user_deck_unit").Insert(&unitDeckData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
position++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +225,7 @@ func login(ctx *gin.Context) {
|
|||||||
loginCode = 31
|
loginCode = 31
|
||||||
loginMsg = "账号不存在或者密码有误!"
|
loginMsg = "账号不存在或者密码有误!"
|
||||||
} else {
|
} else {
|
||||||
userData := user.Users{
|
userData := usermodel.Users{
|
||||||
Autokey: autoKey,
|
Autokey: autoKey,
|
||||||
Ticket: ticket,
|
Ticket: ticket,
|
||||||
LastLoginTime: loginTime,
|
LastLoginTime: loginTime,
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package account
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-think/openssl"
|
"github.com/go-think/openssl"
|
||||||
@@ -36,27 +38,27 @@ func loginAuto(ctx *gin.Context) {
|
|||||||
params, _ := url.ParseQuery(queryStr)
|
params, _ := url.ParseQuery(queryStr)
|
||||||
autoKey := params.Get("autokey")
|
autoKey := params.Get("autokey")
|
||||||
|
|
||||||
var uid, ticket string
|
var userData usermodel.Users
|
||||||
_, err = ss.UserEng.Table("users").Cols("user_id,ticket").Where("autokey = ?", autoKey).Get(&uid, &ticket)
|
exists, err := ss.UserEng.Table("users").Where("autokey = ?", autoKey).Get(&userData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loginAutoData := ghome.LoginAutoData{}
|
loginAutoData := ghomeschema.LoginAutoData{}
|
||||||
loginAutoCode := 0
|
loginAutoCode := 0
|
||||||
loginAutoMsg := "ok"
|
loginAutoMsg := "ok"
|
||||||
if uid != "" {
|
if exists {
|
||||||
loginAutoData = ghome.LoginAutoData{
|
loginAutoData = ghomeschema.LoginAutoData{
|
||||||
Result: loginAutoCode,
|
Result: loginAutoCode,
|
||||||
Message: loginAutoMsg,
|
Message: loginAutoMsg,
|
||||||
Autokey: autoKey,
|
Autokey: autoKey,
|
||||||
UserId: uid,
|
UserId: strconv.Itoa(userData.UserID),
|
||||||
Ticket: ticket,
|
Ticket: userData.Ticket,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loginAutoCode = 31
|
loginAutoCode = 31
|
||||||
loginAutoMsg = "账号不存在或者登陆状态已过期!"
|
loginAutoMsg = "账号不存在或者登陆状态已过期!"
|
||||||
loginAutoData = ghome.LoginAutoData{
|
loginAutoData = ghomeschema.LoginAutoData{
|
||||||
Result: loginAutoCode,
|
Result: loginAutoCode,
|
||||||
Message: loginAutoMsg,
|
Message: loginAutoMsg,
|
||||||
}
|
}
|
||||||
@@ -71,7 +73,7 @@ func loginAuto(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.LoginAutoResp{
|
ss.Respond(ghomeschema.LoginAutoResp{
|
||||||
Code: loginAutoCode,
|
Code: loginAutoCode,
|
||||||
Msg: loginAutoMsg,
|
Msg: loginAutoMsg,
|
||||||
Data: base64.StdEncoding.EncodeToString(encryptedData),
|
Data: base64.StdEncoding.EncodeToString(encryptedData),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package account
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -21,7 +21,7 @@ func reportRole(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.ReportRoleResp{
|
ss.Respond(ghomeschema.ReportRoleResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: base64.StdEncoding.EncodeToString(encryptedToken),
|
Data: base64.StdEncoding.EncodeToString(encryptedToken),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package basic
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -20,7 +20,7 @@ func getCode(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.GetCodeResp{
|
ss.Respond(ghomeschema.GetCodeResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: getCodeData,
|
Data: getCodeData,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package basic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,12 +12,12 @@ func getProductList(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
getProductListData := ghome.GetProductListData{
|
getProductListData := ghomeschema.GetProductListData{
|
||||||
Message: []string{},
|
Message: []string{},
|
||||||
Result: 0,
|
Result: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.GetProductListResp{
|
ss.Respond(ghomeschema.GetProductListResp{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: getProductListData,
|
Data: getProductListData,
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"honoka-chan/pkg/db"
|
|
||||||
"honoka-chan/pkg/encrypt"
|
"honoka-chan/pkg/encrypt"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -34,21 +33,16 @@ func handshake(ctx *gin.Context) {
|
|||||||
|
|
||||||
params, _ := url.ParseQuery(string(decryptedData))
|
params, _ := url.ParseQuery(string(decryptedData))
|
||||||
|
|
||||||
randKey := []byte(params.Get("randkey"))
|
randKey := params.Get("randkey")
|
||||||
deviceID := ss.GetDeviceID()
|
ss.SetRandKey(randKey)
|
||||||
|
|
||||||
err = db.Ldb.Set([]byte(deviceID), randKey)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token := fmt.Sprintf(`{"message":"ok","result":0,"token":"%s"}`, strings.ToUpper(honokautils.RandomStr(33)))
|
token := fmt.Sprintf(`{"message":"ok","result":0,"token":"%s"}`, strings.ToUpper(honokautils.RandomStr(33)))
|
||||||
encryptedToken, err := openssl.Des3ECBEncrypt([]byte(token), randKey[0:24], openssl.PKCS7_PADDING)
|
encryptedToken, err := openssl.Des3ECBEncrypt([]byte(token), []byte(randKey)[0:24], openssl.PKCS7_PADDING)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.HandshakeResp{
|
ss.Respond(ghomeschema.HandshakeResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: base64.StdEncoding.EncodeToString(encryptedToken),
|
Data: base64.StdEncoding.EncodeToString(encryptedToken),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package basic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,10 +12,10 @@ func loginArea(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(ghome.LoginAreaResp{
|
ss.Respond(ghomeschema.LoginAreaResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: ghome.LoginAreaData{
|
Data: ghomeschema.LoginAreaData{
|
||||||
UserID: ctx.PostForm("userid"),
|
UserID: ctx.PostForm("userid"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ func publicKey(ctx *gin.Context) {
|
|||||||
|
|
||||||
publicKeyCode := 0
|
publicKeyCode := 0
|
||||||
publicKeyMsg := "ok"
|
publicKeyMsg := "ok"
|
||||||
publicKeyData := ghome.PublicKeyData{
|
publicKeyData := ghomeschema.PublicKeyData{
|
||||||
Result: publicKeyCode,
|
Result: publicKeyCode,
|
||||||
Message: publicKeyMsg,
|
Message: publicKeyMsg,
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func publicKey(ctx *gin.Context) {
|
|||||||
publicKeyData.Method = "rsa"
|
publicKeyData.Method = "rsa"
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(ghome.PublicKeyResp{
|
ss.Respond(ghomeschema.PublicKeyResp{
|
||||||
Code: publicKeyCode,
|
Code: publicKeyCode,
|
||||||
Msg: publicKeyMsg,
|
Msg: publicKeyMsg,
|
||||||
Data: publicKeyData,
|
Data: publicKeyData,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package guest
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,10 +12,10 @@ func status(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(ghome.GuestStatusResp{
|
ss.Respond(ghomeschema.GuestStatusResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "ok",
|
Msg: "ok",
|
||||||
Data: ghome.GuestStatusData{
|
Data: ghomeschema.GuestStatusData{
|
||||||
Disablead: 1,
|
Disablead: 1,
|
||||||
Loginswitch: 1,
|
Loginswitch: 1,
|
||||||
Message: "ok",
|
Message: "ok",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package misc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,11 +12,11 @@ func agreement(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(ghome.AgreementResp{
|
ss.Respond(ghomeschema.AgreementResp{
|
||||||
ReturnCode: 0,
|
ReturnCode: 0,
|
||||||
ErrorType: 0,
|
ErrorType: 0,
|
||||||
ReturnMessage: "",
|
ReturnMessage: "",
|
||||||
Data: ghome.AgreementData{},
|
Data: ghomeschema.AgreementData{},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package misc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/ghome"
|
ghomeschema "honoka-chan/internal/schema/ghome"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,10 +12,10 @@ func appReport(ctx *gin.Context) {
|
|||||||
ss := session.New(ctx)
|
ss := session.New(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(ghome.AppReportResp{
|
ss.Respond(ghomeschema.AppReportResp{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "",
|
Msg: "",
|
||||||
Data: ghome.AppReportData{
|
Data: ghomeschema.AppReportData{
|
||||||
NeedReport: 0,
|
NeedReport: 0,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package lbonus
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/lbonus"
|
lbonusschema "honoka-chan/internal/schema/lbonus"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ func execute(ctx *gin.Context) {
|
|||||||
d2 := d1.AddDate(0, 1, -1)
|
d2 := d1.AddDate(0, 1, -1)
|
||||||
// fmt.Println(d2)
|
// fmt.Println(d2)
|
||||||
|
|
||||||
weeksList := []lbonus.Day{}
|
weeksList := []lbonusschema.Day{}
|
||||||
for c := d1; ; c = c.AddDate(0, 0, 1) {
|
for c := d1; ; c = c.AddDate(0, 0, 1) {
|
||||||
_, _, rd := c.Date()
|
_, _, rd := c.Date()
|
||||||
received := false
|
received := false
|
||||||
@@ -43,14 +43,14 @@ func execute(ctx *gin.Context) {
|
|||||||
received = true
|
received = true
|
||||||
}
|
}
|
||||||
rw := weeks[c.Weekday().String()]
|
rw := weeks[c.Weekday().String()]
|
||||||
weeksList = append(weeksList, lbonus.Day{
|
weeksList = append(weeksList, lbonusschema.Day{
|
||||||
Day: rd,
|
Day: rd,
|
||||||
DayOfTheWeek: rw,
|
DayOfTheWeek: rw,
|
||||||
SpecialDay: false,
|
SpecialDay: false,
|
||||||
SpecialImageAsset: "",
|
SpecialImageAsset: "",
|
||||||
Received: received,
|
Received: received,
|
||||||
AdReceived: false,
|
AdReceived: false,
|
||||||
Item: lbonus.Item{
|
Item: lbonusschema.Item{
|
||||||
ItemID: 4,
|
ItemID: 4,
|
||||||
AddType: 3001,
|
AddType: 3001,
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
@@ -72,18 +72,18 @@ func execute(ctx *gin.Context) {
|
|||||||
d2 = d1.AddDate(0, 1, -1)
|
d2 = d1.AddDate(0, 1, -1)
|
||||||
// fmt.Println(d2)
|
// fmt.Println(d2)
|
||||||
|
|
||||||
nextWeeksList := []lbonus.Day{}
|
nextWeeksList := []lbonusschema.Day{}
|
||||||
for c := d1; ; c = c.AddDate(0, 0, 1) {
|
for c := d1; ; c = c.AddDate(0, 0, 1) {
|
||||||
_, _, rd := c.Date()
|
_, _, rd := c.Date()
|
||||||
rw := weeks[c.Weekday().String()]
|
rw := weeks[c.Weekday().String()]
|
||||||
nextWeeksList = append(nextWeeksList, lbonus.Day{
|
nextWeeksList = append(nextWeeksList, lbonusschema.Day{
|
||||||
Day: rd,
|
Day: rd,
|
||||||
DayOfTheWeek: rw,
|
DayOfTheWeek: rw,
|
||||||
SpecialDay: false,
|
SpecialDay: false,
|
||||||
SpecialImageAsset: "",
|
SpecialImageAsset: "",
|
||||||
Received: false,
|
Received: false,
|
||||||
AdReceived: false,
|
AdReceived: false,
|
||||||
Item: lbonus.Item{
|
Item: lbonusschema.Item{
|
||||||
ItemID: 4,
|
ItemID: 4,
|
||||||
AddType: 3001,
|
AddType: 3001,
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
@@ -94,26 +94,26 @@ func execute(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := lbonus.ExecuteResp{
|
resp := lbonusschema.ExecuteResp{
|
||||||
ResponseData: lbonus.ExecuteData{
|
ResponseData: lbonusschema.ExecuteData{
|
||||||
Sheets: []any{},
|
Sheets: []any{},
|
||||||
CalendarInfo: lbonus.CalendarInfo{
|
CalendarInfo: lbonusschema.CalendarInfo{
|
||||||
CurrentDate: time.Now().Format("2006-01-02 03:04:05"),
|
CurrentDate: time.Now().Format("2006-01-02 03:04:05"),
|
||||||
CurrentMonth: lbonus.Month{
|
CurrentMonth: lbonusschema.Month{
|
||||||
Year: y,
|
Year: y,
|
||||||
Month: int(cm),
|
Month: int(cm),
|
||||||
Days: weeksList,
|
Days: weeksList,
|
||||||
},
|
},
|
||||||
NextMonth: lbonus.Month{
|
NextMonth: lbonusschema.Month{
|
||||||
Year: y,
|
Year: y,
|
||||||
Month: int(m),
|
Month: int(m),
|
||||||
Days: nextWeeksList,
|
Days: nextWeeksList,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TotalLoginInfo: lbonus.TotalLoginInfo{
|
TotalLoginInfo: lbonusschema.TotalLoginInfo{
|
||||||
LoginCount: 2626,
|
LoginCount: 2626,
|
||||||
RemainingCount: 74,
|
RemainingCount: 74,
|
||||||
Reward: []lbonus.Reward{
|
Reward: []lbonusschema.Reward{
|
||||||
{
|
{
|
||||||
ItemID: 5,
|
ItemID: 5,
|
||||||
AddType: 1000,
|
AddType: 1000,
|
||||||
@@ -122,8 +122,8 @@ func execute(ctx *gin.Context) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
LicenseLbonusList: []any{},
|
LicenseLbonusList: []any{},
|
||||||
ClassSystem: lbonus.ClassSystem{
|
ClassSystem: lbonusschema.ClassSystem{
|
||||||
RankInfo: lbonus.RankInfo{
|
RankInfo: lbonusschema.RankInfo{
|
||||||
BeforeClassRankID: 10,
|
BeforeClassRankID: 10,
|
||||||
AfterClassRankID: 10,
|
AfterClassRankID: 10,
|
||||||
RankUpDate: "2020-02-12 11:57:15",
|
RankUpDate: "2020-02-12 11:57:15",
|
||||||
@@ -133,17 +133,17 @@ func execute(ctx *gin.Context) {
|
|||||||
IsVisible: true,
|
IsVisible: true,
|
||||||
},
|
},
|
||||||
StartDashSheets: []any{},
|
StartDashSheets: []any{},
|
||||||
EffortPoint: []lbonus.EffortPoint{
|
EffortPoint: []lbonusschema.EffortPoint{
|
||||||
{
|
{
|
||||||
LiveEffortPointBoxSpecID: 5,
|
LiveEffortPointBoxSpecID: 5,
|
||||||
Capacity: 4000000,
|
Capacity: 4000000,
|
||||||
Before: 1400116,
|
Before: 1400116,
|
||||||
After: 1400116,
|
After: 1400116,
|
||||||
Rewards: []lbonus.Rewards{},
|
Rewards: []lbonusschema.Rewards{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
LimitedEffortBox: []any{},
|
LimitedEffortBox: []any{},
|
||||||
MuseumInfo: lbonus.Museum{},
|
MuseumInfo: lbonusschema.Museum{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
PresentCnt: 0,
|
PresentCnt: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package live
|
||||||
|
|
||||||
|
import (
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func continuee(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
ss.Respond(liveschema.ContinueResp{
|
||||||
|
ResponseData: liveschema.ContinueData{
|
||||||
|
BeforeSnsCoin: 100000,
|
||||||
|
AfterSnsCoin: 100000,
|
||||||
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/live/continue", middleware.Common, continuee)
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package live
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/live"
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -11,9 +11,12 @@ import (
|
|||||||
|
|
||||||
func gameOver(ctx *gin.Context) {
|
func gameOver(ctx *gin.Context) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer func() {
|
||||||
|
ss.ClearLiveInProgress()
|
||||||
|
ss.Finalize()
|
||||||
|
}()
|
||||||
|
|
||||||
ss.Respond(live.GameOverResp{
|
ss.Respond(liveschema.GameOverResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package live
|
package live
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"errors"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -14,14 +17,81 @@ func partyList(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
data := honokautils.ReadAllText("assets/serverdata/partylist.json")
|
pref := usermodel.UserPref{}
|
||||||
var partyResp map[string]any
|
_, err := ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||||
err := json.Unmarshal([]byte(data), &partyResp)
|
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(partyResp)
|
// TODO: 好友功能实装前先使用自己的卡组助战
|
||||||
|
var unitList []usermodel.UserDeckUnit
|
||||||
|
err = ss.UserEng.Table("user_deck_unit").Where("user_id = ? AND position = 5", ss.UserID).Find(&unitList)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var partyList []liveschema.PartyList
|
||||||
|
for _, u := range unitList {
|
||||||
|
var unitInfo unitmodel.UnitDataMap
|
||||||
|
has, err := ss.GetBasicUnitInfo().
|
||||||
|
Where("unit_owning_user_id = ?", u.UnitOwningUserID).Get(&unitInfo)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !has {
|
||||||
|
ss.Abort(errors.New("卡片不存在!"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
partyList = append(partyList, liveschema.PartyList{
|
||||||
|
UserInfo: ss.GetUserInfo(),
|
||||||
|
CenterUnitInfo: liveschema.CenterUnitInfo{
|
||||||
|
UnitOwningUserID: u.UnitOwningUserID,
|
||||||
|
UnitID: u.UnitID,
|
||||||
|
Exp: unitInfo.Exp,
|
||||||
|
NextExp: 0,
|
||||||
|
Level: u.Level,
|
||||||
|
LevelLimitID: u.LevelLimitID,
|
||||||
|
MaxLevel: unitInfo.MaxLevel,
|
||||||
|
Rank: unitInfo.Rank,
|
||||||
|
MaxRank: unitInfo.MaxRank,
|
||||||
|
Love: u.Love,
|
||||||
|
MaxLove: u.MaxLove,
|
||||||
|
UnitSkillLevel: u.UnitSkillLevel,
|
||||||
|
MaxHp: unitInfo.MaxHp,
|
||||||
|
FavoriteFlag: unitInfo.FavoriteFlag,
|
||||||
|
DisplayRank: u.DisplayRank,
|
||||||
|
UnitSkillExp: unitInfo.UnitSkillExp,
|
||||||
|
UnitRemovableSkillCapacity: unitInfo.UnitRemovableSkillCapacity,
|
||||||
|
Attribute: unitInfo.Attribute,
|
||||||
|
Smile: unitInfo.Smile,
|
||||||
|
Cute: unitInfo.Cute,
|
||||||
|
Cool: unitInfo.Cool,
|
||||||
|
IsLoveMax: u.IsLoveMax,
|
||||||
|
IsLevelMax: u.IsLevelMax,
|
||||||
|
IsRankMax: u.IsRankMax,
|
||||||
|
IsSigned: u.IsSigned,
|
||||||
|
IsSkillLevelMax: unitInfo.IsSkillLevelMax,
|
||||||
|
SettingAwardID: pref.AwardID,
|
||||||
|
RemovableSkillIds: []int{},
|
||||||
|
},
|
||||||
|
SettingAwardID: pref.AwardID,
|
||||||
|
AvailableSocialPoint: 10,
|
||||||
|
FriendStatus: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.Respond(liveschema.PartyListResp{
|
||||||
|
ResponseData: liveschema.PartyListData{
|
||||||
|
PartyList: partyList,
|
||||||
|
TrainingEnergy: 10,
|
||||||
|
TrainingEnergyMax: 10,
|
||||||
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
+144
-155
@@ -2,183 +2,157 @@ package live
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/live"
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"honoka-chan/pkg/db"
|
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func play(ctx *gin.Context) {
|
func play(ctx *gin.Context) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
playReq := live.PlayReq{}
|
playReq := liveschema.PlayReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// fmt.Println(ctx.MustGet("request_data").(string))
|
||||||
|
|
||||||
tDifficultyId := playReq.LiveDifficultyID
|
ss.RegisterLiveInProgress(playReq.UnitDeckID)
|
||||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
|
||||||
|
difficultyID, _ := strconv.Atoi(playReq.LiveDifficultyID)
|
||||||
|
|
||||||
|
// 歌曲类型: normal / special
|
||||||
|
// sqlite3 不支持 FULL OUTER JOIN 所以这里使用 UNION ALL
|
||||||
|
var liveSetting struct {
|
||||||
|
NotesSettingAsset string `xorm:"notes_setting_asset"`
|
||||||
|
ARankScore int `xorm:"a_rank_score"`
|
||||||
|
BRankScore int `xorm:"b_rank_score"`
|
||||||
|
CRankScore int `xorm:"c_rank_score"`
|
||||||
|
SRankScore int `xorm:"s_rank_score"`
|
||||||
|
AcFlag int `xorm:"ac_flag"`
|
||||||
|
SwingFlag int `xorm:"swing_flag"`
|
||||||
|
}
|
||||||
|
sql := `
|
||||||
|
SELECT notes_setting_asset,
|
||||||
|
a_rank_score,
|
||||||
|
b_rank_score,
|
||||||
|
c_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 = ?
|
||||||
|
)
|
||||||
|
`
|
||||||
|
_, err = ss.MainEng.SQL(sql, difficultyID, difficultyID).Get(&liveSetting)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
deckId := playReq.UnitDeckID
|
// fmt.Println("liveSetting", liveSetting)
|
||||||
|
|
||||||
// Save Deck Id for /live/reward
|
notes := []liveschema.NotesList{}
|
||||||
key := "live_deck_" + strconv.Itoa(ss.UserID)
|
notes_list := honokautils.ReadAllText("./assets/serverdata/beatmaps/" + liveSetting.NotesSettingAsset)
|
||||||
err = db.Ldb.Set([]byte(key), []byte(strconv.Itoa(deckId)))
|
|
||||||
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 = 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)
|
|
||||||
|
|
||||||
notes := []live.NotesList{}
|
|
||||||
// fmt.Println("./assets/serverdata/beatmaps/" + notes_setting_asset)
|
|
||||||
notes_list := honokautils.ReadAllText("./assets/serverdata/beatmaps/" + notes_setting_asset)
|
|
||||||
err = json.Unmarshal([]byte(notes_list), ¬es)
|
err = json.Unmarshal([]byte(notes_list), ¬es)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ranks := []live.RankInfo{}
|
ranks := []liveschema.RankInfo{}
|
||||||
ranks = append(ranks, live.RankInfo{
|
ranks = append(ranks, liveschema.RankInfo{
|
||||||
Rank: 5,
|
Rank: 5,
|
||||||
RankMin: 0,
|
RankMin: 0,
|
||||||
RankMax: c_rank_score,
|
RankMax: liveSetting.CRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 4,
|
Rank: 4,
|
||||||
RankMin: c_rank_score + 1,
|
RankMin: liveSetting.CRankScore + 1,
|
||||||
RankMax: b_rank_score,
|
RankMax: liveSetting.BRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 3,
|
Rank: 3,
|
||||||
RankMin: b_rank_score + 1,
|
RankMin: liveSetting.BRankScore + 1,
|
||||||
RankMax: a_rank_score,
|
RankMax: liveSetting.ARankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 2,
|
Rank: 2,
|
||||||
RankMin: a_rank_score + 1,
|
RankMin: liveSetting.ARankScore + 1,
|
||||||
RankMax: s_rank_score,
|
RankMax: liveSetting.SRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 1,
|
Rank: 1,
|
||||||
RankMin: s_rank_score + 1,
|
RankMin: liveSetting.SRankScore + 1,
|
||||||
RankMax: 0,
|
RankMax: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
// ss.UserEng.ShowSQL(true)
|
|
||||||
// ss.MainEng.ShowSQL(true)
|
|
||||||
owningIdList := []int{}
|
owningIdList := []int{}
|
||||||
err = ss.UserEng.Table("user_deck_unit").Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.id").
|
err = ss.UserEng.Table("user_deck_unit").
|
||||||
Where("user_id = ? AND deck_id = ?", ss.UserID, deckId).Cols("unit_owning_user_id").
|
Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.id").
|
||||||
OrderBy("user_deck_unit.position ASC").Find(&owningIdList)
|
Where("user_deck.user_id = ? AND user_deck.deck_id = ?", ss.UserID, playReq.UnitDeckID).
|
||||||
|
Cols("unit_owning_user_id").OrderBy("user_deck_unit.position ASC").Find(&owningIdList)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
unitList := []live.UnitList{}
|
unitList := []liveschema.UnitList{}
|
||||||
var totalSmile, totalPure, totalCool, maxLove float64
|
var totalSmile, totalPure, totalCool float64
|
||||||
var totalHp int
|
var totalHp int
|
||||||
for _, owningId := range owningIdList {
|
for _, owningId := range owningIdList {
|
||||||
var uId int
|
// 卡片基础属性
|
||||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
var baseSmile, basePure, baseCool, smileMax, pureMax, coolMax float64
|
||||||
|
var unitData unitmodel.UnitDataMap
|
||||||
|
_, err = ss.GetBasicUnitInfo().Where("unit_owning_user_id = ?", owningId).Get(&unitData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
baseSmile = float64(unitData.Smile)
|
||||||
var maxHp, attrId, unitTypeId int
|
basePure = float64(unitData.Cute)
|
||||||
var baseSmile, basePure, baseCool, smileMax, pureMax, coolMax float64
|
baseCool = float64(unitData.Cool)
|
||||||
if exists {
|
// fmt.Println("================================")
|
||||||
// 公共卡片仅为100级属性
|
// fmt.Println("基础属性:", baseSmile, basePure, baseCool)
|
||||||
_, 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)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 用户卡片暂时固定为满级350级
|
|
||||||
exists, err := ss.UserEng.Table("user_unit").Where("unit_owning_user_id = ?", owningId).Cols("unit_id").Get(&uId)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
// 卡片100级基础属性
|
|
||||||
_, 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)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 增量属性
|
|
||||||
var diffSmile, diffPure, diffCool float64
|
|
||||||
_, 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)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新卡片属性(注意这里是负数,要用减号)
|
|
||||||
baseSmile -= diffSmile
|
|
||||||
basePure -= diffPure
|
|
||||||
baseCool -= diffCool
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("no such unit owning id: %d", owningId)
|
|
||||||
}
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 饰品属性加成(满级)
|
// 饰品属性加成(满级)
|
||||||
var accessoryOwningId int
|
var accessoryOwningId int
|
||||||
_, err = ss.UserEng.Table("user_accessory_wear").Where("unit_owning_user_id = ?", owningId).
|
exists, err := ss.UserEng.Table("user_accessory_wear").
|
||||||
|
Where("unit_owning_user_id = ?", owningId).
|
||||||
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
Cols("accessory_owning_user_id").Get(&accessoryOwningId)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var smileAccessory, pureAccessory, coolAccessory float64
|
if exists {
|
||||||
_, err = ss.MainEng.Table("common_accessory_m").Join("LEFT", "accessory_m", "common_accessory_m.accessory_id = accessory_m.accessory_id").
|
var smileAccessory, pureAccessory, coolAccessory float64
|
||||||
Where("accessory_owning_user_id = ?", accessoryOwningId).Cols("smile_max,pure_max,cool_max").
|
_, err = ss.MainEng.Table("common_accessory_m").
|
||||||
Get(&smileAccessory, &pureAccessory, &coolAccessory)
|
Join("LEFT", "accessory_m", "common_accessory_m.accessory_id = accessory_m.accessory_id").
|
||||||
if ss.CheckErr(err) {
|
Where("accessory_owning_user_id = ?", accessoryOwningId).Cols("smile_max,pure_max,cool_max").
|
||||||
return
|
Get(&smileAccessory, &pureAccessory, &coolAccessory)
|
||||||
}
|
if ss.CheckErr(err) {
|
||||||
// fmt.Println("基础属性:", baseSmile, basePure, baseCool)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 饰品属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
// 饰品属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
||||||
baseSmile += smileAccessory
|
baseSmile += smileAccessory
|
||||||
basePure += pureAccessory
|
basePure += pureAccessory
|
||||||
baseCool += coolAccessory
|
baseCool += coolAccessory
|
||||||
// fmt.Println("饰品属性加成:", smileAccessory, pureAccessory, coolAccessory)
|
// fmt.Println("饰品属性加成:", smileAccessory, pureAccessory, coolAccessory)
|
||||||
// fmt.Println("饰品属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
// fmt.Println("饰品属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
||||||
|
}
|
||||||
|
|
||||||
// 回忆画廊属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
// 回忆画廊属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
||||||
var smileBuff, pureBuff, coolBuff float64
|
var smileBuff, pureBuff, coolBuff float64
|
||||||
_, err = ss.MainEng.Table("museum_contents_m").Select("SUM(smile_buff),SUM(pure_buff),SUM(cool_buff)").Get(&smileBuff, &pureBuff, &coolBuff)
|
_, 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) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -189,26 +163,25 @@ func play(ctx *gin.Context) {
|
|||||||
// fmt.Println("回忆画廊属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
// fmt.Println("回忆画廊属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
||||||
|
|
||||||
// 绊属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
// 绊属性加成(该加成会影响个宝等百分比宝石属性加成的计算,故先计算。)
|
||||||
switch attrId {
|
switch unitData.Attribute {
|
||||||
case 1:
|
case 1:
|
||||||
baseSmile += maxLove
|
baseSmile += float64(unitData.MaxLove)
|
||||||
case 2:
|
case 2:
|
||||||
basePure += maxLove
|
basePure += float64(unitData.MaxLove)
|
||||||
case 3:
|
case 3:
|
||||||
baseCool += maxLove
|
baseCool += float64(unitData.MaxLove)
|
||||||
}
|
}
|
||||||
// fmt.Println("绊属性加成:", maxLove)
|
// fmt.Println("绊属性加成:", unitData.MaxLove)
|
||||||
// fmt.Println("绊属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
// fmt.Println("绊属性加成后的基础属性:", baseSmile, basePure, baseCool)
|
||||||
|
|
||||||
// 宝石属性加成
|
// 宝石属性加成
|
||||||
var kissSmile, kissPure, kissCool float64
|
var kissSmile, kissPure, kissCool float64
|
||||||
var skillSmile, skillPure, skillCool float64
|
var skillSmile, skillPure, skillCool float64
|
||||||
// var mainCenterSmile, mainCenterPure, mainCenterCool float64
|
|
||||||
// var secCenterSmile, secCenterPure, secCenterCool float64
|
|
||||||
|
|
||||||
// 宝石加成(满级)
|
// 宝石加成(满级)
|
||||||
removableSkillIds := []int{}
|
removableSkillIds := []int{}
|
||||||
err = ss.UserEng.Table("user_unit_skill_equip").Where("unit_owning_user_id = ? AND user_id = ?", owningId, ss.UserID).
|
err = ss.UserEng.Table("user_unit_skill_equip").
|
||||||
|
Where("unit_owning_user_id = ?", owningId).
|
||||||
Cols("unit_removable_skill_id").Find(&removableSkillIds)
|
Cols("unit_removable_skill_id").Find(&removableSkillIds)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -218,7 +191,8 @@ func play(ctx *gin.Context) {
|
|||||||
// 判断宝石效果类型(效果范围、效果类型、效果值、是否固定数值)
|
// 判断宝石效果类型(效果范围、效果类型、效果值、是否固定数值)
|
||||||
var effectRange, effectType, fixedValueFlag, refType int
|
var effectRange, effectType, fixedValueFlag, refType int
|
||||||
var effectValue float64
|
var effectValue float64
|
||||||
_, err = ss.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").
|
Cols("effect_range,effect_type,effect_value,fixed_value_flag,target_reference_type").
|
||||||
Get(&effectRange, &effectType, &effectValue, &fixedValueFlag, &refType)
|
Get(&effectRange, &effectType, &effectValue, &fixedValueFlag, &refType)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
@@ -276,7 +250,8 @@ func play(ctx *gin.Context) {
|
|||||||
|
|
||||||
// 主唱技能加成
|
// 主唱技能加成
|
||||||
var myCenterUnitId int
|
var myCenterUnitId int
|
||||||
_, err = ss.UserEng.Table("user_deck_unit").Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.id").
|
_, err = ss.UserEng.Table("user_deck_unit").
|
||||||
|
Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.id").
|
||||||
Where("user_deck.deck_id = ? AND user_deck.user_id = ? AND user_deck_unit.position = 5", playReq.UnitDeckID, ss.UserID).
|
Where("user_deck.deck_id = ? AND user_deck.user_id = ? AND user_deck_unit.position = 5", playReq.UnitDeckID, ss.UserID).
|
||||||
Cols("user_deck_unit.unit_id").Get(&myCenterUnitId)
|
Cols("user_deck_unit.unit_id").Get(&myCenterUnitId)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
@@ -310,16 +285,18 @@ func play(ctx *gin.Context) {
|
|||||||
_, err = ss.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").
|
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).
|
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)
|
Cols("unit_leader_skill_extra_m.effect_value,unit_leader_skill_extra_m.member_tag_id").
|
||||||
|
Get(&mySubEffectValue, &myMemberTagId)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exists, err = ss.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()
|
Where("unit_type_id = ? AND member_tag_id = ?", unitData.UnitTypeID, myMemberTagId).Exist()
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var mySubSmile, mySubPure, mySubCool float64
|
var mySubSmile, mySubPure, mySubCool float64
|
||||||
if exists {
|
if exists {
|
||||||
switch myAttrId {
|
switch myAttrId {
|
||||||
@@ -335,24 +312,26 @@ func play(ctx *gin.Context) {
|
|||||||
|
|
||||||
// 好友主唱技能加成
|
// 好友主唱技能加成
|
||||||
// TODO 好友支援存入数据库
|
// TODO 好友支援存入数据库
|
||||||
var tomoUnitId int64
|
// var tomoUnitId int64
|
||||||
partyList := gjson.Parse(honokautils.ReadAllText("assets/serverdata/partylist.json")).Get("response_data.party_list")
|
// partyList := gjson.Parse(honokautils.ReadAllText("assets/serverdata/partylist.json")).Get("response_data.party_list")
|
||||||
partyList.ForEach(func(key, value gjson.Result) bool {
|
// partyList.ForEach(func(key, value gjson.Result) bool {
|
||||||
if value.Get("user_info.user_id").Int() == playReq.PartyUserID {
|
// if value.Get("user_info.user_id").Int() == playReq.PartyUserID {
|
||||||
tomoUnitId = value.Get("center_unit_info.unit_id").Int()
|
// tomoUnitId = value.Get("center_unit_info.unit_id").Int()
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
})
|
// })
|
||||||
|
// TODO: 好友功能实装前先使用自己的卡组助战
|
||||||
|
tomoUnitId := myCenterUnitId
|
||||||
// fmt.Println("好友UnitID:", tomoUnitId)
|
// fmt.Println("好友UnitID:", tomoUnitId)
|
||||||
|
|
||||||
// 好友主唱技能加成:主C技能(这里不使用新C技能,即以某属性的百分比提升另一属性)
|
// 好友主唱技能加成:主C技能(这里不使用新C技能,即以某属性的百分比提升另一属性)
|
||||||
var tomoAttrId int
|
|
||||||
var tomoEffectValue float64
|
var tomoEffectValue float64
|
||||||
_, err = ss.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").
|
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).
|
Where("unit_m.unit_id = ?", tomoUnitId).
|
||||||
Cols("unit_m.attribute_id,unit_leader_skill_m.effect_value").Get(&tomoAttrId, &tomoEffectValue)
|
Cols("unit_leader_skill_m.effect_value").
|
||||||
|
Get(&tomoEffectValue)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -373,13 +352,14 @@ func play(ctx *gin.Context) {
|
|||||||
_, err = ss.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").
|
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).
|
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)
|
Cols("unit_leader_skill_extra_m.effect_value,unit_leader_skill_extra_m.member_tag_id").
|
||||||
|
Get(&tomoSubEffectValue, &tomoMemberTagId)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exists, err = ss.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()
|
Where("unit_type_id = ? AND member_tag_id = ?", unitData.UnitTypeID, tomoMemberTagId).Exist()
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -400,7 +380,16 @@ func play(ctx *gin.Context) {
|
|||||||
totalSmile += smileMax + myCenterSmile + mySubSmile + tomoCenterSmile + tomoSubSmile
|
totalSmile += smileMax + myCenterSmile + mySubSmile + tomoCenterSmile + tomoSubSmile
|
||||||
totalPure += pureMax + myCenterPure + mySubPure + tomoCenterPure + tomoSubPure
|
totalPure += pureMax + myCenterPure + mySubPure + tomoCenterPure + tomoSubPure
|
||||||
totalCool += coolMax + myCenterCool + mySubCool + tomoCenterCool + tomoSubCool
|
totalCool += coolMax + myCenterCool + mySubCool + tomoCenterCool + tomoSubCool
|
||||||
totalHp += maxHp
|
totalHp += unitData.MaxHp
|
||||||
|
// fmt.Println("smileMax, myCenterSmile, mySubSmile, tomoCenterSmile, tomoSubSmile, totalSmile",
|
||||||
|
// smileMax, myCenterSmile, mySubSmile, tomoCenterSmile, tomoSubSmile,
|
||||||
|
// smileMax+myCenterSmile+mySubSmile+tomoCenterSmile+tomoSubSmile)
|
||||||
|
// fmt.Println("pureMax, myCenterPure, mySubPure, tomoCenterPure, tomoSubPure, totalPure",
|
||||||
|
// pureMax, myCenterPure, mySubPure, tomoCenterPure, tomoSubPure,
|
||||||
|
// pureMax+myCenterPure+mySubPure+tomoCenterPure+tomoSubPure)
|
||||||
|
// fmt.Println("coolMax, myCenterCool, mySubCool, tomoCenterCool, tomoSubCool, totalPure",
|
||||||
|
// coolMax, myCenterCool, mySubCool, tomoCenterCool, tomoSubCool,
|
||||||
|
// coolMax+myCenterCool+mySubCool+tomoCenterCool+tomoSubCool)
|
||||||
|
|
||||||
// 单卡属性计算结果取上取整
|
// 单卡属性计算结果取上取整
|
||||||
fixedSmileMax := int(smileMax)
|
fixedSmileMax := int(smileMax)
|
||||||
@@ -408,7 +397,7 @@ func play(ctx *gin.Context) {
|
|||||||
fixedCoolMax := int(coolMax)
|
fixedCoolMax := int(coolMax)
|
||||||
// fmt.Println("单卡属性:", fixedSmileMax, fixedPureMax, fixedCoolMax)
|
// fmt.Println("单卡属性:", fixedSmileMax, fixedPureMax, fixedCoolMax)
|
||||||
|
|
||||||
unitList = append(unitList, live.UnitList{
|
unitList = append(unitList, liveschema.UnitList{
|
||||||
Smile: fixedSmileMax,
|
Smile: fixedSmileMax,
|
||||||
Cute: fixedPureMax,
|
Cute: fixedPureMax,
|
||||||
Cool: fixedCoolMax,
|
Cool: fixedCoolMax,
|
||||||
@@ -421,17 +410,17 @@ func play(ctx *gin.Context) {
|
|||||||
fixedTotalCool := int(math.Ceil(totalCool))
|
fixedTotalCool := int(math.Ceil(totalCool))
|
||||||
// fmt.Println("全卡组属性:", fixedTotalSmile, fixedTotalPure, fixedTotalCool)
|
// fmt.Println("全卡组属性:", fixedTotalSmile, fixedTotalPure, fixedTotalCool)
|
||||||
|
|
||||||
lives := []live.PlayLiveList{}
|
lives := []liveschema.PlayLiveList{}
|
||||||
lives = append(lives, live.PlayLiveList{
|
lives = append(lives, liveschema.PlayLiveList{
|
||||||
LiveInfo: live.LiveInfo{
|
LiveInfo: liveschema.LiveInfo{
|
||||||
LiveDifficultyID: difficultyId,
|
LiveDifficultyID: difficultyID,
|
||||||
IsRandom: false,
|
IsRandom: false,
|
||||||
AcFlag: ac_flag,
|
AcFlag: liveSetting.AcFlag,
|
||||||
SwingFlag: swing_flag,
|
SwingFlag: liveSetting.SwingFlag,
|
||||||
NotesList: notes,
|
NotesList: notes,
|
||||||
},
|
},
|
||||||
DeckInfo: live.DeckInfo{
|
DeckInfo: liveschema.DeckInfo{
|
||||||
UnitDeckID: deckId,
|
UnitDeckID: playReq.UnitDeckID,
|
||||||
TotalSmile: fixedTotalSmile,
|
TotalSmile: fixedTotalSmile,
|
||||||
TotalCute: fixedTotalPure,
|
TotalCute: fixedTotalPure,
|
||||||
TotalCool: fixedTotalCool,
|
TotalCool: fixedTotalCool,
|
||||||
@@ -441,8 +430,8 @@ func play(ctx *gin.Context) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
playResp := live.PlayResp{
|
playResp := liveschema.PlayResp{
|
||||||
ResponseData: live.PlayData{
|
ResponseData: liveschema.PlayData{
|
||||||
RankInfo: ranks,
|
RankInfo: ranks,
|
||||||
EnergyFullTime: "2023-03-20 01:28:55",
|
EnergyFullTime: "2023-03-20 01:28:55",
|
||||||
OverMaxEnergy: 0,
|
OverMaxEnergy: 0,
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package live
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"honoka-chan/internal/constant"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/live"
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
"honoka-chan/pkg/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -17,90 +19,225 @@ func preciseScore(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
playScoreReq := live.PlayScoreReq{}
|
playScoreReq := liveschema.PlayScoreReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playScoreReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playScoreReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// fmt.Println(ctx.MustGet("request_data").(string))
|
||||||
|
|
||||||
tDifficultyId := playScoreReq.LiveDifficultyID
|
difficultyID, _ := strconv.Atoi(playScoreReq.LiveDifficultyID)
|
||||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
|
||||||
|
// 歌曲类型: normal / special
|
||||||
|
// sqlite3 不支持 FULL OUTER JOIN 所以这里使用 UNION ALL
|
||||||
|
var liveSetting struct {
|
||||||
|
NotesSettingAsset string `xorm:"notes_setting_asset"`
|
||||||
|
ARankScore int `xorm:"a_rank_score"`
|
||||||
|
BRankScore int `xorm:"b_rank_score"`
|
||||||
|
CRankScore int `xorm:"c_rank_score"`
|
||||||
|
SRankScore int `xorm:"s_rank_score"`
|
||||||
|
AcFlag int `xorm:"ac_flag"`
|
||||||
|
SwingFlag int `xorm:"swing_flag"`
|
||||||
|
}
|
||||||
|
sql := `
|
||||||
|
SELECT notes_setting_asset,
|
||||||
|
a_rank_score,
|
||||||
|
b_rank_score,
|
||||||
|
c_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 = ?
|
||||||
|
)
|
||||||
|
`
|
||||||
|
_, err = ss.MainEng.SQL(sql, difficultyID, difficultyID).Get(&liveSetting)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// fmt.Println("liveSetting", liveSetting)
|
||||||
|
|
||||||
// Song type: normal / special
|
notes := []liveschema.NotesList{}
|
||||||
// sqlite3 doesn't support FULL OUTER JOIN so use UNION ALL here.
|
notes_list := utils.ReadAllText("./assets/serverdata/beatmaps/" + liveSetting.NotesSettingAsset)
|
||||||
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 = 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)
|
|
||||||
|
|
||||||
notes := []live.NotesList{}
|
|
||||||
// fmt.Println("./assets/serverdata/beatmaps/" + notes_setting_asset)
|
|
||||||
notes_list := honokautils.ReadAllText("./assets/serverdata/beatmaps/" + notes_setting_asset)
|
|
||||||
err = json.Unmarshal([]byte(notes_list), ¬es)
|
err = json.Unmarshal([]byte(notes_list), ¬es)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ranks := []live.RankInfo{}
|
ranks := []liveschema.RankInfo{}
|
||||||
ranks = append(ranks, live.RankInfo{
|
ranks = append(ranks, liveschema.RankInfo{
|
||||||
Rank: 5,
|
Rank: 5,
|
||||||
RankMin: 0,
|
RankMin: 0,
|
||||||
RankMax: c_rank_score,
|
RankMax: liveSetting.CRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 4,
|
Rank: 4,
|
||||||
RankMin: c_rank_score + 1,
|
RankMin: liveSetting.CRankScore + 1,
|
||||||
RankMax: b_rank_score,
|
RankMax: liveSetting.BRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 3,
|
Rank: 3,
|
||||||
RankMin: b_rank_score + 1,
|
RankMin: liveSetting.BRankScore + 1,
|
||||||
RankMax: a_rank_score,
|
RankMax: liveSetting.ARankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 2,
|
Rank: 2,
|
||||||
RankMin: a_rank_score + 1,
|
RankMin: liveSetting.ARankScore + 1,
|
||||||
RankMax: s_rank_score,
|
RankMax: liveSetting.SRankScore,
|
||||||
}, live.RankInfo{
|
}, liveschema.RankInfo{
|
||||||
Rank: 1,
|
Rank: 1,
|
||||||
RankMin: s_rank_score + 1,
|
RankMin: liveSetting.SRankScore + 1,
|
||||||
RankMax: 0,
|
RankMax: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
playResp := live.PreciseScoreResp{
|
// 检查是否正在进行 Live
|
||||||
ResponseData: live.PreciseScoreData{
|
progress, _ := ss.GetLiveInProgress()
|
||||||
On: live.On{
|
|
||||||
HasRecord: false,
|
// 检查是否有 Live 记录
|
||||||
LiveInfo: live.LiveInfo{
|
liveRecord := ss.GetUserLiveRecord(difficultyID)
|
||||||
LiveDifficultyID: difficultyId,
|
|
||||||
IsRandom: false,
|
var skillOn liveschema.Skill
|
||||||
AcFlag: ac_flag,
|
var skillOff liveschema.Skill
|
||||||
SwingFlag: swing_flag,
|
var playResp liveschema.PreciseScoreResp
|
||||||
NotesList: notes,
|
|
||||||
|
// 正在进行 Live
|
||||||
|
if progress {
|
||||||
|
// 返回默认
|
||||||
|
playResp = liveschema.PreciseScoreResp{
|
||||||
|
ResponseData: liveschema.PreciseScoreData{
|
||||||
|
On: liveschema.Skill{
|
||||||
|
HasRecord: false,
|
||||||
|
LiveInfo: liveschema.LiveInfo{
|
||||||
|
LiveDifficultyID: difficultyID,
|
||||||
|
IsRandom: false,
|
||||||
|
AcFlag: liveSetting.AcFlag,
|
||||||
|
SwingFlag: liveSetting.SwingFlag,
|
||||||
|
NotesList: notes,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
Off: liveschema.Skill{
|
||||||
Off: live.Off{
|
HasRecord: false,
|
||||||
HasRecord: false,
|
LiveInfo: liveschema.LiveInfo{
|
||||||
LiveInfo: live.LiveInfo{
|
LiveDifficultyID: difficultyID,
|
||||||
LiveDifficultyID: difficultyId,
|
IsRandom: false,
|
||||||
IsRandom: false,
|
AcFlag: liveSetting.AcFlag,
|
||||||
AcFlag: ac_flag,
|
SwingFlag: liveSetting.SwingFlag,
|
||||||
SwingFlag: swing_flag,
|
NotesList: notes,
|
||||||
NotesList: notes,
|
},
|
||||||
},
|
},
|
||||||
|
RankInfo: ranks,
|
||||||
|
CanActivateEffect: true,
|
||||||
|
ServerTimestamp: time.Now().Unix(),
|
||||||
},
|
},
|
||||||
RankInfo: ranks,
|
ReleaseInfo: []any{},
|
||||||
CanActivateEffect: true,
|
StatusCode: 200,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
}
|
||||||
},
|
} else {
|
||||||
ReleaseInfo: []any{},
|
// 如果有 Live 记录
|
||||||
StatusCode: 200,
|
if len(liveRecord) > 0 {
|
||||||
|
skillOn = liveschema.Skill{
|
||||||
|
HasRecord: false,
|
||||||
|
RandomSeed: nil,
|
||||||
|
MaxCombo: nil,
|
||||||
|
UpdateDate: nil,
|
||||||
|
PreciseList: nil,
|
||||||
|
DeckInfo: nil,
|
||||||
|
TapAdjust: nil, // TODO: 不知道保存在哪里
|
||||||
|
CanReplay: false, // TODO: 不知道保存在哪里
|
||||||
|
}
|
||||||
|
skillOff = skillOn
|
||||||
|
|
||||||
|
// 已完成的 Live 判断技能开关情况
|
||||||
|
for _, record := range liveRecord {
|
||||||
|
// LiveInfo
|
||||||
|
var liveInfo liveschema.LiveInfo
|
||||||
|
err = json.Unmarshal([]byte(record.LiveInfoJSON), &liveInfo)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
liveInfo.NotesList = notes
|
||||||
|
|
||||||
|
// PreciseList
|
||||||
|
var preciseList []liveschema.PreciseList
|
||||||
|
err = json.Unmarshal([]byte(record.PreciseListJSON), &preciseList)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeckInfo
|
||||||
|
var deckInfo usermodel.DeckInfo
|
||||||
|
err = json.Unmarshal([]byte(record.DeckInfoJSON), &deckInfo)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// LiveSetting
|
||||||
|
var liveSetting liveschema.LiveSetting
|
||||||
|
err = json.Unmarshal([]byte(record.LiveSettingJSON), &liveSetting)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TriggerLog
|
||||||
|
var triggerLog []liveschema.TriggerLog
|
||||||
|
err = json.Unmarshal([]byte(record.TriggerLogJSON), &triggerLog)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if record.IsSkillOn {
|
||||||
|
// 技能开
|
||||||
|
skillOn.HasRecord = true
|
||||||
|
skillOn.LiveInfo = liveInfo
|
||||||
|
skillOn.RandomSeed = time.Now().Unix() // TODO: 从 /live/play 的 Timestamp 字段获取
|
||||||
|
skillOn.MaxCombo = record.MaxCombo
|
||||||
|
skillOn.UpdateDate = record.UpdateDate
|
||||||
|
skillOn.PreciseList = preciseList
|
||||||
|
skillOn.DeckInfo = deckInfo
|
||||||
|
skillOn.LiveSetting = liveSetting
|
||||||
|
skillOn.TriggerLog = triggerLog
|
||||||
|
skillOn.TapAdjust = record.TapAdjust
|
||||||
|
skillOn.CanReplay = record.CanReplay
|
||||||
|
} else {
|
||||||
|
// 技能关
|
||||||
|
skillOff.HasRecord = true
|
||||||
|
skillOff.LiveInfo = liveInfo
|
||||||
|
skillOff.RandomSeed = time.Now().Unix() // TODO: 从 /live/play 的 Timestamp 字段获取
|
||||||
|
skillOff.MaxCombo = record.MaxCombo
|
||||||
|
skillOff.UpdateDate = record.UpdateDate
|
||||||
|
skillOff.PreciseList = preciseList
|
||||||
|
skillOff.DeckInfo = deckInfo
|
||||||
|
skillOff.LiveSetting = liveSetting
|
||||||
|
skillOff.TriggerLog = triggerLog
|
||||||
|
skillOff.TapAdjust = record.TapAdjust
|
||||||
|
skillOff.CanReplay = record.CanReplay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playResp = liveschema.PreciseScoreResp{
|
||||||
|
ResponseData: liveschema.PreciseScoreData{
|
||||||
|
On: skillOn,
|
||||||
|
Off: skillOff,
|
||||||
|
RankInfo: ranks,
|
||||||
|
CanActivateEffect: true,
|
||||||
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playResp = liveschema.PreciseScoreResp{
|
||||||
|
ResponseData: map[string]constant.ErrorCode{
|
||||||
|
"error_code": constant.ErrorCodeLivePreciseListNotFound,
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 600,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(playResp)
|
ss.Respond(playResp)
|
||||||
|
|||||||
+79
-102
@@ -3,12 +3,11 @@ package live
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/live"
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"honoka-chan/pkg/db"
|
"honoka-chan/pkg/utils"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -16,68 +15,64 @@ import (
|
|||||||
|
|
||||||
func reward(ctx *gin.Context) {
|
func reward(ctx *gin.Context) {
|
||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer func() {
|
||||||
|
ss.ClearLiveInProgress()
|
||||||
|
ss.Finalize()
|
||||||
|
}()
|
||||||
|
|
||||||
playRewardReq := live.RewardReq{}
|
playRewardReq := liveschema.RewardReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playRewardReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &playRewardReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// fmt.Println(ctx.MustGet("request_data").(string))
|
||||||
|
|
||||||
difficultyId := playRewardReq.LiveDifficultyID
|
difficultyID := playRewardReq.LiveDifficultyID
|
||||||
|
_, liveInfo := ss.GetLiveInfo(difficultyID)
|
||||||
|
_, progress := ss.GetLiveInProgress() // TODO: 添加返回指定状态码的方法
|
||||||
|
_, deckInfo := ss.GetDeckInfo(progress.DeckID)
|
||||||
|
deckInfo.LiveDifficultyID = difficultyID
|
||||||
|
|
||||||
// Song type: normal / special
|
unitsList := []liveschema.PlayRewardUnitList{}
|
||||||
// sqlite3 doesn't support FULL OUTER JOIN so use UNION ALL here.
|
err = ss.UserEng.Table("user_deck_unit").
|
||||||
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 = ?)`
|
Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.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
|
Where("user_deck.user_id = ? AND user_deck.deck_id = ?", ss.UserID, progress.DeckID).
|
||||||
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)
|
Find(&unitsList)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
key := "live_deck_" + strconv.Itoa(ss.UserID)
|
pref := usermodel.UserPref{}
|
||||||
deckId, err := db.Ldb.Get([]byte(key))
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
unitsList := []live.PlayRewardUnitList{}
|
|
||||||
err = ss.UserEng.Table("user_deck_unit").Join("LEFT", "user_deck", "user_deck_unit.user_deck_id = user_deck.id").
|
|
||||||
Where("user_id = ? AND deck_id = ?", ss.UserID, string(deckId)).Find(&unitsList)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
pref := user.UserPref{}
|
|
||||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Get(&pref)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
||||||
playResp := live.RewardResp{
|
playResp := liveschema.RewardResp{
|
||||||
ResponseData: live.RewardData{
|
ResponseData: liveschema.RewardData{
|
||||||
LiveInfo: []live.RewardLiveInfo{
|
LiveInfo: []liveschema.RewardLiveInfo{
|
||||||
{
|
{
|
||||||
LiveDifficultyID: difficultyId,
|
LiveDifficultyID: difficultyID,
|
||||||
IsRandom: false,
|
IsRandom: false,
|
||||||
AcFlag: ac_flag,
|
AcFlag: liveInfo.AcFlag,
|
||||||
SwingFlag: swing_flag,
|
SwingFlag: liveInfo.SwingFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TotalLove: 0,
|
TotalLove: 0,
|
||||||
IsHighScore: true,
|
IsHighScore: true,
|
||||||
HiScore: totalScore,
|
HiScore: totalScore,
|
||||||
BaseRewardInfo: live.BaseRewardInfo{
|
BaseRewardInfo: liveschema.BaseRewardInfo{
|
||||||
PlayerExp: 0,
|
PlayerExp: 0,
|
||||||
PlayerExpUnitMax: live.PlayerExpUnitMax{
|
PlayerExpUnitMax: liveschema.PlayerExpUnitMax{
|
||||||
Before: 0,
|
Before: 0,
|
||||||
After: 0,
|
After: 0,
|
||||||
},
|
},
|
||||||
PlayerExpFriendMax: live.PlayerExpFriendMax{
|
PlayerExpFriendMax: liveschema.PlayerExpFriendMax{
|
||||||
Before: 99,
|
Before: 99,
|
||||||
After: 99,
|
After: 99,
|
||||||
},
|
},
|
||||||
PlayerExpLpMax: live.PlayerExpLpMax{
|
PlayerExpLpMax: liveschema.PlayerExpLpMax{
|
||||||
Before: 417,
|
Before: 417,
|
||||||
After: 417,
|
After: 417,
|
||||||
},
|
},
|
||||||
@@ -85,72 +80,26 @@ func reward(ctx *gin.Context) {
|
|||||||
GameCoinRewardBoxFlag: false,
|
GameCoinRewardBoxFlag: false,
|
||||||
SocialPoint: 0,
|
SocialPoint: 0,
|
||||||
},
|
},
|
||||||
RewardUnitList: live.RewardUnitList{
|
RewardUnitList: liveschema.RewardUnitList{
|
||||||
LiveClear: []live.LiveClear{},
|
LiveClear: []liveschema.LiveClear{},
|
||||||
LiveRank: []live.LiveRank{},
|
LiveRank: []liveschema.LiveRank{},
|
||||||
LiveCombo: []any{},
|
LiveCombo: []any{},
|
||||||
},
|
},
|
||||||
UnlockedSubscenarioIds: []any{},
|
UnlockedSubscenarioIds: []any{},
|
||||||
UnlockedMultiUnitScenarioIds: []any{},
|
UnlockedMultiUnitScenarioIds: []any{},
|
||||||
EffortPoint: []live.EffortPoint{},
|
EffortPoint: []liveschema.EffortPoint{},
|
||||||
IsEffortPointVisible: false,
|
IsEffortPointVisible: false,
|
||||||
LimitedEffortBox: []any{},
|
LimitedEffortBox: []any{},
|
||||||
UnitList: unitsList,
|
UnitList: unitsList,
|
||||||
BeforeUserInfo: live.BeforeUserInfo{
|
BeforeUserInfo: ss.GetUserInfo(),
|
||||||
Level: pref.UserLevel,
|
AfterUserInfo: ss.GetUserInfo(),
|
||||||
Exp: 1089696,
|
NextLevelInfo: []liveschema.NextLevelInfo{
|
||||||
PreviousExp: 0,
|
|
||||||
NextExp: 1207185,
|
|
||||||
GameCoin: 999999999,
|
|
||||||
SnsCoin: 10000,
|
|
||||||
FreeSnsCoin: 50000,
|
|
||||||
PaidSnsCoin: 50000,
|
|
||||||
SocialPoint: 1438165,
|
|
||||||
UnitMax: 5000,
|
|
||||||
WaitingUnitMax: 1000,
|
|
||||||
CurrentEnergy: 417,
|
|
||||||
EnergyMax: 417,
|
|
||||||
TrainingEnergy: 9,
|
|
||||||
TrainingEnergyMax: 10,
|
|
||||||
EnergyFullTime: "2023-03-20 01:28:55",
|
|
||||||
LicenseLiveEnergyRecoverlyTime: 60,
|
|
||||||
FriendMax: 99,
|
|
||||||
TutorialState: -1,
|
|
||||||
OverMaxEnergy: 417,
|
|
||||||
UnlockRandomLiveMuse: 1,
|
|
||||||
UnlockRandomLiveAqours: 1,
|
|
||||||
},
|
|
||||||
AfterUserInfo: live.AfterUserInfo{
|
|
||||||
Level: pref.UserLevel,
|
|
||||||
Exp: 1089696,
|
|
||||||
PreviousExp: 0,
|
|
||||||
NextExp: 1207185,
|
|
||||||
GameCoin: 999999999,
|
|
||||||
SnsCoin: 100000,
|
|
||||||
FreeSnsCoin: 50000,
|
|
||||||
PaidSnsCoin: 50000,
|
|
||||||
SocialPoint: 1438375,
|
|
||||||
UnitMax: 5000,
|
|
||||||
WaitingUnitMax: 1000,
|
|
||||||
CurrentEnergy: 417,
|
|
||||||
EnergyMax: 417,
|
|
||||||
TrainingEnergy: 9,
|
|
||||||
TrainingEnergyMax: 10,
|
|
||||||
EnergyFullTime: "2023-03-20 01:28:55",
|
|
||||||
LicenseLiveEnergyRecoverlyTime: 60,
|
|
||||||
FriendMax: 99,
|
|
||||||
TutorialState: -1,
|
|
||||||
OverMaxEnergy: 417,
|
|
||||||
UnlockRandomLiveMuse: 1,
|
|
||||||
UnlockRandomLiveAqours: 1,
|
|
||||||
},
|
|
||||||
NextLevelInfo: []live.NextLevelInfo{
|
|
||||||
{
|
{
|
||||||
Level: pref.UserLevel,
|
Level: pref.UserLevel,
|
||||||
FromExp: 1089696,
|
FromExp: 1089696,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
GoalAccompInfo: live.GoalAccompInfo{
|
GoalAccompInfo: liveschema.GoalAccompInfo{
|
||||||
AchievedIds: []any{},
|
AchievedIds: []any{},
|
||||||
Rewards: []any{},
|
Rewards: []any{},
|
||||||
},
|
},
|
||||||
@@ -159,8 +108,8 @@ func reward(ctx *gin.Context) {
|
|||||||
DailyRewardInfo: []any{},
|
DailyRewardInfo: []any{},
|
||||||
CanSendFriendRequest: false,
|
CanSendFriendRequest: false,
|
||||||
UsingBuffInfo: []any{},
|
UsingBuffInfo: []any{},
|
||||||
ClassSystem: live.ClassSystem{
|
ClassSystem: liveschema.ClassSystem{
|
||||||
RankInfo: live.RewardRankInfo{
|
RankInfo: liveschema.RewardRankInfo{
|
||||||
BeforeClassRankID: 10,
|
BeforeClassRankID: 10,
|
||||||
AfterClassRankID: 10,
|
AfterClassRankID: 10,
|
||||||
RankUpDate: "2020-02-12 11:57:15",
|
RankUpDate: "2020-02-12 11:57:15",
|
||||||
@@ -169,11 +118,11 @@ func reward(ctx *gin.Context) {
|
|||||||
IsOpened: true,
|
IsOpened: true,
|
||||||
IsVisible: true,
|
IsVisible: true,
|
||||||
},
|
},
|
||||||
AccomplishedAchievementList: []live.AccomplishedAchievementList{},
|
AccomplishedAchievementList: []liveschema.AccomplishedAchievementList{},
|
||||||
UnaccomplishedAchievementCnt: 0,
|
UnaccomplishedAchievementCnt: 0,
|
||||||
AddedAchievementList: []any{},
|
AddedAchievementList: []any{},
|
||||||
MuseumInfo: live.Museum{},
|
MuseumInfo: liveschema.Museum{},
|
||||||
UnitSupportList: []live.RewardUnitSupportList{},
|
UnitSupportList: []liveschema.RewardUnitSupportList{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
PresentCnt: 0,
|
PresentCnt: 0,
|
||||||
},
|
},
|
||||||
@@ -181,30 +130,58 @@ func reward(ctx *gin.Context) {
|
|||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
}
|
}
|
||||||
|
|
||||||
if playRewardReq.MaxCombo > s_rank_combo {
|
if playRewardReq.MaxCombo > liveInfo.SRankCombo {
|
||||||
playResp.ResponseData.ComboRank = 1
|
playResp.ResponseData.ComboRank = 1
|
||||||
} else if playRewardReq.MaxCombo > a_rank_combo {
|
} else if playRewardReq.MaxCombo > liveInfo.ARankCombo {
|
||||||
playResp.ResponseData.ComboRank = 2
|
playResp.ResponseData.ComboRank = 2
|
||||||
} else if playRewardReq.MaxCombo > b_rank_combo {
|
} else if playRewardReq.MaxCombo > liveInfo.BRankCombo {
|
||||||
playResp.ResponseData.ComboRank = 3
|
playResp.ResponseData.ComboRank = 3
|
||||||
} else if playRewardReq.MaxCombo > c_rank_combo {
|
} else if playRewardReq.MaxCombo > liveInfo.CRankCombo {
|
||||||
playResp.ResponseData.ComboRank = 4
|
playResp.ResponseData.ComboRank = 4
|
||||||
} else {
|
} else {
|
||||||
playResp.ResponseData.ComboRank = 5
|
playResp.ResponseData.ComboRank = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalScore > s_rank_score {
|
if totalScore > liveInfo.SRankScore {
|
||||||
playResp.ResponseData.Rank = 1
|
playResp.ResponseData.Rank = 1
|
||||||
} else if totalScore > a_rank_score {
|
} else if totalScore > liveInfo.ARankScore {
|
||||||
playResp.ResponseData.Rank = 2
|
playResp.ResponseData.Rank = 2
|
||||||
} else if totalScore > b_rank_score {
|
} else if totalScore > liveInfo.BRankScore {
|
||||||
playResp.ResponseData.Rank = 3
|
playResp.ResponseData.Rank = 3
|
||||||
} else if totalScore > c_rank_score {
|
} else if totalScore > liveInfo.CRankScore {
|
||||||
playResp.ResponseData.Rank = 4
|
playResp.ResponseData.Rank = 4
|
||||||
} else {
|
} else {
|
||||||
playResp.ResponseData.Rank = 5
|
playResp.ResponseData.Rank = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断歌曲记录是否需要保存或者更新
|
||||||
|
liveSetting := playRewardReq.PreciseScoreLog.LiveSetting
|
||||||
|
liveSetting.BackgroundID = ss.UserPref.BackgroundID
|
||||||
|
if playRewardReq.PreciseScoreLog.IsLogOn && liveSetting.PreciseScoreAutoUpdateFlag {
|
||||||
|
newLiveRecord := usermodel.UserLiveRecord{
|
||||||
|
LiveDifficultyID: difficultyID,
|
||||||
|
DeckID: progress.DeckID,
|
||||||
|
TotalScore: totalScore,
|
||||||
|
PerfectCnt: playRewardReq.PerfectCnt,
|
||||||
|
GreatCnt: playRewardReq.GreatCnt,
|
||||||
|
GoodCnt: playRewardReq.GoodCnt,
|
||||||
|
BadCnt: playRewardReq.BadCnt,
|
||||||
|
MissCnt: playRewardReq.MissCnt,
|
||||||
|
MaxCombo: playRewardReq.MaxCombo,
|
||||||
|
IsSkillOn: playRewardReq.PreciseScoreLog.IsSkillOn,
|
||||||
|
LiveInfoJSON: utils.ToJSON(liveInfo),
|
||||||
|
PreciseListJSON: utils.ToJSON(playRewardReq.PreciseScoreLog.PreciseList),
|
||||||
|
DeckInfoJSON: utils.ToJSON(deckInfo),
|
||||||
|
TapAdjust: playRewardReq.PreciseScoreLog.TapAdjust,
|
||||||
|
LiveSettingJSON: utils.ToJSON(liveSetting),
|
||||||
|
CanReplay: true,
|
||||||
|
TriggerLogJSON: utils.ToJSON(playRewardReq.PreciseScoreLog.TriggerLog),
|
||||||
|
UserID: ss.UserID,
|
||||||
|
UpdateDate: time.Now().Format("2006-01-02 15:04:05"),
|
||||||
|
}
|
||||||
|
ss.UpdateUserLiveRecord(&newLiveRecord, liveSetting.PreciseScoreUpdateType)
|
||||||
|
}
|
||||||
|
|
||||||
ss.Respond(playResp)
|
ss.Respond(playResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package login
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
loginmodel "honoka-chan/internal/model/login"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
loginschema "honoka-chan/internal/schema/login"
|
loginschema "honoka-chan/internal/schema/login"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"honoka-chan/pkg/db"
|
|
||||||
"honoka-chan/pkg/encrypt"
|
"honoka-chan/pkg/encrypt"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@@ -38,18 +38,12 @@ func authKey(ctx *gin.Context) {
|
|||||||
serverToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
serverToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
||||||
authorizeToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
authorizeToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
||||||
|
|
||||||
authJson, err := json.Marshal(map[string]any{
|
ss.SetAuthKey(&loginmodel.AuthKey{
|
||||||
"client_token": clientToken,
|
AuthorizeToken: authorizeToken,
|
||||||
"server_token": serverToken,
|
ClientToken: clientToken,
|
||||||
|
ServerToken: serverToken,
|
||||||
|
InsertDate: time.Now().Format("2006-01-02 15:04:05"),
|
||||||
})
|
})
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.Ldb.Set([]byte(authorizeToken), authJson)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ss.Respond(loginschema.AuthKeyResp{
|
ss.Respond(loginschema.AuthKeyResp{
|
||||||
ResponseData: loginschema.AuthKeyData{
|
ResponseData: loginschema.AuthKeyData{
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import (
|
|||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
loginschema "honoka-chan/internal/schema/login"
|
loginschema "honoka-chan/internal/schema/login"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"honoka-chan/pkg/db"
|
|
||||||
"honoka-chan/pkg/encrypt"
|
"honoka-chan/pkg/encrypt"
|
||||||
honokautils "honoka-chan/pkg/utils"
|
honokautils "honoka-chan/pkg/utils"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -21,16 +19,17 @@ func login(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
authData, err := db.Ldb.Get([]byte(ctx.MustGet("token").(string)))
|
has, authKeyData := ss.GetAuthKey(ctx.MustGet("token").(string))
|
||||||
if ss.CheckErr(err) {
|
if !has {
|
||||||
|
ss.Abort(errors.New("invalid token"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
clientToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "client_token").String())
|
clientToken, err := base64.StdEncoding.DecodeString(authKeyData.ClientToken)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
serverToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "server_token").String())
|
serverToken, err := base64.StdEncoding.DecodeString(authKeyData.ServerToken)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,7 @@ func login(ctx *gin.Context) {
|
|||||||
|
|
||||||
authorizeToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
authorizeToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
||||||
|
|
||||||
var userID int // 需要更新为字符串
|
var userID int
|
||||||
exists, err := ss.UserEng.Table("user_key").Where("key = ?", string(loginKey)).Cols("user_id").Get(&userID)
|
exists, err := ss.UserEng.Table("user_key").Where("key = ?", string(loginKey)).Cols("user_id").Get(&userID)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -66,11 +65,6 @@ func login(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.Ldb.Set([]byte(strconv.Itoa(userID)), []byte(authorizeToken))
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ss.Respond(loginschema.LoginResp{
|
ss.Respond(loginschema.LoginResp{
|
||||||
ResponseData: loginschema.LoginData{
|
ResponseData: loginschema.LoginData{
|
||||||
AuthorizeToken: authorizeToken,
|
AuthorizeToken: authorizeToken,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/multiunit"
|
multiunitschema "honoka-chan/internal/schema/multiunit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,14 +15,14 @@ func scenarioStartup(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
startReq := multiunit.ScenarioStartUpReq{}
|
startReq := multiunitschema.ScenarioStartUpReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &startReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &startReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(multiunit.ScenarioStartUpResp{
|
ss.Respond(multiunitschema.ScenarioStartUpResp{
|
||||||
ResponseData: multiunit.ScenarioStartUpData{
|
ResponseData: multiunitschema.ScenarioStartUpData{
|
||||||
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package museum
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/museum"
|
museumschema "honoka-chan/internal/schema/museum"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -33,10 +33,10 @@ func info(ctx *gin.Context) {
|
|||||||
coolBuff += content.CoolBuff
|
coolBuff += content.CoolBuff
|
||||||
contentsList = append(contentsList, content.MuseumContentsId)
|
contentsList = append(contentsList, content.MuseumContentsId)
|
||||||
}
|
}
|
||||||
museumResp := museum.InfoResp{
|
museumResp := museumschema.InfoResp{
|
||||||
ResponseData: museum.InfoData{
|
ResponseData: museumschema.InfoData{
|
||||||
MuseumInfo: museum.Museum{
|
MuseumInfo: museumschema.Museum{
|
||||||
Parameter: museum.Parameter{
|
Parameter: museumschema.Parameter{
|
||||||
Smile: smileBuff,
|
Smile: smileBuff,
|
||||||
Pure: pureBuff,
|
Pure: pureBuff,
|
||||||
Cool: coolBuff,
|
Cool: coolBuff,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package notice
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/notice"
|
noticeschema "honoka-chan/internal/schema/notice"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func friendGreeting(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(notice.FriendGreetingResp{
|
ss.Respond(noticeschema.FriendGreetingResp{
|
||||||
ResponseData: notice.FriendGreetingData{
|
ResponseData: noticeschema.FriendGreetingData{
|
||||||
NextId: 0,
|
NextId: 0,
|
||||||
NoticeList: []any{},
|
NoticeList: []any{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package notice
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/notice"
|
noticeschema "honoka-chan/internal/schema/notice"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func friendVariety(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(notice.FriendVarietyResp{
|
ss.Respond(noticeschema.FriendVarietyResp{
|
||||||
ResponseData: notice.FriendVarietyData{
|
ResponseData: noticeschema.FriendVarietyData{
|
||||||
ItemCount: 1,
|
ItemCount: 1,
|
||||||
NoticeList: []any{},
|
NoticeList: []any{},
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package notice
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/notice"
|
noticeschema "honoka-chan/internal/schema/notice"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func userGreetingHistory(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(notice.UserGreetingResp{
|
ss.Respond(noticeschema.UserGreetingResp{
|
||||||
ResponseData: notice.UserGreetingData{
|
ResponseData: noticeschema.UserGreetingData{
|
||||||
ItemCount: 0,
|
ItemCount: 0,
|
||||||
HasNext: false,
|
HasNext: false,
|
||||||
NoticeList: []any{},
|
NoticeList: []any{},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
paymentapischema "honoka-chan/internal/schema/api/payment"
|
paymentapischema "honoka-chan/internal/schema/api/payment"
|
||||||
"honoka-chan/internal/schema/payment"
|
paymentschema "honoka-chan/internal/schema/payment"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ func productList(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
prodResp := payment.ProductListResp{
|
prodResp := paymentschema.ProductListResp{
|
||||||
ResponseData: payment.ProductListData{
|
ResponseData: paymentschema.ProductListData{
|
||||||
RestrictionInfo: paymentapischema.RestrictionInfo{
|
RestrictionInfo: paymentapischema.RestrictionInfo{
|
||||||
Restricted: false,
|
Restricted: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package personalnotice
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/personalnotice"
|
personalnoticeschema "honoka-chan/internal/schema/personalnotice"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func get(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
noticeResp := personalnotice.GetResp{
|
noticeResp := personalnoticeschema.GetResp{
|
||||||
ResponseData: personalnotice.GetData{
|
ResponseData: personalnoticeschema.GetData{
|
||||||
HasNotice: false,
|
HasNotice: false,
|
||||||
NoticeID: 0,
|
NoticeID: 0,
|
||||||
Type: 0,
|
Type: 0,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package profile
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/profile"
|
profileschema "honoka-chan/internal/schema/profile"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -16,7 +16,7 @@ func register(ctx *gin.Context) {
|
|||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||||
pref := user.UserPref{
|
pref := usermodel.UserPref{
|
||||||
UserDesc: req.Get("introduction").String(),
|
UserDesc: req.Get("introduction").String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func register(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(profile.RegisterResp{
|
ss.Respond(profileschema.RegisterResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/scenario"
|
scenarioschema "honoka-chan/internal/schema/scenario"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,14 +15,14 @@ func startup(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
startReq := scenario.StartUpReq{}
|
startReq := scenarioschema.StartUpReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(scenario.StartUpResp{
|
ss.Respond(scenarioschema.StartUpResp{
|
||||||
ResponseData: scenario.StartUpData{
|
ResponseData: scenarioschema.StartUpData{
|
||||||
ScenarioID: startReq.ScenarioID,
|
ScenarioID: startReq.ScenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/subscenario"
|
subscenarioschema "honoka-chan/internal/schema/subscenario"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,14 +15,14 @@ func startup(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
startReq := subscenario.StartUpReq{}
|
startReq := subscenarioschema.StartUpReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &startReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &startReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(subscenario.StartUpResp{
|
ss.Respond(subscenarioschema.StartUpResp{
|
||||||
ResponseData: subscenario.StartUpData{
|
ResponseData: subscenarioschema.StartUpData{
|
||||||
SubscenarioID: startReq.SubscenarioID,
|
SubscenarioID: startReq.SubscenarioID,
|
||||||
ScenarioAdjustment: 50,
|
ScenarioAdjustment: 50,
|
||||||
ServerTimestamp: time.Now().Unix(),
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package tos
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/tos"
|
tosschema "honoka-chan/internal/schema/tos"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func check(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(tos.CheckResp{
|
ss.Respond(tosschema.CheckResp{
|
||||||
ResponseData: tos.CheckData{
|
ResponseData: tosschema.CheckData{
|
||||||
TosID: 1,
|
TosID: 1,
|
||||||
TosType: 1,
|
TosType: 1,
|
||||||
IsAgreed: true,
|
IsAgreed: true,
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package unit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
unitmodel "honoka-chan/internal/model/unit"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
profileapischema "honoka-chan/internal/schema/api/profile"
|
|
||||||
unitapischema "honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ func deck(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
deckReq := unit.DeckReq{}
|
deckReq := unitschema.DeckReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &deckReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &deckReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -63,53 +63,34 @@ func deck(ctx *gin.Context) {
|
|||||||
// 队伍成员信息
|
// 队伍成员信息
|
||||||
for _, u := range deck.UnitDeckDetail {
|
for _, u := range deck.UnitDeckDetail {
|
||||||
// 成员信息
|
// 成员信息
|
||||||
newUnitData := profileapischema.UnitData{}
|
unitData := unitmodel.UnitDataMap{}
|
||||||
exists, err := ss.UserEng.Table("user_unit").Where("unit_owning_user_id = ?", u.UnitOwningUserID).Exist()
|
_, err = ss.GetBasicUnitInfo().
|
||||||
|
Where("a.unit_owning_user_id = ?", u.UnitOwningUserID).Get(&unitData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if exists {
|
// fmt.Println("新的成员信息:", unitData)
|
||||||
// fmt.Println("新成员为用户增加成员")
|
|
||||||
_, err = ss.UserEng.Table("user_unit").Where("unit_owning_user_id = ?", u.UnitOwningUserID).Get(&newUnitData)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
exists, err := ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", u.UnitOwningUserID).Exist()
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if exists {
|
|
||||||
// fmt.Println("新成员为公共成员")
|
|
||||||
_, err = ss.MainEng.Table("common_unit_m").Where("unit_owning_user_id = ?", u.UnitOwningUserID).Get(&newUnitData)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// fmt.Println("新成员不存在")
|
|
||||||
err = errors.New("新成员不存在")
|
|
||||||
}
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fmt.Println("新的成员信息:", newUnitData)
|
|
||||||
|
|
||||||
// 插入新成员信息
|
// 插入新成员信息
|
||||||
newUnitDeckData := unitapischema.UnitDeckData{}
|
newUnitDeckData := usermodel.UserDeckUnit{
|
||||||
b, err := json.Marshal(newUnitData)
|
UserDeckID: userDeckId,
|
||||||
if ss.CheckErr(err) {
|
UnitOwningUserID: unitData.UnitOwningUserID,
|
||||||
return
|
UnitID: unitData.UnitID,
|
||||||
|
Position: u.Position,
|
||||||
|
Level: unitData.Level,
|
||||||
|
LevelLimitID: unitData.LevelLimitID,
|
||||||
|
DisplayRank: unitData.DisplayRank,
|
||||||
|
Love: unitData.Love,
|
||||||
|
UnitSkillLevel: unitData.UnitSkillLevel,
|
||||||
|
IsRankMax: unitData.IsRankMax,
|
||||||
|
IsLoveMax: unitData.IsLoveMax,
|
||||||
|
IsLevelMax: unitData.IsLevelMax,
|
||||||
|
IsSigned: unitData.IsSigned,
|
||||||
|
BeforeLove: unitData.MaxLove,
|
||||||
|
MaxLove: unitData.MaxLove,
|
||||||
|
UserID: ss.UserID,
|
||||||
|
InsertDate: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(b, &newUnitDeckData)
|
|
||||||
if ss.CheckErr(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
newUnitDeckData.BeforeLove = newUnitDeckData.MaxLove
|
|
||||||
newUnitDeckData.Position = u.Position
|
|
||||||
newUnitDeckData.UserDeckID = userDeckId
|
|
||||||
newUnitDeckData.InsertData = time.Now().Unix()
|
|
||||||
|
|
||||||
_, err = ss.UserEng.Table("user_deck_unit").Insert(&newUnitDeckData)
|
_, err = ss.UserEng.Table("user_deck_unit").Insert(&newUnitDeckData)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -117,7 +98,7 @@ func deck(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(unit.DeckResp{
|
ss.Respond(unitschema.DeckResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
unitapischema "honoka-chan/internal/schema/api/unit"
|
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -15,7 +15,7 @@ func deckName(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
deckReq := unit.DeckNameReq{}
|
deckReq := unitschema.DeckNameReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &deckReq)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &deckReq)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -37,7 +37,7 @@ func deckName(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(unit.DeckResp{
|
ss.Respond(unitschema.DeckResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -13,7 +15,22 @@ func favorite(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(unit.FavoriteResp{
|
var req unitschema.FavoriteReq
|
||||||
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := usermodel.UserUnitData{
|
||||||
|
FavoriteFlag: req.FavoriteFlag != 0,
|
||||||
|
}
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitData)).
|
||||||
|
ID(req.UnitOwningUserID).Cols("favorite_flag").Update(&data)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.Respond(unitschema.FavoriteResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SetResp struct {
|
||||||
|
ResponseData []any `json:"response_data"`
|
||||||
|
ReleaseInfo []any `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func favoriteAccessory(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
fmt.Println(ctx.MustGet("request_data").(string))
|
||||||
|
|
||||||
|
ss.Respond(SetResp{
|
||||||
|
ResponseData: []any{},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/unit/favoriteAccessory", middleware.Common, favoriteAccessory)
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -14,7 +14,7 @@ func removableSkillEquipment(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
req := unit.RemovableSkillEquipmentReq{}
|
req := unitschema.RemovableSkillEquipmentReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -34,7 +34,7 @@ func removableSkillEquipment(ctx *gin.Context) {
|
|||||||
// 佩戴宝石
|
// 佩戴宝石
|
||||||
for _, v := range req.Equip {
|
for _, v := range req.Equip {
|
||||||
// fmt.Println("Equip:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
// fmt.Println("Equip:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
||||||
data := unit.RemovableSkillEquipmentData{
|
data := unitschema.RemovableSkillEquipmentData{
|
||||||
UnitRemovableSkillId: v.UnitRemovableSkillID,
|
UnitRemovableSkillId: v.UnitRemovableSkillID,
|
||||||
UnitOwningUserID: v.UnitOwningUserID,
|
UnitOwningUserID: v.UnitOwningUserID,
|
||||||
UserID: ss.UserID,
|
UserID: ss.UserID,
|
||||||
@@ -45,7 +45,7 @@ func removableSkillEquipment(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(unit.RemovableSkillEquipmentResp{
|
ss.Respond(unitschema.RemovableSkillEquipmentResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func sale(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
req := unitschema.SaleReq{}
|
||||||
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
totalCoin := 0
|
||||||
|
saleDetail := []unitschema.Detail{}
|
||||||
|
for _, id := range req.UnitOwningUserID {
|
||||||
|
salePrice := 1 // TODO: 从 unit_level_up_pattern_m 表获取实际价格
|
||||||
|
totalCoin += salePrice
|
||||||
|
|
||||||
|
_, unitData := ss.GetUserUnitInfo(id)
|
||||||
|
|
||||||
|
saleDetail = append(saleDetail, unitschema.Detail{
|
||||||
|
UnitOwningUserID: id,
|
||||||
|
UnitID: unitData.UnitID,
|
||||||
|
IsSigned: unitData.IsSigned,
|
||||||
|
Price: salePrice,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 卸载宝石
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitSkillEquip)).
|
||||||
|
Where("unit_owning_user_id = ?", id).Delete()
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卸载饰品
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserAccessoryWear)).
|
||||||
|
Where("unit_owning_user_id = ?", id).Delete()
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除卡片
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitData)).
|
||||||
|
Where("unit_owning_user_id = ?", id).Delete()
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
skillList := []int{}
|
||||||
|
err = ss.MainEng.Table("unit_removable_skill_m").
|
||||||
|
Where("skill_type = 1").Cols("unit_removable_skill_id").Find(&skillList)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
owningData := []unitschema.OwningInfo{}
|
||||||
|
for _, sk := range skillList {
|
||||||
|
owningData = append(owningData, unitschema.OwningInfo{
|
||||||
|
UnitRemovableSkillID: sk,
|
||||||
|
TotalAmount: 999,
|
||||||
|
EquippedAmount: 0, // TODO: 计算实际数量
|
||||||
|
InsertDate: "2023-01-01 12:00:00",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.Respond(unitschema.SaleResp{
|
||||||
|
ResponseData: unitschema.SaleData{
|
||||||
|
Total: totalCoin,
|
||||||
|
Detail: saleDetail,
|
||||||
|
BeforeUserInfo: ss.GetUserInfo(),
|
||||||
|
AfterUserInfo: ss.GetUserInfo(),
|
||||||
|
RewardBoxFlag: false,
|
||||||
|
GetExchangePointList: []any{},
|
||||||
|
UnitRemovableSkill: unitschema.UnitRemovableSkill{
|
||||||
|
OwningInfo: owningData,
|
||||||
|
},
|
||||||
|
ServerTimestamp: time.Now().Unix(),
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/unit/sale", middleware.Common, sale)
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -13,7 +15,22 @@ func setDisplayRank(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(unit.SetDisplayRankResp{
|
var req unitschema.SetDisplayRankReq
|
||||||
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := usermodel.UserUnitData{
|
||||||
|
DisplayRank: req.DisplayRank,
|
||||||
|
}
|
||||||
|
_, err = ss.UserEng.Table(new(usermodel.UserUnitData)).
|
||||||
|
ID(req.UnitOwningUserID).Cols("display_rank").Update(&data)
|
||||||
|
if ss.CheckErr(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.Respond(unitschema.SetDisplayRankResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/unit"
|
unitschema "honoka-chan/internal/schema/unit"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -14,7 +14,7 @@ func wearAccessory(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
req := unit.WearAccessoryReq{}
|
req := unitschema.WearAccessoryReq{}
|
||||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &req)
|
||||||
if ss.CheckErr(err) {
|
if ss.CheckErr(err) {
|
||||||
return
|
return
|
||||||
@@ -34,7 +34,7 @@ func wearAccessory(ctx *gin.Context) {
|
|||||||
// 佩戴饰品
|
// 佩戴饰品
|
||||||
for _, v := range req.Wear {
|
for _, v := range req.Wear {
|
||||||
// fmt.Println("Wear:", v.AccessoryOwningUserID, v.UnitOwningUserID)
|
// fmt.Println("Wear:", v.AccessoryOwningUserID, v.UnitOwningUserID)
|
||||||
data := unit.WearAccessoryData{
|
data := unitschema.WearAccessoryData{
|
||||||
AccessoryOwningUserID: v.AccessoryOwningUserID,
|
AccessoryOwningUserID: v.AccessoryOwningUserID,
|
||||||
UnitOwningUserID: v.UnitOwningUserID,
|
UnitOwningUserID: v.UnitOwningUserID,
|
||||||
UserID: ss.UserID,
|
UserID: ss.UserID,
|
||||||
@@ -45,7 +45,7 @@ func wearAccessory(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Respond(unit.WearAccessoryResp{
|
ss.Respond(unitschema.WearAccessoryResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
userschema "honoka-chan/internal/schema/user"
|
userschema "honoka-chan/internal/schema/user"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
@@ -23,7 +23,7 @@ func changeName(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pref := user.UserPref{
|
pref := usermodel.UserPref{
|
||||||
UserName: req.Get("name").String(),
|
UserName: req.Get("name").String(),
|
||||||
}
|
}
|
||||||
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Update(&pref)
|
_, err = ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Update(&pref)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
userschema "honoka-chan/internal/schema/user"
|
userschema "honoka-chan/internal/schema/user"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
@@ -16,7 +16,7 @@ func changeNavi(ctx *gin.Context) {
|
|||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
req := gjson.Parse(ctx.MustGet("request_data").(string))
|
req := gjson.Parse(ctx.MustGet("request_data").(string))
|
||||||
pref := user.UserPref{
|
pref := usermodel.UserPref{
|
||||||
UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()),
|
UnitOwningUserID: int(req.Get("unit_owning_user_id").Int()),
|
||||||
}
|
}
|
||||||
_, err := ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Update(&pref)
|
_, err := ss.UserEng.Table("user_pref").Where("user_id = ?", ss.UserID).Update(&pref)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package user
|
|||||||
import (
|
import (
|
||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
"honoka-chan/internal/schema/user"
|
userschema "honoka-chan/internal/schema/user"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -13,7 +13,7 @@ func setNotificationToken(ctx *gin.Context) {
|
|||||||
ss := session.Get(ctx)
|
ss := session.Get(ctx)
|
||||||
defer ss.Finalize()
|
defer ss.Finalize()
|
||||||
|
|
||||||
ss.Respond(user.SetNotificationTokenResp{
|
ss.Respond(userschema.SetNotificationTokenResp{
|
||||||
ResponseData: []any{},
|
ResponseData: []any{},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user