Commit dec05051 authored by hujiebin's avatar hujiebin

feat:oldCp

parent b4ec010a
......@@ -35,17 +35,19 @@ func (OldCp) TableName() string {
return "cp"
}
func GetOldCpOrNil(model *domain.Model, tmpUserId1 mysql.ID, tmpUserId2 mysql.ID) (*Cp, error) {
// 获取旧的绑定中的cp
func GetOldConnectCp(model *domain.Model, tmpUserId1 mysql.ID, tmpUserId2 mysql.ID) (*OldCp, error) {
userId1 := tmpUserId1
userId2 := tmpUserId2
if tmpUserId1 < tmpUserId2 {
userId1 = tmpUserId2
userId2 = tmpUserId1
}
cp := Cp{}
if err := model.Db.Where(&Cp{
cp := OldCp{}
if err := model.Db.Where(&OldCp{
UserId1: userId1,
UserId2: userId2,
Status: Connect,
}).First(&cp).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return nil, nil
......
......@@ -158,7 +158,7 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
title = cp_cv.GetTranslate(msgId, req.Language)
}
var oldScore uint32
if oldCp, _ := cp_m.GetOldCpOrNil(model, cpRelation.UserId1, cpRelation.UserId2); oldCp != nil {
if oldCp, _ := cp_m.GetOldConnectCp(model, cpRelation.UserId1, cpRelation.UserId2); oldCp != nil {
oldScore = uint32(oldCp.Score)
}
response = cp_cv.CvCp{
......
......@@ -33,7 +33,7 @@ func TestCalLoc(t *testing.T) {
func TestSumCpScore(t *testing.T) {
model := domain.CreateModelNil()
old, err := cp_m.GetOldCpOrNil(model, 76421, 4549)
old, err := cp_m.GetOldConnectCp(model, 7642, 4549)
t.Logf("%v-%v", old, err)
n := cp_m.SumCpPoints(model, 1)
t.Logf("%v", n)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment