|
|
@@ -0,0 +1,50 @@
|
|
|
+package cn.com.ctop.job.bytedance.data.service.impl;
|
|
|
+
|
|
|
+import cn.com.ctop.job.bytedance.data.entity.UserLoginRecord;
|
|
|
+import cn.com.ctop.job.bytedance.data.mapper.UserLoginRecordMapper;
|
|
|
+import cn.com.ctop.job.bytedance.data.service.IUserLoginRecordService;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
|
|
|
+import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author lining
|
|
|
+ * @ClassName UserLoginRecordServiceImpl
|
|
|
+ * @description: TODO
|
|
|
+ * @date 2025年05月09日
|
|
|
+ * @version: 1.0
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class UserLoginRecordServiceImpl implements IUserLoginRecordService {
|
|
|
+ public static final String WEBHOOK_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/cddc4569-c5bb-4764-b79e-7d2e896a97b1";
|
|
|
+ @Autowired
|
|
|
+ private UserLoginRecordMapper userLoginRecordMapper;
|
|
|
+ @Override
|
|
|
+ public String queryUserLoginRecord() {
|
|
|
+ List<UserLoginRecord> userLoginRecords = userLoginRecordMapper.queryUserLoginRecord();
|
|
|
+
|
|
|
+ String date = DateUtils.getNowDate("YYYY-MM-dd HH:mm:ss");
|
|
|
+ StringBuilder text = new StringBuilder(date);
|
|
|
+ text.append("\n");
|
|
|
+ if (userLoginRecords != null && userLoginRecords.size() > 0){
|
|
|
+ userLoginRecords.forEach(userLoginRecord -> {
|
|
|
+ text.append("用户ID:").append(userLoginRecord.getUid()).append("\n")
|
|
|
+ .append("用户openid:").append(userLoginRecord.getOpenId()).append("\n")
|
|
|
+ .append("登录次数:").append(userLoginRecord.getLoginTimes()).append("\n");
|
|
|
+ });
|
|
|
+ log.info("登录次数消息:{}", text);
|
|
|
+ try {
|
|
|
+ FeishuRobotUtil.sendTextToWebhook(text.toString(), WEBHOOK_URL);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发送飞书消息失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return text.toString();
|
|
|
+ }
|
|
|
+}
|