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:
@@ -1,9 +1,11 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/middleware"
|
||||
usermodel "honoka-chan/internal/model/user"
|
||||
"honoka-chan/internal/router"
|
||||
"honoka-chan/internal/schema/unit"
|
||||
unitschema "honoka-chan/internal/schema/unit"
|
||||
"honoka-chan/internal/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -13,7 +15,22 @@ func setDisplayRank(ctx *gin.Context) {
|
||||
ss := session.Get(ctx)
|
||||
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{},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
|
||||
Reference in New Issue
Block a user