新增配送点资料只读卡片

This commit is contained in:
czl231
2026-08-22 19:49:28 +08:00
parent 79749685ee
commit da0185d1aa
9 changed files with 401 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package delivery
import (
"net/url"
"reflect"
"time"
"git.apinb.com/bsm-sdk/core/infra"
"git.apinb.com/heqiapp/platforms/backend/api/internal/config"
@@ -13,6 +14,21 @@ import (
"gorm.io/gorm"
)
// deliveryProfileView 表示配送点管理员可查看的本点只读资料。
type deliveryProfileView struct {
ID uint64 `json:"id"`
Identity string `json:"identity"`
DeliveryCode string `json:"delivery_code"`
Name string `json:"name"`
Principal string `json:"principal"`
Address string `json:"address"`
GasBasicIdentity string `json:"gas_basic_identity"`
GasBasicName string `json:"gas_basic_name"`
Status int `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func currentScope(ctx *gin.Context) (models.DeliveryBasic, models.GasBasic, bool) {
_, point, station, ok := CurrentDeliveryAccount(ctx)
return point, station, ok
@@ -40,12 +56,33 @@ func InvitationQRCode(ctx *gin.Context) {
infra.Response.Success(ctx, gin.H{"register_url": registerURL.String()})
}
// ListProfile 返回 JWT 数据范围内唯一配送点的只读资料。
func ListProfile(ctx *gin.Context) {
_, point, _, ok := CurrentDeliveryAccount(ctx)
_, point, station, ok := CurrentDeliveryAccount(ctx)
if !ok {
return
}
respondList(ctx, []models.DeliveryBasic{point}, 1)
infra.Response.Success(ctx, gin.H{
"total": 1,
"list": []deliveryProfileView{buildDeliveryProfileView(point, station)},
})
}
// buildDeliveryProfileView 组合配送点与所属气站的公开展示字段。
func buildDeliveryProfileView(point models.DeliveryBasic, station models.GasBasic) deliveryProfileView {
return deliveryProfileView{
ID: point.ID,
Identity: point.Identity,
DeliveryCode: point.DeliveryCode,
Name: point.Name,
Principal: point.Principal,
Address: point.Address,
GasBasicIdentity: station.Identity,
GasBasicName: station.Name,
Status: point.Status,
CreatedAt: point.CreatedAt,
UpdatedAt: point.UpdatedAt,
}
}
func respondList(ctx *gin.Context, list any, total int64) {