@@ -2,6 +2,8 @@ package constant
|
|||||||
|
|
||||||
type ErrorCode int
|
type ErrorCode int
|
||||||
|
|
||||||
|
// https://github.com/DarkEnergyProcessor/NPPS4/blob/master/npps4/idol/error.py
|
||||||
const (
|
const (
|
||||||
|
ErrorCodeNoUnitIsSellable ErrorCode = 1205
|
||||||
ErrorCodeLivePreciseListNotFound ErrorCode = 3421
|
ErrorCodeLivePreciseListNotFound ErrorCode = 3421
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
"honoka-chan/internal/handler/api/notice"
|
"honoka-chan/internal/handler/api/notice"
|
||||||
"honoka-chan/internal/handler/api/payment"
|
"honoka-chan/internal/handler/api/payment"
|
||||||
"honoka-chan/internal/handler/api/profile"
|
"honoka-chan/internal/handler/api/profile"
|
||||||
|
"honoka-chan/internal/handler/api/reward"
|
||||||
"honoka-chan/internal/handler/api/scenario"
|
"honoka-chan/internal/handler/api/scenario"
|
||||||
"honoka-chan/internal/handler/api/stamp"
|
"honoka-chan/internal/handler/api/stamp"
|
||||||
"honoka-chan/internal/handler/api/subscenario"
|
"honoka-chan/internal/handler/api/subscenario"
|
||||||
@@ -91,6 +92,8 @@ func api(ctx *gin.Context) {
|
|||||||
result, err = payment.PaymentApi(ctx, v.Action)
|
result, err = payment.PaymentApi(ctx, v.Action)
|
||||||
case "profile":
|
case "profile":
|
||||||
result, err = profile.ProfileApi(ctx, v.Action, v.UserID)
|
result, err = profile.ProfileApi(ctx, v.Action, v.UserID)
|
||||||
|
case "reward":
|
||||||
|
result, err = reward.RewardApi(v.Action)
|
||||||
case "scenario":
|
case "scenario":
|
||||||
result, err = scenario.ScenarioApi(ctx, v.Action)
|
result, err = scenario.ScenarioApi(ctx, v.Action)
|
||||||
case "stamp":
|
case "stamp":
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
rewardapischema "honoka-chan/internal/schema/api/reward"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func rewardHistory() (res any, err error) {
|
||||||
|
res = rewardapischema.HistoryResp{
|
||||||
|
Result: rewardapischema.HistoryData{
|
||||||
|
ItemCount: 0,
|
||||||
|
Limit: 20,
|
||||||
|
History: []any{},
|
||||||
|
},
|
||||||
|
Status: 200,
|
||||||
|
CommandNum: false,
|
||||||
|
TimeStamp: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
rewardapischema "honoka-chan/internal/schema/api/reward"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func rewardList() (res any, err error) {
|
||||||
|
res = rewardapischema.ListResp{
|
||||||
|
Result: rewardapischema.ListData{
|
||||||
|
ItemCount: 0,
|
||||||
|
Limit: 20,
|
||||||
|
Order: 0,
|
||||||
|
Items: []any{},
|
||||||
|
},
|
||||||
|
Status: 200,
|
||||||
|
CommandNum: false,
|
||||||
|
TimeStamp: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RewardApi(action string) (res any, err error) {
|
||||||
|
switch action {
|
||||||
|
case "rewardList":
|
||||||
|
res, err = rewardList()
|
||||||
|
case "rewardHistory":
|
||||||
|
res, err = rewardHistory()
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("unimplemented action: reward: %s", action)
|
||||||
|
}
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
_ "honoka-chan/internal/handler/payment"
|
_ "honoka-chan/internal/handler/payment"
|
||||||
_ "honoka-chan/internal/handler/personalnotice"
|
_ "honoka-chan/internal/handler/personalnotice"
|
||||||
_ "honoka-chan/internal/handler/profile"
|
_ "honoka-chan/internal/handler/profile"
|
||||||
|
_ "honoka-chan/internal/handler/reward"
|
||||||
_ "honoka-chan/internal/handler/scenario"
|
_ "honoka-chan/internal/handler/scenario"
|
||||||
_ "honoka-chan/internal/handler/subscenario"
|
_ "honoka-chan/internal/handler/subscenario"
|
||||||
_ "honoka-chan/internal/handler/tos"
|
_ "honoka-chan/internal/handler/tos"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"honoka-chan/internal/middleware"
|
"honoka-chan/internal/middleware"
|
||||||
usermodel "honoka-chan/internal/model/user"
|
usermodel "honoka-chan/internal/model/user"
|
||||||
"honoka-chan/internal/router"
|
"honoka-chan/internal/router"
|
||||||
|
commonschema "honoka-chan/internal/schema/common"
|
||||||
liveschema "honoka-chan/internal/schema/live"
|
liveschema "honoka-chan/internal/schema/live"
|
||||||
"honoka-chan/internal/session"
|
"honoka-chan/internal/session"
|
||||||
honokautils "honoka-chan/internal/utils"
|
honokautils "honoka-chan/internal/utils"
|
||||||
@@ -232,8 +233,8 @@ func preciseScore(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
playResp = liveschema.PreciseScoreResp{
|
playResp = liveschema.PreciseScoreResp{
|
||||||
ResponseData: map[string]constant.ErrorCode{
|
ResponseData: commonschema.ErrorData{
|
||||||
"error_code": constant.ErrorCodeLivePreciseListNotFound,
|
ErrorCode: constant.ErrorCodeLivePreciseListNotFound,
|
||||||
},
|
},
|
||||||
ReleaseInfo: []any{},
|
ReleaseInfo: []any{},
|
||||||
StatusCode: 600,
|
StatusCode: 600,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
rewardschema "honoka-chan/internal/schema/reward"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func history(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
ss.Respond(rewardschema.HistoryResp{
|
||||||
|
ResponseData: rewardschema.HistoryData{
|
||||||
|
ItemCount: 0,
|
||||||
|
Limit: 20,
|
||||||
|
History: []any{},
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/reward/rewardHistory", middleware.Common, history)
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
rewardschema "honoka-chan/internal/schema/reward"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func list(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
ss.Respond(rewardschema.ListResp{
|
||||||
|
ResponseData: rewardschema.ListData{
|
||||||
|
ItemCount: 0,
|
||||||
|
Limit: 20,
|
||||||
|
Order: 0,
|
||||||
|
Items: []any{},
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/reward/rewardList", middleware.Common, list)
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"honoka-chan/internal/constant"
|
||||||
|
"honoka-chan/internal/middleware"
|
||||||
|
"honoka-chan/internal/router"
|
||||||
|
commonschema "honoka-chan/internal/schema/common"
|
||||||
|
rewardschema "honoka-chan/internal/schema/reward"
|
||||||
|
"honoka-chan/internal/session"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func sellUnit(ctx *gin.Context) {
|
||||||
|
ss := session.Get(ctx)
|
||||||
|
defer ss.Finalize()
|
||||||
|
|
||||||
|
ss.Respond(rewardschema.SellUnitResp{
|
||||||
|
ResponseData: commonschema.ErrorData{
|
||||||
|
ErrorCode: constant.ErrorCodeNoUnitIsSellable,
|
||||||
|
},
|
||||||
|
ReleaseInfo: []any{},
|
||||||
|
StatusCode: 600,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
router.AddHandler("main.php", "POST", "/reward/sellUnit", middleware.Common, sellUnit)
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package rewardapischema
|
||||||
|
|
||||||
|
type HistoryData struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
History []any `json:"history"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HistoryResp struct {
|
||||||
|
Result HistoryData `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package rewardapischema
|
||||||
|
|
||||||
|
type ListData struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
Order int `json:"order"`
|
||||||
|
Items []any `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResp struct {
|
||||||
|
Result ListData `json:"result"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CommandNum bool `json:"commandNum"`
|
||||||
|
TimeStamp int64 `json:"timeStamp"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package commonschema
|
||||||
|
|
||||||
|
import "honoka-chan/internal/constant"
|
||||||
|
|
||||||
|
type ErrorData struct {
|
||||||
|
ErrorCode constant.ErrorCode `json:"error_code"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package rewardschema
|
||||||
|
|
||||||
|
type HistoryData struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
History []any `json:"history"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HistoryResp struct {
|
||||||
|
ResponseData HistoryData `json:"response_data"`
|
||||||
|
ReleaseInfo []any `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package rewardschema
|
||||||
|
|
||||||
|
type ListData struct {
|
||||||
|
ItemCount int `json:"item_count"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
Order int `json:"order"`
|
||||||
|
Items []any `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListResp struct {
|
||||||
|
ResponseData ListData `json:"response_data"`
|
||||||
|
ReleaseInfo []any `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package rewardschema
|
||||||
|
|
||||||
|
type SellUnitResp struct {
|
||||||
|
ResponseData any `json:"response_data"`
|
||||||
|
ReleaseInfo []any `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user