11 changed files with 289 additions and 4 deletions
-
108tp-admin/src/main/java/com/inscloudtech/web/controller/system/TestReportController.java
-
2tp-common/src/main/java/com/inscloudtech/common/annotation/Log.java
-
48tp-common/src/main/java/com/inscloudtech/common/utils/file/FileUploadUtils.java
-
6tp-common/src/main/java/com/inscloudtech/common/utils/file/MimeTypeUtils.java
-
2tp-framework/src/main/java/com/inscloudtech/framework/aspectj/LogAspect.java
-
50tp-functional/src/main/java/com/inscloudtech/functional/domain/TestReport.java
-
18tp-functional/src/main/java/com/inscloudtech/functional/mapper/TestReportMapper.java
-
19tp-functional/src/main/java/com/inscloudtech/functional/service/TestReportService.java
-
36tp-functional/src/main/java/com/inscloudtech/functional/service/impl/TestReportServiceImpl.java
-
2tp-system/src/main/java/com/inscloudtech/system/domain/SysOperLog.java
-
2tp-system/src/main/java/com/inscloudtech/system/service/impl/SysOperLogServiceImpl.java
@ -0,0 +1,108 @@ |
|||||
|
package com.inscloudtech.web.controller.system; |
||||
|
|
||||
|
/***/ |
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.inscloudtech.common.annotation.Log; |
||||
|
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.enums.BusinessType; |
||||
|
import com.inscloudtech.common.utils.file.FileUploadUtils; |
||||
|
import com.inscloudtech.functional.domain.TestReport; |
||||
|
import com.inscloudtech.functional.service.TestReportService; |
||||
|
import com.inscloudtech.system.domain.vo.SysOssVo; |
||||
|
import com.inscloudtech.system.service.ISysOssService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.SneakyThrows; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
/** |
||||
|
* 测试报告管理 |
||||
|
* |
||||
|
* @author zfcf |
||||
|
* @date 2024-08-28 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/functional/testReport") |
||||
|
public class TestReportController { |
||||
|
|
||||
|
private final TestReportService testReportService; |
||||
|
|
||||
|
private final ISysOssService iSysOssService; |
||||
|
|
||||
|
/** |
||||
|
* 分页查询 |
||||
|
* @param |
||||
|
* @param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page" ) |
||||
|
public TableDataInfo<TestReport> page(PageQuery pageQuery, TestReport testReport) { |
||||
|
Page page = new Page(); |
||||
|
page.setSize(pageQuery.getPageSize()); |
||||
|
page.setCurrent(pageQuery.getPageNum()); |
||||
|
Page result = testReportService.page(page, Wrappers.query(testReport)); |
||||
|
TableDataInfo dataInfo = new TableDataInfo(); |
||||
|
dataInfo.setTotal(result.getTotal()); |
||||
|
dataInfo.setRows(result.getRecords()); |
||||
|
return dataInfo; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过id查询测试报告 |
||||
|
* @param id id |
||||
|
* @return R |
||||
|
*/ |
||||
|
@GetMapping("/{id}" ) |
||||
|
public R getById(@PathVariable("id" ) Long id) { |
||||
|
return R.ok(testReportService.getById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 上传测试报告 |
||||
|
* |
||||
|
*/ |
||||
|
@SneakyThrows |
||||
|
@Log(title = "测试报告管理", businessType = BusinessType.INSERT) |
||||
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
|
public R uploadToolAndTips( @RequestPart("file") MultipartFile file, |
||||
|
@RequestPart("reportName") String reportName) { |
||||
|
|
||||
|
if (StrUtil.isEmpty(reportName)) { |
||||
|
return R.fail("报告名称不能为空!"); |
||||
|
} |
||||
|
|
||||
|
testReportService.check(reportName); |
||||
|
TestReport testReport = new TestReport(); |
||||
|
testReport.setReportName(reportName); |
||||
|
if(file != null && FileUploadUtils.checkTxtFileValid(file)){ |
||||
|
SysOssVo toolVo = iSysOssService.upload(file); |
||||
|
testReport.setReportPath(toolVo.getOriginalName()); |
||||
|
testReport.setReportOssId(toolVo.getOssId()); |
||||
|
} |
||||
|
testReportService.save(testReport); |
||||
|
return R.ok("操作成功!"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 通过id删除测试报告 |
||||
|
* @param id id |
||||
|
* @return R |
||||
|
*/ |
||||
|
@DeleteMapping("/{id}" ) |
||||
|
public R removeById(@PathVariable Long id) { |
||||
|
return R.ok(testReportService.removeById(id)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
package com.inscloudtech.functional.domain; |
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.inscloudtech.common.core.domain.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 测试报告管理对象 test_report |
||||
|
* |
||||
|
* @author inscloudtech |
||||
|
* @date 2024-09-02 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("test_report") |
||||
|
public class TestReport extends BaseEntity { |
||||
|
|
||||
|
private static final long serialVersionUID=1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 报告名称 |
||||
|
*/ |
||||
|
@TableField(condition = SqlCondition.LIKE) |
||||
|
private String reportName; |
||||
|
/** |
||||
|
* 报告文件 |
||||
|
*/ |
||||
|
private String reportPath; |
||||
|
/** |
||||
|
* 分析结果文件 |
||||
|
*/ |
||||
|
private String resultPath; |
||||
|
/** |
||||
|
* 报告文件下载id |
||||
|
*/ |
||||
|
private Long reportOssId; |
||||
|
/** |
||||
|
* 分析结果文件下载id |
||||
|
*/ |
||||
|
private Long resultOssId; |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.inscloudtech.functional.mapper; |
||||
|
|
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.inscloudtech.functional.domain.TestReport; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* cpu信息 |
||||
|
* |
||||
|
* @author zfcf |
||||
|
* @date 2024-08-28 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface TestReportMapper extends BaseMapper<TestReport> { |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.inscloudtech.functional.service; |
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.inscloudtech.functional.domain.CpuInfo; |
||||
|
import com.inscloudtech.functional.domain.TestReport; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* cpu信息Service接口 |
||||
|
* @author zfcf |
||||
|
* @date 2024-08-28 |
||||
|
*/ |
||||
|
public interface TestReportService extends IService<TestReport> { |
||||
|
|
||||
|
void check(String reportName); |
||||
|
} |
||||
|
|
@ -0,0 +1,36 @@ |
|||||
|
package com.inscloudtech.functional.service.impl; |
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.inscloudtech.common.exception.ServiceException; |
||||
|
import com.inscloudtech.common.helper.LoginHelper; |
||||
|
import com.inscloudtech.common.utils.file.FileUploadUtils; |
||||
|
import com.inscloudtech.functional.domain.CpuInfo; |
||||
|
import com.inscloudtech.functional.domain.TestReport; |
||||
|
import com.inscloudtech.functional.mapper.CpuInfoMapper; |
||||
|
import com.inscloudtech.functional.mapper.TestReportMapper; |
||||
|
import com.inscloudtech.functional.service.CpuInfoService; |
||||
|
import com.inscloudtech.functional.service.TestReportService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author zfcf |
||||
|
* @date 2024-08-28 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class TestReportServiceImpl extends ServiceImpl<TestReportMapper, TestReport> implements TestReportService { |
||||
|
|
||||
|
@Override |
||||
|
public void check(String reportName) { |
||||
|
TestReport dbObj = baseMapper.selectOne(new LambdaQueryWrapper<TestReport>().eq(TestReport::getReportName, reportName).eq(TestReport::getCreateBy, LoginHelper.getUserId())); |
||||
|
if (ObjectUtil.isNotNull(dbObj)) { |
||||
|
throw new ServiceException("测试报告名称【"+reportName+"】已存在!"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue