|
@@ -2,6 +2,7 @@ package com.fs.course.controller;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
@@ -157,13 +158,23 @@ public class FsCourseWatchCommentController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@Log(title = "评论导入模板", businessType = BusinessType.EXPORT)
|
|
@Log(title = "评论导入模板", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/template")
|
|
@GetMapping("/template")
|
|
|
- public AjaxResult downloadTemplate() {
|
|
|
|
|
|
|
+ public AjaxResult downloadTemplate(Integer type) {
|
|
|
try {
|
|
try {
|
|
|
ExcelUtil<CommentImportTemplate> util = new ExcelUtil<>(CommentImportTemplate.class);
|
|
ExcelUtil<CommentImportTemplate> util = new ExcelUtil<>(CommentImportTemplate.class);
|
|
|
List<CommentImportTemplate> templateData = new ArrayList<>();
|
|
List<CommentImportTemplate> templateData = new ArrayList<>();
|
|
|
CommentImportTemplate example = createExampleRow();
|
|
CommentImportTemplate example = createExampleRow();
|
|
|
templateData.add(example);
|
|
templateData.add(example);
|
|
|
- return util.exportExcel(templateData, "评论导入模板");
|
|
|
|
|
|
|
+ // 根据type参数确定需要导出的字段
|
|
|
|
|
+ List<String> selectedFields = new ArrayList<>();
|
|
|
|
|
+ if (type != null && type == 1) {
|
|
|
|
|
+ // 视频类型,不包含课程列
|
|
|
|
|
+ selectedFields.addAll(Arrays.asList("userId", "userType", "videoId", "type", "parentId", "content", "fontSize", "mode", "color"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 默认课程类型,不包含视频列
|
|
|
|
|
+ selectedFields.addAll(Arrays.asList("userId", "userType", "courseId", "type", "parentId", "content", "fontSize", "mode", "color"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return util.exportExcelSelectedColumns(templateData, "评论导入模板", selectedFields);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("下载评论导入模板失败", e);
|
|
logger.error("下载评论导入模板失败", e);
|
|
|
}
|
|
}
|
|
@@ -189,10 +200,10 @@ public class FsCourseWatchCommentController extends BaseController
|
|
|
|
|
|
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
|
@Log(title = "导入看课评论", businessType = BusinessType.IMPORT)
|
|
@Log(title = "导入看课评论", businessType = BusinessType.IMPORT)
|
|
|
- public R importData(MultipartFile file) throws Exception {
|
|
|
|
|
|
|
+ public R importData(MultipartFile file,Integer type) throws Exception {
|
|
|
ExcelUtil<CommentImportTemplate> util = new ExcelUtil<>(CommentImportTemplate.class);
|
|
ExcelUtil<CommentImportTemplate> util = new ExcelUtil<>(CommentImportTemplate.class);
|
|
|
List<CommentImportTemplate> commentImportTemplates = util.importExcel(file.getInputStream());
|
|
List<CommentImportTemplate> commentImportTemplates = util.importExcel(file.getInputStream());
|
|
|
- int i = fsCourseWatchCommentService.insertBatch(commentImportTemplates);
|
|
|
|
|
|
|
+ int i = fsCourseWatchCommentService.insertBatch(commentImportTemplates,type);
|
|
|
return R.ok().put("data", i);
|
|
return R.ok().put("data", i);
|
|
|
}
|
|
}
|
|
|
|
|
|