- Add session.Attach to reuse per-request sessions across middleware and ghome handlers - Make Session finalize/abort paths idempotent to avoid duplicate commit or rollback work - Move request_data parsing helper to internal/utils - Expand ParseRequestData usage across api, download, unit, live, multiunit, and subscenario handlers - Extract download package metadata into internal/handler/download/types.go - Return explicit errors from selected session lookup helpers and update callers - Make api action handlers return errors directly instead of calling ss.CheckErr in nested layers Signed-off-by: Sean Du <do4suki@gmail.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package museum
|
|
|
|
import (
|
|
museumapischema "honoka-chan/internal/schema/api/museum"
|
|
"honoka-chan/internal/session"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func museumInfo(ctx *gin.Context) (res any, err error) {
|
|
ss := session.Get(ctx)
|
|
|
|
var museumRes []struct {
|
|
MuseumContentsId int `xorm:"museum_contents_id"`
|
|
SmileBuff int `xorm:"smile_buff"`
|
|
PureBuff int `xorm:"pure_buff"`
|
|
CoolBuff int `xorm:"cool_buff"`
|
|
}
|
|
var museumID []int
|
|
var smileBuff, pureBuff, coolBuff int
|
|
err = ss.MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").
|
|
OrderBy("museum_contents_id ASC").Find(&museumRes)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, res := range museumRes {
|
|
smileBuff += res.SmileBuff
|
|
pureBuff += res.PureBuff
|
|
coolBuff += res.CoolBuff
|
|
museumID = append(museumID, res.MuseumContentsId)
|
|
}
|
|
res = museumapischema.InfoResp{
|
|
Result: museumapischema.InfoData{
|
|
MuseumInfo: museumapischema.Info{
|
|
Parameter: museumapischema.Parameter{
|
|
Smile: smileBuff,
|
|
Pure: pureBuff,
|
|
Cool: coolBuff,
|
|
},
|
|
ContentsIDList: museumID,
|
|
},
|
|
},
|
|
Status: 200,
|
|
CommandNum: false,
|
|
TimeStamp: time.Now().Unix(),
|
|
}
|
|
|
|
return res, err
|
|
}
|