- api/common/v1 → api/open/v1,路由前缀 /api/common/v1 → /api/open/v1
- 契约层按子功能拆目录:api/open/v1/tools/{uuid,md5,random,time,ip}/index.go
- 控制器同步拆文件:internal/controller/open/{uuid,md5,random,time,ip}.go
- 命名规则(open 优于 common)与 tools 目录规则记入 AGENTS.md
- 冒烟测试:旧路由 404,新路由 5 端点全部通过
17 lines
433 B
Go
17 lines
433 B
Go
package open
|
|
|
|
import (
|
|
"context"
|
|
|
|
uuidapi "service.xpcool.com/api/open/v1/tools/uuid"
|
|
"service.xpcool.com/common/tools/uuid"
|
|
)
|
|
|
|
// UUID generates a unique ID (32-char by default, 8-char when short=true).
|
|
func (c *Controller) UUID(ctx context.Context, req *uuidapi.UUIDReq) (res *uuidapi.UUIDRes, err error) {
|
|
if req.Short {
|
|
return &uuidapi.UUIDRes{UUID: uuid.Short(8)}, nil
|
|
}
|
|
return &uuidapi.UUIDRes{UUID: uuid.New()}, nil
|
|
}
|