...
|
...
|
@@ -2,8 +2,11 @@ package dao |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
|
|
|
)
|
|
|
|
|
|
type CooperationModeDao struct {
|
...
|
...
|
@@ -46,6 +49,36 @@ func (dao *CooperationModeDao) CheckModeNumberAvailable(queryOptions map[string] |
|
|
return !ok, err
|
|
|
}
|
|
|
|
|
|
// UpdateCooperationModeSlice 更新多个共创模式
|
|
|
func (dao *CooperationModeDao) UpdateCooperationModeSlice(modeIds []int64, status int32) ([]*domain.CooperationMode, error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
_, err := tx.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"UPDATE cooperation_modes SET status=? WHERE cooperation_mode_id IN (?)",
|
|
|
status, pg.In(modeIds))
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
var cooperationModeModels []*models.CooperationMode
|
|
|
cooperationModes := make([]*domain.CooperationMode, 0)
|
|
|
query := tx.Model(&cooperationModeModels)
|
|
|
query.Where("cooperation_mode_id IN (?)", pg.In(modeIds))
|
|
|
query.Order("cooperation_mode_id DESC")
|
|
|
if _, err := query.SelectAndCount(); err != nil {
|
|
|
return cooperationModes, err
|
|
|
} else {
|
|
|
for _, cooperationModeModel := range cooperationModeModels {
|
|
|
if cooperationMode, err := transform.TransformToCooperationModeDomainModelFromPgModels(cooperationModeModel); err != nil {
|
|
|
return cooperationModes, err
|
|
|
} else {
|
|
|
cooperationModes = append(cooperationModes, cooperationMode)
|
|
|
}
|
|
|
}
|
|
|
return cooperationModes, nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewCooperationModeDao(transactionContext *pgTransaction.TransactionContext) (*CooperationModeDao, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|