- Add a shared common error response schema and unknown error code for business-level fallbacks - Return business error payloads for router NoRoute and NoMethod fallbacks - Align the existing event list fallback response with the shared error structure - Introduce an explicit unimplemented API error type instead of relying on formatted strings - Make /api batch dispatch return per-item status 600 error entries for unimplemented modules and actions without failing the whole batch Signed-off-by: Sean Du <do4suki@gmail.com>
38 lines
813 B
Go
38 lines
813 B
Go
package event
|
|
|
|
import (
|
|
"honoka-chan/internal/constant"
|
|
"honoka-chan/internal/middleware"
|
|
"honoka-chan/internal/router"
|
|
commonschema "honoka-chan/internal/schema/common"
|
|
eventschema "honoka-chan/internal/schema/event"
|
|
"honoka-chan/internal/session"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func list(ctx *gin.Context) {
|
|
ss := session.Get(ctx)
|
|
defer ss.Finalize()
|
|
|
|
targets := []eventschema.TargetList{}
|
|
for i := range 6 {
|
|
targets = append(targets, eventschema.TargetList{
|
|
Position: i + 1,
|
|
IsDisplayable: false,
|
|
})
|
|
}
|
|
|
|
ss.Respond(eventschema.ListResp{
|
|
ResponseData: commonschema.ErrorData{
|
|
ErrorCode: constant.ErrorCodeEventNoEventData,
|
|
},
|
|
ReleaseInfo: []any{},
|
|
StatusCode: 600,
|
|
})
|
|
}
|
|
|
|
func init() {
|
|
router.AddHandler("main.php", "POST", "/event/eventList", middleware.Common, list)
|
|
}
|