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