Commit 09c61258 by Joneq

修改defer的位置

parent 6545a04e
Showing with 18 additions and 6 deletions
......@@ -6,6 +6,7 @@ import (
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/model"
"time"
"github.com/bilibili/kratos/pkg/database/sql"
)
//增加或者修改记录
......@@ -15,15 +16,26 @@ func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int
exitId int
execSql string
affectNum int64
rows *sql.Rows
)
//ss := fmt.Sprintf("select id from lie_scores where `type` = %d and project_pid = %d and project_id = %d and com_credits_id = %d limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId)
//print(ss)
err = d.db.QueryRow(ctx,"select id from lie_scores where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ? limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId).Scan(&exitId)
if err != nil {
fmt.Print(err)
fmt.Print("save list fail")
rows,err = d.db.Query(ctx,"select id from lie_scores where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ? limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId)
defer rows.Close()
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
exitId = 0
for _,v:=range twoMap{
fmt.Print(v)
exitId = 1
break
}
if exitId == 0 {
execSql = "INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
......
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 sign in to comment