chore(assets): 参赛提交规范红线修复(ASCII 化 + 相对路径)

按《参赛成果物提交规范·赛道一》§6 红线:
- samples/ 目录改名 sample/(git mv,保留历史)
- 10 个中日文样本文件 + docs 参赛手册 PDF 重命名为 ASCII
  (requirements_*/template_*/rules_*/contestant-handbook.pdf)
- tests/test_zh_template.py 硬编码绝对路径 D:\00_project\Genesis 改为相对路径
- 全局更新 21 个活动文件引用;历史日志/审查文档不改(追加说明记录)
全量 pytest 431 passed / 99.15%
This commit is contained in:
lhl
2026-08-26 14:15:52 +08:00
parent 1925ef7239
commit becd3e1f57
398 changed files with 286 additions and 72 deletions
+104
View File
@@ -0,0 +1,104 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.stock</groupId>
<artifactId>stock-trade-system</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.stock</groupId>
<artifactId>trade-mbg</artifactId>
<packaging>jar</packaging>
<properties>
<mysql.version>8.0.33</mysql.version>
</properties>
<name>trade-mbg</name>
<description>MyBatis Generator module for Trade Platform</description>
<dependencies>
<!-- MyBatis Generator Core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.4.2</version> <!-- 请使用最新稳定版本 -->
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot Starter JDBC (for properties resolution) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- Swagger Annotations (for CommentGenerator) -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.20</version> <!-- 请使用与SpringDoc兼容的版本 -->
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.2</version> <!-- 与mybatis-generator-core版本一致 -->
<configuration>
<!-- MyBatis Generator 配置文件的位置 -->
<configurationFile>${project.basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<!-- 是否覆盖已生成的文件 -->
<overwrite>true</overwrite>
<!-- 是否在控制台输出详细信息 -->
<verbose>true</verbose>
<!--
允许移动生成的文件。默认情况下,插件会把生成的文件放到一个特定的目录中,
如果设置为true,那么插件会把这些文件移动到 <configurationFile> 中指定的目录。
这对于将生成的文件直接集成到项目中非常有用。
-->
<includeCompileDependencies>true</includeCompileDependencies>
</configuration>
<dependencies>
<!-- 数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>
<!-- 自定义的 CommentGenerator -->
<dependency>
<groupId>com.stock</groupId>
<artifactId>trade-mbg</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,205 @@
package com.trade.mbg.util;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.CompilationUnit;
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.InnerEnum;
import org.mybatis.generator.api.dom.java.JavaElement;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;
import org.mybatis.generator.api.dom.java.TopLevelClass;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.config.MergeConstants;
import org.mybatis.generator.config.PropertyRegistry;
import org.mybatis.generator.internal.DefaultCommentGenerator;
import org.mybatis.generator.internal.util.StringUtility;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import java.util.Set;
/**
* Custom Comment Generator for MyBatis Generator.
* It adds @ApiModelProperty annotations for Swagger and uses Lombok annotations.
*/
public class CommentGenerator extends DefaultCommentGenerator {
private boolean suppressDate;
private boolean suppressAllComments;
private boolean addRemarkComments;
private SimpleDateFormat dateFormat;
private boolean useLombok;
private boolean useSwagger;
public CommentGenerator() {
super();
suppressDate = false;
suppressAllComments = false;
addRemarkComments = false;
useLombok = true; // Enable Lombok by default
useSwagger = true; // Enable Swagger by default
}
@Override
public void addJavaFileComment(CompilationUnit compilationUnit) {
// add no file level comments
if (suppressAllComments) {
return;
}
if (useLombok) {
compilationUnit.addImportedType(new FullyQualifiedJavaType("lombok.Data"));
compilationUnit.addImportedType(new FullyQualifiedJavaType("lombok.Builder"));
compilationUnit.addImportedType(new FullyQualifiedJavaType("lombok.NoArgsConstructor"));
compilationUnit.addImportedType(new FullyQualifiedJavaType("lombok.AllArgsConstructor"));
}
if (useSwagger) {
compilationUnit.addImportedType(new FullyQualifiedJavaType("io.swagger.v3.oas.annotations.media.Schema"));
}
}
@Override
public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
if (suppressAllComments || !addRemarkComments) {
return;
}
topLevelClass.addJavaDocLine("/**");
String remarks = introspectedTable.getRemarks();
if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
topLevelClass.addJavaDocLine(" * " + remarks);
topLevelClass.addJavaDocLine(" *");
}
topLevelClass.addJavaDocLine(" * " + introspectedTable.getFullyQualifiedTable());
if (!suppressDate) {
topLevelClass.addJavaDocLine(" * @date " + getDateString());
}
topLevelClass.addJavaDocLine(" */");
if (useLombok) {
topLevelClass.addAnnotation("@Data");
topLevelClass.addAnnotation("@Builder");
topLevelClass.addAnnotation("@NoArgsConstructor");
topLevelClass.addAnnotation("@AllArgsConstructor");
}
if (useSwagger) {
if (StringUtility.stringHasValue(remarks)) {
topLevelClass.addAnnotation("@Schema(description = \"" + remarks + "\")");
} else {
topLevelClass.addAnnotation("@Schema(description = \"" + introspectedTable.getFullyQualifiedTable().getDomainObjectName() + "\")");
}
}
}
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
if (suppressAllComments) {
return;
}
String remarks = introspectedColumn.getRemarks();
if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
field.addJavaDocLine("/**");
field.addJavaDocLine(" * " + remarks);
field.addJavaDocLine(" */");
if (useSwagger) {
field.addAnnotation("@Schema(description = \"" + remarks + "\")");
}
} else if (useSwagger) {
field.addAnnotation("@Schema(description = \"" + introspectedColumn.getActualColumnName() + "\")");
}
}
@Override
public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
// Lombok will generate getters, so no need to add comments here if Lombok is enabled.
if (useLombok || suppressAllComments) {
return;
}
super.addGetterComment(method, introspectedTable, introspectedColumn);
}
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
// Lombok will generate setters, so no need to add comments here if Lombok is enabled.
if (useLombok || suppressAllComments) {
return;
}
super.addSetterComment(method, introspectedTable, introspectedColumn);
}
@Override
public void addConfigurationProperties(Properties properties) {
super.addConfigurationProperties(properties);
suppressDate = StringUtility.isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE));
suppressAllComments = StringUtility.isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS));
addRemarkComments = StringUtility.isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_ADD_REMARK_COMMENTS));
useLombok = StringUtility.isTrue(properties.getProperty("useLombok", "true")); // Default to true
useSwagger = StringUtility.isTrue(properties.getProperty("useSwagger", "true")); // Default to true
String dateFormatString = properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_DATE_FORMAT);
if (StringUtility.stringHasValue(dateFormatString)) {
dateFormat = new SimpleDateFormat(dateFormatString);
}
}
@Override
protected String getDateString() {
if (suppressDate) {
return null;
}
if (dateFormat != null) {
return dateFormat.format(new Date());
}
return new Date().toString();
}
@Override
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
if (suppressAllComments) {
return;
}
super.addClassComment(innerClass, introspectedTable);
}
@Override
public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) {
if (suppressAllComments) {
return;
}
super.addEnumComment(innerEnum, introspectedTable);
}
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
if (suppressAllComments) {
return;
}
super.addFieldComment(field, introspectedTable);
}
@Override
public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
if (suppressAllComments) {
return;
}
super.addGeneralMethodComment(method, introspectedTable);
}
@Override
public void addRootComment(XmlElement rootElement) {
// add no xml comments
}
@Override
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {
if (suppressAllComments) {
return;
}
super.addClassComment(innerClass, introspectedTable, markAsDoNotDelete);
}
}
@@ -0,0 +1,5 @@
# DataSource Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/trade_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=wodiXIAO1988
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 引入数据库连接配置 -->
<properties resource="application-dev.properties"/>
<!--
context:生成一组对象的环境
id:必选,上下文id,用于在生成错误时提示
defaultModelType:指定生成对象的类型,可选的值为:
conditional: 这是默认值,这个模型会产出最少字段的POJO,只有当表包含多个BLOB字段时,才会单独生成一个BLOB类。
flat: 生成的POJO包含表中的所有字段,即一个表对应一个POJO类。
hierarchical: 如果表有主键,那么该模型会产生一个单独的主键类, 如果表还有BLOB字段, 则会为表生成一个包含所有BLOB字段的POJO类,然后POJO会继承主键类,
如果表没有BLOB字段,只有主键,那么POJO会继承主键类,如果表既没有主键,也没有BLOB字段,那么和flat一样。
targetRuntime: MyBatis3DynamicSql, MyBatis3, MyBatis3Simple (推荐使用MyBatis3)
introspectedColumnImpl: 指定扩展Column类,可选
-->
<context id="MySQLContext" defaultModelType="flat" targetRuntime="MyBatis3Simple">
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressTypeWarnings" value="true"/>
<!-- optional,旨在创建class时,对注释进行控制 -->
<commentGenerator type="com.trade.mbg.util.CommentGenerator">
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
<property name="suppressDate" value="true"/>
<property name="addRemarkComments" value="true"/>
</commentGenerator>
<!-- JDBC连接 -->
<jdbcConnection driverClass="${spring.datasource.driver-class-name}"
connectionURL="${spring.datasource.url}"
userId="${spring.datasource.username}"
password="${spring.datasource.password}">
<!-- 解决mysql驱动升级到8.0后不生成指定数据库代码的问题 -->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!--
默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer
true,把JDBC DECIMAL 和 NUMERIC 类型解析为 java.math.BigDecimal
-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
<property name="useJSR310Types" value="true"/> <!-- 使用Java 8时间类型 -->
</javaTypeResolver>
<!-- 生成Domain模型的包名和位置 -->
<javaModelGenerator targetPackage="com.trade.mbg.model" targetProject="${user.dir}/trade-mbg/src/main/java">
<!-- 是否让schema作为包的后缀,默认为false -->
<property name="enableSubPackages" value="true"/>
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成Mapper XML文件的包名和位置 -->
<sqlMapGenerator targetPackage="com.trade.mbg.mapper" targetProject="${user.dir}/trade-mbg/src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成Mapper接口的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.trade.mbg.mapper" targetProject="${user.dir}/trade-mbg/src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--
要生成的表
tableName: 表名
domainObjectName: 生成的Domain对象的名称,不配置时根据表名自动生成驼峰命名
enableCountByExample: 是否生成通过Example统计记录数的SQL,默认为true
enableUpdateByExample: 是否生成通过Example更新记录的SQL(Selective表示仅更新非空字段),默认为true
enableDeleteByExample: 是否生成通过Example删除记录的SQL,默认为true
enableSelectByExample: 是否生成通过Example查询记录的SQL,默认为true
selectByExampleQueryId: 指定查询语句的ID,默认为false
modelType: 指定此表的模型类型,可选conditional, flat, hierarchical。会覆盖context的defaultModelType
-->
<!-- 示例表,请根据实际情况修改或添加 -->
<!-- <table tableName="user" domainObjectName="User"/> -->
<!-- <table tableName="product" domainObjectName="Product"/> -->
<!-- 如果要生成所有表,可以使用 % -->
<!-- <table tableName="%">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table> -->
<!-- 股票信息表 (新增) -->
<table tableName="t_stock_info" domainObjectName="StockInfo">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="listing_date" javaType="java.time.LocalDate"/>
<columnOverride column="delisting_date" javaType="java.time.LocalDate"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="update_time" javaType="java.time.LocalDateTime"/>
</table>
<!-- =========================================================================================== -->
<!-- ================================= 以下为具体业务表的配置 ================================= -->
<!-- =========================================================================================== -->
<!-- 用户表 (trade_user 模块) -->
<table tableName="ums_admin" domainObjectName="UmsAdmin">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="update_time" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_role" domainObjectName="Role">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="t_permission" domainObjectName="Permission">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="t_user_role_relation" domainObjectName="UserRoleRelation"/>
<table tableName="t_role_permission_relation" domainObjectName="RolePermissionRelation"/>
<!-- 行情数据表 (trade_market_data 模块) -->
<table tableName="t_market_data_kline" domainObjectName="MarketDataKline">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="timestamp" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_market_data_tick" domainObjectName="MarketDataTick">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="timestamp" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_symbol_info" domainObjectName="SymbolInfo">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<!-- 技术指标表 (trade_indicator 模块) -->
<table tableName="t_technical_indicator" domainObjectName="TechnicalIndicator">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="timestamp" javaType="java.time.LocalDateTime"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
</table>
<!-- 交易策略表 (trade_strategy 模块) -->
<table tableName="t_strategy" domainObjectName="Strategy">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="update_time" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_strategy_param" domainObjectName="StrategyParam">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<!-- 订单表 (trade_order 模块) -->
<table tableName="t_order" domainObjectName="Order">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="update_time" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_trade_record" domainObjectName="TradeRecord">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="trade_time" javaType="java.time.LocalDateTime"/>
</table>
<!-- 风险管理表 (trade_risk 模块) -->
<table tableName="t_risk_rule" domainObjectName="RiskRule">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="update_time" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_position_limit" domainObjectName="PositionLimit">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<!-- 回测记录表 (trade_backtest 模块) -->
<table tableName="t_backtest_record" domainObjectName="BacktestRecord">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="start_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="end_time" javaType="java.time.LocalDateTime"/>
<columnOverride column="create_time" javaType="java.time.LocalDateTime"/>
</table>
<table tableName="t_backtest_trade_log" domainObjectName="BacktestTradeLog">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="trade_time" javaType="java.time.LocalDateTime"/>
</table>
<!-- 通知记录表 (trade_notification 模块) -->
<table tableName="t_notification_log" domainObjectName="NotificationLog">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="send_time" javaType="java.time.LocalDateTime"/>
</table>
</context>
</generatorConfiguration>