Upstream sync
This commit is contained in:
@@ -24,6 +24,11 @@ func (c *organizationRepo) getProfileQuery(user entity.User) (query string, wher
|
||||
if len(user.Profiles) > 0 {
|
||||
for _, p := range user.Profiles {
|
||||
switch p.Key {
|
||||
case "VIRPT":
|
||||
switch p.Organization.Type.Key {
|
||||
case "provider":
|
||||
return
|
||||
}
|
||||
case "AD", "BCBSIAD", "BDCAD", "PLANAD":
|
||||
switch p.Organization.Type.Key {
|
||||
case "techsupport", "bcbsi", "bcbsa":
|
||||
@@ -44,7 +49,7 @@ func (c *organizationRepo) getProfileQuery(user entity.User) (query string, wher
|
||||
where = fmt.Sprintf(` AND (a.organization_uuid = '%s' OR f.organization_uuid = '%s') `, p.Organization.UUID, p.Organization.UUID)
|
||||
return
|
||||
}
|
||||
case "SP", "SPT", "VIRPT":
|
||||
case "SP", "SPT":
|
||||
switch p.Organization.Type.Key {
|
||||
case "techsupport", "bcbsi", "bcbsa":
|
||||
return
|
||||
@@ -341,7 +346,6 @@ func (c *organizationRepo) GetByUUID(organizationUUID string, user entity.User)
|
||||
}
|
||||
|
||||
query = c.getQuery() + query + " WHERE a.organization_uuid = ? " + where
|
||||
|
||||
return c.parseEntity(c.conn.QueryRow(query, organizationUUID))
|
||||
}
|
||||
|
||||
@@ -446,13 +450,16 @@ func (c *organizationRepo) SetOrganizationAddress(address entity.OrganizationAdd
|
||||
return entity.OrganizationAddress{}, errors.NewNotFoundError()
|
||||
}
|
||||
|
||||
organization, err := c.GetByUUID(address.Organization.UUID, user)
|
||||
if err != nil {
|
||||
return entity.OrganizationAddress{}, err
|
||||
if address.Organization.ID == 0 {
|
||||
organization, err := c.GetByUUID(address.Organization.UUID, user)
|
||||
if err != nil {
|
||||
return entity.OrganizationAddress{}, err
|
||||
}
|
||||
address.Organization = &organization
|
||||
}
|
||||
|
||||
UUID, _ := uuid.NewV4()
|
||||
result, err := c.conn.Exec(query, UUID.String(), organization.ID, address.InternalID, address.Name, address.Address, address.Description, address.Latitude, address.Longitude, address.CreatedUser.ID, address.UpdatedUser.ID)
|
||||
result, err := c.conn.Exec(query, UUID.String(), address.Organization.ID, address.InternalID, address.Name, address.Address, address.Description, address.Latitude, address.Longitude, address.CreatedUser.ID, address.UpdatedUser.ID)
|
||||
if err != nil {
|
||||
return entity.OrganizationAddress{}, err
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ func (c *userRepo) createUser(user entity.User) (int64, string, error) {
|
||||
|
||||
func (c *userRepo) RemoveAddress(addressUUID string) error {
|
||||
const (
|
||||
query = "DELETE FROM tab_address WHERE address_uuid = ?;"
|
||||
query = "UPDATE tab_address SET active = 0 WHERE address_uuid = ?;"
|
||||
)
|
||||
|
||||
_, err := c.conn.Exec(query, addressUUID)
|
||||
|
||||
@@ -190,12 +190,13 @@ func (c *visitRepo) Create(visit entity.Visit) (entity.Visit, error) {
|
||||
|
||||
row := c.conn.QueryRow(statusQuery, retVal.Status.Key, retVal.User.UUID, retVal.CreatedUser.UUID, retVal.TripType.Key)
|
||||
if err := row.Scan(&retVal.Status.ID, &retVal.Status.Key, &retVal.Status.Value, &retVal.User.ID, &retVal.User.Name, &retVal.CreatedUser.ID, &retVal.CreatedUser.Name, &retVal.TripType.ID, &retVal.TripType.Key, &retVal.TripType.Value); err != nil {
|
||||
fmt.Println("Error to get base data: ", err.Error())
|
||||
fmt.Println("data.Visit: Error getting base data: ", err.Error())
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
results, err := c.conn.Exec(query, retVal.UUID, retVal.Status.ID, retVal.User.ID, retVal.VisitDatetime, retVal.PickupDatetime, retVal.Notes, retVal.CreatedUser.ID, toNullInt64(retVal.VisitDuration), retVal.ExternalID, returnDate, retVal.TripType.ID, retVal.Pickup.ID, retVal.PickupAddressID, retVal.DestinationAddressID, retVal.Provider.ProviderID)
|
||||
if err != nil {
|
||||
fmt.Println("data.Visit: Error inserting visit: ", err.Error())
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user