5 changed files with 85 additions and 2 deletions
@ -0,0 +1,18 @@ |
|||||||
|
package vip.xumy.idle.server.mapper; |
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
|
||||||
|
import vip.xumy.idle.server.pojo.ActivityCount; |
||||||
|
|
||||||
|
/** Ownership belongs to the company |
||||||
|
* |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2025年4月21日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface IActivityCountMapper extends BaseMapper<ActivityCount> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package vip.xumy.idle.server.pojo; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Ownership belongs to the company |
||||||
|
* |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2025年4月21日 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@TableName("activity_count") |
||||||
|
public class ActivityCount { |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
private String time; |
||||||
|
private Integer num; |
||||||
|
private String type; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package vip.xumy.idle.server.worker; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import vip.xumy.core.utils.DateUtil; |
||||||
|
import vip.xumy.idle.server.mapper.IActivityCountMapper; |
||||||
|
import vip.xumy.idle.server.pojo.ActivityCount; |
||||||
|
import vip.xumy.idle.server.service.WebSocketService; |
||||||
|
|
||||||
|
/** |
||||||
|
* Ownership belongs to the company |
||||||
|
* |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2025年4月21日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Component |
||||||
|
@EnableScheduling |
||||||
|
public class ActivityCountWorker { |
||||||
|
@Autowired |
||||||
|
private IActivityCountMapper countMapper; |
||||||
|
|
||||||
|
@Scheduled(cron = "0 * * * * ?") |
||||||
|
public void aliveCount() { |
||||||
|
ActivityCount count = new ActivityCount(); |
||||||
|
count.setTime(DateUtil.format()); |
||||||
|
count.setNum(WebSocketService.CLIENT_MAP.size()); |
||||||
|
count.setType("A"); |
||||||
|
countMapper.insert(count); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue