Commit 8c4fd97e authored by 郑杰's avatar 郑杰
Browse files

v1.5 beta版发布,详细查看发行版说明

parent b066bb99
package me.zhengjie.monitor.config;
package me.zhengjie.modules.monitor.config;
import me.zhengjie.monitor.service.VisitsService;
import me.zhengjie.modules.monitor.service.VisitsService;
import org.springframework.context.annotation.Configuration;
/**
......@@ -13,5 +13,6 @@ public class VisitsInitialization {
public VisitsInitialization(VisitsService visitsService){
System.out.println("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------");
visitsService.save();
System.out.println("--------------- 初始化站点统计完成 ---------------");
}
}
package me.zhengjie.monitor.config;
package me.zhengjie.modules.monitor.config;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.monitor.domain.LogMessage;
import me.zhengjie.modules.monitor.domain.LogMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import javax.annotation.PostConstruct;
import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
/**
* 配置WebSocket消息代理端点,即stomp服务端
......
package me.zhengjie.monitor.domain;
package me.zhengjie.modules.monitor.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package me.zhengjie.monitor.domain;
package me.zhengjie.modules.monitor.domain;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
......@@ -31,7 +31,9 @@ public class Visits {
private Long ipCounts;
@CreationTimestamp
@Column(name = "create_time")
private Timestamp createTime;
@Column(name = "week_day")
private String weekDay;
}
package me.zhengjie.monitor.domain.vo;
package me.zhengjie.modules.monitor.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package me.zhengjie.monitor.repository;
package me.zhengjie.modules.monitor.repository;
import me.zhengjie.monitor.domain.Visits;
import me.zhengjie.modules.monitor.domain.Visits;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
......@@ -29,6 +28,6 @@ public interface VisitsRepository extends JpaRepository<Visits,Long> {
* @return
*/
@Query(value = "select * FROM visits where " +
"createTime between ?1 and ?2",nativeQuery = true)
"create_time between ?1 and ?2",nativeQuery = true)
List<Visits> findAllVisits(String date1, String date2);
}
package me.zhengjie.monitor.rest;
package me.zhengjie.modules.monitor.rest;
import me.zhengjie.common.aop.limit.Limit;
import org.springframework.security.access.prepost.PreAuthorize;
import me.zhengjie.aop.limit.Limit;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
* 接口限流测试类
*/
@RestController
@RequestMapping("test")
public class TestController {
@RequestMapping("api")
public class LimitController {
private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger();
/**
* 测试限流注解,下面配置说明该接口 60秒内最多只能访问 10次,保存到redis的键名为 limit_test,
*/
@Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit")
@GetMapping("limit")
@GetMapping("/limit")
public int testLimit() {
return ATOMIC_INTEGER.incrementAndGet();
}
......
package me.zhengjie.monitor.rest;
package me.zhengjie.modules.monitor.rest;
import me.zhengjie.common.aop.log.Log;
import me.zhengjie.monitor.domain.vo.RedisVo;
import me.zhengjie.monitor.service.RedisService;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.monitor.domain.vo.RedisVo;
import me.zhengjie.modules.monitor.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
......@@ -22,14 +22,14 @@ public class RedisController {
@Autowired
private RedisService redisService;
@Log(description = "查询Redis缓存")
@Log("查询Redis缓存")
@GetMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_SELECT')")
public ResponseEntity getRedis(String key, Pageable pageable){
return new ResponseEntity(redisService.findByKey(key,pageable), HttpStatus.OK);
}
@Log(description = "新增Redis缓存")
@Log("新增Redis缓存")
@PostMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_CREATE')")
public ResponseEntity create(@Validated @RequestBody RedisVo resources){
......@@ -37,7 +37,7 @@ public class RedisController {
return new ResponseEntity(HttpStatus.CREATED);
}
@Log(description = "修改Redis缓存")
@Log("修改Redis缓存")
@PutMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_EDIT')")
public ResponseEntity update(@Validated @RequestBody RedisVo resources){
......@@ -45,7 +45,7 @@ public class RedisController {
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log(description = "删除Redis缓存")
@Log("删除Redis缓存")
@DeleteMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')")
public ResponseEntity delete(@RequestBody RedisVo resources){
......@@ -53,7 +53,7 @@ public class RedisController {
return new ResponseEntity(HttpStatus.OK);
}
@Log(description = "清空Redis缓存")
@Log("清空Redis缓存")
@DeleteMapping(value = "/redis/all")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')")
public ResponseEntity deleteAll(){
......
package me.zhengjie.monitor.rest;
package me.zhengjie.modules.monitor.rest;
import me.zhengjie.common.utils.RequestHolder;
import me.zhengjie.monitor.service.VisitsService;
import me.zhengjie.modules.monitor.service.VisitsService;
import me.zhengjie.utils.RequestHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......
package me.zhengjie.monitor.service;
package me.zhengjie.modules.monitor.service;
import me.zhengjie.monitor.domain.vo.RedisVo;
import me.zhengjie.modules.monitor.domain.vo.RedisVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......
package me.zhengjie.monitor.service;
package me.zhengjie.modules.monitor.service;
import org.springframework.scheduling.annotation.Async;
......
package me.zhengjie.monitor.service.impl;
package me.zhengjie.modules.monitor.service.impl;
import me.zhengjie.common.utils.PageUtil;
import me.zhengjie.monitor.domain.vo.RedisVo;
import me.zhengjie.monitor.service.RedisService;
import me.zhengjie.modules.monitor.domain.vo.RedisVo;
import me.zhengjie.modules.monitor.service.RedisService;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
......@@ -10,7 +10,8 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
......
package me.zhengjie.monitor.service.impl;
package me.zhengjie.modules.monitor.service.impl;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.common.utils.TimeUtil;
import me.zhengjie.monitor.domain.Visits;
import me.zhengjie.monitor.repository.LoggingRepository;
import me.zhengjie.monitor.repository.VisitsRepository;
import me.zhengjie.monitor.service.VisitsService;
import me.zhengjie.modules.monitor.domain.Visits;
import me.zhengjie.modules.monitor.repository.VisitsRepository;
import me.zhengjie.modules.monitor.service.VisitsService;
import me.zhengjie.repository.LogRepository;
import me.zhengjie.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -30,7 +30,7 @@ public class VisitsServiceImpl implements VisitsService {
private VisitsRepository visitsRepository;
@Autowired
private LoggingRepository loggingRepository;
private LogRepository logRepository;
@Override
public void save() {
......@@ -38,7 +38,7 @@ public class VisitsServiceImpl implements VisitsService {
Visits visits = visitsRepository.findByDate(localDate.toString());
if(visits == null){
visits = new Visits();
visits.setWeekDay(TimeUtil.getWeekDay());
visits.setWeekDay(StringUtils.getWeekDay());
visits.setPvCounts(1L);
visits.setIpCounts(1L);
visits.setDate(localDate.toString());
......@@ -51,7 +51,7 @@ public class VisitsServiceImpl implements VisitsService {
LocalDate localDate = LocalDate.now();
Visits visits = visitsRepository.findByDate(localDate.toString());
visits.setPvCounts(visits.getPvCounts()+1);
long ipCounts = loggingRepository.findIp(localDate.toString(), localDate.plusDays(1).toString());
long ipCounts = logRepository.findIp(localDate.toString(), localDate.plusDays(1).toString());
visits.setIpCounts(ipCounts);
visitsRepository.save(visits);
}
......
package me.zhengjie.quartz.config;
package me.zhengjie.modules.quartz.config;
import me.zhengjie.quartz.domain.QuartzJob;
import me.zhengjie.quartz.repository.QuartzJobRepository;
import me.zhengjie.quartz.utils.QuartzManage;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.repository.QuartzJobRepository;
import me.zhengjie.modules.quartz.utils.QuartzManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
......
package me.zhengjie.quartz.config;
package me.zhengjie.modules.quartz.config;
import org.quartz.Scheduler;
import org.quartz.spi.TriggerFiredBundle;
......
package me.zhengjie.quartz.domain;
package me.zhengjie.modules.quartz.domain;
import lombok.Data;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
......@@ -25,6 +26,7 @@ public class QuartzJob implements Serializable {
/**
* 定时器名称
*/
@Column(name = "job_name")
private String jobName;
/**
......@@ -71,5 +73,6 @@ public class QuartzJob implements Serializable {
* 创建日期
*/
@UpdateTimestamp
@Column(name = "update_time")
private Timestamp updateTime;
}
\ No newline at end of file
package me.zhengjie.quartz.domain;
package me.zhengjie.modules.quartz.domain;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
......@@ -58,7 +59,7 @@ public class QuartzLog implements Serializable {
/**
* 异常详细
*/
@Column(columnDefinition = "text")
@Column(name = "exception_detail",columnDefinition = "text")
private String exceptionDetail;
/**
......@@ -70,5 +71,6 @@ public class QuartzLog implements Serializable {
* 创建日期
*/
@CreationTimestamp
@Column(name = "create_time")
private Timestamp createTime;
}
package me.zhengjie.quartz.repository;
package me.zhengjie.modules.quartz.repository;
import me.zhengjie.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
......
package me.zhengjie.quartz.repository;
package me.zhengjie.modules.quartz.repository;
import me.zhengjie.quartz.domain.QuartzLog;
import me.zhengjie.modules.quartz.domain.QuartzLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package me.zhengjie.quartz.rest;
package me.zhengjie.modules.quartz.rest;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.common.aop.log.Log;
import me.zhengjie.common.exception.BadRequestException;
import me.zhengjie.quartz.domain.QuartzJob;
import me.zhengjie.quartz.domain.QuartzLog;
import me.zhengjie.quartz.service.QuartzJobService;
import me.zhengjie.quartz.service.query.QuartzJobQueryService;
import me.zhengjie.quartz.service.query.QuartzLogQueryService;
import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import me.zhengjie.modules.quartz.domain.QuartzLog;
import me.zhengjie.modules.quartz.service.QuartzJobService;
import me.zhengjie.modules.quartz.service.query.QuartzJobQueryService;
import me.zhengjie.modules.quartz.service.query.QuartzLogQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
......@@ -36,7 +36,7 @@ public class QuartzJobController {
@Autowired
private QuartzLogQueryService quartzLogQueryService;
@Log(description = "查询定时任务")
@Log("查询定时任务")
@GetMapping(value = "/jobs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')")
public ResponseEntity getJobs(QuartzJob resources, Pageable pageable){
......@@ -55,7 +55,7 @@ public class QuartzJobController {
return new ResponseEntity(quartzLogQueryService.queryAll(resources,pageable), HttpStatus.OK);
}
@Log(description = "新增定时任务")
@Log("新增定时任务")
@PostMapping(value = "/jobs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_CREATE')")
public ResponseEntity create(@Validated @RequestBody QuartzJob resources){
......@@ -65,7 +65,7 @@ public class QuartzJobController {
return new ResponseEntity(quartzJobService.create(resources),HttpStatus.CREATED);
}
@Log(description = "修改定时任务")
@Log("修改定时任务")
@PutMapping(value = "/jobs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
public ResponseEntity update(@Validated @RequestBody QuartzJob resources){
......@@ -76,7 +76,7 @@ public class QuartzJobController {
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log(description = "更改定时任务状态")
@Log("更改定时任务状态")
@PutMapping(value = "/jobs/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
public ResponseEntity updateIsPause(@PathVariable Long id){
......@@ -84,7 +84,7 @@ public class QuartzJobController {
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log(description = "执行定时任务")
@Log("执行定时任务")
@PutMapping(value = "/jobs/exec/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
public ResponseEntity execution(@PathVariable Long id){
......@@ -92,7 +92,7 @@ public class QuartzJobController {
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log(description = "删除定时任务")
@Log("删除定时任务")
@DeleteMapping(value = "/jobs/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment