暂存提交
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent><groupId>com.baiyue.firstleg</groupId><artifactId>baiyue-firstleg-platform</artifactId><version>1.0.0-SNAPSHOT</version><relativePath>../pom.xml</relativePath></parent>
|
||||
<artifactId>print-service</artifactId>
|
||||
<dependencies>
|
||||
<dependency><groupId>com.baiyue.shared</groupId><artifactId>baiyue-common-audit</artifactId><version>${project.version}</version></dependency>
|
||||
<dependency><groupId>com.baiyue.shared</groupId><artifactId>baiyue-common-openapi</artifactId><version>${project.version}</version></dependency>
|
||||
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId></dependency>
|
||||
<dependency><groupId>com.baiyue.shared</groupId><artifactId>baiyue-common-web</artifactId><version>${project.version}</version></dependency>
|
||||
<dependency><groupId>com.baiyue.shared</groupId><artifactId>baiyue-common-security</artifactId><version>${project.version}</version></dependency>
|
||||
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency>
|
||||
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency>
|
||||
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
|
||||
<dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
|
||||
</dependencies>
|
||||
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
|
||||
</project>
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baiyue.print;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 打印服务启动入口。
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.baiyue")
|
||||
public class PrintServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PrintServiceApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baiyue.print.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 打印服务状态检查接口。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/platform/v1/print")
|
||||
@Tag(name = "打印服务状态", description = "打印服务可用性接口")
|
||||
public class PrintHealthController {
|
||||
@GetMapping("/status")
|
||||
@Operation(summary = "查询服务状态", description = "返回打印服务的逻辑运行状态")
|
||||
@ApiResponses({
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "查询成功")
|
||||
})
|
||||
public ApiResponse<Map<String, String>> status() {
|
||||
return ApiResponse.success(Map.of("service", "print-service", "status", "UP"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
server:
|
||||
port: ${PRINT_PORT:9207}
|
||||
spring:
|
||||
application:
|
||||
name: print-service
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:baiyue-common.yml?group=BAIYUE&refreshEnabled=true
|
||||
- optional:nacos:${spring.application.name}.yml?group=BAIYUE&refreshEnabled=true
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: ${NACOS_SERVER_ADDR:127.0.0.1:8848}
|
||||
username: ${NACOS_USERNAME:nacos}
|
||||
password: ${NACOS_PASSWORD:nacos}
|
||||
discovery:
|
||||
enabled: ${NACOS_DISCOVERY_ENABLED:true}
|
||||
register-enabled: ${NACOS_REGISTER_ENABLED:true}
|
||||
group: ${NACOS_GROUP:BAIYUE}
|
||||
namespace: ${NACOS_NAMESPACE:public}
|
||||
config.namespace: ${NACOS_NAMESPACE:public}
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: ${PRINT_DB_URL:jdbc:mysql://127.0.0.1:3306/baiyue_print?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true}
|
||||
username: ${PRINT_DB_USERNAME:root}
|
||||
password: ${PRINT_DB_PASSWORD:123456}
|
||||
baiyue:
|
||||
security:
|
||||
jwt-secret: ${JWT_SECRET:change-me-to-at-least-32-bytes-long-before-start}
|
||||
management.endpoints.web.exposure.include: health,info,prometheus
|
||||
@@ -0,0 +1,62 @@
|
||||
-- 打印服务独占数据库,业务服务只保存打印任务逻辑ID。
|
||||
CREATE DATABASE IF NOT EXISTS baiyue_print
|
||||
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
|
||||
USE baiyue_print;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS print_template (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '模板ID(雪花ID)',
|
||||
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID,平台模板使用平台租户ID',
|
||||
template_code VARCHAR(64) NOT NULL COMMENT '模板编码',
|
||||
template_name VARCHAR(128) NOT NULL COMMENT '模板名称',
|
||||
template_type VARCHAR(32) NOT NULL COMMENT '模板类型',
|
||||
content TEXT NOT NULL COMMENT '模板内容',
|
||||
version_no INT UNSIGNED NOT NULL DEFAULT 1 COMMENT '模板版本号',
|
||||
status VARCHAR(24) NOT NULL DEFAULT 'ACTIVE' COMMENT '模板状态',
|
||||
created_by BIGINT UNSIGNED NOT NULL COMMENT '创建人ID',
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
|
||||
updated_by BIGINT UNSIGNED NOT NULL COMMENT '最后修改人ID',
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
|
||||
deleted TINYINT(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标记',
|
||||
version INT NOT NULL DEFAULT 0 COMMENT '乐观锁版本号',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_print_template_code (tenant_id, template_code, version_no),
|
||||
KEY idx_print_template_status (tenant_id, status)
|
||||
) ENGINE=InnoDB COMMENT='打印模板表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS print_job (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '打印任务ID(雪花ID)',
|
||||
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID',
|
||||
job_no VARCHAR(40) NOT NULL COMMENT '打印任务编号',
|
||||
template_id BIGINT UNSIGNED NOT NULL COMMENT '打印模板逻辑ID',
|
||||
business_type VARCHAR(32) NULL COMMENT '关联业务类型',
|
||||
business_id VARCHAR(64) NULL COMMENT '关联业务逻辑ID',
|
||||
printer_code VARCHAR(64) NULL COMMENT '目标打印机编码',
|
||||
copies INT UNSIGNED NOT NULL DEFAULT 1 COMMENT '打印份数',
|
||||
payload_json JSON NOT NULL COMMENT '模板数据快照',
|
||||
status VARCHAR(24) NOT NULL DEFAULT 'PENDING' COMMENT '任务状态',
|
||||
output_file_id BIGINT UNSIGNED NULL COMMENT '生成文件的逻辑ID',
|
||||
error_message VARCHAR(1000) NULL COMMENT '失败原因',
|
||||
requested_by BIGINT UNSIGNED NOT NULL COMMENT '申请人ID',
|
||||
requested_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '申请时间',
|
||||
started_at DATETIME(3) NULL COMMENT '开始时间',
|
||||
completed_at DATETIME(3) NULL COMMENT '完成时间',
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
|
||||
version INT NOT NULL DEFAULT 0 COMMENT '乐观锁版本号',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_print_job_no (tenant_id, job_no),
|
||||
KEY idx_print_job_status (tenant_id, status, requested_at),
|
||||
KEY idx_print_job_business (tenant_id, business_type, business_id)
|
||||
) ENGINE=InnoDB COMMENT='打印任务表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS print_job_history (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '任务历史ID',
|
||||
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '数据所属租户ID',
|
||||
print_job_id BIGINT UNSIGNED NOT NULL COMMENT '打印任务逻辑ID',
|
||||
from_status VARCHAR(24) NULL COMMENT '变更前状态',
|
||||
to_status VARCHAR(24) NOT NULL COMMENT '变更后状态',
|
||||
message VARCHAR(500) NULL COMMENT '状态说明',
|
||||
operator_id BIGINT UNSIGNED NULL COMMENT '操作人ID',
|
||||
occurred_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '发生时间',
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_print_history_job (tenant_id, print_job_id, occurred_at)
|
||||
) ENGINE=InnoDB COMMENT='打印任务状态历史表';
|
||||
Reference in New Issue
Block a user