All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m4s
27 lines
602 B
Go
27 lines
602 B
Go
package exporter
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
|
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
|
)
|
|
|
|
func applyShopScopeForTask(query *gorm.DB, task *model.ExportTask) *gorm.DB {
|
|
if task == nil {
|
|
return query.Where("1 = 0")
|
|
}
|
|
|
|
switch task.CreatorUserType {
|
|
case constants.UserTypeSuperAdmin, constants.UserTypePlatform:
|
|
return query
|
|
case constants.UserTypeAgent:
|
|
if len(task.ScopeShopIDs) == 0 {
|
|
return query.Where("1 = 0")
|
|
}
|
|
return query.Where("shop_id IN ?", []uint(task.ScopeShopIDs))
|
|
default:
|
|
return query.Where("1 = 0")
|
|
}
|
|
}
|