feat: 迁移1
This commit is contained in:
@@ -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);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<SearchCategory> searchCategories = SearchUtil.getSearchCategory();
|
||||
|
||||
List<Object> result = new ArrayList<>();
|
||||
|
||||
for (SearchCategory category : searchCategories) {
|
||||
result.add(category);
|
||||
List<SearchItem> 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<SearchItem> 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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<SourceCategoryVo> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<Source>> page(
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(required = false) String title,
|
||||
@RequestParam(required = false) Long sourceCategoryId) {
|
||||
LambdaQueryWrapper<Source> 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<Source> getById(@PathVariable Long id) {
|
||||
return Result.success(sourceService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增网盘资源
|
||||
*/
|
||||
@PostMapping
|
||||
public Result<Boolean> save(@RequestBody Source source) {
|
||||
return Result.success(sourceService.save(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改网盘资源
|
||||
*/
|
||||
@PutMapping
|
||||
public Result<Boolean> updateById(@RequestBody Source source) {
|
||||
return Result.success(sourceService.updateById(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除网盘资源
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> removeById(@PathVariable Long id) {
|
||||
return Result.success(sourceService.removeById(id));
|
||||
}
|
||||
}
|
||||
@@ -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<SourceLogVo> 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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, String> map) {
|
||||
return userService.changePassword(map.get("password"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<CloudStorageType, CloudStorageService> 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<T> {
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private Long total;
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
private List<T> rows;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<SourceCategory> {
|
||||
}
|
||||
@@ -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<SourceLog> {
|
||||
}
|
||||
@@ -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<Source> {
|
||||
}
|
||||
@@ -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<AuditLog> {
|
||||
|
||||
/**
|
||||
* 返回日志列表
|
||||
*
|
||||
* @param perPage
|
||||
* @param currentPage
|
||||
* @return
|
||||
*/
|
||||
ResponseResult<?> getLogList(Integer perPage, Integer currentPage);
|
||||
|
||||
/**
|
||||
* 获取参数
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ResponseResult<?> getParam(Integer id);
|
||||
|
||||
/**
|
||||
* 获取用户日志
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ResponseResult<?> getUserLog();
|
||||
}
|
||||
@@ -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<String, String> credentials);
|
||||
|
||||
/**
|
||||
* Search for files in the cloud storage
|
||||
* @param keyword search keyword
|
||||
* @return list of search results
|
||||
*/
|
||||
List<CloudFile> 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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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<User> {
|
||||
|
||||
/**
|
||||
* 后台登录接口
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
@@ -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<Notification> {
|
||||
|
||||
/**
|
||||
* 提醒列表
|
||||
* @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);
|
||||
}
|
||||
@@ -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<SourceCategory> {
|
||||
|
||||
/**
|
||||
* 获取分类列表
|
||||
*
|
||||
* @return 分类列表
|
||||
*/
|
||||
List<SourceCategoryVo> getCategoryList();
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
*
|
||||
* @param category 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean addCategory(SourceCategory category);
|
||||
|
||||
/**
|
||||
* 更新分类
|
||||
*
|
||||
* @param category 分类信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateCategory(SourceCategory category);
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
*
|
||||
* @param id 分类ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteCategory(Long id);
|
||||
}
|
||||
@@ -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<SourceLog> {
|
||||
|
||||
/**
|
||||
* 获取日志列表
|
||||
*
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param sourceId 资源ID
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageVo<SourceLogVo> getLogList(Integer pageNum, Integer pageSize, Long sourceId);
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*
|
||||
* @param sourceId 资源ID
|
||||
* @param ip IP地址
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean addLog(Long sourceId, String ip);
|
||||
}
|
||||
@@ -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<Source> {
|
||||
|
||||
/**
|
||||
* 获取资源列表
|
||||
*
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param title 标题
|
||||
* @param categoryId 分类ID
|
||||
* @param isTime 是否定时
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageVo<SourceVo> 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);
|
||||
}
|
||||
@@ -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<SystemSetting> {
|
||||
|
||||
/**
|
||||
* 获取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);
|
||||
}
|
||||
@@ -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<User> {
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
@@ -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<AuditLogMapper, AuditLog>
|
||||
implements AuditLogService{
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public ResponseResult<?> getLogList(Integer perPage, Integer currentPage) {
|
||||
//分页
|
||||
PageHelper.startPage(currentPage, perPage);
|
||||
LambdaQueryWrapper<AuditLog> auditLogLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
auditLogLambdaQueryWrapper.orderByDesc(AuditLog::getCreateTime);
|
||||
//查询
|
||||
List<AuditLog> auditLogs = list(auditLogLambdaQueryWrapper);
|
||||
//封装分页信息
|
||||
PageInfo pageInfo = new PageInfo<>(auditLogs, perPage);
|
||||
|
||||
//封装结果返回
|
||||
List<AuditLogListVo> 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<AuditLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AuditLog::getOperationType, SystemConstant.LOG_USER);
|
||||
queryWrapper.orderByDesc(AuditLog::getCreateTime);
|
||||
List<AuditLog> list = list(queryWrapper);
|
||||
return ResponseResult.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<String, String> 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<CloudFile> 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;
|
||||
}
|
||||
}
|
||||
@@ -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<UserMapper, User> 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<String, String> 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();
|
||||
}
|
||||
}
|
||||
@@ -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<NotificationMapper, Notification>
|
||||
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<Notification> notificationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
notificationLambdaQueryWrapper.eq(Notification::getAffirm, SystemConstant.NOTIFICATION_NOT_AFFIRM);
|
||||
return ResponseResult.success(count(notificationLambdaQueryWrapper));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<SourceCategoryMapper, SourceCategory> implements SourceCategoryService {
|
||||
|
||||
@Override
|
||||
public List<SourceCategoryVo> getCategoryList() {
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<SourceCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SourceCategory::getStatus, 0)
|
||||
.orderByDesc(SourceCategory::getSort);
|
||||
|
||||
// 查询分类列表
|
||||
List<SourceCategory> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<SourceLogMapper, SourceLog> implements SourceLogService {
|
||||
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
|
||||
@Override
|
||||
public PageVo<SourceLogVo> getLogList(Integer pageNum, Integer pageSize, Long sourceId) {
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<SourceLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (sourceId != null) {
|
||||
queryWrapper.eq(SourceLog::getSourceId, sourceId);
|
||||
}
|
||||
queryWrapper.orderByDesc(SourceLog::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<SourceLog> page = new Page<>(pageNum, pageSize);
|
||||
page(page, queryWrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<SourceLogVo> 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<SourceLogVo> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<SourceMapper, Source> implements SourceService {
|
||||
|
||||
@Autowired
|
||||
private SourceCategoryMapper sourceCategoryMapper;
|
||||
|
||||
@Override
|
||||
public PageVo<SourceVo> getSourceList(Integer pageNum, Integer pageSize, String title, Long categoryId, Integer isTime) {
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<Source> 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<Source> page = new Page<>(pageNum, pageSize);
|
||||
page(page, queryWrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<SourceVo> 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<SourceVo> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<SystemSettingMapper, SystemSetting>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<User> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<UserMapper, User>
|
||||
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("账号信息修改成功");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mzaxd.bps.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一响应结果
|
||||
*
|
||||
* @author mzaxd
|
||||
* @since 2024-04-06
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static <T> Result<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static <T> Result<T> success(T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(200);
|
||||
result.setMessage("success");
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static <T> Result<T> error(String message) {
|
||||
return error(500, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static <T> Result<T> error(Integer code, String message) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<String, String> resolveUrl(String url) {
|
||||
HashMap<String, String> 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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user