✨Feat: 实现MovieDay卡片回传
This commit is contained in:
@@ -11,6 +11,7 @@ import cn.hezhaohui.pojo.vo.MovieVO;
|
|||||||
import com.lark.oapi.core.utils.Jsons;
|
import com.lark.oapi.core.utils.Jsons;
|
||||||
import com.lark.oapi.event.EventDispatcher;
|
import com.lark.oapi.event.EventDispatcher;
|
||||||
import com.lark.oapi.event.cardcallback.P2CardActionTriggerHandler;
|
import com.lark.oapi.event.cardcallback.P2CardActionTriggerHandler;
|
||||||
|
import com.lark.oapi.event.cardcallback.model.CallBackCard;
|
||||||
import com.lark.oapi.event.cardcallback.model.CallBackToast;
|
import com.lark.oapi.event.cardcallback.model.CallBackToast;
|
||||||
import com.lark.oapi.event.cardcallback.model.P2CardActionTrigger;
|
import com.lark.oapi.event.cardcallback.model.P2CardActionTrigger;
|
||||||
import com.lark.oapi.event.cardcallback.model.P2CardActionTriggerResponse;
|
import com.lark.oapi.event.cardcallback.model.P2CardActionTriggerResponse;
|
||||||
@@ -45,16 +46,7 @@ public class EventListener {
|
|||||||
LarkUtil.sendCard(CardEnum.CARD_WEATHER, weather);
|
LarkUtil.sendCard(CardEnum.CARD_WEATHER, weather);
|
||||||
} else if (eventKey.equals("movie")) {
|
} else if (eventKey.equals("movie")) {
|
||||||
MovieService movieService = BeanUtil.getBean(MovieService.class);
|
MovieService movieService = BeanUtil.getBean(MovieService.class);
|
||||||
List<MovieVO> movies = movieService.listMovies();
|
Map<String, Object> data = movieService.getMovies();
|
||||||
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);
|
LarkUtil.sendCard(CardEnum.CARD_MOVIE, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,6 +67,16 @@ public class EventListener {
|
|||||||
toast.setType("success");
|
toast.setType("success");
|
||||||
toast.setContent("Successful Operation!!!");
|
toast.setContent("Successful Operation!!!");
|
||||||
response.setToast(toast);
|
response.setToast(toast);
|
||||||
|
|
||||||
|
CallBackCard card = new CallBackCard();
|
||||||
|
card.setType("template");
|
||||||
|
Map<String, Object> movies = movieService.getMovies();
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put("template_id", CardEnum.CARD_MOVIE.getId());
|
||||||
|
data.put("template_version_name", CardEnum.CARD_MOVIE.getVersionName());
|
||||||
|
data.put("template_variable", movies);
|
||||||
|
card.setData(data);
|
||||||
|
response.setCard(card);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import jakarta.annotation.Resource;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MovieService {
|
public class MovieService {
|
||||||
@@ -17,7 +15,21 @@ public class MovieService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MovieClient movieClient;
|
private MovieClient movieClient;
|
||||||
|
|
||||||
public List<MovieVO> listMovies() {
|
public Map<String, Object> getMovies() {
|
||||||
|
List<MovieVO> input = this.listMovies();
|
||||||
|
List<Object> output = new ArrayList<>();
|
||||||
|
for (MovieVO movieVO : input) {
|
||||||
|
Map<String, String> movieInfo = new HashMap<>();
|
||||||
|
movieInfo.put("movie_title", movieVO.getName());
|
||||||
|
movieInfo.put("submit_time", movieVO.getDate());
|
||||||
|
output.add(movieInfo);
|
||||||
|
}
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put("recent_movie", output);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MovieVO> listMovies() {
|
||||||
List<MovieDTO> movieDTOS = movieClient.listMovies();
|
List<MovieDTO> movieDTOS = movieClient.listMovies();
|
||||||
List<MovieVO> movieVOS = new ArrayList<>();
|
List<MovieVO> movieVOS = new ArrayList<>();
|
||||||
for (MovieDTO movieDTO : movieDTOS) {
|
for (MovieDTO movieDTO : movieDTOS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user