增加气站合同附件受控上传与预览

This commit is contained in:
czl231
2026-08-18 21:52:00 +08:00
parent 06b6f0ee62
commit 61a61f916b
9 changed files with 262 additions and 9 deletions

View File

@@ -73,6 +73,33 @@ func GetGasorderContract(ctx *gin.Context) {
}
}
// UploadGasorderContractAttachment 为当前气站账号提供受控 PDF 临时上传。
func UploadGasorderContractAttachment(ctx *gin.Context) {
if _, ok := currentGas(ctx); !ok {
return
}
platformgasorder.UploadGasorderContractAttachment(ctx)
}
// CleanupGasorderContractAttachment 清理当前气站账号尚未绑定的临时附件。
func CleanupGasorderContractAttachment(ctx *gin.Context) {
if _, ok := currentGas(ctx); !ok {
return
}
platformgasorder.CleanupGasorderContractAttachment(ctx)
}
// ServeGasorderContractAttachment 仅预览当前气站合同范围内的正式附件。
func ServeGasorderContractAttachment(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
if _, ok := scopedContract(ctx, ctx.Param("identity"), station.ID); ok {
platformgasorder.ServeGasorderContractAttachment(ctx)
}
}
func CreateGasorderContract(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {

View File

@@ -65,8 +65,11 @@ func registerGasBusinessRoutes(group *gin.RouterGroup) {
contract := group.Group("/gasorder_contract")
contract.GET("", gaslogic.ListGasorderContract)
contract.POST("", gaslogic.CreateGasorderContract)
contract.POST("/attachment/upload", gaslogic.UploadGasorderContractAttachment)
contract.POST("/attachment/cleanup", gaslogic.CleanupGasorderContractAttachment)
contract.GET("/:identity", gaslogic.GetGasorderContract)
contract.PUT("/:identity", gaslogic.UpdateGasorderContract)
contract.GET("/:identity/attachment", gaslogic.ServeGasorderContractAttachment)
contract.POST("/:identity/activate", gaslogic.ActivateGasorderContract)
contract.POST("/:identity/renew", gaslogic.RenewGasorderContract)
contract.POST("/:identity/terminate", gaslogic.TerminateGasorderContract)

View File

@@ -100,3 +100,23 @@ func TestGasAvatarRoutes(t *testing.T) {
}
}
}
// TestGasContractAttachmentRoutes 验证合同附件通过气站鉴权域提供专用接口。
func TestGasContractAttachmentRoutes(t *testing.T) {
gin.SetMode(gin.TestMode)
engine := gin.New()
RegisterGas("heqi", engine)
routes := map[string]bool{}
for _, route := range engine.Routes() {
routes[route.Method+" "+route.Path] = true
}
for _, path := range []string{
"POST /heqi/gas/v1/gasorder_contract/attachment/upload",
"POST /heqi/gas/v1/gasorder_contract/attachment/cleanup",
"GET /heqi/gas/v1/gasorder_contract/:identity/attachment",
} {
if !routes[path] {
t.Fatalf("missing gas contract attachment route %s", path)
}
}
}