添加功能

This commit is contained in:
马宝龙
2026-07-02 11:25:55 +08:00
parent 4f45536628
commit 6975aaaa48
8 changed files with 374 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
package com.ruoyi.cms.controller;
import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum;
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
import com.ruoyi.cms.service.ModelCommonService;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* 模型通用
*
* @author 马宝龙
* @date 2026/7/2
*/
@RestController
@RequestMapping("/model/common")
@RequiredArgsConstructor
public class ModelCommonController {
private final ModelCommonService modelCommonService;
/**
* 下载导入模板
*
* @param response 响应体
* @param modelTemplateType 模型模板类型
*/
@GetMapping("/template")
public void template(HttpServletResponse response,
@RequestParam ModelTemplateTypeEnum modelTemplateType) {
modelCommonService.template(response, modelTemplateType);
}
/**
* 导入数据
*
* @param file 文件
* @param modelTemplateType 模型模板类型
* @return 导入结果
*/
@PostMapping("/import")
public AjaxResult importExcel(@RequestParam("file") MultipartFile file,
@RequestParam ModelTemplateTypeEnum modelTemplateType) {
String message = modelCommonService.importExcel(file, modelTemplateType);
return AjaxResult.success(message);
}
/**
* 导出数据
*
* @param response 响应体
* @param dto 导出参数
* @return 导出结果
*/
@PostMapping("/export")
public AjaxResult exportExcel(HttpServletResponse response,
@RequestBody ModelExportParamDto dto) {
modelCommonService.exportExcel(response, dto);
return AjaxResult.success();
}
}