@RequestMapping("/")
public String showPortalPage(Model model){
// 1.呼叫MySQLRemoteService提供的方法查詢首頁要顯示的資料
ResultEntity<List<PortalTypeVO>> resultEntity = mySQLRemoteService.getPortalTypeProjectDataRemote();//這里提示資料
//為空
// 2.檢查查詢結果
String result = resultEntity.getResult();
if (ResultEntity.SUCCESS.equals(result)){
// 3.獲取查詢資料
List<PortalTypeVO> list = resultEntity.getData();
// 4.存入模型
model.addAttribute(CrowdConstant.ATTR_NAME_PORTAL_DATA,list);
}
return "portal";
}
//暴露介面
@FeignClient("atguigu-crowd-mysql")
public interface MySQLRemoteService {
@RequestMapping("/get/portal/type/project/data/remote")
public ResultEntity<List<PortalTypeVO>> getPortalTypeProjectDataRemote();
}
//資料庫部分
@RequestMapping("/get/portal/type/project/data/remote")
public ResultEntity<List<PortalTypeVO>> getPortalTypeProjectDataRemote(){
try {
List<PortalTypeVO> portalTypeVOList = projectService.getPortalTypeVO();
return ResultEntity.successWithData(portalTypeVOList);
} catch (Exception e) {
e.printStackTrace();
return ResultEntity.failed(e.getMessage());
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/107599.html
標籤:Java相關
