|
|
package repository
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
|
...
|
...
|
@@ -86,15 +87,24 @@ func (reponsitory CompanyRepository) Edit(m *domain.Company) error { |
|
|
|
|
|
func (reponsitory CompanyRepository) FindOne(queryOptions domain.CompanyFindOneOptions) (domain.Company, error) {
|
|
|
var (
|
|
|
err error
|
|
|
tx = reponsitory.transactionContext.PgTx
|
|
|
m models.Company
|
|
|
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
|
...
|
...
|
|