package com.rongyichuang; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ActiveProfiles; @SpringBootTest @ActiveProfiles("test") public class SetupActivityJudgeTest { @Autowired private JdbcTemplate jdbcTemplate; @Test public void setupActivityJudge() { // 为评委ID为21的评委添加活动ID为1的关联记录 String insertSql = "INSERT INTO t_activity_judge (activity_id, stage_id, judge_id, state) VALUES (1, 1, 21, 1)"; int insertedRows = jdbcTemplate.update(insertSql); System.out.println("插入了 " + insertedRows + " 条活动评委关联记录"); // 验证插入结果 String verifySql = "SELECT * FROM t_activity_judge WHERE activity_id = 1 AND judge_id = 21"; jdbcTemplate.queryForList(verifySql).forEach(row -> { System.out.println("活动ID: " + row.get("activity_id") + ", 评委ID: " + row.get("judge_id") + ", 阶段ID: " + row.get("stage_id") + ", 状态: " + row.get("state")); }); } }