|
|
package repository
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
|
...
|
...
|
@@ -89,12 +90,21 @@ func (reponsitory CompanyRepository) FindOne(queryOptions domain.CompanyFindOneO |
|
|
err error
|
|
|
tx = reponsitory.transactionContext.PgTx
|
|
|
m models.Company
|
|
|
hasCondition bool
|
|
|
)
|
|
|
|
|
|
query := tx.Model(&m)
|
|
|
if queryOptions.Id > 0 {
|
|
|
hasCondition = true
|
|
|
query = query.Where("id=?", queryOptions.Id)
|
|
|
}
|
|
|
if queryOptions.AdminCompanyId > 0 {
|
|
|
hasCondition = true
|
|
|
query = query.Where("admin_company_id=?", queryOptions.Id)
|
|
|
}
|
|
|
if !hasCondition {
|
|
|
return domain.Company{}, errors.New("findOne 必须要有查询条件")
|
|
|
}
|
|
|
err = query.First()
|
|
|
if err != nil {
|
|
|
return domain.Company{}, err
|
...
|
...
|
|