12 changed files with 516 additions and 23 deletions
-
12pom.xml
-
14tp-admin/pom.xml
-
13tp-admin/src/main/resources/application-dev.yml
-
11tp-admin/src/main/resources/application-prod.yml
-
141tp-functional/src/main/java/com/inscloudtech/functional/controller/FuncCarAppController.java
-
56tp-functional/src/main/java/com/inscloudtech/functional/controller/FuncCarMediaController.java
-
45tp-functional/src/main/java/com/inscloudtech/functional/domain/FuncCarApp.java
-
46tp-functional/src/main/java/com/inscloudtech/functional/domain/FuncCarAppPg.java
-
14tp-functional/src/main/java/com/inscloudtech/functional/mapper/FuncCarAppMapper.java
-
16tp-functional/src/main/java/com/inscloudtech/functional/mapper/FuncCarAppPgMapper.java
-
37tp-functional/src/main/java/com/inscloudtech/functional/service/IFuncCarAppService.java
-
134tp-functional/src/main/java/com/inscloudtech/functional/service/impl/FuncCarAppServiceImpl.java
@ -0,0 +1,141 @@ |
|||
package com.inscloudtech.functional.controller; |
|||
|
|||
import com.inscloudtech.common.annotation.RepeatSubmit; |
|||
import com.inscloudtech.common.config.ProjectConfig; |
|||
import com.inscloudtech.common.core.controller.BaseController; |
|||
import com.inscloudtech.common.core.domain.PageQuery; |
|||
import com.inscloudtech.common.core.domain.R; |
|||
import com.inscloudtech.common.core.page.TableDataInfo; |
|||
import com.inscloudtech.common.core.validate.AddGroup; |
|||
import com.inscloudtech.common.core.validate.EditGroup; |
|||
import com.inscloudtech.common.utils.StringUtils; |
|||
import com.inscloudtech.common.utils.file.FileUtils; |
|||
import com.inscloudtech.functional.domain.FuncCarApp; |
|||
import com.inscloudtech.functional.service.IFuncCarApiService; |
|||
import com.inscloudtech.functional.service.IFuncCarAppService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.util.Arrays; |
|||
import java.util.Random; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/functional/carApp") |
|||
public class FuncCarAppController extends BaseController { |
|||
|
|||
private String DEMO_APP_STATUS = "STOP"; |
|||
|
|||
private String DATA_SOURCE = "MYSQL"; |
|||
|
|||
private final IFuncCarAppService iFuncCarAppService; |
|||
|
|||
/** |
|||
* 数据库测试-示例应用状态 |
|||
*/ |
|||
@GetMapping("/status") |
|||
public R status() { |
|||
return R.ok(DEMO_APP_STATUS); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-启动示例应用程序 |
|||
*/ |
|||
@GetMapping("/start") |
|||
public R start() { |
|||
// 模拟网络延迟 |
|||
Random random = new Random(); |
|||
int delayMillis = random.nextInt(2000); // 随机延迟0-500毫秒 |
|||
try { |
|||
Thread.sleep(delayMillis); |
|||
} catch (InterruptedException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
DEMO_APP_STATUS = "START"; |
|||
return R.ok("示例应用已启动!"); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-停止示例应用程序 |
|||
*/ |
|||
@GetMapping("/stop") |
|||
public R stop() { |
|||
DEMO_APP_STATUS = "STOP"; |
|||
return R.ok("示例应用已停止!"); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-1.当前数据源 |
|||
*/ |
|||
@GetMapping("/getDS") |
|||
public R getDS() { |
|||
return R.ok("当前数据源为【" +DATA_SOURCE+ "】"); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-2.切换数据源 |
|||
*/ |
|||
@GetMapping("/changeDS/{ds}") |
|||
public R changeDS(@PathVariable int ds) { |
|||
if(ds == 0){ |
|||
DATA_SOURCE = "MYSQL"; |
|||
}else if (ds == 1){ |
|||
DATA_SOURCE = "POSTGRESQL"; |
|||
}else { |
|||
throw new RuntimeException("未提供该类数据源!"); |
|||
} |
|||
|
|||
return R.ok("数据源已切换为【" +DATA_SOURCE+ "】"); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 数据库测试-3查询示例数据列表 |
|||
*/ |
|||
@GetMapping("/demoDataList") |
|||
public TableDataInfo list(FuncCarApp bo, PageQuery pageQuery) { |
|||
return iFuncCarAppService.queryPageList(bo, pageQuery,DATA_SOURCE); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 数据库测试-4新增示例数据列表 |
|||
*/ |
|||
@RepeatSubmit() |
|||
@PostMapping("/demoData") |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody FuncCarApp bo) { |
|||
return toAjax(iFuncCarAppService.insertByBo(bo,DATA_SOURCE)); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-5修改示例数据列表 |
|||
*/ |
|||
@RepeatSubmit() |
|||
@PutMapping("/demoData") |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FuncCarApp bo) { |
|||
return toAjax(iFuncCarAppService.updateByBo(bo,DATA_SOURCE)); |
|||
} |
|||
|
|||
/** |
|||
* 数据库测试-6删除示例数据列表 |
|||
* |
|||
* @param operIds 主键串 |
|||
*/ |
|||
@DeleteMapping("/demoData/{operIds}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] operIds) { |
|||
return toAjax(iFuncCarAppService.deleteWithValidByIds(Arrays.asList(operIds), true,DATA_SOURCE)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.inscloudtech.functional.controller; |
|||
|
|||
import com.inscloudtech.common.config.ProjectConfig; |
|||
import com.inscloudtech.common.core.controller.BaseController; |
|||
import com.inscloudtech.common.utils.StringUtils; |
|||
import com.inscloudtech.common.utils.file.FileUtils; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-多媒体文件兼容性测试工具 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/functional/carMedia") |
|||
public class FuncCarMediaController extends BaseController { |
|||
|
|||
private final ProjectConfig projectConfig; |
|||
|
|||
private final static String FFMPEG_FILE_NAME = "ffmpeg.zip"; |
|||
|
|||
|
|||
/** |
|||
* 文件格式验证-编码格式支持-分辨率与比特率-帧率-音频声道数和采样率-工具下载 |
|||
*/ |
|||
@GetMapping("/ffDownload") |
|||
public void jmDownload(HttpServletResponse response, HttpServletRequest request) { |
|||
doDownLoad(FFMPEG_FILE_NAME,response); |
|||
} |
|||
|
|||
|
|||
void doDownLoad(String filename,HttpServletResponse response){ |
|||
try { |
|||
if (!FileUtils.checkAllowDownload(filename)) { |
|||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", filename)); |
|||
} |
|||
String realFileName = System.currentTimeMillis() + filename.substring(filename.indexOf("_") + 1); |
|||
String filePath = projectConfig.getDownloadPath() + filename; |
|||
|
|||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
|||
FileUtils.setAttachmentResponseHeader(response, realFileName); |
|||
FileUtils.writeBytes(filePath, response.getOutputStream()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.inscloudtech.functional.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import com.inscloudtech.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-应用程序兼容性测试工具对象 func_car_app |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-17 |
|||
*/ |
|||
@Data |
|||
@TableName("func_car_app") |
|||
public class FuncCarApp { |
|||
|
|||
private static final long serialVersionUID=1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(value = "oper_id") |
|||
private Long operId; |
|||
/** |
|||
* 商品名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 状态 |
|||
*/ |
|||
private Long status; |
|||
/** |
|||
* |
|||
*/ |
|||
private Long userId; |
|||
|
|||
private Date createTime; |
|||
|
|||
private Date updateTime; |
|||
|
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.inscloudtech.functional.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.inscloudtech.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-应用程序兼容性测试工具对象 func_car_app |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-17 |
|||
*/ |
|||
@Data |
|||
@TableName("public.func_car_app") |
|||
public class FuncCarAppPg { |
|||
|
|||
private static final long serialVersionUID=1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(value = "oper_id") |
|||
private Long operId; |
|||
/** |
|||
* 商品名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 状态 |
|||
*/ |
|||
private Long status; |
|||
/** |
|||
* |
|||
*/ |
|||
private Long userId; |
|||
|
|||
private Date createTime; |
|||
|
|||
private Date updateTime; |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.inscloudtech.functional.mapper; |
|||
|
|||
import com.inscloudtech.common.core.mapper.BaseMapperPlus; |
|||
import com.inscloudtech.functional.domain.FuncCarApp; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-API接口兼容性测试工具Mapper接口 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-11 |
|||
*/ |
|||
public interface FuncCarAppMapper extends BaseMapperPlus<FuncCarAppMapper, FuncCarApp, FuncCarApp> { |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.inscloudtech.functional.mapper; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.inscloudtech.common.core.mapper.BaseMapperPlus; |
|||
import com.inscloudtech.functional.domain.FuncCarAppPg; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-API接口兼容性测试工具Mapper接口 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-11 |
|||
*/ |
|||
@DS("postgresql") |
|||
public interface FuncCarAppPgMapper extends BaseMapperPlus<FuncCarAppPgMapper, FuncCarAppPg, FuncCarAppPg> { |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.inscloudtech.functional.service; |
|||
|
|||
import com.inscloudtech.functional.domain.FuncCarApp; |
|||
import com.inscloudtech.common.core.page.TableDataInfo; |
|||
import com.inscloudtech.common.core.domain.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-应用程序兼容性测试工具Service接口 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-17 |
|||
*/ |
|||
public interface IFuncCarAppService { |
|||
|
|||
/** |
|||
* 查询兼容可靠性测试系统-应用程序兼容性测试工具列表 |
|||
*/ |
|||
TableDataInfo queryPageList(FuncCarApp bo, PageQuery pageQuery,String dataSource); |
|||
|
|||
/** |
|||
* 新增兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
*/ |
|||
Boolean insertByBo(FuncCarApp bo,String dataSource); |
|||
|
|||
/** |
|||
* 修改兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
*/ |
|||
Boolean updateByBo(FuncCarApp bo,String dataSource); |
|||
|
|||
/** |
|||
* 校验并批量删除兼容可靠性测试系统-应用程序兼容性测试工具信息 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid,String dataSource); |
|||
} |
@ -0,0 +1,134 @@ |
|||
package com.inscloudtech.functional.service.impl; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.inscloudtech.common.core.domain.model.LoginUser; |
|||
import com.inscloudtech.common.core.page.TableDataInfo; |
|||
import com.inscloudtech.common.core.domain.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.inscloudtech.common.helper.LoginHelper; |
|||
import com.inscloudtech.common.utils.StringUtils; |
|||
import com.inscloudtech.functional.domain.FuncCarAppPg; |
|||
import com.inscloudtech.functional.mapper.FuncCarAppPgMapper; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import com.inscloudtech.functional.domain.FuncCarApp; |
|||
import com.inscloudtech.functional.mapper.FuncCarAppMapper; |
|||
import com.inscloudtech.functional.service.IFuncCarAppService; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 兼容可靠性测试系统-应用程序兼容性测试工具Service业务层处理 |
|||
* |
|||
* @author inscloudtech |
|||
* @date 2024-06-17 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class FuncCarAppServiceImpl implements IFuncCarAppService { |
|||
|
|||
private final FuncCarAppMapper baseMapper; |
|||
|
|||
private final FuncCarAppPgMapper pgBaseMapper; |
|||
|
|||
|
|||
/** |
|||
* 查询兼容可靠性测试系统-应用程序兼容性测试工具列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo queryPageList(FuncCarApp bo, PageQuery pageQuery,String dataSource) { |
|||
|
|||
if(dataSource.equals("MYSQL")){ |
|||
LambdaQueryWrapper<FuncCarApp> lqw = buildQueryWrapper(bo); |
|||
Page<FuncCarApp> result = baseMapper.selectPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
}else { |
|||
LambdaQueryWrapper<FuncCarAppPg> lqw = Wrappers.lambdaQuery(); |
|||
lqw.like(StringUtils.isNotBlank(bo.getName()), FuncCarAppPg::getName, bo.getName()); |
|||
lqw.eq(bo.getStatus() != null, FuncCarAppPg::getStatus, bo.getStatus()); |
|||
LoginUser loginUser = LoginHelper.getLoginUser(); |
|||
lqw.eq(FuncCarAppPg::getUserId, loginUser.getUserId()); |
|||
Page<FuncCarAppPg> result = pgBaseMapper.selectPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
private LambdaQueryWrapper<FuncCarApp> buildQueryWrapper(FuncCarApp bo) { |
|||
LambdaQueryWrapper<FuncCarApp> lqw = Wrappers.lambdaQuery(); |
|||
lqw.like(StringUtils.isNotBlank(bo.getName()), FuncCarApp::getName, bo.getName()); |
|||
lqw.eq(bo.getStatus() != null, FuncCarApp::getStatus, bo.getStatus()); |
|||
LoginUser loginUser = LoginHelper.getLoginUser(); |
|||
lqw.eq(FuncCarApp::getUserId, loginUser.getUserId()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(FuncCarApp add,String dataSource) { |
|||
validEntityBeforeSave(add); |
|||
LoginUser loginUser = LoginHelper.getLoginUser(); |
|||
add.setUserId(loginUser.getUserId()); |
|||
add.setCreateTime(new Date()); |
|||
boolean flag ; |
|||
if(dataSource.equals("MYSQL")){ |
|||
flag = baseMapper.insert(add) > 0; |
|||
}else { |
|||
FuncCarAppPg pgAdd = BeanUtil.toBean(add, FuncCarAppPg.class); |
|||
flag = pgBaseMapper.insert(pgAdd) > 0; |
|||
} |
|||
|
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(FuncCarApp bo,String dataSource) { |
|||
validEntityBeforeSave(bo); |
|||
bo.setUpdateTime(new Date()); |
|||
boolean flag ; |
|||
if(dataSource.equals("MYSQL")){ |
|||
flag = baseMapper.updateById(bo) > 0; |
|||
}else { |
|||
FuncCarAppPg pgAdd = BeanUtil.toBean(bo, FuncCarAppPg.class); |
|||
flag = pgBaseMapper.updateById(pgAdd) > 0; |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(FuncCarApp entity){ |
|||
//TODO 做一些数据校验,如唯一约束 |
|||
} |
|||
|
|||
/** |
|||
* 批量删除兼容可靠性测试系统-应用程序兼容性测试工具 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid,String dataSource) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验 |
|||
} |
|||
boolean flag ; |
|||
if(dataSource.equals("MYSQL")){ |
|||
flag = baseMapper.deleteBatchIds(ids) > 0; |
|||
}else { |
|||
flag = pgBaseMapper.deleteBatchIds(ids) > 0; |
|||
} |
|||
return flag; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue