diff --git a/route/cp_r/cp_relation.go b/route/cp_r/cp_relation.go index b274afb1453ba896afbadf1c7f3293f813606069..4c70879f97512df76dd6fc22c5ad78f46305b564 100644 --- a/route/cp_r/cp_relation.go +++ b/route/cp_r/cp_relation.go @@ -417,6 +417,9 @@ func CpDetailPage(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myCtx, err } + if user == nil || user.ID == 0 { + return myCtx, bizerr.InvalidParameter + } cp, err := cp_m.GetCp(model, user.ID) if err != nil { @@ -434,12 +437,14 @@ func CpDetailPage(c *gin.Context) (*mycontext.MyContext, error) { res = new(CpDetail) // 返回值 level := cp_m.GetCpLevel(model, cp.Id) - res.CpLevel = cp_cv.CvCpLevel{ - Level: level.Level, - Points: cp_e.CpLevelPoints[level.Level] + level.Points, - StartPoints: cp_e.CpLevelPoints[level.Level], - ExpireAtUnix: level.ExpireAt.Unix(), - SettlementDate: level.ExpireAt.Format(utils.DATE_FORMAT), + if level.ID > 0 { + res.CpLevel = cp_cv.CvCpLevel{ + Level: level.Level, + Points: cp_e.CpLevelPoints[level.Level] + level.Points, + StartPoints: cp_e.CpLevelPoints[level.Level], + ExpireAtUnix: level.ExpireAt.Unix(), + SettlementDate: level.ExpireAt.Format(utils.DATE_FORMAT), + } } if res.CpLevel.Level != cp_e.CpLevelMax { res.CpLevel.EndPoints = cp_e.CpLevelPoints[res.CpLevel.Level+1]