refactor: 删除Blog模块
This commit is contained in:
@@ -7,7 +7,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan(basePackages = {"com.cxx.common.mapper", "com.cxx.admin.mapper", "com.cxx.admin.dao"})
|
||||
@EnableScheduling
|
||||
public class AdminServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminServiceApplication.class, args);
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.admin.service.BlogManageService;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogVisitDto;
|
||||
import com.cxx.admin.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.admin.dto.blog.BlogDto;
|
||||
import com.cxx.admin.dto.blog.BlogVisitDto;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.cxx.admin.controller;
|
||||
|
||||
import com.cxx.admin.service.BudgetManageService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/budget-manage")
|
||||
@Tag(name = "预算管理")
|
||||
public class BudgetManageController {
|
||||
@Resource
|
||||
private BudgetManageService budgetManageService;
|
||||
|
||||
@Operation(summary = "新增预算类别")
|
||||
@PostMapping("/category")
|
||||
public Boolean addBudgetCategory(@RequestParam String category) {
|
||||
return budgetManageService.addBudgetCategory(category);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新预算类别")
|
||||
@PutMapping("/category/{id}")
|
||||
public Boolean updateBudgetCategory(@PathVariable("id") Long id, @RequestParam String category) {
|
||||
return budgetManageService.updateBudgetCategory(id, category);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.cxx.admin.controller;
|
||||
|
||||
import com.cxx.admin.dto.server.*;
|
||||
import com.cxx.admin.service.ServerMonitorService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/server-monitor")
|
||||
@Tag(name = "服务器监控")
|
||||
public class ServerMonitorController {
|
||||
@Resource
|
||||
private ServerMonitorService serverMonitorService;
|
||||
|
||||
@Operation(summary = "系统信息")
|
||||
@GetMapping("/system/info")
|
||||
public SystemInfoDto getSystemInfo() {
|
||||
return serverMonitorService.getSystemInfo();
|
||||
}
|
||||
|
||||
@Operation(summary = "系统指标")
|
||||
@GetMapping("/system/metrics")
|
||||
public List<SystemMetricsDto> querySystemMetrics(@RequestParam String range) {
|
||||
return serverMonitorService.querySystemMetrics(range);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.cxx.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogVisitDto;
|
||||
import com.cxx.common.entity.Blog;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
import com.cxx.admin.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.admin.dto.blog.BlogDto;
|
||||
import com.cxx.admin.dto.blog.BlogVisitDto;
|
||||
import com.cxx.admin.entity.Blog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.blog;
|
||||
package com.cxx.admin.dto.blog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
@@ -0,0 +1 @@
|
||||
package com.cxx.admin.dto.blog;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.blog;
|
||||
package com.cxx.admin.dto.blog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.blog;
|
||||
package com.cxx.admin.dto.blog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.blog;
|
||||
package com.cxx.admin.dto.blog;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BlogCategory;
|
||||
import com.cxx.admin.entity.BlogCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BlogContent;
|
||||
import com.cxx.admin.entity.BlogContent;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.Blog;
|
||||
import com.cxx.admin.entity.Blog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BlogVisit;
|
||||
import com.cxx.admin.entity.BlogVisit;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.FileRecord;
|
||||
import com.cxx.admin.entity.FileRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.cxx.admin.schedule;
|
||||
|
||||
import com.cxx.admin.service.ServerMonitorService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ServerMonitor {
|
||||
@Resource
|
||||
private ServerMonitorService serverMonitorService;
|
||||
|
||||
// @Scheduled(fixedRate = 60000)
|
||||
public void collectAndStoreMetrics() {
|
||||
log.info("开始存储服务器状态");
|
||||
serverMonitorService.storeSystemMetrics();
|
||||
log.info("结束存储服务器状态");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.cxx.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogVisitDto;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
import com.cxx.admin.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.admin.dto.blog.BlogDto;
|
||||
import com.cxx.admin.dto.blog.BlogVisitDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.cxx.admin.service;
|
||||
|
||||
|
||||
public interface BudgetManageService {
|
||||
Boolean addBudgetCategory(String category);
|
||||
|
||||
Boolean updateBudgetCategory(Long id, String category);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.cxx.admin.service;
|
||||
|
||||
import com.cxx.admin.dto.server.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ServerMonitorService {
|
||||
CpuDto getCpuInfo();
|
||||
|
||||
MemoryDto getMemoryInfo();
|
||||
|
||||
DiskDto getDiskInfo();
|
||||
|
||||
SystemInfoDto getSystemInfo();
|
||||
|
||||
void storeSystemMetrics();
|
||||
|
||||
List<SystemMetricsDto> querySystemMetrics(String range) ;
|
||||
}
|
||||
@@ -6,15 +6,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.cxx.admin.dao.BlogDao;
|
||||
import com.cxx.admin.service.BlogManageService;
|
||||
import com.cxx.admin.util.BlogUtils;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogVisitDto;
|
||||
import com.cxx.common.entity.Blog;
|
||||
import com.cxx.common.entity.BlogCategory;
|
||||
import com.cxx.common.entity.BlogContent;
|
||||
import com.cxx.common.mapper.BlogCategoryMapper;
|
||||
import com.cxx.common.mapper.BlogContentMapper;
|
||||
import com.cxx.common.mapper.BlogMapper;
|
||||
import com.cxx.admin.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.admin.dto.blog.BlogDto;
|
||||
import com.cxx.admin.dto.blog.BlogVisitDto;
|
||||
import com.cxx.admin.entity.Blog;
|
||||
import com.cxx.admin.entity.BlogCategory;
|
||||
import com.cxx.admin.entity.BlogContent;
|
||||
import com.cxx.admin.mapper.BlogCategoryMapper;
|
||||
import com.cxx.admin.mapper.BlogContentMapper;
|
||||
import com.cxx.admin.mapper.BlogMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.cxx.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cxx.admin.service.BudgetManageService;
|
||||
import com.cxx.common.entity.BudgetCategory;
|
||||
import com.cxx.common.mapper.BudgetCategoryMapper;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class BudgetManageServiceImpl implements BudgetManageService {
|
||||
@Resource
|
||||
private BudgetCategoryMapper budgetCategoryMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean addBudgetCategory(String category) {
|
||||
LambdaQueryWrapper<BudgetCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (budgetCategoryMapper.exists(queryWrapper.eq(BudgetCategory::getName, category))) {
|
||||
throw new CustomException("该预算类别已存在");
|
||||
}
|
||||
|
||||
BudgetCategory budgetCategory = new BudgetCategory();
|
||||
budgetCategory.setName(category);
|
||||
return budgetCategoryMapper.insert(budgetCategory) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateBudgetCategory(Long id, String category) {
|
||||
if (Objects.isNull(budgetCategoryMapper.selectById(id))) {
|
||||
throw new CustomException("该预算类别不存在");
|
||||
}
|
||||
|
||||
BudgetCategory budgetCategory = new BudgetCategory();
|
||||
budgetCategory.setId(id);
|
||||
budgetCategory.setName(category);
|
||||
|
||||
return budgetCategoryMapper.updateById(budgetCategory) == 1;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import com.cxx.admin.service.FileService;
|
||||
import com.cxx.admin.dto.file.FileRecordDto;
|
||||
import com.cxx.admin.util.FileUtils;
|
||||
import com.cxx.admin.util.UploadFileUtil;
|
||||
import com.cxx.common.entity.FileRecord;
|
||||
import com.cxx.common.mapper.FileRecordMapper;
|
||||
import com.cxx.admin.entity.FileRecord;
|
||||
import com.cxx.admin.mapper.FileRecordMapper;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
package com.cxx.admin.service.impl;
|
||||
|
||||
import com.cxx.admin.dto.server.*;
|
||||
import com.cxx.admin.service.ServerMonitorService;
|
||||
import com.influxdb.client.InfluxDBClient;
|
||||
import com.influxdb.client.InfluxDBClientFactory;
|
||||
import com.influxdb.client.QueryApi;
|
||||
import com.influxdb.client.WriteApi;
|
||||
import com.influxdb.client.domain.WritePrecision;
|
||||
import com.influxdb.client.write.Point;
|
||||
import com.influxdb.query.FluxTable;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HWDiskStore;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class ServerMonitorServiceImpl implements ServerMonitorService {
|
||||
private final SystemInfo systemInfo = new SystemInfo();
|
||||
private final HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||
private final OperatingSystem os = systemInfo.getOperatingSystem();
|
||||
private final CentralProcessor processor = hardware.getProcessor();
|
||||
|
||||
private final InfluxDBClient client;
|
||||
|
||||
private final QueryApi queryApi;
|
||||
|
||||
private final String SYSTEM_METRICS = "system_metrics";
|
||||
|
||||
private final long GB = 1024 * 1024 * 1024;
|
||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
public ServerMonitorServiceImpl(
|
||||
@Value("${influxdb.url}") String url,
|
||||
@Value("${influxdb.token}") String token,
|
||||
@Value("${influxdb.org}") String org,
|
||||
@Value("${influxdb.bucket}") String bucket) {
|
||||
this.client = InfluxDBClientFactory.create(url, token.toCharArray(), org, bucket);
|
||||
this.queryApi = this.client.getQueryApi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuDto getCpuInfo() {
|
||||
CpuDto cpuDto = new CpuDto();
|
||||
cpuDto.setUsagePercent(formatPercent(hardware.getProcessor().getSystemCpuLoad(500) * 100));
|
||||
|
||||
return cpuDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemoryDto getMemoryInfo() {
|
||||
GlobalMemory memory = hardware.getMemory();
|
||||
MemoryDto memoryDto = new MemoryDto();
|
||||
long total = memory.getTotal();
|
||||
long free = memory.getAvailable();
|
||||
long used = total - free;
|
||||
|
||||
memoryDto.setTotal(bytesToGb(total));
|
||||
memoryDto.setUsed(bytesToGb(used));
|
||||
memoryDto.setFree(bytesToGb(free));
|
||||
memoryDto.setUsagePercent(formatPercent((used * 100.0) / total));
|
||||
|
||||
return memoryDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiskDto getDiskInfo() {
|
||||
List<HWDiskStore> disks = hardware.getDiskStores();
|
||||
if (disks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取根分区信息
|
||||
HWDiskStore rootDisk = disks.get(0);
|
||||
DiskDto diskInfo = new DiskDto();
|
||||
diskInfo.setTotal(bytesToGb(rootDisk.getSize()));
|
||||
|
||||
// 获取文件系统使用情况
|
||||
os.getFileSystem().getFileStores().stream()
|
||||
.filter(fs -> fs.getMount().equals(File.separator))
|
||||
.findFirst()
|
||||
.ifPresent(fs -> {
|
||||
long total = fs.getTotalSpace();
|
||||
long free = fs.getFreeSpace();
|
||||
long used = total - free;
|
||||
|
||||
diskInfo.setUsed(bytesToGb(used));
|
||||
diskInfo.setFree(bytesToGb(free));
|
||||
diskInfo.setUsagePercent(formatPercent((double) (used) * 100.0 / total));
|
||||
});
|
||||
|
||||
return diskInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemInfoDto getSystemInfo() {
|
||||
SystemInfoDto dto = new SystemInfoDto();
|
||||
|
||||
// 获取CPU信息
|
||||
dto.setCpuName(processor.getProcessorIdentifier().getName());
|
||||
dto.setCpuVendor(processor.getProcessorIdentifier().getVendor());
|
||||
dto.setCpuLogicalCores(processor.getLogicalProcessorCount());
|
||||
dto.setCpuPhysicalCores(processor.getPhysicalProcessorCount());
|
||||
|
||||
// 获取CPU负载
|
||||
double[] loadAverage = processor.getSystemLoadAverage(3);
|
||||
dto.setCpuSystemLoad(loadAverage[0]); // 1分钟平均负载
|
||||
|
||||
// 获取操作系统信息
|
||||
dto.setOsFamily(os.getFamily());
|
||||
dto.setOsVersion(os.getVersionInfo().getVersion());
|
||||
dto.setOsManufacturer(os.getManufacturer());
|
||||
|
||||
// 获取系统运行时间(秒)
|
||||
dto.setSystemUptime(TimeUnit.MILLISECONDS.toSeconds(systemInfo.getOperatingSystem().getSystemUptime()));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeSystemMetrics() {
|
||||
try (WriteApi writeApi = client.getWriteApi()) {
|
||||
CpuDto cpuDto = getCpuInfo();
|
||||
MemoryDto memoryDto = getMemoryInfo();
|
||||
DiskDto diskDto = getDiskInfo();
|
||||
|
||||
Point point = Point
|
||||
.measurement(SYSTEM_METRICS)
|
||||
.addTag("host", "localhost")
|
||||
.addField("cpu_usage", cpuDto.getUsagePercent())
|
||||
.addField("memory_total", memoryDto.getTotal())
|
||||
.addField("memory_used", memoryDto.getUsed())
|
||||
.addField("memory_free", memoryDto.getFree())
|
||||
.addField("memory_usage", memoryDto.getUsagePercent())
|
||||
.addField("disk_total", diskDto.getTotal())
|
||||
.addField("disk_used", diskDto.getUsed())
|
||||
.addField("disk_free", diskDto.getFree())
|
||||
.addField("disk_usage", diskDto.getUsagePercent())
|
||||
.time(Instant.now(), WritePrecision.S);
|
||||
|
||||
writeApi.writePoint(point);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMetricsDto> querySystemMetrics(String range) {
|
||||
String fluxQuery = "from(bucket: \"server_metrics\")" +
|
||||
"|> range(start: -" + range + ")" + // range 可以是 "1h", "24h" 等
|
||||
"|> filter(fn: (r) => r._measurement == \"system_metrics\")" +
|
||||
"|> pivot(rowKey: [\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")";
|
||||
|
||||
List<Map<String, Object>> results = executeQuery(fluxQuery);
|
||||
|
||||
List<SystemMetricsDto> systemMetricsList = new ArrayList<>();
|
||||
|
||||
for (Map<String, Object> data : results) {
|
||||
SystemMetricsDto systemMetrics = new SystemMetricsDto();
|
||||
systemMetrics.setCpuUsage((Double) data.get("cpu_usage"));
|
||||
systemMetrics.setMemoryTotal((Double) data.get("memory_total"));
|
||||
systemMetrics.setMemoryUsed((Double) data.get("memory_used"));
|
||||
systemMetrics.setMemoryFree((Double) data.get("memory_free"));
|
||||
systemMetrics.setMemoryUsage((Double) data.get("memory_usage"));
|
||||
systemMetrics.setDiskTotal((Double) data.get("disk_total"));
|
||||
systemMetrics.setDiskUsed((Double) data.get("disk_used"));
|
||||
systemMetrics.setDiskFree((Double) data.get("disk_free"));
|
||||
systemMetrics.setDiskUsage((Double) data.get("disk_usage"));
|
||||
systemMetrics.setTime(Date.from((Instant) data.get("time")));
|
||||
|
||||
systemMetricsList.add(systemMetrics);
|
||||
}
|
||||
|
||||
return systemMetricsList;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> executeQuery(String fluxQuery) {
|
||||
List<FluxTable> tables = queryApi.query(fluxQuery);
|
||||
List<Map<String, Object>> results = new ArrayList<>();
|
||||
|
||||
for (FluxTable table : tables) {
|
||||
table.getRecords().forEach(record -> {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("time", record.getTime());
|
||||
|
||||
record.getValues().forEach((key, value) -> {
|
||||
if (!key.startsWith("_")) { // 过滤掉内部字段
|
||||
data.put(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
results.add(data);
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private double bytesToGb(long bytes) {
|
||||
double gb = bytes / (double) GB;
|
||||
return Double.parseDouble(df.format(gb));
|
||||
}
|
||||
|
||||
public double formatPercent(double percent) {
|
||||
return Double.parseDouble(df.format(percent));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.vo.blog;
|
||||
package com.cxx.admin.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
@@ -3,7 +3,7 @@ spring:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||
username: root
|
||||
password: estun@medical
|
||||
password: 123456
|
||||
|
||||
file:
|
||||
path: D:\\temp\\
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxx.admin.dao.BlogDao">
|
||||
<select id="queryBlogByPage" resultType="com.cxx.common.dto.blog.BlogDto">
|
||||
<select id="queryBlogByPage" resultType="com.cxx.admin.dto.blog.BlogDto">
|
||||
SELECT a.id AS id,
|
||||
a.title AS title,
|
||||
a.top_value AS topValue,
|
||||
@@ -21,7 +21,7 @@
|
||||
a.update_time DESC
|
||||
</select>
|
||||
|
||||
<select id="queryBlogById" resultType="com.cxx.common.dto.blog.BlogDto">
|
||||
<select id="queryBlogById" resultType="com.cxx.admin.dto.blog.BlogDto">
|
||||
SELECT a.id AS id,
|
||||
a.title AS title,
|
||||
a.top_value AS topValue,
|
||||
@@ -41,7 +41,7 @@
|
||||
WHERE a.id = #{id} LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="queryBlogCategory" resultType="com.cxx.common.dto.blog.BlogCategoryDto">
|
||||
<select id="queryBlogCategory" resultType="com.cxx.admin.dto.blog.BlogCategoryDto">
|
||||
SELECT b.name AS name,
|
||||
count(b.name) AS count
|
||||
FROM blog a
|
||||
@@ -50,7 +50,7 @@
|
||||
GROUP BY b.name
|
||||
</select>
|
||||
|
||||
<select id="queryBlogVisit" resultType="com.cxx.common.dto.blog.BlogVisitDto">
|
||||
<select id="queryBlogVisit" resultType="com.cxx.admin.dto.blog.BlogVisitDto">
|
||||
SELECT a.ip AS ip,
|
||||
a.os AS os,
|
||||
a.browser AS browser,
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
FROM docker-0.unsee.tech/openjdk:11-jdk-slim
|
||||
ARG JAR_FILE=target/*.jar
|
||||
COPY $JAR_FILE app.jar
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo 'Asia/Shanghai' > /etc/timezone
|
||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
@@ -1 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.cxx.blog;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan(basePackages = {"com.cxx.common.mapper", "com.cxx.blog.dao"})
|
||||
public class BlogServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BlogServiceApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.cxx.blog.config;
|
||||
|
||||
import com.cxx.blog.service.BlogService;
|
||||
import com.cxx.common.entity.BlogVisit;
|
||||
import com.cxx.blog.util.IpUtils;
|
||||
import eu.bitwalker.useragentutils.Browser;
|
||||
import eu.bitwalker.useragentutils.OperatingSystem;
|
||||
import eu.bitwalker.useragentutils.UserAgent;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* 利用AOP监控博客访问
|
||||
* 1. @Before:前置通知,在方法执行之前执行
|
||||
* 2. @After:后置通知,在方法执行之后执行
|
||||
* 3. @AfterRunning:返回通知,在方法返回结果之后执行
|
||||
* 4. @AfterThrowing:异常通知,在方法抛出异常之后执行
|
||||
* 5. @Around:环绕通知,围绕着方法执行
|
||||
*/
|
||||
@Component
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class BlogVisitMonitor {
|
||||
@Resource
|
||||
private BlogService blogService;
|
||||
|
||||
/**
|
||||
* 定义切面
|
||||
* 指定需要统计的包
|
||||
*/
|
||||
@Pointcut("execution(* com.cxx.blog.controller.BlogController.*(..))")
|
||||
public void pointCut() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有正常返回才会执行此方法
|
||||
* 如果程序执行失败,则不执行此方法
|
||||
*/
|
||||
@AfterReturning(returning = "returnVal", pointcut = "pointCut()")
|
||||
public void doAfterReturning(JoinPoint joinPoint, Object returnVal) {
|
||||
// 获取接收到的HTTP请求信息
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
||||
String agent = request.getHeader("User-Agent");
|
||||
UserAgent userAgent = UserAgent.parseUserAgentString(agent);
|
||||
OperatingSystem os = userAgent.getOperatingSystem();
|
||||
Browser browser = userAgent.getBrowser();
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
BlogVisit blogVisit = new BlogVisit();
|
||||
blogVisit.setIp(IpUtils.getIpAddress(request));
|
||||
blogVisit.setOs(os.getName());
|
||||
blogVisit.setBrowser(browser.getName() + "-" + userAgent.getBrowserVersion());
|
||||
blogVisit.setUri(uri);
|
||||
blogVisit.setBlogId(0L);
|
||||
|
||||
if (blogVisit.getUri().contains("content")) {
|
||||
blogVisit.setBlogId(Long.valueOf(uri.split("/")[3]));
|
||||
}
|
||||
|
||||
blogService.addBlogVisit(blogVisit);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.cxx.blog.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.blog.service.BlogService;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogLatestDto;
|
||||
import com.cxx.common.dto.blog.BlogStatsDto;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/blog")
|
||||
@Tag(name = "查看博客")
|
||||
public class BlogController {
|
||||
@Resource
|
||||
private BlogService blogService;
|
||||
|
||||
@Operation(summary = "分页查询博客")
|
||||
@GetMapping("/page")
|
||||
public IPage<BlogDto> queryBlogByPage(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
return blogService.queryBlogByPage(currentPage, pageSize);
|
||||
}
|
||||
|
||||
@Operation(summary = "条件查询博客")
|
||||
@GetMapping("/condition")
|
||||
public @JsonView(ReadView.class) List<BlogDto> queryBlogByCondition(BlogQueryVo query) {
|
||||
return blogService.queryBlogByCondition(query);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询博客内容")
|
||||
@GetMapping("/content/{id}")
|
||||
public @JsonView(ReadView.class) BlogDto queryBlogById(@PathVariable("id") long id) {
|
||||
return blogService.queryBlogById(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询博客分类")
|
||||
@GetMapping("/category")
|
||||
public List<BlogCategoryDto> queryBlogCategory() {
|
||||
return blogService.queryBlogCategory();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询博客统计信息")
|
||||
@GetMapping("/stats")
|
||||
public BlogStatsDto queryBlogStats() {
|
||||
return blogService.queryBlogStats();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询近期博客")
|
||||
@GetMapping("/latest")
|
||||
public List<BlogLatestDto> queryLatestBlog() {
|
||||
return blogService.queryLatestBlog();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.cxx.blog.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogLatestDto;
|
||||
import com.cxx.common.entity.Blog;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BlogDao {
|
||||
IPage<BlogDto> queryBlogByPage(IPage<Blog> page);
|
||||
|
||||
List<BlogDto> queryBlogByCondition(@Param("query") BlogQueryVo query);
|
||||
|
||||
BlogDto queryBlogById(@Param("id") Long id);
|
||||
|
||||
List<BlogCategoryDto> queryBlogCategory();
|
||||
|
||||
List<BlogLatestDto> queryLatestBlog();
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.cxx.blog.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogLatestDto;
|
||||
import com.cxx.common.dto.blog.BlogStatsDto;
|
||||
import com.cxx.common.entity.BlogVisit;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface BlogService {
|
||||
IPage<BlogDto> queryBlogByPage(Integer currentPage, Integer pageSize);
|
||||
|
||||
List<BlogDto> queryBlogByCondition(BlogQueryVo query);
|
||||
|
||||
BlogDto queryBlogById(Long id);
|
||||
|
||||
List<BlogCategoryDto> queryBlogCategory();
|
||||
|
||||
BlogStatsDto queryBlogStats();
|
||||
|
||||
List<BlogLatestDto> queryLatestBlog();
|
||||
|
||||
void addBlogVisit(BlogVisit blogVisit);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.cxx.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.cxx.blog.dao.BlogDao;
|
||||
import com.cxx.blog.service.BlogService;
|
||||
import com.cxx.common.dto.blog.BlogCategoryDto;
|
||||
import com.cxx.common.dto.blog.BlogDto;
|
||||
import com.cxx.common.dto.blog.BlogLatestDto;
|
||||
import com.cxx.common.dto.blog.BlogStatsDto;
|
||||
import com.cxx.common.entity.BlogVisit;
|
||||
import com.cxx.common.mapper.BlogCategoryMapper;
|
||||
import com.cxx.common.mapper.BlogMapper;
|
||||
import com.cxx.common.mapper.BlogVisitMapper;
|
||||
import com.cxx.common.vo.blog.BlogQueryVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BlogServiceImpl implements BlogService {
|
||||
@Resource
|
||||
private BlogDao blogDao;
|
||||
|
||||
@Resource
|
||||
private BlogMapper blogMapper;
|
||||
|
||||
@Resource
|
||||
private BlogCategoryMapper categoryMapper;
|
||||
|
||||
@Resource
|
||||
private BlogVisitMapper visitMapper;
|
||||
|
||||
@Override
|
||||
public IPage<BlogDto> queryBlogByPage(Integer currentPage, Integer pageSize) {
|
||||
return blogDao.queryBlogByPage(new Page<>(currentPage, pageSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlogDto> queryBlogByCondition(BlogQueryVo query) {
|
||||
return blogDao.queryBlogByCondition(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlogDto queryBlogById(Long id) {
|
||||
return blogDao.queryBlogById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlogCategoryDto> queryBlogCategory() {
|
||||
return blogDao.queryBlogCategory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlogStatsDto queryBlogStats() {
|
||||
BlogStatsDto blogStats = new BlogStatsDto();
|
||||
blogStats.setBlogCount(blogMapper.selectCount(null));
|
||||
blogStats.setCategoryCount(categoryMapper.selectCount(null));
|
||||
|
||||
return blogStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlogLatestDto> queryLatestBlog() {
|
||||
return blogDao.queryLatestBlog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlogVisit(BlogVisit blogVisit) {
|
||||
visitMapper.insert(blogVisit);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.cxx.blog.util;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlogUtils {
|
||||
public static File multipartFileToFile(MultipartFile multipartFile) {
|
||||
if (multipartFile.getOriginalFilename() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(multipartFile.getOriginalFilename());
|
||||
try {
|
||||
InputStream ins = multipartFile.getInputStream();
|
||||
OutputStream os = new FileOutputStream(file);
|
||||
int bytesRead = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
}
|
||||
os.close();
|
||||
ins.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.cxx.blog.util;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class IpUtils {
|
||||
private static final String UNKNOWN = "unknown";
|
||||
private static final String LOCALHOST_IP = "127.0.0.1";
|
||||
// 客户端与服务器同为一台机器,获取的 ip 有时候是 ipv6 格式
|
||||
private static final String LOCALHOST_IPV6 = "0:0:0:0:0:0:0:1";
|
||||
private static final String SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 根据 HttpServletRequest 获取 IP
|
||||
* @param request 请求
|
||||
* @return ip
|
||||
*/
|
||||
public static String getIpAddress(HttpServletRequest request) {
|
||||
if (request == null) {
|
||||
return "unknown";
|
||||
}
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Forwarded-For");
|
||||
}
|
||||
if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
}
|
||||
if (ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
if (LOCALHOST_IP.equalsIgnoreCase(ip) || LOCALHOST_IPV6.equalsIgnoreCase(ip)) {
|
||||
// 根据网卡取本机配置的 IP
|
||||
InetAddress iNet = null;
|
||||
try {
|
||||
iNet = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (iNet != null)
|
||||
ip = iNet.getHostAddress();
|
||||
}
|
||||
}
|
||||
// 对于通过多个代理的情况,分割出第一个 IP
|
||||
if (ip != null && ip.length() > 15) {
|
||||
if (ip.indexOf(SEPARATOR) > 0) {
|
||||
ip = ip.substring(0, ip.indexOf(SEPARATOR));
|
||||
}
|
||||
}
|
||||
return LOCALHOST_IPV6.equals(ip) ? LOCALHOST_IP : ip;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
config:
|
||||
@@ -1,13 +0,0 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://mysql:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||
username: docker
|
||||
password: 19940822Cxx
|
||||
|
||||
logging:
|
||||
fluentd:
|
||||
host: fluent-bit
|
||||
port: 24224
|
||||
level:
|
||||
root: info
|
||||
@@ -1,12 +0,0 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||
username: cxx
|
||||
password: 19940822Cxx@1213
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
config:
|
||||
classpath:logback-spring-drop.xml
|
||||
@@ -1,20 +0,0 @@
|
||||
server:
|
||||
port: 8082
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @project.artifactId@
|
||||
version: @project.version@
|
||||
profiles:
|
||||
active: dev
|
||||
|
||||
# mybatis plus mapper路径
|
||||
mybatis-plus:
|
||||
# mybatis plus
|
||||
mapper-locations: classpath*:/mapper/**/*.xml
|
||||
configuration:
|
||||
log-impl:
|
||||
org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
web-starter:
|
||||
base-package: com.cxx.blog
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="10 seconds">
|
||||
|
||||
<contextName>logback</contextName>
|
||||
|
||||
<property name="log.path" value="logs/blogService"/>
|
||||
|
||||
<!--控制台日志格式:彩色日志-->
|
||||
<!-- magenta:洋红 -->
|
||||
<!-- boldMagenta:粗红-->
|
||||
<!-- cyan:青色 -->
|
||||
<!-- white:白色 -->
|
||||
<!-- magenta:洋红 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%blue(%thread) |%blue(%file:%line) |%green(%logger) |%cyan(%msg%n)"/>
|
||||
|
||||
<!--文件日志格式-->
|
||||
<property name="FILE_LOG_PATTERN"
|
||||
value="%date{yyyy-MM-dd HH:mm:ss} |%-5level |%thread |%file:%line |%logger |%msg%n"/>
|
||||
|
||||
<!--编码-->
|
||||
<property name="ENCODING"
|
||||
value="UTF-8"/>
|
||||
|
||||
<!--输出到控制台-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<!--日志级别-->
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<!--日志格式-->
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||
<!--日志字符集-->
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--输出到文件-->
|
||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--日志过滤器:此日志文件只记录INFO级别的-->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${log.path}/log_info.log</file>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 日志过滤器:此日志文件只记录WARN级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>WARN</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${log.path}/log_warn.log</file>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<charset>${ENCODING}</charset> <!-- 此处设置字符集 -->
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 日志过滤器:此日志文件只记录ERROR级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${log.path}/log_error.log</file>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<charset>${ENCODING}</charset> <!-- 此处设置字符集 -->
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="INFO_FILE"/>
|
||||
<appender-ref ref="WARN_FILE"/>
|
||||
<appender-ref ref="ERROR_FILE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxx.blog.dao.BlogDao">
|
||||
<select id="queryBlogByPage" resultType="com.cxx.common.dto.blog.BlogDto">
|
||||
SELECT a.id AS id,
|
||||
a.title AS title,
|
||||
a.top_value AS topValue,
|
||||
a.is_great AS isGreat,
|
||||
b.NAME AS category,
|
||||
a.summary AS summary,
|
||||
a.word_count AS wordCount,
|
||||
a.read_duration AS readDuration,
|
||||
COUNT(c.id) AS visitCount,
|
||||
a.create_time AS createTime,
|
||||
a.update_time AS updateTime
|
||||
FROM blog a
|
||||
LEFT JOIN blog_category b ON b.id = a.category_id
|
||||
LEFT JOIN blog_visit c ON c.blog_id = a.id
|
||||
GROUP BY a.id
|
||||
ORDER BY a.top_value DESC,
|
||||
a.update_time DESC
|
||||
</select>
|
||||
|
||||
<select id="queryBlogByCondition" resultType="com.cxx.common.dto.blog.BlogDto">
|
||||
SELECT a.id AS id,
|
||||
a.title AS title,
|
||||
a.top_value AS topValue,
|
||||
a.is_great AS isGreat,
|
||||
b.name AS category,
|
||||
a.summary AS summary,
|
||||
c.content AS content,
|
||||
a.word_count AS wordCount,
|
||||
a.read_duration AS readDuration,
|
||||
a.create_time AS createTime,
|
||||
a.update_time AS updateTime
|
||||
FROM blog a
|
||||
LEFT JOIN blog_category b on a.category_id = b.id
|
||||
LEFT JOIN blog_content c on a.content_id = c.id
|
||||
<where>
|
||||
<if test="query.category != null and query.category != ''">
|
||||
b.name = #{query.category}
|
||||
</if>
|
||||
<if test="query.title != null and query.title != ''">
|
||||
AND a.title LIKE CONCAT('%',#{query.title},'%')
|
||||
</if>
|
||||
<if test="query.year != null">
|
||||
AND YEAR(a.create_time) = #{query.year}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.update_time DESC
|
||||
</select>
|
||||
|
||||
<select id="queryBlogById" resultType="com.cxx.common.dto.blog.BlogDto">
|
||||
SELECT a.id AS id,
|
||||
a.title AS title,
|
||||
a.top_value AS topValue,
|
||||
a.is_great AS isGreat,
|
||||
b.NAME AS category,
|
||||
a.summary AS summary,
|
||||
c.content AS content,
|
||||
a.word_count AS wordCount,
|
||||
a.read_duration AS readDuration,
|
||||
COUNT(d.id) AS visitCount,
|
||||
a.create_time AS createTime,
|
||||
a.update_time AS updateTime
|
||||
FROM blog a
|
||||
LEFT JOIN blog_category b ON b.id = a.category_id
|
||||
LEFT JOIN blog_content c ON c.id = a.content_id
|
||||
LEFT JOIN blog_visit d ON d.blog_id = a.id
|
||||
WHERE a.id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="queryBlogCategory" resultType="com.cxx.common.dto.blog.BlogCategoryDto">
|
||||
SELECT b.name AS name,
|
||||
count(b.name) AS count
|
||||
FROM blog a
|
||||
LEFT JOIN blog_category b
|
||||
ON a.category_id = b.id
|
||||
GROUP BY b.name
|
||||
</select>
|
||||
|
||||
<select id="queryLatestBlog" resultType="com.cxx.common.dto.blog.BlogLatestDto">
|
||||
SELECT id AS id,
|
||||
title AS title
|
||||
FROM blog
|
||||
ORDER BY update_time DESC
|
||||
LIMIT 5
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.cxx.blog;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* @Author: Cxx
|
||||
* @Date: 2024/9/22 0:17
|
||||
* @Description:
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class BlogServiceTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package com.cxx.common.dto.blog;
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.cxx.common.dto.budget;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.PositiveOrZero;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonView(PlainView.class)
|
||||
public class BudgetDto {
|
||||
@Schema(description = "id")
|
||||
@JsonView(ReadView.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "预算类别")
|
||||
@NotBlank(message = "类别不能为空")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "预算项目")
|
||||
@NotBlank(message = "项目不能为空")
|
||||
private String project;
|
||||
|
||||
@Schema(description = "预算内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "供应商")
|
||||
private String vendor;
|
||||
|
||||
@Schema(description = "预算支出")
|
||||
@PositiveOrZero(message = "预算支出支出必须大于等于0")
|
||||
private Double budget;
|
||||
|
||||
@Schema(description = "实际支出")
|
||||
@PositiveOrZero(message = "实际支出支出必须大于等于0")
|
||||
private Double actual;
|
||||
|
||||
@Schema(description = "支付时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date payTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remake;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.cxx.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cxx.framework.data.AbstractEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("budget")
|
||||
public class Budget extends AbstractEntity {
|
||||
@TableField("category_id")
|
||||
private Long categoryId;
|
||||
|
||||
@TableField("project")
|
||||
private String project;
|
||||
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
@TableField("vendor")
|
||||
private String vendor;
|
||||
|
||||
@TableField("budget")
|
||||
private Double budget;
|
||||
|
||||
@TableField("actual")
|
||||
private Double actual;
|
||||
|
||||
@TableField("pay_time")
|
||||
private Date payTime;
|
||||
|
||||
@TableField("remake")
|
||||
private String remake;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.cxx.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cxx.framework.data.AbstractEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("budget_category")
|
||||
public class BudgetCategory extends AbstractEntity {
|
||||
@TableField("name")
|
||||
private String name;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.cxx.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BudgetCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BudgetCategoryMapper extends BaseMapper<BudgetCategory> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.cxx.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.Budget;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BudgetMapper extends BaseMapper<Budget> {
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package com.cxx.home.controller;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.bill.BillCategoryDto;
|
||||
import com.cxx.common.dto.bill.BillItemDto;
|
||||
import com.cxx.common.dto.bill.BillRecordDto;
|
||||
import com.cxx.common.dto.bill.BillSummaryDto;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillRecordDto;
|
||||
import com.cxx.home.dto.bill.BillSummaryDto;
|
||||
import com.cxx.home.service.BillRecordService;
|
||||
import com.cxx.common.vo.bill.BillQueryVo;
|
||||
import com.cxx.home.vo.BillQueryVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.cxx.admin.controller;
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.admin.service.BillManageService;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.bill.BillCategoryDto;
|
||||
import com.cxx.common.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.home.service.BillManageService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.budget.BudgetDto;
|
||||
import com.cxx.home.service.BudgetService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/budget")
|
||||
@Tag(name = "预算统计")
|
||||
public class BudgetController {
|
||||
@Resource
|
||||
private BudgetService budgetService;
|
||||
|
||||
@Operation(summary = "查询预算类别")
|
||||
@GetMapping("/category")
|
||||
public List<String> queryBudgetCategory() {
|
||||
return budgetService.queryBudgetCategory();
|
||||
}
|
||||
|
||||
@Operation(summary = "新增预算")
|
||||
@PostMapping("")
|
||||
public Boolean addBudget(@RequestBody @JsonView(WriteView.class) @Validated BudgetDto budgetDto) {
|
||||
return budgetService.addBudget(budgetDto);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新预算")
|
||||
@PutMapping("/{id}")
|
||||
public Boolean updateBudget(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) BudgetDto budgetDto) {
|
||||
return budgetService.updateBudget(id, budgetDto);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除预算")
|
||||
@DeleteMapping("/{id}")
|
||||
public Boolean deleteBudget(@PathVariable("id") long id) {
|
||||
return budgetService.deleteBudget(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询预算")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<BudgetDto> queryBudget(@RequestParam("category") String category) {
|
||||
return budgetService.queryBudget(category);
|
||||
}
|
||||
|
||||
@Operation(summary = "预算排行统计")
|
||||
@GetMapping("stats/rank")
|
||||
public List<StatsChartDto> queryBudgetRankStats(@RequestParam("category") String category) {
|
||||
return budgetService.queryBudgetRankStats(category);
|
||||
}
|
||||
|
||||
@Operation(summary = "预算项目统计")
|
||||
@GetMapping("stats/project")
|
||||
public List<StatsChartDto> queryBudgetProjectStats(@RequestParam("category") String category) {
|
||||
return budgetService.queryBudgetProjectStats(category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.plan.PlanDto;
|
||||
import com.cxx.common.dto.plan.PlanStatsDto;
|
||||
import com.cxx.common.vo.plan.PlanQueryVo;
|
||||
import com.cxx.home.dto.plan.PlanDto;
|
||||
import com.cxx.home.dto.plan.PlanStatsDto;
|
||||
import com.cxx.home.vo.PlanQueryVo;
|
||||
import com.cxx.home.service.PlanService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.cxx.home.dao;
|
||||
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.bill.*;
|
||||
import com.cxx.common.vo.bill.BillQueryVo;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillRecordDto;
|
||||
import com.cxx.home.dto.bill.BillSummaryDto;
|
||||
import com.cxx.home.vo.BillQueryVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.cxx.home.dao;
|
||||
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.budget.BudgetDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BudgetDao {
|
||||
List<BudgetDto> queryBudget(@Param("category") String category);
|
||||
|
||||
List<StatsChartDto> queryBudgetRankStats(@Param("category") String category);
|
||||
|
||||
List<StatsChartDto> queryBudgetProjectStats(@Param("category") String category);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.cxx.home.dao;
|
||||
|
||||
import com.cxx.common.dto.plan.PlanDto;
|
||||
import com.cxx.common.dto.plan.PlanStatsDto;
|
||||
import com.cxx.common.vo.plan.PlanQueryVo;
|
||||
import com.cxx.home.dto.plan.PlanDto;
|
||||
import com.cxx.home.dto.plan.PlanStatsDto;
|
||||
import com.cxx.home.vo.PlanQueryVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.bill;
|
||||
package com.cxx.home.dto.bill;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.bill;
|
||||
package com.cxx.home.dto.bill;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.bill;
|
||||
package com.cxx.home.dto.bill;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.bill;
|
||||
package com.cxx.home.dto.bill;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.message;
|
||||
package com.cxx.home.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.plan;
|
||||
package com.cxx.home.dto.plan;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.plan;
|
||||
package com.cxx.home.dto.plan;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.task;
|
||||
package com.cxx.home.dto.task;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.entity;
|
||||
package com.cxx.home.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BillBook;
|
||||
import com.cxx.home.entity.BillBook;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BillCategory;
|
||||
import com.cxx.home.entity.BillCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BillImage;
|
||||
import com.cxx.home.entity.BillImage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BillPay;
|
||||
import com.cxx.home.entity.BillPay;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.BillRecord;
|
||||
import com.cxx.home.entity.BillRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.Plan;
|
||||
import com.cxx.home.entity.Plan;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.common.mapper;
|
||||
package com.cxx.home.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.home.entity.Task;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.home.schedule;
|
||||
|
||||
|
||||
import com.cxx.common.dto.task.TaskDto;
|
||||
import com.cxx.home.dto.task.TaskDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.cxx.home.schedule;
|
||||
|
||||
import com.cxx.common.dto.message.MailMessageDto;
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.home.dto.message.MailMessageDto;
|
||||
import com.cxx.home.entity.Task;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import com.cxx.common.mapper.TaskMapper;
|
||||
import com.cxx.home.mapper.TaskMapper;
|
||||
import com.cxx.home.service.MessageService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.home.schedule;
|
||||
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.home.entity.Task;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import org.quartz.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.admin.service;
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.dto.bill.BillCategoryDto;
|
||||
import com.cxx.common.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
|
||||
public interface BillManageService {
|
||||
Boolean addBillPay(BillItemDto billItemDto);
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.bill.BillCategoryDto;
|
||||
import com.cxx.common.dto.bill.BillItemDto;
|
||||
import com.cxx.common.dto.bill.BillRecordDto;
|
||||
import com.cxx.common.dto.bill.BillSummaryDto;
|
||||
import com.cxx.common.vo.bill.BillQueryVo;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillRecordDto;
|
||||
import com.cxx.home.dto.bill.BillSummaryDto;
|
||||
import com.cxx.home.vo.BillQueryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.budget.BudgetDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BudgetService {
|
||||
List<String> queryBudgetCategory();
|
||||
|
||||
Boolean addBudget(BudgetDto budgetDto);
|
||||
|
||||
Boolean updateBudget(Long id, BudgetDto budgetDto);
|
||||
|
||||
Boolean deleteBudget(Long id);
|
||||
|
||||
List<BudgetDto> queryBudget(String category);
|
||||
|
||||
List<StatsChartDto> queryBudgetRankStats(String category);
|
||||
|
||||
List<StatsChartDto> queryBudgetProjectStats(String category);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.dto.message.MailMessageDto;
|
||||
import com.cxx.home.dto.message.MailMessageDto;
|
||||
|
||||
public interface MessageService {
|
||||
void sendMailMessage(MailMessageDto mailMessageDto);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.dto.plan.PlanDto;
|
||||
import com.cxx.common.dto.plan.PlanStatsDto;
|
||||
import com.cxx.common.vo.plan.PlanQueryVo;
|
||||
import com.cxx.home.dto.plan.PlanDto;
|
||||
import com.cxx.home.dto.plan.PlanStatsDto;
|
||||
import com.cxx.home.vo.PlanQueryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.home.entity.Task;
|
||||
import com.cxx.home.schedule.QuartzDto;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.home.service;
|
||||
|
||||
import com.cxx.common.dto.task.TaskDto;
|
||||
import com.cxx.home.dto.task.TaskDto;
|
||||
|
||||
|
||||
public interface TaskService {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.cxx.admin.service.impl;
|
||||
package com.cxx.home.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cxx.admin.service.BillManageService;
|
||||
import com.cxx.common.dto.bill.BillCategoryDto;
|
||||
import com.cxx.common.dto.bill.BillItemDto;
|
||||
import com.cxx.common.entity.BillBook;
|
||||
import com.cxx.common.entity.BillCategory;
|
||||
import com.cxx.common.entity.BillPay;
|
||||
import com.cxx.common.mapper.BillBookMapper;
|
||||
import com.cxx.common.mapper.BillCategoryMapper;
|
||||
import com.cxx.common.mapper.BillPayMapper;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import com.cxx.home.entity.BillBook;
|
||||
import com.cxx.home.entity.BillCategory;
|
||||
import com.cxx.home.entity.BillPay;
|
||||
import com.cxx.home.mapper.BillBookMapper;
|
||||
import com.cxx.home.mapper.BillCategoryMapper;
|
||||
import com.cxx.home.mapper.BillPayMapper;
|
||||
import com.cxx.home.service.BillManageService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -3,21 +3,16 @@ package com.cxx.home.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.bill.*;
|
||||
import com.cxx.common.entity.*;
|
||||
import com.cxx.common.mapper.*;
|
||||
import com.cxx.common.entity.BillBook;
|
||||
import com.cxx.common.entity.BillCategory;
|
||||
import com.cxx.common.entity.BillPay;
|
||||
import com.cxx.common.entity.BillRecord;
|
||||
import com.cxx.common.mapper.BillBookMapper;
|
||||
import com.cxx.common.mapper.BillCategoryMapper;
|
||||
import com.cxx.common.mapper.BillPayMapper;
|
||||
import com.cxx.common.mapper.BillRecordMapper;
|
||||
import com.cxx.home.dto.bill.BillCategoryDto;
|
||||
import com.cxx.home.dto.bill.BillItemDto;
|
||||
import com.cxx.home.dto.bill.BillRecordDto;
|
||||
import com.cxx.home.dto.bill.BillSummaryDto;
|
||||
import com.cxx.home.entity.*;
|
||||
import com.cxx.home.mapper.*;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import com.cxx.home.dao.BillDao;
|
||||
import com.cxx.home.service.BillRecordService;
|
||||
import com.cxx.common.vo.bill.BillQueryVo;
|
||||
import com.cxx.home.vo.BillQueryVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.cxx.home.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SimpleQuery;
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.common.dto.budget.BudgetDto;
|
||||
import com.cxx.common.entity.Budget;
|
||||
import com.cxx.common.entity.BudgetCategory;
|
||||
import com.cxx.common.mapper.BudgetCategoryMapper;
|
||||
import com.cxx.common.mapper.BudgetMapper;
|
||||
import com.cxx.home.dao.BudgetDao;
|
||||
import com.cxx.home.service.BudgetService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class BudgetServiceImpl implements BudgetService {
|
||||
@Resource
|
||||
private BudgetDao budgetDao;
|
||||
|
||||
@Resource
|
||||
private BudgetMapper budgetMapper;
|
||||
|
||||
@Resource
|
||||
private BudgetCategoryMapper budgetCategoryMapper;
|
||||
|
||||
@Override
|
||||
public List<String> queryBudgetCategory() {
|
||||
LambdaQueryWrapper<BudgetCategory> queryWrapper = Wrappers.lambdaQuery(BudgetCategory.class);
|
||||
return SimpleQuery.list(queryWrapper.select(BudgetCategory::getName), BudgetCategory::getName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addBudget(BudgetDto budgetDto) {
|
||||
Budget budge = new Budget();
|
||||
BeanUtils.copyProperties(budgetDto, budge);
|
||||
budge.setCategoryId(getBudgetCategory(budgetDto.getCategory()));
|
||||
|
||||
return budgetMapper.insert(budge) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateBudget(Long id, BudgetDto budgetDto) {
|
||||
Budget budge = new Budget();
|
||||
BeanUtils.copyProperties(budgetDto, budge);
|
||||
budge.setCategoryId(getBudgetCategory(budgetDto.getCategory()));
|
||||
budge.setId(id);
|
||||
return budgetMapper.updateById(budge) == 1;
|
||||
}
|
||||
|
||||
private Long getBudgetCategory(String category) {
|
||||
LambdaQueryWrapper<BudgetCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
BudgetCategory budgetCategory = budgetCategoryMapper.selectOne(queryWrapper.eq(BudgetCategory::getName, category));
|
||||
if (Objects.isNull(budgetCategory)) {
|
||||
BudgetCategory newBudgetCategory = new BudgetCategory();
|
||||
newBudgetCategory.setName(category);
|
||||
budgetCategoryMapper.insert(newBudgetCategory);
|
||||
return newBudgetCategory.getId();
|
||||
} else {
|
||||
return budgetCategory.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteBudget(Long id) {
|
||||
return budgetMapper.deleteById(id) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BudgetDto> queryBudget(String category) {
|
||||
return budgetDao.queryBudget(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatsChartDto> queryBudgetRankStats(String category) {
|
||||
return budgetDao.queryBudgetRankStats(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatsChartDto> queryBudgetProjectStats(String category) {
|
||||
return budgetDao.queryBudgetProjectStats(category);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.home.service.impl;
|
||||
|
||||
import com.cxx.common.dto.message.MailMessageDto;
|
||||
import com.cxx.home.dto.message.MailMessageDto;
|
||||
import com.cxx.home.service.MessageService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.mail.MessagingException;
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.cxx.home.service.impl;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.cxx.common.dto.message.MailMessageDto;
|
||||
import com.cxx.common.dto.plan.PlanDto;
|
||||
import com.cxx.common.dto.plan.PlanStatsDto;
|
||||
import com.cxx.common.dto.task.TaskDto;
|
||||
import com.cxx.common.entity.Plan;
|
||||
import com.cxx.common.mapper.PlanMapper;
|
||||
import com.cxx.common.vo.plan.PlanQueryVo;
|
||||
import com.cxx.home.dto.message.MailMessageDto;
|
||||
import com.cxx.home.dto.plan.PlanDto;
|
||||
import com.cxx.home.dto.plan.PlanStatsDto;
|
||||
import com.cxx.home.dto.task.TaskDto;
|
||||
import com.cxx.home.entity.Plan;
|
||||
import com.cxx.home.mapper.PlanMapper;
|
||||
import com.cxx.home.vo.PlanQueryVo;
|
||||
import com.cxx.home.dao.PlanDao;
|
||||
import com.cxx.home.schedule.TaskType;
|
||||
import com.cxx.home.service.PlanService;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cxx.home.service.impl;
|
||||
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.common.mapper.TaskMapper;
|
||||
import com.cxx.home.entity.Task;
|
||||
import com.cxx.home.mapper.TaskMapper;
|
||||
import com.cxx.framework.web.CustomException;
|
||||
import com.cxx.home.schedule.QuartzDto;
|
||||
import com.cxx.home.schedule.QuartzUtils;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.cxx.home.service.impl;
|
||||
|
||||
import com.cxx.common.dto.task.TaskDto;
|
||||
import com.cxx.common.entity.Task;
|
||||
import com.cxx.common.mapper.TaskMapper;
|
||||
import com.cxx.home.dto.task.TaskDto;
|
||||
import com.cxx.home.entity.Task;
|
||||
import com.cxx.home.mapper.TaskMapper;
|
||||
import com.cxx.home.service.QuartzService;
|
||||
import com.cxx.home.service.TaskService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user