feat: 增加了 openapi spec
diff --git a/payapi-spec/build.gradle b/payapi-spec/build.gradle
new file mode 100644
index 0000000..c4bc7c9
--- /dev/null
+++ b/payapi-spec/build.gradle
@@ -0,0 +1,54 @@
+plugins {
+ id 'java-library'
+ id 'org.springframework.boot'
+ id "org.openapi.generator"
+}
+
+apply plugin: 'io.spring.dependency-management'
+
+
+dependencies {
+ implementation "org.springframework.boot:spring-boot-autoconfigure"
+}
+
+bootJar {
+ enabled = false
+}
+
+openApiGenerate {
+ generatorName = "spring"
+ inputSpec = "$projectDir/payapi-spec.yaml".toString()
+ outputDir = "$buildDir/generated".toString()
+ apiPackage = "com.supwisdom.dlpay.api"
+ invokerPackage = "com.supwisdom.dlpay.payapi"
+ modelPackage = "com.supwisdom.dlpay.payapi.model"
+
+ configOptions = [
+ dateLibrary : "java8",
+ artifactDescription : "PayAPI API",
+ developerName : "Supwisdom",
+ developerEmail : "admin@supwisdom.com",
+ developerOrganization : "Supwisdom Tech Inc.",
+ developerOrganizationUrl: "http://www.supwisdom.com",
+ java8 : "true",
+ interfaceOnly : "true",
+ generateAliasAsModel : "false"
+ ]
+}
+
+task copyApiSrc(type: Copy) {
+ from("$buildDir/generated/src/main/java/com/supwisdom/dlpay/api") {
+ include "**/*.java"
+ }
+ into "$rootProject.projectDir/payapi/src/main/java/com/supwisdom/dlpay/api"
+
+
+}
+task copyModelSrc(type: Copy) {
+ from("$buildDir/generated/src/main/java/com/supwisdom/dlpay/payapi/model") {
+ include "**/*.java"
+ }
+ into "$rootProject.projectDir/payapi-common/src/main/java/com/supwisdom/dlpay/payapi/model"
+}
+
+//copySrc.dependsOn openApiGenerate
\ No newline at end of file
diff --git a/payapi-spec/consumeapi.yaml b/payapi-spec/consumeapi.yaml
new file mode 100644
index 0000000..4d62dd5
--- /dev/null
+++ b/payapi-spec/consumeapi.yaml
@@ -0,0 +1,188 @@
+components:
+ schemas:
+ ErrorResponse:
+ type: object
+ title: 请求错误
+ required:
+ - message
+ properties:
+ code:
+ type: string
+ title: 错误码
+ message:
+ type: string
+ title: 错误信息
+ QrcodePayInitRequest:
+ type: object
+ title: QrCode请求初始化
+ required:
+ - qrcode
+ - transDate
+ - transTime
+ - shopaccno
+ - billno
+ properties:
+ qrcode:
+ type: string
+ title: QrCode
+ transDate:
+ $ref: 'definitions.yaml#/components/schemas/TransDate'
+ transTime:
+ $ref: 'definitions.yaml#/components/schemas/TransTime'
+ shopaccno:
+ $ref: 'definitions.yaml#/components/schemas/ShopAccNo'
+ billno:
+ $ref: 'definitions.yaml#/components/schemas/Refno'
+ qrcodeFormat:
+ $ref: 'definitions.yaml#/components/schemas/QrcodeFormat'
+
+ QrcodePayInitResponse:
+ type: object
+ title: QrCode请求初始化应答
+ properties:
+ anonymous:
+ title: 是否匿名用户
+ type: boolean
+ userid:
+ title: 用户ID(非匿名)
+ type: string
+ username:
+ title: 用户名(非匿名)
+ type: string
+ sourcetype:
+ title: 支付方式
+ type: string
+ QrcodePayConfirmRequest:
+ type: object
+ title: Qrcode消费确认请求
+ properties:
+ billno:
+ $ref: 'definitions.yaml#/components/schemas/Refno'
+ shopaccno:
+ $ref: 'definitions.yaml#/components/schemas/ShopAccNo'
+ transDate:
+ $ref: 'definitions.yaml#/components/schemas/TransDate'
+ transTime:
+ $ref: 'definitions.yaml#/components/schemas/TransTime'
+ dlttype:
+ type: string
+ title: 交易类型
+ amount:
+ type: integer
+ format: int32
+ title: 交易金额
+ userid:
+ type: string
+ title: 用户ID(非匿名)
+ anonymous:
+ type: boolean
+ title: 是否匿名
+ qrcode:
+ type: string
+ title: QrCode
+ qrcodeFormat:
+ $ref: 'definitions.yaml#/components/schemas/QrcodeFormat'
+ QrcodePayConfirmResponse:
+ type: object
+ title: QrCode消费确认返回
+ properties:
+ refno:
+ $ref: 'definitions.yaml#/components/schemas/Refno'
+ hostDate:
+ $ref: 'definitions.yaml#/components/schemas/TransDate'
+ hostTime:
+ $ref: 'definitions.yaml#/components/schemas/TransTime'
+ description:
+ type: string
+ title: 交易描述
+ result:
+ title: 交易结果
+ type: string
+ enum:
+ - success
+ - require_query
+ - already_success
+ - failed
+
+ paths:
+ qrcodePayInit:
+ parameters:
+ - $ref: definitions.yaml#/components/headers/TenantId
+ post:
+ operationId: qrcodePayInit
+ tags:
+ - pos
+ requestBody:
+ description: QrCode 初始化
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/QrcodePayInitRequest'
+
+ responses:
+ '200':
+ description: 初始化成功
+ content:
+ application/json:
+ $ref: '#/components/schemas/QrcodePayInitResponse'
+ 'default':
+ description: 请求错误
+ content:
+ application/json:
+ $ref: '#/components/schemas/ErrorResponse'
+ qrcodePayConfirm:
+ parameters:
+ - $ref: definitions.yaml#/components/headers/TenantId
+ post:
+ operationId: qrcodePayConfirm
+ tags:
+ - pos
+ requestBody:
+ description: Qrcode确认
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/QrcodePayConfirmRequest'
+ responses:
+ '200':
+ description: 交易成功
+ content:
+ application/json:
+ $ref: '#/components/schemas/QrcodePayConfirmResponse'
+ '409':
+ description: 交易正忙,稍后重试
+ content:
+ application/json:
+ $ref: '#/components/schemas/ErrorResponse'
+ 'default':
+ description: 交易失败
+ content:
+ application/json:
+ $ref: '#/components/schemas/ErrorResponse'
+ qrcodePayQuery:
+ parameters:
+ - $ref: 'definitions.yaml#/components/headers/TenantId'
+ - name: refno
+ in: path
+ description: 系统交易参考号
+ required: true
+ schema:
+ type: string
+ title: 系统交易参考号
+ get:
+ description: 根据系统交易参考号查询流水状态
+ tags:
+ - pos
+ operationId: qrcodePayQuery
+ responses:
+ '200':
+ description: 查询成功
+ content:
+ application/json:
+ $ref: '#/components/schemas/QrcodePayConfirmResponse'
+ 'default':
+ description: 查询失败
+ content:
+ application/json:
+ $ref: '#/components/schemas/ErrorResponse'
+
diff --git a/payapi-spec/definitions.yaml b/payapi-spec/definitions.yaml
new file mode 100644
index 0000000..fea5324
--- /dev/null
+++ b/payapi-spec/definitions.yaml
@@ -0,0 +1,40 @@
+components:
+ headers:
+ TenantId:
+ name: X-Tenant-Id
+ in: header
+ description: 租户ID
+ required: true
+ schema:
+ type: string
+
+
+ schemas:
+ TransDate:
+ type: string
+ title: 交易日期
+ minLength: 8
+ maxLength: 8
+ pattern: '[0-9]*'
+ TransTime:
+ type: string
+ title: 交易时间
+ minLength: 6
+ maxLength: 6
+ pattern: '[0-9]*'
+ ShopAccNo:
+ type: string
+ title: 商户号
+ pattern: '[0-9]*'
+ Refno:
+ type: string
+ title: 交易号
+ minLength: 16
+ pattern: '[0-9]*'
+ QrcodeFormat:
+ type: string
+ title: Qrcode格式
+ enum:
+ - plain
+ - base64
+ - hex
diff --git a/payapi-spec/payapi-spec.yaml b/payapi-spec/payapi-spec.yaml
new file mode 100644
index 0000000..1b432bc
--- /dev/null
+++ b/payapi-spec/payapi-spec.yaml
@@ -0,0 +1,13 @@
+openapi: '3.0.2'
+info:
+ title: API Title
+ version: '1.0'
+servers:
+ - url: https://api.server.test/api
+paths:
+ /consume/qrcode/init:
+ $ref: consumeapi.yaml#/components/paths/qrcodePayInit
+ /consume/qrcode/confirm:
+ $ref: consumeapi.yaml#/components/paths/qrcodePayConfirm
+ /consume/qrcode/query/{refno}:
+ $ref: consumeapi.yaml#/components/paths/qrcodePayQuery