Reorganize directory structures
Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MuseumContent struct {
|
||||
MuseumContentsId int `xorm:"museum_contents_id"`
|
||||
SmileBuff int `xorm:"smile_buff"`
|
||||
PureBuff int `xorm:"pure_buff"`
|
||||
CoolBuff int `xorm:"cool_buff"`
|
||||
}
|
||||
|
||||
func MuseumInfo(ctx *gin.Context) {
|
||||
var contents []MuseumContent
|
||||
err := MainEng.Table("museum_contents_m").Cols("museum_contents_id,smile_buff,pure_buff,cool_buff").Find(&contents)
|
||||
utils.CheckErr(err)
|
||||
var smileBuff, pureBuff, coolBuff int
|
||||
var contentsList []int
|
||||
for _, content := range contents {
|
||||
smileBuff += content.SmileBuff
|
||||
pureBuff += content.PureBuff
|
||||
coolBuff += content.CoolBuff
|
||||
contentsList = append(contentsList, content.MuseumContentsId)
|
||||
}
|
||||
museumResp := model.MuseumResp{
|
||||
ResponseData: model.MuseumRes{
|
||||
MuseumInfo: model.Museum{
|
||||
Parameter: model.MuseumParameter{
|
||||
Smile: smileBuff,
|
||||
Pure: pureBuff,
|
||||
Cool: coolBuff,
|
||||
},
|
||||
ContentsIDList: contentsList,
|
||||
},
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
},
|
||||
ReleaseInfo: []any{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(museumResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
Reference in New Issue
Block a user