-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature. update organization admin_id, when organization created
- Loading branch information
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package user | ||
|
||
import ( | ||
"time" | ||
|
||
"gorm.io/gorm" | ||
|
||
"github.com/gofrs/uuid" | ||
) | ||
|
||
type User struct { | ||
ID uuid.UUID `gorm:"primarykey;type:uuid" json:"id"` | ||
AccountId string `json:"accountId"` | ||
Password string `gorm:"-:all" json:"password"` | ||
Name string `json:"name"` | ||
Token string `json:"token"` | ||
RoleId string | ||
OrganizationId string | ||
Creator string `json:"creator"` | ||
CreatedAt time.Time `json:"createdAt"` | ||
UpdatedAt time.Time `json:"updatedAt"` | ||
PasswordUpdatedAt time.Time `json:"passwordUpdatedAt"` | ||
PasswordExpired bool `json:"passwordExpired"` | ||
Email string `json:"email"` | ||
Department string `json:"department"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type UserAccessor struct { | ||
db *gorm.DB | ||
} | ||
|
||
func New(db *gorm.DB) *UserAccessor { | ||
return &UserAccessor{ | ||
db: db, | ||
} | ||
} | ||
|
||
func (x *UserAccessor) GetDb() *gorm.DB { | ||
return x.db | ||
} | ||
|
||
func (x *UserAccessor) GetOrganizationAdmin(organizationId string) (out User, err error) { | ||
res := x.db. | ||
Where("organization_id = ?", organizationId). | ||
First(&out) | ||
|
||
if res.Error != nil { | ||
return out, res.Error | ||
} | ||
return | ||
} |