refactor platform domain states and permissions
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
@@ -61,6 +63,9 @@ func UpdateUserAddress(ctx *gin.Context) {
|
||||
if err := tx.Where("identity = ?", ctx.Param("identity")).First(¤t).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if current.UserAccountID != userAccountID {
|
||||
return errors.New("address owner cannot be changed")
|
||||
}
|
||||
if request.IsDefault {
|
||||
if err := tx.Model(&models.UserAddress{}).
|
||||
Where("user_account_id = ? AND id <> ?", userAccountID, current.ID).
|
||||
@@ -137,5 +142,10 @@ func resolveServiceRelation(ctx *gin.Context, request serviceRelationRequest) (u
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return 0, 0, 0, 0, false
|
||||
}
|
||||
if gasBasicID == 0 && deliveryBasicID == 0 && staffAccountID == 0 ||
|
||||
!common.ValidateOrganizationIDs(gasBasicID, deliveryBasicID, staffAccountID) {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return 0, 0, 0, 0, false
|
||||
}
|
||||
return userAccountID, gasBasicID, deliveryBasicID, staffAccountID, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user