1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package dao
- import (
- "context"
- "database/sql"
- "go-common/app/job/main/passport-user-compare/model"
- xsql "go-common/library/database/sql"
- "go-common/library/log"
- )
- const (
- _getUserTelDuplicateSQL = "SELECT id,mid,tel,cid,tel_bind_time,status,ts FROM user_tel_duplicate WHERE status = 0 order by ts"
- _getUserEmailDuplicateSQL = "SELECT id,mid,email,verified,email_bind_time,status,ts FROM user_email_duplicate WHERE status = 0 order by ts"
- _updateTelDuplicateStatusSQL = "UPDATE user_tel_duplicate SET status = 1 WHERE id = ?"
- _updateEmailDuplicateStatusSQL = "UPDATE user_email_duplicate SET status = 1 WHERE id = ?"
- )
- // UserTelDuplicate get user tel duplicate.
- func (d *Dao) UserTelDuplicate(c context.Context) (res []*model.UserTelDuplicate, err error) {
- var rows *xsql.Rows
- if rows, err = d.userDB.Query(c, _getUserTelDuplicateSQL); err != nil {
- log.Error("fail to get UserTelDuplicate, dao.userDB.Query(%s) error(%v)", _getUserTelDuplicateSQL, err)
- return
- }
- defer rows.Close()
- for rows.Next() {
- r := new(model.UserTelDuplicate)
- if err = rows.Scan(&r.ID, &r.Mid, &r.Tel, &r.Cid, &r.TelBindTime, &r.Status, &r.Timestamp); err != nil {
- log.Error("row.Scan() error(%v)", err)
- res = nil
- return
- }
- res = append(res, r)
- }
- return
- }
- // UserEmailDuplicate get user email duplicate.
- func (d *Dao) UserEmailDuplicate(c context.Context) (res []*model.UserEmailDuplicate, err error) {
- var rows *xsql.Rows
- if rows, err = d.userDB.Query(c, _getUserEmailDuplicateSQL); err != nil {
- log.Error("fail to get UserEmailDuplicate, dao.userDB.Query(%s) error(%v)", _getUserEmailDuplicateSQL, err)
- return
- }
- defer rows.Close()
- for rows.Next() {
- r := new(model.UserEmailDuplicate)
- if err = rows.Scan(&r.ID, &r.Mid, &r.Email, &r.Verified, &r.EmailBindTime, &r.Status, &r.Timestamp); err != nil {
- log.Error("row.Scan() error(%v)", err)
- res = nil
- return
- }
- res = append(res, r)
- }
- return
- }
- // UpdateUserTelDuplicateStatus update user tel duplicate status.
- func (d *Dao) UpdateUserTelDuplicateStatus(c context.Context, id int64) (affected int64, err error) {
- var res sql.Result
- if res, err = d.userDB.Exec(c, _updateTelDuplicateStatusSQL, id); err != nil {
- log.Error("fail to update tel duplicate status, id(%d) dao.userDB.Exec() error(%+v)", id, err)
- return
- }
- return res.RowsAffected()
- }
- // UpdateUserEmailDuplicateStatus update user email duplicate status.
- func (d *Dao) UpdateUserEmailDuplicateStatus(c context.Context, id int64) (affected int64, err error) {
- var res sql.Result
- if res, err = d.userDB.Exec(c, _updateEmailDuplicateStatusSQL, id); err != nil {
- log.Error("fail to update email duplicate status, id(%d) dao.userDB.Exec() error(%+v)", id, err)
- return
- }
- return res.RowsAffected()
- }
|