【修改】判分时下载的文件带上文件的属性

This commit is contained in:
YOHO\20373
2025-06-11 15:26:02 +08:00
parent a11aa2da99
commit 8df06f4f07
8 changed files with 53 additions and 36 deletions

View File

@@ -65,18 +65,11 @@ public class ExamQuestionAnswer
// @Excel(name = "排序")
private Integer sort;
private String attribute;
@TableField(exist = false)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<ExamMysqlKeyword> examMysqlKeywordList;
public ExamQuestionAnswer(String answerId, String quId, String isRight, String image, String content, String contentIn, String scoreRate, Integer sort) {
this.answerId = answerId;
this.quId = quId;
this.isRight = isRight;
this.image = image;
this.content = content;
this.contentIn = contentIn;
this.scoreRate = scoreRate;
this.sort = sort;
}
}

View File

@@ -56,30 +56,31 @@ public class GetDifferencesBetweenFolders {
// 列出文件夹下的所有文件及其属性
public static Map<String, String> listFilesAndFoldersWithAttributes(Path folder) throws IOException {
if (!Files.exists(folder)) return Collections.emptyMap();
try (Stream<Path> stream = Files.walk(folder)) {
return stream.collect(Collectors.toMap(
path -> folder.relativize(path).toString(),
GetDifferencesBetweenFolders::getFileAttributes,
(a, b) -> a,
LinkedHashMap::new
));
public static Map<String, String> listFilesAndFoldersWithAttributes(Path folder) throws IOException {
if (!Files.exists(folder)) return Collections.emptyMap();
try (Stream<Path> stream = Files.walk(folder)) {
return stream.collect(Collectors.toMap(
path -> folder.relativize(path).toString(),
GetDifferencesBetweenFolders::getFileAttributes,
(a, b) -> a,
LinkedHashMap::new
));
}
}
}
// 在 getFileAttributes 方法中,只返回文件的属性,如果是文件夹则返回特殊标识
static String getFileAttributes(Path path) {
// 返回文件和文件夹的属性
static String getFileAttributes(Path path) {
try {
if (Files.isDirectory(path)) {
return "文件夹"; // 特别标记为文件夹
boolean isDirectory = Files.isDirectory(path);
boolean isHidden = Files.isHidden(path);
boolean isReadable = Files.isReadable(path);
if (isDirectory) {
return String.format("隐藏: %b, 可读: %b", isHidden, isReadable);
} else {
BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
boolean isHidden = Files.isHidden(path);
boolean isReadable = Files.isReadable(path);
boolean isWritable = Files.isWritable(path);
return String.format("大小: %dB, 隐藏: %b, 可读: %b, 可写: %b",
attrs.size(), isHidden, isReadable, isWritable);
return String.format("隐藏: %b, 可读: %b, 可写: %b",
isHidden, isReadable, isWritable);
}
} catch (IOException e) {
return "无法获取属性";

View File

@@ -11,11 +11,12 @@
<result property="content" column="content" />
<result property="contentIn" column="contentIn" />
<result property="scoreRate" column="score_rate" />
<result property="attribute" column="attribute" />
<result property="sort" column="sort" />
</resultMap>
<sql id="selectExamQuestionAnswerVo">
select answer_id, qu_id, is_right, image, content,contentIn, score_rate,sort from exam_question_answer
select answer_id, qu_id, is_right, image, content,contentIn, score_rate,attribute,sort from exam_question_answer
</sql>
<select id="selectExamQuestionAnswerList" parameterType="ExamQuestionAnswer" resultMap="ExamQuestionAnswerResult">
@@ -105,10 +106,10 @@
</select>
<insert id="insertExamQuestionAnswerList">
insert into exam_question_answer
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort)
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort,attribute)
values
<foreach collection="collection" separator="," item="item">
(#{item.answerId},#{item.quId},#{item.isRight},#{item.image},#{item.content},#{item.contentIn},#{item.scoreRate},#{item.sort})
(#{item.answerId},#{item.quId},#{item.isRight},#{item.image},#{item.content},#{item.contentIn},#{item.scoreRate},#{item.sort},#{item.attribute})
</foreach>
</insert>