@@ -0,0 +1,17 @@
|
||||
package album
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AlbumApi(ctx *gin.Context, action string) (res any, err error) {
|
||||
switch action {
|
||||
case "albumAll":
|
||||
res, err = albumAll(ctx)
|
||||
default:
|
||||
err = fmt.Errorf("unimplemented action: album: %s", action)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package album
|
||||
|
||||
import (
|
||||
"honoka-chan/internal/schema/api/album"
|
||||
"honoka-chan/internal/session"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func albumAll(ctx *gin.Context) (res any, err error) {
|
||||
ss := session.Get(ctx)
|
||||
|
||||
albumLists := []album.UnitList{}
|
||||
var unitList []struct {
|
||||
UnitId int `xorm:"unit_id"`
|
||||
Rarity int `xorm:"rarity"`
|
||||
}
|
||||
err = ss.MainEng.Table("unit_m").Cols("unit_id,rarity").OrderBy("unit_id ASC").Find(&unitList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, unit := range unitList {
|
||||
albumList := album.UnitList{
|
||||
RankMaxFlag: true,
|
||||
LoveMaxFlag: true,
|
||||
RankLevelMaxFlag: true,
|
||||
AllMaxFlag: true,
|
||||
FavoritePoint: 1000,
|
||||
}
|
||||
albumList.UnitID = unit.UnitId
|
||||
if unit.Rarity != 4 {
|
||||
albumList.SignFlag = false
|
||||
switch unit.Rarity {
|
||||
case 1:
|
||||
albumList.HighestLovePerUnit = 50
|
||||
albumList.TotalLove = 50
|
||||
case 2:
|
||||
albumList.HighestLovePerUnit = 200
|
||||
albumList.TotalLove = 200
|
||||
case 3:
|
||||
albumList.HighestLovePerUnit = 500
|
||||
albumList.TotalLove = 500
|
||||
case 5:
|
||||
albumList.HighestLovePerUnit = 750
|
||||
albumList.TotalLove = 750
|
||||
}
|
||||
} else {
|
||||
albumList.HighestLovePerUnit = 1000
|
||||
albumList.TotalLove = 1000
|
||||
|
||||
// IsSigned
|
||||
albumList.SignFlag, err = ss.MainEng.Table("unit_sign_asset_m").Where("unit_id = ?", unit.UnitId).Exist()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
albumLists = append(albumLists, albumList)
|
||||
}
|
||||
|
||||
res = album.AllResp{
|
||||
Result: albumLists,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user