diff --git a/controllers/client/sign.go b/controllers/client/sign.go index 90aa2e8..438da0a 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -144,7 +144,7 @@ func (t *SignCtl) RealSign() { history.CreatedAt = time.Now() history.UpdatedAt = time.Now() if isSign { - err = history.UpdateById(history.Id) + err = history.UpdateById([]interface{}{history.Id}) } else { err = history.Insert() } diff --git a/controllers/pc/sign.go b/controllers/pc/sign.go index ef003ac..a6a7eb9 100644 --- a/controllers/pc/sign.go +++ b/controllers/pc/sign.go @@ -6,6 +6,7 @@ import ( "hudongzhuanjia/utils" "hudongzhuanjia/utils/code" "hudongzhuanjia/utils/define" + "strings" "github.com/ouxuanserver/osmanthuswine/src/core" ) @@ -93,7 +94,7 @@ func (t *SignCtl) RealSignInfo() { rid := t.MustGetInt64("rehearsal_id") results := make([]*models.RealSignHistory, 0) err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=0", - aid, rid).Asc("updated_at").Find(results) + aid, rid).Asc("updated_at").Find(&results) t.CheckErr(err) t.JSON(map[string]interface{}{ "result": results, @@ -102,11 +103,14 @@ func (t *SignCtl) RealSignInfo() { } func (t *SignCtl) RealSignVerify() { - id := t.MustGetInt64("real_sign_history_id") // 获取历史信息 - + ids := strings.Split(t.MustGet("real_sign_history_ids"), ",") + idList := make([]interface{}, len(ids)) + for _, id := range ids { + idList = append(idList, id) + } history := new(models.RealSignHistory) history.Status = 1 - err := history.UpdateById(id, "status") + err := history.UpdateById(idList, "status") t.CheckErr(err) t.SUCCESS("审核成功") } diff --git a/log/hdzj.log b/log/hdzj.log index 089e80e..700b338 100644 --- a/log/hdzj.log +++ b/log/hdzj.log @@ -5,3 +5,4 @@ 2020-03-09 12:40:14.756 ERROR logger/logger.go:92 check err {"error": "Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%张三% and json_list like %张三% )' at line 1"} 2020-03-12 10:06:16.154 ERROR logger/logger.go:92 check err {"error": "token invalid"} 2020-03-12 10:07:26.864 ERROR logger/logger.go:92 check err {"error": "Error 1146: Table 'hudongzhuanjia.ox_real_sign_history' doesn't exist"} +2020-03-12 15:08:47.495 INFO controllers/base.go:57 get int64 from request error%!(EXTRA *strconv.NumError=strconv.ParseInt: parsing "": invalid syntax) diff --git a/models/real_sign_history.go b/models/real_sign_history.go index f3f9404..bbd7f9d 100644 --- a/models/real_sign_history.go +++ b/models/real_sign_history.go @@ -34,12 +34,12 @@ func (t *RealSignHistory) Check(uid, aid, rid int64) (bool, error) { uid, aid, rid).Get(t) } -func (t *RealSignHistory) UpdateById(id int64, fields ...string) (err error) { +func (t *RealSignHistory) UpdateById(ids []interface{}, fields ...string) (err error) { if len(fields) > 0 { - _, err = core.GetXormAuto().ID(id).Cols(fields...).Update(t) + _, err = core.GetXormAuto().In("id", ids...).Cols(fields...).Update(t) } else { - _, err = core.GetXormAuto().ID(id).AllCols().Update(t) + _, err = core.GetXormAuto().In("id", ids...).AllCols().Update(t) } return err }