...
|
...
|
@@ -155,6 +155,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con |
|
|
if v, ok := queryOptions["auditStatus"]; ok {
|
|
|
tx.Where("audit_status in (?)", v)
|
|
|
}
|
|
|
if v, ok := queryOptions["accountFrom"]; ok {
|
|
|
tx.Where("account_from in (?)", v)
|
|
|
}
|
|
|
|
|
|
// 列表查询条件
|
|
|
if v, ok := queryOptions["likeName"]; ok {
|
...
|
...
|
@@ -236,6 +239,41 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn |
|
|
return total, dms, nil
|
|
|
}
|
|
|
|
|
|
func (repository *UserRepository) FindCompanyPositions(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.User, error) {
|
|
|
var (
|
|
|
tx = conn.DB()
|
|
|
ms []*models.User
|
|
|
dms = make([]*domain.User, 0)
|
|
|
total int64
|
|
|
)
|
|
|
queryFunc := func() (interface{}, error) {
|
|
|
tx = tx.Model(&ms)
|
|
|
tx.Select("distinct position")
|
|
|
tx.Where("company_id = ?", companyId)
|
|
|
tx.Where("position <> ''")
|
|
|
tx.Where("audit_status in (?)", domain.UserAuditStatusPassed)
|
|
|
tx.Where("enable = ?", domain.UserEnable)
|
|
|
tx.Order("position asc")
|
|
|
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
|
|
|
return dms, tx.Error
|
|
|
}
|
|
|
return dms, nil
|
|
|
}
|
|
|
|
|
|
if _, err := repository.Query(queryFunc); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
|
|
|
for _, item := range ms {
|
|
|
if dm, err := repository.ModelToDomainModel(item); err != nil {
|
|
|
return 0, dms, err
|
|
|
} else {
|
|
|
dms = append(dms, dm)
|
|
|
}
|
|
|
}
|
|
|
return total, dms, nil
|
|
|
}
|
|
|
|
|
|
func (repository *UserRepository) ModelToDomainModel(from *models.User) (*domain.User, error) {
|
|
|
to := &domain.User{}
|
|
|
err := copier.Copy(to, from)
|
...
|
...
|
|