|
@@ -1,11 +1,17 @@
|
|
package org.dromara.system.controller;
|
|
package org.dromara.system.controller;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.validation.constraints.*;
|
|
import jakarta.validation.constraints.*;
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
+import org.dromara.common.excel.core.ExcelResult;
|
|
|
|
+import org.dromara.system.domain.GameTeam;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
@@ -21,6 +27,7 @@ import org.dromara.system.domain.vo.GameTeamVo;
|
|
import org.dromara.system.domain.bo.GameTeamBo;
|
|
import org.dromara.system.domain.bo.GameTeamBo;
|
|
import org.dromara.system.service.IGameTeamService;
|
|
import org.dromara.system.service.IGameTeamService;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 参赛队伍
|
|
* 参赛队伍
|
|
@@ -28,6 +35,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
* @author zlt
|
|
* @author zlt
|
|
* @date 2025-07-30
|
|
* @date 2025-07-30
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Validated
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RestController
|
|
@@ -45,6 +53,33 @@ public class GameTeamController extends BaseController {
|
|
return gameTeamService.queryPageList(bo, pageQuery);
|
|
return gameTeamService.queryPageList(bo, pageQuery);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 导入参赛队伍列表
|
|
|
|
+ */
|
|
|
|
+ @SaCheckPermission("system:gameTeam:import")
|
|
|
|
+ @Log(title = "参赛队伍", businessType = BusinessType.IMPORT)
|
|
|
|
+ @PostMapping("/import")
|
|
|
|
+ public R<Void> importExcel(@RequestPart("file") MultipartFile file) {
|
|
|
|
+ ExcelResult<GameTeamVo> excelResult = null;
|
|
|
|
+ try {
|
|
|
|
+ excelResult = ExcelUtil.importExcel(file.getInputStream(), GameTeamVo.class, true);
|
|
|
|
+ List<GameTeam> list = MapstructUtils.convert(excelResult.getList(), GameTeam.class);
|
|
|
|
+ log.info("转换后的列表:", list);
|
|
|
|
+ gameTeamService.saveBatch(list);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return R.ok(excelResult.getAnalysis());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取导入模板
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/importTemplate")
|
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
|
+ ExcelUtil.exportExcel(new ArrayList<>(), "参数队伍数据", GameTeamVo.class, response);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 导出参赛队伍列表
|
|
* 导出参赛队伍列表
|
|
*/
|
|
*/
|
|
@@ -64,7 +99,7 @@ public class GameTeamController extends BaseController {
|
|
@SaCheckPermission("system:gameTeam:query")
|
|
@SaCheckPermission("system:gameTeam:query")
|
|
@GetMapping("/{teamId}")
|
|
@GetMapping("/{teamId}")
|
|
public R<GameTeamVo> getInfo(@NotNull(message = "主键不能为空")
|
|
public R<GameTeamVo> getInfo(@NotNull(message = "主键不能为空")
|
|
- @PathVariable Long teamId) {
|
|
|
|
|
|
+ @PathVariable Long teamId) {
|
|
return R.ok(gameTeamService.queryById(teamId));
|
|
return R.ok(gameTeamService.queryById(teamId));
|
|
}
|
|
}
|
|
|
|
|