feat: 🎸 视频上传接口&示例接口
This commit is contained in:
parent
e5e0823e7a
commit
025be43257
@ -1,32 +1,35 @@
|
|||||||
package org.jeecg.modules.learn.business.controller;
|
package org.jeecg.modules.biz.controller;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
import org.jeecg.config.shiro.IgnoreAuth;
|
import org.jeecg.config.shiro.IgnoreAuth;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
|
import org.jeecg.modules.biz.service.CourseBizService;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@Tag(name="课程")
|
@Tag(name = "课程")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/business/course")
|
@RequestMapping("/biz/course")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CourseBusinessController {
|
public class CourseBizController {
|
||||||
|
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
@Operation(summary="测试")
|
@Operation(summary = "测试")
|
||||||
@IgnoreAuth
|
@IgnoreAuth
|
||||||
public Result<String> test() {
|
public Result<String> test() {
|
||||||
return Result.OK("test");
|
return Result.OK("test");
|
||||||
@ -34,9 +37,11 @@ public class CourseBusinessController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysBaseAPI sysBaseApi;
|
private ISysBaseAPI sysBaseApi;
|
||||||
|
@Autowired
|
||||||
|
private CourseBizService courseBusinessService;
|
||||||
|
|
||||||
@GetMapping("/test2")
|
@GetMapping("/test2")
|
||||||
@Operation(summary="测试2")
|
@Operation(summary = "测试2")
|
||||||
public Result<String> test2(HttpServletRequest request, HttpServletResponse response) {
|
public Result<String> test2(HttpServletRequest request, HttpServletResponse response) {
|
||||||
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
|
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
|
||||||
String username = JwtUtil.getUsername(token);
|
String username = JwtUtil.getUsername(token);
|
||||||
@ -44,4 +49,20 @@ public class CourseBusinessController {
|
|||||||
return Result.OK(sysUser.toString());
|
return Result.OK(sysUser.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/test3")
|
||||||
|
@Operation(summary = "测试3")
|
||||||
|
@IgnoreAuth
|
||||||
|
public Result<Long> test3() {
|
||||||
|
long count = courseBusinessService.count();
|
||||||
|
return Result.OK(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
@Operation(summary = "课程视频文件上传", description = "课程视频文件上传,返回m3u8文件地址")
|
||||||
|
@IgnoreAuth
|
||||||
|
public Result<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
|
||||||
|
if (file == null || file.isEmpty()) return Result.error("没有找到上传的文件");
|
||||||
|
String url = courseBusinessService.uploadHls(file, request);
|
||||||
|
return Result.OK(url);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package org.jeecg.modules.biz.service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 课程业务
|
||||||
|
*/
|
||||||
|
public interface CourseBizService extends IService<TestTable> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传视频并切片为 HLS(m3u8+ts),按配置(local|minio|alioss)上传,返回 m3u8 的路径/URL
|
||||||
|
* @param file 上传的视频文件
|
||||||
|
* @param request 用于读取 header 或环境配置
|
||||||
|
* @return m3u8 路径/URL
|
||||||
|
* @throws Exception 处理异常
|
||||||
|
*/
|
||||||
|
String uploadHls(MultipartFile file, HttpServletRequest request) throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
|||||||
|
package org.jeecg.modules.biz.service.impl;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.util.CommonUtils;
|
||||||
|
import org.jeecg.common.util.MinioUtil;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import org.jeecg.common.util.oss.OssBootUtil;
|
||||||
|
import org.jeecg.modules.biz.service.CourseBizService;
|
||||||
|
import org.jeecg.modules.gen.test.mapper.TestTableMapper;
|
||||||
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CourseBizServiceImpl extends ServiceImpl<TestTableMapper, TestTable> implements CourseBizService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadHls(MultipartFile file, HttpServletRequest request) throws Exception {
|
||||||
|
// 读取上传类型(header 优先)
|
||||||
|
String headerUploadType = request.getHeader("uploadType");
|
||||||
|
String configUploadType = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("jeecg.uploadType", "minio");
|
||||||
|
String uploadType = (headerUploadType != null && headerUploadType.trim().length() > 0) ? headerUploadType : configUploadType;
|
||||||
|
|
||||||
|
// 1) 保存临时原始视频
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
String tmpRoot = System.getProperty("java.io.tmpdir");
|
||||||
|
Path tmpVideoDir = Path.of(tmpRoot, "jeecg", "video", uuid);
|
||||||
|
Path hlsDir = Path.of(tmpRoot, "jeecg", "hls", uuid);
|
||||||
|
Files.createDirectories(tmpVideoDir);
|
||||||
|
Files.createDirectories(hlsDir);
|
||||||
|
|
||||||
|
String original = CommonUtils.getFileName(Objects.requireNonNull(file.getOriginalFilename()));
|
||||||
|
Path tmpVideoFile = tmpVideoDir.resolve(original);
|
||||||
|
Files.copy(file.getInputStream(), tmpVideoFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
|
// 2) ffmpeg 切片
|
||||||
|
Path m3u8Path = hlsDir.resolve(uuid + ".m3u8");
|
||||||
|
List<String> cmd = Arrays.asList(
|
||||||
|
"ffmpeg", "-i", tmpVideoFile.toString(),
|
||||||
|
"-c:v", "libx264", "-c:a", "aac",
|
||||||
|
"-hls_time", "10", "-hls_playlist_type", "vod",
|
||||||
|
m3u8Path.toString());
|
||||||
|
Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start();
|
||||||
|
boolean ok = p.waitFor(10, TimeUnit.MINUTES) && p.exitValue() == 0;
|
||||||
|
if (!ok) {
|
||||||
|
deleteQuietly(hlsDir.toFile());
|
||||||
|
deleteQuietly(tmpVideoDir.toFile());
|
||||||
|
throw new RuntimeException("ffmpeg切片超时");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) 上传切片
|
||||||
|
String m3u8Url = "";
|
||||||
|
String base = "video/hls/" + uuid;
|
||||||
|
try (Stream<Path> paths = Files.list(hlsDir)) {
|
||||||
|
for (Path f : (Iterable<Path>) paths::iterator) {
|
||||||
|
if (!Files.isRegularFile(f)) continue;
|
||||||
|
String rel = base + "/" + f.getFileName().toString();
|
||||||
|
try (InputStream in = Files.newInputStream(f)) {
|
||||||
|
if ("minio".equals(uploadType)) {
|
||||||
|
String tmpUrl = MinioUtil.upload(in, rel);
|
||||||
|
if (f.getFileName().toString().endsWith(".m3u8")) {
|
||||||
|
m3u8Url = tmpUrl;
|
||||||
|
}
|
||||||
|
} else if ("alioss".equals(uploadType)) {
|
||||||
|
OssBootUtil.upload(in, rel);
|
||||||
|
if (f.getFileName().toString().endsWith(".m3u8")) {
|
||||||
|
m3u8Url = rel; // 可在网关拼域名
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String uploadpath = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("jeecg.path.upload");
|
||||||
|
Path target = Path.of(uploadpath, rel);
|
||||||
|
Files.createDirectories(target.getParent());
|
||||||
|
Files.copy(f, target, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
if (f.getFileName().toString().endsWith(".m3u8")) {
|
||||||
|
m3u8Url = rel; // local 返回相对路径
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
deleteQuietly(hlsDir.toFile());
|
||||||
|
deleteQuietly(tmpVideoDir.toFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
return m3u8Url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除临时目录文件 */
|
||||||
|
private static void deleteQuietly(File file) {
|
||||||
|
try {
|
||||||
|
if (file == null || !file.exists()) return;
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
File[] children = file.listFiles();
|
||||||
|
if (children != null) {
|
||||||
|
for (File c : children) deleteQuietly(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.jeecg.modules.learn.test.controller;
|
package org.jeecg.modules.gen.test.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -14,8 +14,8 @@ import org.jeecg.common.api.vo.Result;
|
|||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.jeecg.modules.learn.test.entity.TestTable;
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
import org.jeecg.modules.learn.test.service.ITestTableService;
|
import org.jeecg.modules.gen.test.service.ITestTableService;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -41,12 +41,12 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||||||
/**
|
/**
|
||||||
* @Description: 测试表
|
* @Description: 测试表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-08
|
* @Date: 2025-08-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Tag(name="测试表")
|
@Tag(name="测试表")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/testTable")
|
@RequestMapping("/gen/test/testTable")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TestTableController extends JeecgController<TestTable, ITestTableService> {
|
public class TestTableController extends JeecgController<TestTable, ITestTableService> {
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -84,7 +84,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
*/
|
*/
|
||||||
@AutoLog(value = "测试表-添加")
|
@AutoLog(value = "测试表-添加")
|
||||||
@Operation(summary="测试表-添加")
|
@Operation(summary="测试表-添加")
|
||||||
@RequiresPermissions("test:test_table:add")
|
@RequiresPermissions("gen.test:test_table:add")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<String> add(@RequestBody TestTable testTable) {
|
public Result<String> add(@RequestBody TestTable testTable) {
|
||||||
testTableService.save(testTable);
|
testTableService.save(testTable);
|
||||||
@ -100,7 +100,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
*/
|
*/
|
||||||
@AutoLog(value = "测试表-编辑")
|
@AutoLog(value = "测试表-编辑")
|
||||||
@Operation(summary="测试表-编辑")
|
@Operation(summary="测试表-编辑")
|
||||||
@RequiresPermissions("test:test_table:edit")
|
@RequiresPermissions("gen.test:test_table:edit")
|
||||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
public Result<String> edit(@RequestBody TestTable testTable) {
|
public Result<String> edit(@RequestBody TestTable testTable) {
|
||||||
testTableService.updateById(testTable);
|
testTableService.updateById(testTable);
|
||||||
@ -115,7 +115,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
*/
|
*/
|
||||||
@AutoLog(value = "测试表-通过id删除")
|
@AutoLog(value = "测试表-通过id删除")
|
||||||
@Operation(summary="测试表-通过id删除")
|
@Operation(summary="测试表-通过id删除")
|
||||||
@RequiresPermissions("test:test_table:delete")
|
@RequiresPermissions("gen.test:test_table:delete")
|
||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
testTableService.removeById(id);
|
testTableService.removeById(id);
|
||||||
@ -130,7 +130,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
*/
|
*/
|
||||||
@AutoLog(value = "测试表-批量删除")
|
@AutoLog(value = "测试表-批量删除")
|
||||||
@Operation(summary="测试表-批量删除")
|
@Operation(summary="测试表-批量删除")
|
||||||
@RequiresPermissions("test:test_table:deleteBatch")
|
@RequiresPermissions("gen.test:test_table:deleteBatch")
|
||||||
@DeleteMapping(value = "/deleteBatch")
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
this.testTableService.removeByIds(Arrays.asList(ids.split(",")));
|
this.testTableService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
@ -160,7 +160,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
* @param request
|
* @param request
|
||||||
* @param testTable
|
* @param testTable
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("test:test_table:exportXls")
|
@RequiresPermissions("gen.test:test_table:exportXls")
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, TestTable testTable) {
|
public ModelAndView exportXls(HttpServletRequest request, TestTable testTable) {
|
||||||
return super.exportXls(request, testTable, TestTable.class, "测试表");
|
return super.exportXls(request, testTable, TestTable.class, "测试表");
|
||||||
@ -173,7 +173,7 @@ public class TestTableController extends JeecgController<TestTable, ITestTableSe
|
|||||||
* @param response
|
* @param response
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("test:test_table:importExcel")
|
@RequiresPermissions("gen.test:test_table:importExcel")
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
return super.importExcel(request, response, TestTable.class);
|
return super.importExcel(request, response, TestTable.class);
|
@ -1,4 +1,4 @@
|
|||||||
package org.jeecg.modules.learn.test.entity;
|
package org.jeecg.modules.gen.test.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
|
|||||||
/**
|
/**
|
||||||
* @Description: 测试表
|
* @Description: 测试表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-08
|
* @Date: 2025-08-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
@ -1,15 +1,15 @@
|
|||||||
package org.jeecg.modules.learn.test.mapper;
|
package org.jeecg.modules.gen.test.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.learn.test.entity.TestTable;
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 测试表
|
* @Description: 测试表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-08
|
* @Date: 2025-08-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface TestTableMapper extends BaseMapper<TestTable> {
|
public interface TestTableMapper extends BaseMapper<TestTable> {
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.jeecg.modules.learn.test.mapper.TestTableMapper">
|
<mapper namespace="org.jeecg.modules.gen.test.mapper.TestTableMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -1,12 +1,12 @@
|
|||||||
package org.jeecg.modules.learn.test.service;
|
package org.jeecg.modules.gen.test.service;
|
||||||
|
|
||||||
import org.jeecg.modules.learn.test.entity.TestTable;
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 测试表
|
* @Description: 测试表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-08
|
* @Date: 2025-08-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface ITestTableService extends IService<TestTable> {
|
public interface ITestTableService extends IService<TestTable> {
|
@ -1,8 +1,8 @@
|
|||||||
package org.jeecg.modules.learn.test.service.impl;
|
package org.jeecg.modules.gen.test.service.impl;
|
||||||
|
|
||||||
import org.jeecg.modules.learn.test.entity.TestTable;
|
import org.jeecg.modules.gen.test.entity.TestTable;
|
||||||
import org.jeecg.modules.learn.test.mapper.TestTableMapper;
|
import org.jeecg.modules.gen.test.mapper.TestTableMapper;
|
||||||
import org.jeecg.modules.learn.test.service.ITestTableService;
|
import org.jeecg.modules.gen.test.service.ITestTableService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
/**
|
/**
|
||||||
* @Description: 测试表
|
* @Description: 测试表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-08
|
* @Date: 2025-08-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
@ -1,7 +1,7 @@
|
|||||||
#code_generate_project_path
|
#code_generate_project_path
|
||||||
project_path=E:\\workspace\\jeecg-boot
|
project_path=E:\\workspace\\jeecg-boot
|
||||||
#bussi_package[User defined]
|
#bussi_package[User defined]
|
||||||
bussi_package=org.jeecg.modules.learn
|
bussi_package=org.jeecg.modules
|
||||||
|
|
||||||
|
|
||||||
#default code path
|
#default code path
|
||||||
|
@ -4,13 +4,13 @@ import { useMessage } from "/@/hooks/web/useMessage";
|
|||||||
const { createConfirm } = useMessage();
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
list = '/test/testTable/list',
|
list = '/gen/test/testTable/list',
|
||||||
save='/test/testTable/add',
|
save='/gen/test/testTable/add',
|
||||||
edit='/test/testTable/edit',
|
edit='/gen/test/testTable/edit',
|
||||||
deleteOne = '/test/testTable/delete',
|
deleteOne = '/gen/test/testTable/delete',
|
||||||
deleteBatch = '/test/testTable/deleteBatch',
|
deleteBatch = '/gen/test/testTable/deleteBatch',
|
||||||
importExcel = '/test/testTable/importExcel',
|
importExcel = '/gen/test/testTable/importExcel',
|
||||||
exportXls = '/test/testTable/exportXls',
|
exportXls = '/gen/test/testTable/exportXls',
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 导出api
|
* 导出api
|
@ -4,9 +4,9 @@
|
|||||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
<!--插槽:table标题-->
|
<!--插槽:table标题-->
|
||||||
<template #tableTitle>
|
<template #tableTitle>
|
||||||
<a-button type="primary" v-auth="'test:test_table:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
<a-button type="primary" v-auth="'gen.test:test_table:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||||
<a-button type="primary" v-auth="'test:test_table:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
<a-button type="primary" v-auth="'gen.test:test_table:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||||
<j-upload-button type="primary" v-auth="'test:test_table:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
<j-upload-button type="primary" v-auth="'gen.test:test_table:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
|
||||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</template>
|
</template>
|
||||||
<a-button v-auth="'test:test_table:deleteBatch'">批量操作
|
<a-button v-auth="'gen.test:test_table:deleteBatch'">批量操作
|
||||||
<Icon icon="mdi:chevron-down"></Icon>
|
<Icon icon="mdi:chevron-down"></Icon>
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="test-testTable" setup>
|
<script lang="ts" name="gen.test-testTable" setup>
|
||||||
import {ref, reactive, computed, unref} from 'vue';
|
import {ref, reactive, computed, unref} from 'vue';
|
||||||
import {BasicTable, useTable, TableAction} from '/@/components/Table';
|
import {BasicTable, useTable, TableAction} from '/@/components/Table';
|
||||||
import {useModal} from '/@/components/Modal';
|
import {useModal} from '/@/components/Modal';
|
||||||
@ -170,7 +170,7 @@
|
|||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
onClick: handleEdit.bind(null, record),
|
onClick: handleEdit.bind(null, record),
|
||||||
auth: 'test:test_table:edit'
|
auth: 'gen.test:test_table:edit'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@
|
|||||||
confirm: handleDelete.bind(null, record),
|
confirm: handleDelete.bind(null, record),
|
||||||
placement: 'topLeft',
|
placement: 'topLeft',
|
||||||
},
|
},
|
||||||
auth: 'test:test_table:delete'
|
auth: 'gen.test:test_table:delete'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -40,7 +40,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let formData = {};
|
let formData = {};
|
||||||
const queryByIdUrl = '/test/testTable/queryById';
|
const queryByIdUrl = '/gen/test/testTable/queryById';
|
||||||
async function initFormData(){
|
async function initFormData(){
|
||||||
let params = {id: props.formData.dataId};
|
let params = {id: props.formData.dataId};
|
||||||
const data = await defHttp.get({url: queryByIdUrl, params});
|
const data = await defHttp.get({url: queryByIdUrl, params});
|
@ -1,26 +0,0 @@
|
|||||||
-- 注意:该页面对应的前台目录为views/test文件夹下
|
|
||||||
-- 如果你想更改到其他目录,请修改sql中component字段对应的值
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
|
|
||||||
VALUES ('2025080808129710360', NULL, '测试表', '/test/testTableList', 'test/TestTableList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0);
|
|
||||||
|
|
||||||
-- 权限控制sql
|
|
||||||
-- 新增
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710361', '2025080808129710360', '添加测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
||||||
-- 编辑
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710362', '2025080808129710360', '编辑测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
||||||
-- 删除
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710363', '2025080808129710360', '删除测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
||||||
-- 批量删除
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710364', '2025080808129710360', '批量删除测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
||||||
-- 导出excel
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710365', '2025080808129710360', '导出excel_测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
||||||
-- 导入excel
|
|
||||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
|
|
||||||
VALUES ('2025080808129710366', '2025080808129710360', '导入excel_测试表', NULL, NULL, 0, NULL, NULL, 2, 'test:test_table:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-08-08 20:12:36', NULL, NULL, 0, 0, '1', 0);
|
|
Loading…
x
Reference in New Issue
Block a user