liuxiaolong
2022-03-04 f64dd9f191dff341b4eb430d7bacc44a3db9a279
models/userClient.go
@@ -25,7 +25,7 @@
func (uc *UserClient) Exist(phoneNum string) bool {
   var list []UserClient
   o := orm.NewOrm()
   o.Raw("select * from ? where phoneNum=?", uc.TableName(), phoneNum).QueryRows(&list)
   o.QueryTable(uc.TableName()).Filter("phoneNum", phoneNum).All(&list)
   if len(list) >0 {
      return true
   }
@@ -35,17 +35,27 @@
func (uc *UserClient) ExistByCid(phoneNum string, cid string) bool {
   var list []UserClient
   o := orm.NewOrm()
   o.Raw("select * from ? where phoneNum=? and clientId=?", uc.TableName(), phoneNum, cid).QueryRows(&list)
   o.QueryTable(uc.TableName()).Filter("phoneNum", phoneNum).Filter("clientId", cid).All(&list)
   if len(list) >0 {
      return true
   }
   return false
}
func (uc *UserClient) Delete(phoneNum string, clientId string) (int64, error) {
func (uc *UserClient) GetByCid(cid string) []UserClient {
   var list []UserClient
   o := orm.NewOrm()
   sql := fmt.Sprintf("delete from "+uc.TableName()+" where phoneNum='%s' and clientId='%s'", phoneNum, clientId)
   _, err := o.QueryTable(uc.TableName()).Filter("clientId", cid).All(&list)
   if err != nil {
      return nil
   }
   return  list
}
func (uc *UserClient) DeleteByCid(clientId string) (int64, error) {
   o := orm.NewOrm()
   sql := fmt.Sprintf("delete from "+uc.TableName()+" where clientId='%s'", clientId)
   result, err := o.Raw(sql).Exec()
   if err != nil {
      return 0, err