From 7025c84a586f9000ac4f0774ebfe170aaa5145db Mon Sep 17 00:00:00 2001 From: mazxd Date: Sun, 6 Apr 2025 18:24:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=81=E7=A7=BB1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mzaxd/bps/aspect/SysLogAspect.java | 95 +++++------ .../mzaxd/bps/controller/AuthController.java | 43 ----- .../bps/controller/DashboardController.java | 37 ---- .../mzaxd/bps/controller/LogController.java | 34 ---- .../controller/NotificationController.java | 40 ----- .../mzaxd/bps/controller/OtherController.java | 65 ------- .../bps/controller/SettingController.java | 35 ---- .../controller/SourceCategoryController.java | 50 ++++++ .../bps/controller/SourceController.java | 72 ++++++++ .../bps/controller/SourceLogController.java | 42 +++++ .../bps/controller/SystemController.java | 26 --- .../mzaxd/bps/controller/UserController.java | 49 ------ .../java/com/mzaxd/bps/domain/CloudFile.java | 71 +------- .../mzaxd/bps/domain/CloudStorageFactory.java | 28 +++ .../com/mzaxd/bps/domain/entity/Source.java | 96 +++++++++++ .../bps/domain/entity/SourceCategory.java | 50 ++++++ .../mzaxd/bps/domain/entity/SourceLog.java | 39 +++++ .../java/com/mzaxd/bps/domain/vo/PageVo.java | 28 +++ .../mzaxd/bps/domain/vo/SourceCategoryVo.java | 48 ++++++ .../com/mzaxd/bps/domain/vo/SourceLogVo.java | 43 +++++ .../com/mzaxd/bps/domain/vo/SourceVo.java | 93 ++++++++++ .../com/mzaxd/bps/enums/BaiduPcsCommand.java | 24 +++ .../com/mzaxd/bps/enums/CloudStorageType.java | 24 +++ .../bps/mapper/SourceCategoryMapper.java | 15 ++ .../com/mzaxd/bps/mapper/SourceLogMapper.java | 15 ++ .../com/mzaxd/bps/mapper/SourceMapper.java | 15 ++ .../mzaxd/bps/service/AuditLogService.java | 37 ---- .../bps/service/CloudStorageService.java | 57 +++++++ .../mzaxd/bps/service/DashboardService.java | 31 ---- .../com/mzaxd/bps/service/LoginService.java | 45 ----- .../bps/service/NotificationService.java | 36 ---- .../bps/service/SourceCategoryService.java | 47 +++++ .../mzaxd/bps/service/SourceLogService.java | 34 ++++ .../com/mzaxd/bps/service/SourceService.java | 59 +++++++ .../bps/service/SystemSettingService.java | 59 ------- .../com/mzaxd/bps/service/UserService.java | 67 -------- .../bps/service/impl/AuditLogServiceImpl.java | 75 -------- .../bps/service/impl/BaiduPcsService.java | 160 ++++++++++++++++++ .../bps/service/impl/LoginServiceImpl.java | 90 ---------- .../service/impl/NotificationServiceImpl.java | 69 -------- .../impl/SourceCategoryServiceImpl.java | 57 +++++++ .../service/impl/SourceLogServiceImpl.java | 75 ++++++++ .../bps/service/impl/SourceServiceImpl.java | 119 +++++++++++++ .../impl/SystemSettingServiceImpl.java | 84 --------- .../service/impl/UserDetailServiceImpl.java | 47 ----- .../bps/service/impl/UserServiceImpl.java | 95 ----------- src/main/java/com/mzaxd/bps/util/Result.java | 63 +++++++ .../mzaxd/bps/util/SystemSettingUtils.java | 51 ------ src/main/java/com/mzaxd/bps/util/UrlUtil.java | 56 ------ 49 files changed, 1401 insertions(+), 1289 deletions(-) delete mode 100644 src/main/java/com/mzaxd/bps/controller/AuthController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/DashboardController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/LogController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/NotificationController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/OtherController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/SettingController.java create mode 100644 src/main/java/com/mzaxd/bps/controller/SourceCategoryController.java create mode 100644 src/main/java/com/mzaxd/bps/controller/SourceController.java create mode 100644 src/main/java/com/mzaxd/bps/controller/SourceLogController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/SystemController.java delete mode 100644 src/main/java/com/mzaxd/bps/controller/UserController.java create mode 100644 src/main/java/com/mzaxd/bps/domain/CloudStorageFactory.java create mode 100644 src/main/java/com/mzaxd/bps/domain/entity/Source.java create mode 100644 src/main/java/com/mzaxd/bps/domain/entity/SourceCategory.java create mode 100644 src/main/java/com/mzaxd/bps/domain/entity/SourceLog.java create mode 100644 src/main/java/com/mzaxd/bps/domain/vo/PageVo.java create mode 100644 src/main/java/com/mzaxd/bps/domain/vo/SourceCategoryVo.java create mode 100644 src/main/java/com/mzaxd/bps/domain/vo/SourceLogVo.java create mode 100644 src/main/java/com/mzaxd/bps/domain/vo/SourceVo.java create mode 100644 src/main/java/com/mzaxd/bps/enums/BaiduPcsCommand.java create mode 100644 src/main/java/com/mzaxd/bps/enums/CloudStorageType.java create mode 100644 src/main/java/com/mzaxd/bps/mapper/SourceCategoryMapper.java create mode 100644 src/main/java/com/mzaxd/bps/mapper/SourceLogMapper.java create mode 100644 src/main/java/com/mzaxd/bps/mapper/SourceMapper.java delete mode 100644 src/main/java/com/mzaxd/bps/service/AuditLogService.java create mode 100644 src/main/java/com/mzaxd/bps/service/CloudStorageService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/DashboardService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/LoginService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/NotificationService.java create mode 100644 src/main/java/com/mzaxd/bps/service/SourceCategoryService.java create mode 100644 src/main/java/com/mzaxd/bps/service/SourceLogService.java create mode 100644 src/main/java/com/mzaxd/bps/service/SourceService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/SystemSettingService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/UserService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/AuditLogServiceImpl.java create mode 100644 src/main/java/com/mzaxd/bps/service/impl/BaiduPcsService.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/LoginServiceImpl.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/NotificationServiceImpl.java create mode 100644 src/main/java/com/mzaxd/bps/service/impl/SourceCategoryServiceImpl.java create mode 100644 src/main/java/com/mzaxd/bps/service/impl/SourceLogServiceImpl.java create mode 100644 src/main/java/com/mzaxd/bps/service/impl/SourceServiceImpl.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/SystemSettingServiceImpl.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/UserDetailServiceImpl.java delete mode 100644 src/main/java/com/mzaxd/bps/service/impl/UserServiceImpl.java create mode 100644 src/main/java/com/mzaxd/bps/util/Result.java delete mode 100644 src/main/java/com/mzaxd/bps/util/SystemSettingUtils.java delete mode 100644 src/main/java/com/mzaxd/bps/util/UrlUtil.java diff --git a/src/main/java/com/mzaxd/bps/aspect/SysLogAspect.java b/src/main/java/com/mzaxd/bps/aspect/SysLogAspect.java index de4232d..8d72987 100644 --- a/src/main/java/com/mzaxd/bps/aspect/SysLogAspect.java +++ b/src/main/java/com/mzaxd/bps/aspect/SysLogAspect.java @@ -1,20 +1,9 @@ package com.mzaxd.bps.aspect; -import com.alibaba.fastjson.JSON; -import com.mzaxd.bps.annotation.SysLog; -import com.mzaxd.bps.domain.entity.AuditLog; -import com.mzaxd.bps.service.AuditLogService; import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; -import javax.annotation.Resource; -import java.lang.reflect.Method; - /** * @author 13439 */ @@ -23,46 +12,46 @@ import java.lang.reflect.Method; @Slf4j public class SysLogAspect { - @Resource - private AuditLogService auditLogService; - - @Pointcut("@annotation(com.mzaxd.bps.annotation.SysLog)") - public void logPointCut() { - - } - - //方法执行前后都操作 - @Around("logPointCut()") - public Object around(ProceedingJoinPoint point) throws Throwable { - //执行方法 - Object result = point.proceed(); - //保存日志 - saveSysLog(point); - return result; - } - - private void saveSysLog(ProceedingJoinPoint joinPoint) { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); - - AuditLog auditLog = new AuditLog(); - SysLog syslog = method.getAnnotation(SysLog.class); - if (syslog != null) { - //注解上的描述 - auditLog.setOperation(syslog.operation().getOperation()); - auditLog.setOperationType(syslog.operation().getOperationType()); - } - - //请求的参数 - Object[] args = joinPoint.getArgs(); - try { - String params = JSON.toJSONString(args); - auditLog.setParam(params); - } catch (Exception e) { - log.error(e.getMessage()); - } - - //保存系统日志 - auditLogService.save(auditLog); - } +// @Resource +// private AuditLogService auditLogService; +// +// @Pointcut("@annotation(com.mzaxd.bps.annotation.SysLog)") +// public void logPointCut() { +// +// } +// +// //方法执行前后都操作 +// @Around("logPointCut()") +// public Object around(ProceedingJoinPoint point) throws Throwable { +// //执行方法 +// Object result = point.proceed(); +// //保存日志 +// saveSysLog(point); +// return result; +// } +// +// private void saveSysLog(ProceedingJoinPoint joinPoint) { +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); +// Method method = signature.getMethod(); +// +// AuditLog auditLog = new AuditLog(); +// SysLog syslog = method.getAnnotation(SysLog.class); +// if (syslog != null) { +// //注解上的描述 +// auditLog.setOperation(syslog.operation().getOperation()); +// auditLog.setOperationType(syslog.operation().getOperationType()); +// } +// +// //请求的参数 +// Object[] args = joinPoint.getArgs(); +// try { +// String params = JSON.toJSONString(args); +// auditLog.setParam(params); +// } catch (Exception e) { +// log.error(e.getMessage()); +// } +// +// //保存系统日志 +// auditLogService.save(auditLog); +// } } diff --git a/src/main/java/com/mzaxd/bps/controller/AuthController.java b/src/main/java/com/mzaxd/bps/controller/AuthController.java deleted file mode 100644 index 8eb4d1b..0000000 --- a/src/main/java/com/mzaxd/bps/controller/AuthController.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.annotation.SysLog; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.User; -import com.mzaxd.bps.enums.OperationEnum; -import com.mzaxd.bps.service.LoginService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -/** - * @author root - */ -@RestController -@RequestMapping("/auth") -public class AuthController { - - @Resource - private LoginService loginService; - - @PostMapping("/login") - public ResponseResult login(@RequestBody User user) { - return loginService.login(user); - } - - @SysLog(operation = OperationEnum.USER_FIRST_USE) - @PostMapping("/updateAccount") - public ResponseResult updateAccount(@RequestBody User user) { - return loginService.updateAccount(user); - } - - @PostMapping("/logout") - public ResponseResult logout() { - return loginService.logout(); - } - - @GetMapping("/deleteAccount") - public ResponseResult deleteAccount() { - return loginService.deleteAccount(); - } - -} diff --git a/src/main/java/com/mzaxd/bps/controller/DashboardController.java b/src/main/java/com/mzaxd/bps/controller/DashboardController.java deleted file mode 100644 index 4c1c6af..0000000 --- a/src/main/java/com/mzaxd/bps/controller/DashboardController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.service.DashboardService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ - -@RestController -@RequestMapping("/dashboard") -public class DashboardController { - - @Resource - private DashboardService dashboardService; - - @GetMapping("/getInstancesRealTimeData") - public ResponseResult getInstancesRealTimeData() { - return dashboardService.getInstancesRealTimeData(); - } - - @GetMapping("/getRecentConsoleList") - public ResponseResult getRecentConsoleList() { - return dashboardService.getRecentConsoleList(); - } - - @GetMapping("/getAffectedServirList") - public ResponseResult getAffectedServirList() { - return dashboardService.getAffectedServirList(); - } - -} diff --git a/src/main/java/com/mzaxd/bps/controller/LogController.java b/src/main/java/com/mzaxd/bps/controller/LogController.java deleted file mode 100644 index 886384d..0000000 --- a/src/main/java/com/mzaxd/bps/controller/LogController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.service.AuditLogService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ -@RestController -@RequestMapping("/auditLog") -public class LogController { - - @Resource - private AuditLogService auditLogService; - - @GetMapping("/logList") - public ResponseResult getLogList(@RequestParam("perPage") Integer perPage, - @RequestParam("currentPage") Integer currentPage) { - return auditLogService.getLogList(perPage, currentPage); - } - - @GetMapping("/getParam/{id}") - public ResponseResult getParam(@PathVariable("id") Integer id) { - return auditLogService.getParam(id); - } - - @GetMapping("/userLog") - public ResponseResult getUserLog() { - return auditLogService.getUserLog(); - } -} diff --git a/src/main/java/com/mzaxd/bps/controller/NotificationController.java b/src/main/java/com/mzaxd/bps/controller/NotificationController.java deleted file mode 100644 index c43a992..0000000 --- a/src/main/java/com/mzaxd/bps/controller/NotificationController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.annotation.SysLog; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.enums.OperationEnum; -import com.mzaxd.bps.service.NotificationService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ -@RestController -@RequestMapping("/notification") -public class NotificationController { - - @Resource - private NotificationService notificationService; - - @GetMapping("/notificationList") - public ResponseResult getNotificationList( - @RequestParam(value = "tab", required = false) Integer tab, - @RequestParam("perPage") Integer perPage, - @RequestParam("currentPage") Integer currentPage) { - return notificationService.getNotificationList(tab, perPage, currentPage); - } - - @SysLog(operation = OperationEnum.NOTIFICATION_AFFIRM) - @PutMapping("/{id}") - public ResponseResult affirmNotification(@PathVariable("id") Long id) { - return notificationService.affirmNotification(id); - } - - @GetMapping("/count") - public ResponseResult getNotificationCount() { - return notificationService.getNotificationCount(); - } - -} diff --git a/src/main/java/com/mzaxd/bps/controller/OtherController.java b/src/main/java/com/mzaxd/bps/controller/OtherController.java deleted file mode 100644 index 70ce77f..0000000 --- a/src/main/java/com/mzaxd/bps/controller/OtherController.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.search.SearchCategory; -import com.mzaxd.bps.domain.search.SearchItem; -import com.mzaxd.bps.util.SearchUtil; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author ThinkBook - */ - -@RestController -public class OtherController { - - /** - * 全局搜索功能的接口 - * - * @param str - * @return - */ - @GetMapping("/app-bar/search") - public ResponseResult searchbar(@RequestParam("q") String str) { - List searchCategories = SearchUtil.getSearchCategory(); - - List result = new ArrayList<>(); - - for (SearchCategory category : searchCategories) { - result.add(category); - List searchItems = null; - switch (category) { - case INSTANCE: - searchItems = SearchUtil.getInstanceSearchItem(); - break; - case STATISTICS: - searchItems = SearchUtil.getStatisticsSearchItem(); - break; - case SETTING: - searchItems = SearchUtil.getSettingSearchItem(); - break; - case OTHER: - searchItems = SearchUtil.getOtherSearchItem(); - break; - default: - break; - } - if (searchItems != null) { - List filteredItems = searchItems.stream() - .filter(item -> item.getTitle().contains(str)) - .toList(); - if (!filteredItems.isEmpty()) { - result.addAll(filteredItems); - } else { - result.remove(result.size() - 1); - } - } - } - return ResponseResult.success(result); - } -} diff --git a/src/main/java/com/mzaxd/bps/controller/SettingController.java b/src/main/java/com/mzaxd/bps/controller/SettingController.java deleted file mode 100644 index 81c5df2..0000000 --- a/src/main/java/com/mzaxd/bps/controller/SettingController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.service.SystemSettingService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ -@RestController -@RequestMapping("/setting") -public class SettingController { - - @Resource - private SystemSettingService systemSettingService; - - @GetMapping("/smtp") - public ResponseResult getSmtpSetting() { - return systemSettingService.getSmtpSetting(); - } - - @GetMapping("/terminal") - public ResponseResult getTerminalSetting() { - return systemSettingService.getTerminalSetting(); - } - - - @GetMapping("/system") - public ResponseResult getSystemSetting() { - return systemSettingService.getSystemSetting(); - } - -} diff --git a/src/main/java/com/mzaxd/bps/controller/SourceCategoryController.java b/src/main/java/com/mzaxd/bps/controller/SourceCategoryController.java new file mode 100644 index 0000000..7668bcd --- /dev/null +++ b/src/main/java/com/mzaxd/bps/controller/SourceCategoryController.java @@ -0,0 +1,50 @@ +package com.mzaxd.bps.controller; + +import com.mzaxd.bps.domain.entity.SourceCategory; +import com.mzaxd.bps.domain.vo.SourceCategoryVo; +import com.mzaxd.bps.service.SourceCategoryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 网盘分类表(SourceCategory)表控制层 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@RestController +@RequestMapping("/api/source/category") +@Api(tags = "网盘分类管理") +public class SourceCategoryController { + + @Autowired + private SourceCategoryService sourceCategoryService; + + @GetMapping("/list") + @ApiOperation("获取分类列表") + public List getCategoryList() { + return sourceCategoryService.getCategoryList(); + } + + @PostMapping + @ApiOperation("新增分类") + public boolean addCategory(@RequestBody SourceCategory category) { + return sourceCategoryService.addCategory(category); + } + + @PutMapping + @ApiOperation("更新分类") + public boolean updateCategory(@RequestBody SourceCategory category) { + return sourceCategoryService.updateCategory(category); + } + + @DeleteMapping("/{id}") + @ApiOperation("删除分类") + public boolean deleteCategory(@PathVariable Long id) { + return sourceCategoryService.deleteCategory(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/controller/SourceController.java b/src/main/java/com/mzaxd/bps/controller/SourceController.java new file mode 100644 index 0000000..5b2bc12 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/controller/SourceController.java @@ -0,0 +1,72 @@ +package com.mzaxd.bps.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mzaxd.bps.domain.entity.Source; +import com.mzaxd.bps.service.SourceService; +import com.mzaxd.bps.util.Result; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 网盘资源Controller + * + * @author mzaxd + * @since 2024-04-06 + */ +@RestController +@RequestMapping("/source") +public class SourceController { + + @Resource + private SourceService sourceService; + + /** + * 分页查询网盘资源 + */ + @GetMapping("/page") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String title, + @RequestParam(required = false) Long sourceCategoryId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(title != null, Source::getTitle, title) + .eq(sourceCategoryId != null, Source::getSourceCategoryId, sourceCategoryId) + .orderByDesc(Source::getCreateTime); + return Result.success(sourceService.page(new Page<>(pageNum, pageSize), queryWrapper)); + } + + /** + * 获取网盘资源详情 + */ + @GetMapping("/{id}") + public Result getById(@PathVariable Long id) { + return Result.success(sourceService.getById(id)); + } + + /** + * 新增网盘资源 + */ + @PostMapping + public Result save(@RequestBody Source source) { + return Result.success(sourceService.save(source)); + } + + /** + * 修改网盘资源 + */ + @PutMapping + public Result updateById(@RequestBody Source source) { + return Result.success(sourceService.updateById(source)); + } + + /** + * 删除网盘资源 + */ + @DeleteMapping("/{id}") + public Result removeById(@PathVariable Long id) { + return Result.success(sourceService.removeById(id)); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/controller/SourceLogController.java b/src/main/java/com/mzaxd/bps/controller/SourceLogController.java new file mode 100644 index 0000000..b312e15 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/controller/SourceLogController.java @@ -0,0 +1,42 @@ +package com.mzaxd.bps.controller; + +import com.mzaxd.bps.domain.vo.PageVo; +import com.mzaxd.bps.domain.vo.SourceLogVo; +import com.mzaxd.bps.service.SourceLogService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; + +/** + * 网盘日志表(SourceLog)表控制层 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@RestController +@RequestMapping("/api/source/log") +@Api(tags = "网盘日志管理") +public class SourceLogController { + + @Autowired + private SourceLogService sourceLogService; + + @GetMapping("/list") + @ApiOperation("获取日志列表") + public PageVo getLogList( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) Long sourceId) { + return sourceLogService.getLogList(pageNum, pageSize, sourceId); + } + + @PostMapping("/{sourceId}") + @ApiOperation("添加日志") + public boolean addLog(@PathVariable Long sourceId, HttpServletRequest request) { + String ip = request.getRemoteAddr(); + return sourceLogService.addLog(sourceId, ip); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/controller/SystemController.java b/src/main/java/com/mzaxd/bps/controller/SystemController.java deleted file mode 100644 index 4ade8a1..0000000 --- a/src/main/java/com/mzaxd/bps/controller/SystemController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.service.UserService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ - -@RestController -@RequestMapping("/system") -public class SystemController { - - @Resource - private UserService userService; - - @RequestMapping("/isFirstUse") - private ResponseResult isFirstUse() { - return userService.isFirstUse(); - } - -} diff --git a/src/main/java/com/mzaxd/bps/controller/UserController.java b/src/main/java/com/mzaxd/bps/controller/UserController.java deleted file mode 100644 index c999575..0000000 --- a/src/main/java/com/mzaxd/bps/controller/UserController.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.mzaxd.bps.controller; - -import com.mzaxd.bps.annotation.SysLog; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.User; -import com.mzaxd.bps.enums.OperationEnum; -import com.mzaxd.bps.service.UserService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * @author root - */ -@RestController -@RequestMapping("/user") -public class UserController { - - @Resource - private UserService userService; - - @GetMapping("/userInfo") - public ResponseResult userInfo() { - return userService.userInfo(); - } - - @PutMapping("/userInfo") - public ResponseResult updateUserInfo(@RequestBody User user) { - return userService.updateUserInfo(user); - } - - @GetMapping("/profile") - public ResponseResult profile() { - return userService.getProfile(); - } - - @GetMapping("/{id}") - public ResponseResult getUserInfo(@PathVariable("id") Integer id) { - return userService.getUserInfo(id); - } - - @SysLog(operation = OperationEnum.USER_UPDATE_PASSWORD) - @PostMapping("/changePassword") - public ResponseResult changePassword(@RequestBody Map map) { - return userService.changePassword(map.get("password")); - } - -} diff --git a/src/main/java/com/mzaxd/bps/domain/CloudFile.java b/src/main/java/com/mzaxd/bps/domain/CloudFile.java index a4131e8..ad9ae55 100644 --- a/src/main/java/com/mzaxd/bps/domain/CloudFile.java +++ b/src/main/java/com/mzaxd/bps/domain/CloudFile.java @@ -1,7 +1,12 @@ package com.mzaxd.bps.domain; +import lombok.Getter; +import lombok.Setter; + import java.time.LocalDateTime; +@Setter +@Getter public class CloudFile { private String id; private String name; @@ -12,68 +17,4 @@ public class CloudFile { private String md5; private String shareLink; - // Getters and Setters - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public LocalDateTime getCreateTime() { - return createTime; - } - - public void setCreateTime(LocalDateTime createTime) { - this.createTime = createTime; - } - - public LocalDateTime getModifyTime() { - return modifyTime; - } - - public void setModifyTime(LocalDateTime modifyTime) { - this.modifyTime = modifyTime; - } - - public String getMd5() { - return md5; - } - - public void setMd5(String md5) { - this.md5 = md5; - } - - public String getShareLink() { - return shareLink; - } - - public void setShareLink(String shareLink) { - this.shareLink = shareLink; - } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/CloudStorageFactory.java b/src/main/java/com/mzaxd/bps/domain/CloudStorageFactory.java new file mode 100644 index 0000000..f6caafd --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/CloudStorageFactory.java @@ -0,0 +1,28 @@ +package com.mzaxd.bps.domain; + +import com.mzaxd.bps.service.impl.BaiduPcsService; +import com.mzaxd.bps.enums.CloudStorageType; +import com.mzaxd.bps.service.CloudStorageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class CloudStorageFactory { + private final Map services = new HashMap<>(); + + @Autowired + public CloudStorageFactory(BaiduPcsService baiduPcsService) { + services.put(CloudStorageType.BAIDU, baiduPcsService); + } + + public CloudStorageService getService(CloudStorageType type) { + CloudStorageService service = services.get(type); + if (service == null) { + throw new IllegalArgumentException("Unsupported cloud storage type: " + type); + } + return service; + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/entity/Source.java b/src/main/java/com/mzaxd/bps/domain/entity/Source.java new file mode 100644 index 0000000..6f223af --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/entity/Source.java @@ -0,0 +1,96 @@ +package com.mzaxd.bps.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 网盘资源实体类 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Data +@TableName("source") +public class Source { + + /** + * 主键ID + */ + @TableId(type = IdType.AUTO) + private Long sourceId; + + /** + * 分类ID + */ + private Long sourceCategoryId; + + /** + * 资源标题 + */ + private String title; + + /** + * 资源描述 + */ + private String description; + + /** + * 资源URL + */ + private String url; + + /** + * 资源代码 + */ + private String code; + + /** + * 视频内容 + */ + private String vodContent; + + /** + * 视频封面 + */ + private String vodPic; + + /** + * 资源类型 + */ + private Integer isType; + + /** + * 是否定时 + */ + private Integer isTime; + + /** + * 是否删除 + */ + @TableLogic + private Integer isDelete; + + /** + * 状态 + */ + private Integer status; + + /** + * 浏览量 + */ + private Integer pageViews; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/entity/SourceCategory.java b/src/main/java/com/mzaxd/bps/domain/entity/SourceCategory.java new file mode 100644 index 0000000..fcb2ad1 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/entity/SourceCategory.java @@ -0,0 +1,50 @@ +package com.mzaxd.bps.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 网盘分类实体类 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Data +@TableName("source_category") +public class SourceCategory { + + /** + * 主键ID + */ + @TableId(type = IdType.AUTO) + private Long sourceCategoryId; + + /** + * 分类名称 + */ + private String name; + + /** + * 排序 + */ + private Integer sort; + + /** + * 状态 + */ + private Integer status; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/entity/SourceLog.java b/src/main/java/com/mzaxd/bps/domain/entity/SourceLog.java new file mode 100644 index 0000000..993e0a1 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/entity/SourceLog.java @@ -0,0 +1,39 @@ +package com.mzaxd.bps.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 网盘日志实体类 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Data +@TableName("source_log") +public class SourceLog { + + /** + * 主键ID + */ + @TableId(type = IdType.AUTO) + private Long logId; + + /** + * 资源ID + */ + private Long sourceId; + + /** + * IP地址 + */ + private String ip; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/vo/PageVo.java b/src/main/java/com/mzaxd/bps/domain/vo/PageVo.java new file mode 100644 index 0000000..1385dd0 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/vo/PageVo.java @@ -0,0 +1,28 @@ +package com.mzaxd.bps.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 分页结果封装类 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PageVo { + /** + * 总记录数 + */ + private Long total; + + /** + * 数据列表 + */ + private List rows; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/vo/SourceCategoryVo.java b/src/main/java/com/mzaxd/bps/domain/vo/SourceCategoryVo.java new file mode 100644 index 0000000..b65a346 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/vo/SourceCategoryVo.java @@ -0,0 +1,48 @@ +package com.mzaxd.bps.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 网盘分类返回对象 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SourceCategoryVo { + /** + * 分类ID + */ + private Long id; + + /** + * 分类名称 + */ + private String name; + + /** + * 排序 + */ + private Integer sort; + + /** + * 状态 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/vo/SourceLogVo.java b/src/main/java/com/mzaxd/bps/domain/vo/SourceLogVo.java new file mode 100644 index 0000000..7b5d916 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/vo/SourceLogVo.java @@ -0,0 +1,43 @@ +package com.mzaxd.bps.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 网盘日志返回对象 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SourceLogVo { + /** + * 日志ID + */ + private Long id; + + /** + * 资源ID + */ + private Long sourceId; + + /** + * 资源标题 + */ + private String sourceTitle; + + /** + * IP地址 + */ + private String ip; + + /** + * 创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/domain/vo/SourceVo.java b/src/main/java/com/mzaxd/bps/domain/vo/SourceVo.java new file mode 100644 index 0000000..7cbfa2f --- /dev/null +++ b/src/main/java/com/mzaxd/bps/domain/vo/SourceVo.java @@ -0,0 +1,93 @@ +package com.mzaxd.bps.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 网盘资源返回对象 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SourceVo { + /** + * 资源ID + */ + private Long id; + + /** + * 分类ID + */ + private Long sourceCategoryId; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 资源标题 + */ + private String title; + + /** + * 资源描述 + */ + private String description; + + /** + * 资源URL + */ + private String url; + + /** + * 资源代码 + */ + private String code; + + /** + * 视频内容 + */ + private String vodContent; + + /** + * 视频封面 + */ + private String vodPic; + + /** + * 资源类型 + */ + private Integer isType; + + /** + * 是否定时 + */ + private Integer isTime; + + /** + * 状态 + */ + private Integer status; + + /** + * 浏览量 + */ + private Integer pageViews; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/enums/BaiduPcsCommand.java b/src/main/java/com/mzaxd/bps/enums/BaiduPcsCommand.java new file mode 100644 index 0000000..d760c0f --- /dev/null +++ b/src/main/java/com/mzaxd/bps/enums/BaiduPcsCommand.java @@ -0,0 +1,24 @@ +package com.mzaxd.bps.enums; + +import lombok.Getter; + +@Getter +public enum BaiduPcsCommand { + LOGIN("login", "Login to Baidu PCS"), + SEARCH("search", "Search files"), + DOWNLOAD("download", "Download file"), + UPLOAD("upload", "Upload file"), + SHARE("share", "Create share link"), + LIST("list", "List files"), + META("meta", "Get file metadata"), + QUOTA("quota", "Get quota information"); + + private final String command; + private final String description; + + BaiduPcsCommand(String command, String description) { + this.command = command; + this.description = description; + } + +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/enums/CloudStorageType.java b/src/main/java/com/mzaxd/bps/enums/CloudStorageType.java new file mode 100644 index 0000000..74656fd --- /dev/null +++ b/src/main/java/com/mzaxd/bps/enums/CloudStorageType.java @@ -0,0 +1,24 @@ +package com.mzaxd.bps.enums; + +public enum CloudStorageType { + BAIDU("baidu", "BaiduPCS-GO"), + UC("uc", "UC Cloud"), + XUN_LEI("xunlei", "Xunlei Cloud"), + QUARK("quark", "Quark Cloud"); + + private final String code; + private final String name; + + CloudStorageType(String code, String name) { + this.code = code; + this.name = name; + } + + public String getCode() { + return code; + } + + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/mapper/SourceCategoryMapper.java b/src/main/java/com/mzaxd/bps/mapper/SourceCategoryMapper.java new file mode 100644 index 0000000..566266c --- /dev/null +++ b/src/main/java/com/mzaxd/bps/mapper/SourceCategoryMapper.java @@ -0,0 +1,15 @@ +package com.mzaxd.bps.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mzaxd.bps.domain.entity.SourceCategory; +import org.apache.ibatis.annotations.Mapper; + +/** + * 网盘分类Mapper接口 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Mapper +public interface SourceCategoryMapper extends BaseMapper { +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/mapper/SourceLogMapper.java b/src/main/java/com/mzaxd/bps/mapper/SourceLogMapper.java new file mode 100644 index 0000000..ff70a72 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/mapper/SourceLogMapper.java @@ -0,0 +1,15 @@ +package com.mzaxd.bps.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mzaxd.bps.domain.entity.SourceLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * 网盘日志Mapper接口 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Mapper +public interface SourceLogMapper extends BaseMapper { +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/mapper/SourceMapper.java b/src/main/java/com/mzaxd/bps/mapper/SourceMapper.java new file mode 100644 index 0000000..c00d163 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/mapper/SourceMapper.java @@ -0,0 +1,15 @@ +package com.mzaxd.bps.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mzaxd.bps.domain.entity.Source; +import org.apache.ibatis.annotations.Mapper; + +/** + * 网盘资源Mapper接口 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Mapper +public interface SourceMapper extends BaseMapper { +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/AuditLogService.java b/src/main/java/com/mzaxd/bps/service/AuditLogService.java deleted file mode 100644 index 6a01a7f..0000000 --- a/src/main/java/com/mzaxd/bps/service/AuditLogService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mzaxd.bps.service; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.AuditLog; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 13439 -* @description 针对表【audit_log】的数据库操作Service -* @createDate 2023-02-13 12:19:26 -*/ -public interface AuditLogService extends IService { - - /** - * 返回日志列表 - * - * @param perPage - * @param currentPage - * @return - */ - ResponseResult getLogList(Integer perPage, Integer currentPage); - - /** - * 获取参数 - * - * @param id - * @return - */ - ResponseResult getParam(Integer id); - - /** - * 获取用户日志 - * - * @return - */ - ResponseResult getUserLog(); -} diff --git a/src/main/java/com/mzaxd/bps/service/CloudStorageService.java b/src/main/java/com/mzaxd/bps/service/CloudStorageService.java new file mode 100644 index 0000000..03996e3 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/CloudStorageService.java @@ -0,0 +1,57 @@ +package com.mzaxd.bps.service; + +import com.mzaxd.bps.domain.CloudFile; +import com.mzaxd.bps.enums.CloudStorageType; + +import java.util.List; +import java.util.Map; + +public interface CloudStorageService { + /** + * Initialize the cloud storage service + */ + void initialize(); + + /** + * Login to the cloud storage + * @param credentials login credentials + * @return true if login successful + */ + boolean login(Map credentials); + + /** + * Search for files in the cloud storage + * @param keyword search keyword + * @return list of search results + */ + List search(String keyword); + + /** + * Download a file from the cloud storage + * @param fileId file identifier + * @param localPath local path to save the file + * @return true if download successful + */ + boolean download(String fileId, String localPath); + + /** + * Upload a file to the cloud storage + * @param localPath local file path + * @param remotePath remote path to save the file + * @return true if upload successful + */ + boolean upload(String localPath, String remotePath); + + /** + * Create a share link for a file + * @param fileId file identifier + * @return share link + */ + String createShareLink(String fileId); + + /** + * Get the type of cloud storage + * @return cloud storage type + */ + CloudStorageType getType(); +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/DashboardService.java b/src/main/java/com/mzaxd/bps/service/DashboardService.java deleted file mode 100644 index 654d07f..0000000 --- a/src/main/java/com/mzaxd/bps/service/DashboardService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mzaxd.bps.service; - -import com.mzaxd.bps.domain.ResponseResult; - -/** - * @author 13439 - */ -public interface DashboardService { - /** - * 获取仪表台实例服务实时数据 - * - * @return - */ - ResponseResult getInstancesRealTimeData(); - - /** - * 获取最近连接过的控制台列表 - * - * @return - */ - ResponseResult getRecentConsoleList(); - - /** - * 获取所有受影响的服务 - * - * @return ResponseResult - * @author mzaxd - * @date 2023/3/8 9:43 - */ - ResponseResult getAffectedServirList(); -} diff --git a/src/main/java/com/mzaxd/bps/service/LoginService.java b/src/main/java/com/mzaxd/bps/service/LoginService.java deleted file mode 100644 index c0145f6..0000000 --- a/src/main/java/com/mzaxd/bps/service/LoginService.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mzaxd.bps.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.User; - -/** - * @author root - */ -public interface LoginService extends IService { - - /** - * 后台登录接口 - * - * @author mzaxd - * @date 12/4/22 1:29 PM - * @param user - * @return ResponseResult - */ - ResponseResult login(User user); - - /** - * 后台用户退出登陆 - * - * @author mzaxd - * @date 12/6/22 2:07 PM - * @return ResponseResult - */ - ResponseResult logout(); - - /** - * 首次登陆时 修改账户信息 - * - * @param user - * @return - */ - ResponseResult updateAccount(User user); - - /** - * 删除账号 - * - * @return - */ - ResponseResult deleteAccount(); -} diff --git a/src/main/java/com/mzaxd/bps/service/NotificationService.java b/src/main/java/com/mzaxd/bps/service/NotificationService.java deleted file mode 100644 index a11cbdf..0000000 --- a/src/main/java/com/mzaxd/bps/service/NotificationService.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mzaxd.bps.service; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.Notification; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 13439 -* @description 针对表【notification】的数据库操作Service -* @createDate 2023-02-16 16:04:53 -*/ -public interface NotificationService extends IService { - - /** - * 提醒列表 - * @param tab - * @param perPage - * @param currentPage - * @return - */ - ResponseResult getNotificationList(Integer tab, Integer perPage, Integer currentPage); - - /** - * 获取新通知数量 - * @return - */ - ResponseResult getNotificationCount(); - - /** - * 确认提醒 - * - * @param id - * @return - */ - ResponseResult affirmNotification(Long id); -} diff --git a/src/main/java/com/mzaxd/bps/service/SourceCategoryService.java b/src/main/java/com/mzaxd/bps/service/SourceCategoryService.java new file mode 100644 index 0000000..8139d31 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/SourceCategoryService.java @@ -0,0 +1,47 @@ +package com.mzaxd.bps.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mzaxd.bps.domain.entity.SourceCategory; +import com.mzaxd.bps.domain.vo.SourceCategoryVo; + +import java.util.List; + +/** + * 网盘分类表(SourceCategory)表服务接口 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +public interface SourceCategoryService extends IService { + + /** + * 获取分类列表 + * + * @return 分类列表 + */ + List getCategoryList(); + + /** + * 新增分类 + * + * @param category 分类信息 + * @return 是否成功 + */ + boolean addCategory(SourceCategory category); + + /** + * 更新分类 + * + * @param category 分类信息 + * @return 是否成功 + */ + boolean updateCategory(SourceCategory category); + + /** + * 删除分类 + * + * @param id 分类ID + * @return 是否成功 + */ + boolean deleteCategory(Long id); +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/SourceLogService.java b/src/main/java/com/mzaxd/bps/service/SourceLogService.java new file mode 100644 index 0000000..4e00712 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/SourceLogService.java @@ -0,0 +1,34 @@ +package com.mzaxd.bps.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mzaxd.bps.domain.entity.SourceLog; +import com.mzaxd.bps.domain.vo.PageVo; +import com.mzaxd.bps.domain.vo.SourceLogVo; + +/** + * 网盘日志Service接口 + * + * @author mzaxd + * @since 2024-04-06 + */ +public interface SourceLogService extends IService { + + /** + * 获取日志列表 + * + * @param pageNum 页码 + * @param pageSize 每页大小 + * @param sourceId 资源ID + * @return 分页结果 + */ + PageVo getLogList(Integer pageNum, Integer pageSize, Long sourceId); + + /** + * 添加日志 + * + * @param sourceId 资源ID + * @param ip IP地址 + * @return 是否成功 + */ + boolean addLog(Long sourceId, String ip); +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/SourceService.java b/src/main/java/com/mzaxd/bps/service/SourceService.java new file mode 100644 index 0000000..6d4759f --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/SourceService.java @@ -0,0 +1,59 @@ +package com.mzaxd.bps.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mzaxd.bps.domain.entity.Source; +import com.mzaxd.bps.domain.vo.PageVo; +import com.mzaxd.bps.domain.vo.SourceVo; + +/** + * 网盘资源Service接口 + * + * @author mzaxd + * @since 2024-04-06 + */ +public interface SourceService extends IService { + + /** + * 获取资源列表 + * + * @param pageNum 页码 + * @param pageSize 每页大小 + * @param title 标题 + * @param categoryId 分类ID + * @param isTime 是否定时 + * @return 分页结果 + */ + PageVo getSourceList(Integer pageNum, Integer pageSize, String title, Long categoryId, Integer isTime); + + /** + * 获取资源详情 + * + * @param id 资源ID + * @return 资源详情 + */ + SourceVo getSourceDetail(Long id); + + /** + * 新增资源 + * + * @param source 资源信息 + * @return 是否成功 + */ + boolean addSource(Source source); + + /** + * 更新资源 + * + * @param source 资源信息 + * @return 是否成功 + */ + boolean updateSource(Source source); + + /** + * 删除资源 + * + * @param id 资源ID + * @return 是否成功 + */ + boolean deleteSource(Long id); +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/SystemSettingService.java b/src/main/java/com/mzaxd/bps/service/SystemSettingService.java deleted file mode 100644 index 466885f..0000000 --- a/src/main/java/com/mzaxd/bps/service/SystemSettingService.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mzaxd.bps.service; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.SystemSetting; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author 13439 -* @description 针对表【system_setting】的数据库操作Service -* @createDate 2023-02-16 20:25:57 -*/ -public interface SystemSettingService extends IService { - - /** - * 获取SMTP服务器设置 - * - * @return - */ - ResponseResult getSmtpSetting(); - - /** - * 保存smtp设置 - * - * @param smtpVo - * @return - */ - ResponseResult saveSmtpSetting(SmtpVo smtpVo); - - /** - * 获取终端设置 - * - * @return - */ - ResponseResult getTerminalSetting(); - - /** - * 报错终端设置 - * - * @param terminalVo - * @return - */ - ResponseResult saveTerminalSetting(TerminalVo terminalVo); - - /** - * 获取系统设置 - * - * @return - */ - ResponseResult getSystemSetting(); - - - /** - * 保存系统设置 - * - * @param systemVo - * @return - */ - ResponseResult saveSystemSetting(SystemVo systemVo); -} diff --git a/src/main/java/com/mzaxd/bps/service/UserService.java b/src/main/java/com/mzaxd/bps/service/UserService.java deleted file mode 100644 index 4a37326..0000000 --- a/src/main/java/com/mzaxd/bps/service/UserService.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.mzaxd.bps.service; - -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.User; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author root -* @description 针对表【user】的数据库操作Service -* @createDate 2023-01-28 09:16:07 -*/ -public interface UserService extends IService { - - /** - * 查询用户信息 - * - * @author mzaxd - * @date 1/29/23 4:16 AM - * @return ResponseResult - */ - ResponseResult userInfo(); - - /** - * 修改用户信息 - * - * @author mzaxd - * @date 1/29/23 4:16 AM - * @param user - * @return ResponseResult - */ - ResponseResult updateUserInfo(User user); - - /** - * 返回profile页面所需数据 - * - * @return - */ - ResponseResult getProfile(); - - /** - * 通过判断默认账户的state状态来判断是否第一次使用 - * @return - */ - ResponseResult isFirstUse(); - - /** - * 修改密码 - * @param password - * @return - */ - ResponseResult changePassword(String password); - - /** - * 通过id获取UserInfo - * - * @param id - * @return - */ - ResponseResult getUserInfo(Integer id); - - /** - * 修改账号信息 - * @param userData - * @return - */ - ResponseResult updateUserInfo(UserInfoVo userData); -} diff --git a/src/main/java/com/mzaxd/bps/service/impl/AuditLogServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/AuditLogServiceImpl.java deleted file mode 100644 index b78a58b..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/AuditLogServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mzaxd.bps.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.mzaxd.bps.constant.SystemConstant; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.*; -import com.mzaxd.bps.domain.vo.*; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.mapper.UserMapper; -import com.mzaxd.bps.service.AuditLogService; -import com.mzaxd.bps.mapper.AuditLogMapper; -import com.mzaxd.bps.util.BeanCopyUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.List; - -/** -* @author 13439 -* @description 针对表【audit_log】的数据库操作Service实现 -* @createDate 2023-02-13 12:19:26 -*/ -@Service -@Transactional(rollbackFor = SystemException.class) -public class AuditLogServiceImpl extends ServiceImpl - implements AuditLogService{ - - @Resource - private UserMapper userMapper; - - @Override - public ResponseResult getLogList(Integer perPage, Integer currentPage) { - //分页 - PageHelper.startPage(currentPage, perPage); - LambdaQueryWrapper auditLogLambdaQueryWrapper = new LambdaQueryWrapper<>(); - auditLogLambdaQueryWrapper.orderByDesc(AuditLog::getCreateTime); - //查询 - List auditLogs = list(auditLogLambdaQueryWrapper); - //封装分页信息 - PageInfo pageInfo = new PageInfo<>(auditLogs, perPage); - - //封装结果返回 - List auditLogListVos = BeanCopyUtils.copyBeanList(auditLogs, AuditLogListVo.class); - auditLogListVos.forEach(auditLogListVo -> { - User user = userMapper.selectById(auditLogListVo.getCreateBy()); - UserInfoVo userInfoVo = BeanCopyUtils.copyBean(user, UserInfoVo.class); - auditLogListVo.setUser(userInfoVo); - }); - pageInfo.setList(auditLogListVos); - return ResponseResult.success(pageInfo); - } - - @Override - public ResponseResult getParam(Integer id) { - AuditLog auditLog = getById(id); - return ResponseResult.success(auditLog.getParam()); - } - - @Override - public ResponseResult getUserLog() { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(AuditLog::getOperationType, SystemConstant.LOG_USER); - queryWrapper.orderByDesc(AuditLog::getCreateTime); - List list = list(queryWrapper); - return ResponseResult.success(list); - } -} - - - - diff --git a/src/main/java/com/mzaxd/bps/service/impl/BaiduPcsService.java b/src/main/java/com/mzaxd/bps/service/impl/BaiduPcsService.java new file mode 100644 index 0000000..2f18090 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/impl/BaiduPcsService.java @@ -0,0 +1,160 @@ +package com.mzaxd.bps.service.impl; + +import com.mzaxd.bps.enums.BaiduPcsCommand; +import com.mzaxd.bps.enums.CloudStorageType; +import com.mzaxd.bps.domain.CloudFile; +import com.mzaxd.bps.service.CloudStorageService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Service +public class BaiduPcsService implements CloudStorageService { + private static final Logger logger = LoggerFactory.getLogger(BaiduPcsService.class); + private static final String EXECUTABLE_NAME = "baidupcs-go"; + private String executablePath; + private boolean initialized = false; + + @Override + public void initialize() { + if (initialized) { + return; + } + + try { + String os = System.getProperty("os.name").toLowerCase(); + String resourcePath = os.contains("win") ? "baidu/win/" : "baidu/linux/"; + + ClassPathResource resource = new ClassPathResource(resourcePath + EXECUTABLE_NAME); + File tempFile = File.createTempFile(EXECUTABLE_NAME, ""); + Files.copy(resource.getInputStream(), tempFile.toPath()); + tempFile.setExecutable(true); + + executablePath = tempFile.getAbsolutePath(); + initialized = true; + logger.info("BaiduPCS-GO initialized successfully at: {}", executablePath); + } catch (IOException e) { + logger.error("Failed to initialize BaiduPCS-GO", e); + throw new RuntimeException("Failed to initialize BaiduPCS-GO", e); + } + } + + @Override + public boolean login(Map credentials) { + String username = credentials.get("username"); + String password = credentials.get("password"); + + if (username == null || password == null) { + throw new IllegalArgumentException("Username and password are required"); + } + + try { + ProcessBuilder processBuilder = new ProcessBuilder( + executablePath, + BaiduPcsCommand.LOGIN.getCommand(), + username, + password + ); + + Process process = processBuilder.start(); + return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0; + } catch (IOException | InterruptedException e) { + logger.error("Login failed", e); + return false; + } + } + + @Override + public List search(String keyword) { + try { + ProcessBuilder processBuilder = new ProcessBuilder( + executablePath, + BaiduPcsCommand.SEARCH.getCommand(), + keyword + ); + + Process process = processBuilder.start(); + if (process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) { + // Parse the output and convert to CloudFile objects + // This is a simplified version, you'll need to implement proper parsing + return new ArrayList<>(); + } + return new ArrayList<>(); + } catch (IOException | InterruptedException e) { + logger.error("Search failed", e); + return new ArrayList<>(); + } + } + + @Override + public boolean download(String fileId, String localPath) { + try { + ProcessBuilder processBuilder = new ProcessBuilder( + executablePath, + BaiduPcsCommand.DOWNLOAD.getCommand(), + fileId, + localPath + ); + + Process process = processBuilder.start(); + return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0; + } catch (IOException | InterruptedException e) { + logger.error("Download failed", e); + return false; + } + } + + @Override + public boolean upload(String localPath, String remotePath) { + try { + ProcessBuilder processBuilder = new ProcessBuilder( + executablePath, + BaiduPcsCommand.UPLOAD.getCommand(), + localPath, + remotePath + ); + + Process process = processBuilder.start(); + return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0; + } catch (IOException | InterruptedException e) { + logger.error("Upload failed", e); + return false; + } + } + + @Override + public String createShareLink(String fileId) { + try { + ProcessBuilder processBuilder = new ProcessBuilder( + executablePath, + BaiduPcsCommand.SHARE.getCommand(), + fileId + ); + + Process process = processBuilder.start(); + if (process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) { + // Parse the output to get the share link + // This is a simplified version, you'll need to implement proper parsing + return ""; + } + return ""; + } catch (IOException | InterruptedException e) { + logger.error("Create share link failed", e); + return ""; + } + } + + @Override + public CloudStorageType getType() { + return CloudStorageType.BAIDU; + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/impl/LoginServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/LoginServiceImpl.java deleted file mode 100644 index 0e73985..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/LoginServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.mzaxd.bps.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.mzaxd.bps.constant.SystemConstant; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.LoginUser; -import com.mzaxd.bps.domain.entity.User; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.mapper.UserMapper; -import com.mzaxd.bps.service.LoginService; -import com.mzaxd.bps.util.JwtUtil; -import com.mzaxd.bps.util.RedisCache; -import com.mzaxd.bps.util.SecurityUtils; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * @author root - */ -@Service -@Transactional(rollbackFor = {SystemException.class}) -public class LoginServiceImpl extends ServiceImpl implements LoginService { - - @Resource - private AuthenticationManager authenticationManager; - @Resource - private RedisCache redisCache; - @Resource - private PasswordEncoder passwordEncoder; - @Resource - private UserMapper userMapper; - - @Override - public ResponseResult login(User user) { - UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getEmail(), user.getPassword()); - Authentication authenticate = authenticationManager.authenticate(authenticationToken); - //判断是否认证通过 - if (Objects.isNull(authenticate)) { - throw new RuntimeException("邮箱或密码错误"); - } - //获取userid 生成token - LoginUser loginUser = (LoginUser) authenticate.getPrincipal(); - String userId = loginUser.getUser().getId().toString(); - String jwt = JwtUtil.createJWT(userId); - //把用户信息存入redis - redisCache.setCacheObject("login:" + userId, loginUser); - //把token封装 返回 - Map map = new HashMap<>(); - map.put("token", jwt); - map.put("userId", userId); - return ResponseResult.success("登录成功", map); - } - - @Override - public ResponseResult logout() { - //获取当前登录的用户id - Long userId = SecurityUtils.getUserId(); - //删除redis中对应的值 - redisCache.deleteObject("login:" + userId); - return ResponseResult.success(); - } - - @Override - public ResponseResult updateAccount(User user) { - //获取当前登录的用户id - Long userId = SecurityUtils.getUserId(); - User defaultUser = getById(userId); - defaultUser.setEmail(user.getEmail()); - defaultUser.setPassword(passwordEncoder.encode(user.getPassword())); - defaultUser.setUserState(SystemConstant.NORMAL_STATE); - saveOrUpdate(defaultUser); - return ResponseResult.success("修改账号信息成功"); - } - - @Override - public ResponseResult deleteAccount() { - Long userId = SecurityUtils.getUserId(); - userMapper.deleteById(userId); - return ResponseResult.success(); - } -} diff --git a/src/main/java/com/mzaxd/bps/service/impl/NotificationServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/NotificationServiceImpl.java deleted file mode 100644 index a1d5f10..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/NotificationServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.mzaxd.bps.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.mzaxd.bps.constant.RedisConstant; -import com.mzaxd.bps.constant.SystemConstant; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.Notification; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.mapper.NotificationMapper; -import com.mzaxd.bps.service.NotificationService; -import com.mzaxd.bps.util.SystemSettingUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; - -/** - * @author 13439 - * @description 针对表【notification】的数据库操作Service实现 - * @createDate 2023-02-16 16:04:53 - */ -@Service -@Slf4j -@Transactional(rollbackFor = SystemException.class) -public class NotificationServiceImpl extends ServiceImpl - implements NotificationService { - - @Resource - private SystemSettingUtils systemSettingUtils; - - @Resource - private RedisTemplate redisTemplate; - - @Override - public ResponseResult affirmNotification(Long id) { - Notification notification = getById(id); - if (SystemConstant.INSTANCETYPE_HOST.equals(notification.getInstanceType())) { - redisTemplate.opsForSet().remove(RedisConstant.NOTIFY_HOST_IDS, notification.getInstanceId().toString()); - } - if (SystemConstant.INSTANCETYPE_VM.equals(notification.getInstanceType())) { - redisTemplate.opsForSet().remove(RedisConstant.NOTIFY_VM_IDS, notification.getInstanceId().toString()); - } - if (SystemConstant.INSTANCETYPE_CONTAINER.equals(notification.getInstanceType())) { - redisTemplate.opsForSet().remove(RedisConstant.NOTIFY_CONTAINER_IDS, notification.getInstanceId().toString()); - } - saveOrUpdate(notification.setAffirm(SystemConstant.NOTIFICATION_AFFIRM)); - return ResponseResult.success("处理完成"); - } - - @Override - public ResponseResult getNotificationList(Integer tab, Integer perPage, Integer currentPage) { - return null; - } - - @Override - public ResponseResult getNotificationCount() { - LambdaQueryWrapper notificationLambdaQueryWrapper = new LambdaQueryWrapper<>(); - notificationLambdaQueryWrapper.eq(Notification::getAffirm, SystemConstant.NOTIFICATION_NOT_AFFIRM); - return ResponseResult.success(count(notificationLambdaQueryWrapper)); - } - -} - - - - diff --git a/src/main/java/com/mzaxd/bps/service/impl/SourceCategoryServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/SourceCategoryServiceImpl.java new file mode 100644 index 0000000..b316239 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/impl/SourceCategoryServiceImpl.java @@ -0,0 +1,57 @@ +package com.mzaxd.bps.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mzaxd.bps.domain.entity.SourceCategory; +import com.mzaxd.bps.domain.vo.SourceCategoryVo; +import com.mzaxd.bps.mapper.SourceCategoryMapper; +import com.mzaxd.bps.service.SourceCategoryService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 网盘分类表(SourceCategory)表服务实现类 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Service +public class SourceCategoryServiceImpl extends ServiceImpl implements SourceCategoryService { + + @Override + public List getCategoryList() { + // 构建查询条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SourceCategory::getStatus, 0) + .orderByDesc(SourceCategory::getSort); + + // 查询分类列表 + List categories = list(queryWrapper); + + // 转换为VO + return categories.stream().map(category -> { + SourceCategoryVo categoryVo = new SourceCategoryVo(); + BeanUtils.copyProperties(category, categoryVo); + categoryVo.setId(category.getSourceCategoryId()); + return categoryVo; + }).collect(Collectors.toList()); + } + + @Override + public boolean addCategory(SourceCategory category) { + return save(category); + } + + @Override + public boolean updateCategory(SourceCategory category) { + return updateById(category); + } + + @Override + public boolean deleteCategory(Long id) { + return removeById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/impl/SourceLogServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/SourceLogServiceImpl.java new file mode 100644 index 0000000..2667877 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/impl/SourceLogServiceImpl.java @@ -0,0 +1,75 @@ +package com.mzaxd.bps.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mzaxd.bps.domain.entity.Source; +import com.mzaxd.bps.domain.entity.SourceLog; +import com.mzaxd.bps.domain.vo.PageVo; +import com.mzaxd.bps.domain.vo.SourceLogVo; +import com.mzaxd.bps.mapper.SourceLogMapper; +import com.mzaxd.bps.mapper.SourceMapper; +import com.mzaxd.bps.service.SourceLogService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 网盘日志表(SourceLog)表服务实现类 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Service +public class SourceLogServiceImpl extends ServiceImpl implements SourceLogService { + + @Autowired + private SourceMapper sourceMapper; + + @Override + public PageVo getLogList(Integer pageNum, Integer pageSize, Long sourceId) { + // 构建查询条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (sourceId != null) { + queryWrapper.eq(SourceLog::getSourceId, sourceId); + } + queryWrapper.orderByDesc(SourceLog::getCreateTime); + + // 分页查询 + Page page = new Page<>(pageNum, pageSize); + page(page, queryWrapper); + + // 转换为VO + List logVos = page.getRecords().stream().map(log -> { + SourceLogVo logVo = new SourceLogVo(); + BeanUtils.copyProperties(log, logVo); + logVo.setId(log.getLogId()); + + // 查询资源标题 + Source source = sourceMapper.selectById(log.getSourceId()); + if (source != null) { + logVo.setSourceTitle(source.getTitle()); + } + + return logVo; + }).collect(Collectors.toList()); + + // 封装返回结果 + PageVo pageVo = new PageVo<>(); + pageVo.setTotal(page.getTotal()); + pageVo.setRows(logVos); + + return pageVo; + } + + @Override + public boolean addLog(Long sourceId, String ip) { + SourceLog log = new SourceLog(); + log.setSourceId(sourceId); + log.setIp(ip); + return save(log); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/impl/SourceServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/SourceServiceImpl.java new file mode 100644 index 0000000..5782853 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/service/impl/SourceServiceImpl.java @@ -0,0 +1,119 @@ +package com.mzaxd.bps.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mzaxd.bps.domain.entity.Source; +import com.mzaxd.bps.domain.entity.SourceCategory; +import com.mzaxd.bps.domain.vo.PageVo; +import com.mzaxd.bps.domain.vo.SourceVo; +import com.mzaxd.bps.mapper.SourceMapper; +import com.mzaxd.bps.mapper.SourceCategoryMapper; +import com.mzaxd.bps.service.SourceService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 网盘资源表(Source)表服务实现类 + * + * @author mzaxd + * @since 2024-04-06 10:00:00 + */ +@Service +public class SourceServiceImpl extends ServiceImpl implements SourceService { + + @Autowired + private SourceCategoryMapper sourceCategoryMapper; + + @Override + public PageVo getSourceList(Integer pageNum, Integer pageSize, String title, Long categoryId, Integer isTime) { + // 构建查询条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Source::getStatus, 1) + .eq(Source::getIsDelete, 0); + + if (StringUtils.hasText(title)) { + queryWrapper.like(Source::getTitle, title); + } + + if (categoryId != null) { + queryWrapper.eq(Source::getSourceCategoryId, categoryId); + } + + if (isTime != null) { + queryWrapper.eq(Source::getIsTime, isTime); + } + + // 分页查询 + Page page = new Page<>(pageNum, pageSize); + page(page, queryWrapper); + + // 转换为VO + List sourceVos = page.getRecords().stream().map(source -> { + SourceVo sourceVo = new SourceVo(); + BeanUtils.copyProperties(source, sourceVo); + sourceVo.setId(source.getSourceId()); + + // 查询分类名称 + SourceCategory category = sourceCategoryMapper.selectById(source.getSourceCategoryId()); + if (category != null) { + sourceVo.setCategoryName(category.getName()); + } + + return sourceVo; + }).collect(Collectors.toList()); + + // 封装返回结果 + PageVo pageVo = new PageVo<>(); + pageVo.setTotal(page.getTotal()); + pageVo.setRows(sourceVos); + + return pageVo; + } + + @Override + public SourceVo getSourceDetail(Long id) { + // 查询资源 + Source source = getById(id); + if (source == null) { + return null; + } + + // 转换为VO + SourceVo sourceVo = new SourceVo(); + BeanUtils.copyProperties(source, sourceVo); + sourceVo.setId(source.getSourceId()); + + // 查询分类名称 + SourceCategory category = sourceCategoryMapper.selectById(source.getSourceCategoryId()); + if (category != null) { + sourceVo.setCategoryName(category.getName()); + } + + // 增加浏览量 + source.setPageViews(source.getPageViews() + 1); + updateById(source); + + return sourceVo; + } + + @Override + public boolean addSource(Source source) { + return save(source); + } + + @Override + public boolean updateSource(Source source) { + return updateById(source); + } + + @Override + public boolean deleteSource(Long id) { + return removeById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/service/impl/SystemSettingServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/SystemSettingServiceImpl.java deleted file mode 100644 index eaba4a4..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/SystemSettingServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mzaxd.bps.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.SystemSetting; -import com.mzaxd.bps.enums.AppHttpCodeEnum; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.service.SystemSettingService; -import com.mzaxd.bps.mapper.SystemSettingMapper; -import com.mzaxd.bps.util.BeanCopyUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** -* @author 13439 -* @description 针对表【system_setting】的数据库操作Service实现 -* @createDate 2023-02-16 20:25:57 -*/ -@Service -@Transactional(rollbackFor = SystemException.class) -public class SystemSettingServiceImpl extends ServiceImpl - implements SystemSettingService{ - - @Override - public ResponseResult getSmtpSetting() { - SystemSetting systemSetting = getSetting(); - SmtpVo smtpVo = BeanCopyUtils.copyBean(systemSetting, SmtpVo.class); - return ResponseResult.success(smtpVo); - } - - @Override - public ResponseResult saveSmtpSetting(SmtpVo smtpVo) { - SystemSetting systemSetting = getById(1); - systemSetting.setServerEmail(smtpVo.getServerEmail()); - systemSetting.setEmailPass(smtpVo.getEmailPass()); - systemSetting.setNotificationEmail(smtpVo.getNotificationEmail()); - saveOrUpdate(systemSetting); - return ResponseResult.success(AppHttpCodeEnum.SUCCESS); - } - - @Override - public ResponseResult getTerminalSetting() { - SystemSetting systemSetting = getSetting(); - TerminalVo terminalVo = BeanCopyUtils.copyBean(systemSetting, TerminalVo.class); - return ResponseResult.success(terminalVo); - } - - @Override - public ResponseResult saveTerminalSetting(TerminalVo terminalVo) { - SystemSetting systemSetting = getById(1); - systemSetting.setRendererType(terminalVo.getRendererType()); - systemSetting.setFontSize(terminalVo.getFontSize()); - systemSetting.setCursorBlink(terminalVo.getCursorBlink()); - systemSetting.setForeground(terminalVo.getForeground()); - systemSetting.setBackground(terminalVo.getBackground()); - saveOrUpdate(systemSetting); - return ResponseResult.success(AppHttpCodeEnum.SUCCESS); - } - - @Override - public ResponseResult getSystemSetting() { - SystemSetting systemSetting = getSetting(); - SystemVo systemVo = BeanCopyUtils.copyBean(systemSetting, SystemVo.class); - return ResponseResult.success(systemVo); - } - - @Override - public ResponseResult saveSystemSetting(SystemVo systemVo) { - SystemSetting systemSetting = getById(1); - systemSetting.setLogExpire(systemVo.getLogExpire()); - systemSetting.setDefaultLang(systemVo.getDefaultLang()); - systemSetting.setCheckInstanceStatePeriod(systemVo.getCheckInstanceStatePeriod()); - saveOrUpdate(systemSetting); - return ResponseResult.success(AppHttpCodeEnum.SUCCESS); - } - - private SystemSetting getSetting(){ - return getById(1); - } -} - - - - diff --git a/src/main/java/com/mzaxd/bps/service/impl/UserDetailServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/UserDetailServiceImpl.java deleted file mode 100644 index 27adc39..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/UserDetailServiceImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mzaxd.bps.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.mzaxd.bps.domain.entity.LoginUser; -import com.mzaxd.bps.domain.entity.User; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.mapper.UserMapper; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.Objects; - -/** - * @author root - * @description - * @createDate 2022-11-26 12:24:08 - */ -@Service -@Transactional(rollbackFor = SystemException.class) -public class UserDetailServiceImpl implements UserDetailsService { - - @Resource - private UserMapper userMapper; - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - //根据用户名查询用户信息 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(User::getEmail, email); - User user = userMapper.selectOne(wrapper); - //如果查询不到数据就通过抛出异常来给出提示 - if (Objects.isNull(user)) { - throw new RuntimeException("邮箱或密码错误"); - } - - //封装成UserDetails对象返回 - return new LoginUser(user); - } -} - - - - diff --git a/src/main/java/com/mzaxd/bps/service/impl/UserServiceImpl.java b/src/main/java/com/mzaxd/bps/service/impl/UserServiceImpl.java deleted file mode 100644 index 3af645e..0000000 --- a/src/main/java/com/mzaxd/bps/service/impl/UserServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.mzaxd.bps.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.mzaxd.bps.domain.ResponseResult; -import com.mzaxd.bps.domain.entity.User; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.mapper.UserMapper; -import com.mzaxd.bps.service.UserService; -import com.mzaxd.bps.util.BeanCopyUtils; -import com.mzaxd.bps.util.SecurityUtils; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; - -/** -* @author root -* @description 针对表【user】的数据库操作Service实现 -* @createDate 2023-01-28 09:16:07 -*/ -@Service -@Transactional(rollbackFor = SystemException.class) -public class UserServiceImpl extends ServiceImpl - implements UserService{ - - @Resource - private PasswordEncoder passwordEncoder; - - @Override - public ResponseResult userInfo() { - //获取当前用户id - Long userId = SecurityUtils.getUserId(); - //根据id查询用户信息 - User user = getById(userId); - //将用户信息封装Vo并返回 - UserInfoVo userInfoVo = BeanCopyUtils.copyBean(user, UserInfoVo.class); - return ResponseResult.success(userInfoVo); - } - - @Override - public ResponseResult updateUserInfo(User user) { - updateById(user); - return ResponseResult.success(); - } - - @Override - public ResponseResult getProfile() { - //获取当前用户id - Long userId = SecurityUtils.getUserId(); - User user = getById(userId); - ProfileVo profile = BeanCopyUtils.copyBean(user, ProfileVo.class); - return ResponseResult.success(profile); - } - - @Override - public ResponseResult isFirstUse() { - User user = getById(1); - if (user.getUserState() == 0) { - return ResponseResult.success(true); - } else { - return ResponseResult.success(false); - } - } - - @Override - public ResponseResult changePassword(String password) { - Long userId = SecurityUtils.getUserId(); - User user = getById(userId); - user.setPassword(passwordEncoder.encode(password)); - saveOrUpdate(user); - return ResponseResult.success("密码修改成功"); - } - - @Override - public ResponseResult getUserInfo(Integer id) { - User user = getById(id); - UserInfoVo userInfoVo = BeanCopyUtils.copyBean(user, UserInfoVo.class); - return ResponseResult.success(userInfoVo); - } - - @Override - public ResponseResult updateUserInfo(UserInfoVo userData) { - Long userId = SecurityUtils.getUserId(); - User user = getById(userId); - user.setEmail(userData.getEmail()).setUserName(userData.getUserName()).setNickName(userData.getNickName()).setAvatar(userData.getAvatar()); - saveOrUpdate(user); - return ResponseResult.success("账号信息修改成功"); - } -} - - - - diff --git a/src/main/java/com/mzaxd/bps/util/Result.java b/src/main/java/com/mzaxd/bps/util/Result.java new file mode 100644 index 0000000..749fb64 --- /dev/null +++ b/src/main/java/com/mzaxd/bps/util/Result.java @@ -0,0 +1,63 @@ +package com.mzaxd.bps.util; + +import lombok.Data; + +/** + * 统一响应结果 + * + * @author mzaxd + * @since 2024-04-06 + */ +@Data +public class Result { + + /** + * 状态码 + */ + private Integer code; + + /** + * 提示信息 + */ + private String message; + + /** + * 数据 + */ + private T data; + + /** + * 成功 + */ + public static Result success() { + return success(null); + } + + /** + * 成功 + */ + public static Result success(T data) { + Result result = new Result<>(); + result.setCode(200); + result.setMessage("success"); + result.setData(data); + return result; + } + + /** + * 失败 + */ + public static Result error(String message) { + return error(500, message); + } + + /** + * 失败 + */ + public static Result error(Integer code, String message) { + Result result = new Result<>(); + result.setCode(code); + result.setMessage(message); + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/mzaxd/bps/util/SystemSettingUtils.java b/src/main/java/com/mzaxd/bps/util/SystemSettingUtils.java deleted file mode 100644 index e4ed9e7..0000000 --- a/src/main/java/com/mzaxd/bps/util/SystemSettingUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mzaxd.bps.util; - -import cn.hutool.extra.mail.MailAccount; -import com.mzaxd.bps.domain.entity.SystemSetting; -import com.mzaxd.bps.enums.AppHttpCodeEnum; -import com.mzaxd.bps.exception.SystemException; -import com.mzaxd.bps.service.SystemSettingService; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -import javax.annotation.Resource; - -/** - * @author 13439 - */ -@Component -public class SystemSettingUtils { - - @Resource - private SystemSettingService systemSettingService; - - /** - * 获取邮件服务器Bean - * @return - */ - public MailAccount getMailAccount() { - //获取系统设置 - SystemSetting setting = systemSettingService.getById(1); - MailAccount account = new MailAccount(); - if (!StringUtils.hasText(setting.getEmailPass())) { - throw new SystemException(AppHttpCodeEnum.EMAIL_NOT_NULL); - } - account.setFrom(setting.getServerEmail()); - account.setUser(setting.getServerEmail()); - account.setPass(setting.getEmailPass()); - return account; - } - - public String getMailTarget() { - //获取系统设置 - SystemSetting setting = systemSettingService.getById(1); - //如果不配置目标邮箱的话,默认目标邮箱为服务器邮箱地址 - String target; - if (StringUtils.hasText(setting.getNotificationEmail())) { - target = setting.getNotificationEmail(); - } else { - target = setting.getServerEmail(); - } - return target; - } -} diff --git a/src/main/java/com/mzaxd/bps/util/UrlUtil.java b/src/main/java/com/mzaxd/bps/util/UrlUtil.java deleted file mode 100644 index a97044d..0000000 --- a/src/main/java/com/mzaxd/bps/util/UrlUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mzaxd.bps.util; - -import com.mzaxd.bps.constant.UrlConstant; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.net.*; -import java.util.HashMap; -import java.util.Map; - -/** - * @author root - */ -@Slf4j -@Component -public class UrlUtil { - - public static String getUrl(String protocol, String ip, String port, String path) { - return getAddress(protocol, ip, port) + path; - } - - public static String getAddress(String protocol, String ip, String port) { - return protocol + "://" + ip + ":" + port; - } - - public static Map resolveUrl(String url) { - HashMap result = new HashMap<>(3); - - String[] protocolAndAddress = url.split("://"); - String protocol = protocolAndAddress[0]; - String[] ipAndPort = protocolAndAddress[1].split(":"); - String ip = ipAndPort[0]; - String port = ipAndPort[1]; - result.put(UrlConstant.PROTOCOL, protocol); - result.put(UrlConstant.IP, ip); - result.put(UrlConstant.PORT, port); - return result; - } - - public static String getHostname(String address) { - String[] parts = address.split(":"); - return parts[0]; - } - - public static boolean isHostOnline(String ipAddress) throws IOException { - InetAddress inetAddress = InetAddress.getByName(ipAddress); - // 超时时间为5秒 - return inetAddress.isReachable(5000); - } - - public static int getPort(String address) { - String[] parts = address.split(":"); - return Integer.parseInt(parts[1]); - } -}