stores login fix
This commit is contained in:
@@ -30,7 +30,7 @@ type TenantRepository interface {
|
||||
CheckTenantByNo(cno string) int
|
||||
CreateTenantUser(data models.Tenants) (bool, error)
|
||||
GetUserByNo(cno string) models.UserInfo
|
||||
GetTenantByID(tid int, locationid int) (models.Tenantinfo, error)
|
||||
GetTenantByID(tid int, locationid int, userid int) (models.Tenantinfo, error)
|
||||
GetTenantByKeyword(keyword string) ([]models.TenantSearch, error)
|
||||
}
|
||||
|
||||
@@ -135,16 +135,15 @@ func (r *tenantRepository) GetAllTenants(pageno, pagesize, aid int, status, tena
|
||||
func (r *tenantRepository) GetTenantLocations(tid int) ([]models.Tenantlocations, error) {
|
||||
var data []models.Tenantlocations
|
||||
|
||||
q1 := `SELECT a.*, b.roleid FROM tenantlocations a
|
||||
LEFT JOIN app_users b ON a.locationid = b.locationid
|
||||
AND a.tenantid = b.tenantid
|
||||
WHERE a.tenantid = ?`
|
||||
q1 := `SELECT * FROM tenantlocations WHERE tenantid = ?`
|
||||
|
||||
if err := r.db.Raw(q1, tid).Find(&data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
print(q1)
|
||||
for i := range data {
|
||||
data[i].Status = strings.ToLower(data[i].Status)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
@@ -651,9 +650,17 @@ func (r *tenantRepository) GetUserByNo(cno string) models.UserInfo {
|
||||
return user
|
||||
}
|
||||
|
||||
func (r *tenantRepository) GetTenantByID(tid int, locationid int) (models.Tenantinfo, error) {
|
||||
func (r *tenantRepository) GetTenantByID(tid int, locationid int, userid int) (models.Tenantinfo, error) {
|
||||
var data models.Tenantinfo
|
||||
|
||||
if locationid == 0 && userid > 0 {
|
||||
var userLocationID int
|
||||
err := r.db.Table("app_users").Select("locationid").Where("userid = ?", userid).Row().Scan(&userLocationID)
|
||||
if err == nil && userLocationID > 0 {
|
||||
locationid = userLocationID
|
||||
}
|
||||
}
|
||||
|
||||
q1 := `
|
||||
SELECT a.*,b.categoryname,c.locationname AS applocation, d.allocationid AS allocationmode,e.typename AS allocationtype,e.mapid AS allocationid,f.locationid,
|
||||
f.locationname, f.contactno as locationcontact
|
||||
@@ -678,6 +685,8 @@ func (r *tenantRepository) GetTenantByID(tid int, locationid int) (models.Tenant
|
||||
return data, err
|
||||
}
|
||||
|
||||
data.Status = strings.ToLower(data.Status)
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user