fix platform authorization and workflow integrity
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package delivery
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type accountRequest struct {
|
||||
@@ -23,8 +26,23 @@ type accountUpdateRequest struct {
|
||||
DeliveryBasicIdentity string `json:"delivery_basic_identity"`
|
||||
}
|
||||
|
||||
func ListDeliveryAccount(ctx *gin.Context) { common.ListPage[models.DeliveryAccount](ctx) }
|
||||
func GetDeliveryAccount(ctx *gin.Context) { common.GetByIdentity[models.DeliveryAccount](ctx) }
|
||||
func ListDeliveryAccount(ctx *gin.Context) {
|
||||
identities := strings.Split(strings.TrimSpace(ctx.Query("delivery_basic_identities")), ",")
|
||||
if len(identities) == 1 && identities[0] == "" {
|
||||
identities = nil
|
||||
}
|
||||
if len(identities) > 100 {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
common.ListPageFiltered[models.DeliveryAccount](ctx, func(query *gorm.DB) *gorm.DB {
|
||||
if len(identities) == 0 {
|
||||
return query
|
||||
}
|
||||
return query.Where("delivery_basic_id IN (SELECT id FROM delivery_basic WHERE identity IN ? AND status <> ?)", identities, common.StatusArchived)
|
||||
})
|
||||
}
|
||||
func GetDeliveryAccount(ctx *gin.Context) { common.GetByIdentity[models.DeliveryAccount](ctx) }
|
||||
|
||||
func CreateDeliveryAccount(ctx *gin.Context) {
|
||||
var request accountRequest
|
||||
|
||||
Reference in New Issue
Block a user