Binary file not shown.
+50
-3
@@ -296,10 +296,57 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
case "removableSkillInfo":
|
case "removableSkillInfo":
|
||||||
// key = "owning_equip_result"
|
// key = "owning_equip_result"
|
||||||
|
var skillEquipCount []model.SkillEquipCount
|
||||||
|
err := UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||||
|
GroupBy("unit_removable_skill_id").Find(&skillEquipCount)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
var rmSkillIds []int
|
||||||
|
err = MainEng.Table("unit_removable_skill_m").Where("effect_range = 1").Cols("unit_removable_skill_id").Find(&rmSkillIds)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
owingInfo := []model.OwningInfo{}
|
||||||
|
for _, id := range rmSkillIds {
|
||||||
|
info := model.OwningInfo{
|
||||||
|
UnitRemovableSkillID: id,
|
||||||
|
TotalAmount: 9,
|
||||||
|
EquippedAmount: 0,
|
||||||
|
InsertDate: "2023-01-01 12:00:00",
|
||||||
|
}
|
||||||
|
for _, sk := range skillEquipCount {
|
||||||
|
if id == sk.UnitRemovableSkillId {
|
||||||
|
info.EquippedAmount = sk.Count
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
owingInfo = append(owingInfo, info)
|
||||||
|
}
|
||||||
|
|
||||||
|
// equipInfo := []model.SkillEquip{}
|
||||||
|
// err = UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Cols("unit_removable_skill_id,unit_owning_user_id").Find(&equipInfo)
|
||||||
|
// CheckErr(err)
|
||||||
|
|
||||||
|
var unitOwningIds []int
|
||||||
|
err = UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Cols("unit_owning_user_id").GroupBy("unit_owning_user_id").Find(&unitOwningIds)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
equipInfo := map[int]interface{}{}
|
||||||
|
for _, v := range unitOwningIds {
|
||||||
|
detail := []model.SkillEquipDetail{}
|
||||||
|
err = UserEng.Table("skill_equip_m").Where("user_id = ? AND unit_owning_user_id = ?", ctx.GetString("userid"), v).
|
||||||
|
Cols("unit_removable_skill_id").Find(&detail)
|
||||||
|
CheckErr(err)
|
||||||
|
|
||||||
|
equipInfo[v] = model.SkillEquipList{
|
||||||
|
UnitOwningUserID: v,
|
||||||
|
Detail: detail,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rmSkillResp := model.RemovableSkillResp{
|
rmSkillResp := model.RemovableSkillResp{
|
||||||
Result: model.RemovableSkillResult{
|
Result: model.RemovableSkillResult{
|
||||||
OwningInfo: []model.OwningInfo{},
|
OwningInfo: owingInfo,
|
||||||
EquipmentInfo: []interface{}{},
|
EquipmentInfo: equipInfo,
|
||||||
}, // 宝石
|
}, // 宝石
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
@@ -312,7 +359,7 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
accessoryList := []model.AccessoryList{}
|
accessoryList := []model.AccessoryList{}
|
||||||
err := MainEng.Table("common_accessory_m").Find(&accessoryList)
|
err := MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
for k, _ := range accessoryList {
|
for k := range accessoryList {
|
||||||
accessoryList[k].NextExp = 0
|
accessoryList[k].NextExp = 0
|
||||||
accessoryList[k].Level = 8
|
accessoryList[k].Level = 8
|
||||||
accessoryList[k].MaxLevel = 8
|
accessoryList[k].MaxLevel = 8
|
||||||
|
|||||||
@@ -317,3 +317,65 @@ func WearAccessory(ctx *gin.Context) {
|
|||||||
|
|
||||||
ctx.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveSkillEquip(ctx *gin.Context) {
|
||||||
|
fmt.Println(ctx.PostForm("request_data"))
|
||||||
|
req := model.SkillEquipReq{}
|
||||||
|
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &req); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
UserEng.ShowSQL(true)
|
||||||
|
// 开始事务
|
||||||
|
session := UserEng.NewSession()
|
||||||
|
defer session.Close()
|
||||||
|
if err := session.Begin(); err != nil {
|
||||||
|
session.Rollback()
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取下宝石
|
||||||
|
for _, v := range req.Remove {
|
||||||
|
fmt.Println("Remove:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
||||||
|
_, err := session.Table("skill_equip_m").
|
||||||
|
Where("unit_removable_skill_id = ? AND unit_owning_user_id = ? AND user_id = ?", v.UnitRemovableSkillID, v.UnitOwningUserID, ctx.GetString("userid")).
|
||||||
|
Delete()
|
||||||
|
if err != nil {
|
||||||
|
session.Rollback()
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 佩戴宝石
|
||||||
|
for _, v := range req.Equip {
|
||||||
|
fmt.Println("Equip:", v.UnitOwningUserID, v.UnitRemovableSkillID)
|
||||||
|
data := model.SkillEquipData{
|
||||||
|
UnitRemovableSkillId: v.UnitRemovableSkillID,
|
||||||
|
UnitOwningUserID: v.UnitOwningUserID,
|
||||||
|
UserId: ctx.GetString("userid"),
|
||||||
|
}
|
||||||
|
_, err := session.Table("skill_equip_m").Insert(&data)
|
||||||
|
CheckErr(err)
|
||||||
|
}
|
||||||
|
if err := session.Commit(); err != nil {
|
||||||
|
session.Rollback()
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wearResp := model.AwardSetResp{
|
||||||
|
ResponseData: []interface{}{},
|
||||||
|
ReleaseInfo: []interface{}{},
|
||||||
|
StatusCode: 200,
|
||||||
|
}
|
||||||
|
resp, err := json.Marshal(wearResp)
|
||||||
|
CheckErr(err)
|
||||||
|
fmt.Println(string(resp))
|
||||||
|
|
||||||
|
nonce := ctx.GetInt("nonce")
|
||||||
|
nonce++
|
||||||
|
|
||||||
|
ctx.Header("user_id", ctx.GetString("userid"))
|
||||||
|
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||||
|
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||||
|
|
||||||
|
ctx.String(http.StatusOK, string(resp))
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ func main() {
|
|||||||
m.POST("/unit/deck", handler.SetDeckHandler)
|
m.POST("/unit/deck", handler.SetDeckHandler)
|
||||||
m.POST("/unit/deckName", handler.SetDeckNameHandler)
|
m.POST("/unit/deckName", handler.SetDeckNameHandler)
|
||||||
m.POST("/unit/favorite", handler.SetDisplayRankHandler)
|
m.POST("/unit/favorite", handler.SetDisplayRankHandler)
|
||||||
|
m.POST("/unit/removableSkillEquipment", handler.RemoveSkillEquip)
|
||||||
m.POST("/unit/setDisplayRank", handler.SetDisplayRankHandler)
|
m.POST("/unit/setDisplayRank", handler.SetDisplayRankHandler)
|
||||||
m.POST("/unit/wearAccessory", handler.WearAccessory)
|
m.POST("/unit/wearAccessory", handler.WearAccessory)
|
||||||
m.POST("/user/changeName", handler.ChangeNameHandler)
|
m.POST("/user/changeName", handler.ChangeNameHandler)
|
||||||
|
|||||||
+56
-1
@@ -71,6 +71,61 @@ type AccessoryWearResp struct {
|
|||||||
StatusCode int `json:"status_code"`
|
StatusCode int `json:"status_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SkillEquipReq ...
|
||||||
|
type SkillEquipReq struct {
|
||||||
|
Module string `json:"module"`
|
||||||
|
Remove []SkillRemove `json:"remove"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
TimeStamp int `json:"timeStamp"`
|
||||||
|
Equip []SkillEquip `json:"equip"`
|
||||||
|
Mgd int `json:"mgd"`
|
||||||
|
CommandNum string `json:"commandNum"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillRemove ...
|
||||||
|
type SkillRemove struct {
|
||||||
|
UnitRemovableSkillID int `json:"unit_removable_skill_id"`
|
||||||
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquip ...
|
||||||
|
type SkillEquip struct {
|
||||||
|
UnitRemovableSkillID int `json:"unit_removable_skill_id"`
|
||||||
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquipCount ...
|
||||||
|
type SkillEquipCount struct {
|
||||||
|
UnitRemovableSkillId int `xorm:"unit_removable_skill_id"`
|
||||||
|
Count int `xorm:"ct"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquipData ...
|
||||||
|
type SkillEquipData struct {
|
||||||
|
Id int `xorm:"id pk autoincr"`
|
||||||
|
UnitRemovableSkillId int `xorm:"unit_removable_skill_id"`
|
||||||
|
UnitOwningUserID int `xorm:"unit_owning_user_id"`
|
||||||
|
UserId string `xorm:"user_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquipDetail ...
|
||||||
|
type SkillEquipDetail struct {
|
||||||
|
UnitRemovableSkillID int `json:"unit_removable_skill_id" xorm:"unit_removable_skill_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquipList ...
|
||||||
|
type SkillEquipList struct {
|
||||||
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
|
Detail []SkillEquipDetail `json:"detail"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkillEquipResp ...
|
||||||
|
type SkillEquipResp struct {
|
||||||
|
ResponseData []interface{} `json:"response_data"`
|
||||||
|
ReleaseInfo []interface{} `json:"release_info"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
|
}
|
||||||
|
|
||||||
// module: unit, action: unitAll
|
// module: unit, action: unitAll
|
||||||
type Costume struct {
|
type Costume struct {
|
||||||
UnitID int `json:"unit_id"`
|
UnitID int `json:"unit_id"`
|
||||||
@@ -193,7 +248,7 @@ type OwningInfo struct {
|
|||||||
|
|
||||||
type RemovableSkillResult struct {
|
type RemovableSkillResult struct {
|
||||||
OwningInfo []OwningInfo `json:"owning_info"`
|
OwningInfo []OwningInfo `json:"owning_info"`
|
||||||
EquipmentInfo []interface{} `json:"equipment_info"`
|
EquipmentInfo map[int]interface{} `json:"equipment_info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemovableSkillResp struct {
|
type RemovableSkillResp struct {
|
||||||
|
|||||||
+1
-1
@@ -324,7 +324,7 @@ func GenApi1Data() {
|
|||||||
// _ = model.RemovableSkillResp{
|
// _ = model.RemovableSkillResp{
|
||||||
Result: model.RemovableSkillResult{
|
Result: model.RemovableSkillResult{
|
||||||
OwningInfo: []model.OwningInfo{},
|
OwningInfo: []model.OwningInfo{},
|
||||||
EquipmentInfo: []interface{}{},
|
EquipmentInfo: map[int]interface{}{},
|
||||||
}, // 宝石
|
}, // 宝石
|
||||||
Status: 200,
|
Status: 200,
|
||||||
CommandNum: false,
|
CommandNum: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user