Compare commits
26 Commits
60321e1722
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a70fe6c9ef | |||
| 69df40a47d | |||
| fe89d3cc85 | |||
| 20aa820794 | |||
| 17b20a3d4b | |||
| 638a1a9186 | |||
| 1a4b1a8639 | |||
| 1b56f33a02 | |||
| fb4ec4a50f | |||
| 20da1e064b | |||
| 3e83adf4f8 | |||
| fcaef1409d | |||
| ea8d6cfa12 | |||
| 4cbf49d2a3 | |||
| f9d01b7b36 | |||
| c8d2bd1df0 | |||
| 67c72779ad | |||
| 6ea9e4e9cc | |||
| b3a2844f5a | |||
| 7ce83bb52f | |||
| 31c67e8a11 | |||
| d119e7aee8 | |||
| 7ca52c0537 | |||
| 43500ede69 | |||
| 1bc78e80b7 | |||
| f13c26251f |
@@ -47,12 +47,12 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- <build>-->
|
||||
<!-- <plugins>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- </plugins>-->
|
||||
<!-- </build>-->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -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);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cxx.admin.controller;
|
||||
import com.cxx.admin.service.AccountService;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.admin.dto.user.AccountDto;
|
||||
import com.cxx.common.dto.AccountDto;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -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,6 +1,7 @@
|
||||
package com.cxx.admin.controller;
|
||||
|
||||
import com.cxx.common.dto.user.SessionDto;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.cxx.common.dto.SessionDto;
|
||||
import com.cxx.admin.service.SessionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -16,6 +17,7 @@ public class SessionController {
|
||||
|
||||
@Operation(summary = "创建会话")
|
||||
@PostMapping("")
|
||||
@SaIgnore
|
||||
public SessionDto createSession(@RequestParam String name,
|
||||
@RequestParam String password) {
|
||||
return sessionService.create(name, password);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.admin.dao;
|
||||
|
||||
import com.cxx.admin.dto.user.AccountDto;
|
||||
import com.cxx.common.dto.AccountDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -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,10 +0,0 @@
|
||||
package com.cxx.admin.dto.server;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CpuDto {
|
||||
private double usagePercent;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.cxx.admin.dto.server;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DiskDto {
|
||||
private double total;
|
||||
private double used;
|
||||
private double free;
|
||||
private double usagePercent;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.cxx.admin.dto.server;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MemoryDto {
|
||||
private double total;
|
||||
private double used;
|
||||
private double free;
|
||||
private double usagePercent;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.cxx.admin.dto.server;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemInfoDto {
|
||||
// CPU信息
|
||||
private String cpuName;
|
||||
private String cpuVendor;
|
||||
private int cpuLogicalCores;
|
||||
private int cpuPhysicalCores;
|
||||
private double cpuSystemLoad;
|
||||
// 操作系统信息
|
||||
private String osFamily;
|
||||
private String osVersion;
|
||||
private String osManufacturer;
|
||||
// 系统运行时间
|
||||
private long systemUptime;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.cxx.admin.dto.server;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemMetricsDto {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date time;
|
||||
|
||||
private double cpuUsage;
|
||||
private double memoryTotal;
|
||||
private double memoryUsed;
|
||||
private double memoryFree;
|
||||
private double memoryUsage;
|
||||
private double diskTotal;
|
||||
private double diskUsed;
|
||||
private double diskFree;
|
||||
private double diskUsage;
|
||||
}
|
||||
@@ -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,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,7 +1,7 @@
|
||||
package com.cxx.admin.service;
|
||||
|
||||
|
||||
import com.cxx.admin.dto.user.AccountDto;
|
||||
import com.cxx.common.dto.AccountDto;
|
||||
import com.cxx.common.entity.Account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -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) ;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.admin.service;
|
||||
|
||||
import com.cxx.common.dto.user.SessionDto;
|
||||
import com.cxx.common.dto.SessionDto;
|
||||
|
||||
public interface SessionService {
|
||||
SessionDto create(String name, String password);
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.cxx.admin.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cxx.admin.dao.AccountDao;
|
||||
import com.cxx.admin.service.AccountService;
|
||||
import com.cxx.admin.dto.user.AccountDto;
|
||||
import com.cxx.admin.dao.AccountDao;
|
||||
import com.cxx.common.dto.AccountDto;
|
||||
import com.cxx.common.entity.Account;
|
||||
import com.cxx.common.entity.User;
|
||||
import com.cxx.common.mapper.AccountMapper;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.cxx.common.dto.user.SessionDto;
|
||||
import com.cxx.admin.service.SessionService;
|
||||
import com.cxx.common.dto.user.UserDto;
|
||||
import com.cxx.common.dto.SessionDto;
|
||||
import com.cxx.common.dto.UserDto;
|
||||
import com.cxx.common.entity.Account;
|
||||
import com.cxx.common.entity.User;
|
||||
import com.cxx.common.mapper.AccountMapper;
|
||||
|
||||
@@ -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;
|
||||
@@ -2,14 +2,5 @@ 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:
|
||||
|
||||
file:
|
||||
path: D:\\temp\\
|
||||
log-path: D:\\temp\\
|
||||
username: cxx
|
||||
password: 123456
|
||||
@@ -4,13 +4,3 @@ spring:
|
||||
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
|
||||
|
||||
file:
|
||||
path: /upload-file/
|
||||
@@ -4,13 +4,3 @@ spring:
|
||||
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
|
||||
|
||||
file:
|
||||
path: /root/docker/upload-file/
|
||||
log-path: /root/service/logs/
|
||||
@@ -33,4 +33,4 @@ influxdb:
|
||||
bucket: server_metrics
|
||||
|
||||
web-starter:
|
||||
base-package: com.cxx.service
|
||||
base-package: com.cxx.admin
|
||||
@@ -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/adminService"/>
|
||||
|
||||
<!--控制台日志格式:彩色日志-->
|
||||
<!-- 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,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.AccountDao">
|
||||
<select id="queryAccount" resultType="com.cxx.admin.dto.user.AccountDto">
|
||||
<select id="queryAccount" resultType="com.cxx.common.dto.AccountDto">
|
||||
SELECT b.id AS id,
|
||||
b.account_name AS accountName,
|
||||
a.username AS username,
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
package com.cxx.admin.dto.user;
|
||||
package com.cxx.common.dto;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.user;
|
||||
package com.cxx.common.dto;
|
||||
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.common.dto.user;
|
||||
package com.cxx.common.dto;
|
||||
|
||||
import com.cxx.common.PlainView;
|
||||
import com.cxx.common.ReadView;
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM docker-0.unsee.tech/openjdk:11-jdk-slim
|
||||
FROM openjdk:17-jdk
|
||||
ARG JAR_FILE=target/*.jar
|
||||
COPY $JAR_FILE app.jar
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
@@ -32,14 +32,27 @@
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
<version>4.7.5.B</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 加密工具 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jave 2 视频处理库 -->
|
||||
<dependency>
|
||||
<groupId>ws.schild</groupId>
|
||||
<artifactId>jave-all-deps</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.graalvm.buildtools</groupId>-->
|
||||
<!-- <artifactId>native-maven-plugin</artifactId>-->
|
||||
<!-- </plugin>-->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.cxx.home.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "alist")
|
||||
@Getter
|
||||
@Setter
|
||||
public class AListProperties {
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cxx.home.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@Configuration
|
||||
public class RestClientConfig {
|
||||
final String baseUrl = "http://192.168.1.7:5244/";
|
||||
|
||||
@Bean
|
||||
public RestClient aListClient() {
|
||||
|
||||
return RestClient.builder()
|
||||
// 基础RURL
|
||||
.baseUrl(baseUrl)
|
||||
// 默认请求头 请求体为JSON格式
|
||||
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
// 默认请求头 响应体为JSON格式
|
||||
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cxx.admin.config;
|
||||
package com.cxx.home.config;
|
||||
|
||||
import com.cxx.admin.constant.FileConstant;
|
||||
import com.cxx.home.constant.FileConstant;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.cxx.admin.constant;
|
||||
package com.cxx.home.constant;
|
||||
|
||||
public interface FileConstant {
|
||||
String FILE_NAME_SPLIT = "_";
|
||||
@@ -3,7 +3,7 @@ package com.cxx.home.controller;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.StatsChartDto;
|
||||
import com.cxx.home.dto.anniversary.AnniversaryDto;
|
||||
import com.cxx.home.dto.AnniversaryDto;
|
||||
import com.cxx.home.service.AnniversaryService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.asset.AssetDto;
|
||||
import com.cxx.home.dto.AssetDto;
|
||||
import com.cxx.home.service.AssetService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
@Tag(name = "认证")
|
||||
public class AuthController {
|
||||
@Operation(summary = "查询在线人数")
|
||||
@GetMapping("/online")
|
||||
public List<String> queryOnline() {
|
||||
return StpUtil.searchSessionId("", 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.AwardDto;
|
||||
import com.cxx.home.service.AwardService;
|
||||
import com.cxx.home.vo.AwardQueryVo;
|
||||
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("/award")
|
||||
@Tag(name = "证书奖状")
|
||||
public class AwardController {
|
||||
@Resource
|
||||
private AwardService awardService;
|
||||
|
||||
@Operation(summary = "新增证书奖状")
|
||||
@PostMapping("")
|
||||
public Boolean addAward(@RequestBody @JsonView(WriteView.class) @Validated AwardDto dto) {
|
||||
return awardService.addAward(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新证书奖状")
|
||||
@PutMapping("/{id}")
|
||||
public Boolean updateAward(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) @Validated AwardDto dto) {
|
||||
return awardService.updateAward(id, dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除证书奖状")
|
||||
@DeleteMapping("/{id}")
|
||||
public Boolean deleteAward(@PathVariable("id") long id) {
|
||||
return awardService.deleteAward(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有证书奖状")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<AwardDto> queryAwardList(AwardQueryVo vo) {
|
||||
return awardService.queryAwardList(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询证书奖状")
|
||||
@GetMapping("/{id}")
|
||||
public @JsonView(ReadView.class) AwardDto queryAward(@PathVariable("id") long id) {
|
||||
return awardService.queryAward(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ 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.cxx.home.vo.BillSearchVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -55,6 +56,12 @@ public class BillController {
|
||||
return billRecordService.queryBillSummary(billQueryVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "搜索账单概要")
|
||||
@GetMapping("/search")
|
||||
public @JsonView(ReadView.class) List<BillSummaryDto> searchBillSummary(BillSearchVo billSearchVo) {
|
||||
return billRecordService.searchBillSummary(billSearchVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询账单统计")
|
||||
@GetMapping("/stats/{type}")
|
||||
public List<StatsChartDto> queryBillStats(@PathVariable("type") String type, BillQueryVo billQueryVo) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.CarEventDto;
|
||||
import com.cxx.home.service.CarEventService;
|
||||
import com.cxx.home.vo.CarQueryVo;
|
||||
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("/car")
|
||||
@Tag(name = "汽车事件")
|
||||
public class CarEventController {
|
||||
@Resource
|
||||
private CarEventService carEventService;
|
||||
|
||||
@Operation(summary = "新增汽车事件")
|
||||
@PostMapping("")
|
||||
public Boolean addCarEvent(@RequestBody @JsonView(WriteView.class) @Validated CarEventDto dto) {
|
||||
return carEventService.addCarEvent(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新汽车事件")
|
||||
@PutMapping("/{id}")
|
||||
public Boolean updateCarEvent(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) @Validated CarEventDto dto) {
|
||||
return carEventService.updateCarEvent(id, dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除汽车事件")
|
||||
@DeleteMapping("/{id}")
|
||||
public Boolean deleteCarEvent(@PathVariable("id") long id) {
|
||||
return carEventService.deleteCarEvent(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有汽车事件")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<CarEventDto> queryCarEventList(CarQueryVo query) {
|
||||
return carEventService.queryCarEventList(query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.cxx.admin.controller;
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.admin.dto.file.ChunkInfoDto;
|
||||
import com.cxx.admin.dto.file.ChunkResultDto;
|
||||
import com.cxx.admin.dto.file.FileInfoDto;
|
||||
import com.cxx.admin.service.FileService;
|
||||
import com.cxx.admin.dto.file.FileRecordDto;
|
||||
import com.cxx.home.dto.file.ChunkInfoDto;
|
||||
import com.cxx.home.dto.file.ChunkResultDto;
|
||||
import com.cxx.home.dto.file.FileInfoDto;
|
||||
import com.cxx.home.dto.file.FileRecordDto;
|
||||
import com.cxx.home.service.AListService;
|
||||
import com.cxx.home.service.FileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -20,6 +21,9 @@ public class FileController {
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
@Resource
|
||||
private AListService aListService;
|
||||
|
||||
@Operation(summary = "上传文件")
|
||||
@PostMapping(value = "", headers = "content-type=multipart/form-data")
|
||||
public FileRecordDto uploadFile(@RequestPart("file") MultipartFile file,
|
||||
@@ -28,6 +32,13 @@ public class FileController {
|
||||
return fileService.uploadFile(file, path, md5);
|
||||
}
|
||||
|
||||
@Operation(summary = "上传aList文件")
|
||||
@PostMapping(value = "/alist", consumes = "multipart/form-data")
|
||||
public String uploadAListFile(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("filePath") String filePath) {
|
||||
return aListService.uploadFile(file, filePath);
|
||||
}
|
||||
|
||||
@Operation(summary = "上传文件块")
|
||||
@PostMapping("/chunk")
|
||||
public Boolean uploadChunk(ChunkInfoDto chunkInfo,
|
||||
@@ -52,6 +52,12 @@ public class FoodController {
|
||||
return foodService.queryFoodSummary(currentPage, pageSize, foodQueryVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "搜索美食")
|
||||
@GetMapping("/recipe/search")
|
||||
public FoodSummaryDto searchFood(@RequestParam("name") String name) {
|
||||
return foodService.searchFood(name);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询美食")
|
||||
@GetMapping("/recipe/{id}")
|
||||
public @JsonView(ReadView.class) FoodRecipeDto queryFoodRecipe(@PathVariable("id") long id) {
|
||||
@@ -60,8 +66,8 @@ public class FoodController {
|
||||
|
||||
@Operation(summary = "查询所有美食名称")
|
||||
@GetMapping("/recipe/name")
|
||||
public List<String> queryFoodName() {
|
||||
return foodService.queryFoodName();
|
||||
public List<String> queryFoodNameList() {
|
||||
return foodService.queryFoodNameList();
|
||||
}
|
||||
|
||||
@Operation(summary = "新增美食成果")
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.HealthRecordDto;
|
||||
import com.cxx.home.service.HealthService;
|
||||
import com.cxx.home.vo.HealthQueryVo;
|
||||
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("/health")
|
||||
@Tag(name = "锻炼记录")
|
||||
public class HealthController {
|
||||
@Resource
|
||||
private HealthService healthService;
|
||||
|
||||
@Operation(summary = "更新健康记录")
|
||||
@PutMapping("/{id}")
|
||||
public Boolean updateExercise(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) HealthRecordDto dto) {
|
||||
return healthService.update(id, dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询健康记录")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<HealthRecordDto> queryExercise(HealthQueryVo queryVo) {
|
||||
return healthService.query(queryVo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.journal.JournalDto;
|
||||
import com.cxx.home.dto.JournalDto;
|
||||
import com.cxx.home.service.JournalService;
|
||||
import com.cxx.home.vo.JournalQueryVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.kpi.KpiDto;
|
||||
import com.cxx.home.dto.KpiDto;
|
||||
import com.cxx.home.service.KpiService;
|
||||
import com.cxx.home.vo.KpiQueryVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.ledger.LedgerDto;
|
||||
import com.cxx.home.dto.LedgerDto;
|
||||
import com.cxx.home.service.LedgerService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.PasswordDto;
|
||||
import com.cxx.home.service.PasswordService;
|
||||
import com.cxx.home.vo.PasswordQueryVo;
|
||||
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("/password")
|
||||
@Tag(name = "密码管理")
|
||||
public class PasswordController {
|
||||
@Resource
|
||||
private PasswordService passwordService;
|
||||
|
||||
@Operation(summary = "查询密码记录")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<PasswordDto> queryPassword(PasswordQueryVo query) {
|
||||
return passwordService.query(query);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增密码记录")
|
||||
@PostMapping("")
|
||||
public Boolean addPassword(@RequestBody @JsonView(WriteView.class) @Validated PasswordDto passwordDto) {
|
||||
return passwordService.add(passwordDto);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新密码记录")
|
||||
@PutMapping("/{id}")
|
||||
public Boolean updatePassword(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) PasswordDto passwordDto) {
|
||||
return passwordService.update(id, passwordDto);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除密码记录")
|
||||
@DeleteMapping("/{id}")
|
||||
public Boolean deletePassword(@PathVariable("id") long id) {
|
||||
return passwordService.delete(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询密码记录类别")
|
||||
@GetMapping("/category")
|
||||
public List<String> queryPasswordCategory() {
|
||||
return passwordService.queryCategory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.period.MenstrualPeriodDto;
|
||||
import com.cxx.home.dto.period.PeriodDayDto;
|
||||
import com.cxx.home.dto.period.PeriodSettingDto;
|
||||
import com.cxx.home.service.PeriodService;
|
||||
@@ -39,6 +40,12 @@ public class PeriodController {
|
||||
return periodService.getMenstruateFirstDate(month);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取月经周期天数")
|
||||
@GetMapping("/menstruate/days")
|
||||
public List<MenstrualPeriodDto> getMenstrualPeriod() {
|
||||
return periodService.getMenstrualPeriod();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询月经设置")
|
||||
@GetMapping("/setting")
|
||||
public @JsonView(ReadView.class) PeriodSettingDto queryPeriodSetting() {
|
||||
|
||||
@@ -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,9 +1,8 @@
|
||||
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.home.dto.product.ProductDto;
|
||||
import com.cxx.home.dto.ProductDto;
|
||||
import com.cxx.home.service.ProductService;
|
||||
import com.cxx.home.vo.ProductQueryVo;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.cxx.common.dto.SessionDto;
|
||||
import com.cxx.home.service.SessionService;
|
||||
import com.cxx.common.dto.user.SessionDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.cxx.admin.controller;
|
||||
package com.cxx.home.controller;
|
||||
|
||||
import com.cxx.admin.service.UserService;
|
||||
import com.cxx.common.ReadView;
|
||||
import com.cxx.common.WriteView;
|
||||
import com.cxx.common.dto.user.UserDto;
|
||||
import com.cxx.common.dto.UserDto;
|
||||
import com.cxx.home.service.UserService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.cxx.home.converter;
|
||||
|
||||
import com.cxx.home.dto.AwardDto;
|
||||
import com.cxx.home.entity.Award;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface AwardConverter {
|
||||
Award toEntity(AwardDto dto);
|
||||
|
||||
List<Award> toEntities(List<AwardDto> dto);
|
||||
|
||||
AwardDto toDto(Award entities);
|
||||
|
||||
List<AwardDto> toDtos(List<Award> entities);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.cxx.home.converter;
|
||||
|
||||
import com.cxx.home.dto.CarEventDto;
|
||||
import com.cxx.home.entity.CarEvent;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface CarEventConverter {
|
||||
CarEvent toEntity(CarEventDto dto);
|
||||
|
||||
List<CarEvent> toEntities(List<CarEventDto> dto);
|
||||
|
||||
CarEventDto toDto(CarEvent entities);
|
||||
|
||||
List<CarEventDto> toDtos(List<CarEvent> entities);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user