add notice log

This commit is contained in:
JiyangTang 2023-10-12 10:28:33 +08:00
parent ef9707bb6a
commit 32d5833d4d
6 changed files with 195 additions and 0 deletions

View File

@ -0,0 +1,66 @@
package top.baogutang.admin.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @description: 公告log表
* @author: nikooh
* @date: 2023/10/12 : 09:53
*/
@Data
@TableName("t_notice_log")
public class NoticeLogEntity implements Serializable {
private static final long serialVersionUID = 3551414232257314995L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 公告
*/
private String noticeType;
private Long noticeId;
/**
* 标题
*/
private String title;
/**
* 类型
*/
private String type;
/**
* 封面
*/
private String cover;
/**
* 创作者
*/
private String noticeCreator;
/**
* 内容
*/
private String detailUrl;
/**
* 创建时间
*/
private Date noticeCreatedAt;
private Date createTime;
private Boolean deleted;
}

View File

@ -0,0 +1,15 @@
package top.baogutang.admin.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import top.baogutang.admin.dao.entity.NoticeLogEntity;
/**
* @description:
* @author: nikooh
* @date: 2023/10/12 : 09:59
*/
@Mapper
public interface NoticeLogMapper extends BaseMapper<NoticeLogEntity> {
}

View File

@ -10,8 +10,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import top.baogutang.admin.domain.AnnouncementsDto;
import top.baogutang.admin.services.INoticeLogService;
import top.baogutang.admin.services.IWxMsgPushService;
import top.baogutang.admin.utils.DingTalkMsgPushUtils;
import top.baogutang.common.constants.NoticeTypeEnum;
import top.baogutang.common.domain.Page;
import top.baogutang.common.domain.Results;
import top.baogutang.common.properties.WxMsgPushProperties;
@ -45,6 +47,9 @@ public class NoticeSchedule {
@Resource
private DingTalkMsgPushUtils dingTalkMsgPushUtils;
@Resource
private INoticeLogService noticeLogService;
// @Value("${dingtalk.baogutang.agentId}")
// private String agentId;
@ -76,6 +81,7 @@ public class NoticeSchedule {
String content = "# EDGE-X-" + announcementsDto.getTitle() + "\n\n![](" + announcementsDto.getCover() + ")\n\n> 点击下方链接查看更多详情:\n\n[查看详情](" + "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId() + ")";
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), content);
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
noticeLogService.saveNotice(NoticeTypeEnum.EDGE_X, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
}
}
@ -105,6 +111,7 @@ public class NoticeSchedule {
String content = "# EDGE-" + announcementsDto.getTitle() + "\n\n![](" + announcementsDto.getCover() + ")\n\n> 点击下方链接查看更多详情:\n\n[查看详情](" + "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId() + ")";
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), content);
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
noticeLogService.saveNotice(NoticeTypeEnum.EDGE, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
}
}

View File

@ -0,0 +1,27 @@
package top.baogutang.admin.services;
import top.baogutang.common.constants.NoticeTypeEnum;
import java.util.Date;
/**
* @description:
* @author: nikooh
* @date: 2023/10/12 : 10:01
*/
public interface INoticeLogService {
/**
* 公告信息持久化
*
* @param noticeType 公告类型
* @param noticeId 公告ID
* @param type 公告具体类型
* @param title 公告标题
* @param coverUrl 公告封面
* @param detailUrl 公告详情
* @param noticeCreator 公告作者
* @param noticeCreatedAt 公告创建时间
*/
void saveNotice(NoticeTypeEnum noticeType, Long noticeId, String type, String title, String coverUrl, String detailUrl, String noticeCreator, Date noticeCreatedAt);
}

View File

@ -0,0 +1,43 @@
package top.baogutang.admin.services.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.baogutang.admin.dao.entity.NoticeLogEntity;
import top.baogutang.admin.dao.mapper.NoticeLogMapper;
import top.baogutang.admin.services.INoticeLogService;
import top.baogutang.common.constants.NoticeTypeEnum;
import javax.annotation.Resource;
import java.util.Date;
/**
* @description:
* @author: nikooh
* @date: 2023/10/12 : 10:01
*/
@Slf4j
@Service
public class NoticeLogServiceImpl extends ServiceImpl<NoticeLogMapper, NoticeLogEntity> implements INoticeLogService {
@Resource
private NoticeLogMapper noticeLogMapper;
@Override
@Async("commonExecutor")
@Transactional(rollbackFor = Exception.class)
public void saveNotice(NoticeTypeEnum noticeType, Long noticeId, String type, String title, String coverUrl, String detailUrl, String noticeCreator, Date noticeCreatedAt) {
NoticeLogEntity noticeLog = new NoticeLogEntity();
noticeLog.setNoticeType(noticeType.getDesc());
noticeLog.setNoticeId(noticeId);
noticeLog.setTitle(title);
noticeLog.setType(type);
noticeLog.setCover(coverUrl);
noticeLog.setNoticeCreator(noticeCreator);
noticeLog.setDetailUrl(detailUrl);
noticeLog.setNoticeCreatedAt(noticeCreatedAt);
noticeLogMapper.insert(noticeLog);
}
}

View File

@ -0,0 +1,37 @@
package top.baogutang.common.constants;
/**
* @description:
* @author: nikooh
* @date: 2023/10/12 : 10:03
*/
public enum NoticeTypeEnum {
/**
* edge
*/
EDGE(1, "edge"),
/**
* edgeX
*/
EDGE_X(2, "edgeX"),
;
private final Integer code;
private final String desc;
NoticeTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}