✨Feat: 实现卡片推送的历史放映部分
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package cn.hezhaohui.common;
|
||||
|
||||
public enum CardEnum {
|
||||
CARD_WEATHER("AAqxas5etOJDx", "1.0.5");
|
||||
CARD_WEATHER("AAqxas5etOJDx", "1.0.5"),
|
||||
CARD_MOVIE("AAqhYDej6RK7O", "1.0.1");
|
||||
|
||||
private final String id;
|
||||
private final String versionName;
|
||||
|
||||
@@ -2,10 +2,12 @@ package cn.hezhaohui.lark.handler;
|
||||
|
||||
import cn.hezhaohui.common.AppConstant;
|
||||
import cn.hezhaohui.common.CardEnum;
|
||||
import cn.hezhaohui.lark.service.MovieService;
|
||||
import cn.hezhaohui.pojo.entity.Weather;
|
||||
import cn.hezhaohui.lark.client.WeatherClient;
|
||||
import cn.hezhaohui.lark.util.BeanUtil;
|
||||
import cn.hezhaohui.lark.util.LarkUtil;
|
||||
import cn.hezhaohui.pojo.vo.MovieVO;
|
||||
import com.lark.oapi.core.utils.Jsons;
|
||||
import com.lark.oapi.event.EventDispatcher;
|
||||
import com.lark.oapi.service.application.ApplicationService;
|
||||
@@ -14,6 +16,11 @@ import com.lark.oapi.service.im.ImService;
|
||||
import com.lark.oapi.service.im.v1.model.P2MessageReceiveV1;
|
||||
import com.lark.oapi.ws.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EventListener {
|
||||
|
||||
// onP2MessageReceiveV1 为接收消息 v2.0;onCustomizedEvent 内的 message 为接收消息 v1.0。
|
||||
@@ -32,6 +39,19 @@ public class EventListener {
|
||||
WeatherClient weatherClient = BeanUtil.getBean(WeatherClient.class);
|
||||
Weather weather = weatherClient.getWeather();
|
||||
LarkUtil.sendCard(CardEnum.CARD_WEATHER, weather);
|
||||
} else if (eventKey.equals("movie")) {
|
||||
MovieService movieService = BeanUtil.getBean(MovieService.class);
|
||||
List<MovieVO> movies = movieService.listMovies();
|
||||
List<Map<String, String>> movieList = new ArrayList<>();
|
||||
for (MovieVO movie : movies) {
|
||||
Map<String, String> movieInfo = new HashMap<>();
|
||||
movieInfo.put("movie_title", movie.getName());
|
||||
movieInfo.put("submit_time", movie.getDate());
|
||||
movieList.add(movieInfo);
|
||||
}
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("recent_movie", movieList);
|
||||
LarkUtil.sendCard(CardEnum.CARD_MOVIE, data);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user