- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称 - 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配 - 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配 - 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名 - 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试 - 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token - 调整系统角色授权用户页面的表单布局和表格样式类名 - 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
34 lines
3.5 KiB
Java
34 lines
3.5 KiB
Java
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import java.nio.file.*;
|
|
import java.sql.*;
|
|
import java.util.*;
|
|
|
|
/** Deployment readiness only: no DDL/DML and no automatic initialization. */
|
|
public class ReadOnlyProductionPreflight {
|
|
public static void main(String[] args) throws Exception {
|
|
Map<String,String> config = new HashMap<>(); boolean master = false;
|
|
for (String line : Files.readAllLines(Path.of("ruoyi-admin/src/main/resources/application-druid.yml"))) {
|
|
if (line.trim().equals("master:")) { master=true; continue; }
|
|
if (line.trim().equals("slave:")) break;
|
|
if (master && line.indexOf(':') > 0) { int colon=line.indexOf(':'); config.put(line.substring(0,colon).trim(),DatabaseTool.value(line.substring(colon+1).trim())); }
|
|
}
|
|
String configured=config.get("url");
|
|
if (configured==null || !configured.matches("^jdbc:mysql://192\\.168\\.28\\.10:3306/cmvr-project-dev(?:\\?.*)?$")) throw new IllegalStateException("Unexpected local datasource");
|
|
var properties=new Properties();properties.setProperty("user",config.get("username"));properties.setProperty("password",config.get("password"));properties.setProperty("connectTimeout","5000");properties.setProperty("socketTimeout","60000");
|
|
var report=new LinkedHashMap<String,Object>();report.put("database","cmvr-project-prod");report.put("readOnly",true);
|
|
try(var c=DriverManager.getConnection(configured.replace("/cmvr-project-dev","/cmvr-project-prod"),properties)) {
|
|
c.setReadOnly(true);c.setAutoCommit(false);try(var s=c.createStatement()){s.execute("START TRANSACTION READ ONLY");}
|
|
try(var s=c.createStatement();var r=s.executeQuery("select database()")){r.next();if(!"cmvr-project-prod".equals(r.getString(1)))throw new IllegalStateException("Production target mismatch");}
|
|
var tables=new TreeMap<String,Long>();
|
|
try(var s=c.prepareStatement("select table_name from information_schema.tables where table_schema=? and table_type='BASE TABLE'")){s.setString(1,"cmvr-project-prod");try(var r=s.executeQuery()){while(r.next())tables.put(r.getString(1),0L);}}
|
|
for(String name:tables.keySet()){if(!name.matches("[A-Za-z0-9_]+"))throw new IllegalStateException("Unexpected identifier");try(var s=c.createStatement();var r=s.executeQuery("select count(*) from `"+name+"`")){r.next();tables.put(name,r.getLong(1));}}
|
|
var missing=new ArrayList<String>();
|
|
try(var s=c.prepareStatement("select d.table_name,d.column_name from information_schema.columns d left join information_schema.columns p on p.table_schema='cmvr-project-prod' and p.table_name=d.table_name and p.column_name=d.column_name where d.table_schema='cmvr-project-dev' and p.column_name is null order by d.table_name,d.ordinal_position");var r=s.executeQuery()){while(r.next())missing.add(r.getString(1)+"."+r.getString(2));}
|
|
report.put("tableCounts",tables);report.put("missingColumnsComparedWithDevelopment",missing);c.rollback();
|
|
}
|
|
Path output=Path.of(".codex-tmp/deploy-production/preflight.json");Files.createDirectories(output.getParent());Files.writeString(output,new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(report));
|
|
System.out.println("Read-only production preflight saved: "+output);
|
|
System.out.println("Production tables: "+((Map<?,?>)report.get("tableCounts")).size()+"; missing columns: "+((List<?>)report.get("missingColumnsComparedWithDevelopment")).size());
|
|
}
|
|
}
|