feat: implement license platform business flows and delivery tooling
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled

Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
2026-10-09 15:33:22 +08:00
parent 3ab651d3a8
commit 54c318c615
142 changed files with 11105 additions and 178 deletions

View File

@@ -0,0 +1,42 @@
package httpapi
import (
"github.com/gin-gonic/gin"
"strconv"
)
func (a *BusinessAPI) listReleases(c *gin.Context) {
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil || id == 0 {
apiError(c, 400, "invalid_request", "产品无效")
return
}
p, size := page(c)
var total int
if err = a.db.QueryRowContext(c, "SELECT COUNT(*) FROM product_releases WHERE product_id=?", id).Scan(&total); err != nil {
apiError(c, 500, "internal_error", "加载失败")
return
}
rows, err := a.db.QueryContext(c, "SELECT id,version,sha256,size_bytes,published FROM product_releases WHERE product_id=? ORDER BY id DESC LIMIT ? OFFSET ?", id, size, (p-1)*size)
if err != nil {
apiError(c, 500, "internal_error", "加载失败")
return
}
defer rows.Close()
data := []gin.H{}
for rows.Next() {
var rid, n uint64
var version, digest string
var published bool
if err = rows.Scan(&rid, &version, &digest, &n, &published); err != nil {
apiError(c, 500, "internal_error", "加载失败")
return
}
data = append(data, gin.H{"id": rid, "version": version, "sha256": digest, "size_bytes": n, "published": published})
}
if rows.Err() != nil {
apiError(c, 500, "internal_error", "加载失败")
return
}
c.JSON(200, gin.H{"data": data, "meta": gin.H{"total": total, "page": p, "page_size": size}})
}