...
|
...
|
@@ -18,7 +18,7 @@ func GetRankList(companyid int64) []protocol.ResponseRankType { |
|
|
rspData = make([]protocol.ResponseRankType, 0)
|
|
|
err error
|
|
|
)
|
|
|
sqlString := `SELECT id,name,status,rank_type FROM rank WHERE company_id=?`
|
|
|
sqlString := `SELECT id,name,enable_status,type FROM rank_type WHERE company_id=?`
|
|
|
err = utils.ExecuteQueryAll(&rspData, sqlString, companyid)
|
|
|
if err != nil {
|
|
|
log.Error("获取榜单列表失败,err%s", err)
|
...
|
...
|
@@ -148,7 +148,7 @@ func RankSeasonList(pageindex int, pagesize int, companyid int64) (protocol.Resp |
|
|
var (
|
|
|
err error
|
|
|
listdata []protocol.RankSeasonItem
|
|
|
cnt int64
|
|
|
cnt int
|
|
|
)
|
|
|
rspData := protocol.ResponseRankSeasonList{
|
|
|
ResponsePageInfo: protocol.ResponsePageInfo{
|
...
|
...
|
@@ -173,6 +173,8 @@ func RankSeasonList(pageindex int, pagesize int, companyid int64) (protocol.Resp |
|
|
log.Error("EXCUTE SQL ERR:%s", err)
|
|
|
return rspData, nil
|
|
|
}
|
|
|
rspData.TotalPage = cnt
|
|
|
rspData.List = listdata
|
|
|
return rspData, err
|
|
|
}
|
|
|
|
...
|
...
|
@@ -184,8 +186,8 @@ func AddRankPeriod(rankTypeId int64, beginTime int64, endTime int64, name string |
|
|
CompanyId: companyid,
|
|
|
SeasonName: name,
|
|
|
RankTypeId: rankTypeId,
|
|
|
BeginTime: time.Unix(beginTime, 0),
|
|
|
EndTime: time.Unix(endTime, 0),
|
|
|
BeginTime: time.Unix(beginTime, 0).Local(),
|
|
|
EndTime: time.Unix(endTime, 0).Local(),
|
|
|
Status: 0,
|
|
|
}
|
|
|
_, err = models.AddRankPeriod(m)
|
...
|
...
|
@@ -212,7 +214,7 @@ func EditRankPeriod(id int64, beginTime int64, endTime int64, name string, compa |
|
|
m.SeasonName = name
|
|
|
m.BeginTime = time.Unix(beginTime, 0)
|
|
|
m.EndTime = time.Unix(endTime, 0)
|
|
|
err = models.UpdateRankPeriodById(m)
|
|
|
err = models.UpdateRankPeriodById(m, []string{"SeasonName", "BeginTime", "EndTime"})
|
|
|
if err != nil {
|
|
|
log.Error("更新赛季失败;%s", err)
|
|
|
}
|
...
|
...
|
@@ -226,7 +228,7 @@ func GetRankRangeList(companyid int64) []protocol.RankRangeItem { |
|
|
rspData = make([]protocol.RankRangeItem, 0)
|
|
|
)
|
|
|
datasql := `SELECT a.id ,a.name,a.type FROM rank_range AS a WHERE company_id=?`
|
|
|
err = utils.ExecuteQueryAll(rspData, datasql, companyid)
|
|
|
err = utils.ExecuteQueryAll(&rspData, datasql, companyid)
|
|
|
if err != nil {
|
|
|
log.Error("获取参与人列表失败:%s", err)
|
|
|
}
|
...
|
...
|
@@ -497,6 +499,7 @@ func GetRankItemEdit(companyid int64, rankTypeid int64, itemKey []string) error |
|
|
RankTypeId: rankTypeid,
|
|
|
ItemName: AllRankItem[ii].ItemName,
|
|
|
SortNum: i,
|
|
|
ItemKey: itemKey[i],
|
|
|
}
|
|
|
newItems = append(newItems, m)
|
|
|
break
|
...
|
...
|
@@ -526,7 +529,7 @@ func GetRankItemEdit(companyid int64, rankTypeid int64, itemKey []string) error |
|
|
for i := range newItems {
|
|
|
var has bool = false
|
|
|
for ii := range rankitemData {
|
|
|
if rankitemData[i].ItemKey == newItems[ii].ItemKey {
|
|
|
if rankitemData[ii].ItemKey == newItems[i].ItemKey {
|
|
|
has = true
|
|
|
break
|
|
|
}
|
...
|
...
|
@@ -538,15 +541,17 @@ func GetRankItemEdit(companyid int64, rankTypeid int64, itemKey []string) error |
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
|
//添加
|
|
|
if len(addItems) > 0 {
|
|
|
_, err = models.AddRankItem(addItems, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("添加rank_item记录失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
}
|
|
|
//更新
|
|
|
for i := range updateItems {
|
|
|
err = models.UpdateRankItemById(&updateItems[i], []string{"SortNum"}, o)
|
|
|
err = models.UpdateRankItemById(&updateItems[i], []string{"SortNum", "ItemName", "ItemKey"}, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("更新rank_item记录失败:%s", err)
|
...
|
...
|
@@ -554,12 +559,51 @@ func GetRankItemEdit(companyid int64, rankTypeid int64, itemKey []string) error |
|
|
}
|
|
|
}
|
|
|
//删除
|
|
|
if len(delItemIds) > 0 {
|
|
|
err = models.DeleteRanKItemByIds(delItemIds, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("删除rank_item记录失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
o.Commit()
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func ForbidRankRange(id int64, companyid int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
rankRange *models.RankRange
|
|
|
)
|
|
|
rankRange, err = models.GetRankRangeById(id)
|
|
|
if err != nil {
|
|
|
log.Error("获取rank_range数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
rankRange.Status = 1
|
|
|
err = models.UpdateRankRangeById(rankRange, []string{"Status"})
|
|
|
if err != nil {
|
|
|
log.Error("更新rank_range数据失败:%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func AllowRankRange(id int64, companyid int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
rankRange *models.RankRange
|
|
|
)
|
|
|
rankRange, err = models.GetRankRangeById(id)
|
|
|
if err != nil {
|
|
|
log.Error("获取rank_range数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
rankRange.Status = 0
|
|
|
err = models.UpdateRankRangeById(rankRange, []string{"Status"})
|
|
|
if err != nil {
|
|
|
log.Error("更新rank_range数据失败:%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|