MCPcopy Create free account
hub / github.com/TalkingData/owl / getAllUsers

Method getAllUsers

api/mysql.go:717–744  ·  view source on GitHub ↗
(paging bool, query string, order string, offset, limit int)

Source from the content-addressed store, hash-verified

715}
716
717func (d *db) getAllUsers(paging bool, query string, order string, offset, limit int) (int, []User) {
718 var (
719 users = make([]User, 0)
720 cnt int
721 err error
722 )
723 rawSQL := fmt.Sprintf("select id, username, display_name, role, wechat, type, mail, phone, status, create_at, update_at from user")
724 cntSQL := fmt.Sprintf("select count(*) from user")
725 if len(query) > 0 {
726 rawSQL = fmt.Sprintf("%s where username like '%%%s%%' or display_name like '%%%s%%' or phone like '%%%s%%'", rawSQL, query, query, query)
727 cntSQL = fmt.Sprintf("%s where username like '%%%s%%' or display_name like '%%%s%%' or phone like '%%%s%%'", cntSQL, query, query, query)
728 }
729 if len(order) > 0 {
730 rawSQL = fmt.Sprintf("%s order by %s", rawSQL, order)
731 }
732 if paging {
733 rawSQL = fmt.Sprintf("%s limit %d, %d", rawSQL, offset, limit)
734 }
735 log.Println(rawSQL)
736 log.Println(cntSQL)
737 if err = d.Select(&users, rawSQL); err != nil {
738 log.Println(err)
739 }
740 if err = d.Get(&cnt, cntSQL); err != nil {
741 log.Println(err)
742 }
743 return cnt, users
744}
745
746// get user profile
747func (d *db) getUserProfile(username string) *User {

Callers 2

SyncUsersFunction · 0.80
listAllUsersFunction · 0.80

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected