1
This commit is contained in:
parent
adbc577e01
commit
6026b3e729
@ -27,7 +27,59 @@ func (this *vip) init() () {
|
||||
}
|
||||
|
||||
func (this *vip) Add(accountAddress string, val string, idx int64, valField string, idxField string) bool {
|
||||
return this.AddEx(accountAddress, val, idx, valField, idxField, [][]string{})
|
||||
this.lock.Lock()
|
||||
defer this.lock.Unlock()
|
||||
|
||||
extKv := [][]string{}
|
||||
accountAddress = strings.ToLower(accountAddress)
|
||||
err, ds := f5.GetGoStyleDb().NewOrmSelect(
|
||||
constant.BCNFT_DB,
|
||||
"t_vip_user",
|
||||
[][]string {
|
||||
{"account_address", accountAddress},
|
||||
})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
updateKv := [][]string {
|
||||
{valField, val},
|
||||
{idxField, q5.ToString(idx)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
}
|
||||
insertKv := [][]string {
|
||||
{"account_address", accountAddress},
|
||||
{valField, val},
|
||||
{idxField, q5.ToString(idx)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
}
|
||||
updateKv = append(updateKv, extKv...)
|
||||
insertKv = append(insertKv, extKv...)
|
||||
if ds.Next() {
|
||||
if q5.ToInt64(ds.GetByName(idxField)) >= idx {
|
||||
return true
|
||||
}
|
||||
err1, _, _ := f5.GetGoStyleDb().NewUpdate(
|
||||
constant.BCNFT_DB,
|
||||
"t_vip_user",
|
||||
[][]string {
|
||||
{"account_address", accountAddress},
|
||||
},
|
||||
updateKv)
|
||||
if err1 != nil {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
err1, _, _ := f5.GetGoStyleDb().NewInsert(
|
||||
constant.BCNFT_DB,
|
||||
"t_vip_user",
|
||||
insertKv)
|
||||
if err1 != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *vip) AddEx(accountAddress string, val string, idx int64, valField string, idxField string,
|
||||
|
Loading…
x
Reference in New Issue
Block a user