作者 tangxvhui

调整,赛季参与人设置

... ... @@ -15,7 +15,7 @@ type ResponseRankSeasonList struct {
}
type RankSeasonItem struct {
Id int64 `json:"id" orm:"column(id)"`
Name string `json:"name" orm:"column(name)"`
Name string `json:"name" orm:"column(season_name)"`
BeginTime string `json:"begin_time" orm:"column(begin_time)"`
EndTime string `json:"end_time" orm:"column(end_time)"`
Status int8 `json:"status" orm:"column(status)"`
... ...
... ... @@ -280,7 +280,7 @@ func AddRankRange(rankTypeId int64, name string, rangetype int8, relationId []in
log.Error("添加rank_range记录失败:%s", err)
return protocol.NewErrWithMessage("1")
}
//TODO 去除其他分组的重复项
for i := range relationId {
m := models.RankRangeData{
RankRangeId: rankRange.Id,
... ... @@ -291,6 +291,13 @@ func AddRankRange(rankTypeId int64, name string, rangetype int8, relationId []in
rankRangeDatas = append(rankRangeDatas, m)
}
if len(rankRangeDatas) > 0 {
//TODO 去除其他分组的重复项
err = deleteRankRangeDataByRelation(rankTypeId, rangetype, relationId, o)
if err != nil {
log.Error(err.Error())
o.Rollback()
return protocol.NewErrWithMessage("1")
}
_, err = models.AddRankRangeDataMulti(rankRangeDatas, o)
if err != nil {
o.Rollback()
... ... @@ -324,28 +331,18 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
}
var (
oldids []int64
delids []int64
addids []int64
)
if rankRange.Type != rangetype {
//当rangeType不同时
delids = oldids
addids = relationId
} else {
for i := range rankRangeDatas {
oldids = append(oldids, rankRangeDatas[i].RelationId)
}
delids = utils.ArrayInt64Diff(oldids, relationId)
addids = utils.ArrayInt64Diff(relationId, oldids)
for i := range rankRangeDatas {
oldids = append(oldids, rankRangeDatas[i].RelationId)
}
var (
addRangeData []models.RankRangeData
)
for i := range addids {
for i := range relationId {
r := models.RankRangeData{
RankRangeId: id,
RangeType: rangetype,
RelationId: addids[i],
RelationId: relationId[i],
}
addRangeData = append(addRangeData, r)
}
... ... @@ -353,22 +350,30 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
rankRange.Type = rangetype
o := orm.NewOrm()
o.Begin()
//TODO 去除其他分组的重复项
err = models.UpdateRankRangeById(rankRange, []string{"Name", "Type"}, o)
if err != nil {
o.Rollback()
log.Error("添加rank_range数据失败:%s", err)
return protocol.NewErrWithMessage("1")
}
if len(delids) > 0 {
err = models.DeleteRankRangeData(delids, o)
if len(oldids) > 0 {
err = models.DeleteRankRangeData(oldids, o)
if err != nil {
o.Rollback()
log.Error("删除rank_range_data数据失败:%s", err)
return protocol.NewErrWithMessage("1")
}
}
if len(addids) > 0 {
if len(relationId) > 0 {
//TODO 去除其他分组的重复项
err = deleteRankRangeDataByRelation(rankRange.RankTypeId, rangetype, relationId, o)
if err != nil {
log.Error(err.Error())
o.Rollback()
return protocol.NewErrWithMessage("1")
}
_, err = models.AddRankRangeDataMulti(addRangeData, o)
if err != nil {
o.Rollback()
... ...