16 changed files with 543 additions and 348 deletions
-
147tp-admin/src/main/java/com/inscloudtech/web/controller/system/ToolManageController.java
-
8tp-admin/src/main/resources/application-dev.yml
-
4tp-admin/src/main/resources/application.yml
-
3tp-common/src/main/java/com/inscloudtech/common/utils/DownLoadUtils.java
-
150tp-functional/src/main/java/com/inscloudtech/functional/controller/FuncCarAppController.java
-
14tp-functional/src/main/java/com/inscloudtech/functional/mapper/FuncCarAppMapper.java
-
37tp-functional/src/main/java/com/inscloudtech/functional/service/IFuncCarAppService.java
-
134tp-functional/src/main/java/com/inscloudtech/functional/service/impl/FuncCarAppServiceImpl.java
-
53tp-system/src/main/java/com/inscloudtech/system/domain/ToolManage.java
-
26tp-system/src/main/java/com/inscloudtech/system/domain/vo/DownloadToolRequest.java
-
5tp-system/src/main/java/com/inscloudtech/system/domain/vo/SysOssVo.java
-
56tp-system/src/main/java/com/inscloudtech/system/domain/vo/ToolManageVo.java
-
17tp-system/src/main/java/com/inscloudtech/system/mapper/ToolManageMapper.java
-
59tp-system/src/main/java/com/inscloudtech/system/service/IToolManageService.java
-
1tp-system/src/main/java/com/inscloudtech/system/service/impl/SysOssServiceImpl.java
-
177tp-system/src/main/java/com/inscloudtech/system/service/impl/ToolManageServiceImpl.java
@ -0,0 +1,147 @@ |
|||||
|
package com.inscloudtech.web.controller.system; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.inscloudtech.common.annotation.Log; |
||||
|
import com.inscloudtech.common.annotation.RepeatSubmit; |
||||
|
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.enums.BusinessType; |
||||
|
import com.inscloudtech.common.utils.poi.ExcelUtil; |
||||
|
import com.inscloudtech.system.domain.ToolManage; |
||||
|
import com.inscloudtech.system.domain.vo.DownloadToolRequest; |
||||
|
import com.inscloudtech.system.domain.vo.ToolManageVo; |
||||
|
import com.inscloudtech.system.service.IToolManageService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 测试包管理 |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/system/toolManage") |
||||
|
public class ToolManageController extends BaseController { |
||||
|
|
||||
|
private final IToolManageService iToolManageService; |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理列表 |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<ToolManageVo> list(ToolManage bo, PageQuery pageQuery) { |
||||
|
return iToolManageService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出测试包管理列表 |
||||
|
*/ |
||||
|
@Log(title = "测试包管理", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(ToolManage bo, HttpServletResponse response) { |
||||
|
List<ToolManageVo> list = iToolManageService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "测试包管理", ToolManageVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取测试包管理详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@GetMapping("/{id}") |
||||
|
public R<ToolManageVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable Long id) { |
||||
|
return R.ok(iToolManageService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增测试包 |
||||
|
*/ |
||||
|
@Log(title = "测试包管理", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody ToolManage bo) { |
||||
|
return toAjax(iToolManageService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 新增/修改测试包 |
||||
|
* |
||||
|
*/ |
||||
|
@Log(title = "测试包管理", businessType = BusinessType.INSERT) |
||||
|
@PostMapping(value = "/uploadToolAndTips", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
|
public R uploadToolAndTips(@RequestPart("file") MultipartFile file, |
||||
|
@RequestPart("tipsFile") MultipartFile tipsFile, |
||||
|
@RequestPart("moduleName") String moduleName, |
||||
|
@RequestPart("toolName") String toolName, |
||||
|
@RequestPart("toolManageId") Long toolManageId) { |
||||
|
if (ObjectUtil.isNull(file) && ObjectUtil.isNull(tipsFile) ) { |
||||
|
return R.fail("上传文件不能为空!"); |
||||
|
} |
||||
|
if (StrUtil.isEmpty(moduleName)) { |
||||
|
return R.fail("模块名不能为空!"); |
||||
|
} |
||||
|
if (StrUtil.isEmpty(toolName)) { |
||||
|
return R.fail("文件名不能为空!"); |
||||
|
} |
||||
|
iToolManageService.uploadToolOrTips(file,tipsFile,toolName,moduleName, toolManageId); |
||||
|
return R.ok("上传成功!"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 根据测试模块名称-工具名称下载测试工具/工具操作手册 |
||||
|
*/ |
||||
|
@GetMapping("/downloadTool") |
||||
|
public void downloadTool(DownloadToolRequest downloadToolRequest , HttpServletResponse response) throws IOException { |
||||
|
iToolManageService.downloadByToolName(downloadToolRequest,response); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// /** |
||||
|
// * 修改测试包管理 |
||||
|
// */ |
||||
|
// @Log(title = "测试包管理", businessType = BusinessType.UPDATE) |
||||
|
// @RepeatSubmit() |
||||
|
// @PutMapping() |
||||
|
// public R<Void> edit(@Validated(EditGroup.class) @RequestBody ToolManage bo) { |
||||
|
// return toAjax(iToolManageService.updateByBo(bo)); |
||||
|
// } |
||||
|
|
||||
|
/** |
||||
|
* 删除测试包管理 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("system:manage:remove") |
||||
|
@Log(title = "测试包管理", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable Long[] ids) { |
||||
|
return toAjax(iToolManageService.deleteWithValidByIds(Arrays.asList(ids), true)); |
||||
|
} |
||||
|
} |
||||
|
|
@ -1,150 +0,0 @@ |
|||||
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+ "】"); |
|
||||
} |
|
||||
|
|
||||
void checkDemoAppStatus(){ |
|
||||
if(DEMO_APP_STATUS.equals("STOP")){ |
|
||||
throw new RuntimeException("示例应用程序未启动!"); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 数据库测试-3查询示例数据列表 |
|
||||
*/ |
|
||||
@GetMapping("/demoDataList") |
|
||||
public TableDataInfo list(FuncCarApp bo, PageQuery pageQuery) { |
|
||||
checkDemoAppStatus(); |
|
||||
return iFuncCarAppService.queryPageList(bo, pageQuery,DATA_SOURCE); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 数据库测试-4新增示例数据 |
|
||||
*/ |
|
||||
@RepeatSubmit() |
|
||||
@PostMapping("/demoData") |
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody FuncCarApp bo) { |
|
||||
checkDemoAppStatus(); |
|
||||
return toAjax(iFuncCarAppService.insertByBo(bo,DATA_SOURCE)); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 数据库测试-5修改示例数据 |
|
||||
*/ |
|
||||
@RepeatSubmit() |
|
||||
@PutMapping("/demoData") |
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FuncCarApp bo) { |
|
||||
checkDemoAppStatus(); |
|
||||
return toAjax(iFuncCarAppService.updateByBo(bo,DATA_SOURCE)); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 数据库测试-6删除示例数据 |
|
||||
* |
|
||||
* @param operIds 主键串 |
|
||||
*/ |
|
||||
@DeleteMapping("/demoData/{operIds}") |
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|
||||
@PathVariable Long[] operIds) { |
|
||||
checkDemoAppStatus(); |
|
||||
return toAjax(iFuncCarAppService.deleteWithValidByIds(Arrays.asList(operIds), true,DATA_SOURCE)); |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
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> { |
|
||||
|
|
||||
} |
|
@ -1,37 +0,0 @@ |
|||||
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); |
|
||||
} |
|
@ -1,134 +0,0 @@ |
|||||
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; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,53 @@ |
|||||
|
package com.inscloudtech.system.domain; |
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.inscloudtech.common.core.domain.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 测试包管理对象 tool_manage |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("tool_manage") |
||||
|
public class ToolManage extends BaseEntity { |
||||
|
|
||||
|
private static final long serialVersionUID=1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 功能模块 |
||||
|
*/ |
||||
|
private String moduleName; |
||||
|
/** |
||||
|
* 工具名称 |
||||
|
*/ |
||||
|
private String toolName; |
||||
|
/** |
||||
|
* 测试包 |
||||
|
*/ |
||||
|
private String toolPath; |
||||
|
/** |
||||
|
* 操作手册 |
||||
|
*/ |
||||
|
private String tipsPath; |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private Long toolOssId; |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private Long tipsOssId; |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.inscloudtech.system.domain.vo; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
@Data |
||||
|
public class DownloadToolRequest { |
||||
|
|
||||
|
/** |
||||
|
* 模块名称 |
||||
|
*/ |
||||
|
@NotNull(message = "模块名称不能为空") |
||||
|
private String moduleName; |
||||
|
/** |
||||
|
* 工具名称 |
||||
|
*/ |
||||
|
@NotNull(message = "工具名称不能为空") |
||||
|
private String toolName; |
||||
|
|
||||
|
/** |
||||
|
* 下载类型-0工具/1操作手册 |
||||
|
*/ |
||||
|
@NotNull(message = "下载类型不能为空") |
||||
|
private String type; |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package com.inscloudtech.system.domain.vo; |
||||
|
|
||||
|
|
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import com.inscloudtech.common.annotation.ExcelDictFormat; |
||||
|
import com.inscloudtech.common.convert.ExcelDictConvert; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 测试包管理视图对象 tool_manage |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
public class ToolManageVo implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "主键") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 功能模块 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "功能模块") |
||||
|
private String moduleName; |
||||
|
|
||||
|
/** |
||||
|
* 工具名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "工具名称") |
||||
|
private String toolName; |
||||
|
|
||||
|
/** |
||||
|
* 测试包 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "测试包") |
||||
|
private String toolPath; |
||||
|
|
||||
|
/** |
||||
|
* 操作手册 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "操作手册") |
||||
|
private String tipsPath; |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.inscloudtech.system.mapper; |
||||
|
|
||||
|
|
||||
|
import com.inscloudtech.system.domain.ToolManage; |
||||
|
import com.inscloudtech.system.domain.vo.ToolManageVo; |
||||
|
import com.inscloudtech.common.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 测试包管理Mapper接口 |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
public interface ToolManageMapper extends BaseMapperPlus<ToolManageMapper, ToolManage, ToolManageVo> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,59 @@ |
|||||
|
package com.inscloudtech.system.service; |
||||
|
|
||||
|
|
||||
|
|
||||
|
import com.inscloudtech.system.domain.ToolManage; |
||||
|
import com.inscloudtech.system.domain.vo.DownloadToolRequest; |
||||
|
import com.inscloudtech.system.domain.vo.ToolManageVo; |
||||
|
import com.inscloudtech.common.core.page.TableDataInfo; |
||||
|
import com.inscloudtech.common.core.domain.PageQuery; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 测试包管理Service接口 |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
public interface IToolManageService { |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理 |
||||
|
*/ |
||||
|
ToolManageVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理列表 |
||||
|
*/ |
||||
|
TableDataInfo<ToolManageVo> queryPageList(ToolManage bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理列表 |
||||
|
*/ |
||||
|
List<ToolManageVo> queryList(ToolManage bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增测试包管理 |
||||
|
*/ |
||||
|
Boolean insertByBo(ToolManage bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改测试包管理 |
||||
|
*/ |
||||
|
Boolean updateByBo(ToolManage bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除测试包管理信息 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
|
||||
|
Boolean uploadToolOrTips(MultipartFile file, MultipartFile tipsFile, String toolName,String moduleName,Long toolManageId); |
||||
|
|
||||
|
void downloadByToolName(DownloadToolRequest downloadToolRequest,HttpServletResponse response); |
||||
|
} |
||||
|
|
@ -0,0 +1,177 @@ |
|||||
|
package com.inscloudtech.system.service.impl; |
||||
|
|
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
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.exception.ServiceException; |
||||
|
import com.inscloudtech.system.domain.SysOss; |
||||
|
import com.inscloudtech.system.domain.vo.DownloadToolRequest; |
||||
|
import com.inscloudtech.system.domain.vo.SysOssVo; |
||||
|
import com.inscloudtech.system.service.ISysOssService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.SneakyThrows; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.inscloudtech.system.domain.vo.ToolManageVo; |
||||
|
import com.inscloudtech.system.domain.ToolManage; |
||||
|
import com.inscloudtech.system.mapper.ToolManageMapper; |
||||
|
import com.inscloudtech.system.service.IToolManageService; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
/** |
||||
|
* 测试包管理Service业务层处理 |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-08-08 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class ToolManageServiceImpl implements IToolManageService { |
||||
|
|
||||
|
private final ToolManageMapper baseMapper; |
||||
|
|
||||
|
private final ISysOssService iSysOssService; |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理 |
||||
|
*/ |
||||
|
@Override |
||||
|
public ToolManageVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<ToolManageVo> queryPageList(ToolManage bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<ToolManage> lqw = buildQueryWrapper(bo); |
||||
|
Page<ToolManageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询测试包管理列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ToolManageVo> queryList(ToolManage bo) { |
||||
|
LambdaQueryWrapper<ToolManage> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<ToolManage> buildQueryWrapper(ToolManage bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<ToolManage> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.like(StrUtil.isNotBlank(bo.getModuleName()), ToolManage::getModuleName, bo.getModuleName()); |
||||
|
lqw.like(StrUtil.isNotBlank(bo.getToolName()), ToolManage::getToolName, bo.getToolName()); |
||||
|
lqw.eq(StrUtil.isNotBlank(bo.getToolPath()), ToolManage::getToolPath, bo.getToolPath()); |
||||
|
lqw.eq(StrUtil.isNotBlank(bo.getTipsPath()), ToolManage::getTipsPath, bo.getTipsPath()); |
||||
|
lqw.eq(bo.getToolOssId() != null, ToolManage::getToolOssId, bo.getToolOssId()); |
||||
|
lqw.eq(bo.getTipsOssId() != null, ToolManage::getTipsOssId, bo.getTipsOssId()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增测试包管理 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(ToolManage bo) { |
||||
|
ToolManage add = BeanUtil.toBean(bo, ToolManage.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改测试包管理 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(ToolManage bo) { |
||||
|
ToolManage update = BeanUtil.toBean(bo, ToolManage.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(ToolManage entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束 |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量删除测试包管理 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验 |
||||
|
} |
||||
|
return baseMapper.deleteBatchIds(ids) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Boolean uploadToolOrTips(MultipartFile file, MultipartFile tipsFile, String toolName,String moduleName,Long toolManageId) { |
||||
|
ToolManage toolManage; |
||||
|
if(null != toolManageId && toolManageId != 0L){ |
||||
|
toolManage = baseMapper.selectById(toolManageId); |
||||
|
if (ObjectUtil.isNotNull(toolManage)) { |
||||
|
throw new ServiceException("修改对象不存在!"); |
||||
|
} |
||||
|
}else { |
||||
|
ToolManage dbObj = baseMapper.selectOne(new LambdaQueryWrapper<ToolManage>().eq(ToolManage::getToolName, toolName).eq(ToolManage::getModuleName, moduleName)); |
||||
|
if (ObjectUtil.isNotNull(dbObj)) { |
||||
|
throw new ServiceException("工具名称【"+toolName+"】已存在!"); |
||||
|
} |
||||
|
toolManage = new ToolManage(); |
||||
|
} |
||||
|
SysOssVo toolVo = iSysOssService.upload(file); |
||||
|
SysOssVo tipsVo = iSysOssService.upload(tipsFile); |
||||
|
toolManage.setToolName(toolName); |
||||
|
toolManage.setModuleName(moduleName); |
||||
|
toolManage.setToolOssId(toolVo.getOssId()); |
||||
|
toolManage.setToolPath(toolVo.getOriginalName()); |
||||
|
toolManage.setTipsOssId(tipsVo.getOssId()); |
||||
|
toolManage.setTipsPath(tipsVo.getOriginalName()); |
||||
|
if(null != toolManageId && toolManageId != 0L){ |
||||
|
baseMapper.updateById(toolManage); |
||||
|
}else { |
||||
|
baseMapper.insert(toolManage); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
@SneakyThrows |
||||
|
@Override |
||||
|
public void downloadByToolName(DownloadToolRequest request, HttpServletResponse response) { |
||||
|
|
||||
|
ToolManage dbObj = baseMapper.selectOne(new LambdaQueryWrapper<ToolManage>().eq(ToolManage::getToolName, request.getToolName()) |
||||
|
.eq(ToolManage::getModuleName, request.getModuleName())); |
||||
|
if (ObjectUtil.isNull(dbObj)) { |
||||
|
throw new ServiceException("文件数据不存在!"); |
||||
|
} |
||||
|
|
||||
|
if(request.getType().equals("0")){ |
||||
|
iSysOssService.download(dbObj.getToolOssId(),response); |
||||
|
}else if(request.getType().equals("1")){ |
||||
|
iSysOssService.download(dbObj.getToolOssId(),response); |
||||
|
}else { |
||||
|
throw new ServiceException("非法下载类型!"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue