Files
backend-go/docs/swagger.json

1149 lines
37 KiB
JSON

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