35 lines
602 B
Go
35 lines
602 B
Go
package dao
|
|
|
|
import (
|
|
"enterprise/common/model"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ExternalCorpUser struct {
|
|
}
|
|
|
|
func NewExternalCorpUser() *ExternalCorpUser {
|
|
return &ExternalCorpUser{}
|
|
}
|
|
|
|
func (d *ExternalCorpUser) TableName() string {
|
|
return "cp_user"
|
|
}
|
|
|
|
func (d *ExternalCorpUser) Get(owner string) (*model.ExternalCorpUser, error) {
|
|
orderTable := d.TableName()
|
|
tx := corpDB.Table(orderTable)
|
|
|
|
var o model.ExternalCorpUser
|
|
|
|
tx.Where("username = ?", owner)
|
|
tx = tx.First(&o)
|
|
if tx.Error == gorm.ErrRecordNotFound {
|
|
return nil, nil
|
|
}
|
|
if tx.Error != nil {
|
|
return nil, tx.Error
|
|
}
|
|
return &o, nil
|
|
}
|