Files
backend-go/docs/swagger.yaml

743 lines
18 KiB
YAML

basePath: /api
definitions:
models.BaseResponse:
properties:
message:
type: string
type: object
models.ChangePasswordDTO:
properties:
currentPassword:
type: string
newPassword:
minLength: 6
type: string
required:
- currentPassword
- newPassword
type: object
models.Company:
properties:
companyName:
type: string
createdAt:
type: string
id:
type: integer
isActive:
type: boolean
updatedAt:
type: string
type: object
models.CompanyDataRequest:
properties:
companyName:
type: string
required:
- companyName
type: object
models.CompanyResponse:
properties:
company:
$ref: '#/definitions/models.Company'
message:
type: string
type: object
models.CompanyUpdateRequest:
properties:
companyName:
type: string
isActive:
type: boolean
type: object
models.DataResponse:
properties:
data: {}
message:
type: string
type: object
models.ErrorResponse:
properties:
error:
type: string
message:
type: string
type: object
models.GenerateSerialDTO:
properties:
companyName:
type: string
quantity:
maximum: 1000
minimum: 1
type: integer
validDays:
maximum: 3650
minimum: 1
type: integer
required:
- companyName
type: object
models.GenerateWithPrefixDTO:
properties:
companyName:
type: string
quantity:
maximum: 1000
minimum: 1
type: integer
serialPrefix:
type: string
validDays:
maximum: 3650
minimum: 1
type: integer
required:
- companyName
type: object
models.LoginDTO:
properties:
password:
minLength: 6
type: string
username:
type: string
required:
- password
- username
type: object
models.LoginResponse:
properties:
accessToken:
type: string
message:
type: string
user:
$ref: '#/definitions/models.UserDTO'
type: object
models.Pagination:
properties:
limit:
type: integer
page:
type: integer
total:
type: integer
totalPages:
type: integer
type: object
models.PaginationResponse:
properties:
data: {}
message:
type: string
pagination:
$ref: '#/definitions/models.Pagination'
type: object
models.QRCodeDTO:
properties:
baseUrl:
type: string
type: object
models.QRCodeResponse:
properties:
message:
type: string
qrCodeData:
type: string
queryUrl:
type: string
type: object
models.UpdateProfileDTO:
properties:
email:
type: string
name:
type: string
required:
- email
- name
type: object
models.UpdateSerialDTO:
properties:
companyName:
type: string
isActive:
type: boolean
validUntil:
type: string
type: object
models.UserDTO:
properties:
createdAt:
type: string
email:
type: string
id:
type: integer
name:
type: string
role:
type: string
username:
type: string
type: object
host: localhost:8080
info:
contact:
email: support@swagger.io
name: API Support
url: http://www.swagger.io/support
description: 防伪溯源系统 API 文档
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Trace System API
version: "1.0"
paths:
/auth/change-password:
post:
consumes:
- application/json
description: 修改当前登录用户的密码
parameters:
- description: 密码修改数据
in: body
name: passwordData
required: true
schema:
$ref: '#/definitions/models.ChangePasswordDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.BaseResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 修改密码
tags:
- 认证
/auth/login:
post:
consumes:
- application/json
description: 验证用户身份并返回 JWT 令牌
parameters:
- description: 登录数据
in: body
name: loginData
required: true
schema:
$ref: '#/definitions/models.LoginDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.LoginResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: 用户登录
tags:
- 认证
/auth/profile:
get:
description: 获取当前登录用户的个人信息
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 获取用户信息
tags:
- 认证
put:
consumes:
- application/json
description: 更新当前登录用户的个人信息
parameters:
- description: 用户信息更新数据
in: body
name: profileData
required: true
schema:
$ref: '#/definitions/models.UpdateProfileDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 更新用户信息
tags:
- 认证
/companies:
get:
description: 获取企业列表,支持分页和搜索
parameters:
- description: 页码
in: query
name: page
type: integer
- description: 每页数量
in: query
name: limit
type: integer
- description: 搜索关键词
in: query
name: search
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.PaginationResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 获取企业列表
tags:
- 企业管理
post:
consumes:
- application/json
description: 创建新的企业
parameters:
- description: 企业数据
in: body
name: companyData
required: true
schema:
$ref: '#/definitions/models.CompanyDataRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/models.CompanyResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"409":
description: Conflict
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 创建企业
tags:
- 企业管理
/companies/{companyName}:
delete:
description: 删除企业
parameters:
- description: 企业名称
in: path
name: companyName
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.BaseResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 删除企业
tags:
- 企业管理
put:
consumes:
- application/json
description: 更新企业信息
parameters:
- description: 企业名称
in: path
name: companyName
required: true
type: string
- description: 企业数据
in: body
name: companyData
required: true
schema:
$ref: '#/definitions/models.CompanyUpdateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.CompanyResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"409":
description: Conflict
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 更新企业信息
tags:
- 企业管理
/serials:
get:
description: 获取序列号列表,支持分页和搜索
parameters:
- description: 页码
in: query
name: page
type: integer
- description: ' '
in: query
name: limit
type: integer
- description: 搜索关键词
in: query
name: search
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.PaginationResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 获取序列号列表
tags:
- 序列号管理
/serials/{serialNumber}:
put:
consumes:
- application/json
description: 更新指定序列号的信息
parameters:
- description: 序列号
in: path
name: serialNumber
required: true
type: string
- description: 更新数据
in: body
name: updateData
required: true
schema:
$ref: '#/definitions/models.UpdateSerialDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 更新序列号信息
tags:
- 序列号管理
/serials/{serialNumber}/qrcode:
post:
consumes:
- application/json
description: 为指定序列号生成查询二维码
parameters:
- description: 序列号
in: path
name: serialNumber
required: true
type: string
- description: 二维码数据
in: body
name: qrCodeData
schema:
$ref: '#/definitions/models.QRCodeDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.QRCodeResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 生成二维码
tags:
- 序列号管理
/serials/{serialNumber}/query:
get:
description: 查询指定序列号的详细信息
parameters:
- description: 序列号
in: path
name: serialNumber
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: 查询序列号信息
tags:
- 序列号查询
/serials/{serialNumber}/revoke:
post:
description: 吊销指定序列号
parameters:
- description: 序列号
in: path
name: serialNumber
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.BaseResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 吊销序列号
tags:
- 序列号管理
/serials/generate:
post:
consumes:
- application/json
description: 生成指定数量的序列号
parameters:
- description: 生成数据
in: body
name: generateData
required: true
schema:
$ref: '#/definitions/models.GenerateSerialDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 生成序列号
tags:
- 序列号管理
/serials/generate-with-prefix:
post:
consumes:
- application/json
description: 生成带有指定前缀的序列号
parameters:
- description: 生成数据
in: body
name: generateData
required: true
schema:
$ref: '#/definitions/models.GenerateWithPrefixDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DataResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/models.ErrorResponse'
security:
- BearerAuth: []
summary: 带前缀生成序列号
tags:
- 序列号管理
securityDefinitions:
BearerAuth:
description: Bearer token 认证
in: header
name: Authorization
type: apiKey
swagger: "2.0"