Explorar el Código

update

master
shenjiachi hace 1 día
padre
commit
2fadc60eff
Se han modificado 1 ficheros con 14 adiciones y 5 borrados
  1. +14
    -5
      src/implement/user_tag_records_implement.go

+ 14
- 5
src/implement/user_tag_records_implement.go Ver fichero

@@ -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
}

Cargando…
Cancelar
Guardar