瀏覽代碼

update

master
shenjiachi 4 天之前
父節點
當前提交
2fadc60eff
共有 1 個檔案被更改,包括 14 行新增5 行删除
  1. +14
    -5
      src/implement/user_tag_records_implement.go

+ 14
- 5
src/implement/user_tag_records_implement.go 查看文件

@@ -3,6 +3,7 @@ package implement
import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"fmt"
"reflect"
@@ -44,10 +45,10 @@ func (u UserTagRecordsDb) UserTagRecordsUpdateBySession(session *xorm.Session, u

func (u UserTagRecordsDb) UserTagRecordsDeleteBySession(session *xorm.Session, params map[string]interface{}) (int64, error) {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
return session.In(zhios_order_relate_logx.AnyToString(params["key"]), params["value"]).Delete(model.UserTag{})
return session.In(zhios_order_relate_logx.AnyToString(params["key"]), params["value"]).Delete(model.UserTagRecords{})
} else {
var query = fmt.Sprintf("%s =?", params["key"])
return session.Where(query, params["value"]).Delete(model.UserTag{})
return session.Where(query, params["value"]).Delete(model.UserTagRecords{})
}
}

@@ -61,9 +62,17 @@ func (u UserTagRecordsDb) UserTagRecordsBatchInsert(userTagRecord []*model.UserT

func (u UserTagRecordsDb) UserTagRecordsFindByParams(params map[string]interface{}) (*[]model.UserTagRecords, error) {
var m []model.UserTagRecords
var query = fmt.Sprintf("%s = ?", params["key"])
if err := u.Db.Where(query, params["value"]).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Error(err)
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := u.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err)
}
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := u.Db.Where(query, params["value"]).Find(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
}
return &m, nil
}

Loading…
取消
儲存