作者 tangxvhui

... ... @@ -142,6 +142,11 @@ func (c RankController) RankSeasonAdd() {
return
}
endTime = t2.Unix() + 86399 //60*60*24-1
ok := serverank.RankPeriodCheckTime(param.RankTypeId, beginTime, endTime, 0)
if !ok {
msg = protocol.BadRequestParam("10101")
return
}
companyid := c.GetCompanyId()
err = serverank.AddRankPeriod(param.RankTypeId, beginTime, endTime, param.Name, companyid)
msg = protocol.NewReturnResponse(nil, err)
... ... @@ -158,6 +163,7 @@ func (c RankController) RankSeasonEdit() {
type Parameter struct {
Id int64 `json:"id"`
Name string `json:"name"`
RankTypeId int64 `json:"rank_type_id"`
BeginTime string `json:"begin_time"`
EndTime string `json:"end_time"`
}
... ... @@ -189,6 +195,11 @@ func (c RankController) RankSeasonEdit() {
}
endTime = t2.Unix() + 86399 //60*60*24-1
ok := serverank.RankPeriodCheckTime(param.RankTypeId, beginTime, endTime, param.Id)
if !ok {
msg = protocol.BadRequestParam("10101")
return
}
companyid := c.GetCompanyId()
fmt.Println(beginTime, endTime)
err = serverank.EditRankPeriod(param.Id, beginTime, endTime, param.Name, companyid)
... ...
... ... @@ -106,6 +106,8 @@ var errmessge ErrorMap = map[string]string{
"12102": "评分规则不符合要求",
//权限配置相关
"10091": "至少选择一个特定部门",
//榜单设置
"10101": "赛季周期设置与其他赛季重叠",
}
//错误码转换 ,兼容需要
... ...
... ... @@ -197,6 +197,31 @@ func AddRankPeriod(rankTypeId int64, beginTime int64, endTime int64, name string
return nil
}
//RankPeriodCheckTime 设置赛季时检查时间范围的合法性
func RankPeriodCheckTime(rankTypeId int64, beginTime int64, endTime int64, idNot int64) bool {
sql := `SELECT 1 FROM rank_period
WHERE rank_type_id = %d
AND id <> %d
AND
(
(UNIX_TIMESTAMP(begin_time) BETWEEN %d AND %d)
OR
(UNIX_TIMESTAMP(end_time) BETWEEN %d AND %d)
)
LIMIT 1 `
sql = fmt.Sprintf(sql, rankTypeId, idNot, beginTime, endTime, beginTime, endTime)
var cnt int
err := utils.ExecuteQueryOne(&cnt, sql)
if err != nil {
log.Error("SQL Execute err:%s", err)
return false
}
if cnt > 0 {
return false
}
return true
}
func EditRankPeriod(id int64, beginTime int64, endTime int64, name string, companyid int64) error {
var (
err error
... ... @@ -607,3 +632,21 @@ func AllowRankRange(id int64, companyid int64) error {
}
return nil
}
func RankRangeMove(fromId int64, toId int64, moveIds []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
}
... ...