daily merchant app login fix
This commit is contained in:
@@ -14,7 +14,6 @@ type UserRepository interface {
|
||||
GetUserByID(uid int) (models.UserInfo, error)
|
||||
Login(user models.User) (models.UserInfo, error)
|
||||
FindUserID(authname, contactno string, configid int) (int, error)
|
||||
GetTenantUserByID(userid int) (models.TenantUserInfo, error)
|
||||
UpdateStaff(user models.User) error
|
||||
GetUserByAuthname(authname string, configid int) (int, string, string)
|
||||
GetUserByContactNo(contactno string, configid int) (int, string, string)
|
||||
@@ -188,18 +187,7 @@ func (r *userRepository) FindUserID(authname, contactno string, configid int) (i
|
||||
return uid, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) GetTenantUserByID(userid int) (models.TenantUserInfo, error) {
|
||||
var info models.TenantUserInfo
|
||||
query := `SELECT a.userid, a.authname, a.contactno, a.tenantid, t.tenantname
|
||||
FROM app_users a
|
||||
LEFT JOIN tenants t ON a.tenantid = t.tenantid
|
||||
WHERE a.userid = ?`
|
||||
|
||||
if err := r.db.Raw(query, userid).Scan(&info).Error; err != nil {
|
||||
return info, err
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) UpdateStaff(user models.User) error {
|
||||
return r.db.Table("app_users").Where("userid = ?", user.Userid).Updates(&user).Error
|
||||
@@ -237,6 +225,15 @@ func (r *userRepository) UpdateFCMToken(userid int, token string) error {
|
||||
return r.db.Exec(query, token, userid).Error
|
||||
}
|
||||
|
||||
// The one tenant-user read. There used to be two.
|
||||
//
|
||||
// A `GetTenantUserByID` sat beside this — one capital letter apart, twenty-eight
|
||||
// columns short, selecting only userid, authname, contactno, tenantid and
|
||||
// tenantname. `TenantLogin` called that one, so the mobile login it served
|
||||
// answered with a record whose name, branch, region and coordinates were blank,
|
||||
// and the route was quietly pointed at a different handler to work around it.
|
||||
// Deleted rather than documented: two functions this similar, where picking the
|
||||
// wrong one fails silently, is a trap and not an API.
|
||||
func (r *userRepository) GetTenantUserById(userid int) models.TenantUserInfo {
|
||||
var info models.TenantUserInfo
|
||||
|
||||
@@ -252,12 +249,14 @@ func (r *userRepository) GetTenantUserById(userid int) models.TenantUserInfo {
|
||||
b.partnerid,b.moduleid,b.categoryid as categoryid,b.subcategoryid as subcategoryid,
|
||||
b.applocationid,b.tenantname,b.address as tenantaddress,b.state as tenantstate,b.city as tenantcity,
|
||||
b.postcode as tenantpostcode,b.latitude as tenantlat,b.longitude as tenantlong,c.locationname AS applocation,
|
||||
c.latitude as applatitude,c.longitude as applongitude,c.radius as appradius, d.categoryname, e.locationname
|
||||
c.latitude as applatitude,c.longitude as applongitude,c.radius as appradius, d.categoryname, e.locationname,
|
||||
a.shiftid, concat(f.starttime, ' - ', f.endtime) as shiftname, a.status
|
||||
from app_users a
|
||||
LEFT JOIN tenants b ON a.tenantid=b.tenantid
|
||||
LEFT JOIN app_location c on c.applocationid=b.applocationid
|
||||
LEFT JOIN app_category d ON b.categoryid=d.categoryid
|
||||
LEFT JOIN tenantlocations e ON a.locationid=e.locationid
|
||||
LEFT JOIN ridershifts f ON a.shiftid = f.shiftid
|
||||
WHERE a.userid = ?
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user