发表于: 2020-08-04 23:06:53
1 1237
今天完成的事情:
修改查看导航接口,搜索关键字接口,游客评论接口,查看banner列表。
查看导航接口
@Controller
@RequestMapping("/task3")
public class CatalogController {
@Autowired
FirstPortfolioService firstPortfolioService;
/**
* 查看一级导航下的二级导航接口
* @param firstId
* @return
*/
@GetMapping("/catalog/{firstId}")
@ResponseBody
public Map<String,Object> showSecond(@PathVariable int firstId){
FirstPortFolio firstPortFolio=firstPortfolioService.getFirstPortfolio(firstId);
if (firstPortFolio!=null){
return Result.set(200,"查看二级导航成功",firstPortFolio);
}else {
return Result.set(404,"查看二级导航失败");
}
}
}
搜索关键字接口
@Controller
@RequestMapping("/task3")
public class FindController {
@Autowired
FindService findService;
@GetMapping("/find")
@ResponseBody
public Map<String,Object> findByKeyword(@RequestParam String keyword){
List<Works> worksList=findService.selectByKeyword(keyword);
if(worksList!=null||!worksList.isEmpty()){
return Result.set(200,"搜索成功",worksList);
}else {
return Result.set(404,"搜索失败");
}
}
}
游客评论接口
@Controller
@RequestMapping("/task3")
public class MessageController {
@Autowired
MessageService messageService;
/**
* 游客评论接口
*/
@PostMapping(value = "/message")
@ResponseBody
public Map<String, Object> postMassage(@RequestParam String touristName, @RequestParam String content, @RequestParam int worksId) {
Message message = new Message();
//留言时间
message.setMessageTime(System.currentTimeMillis());
//留言内容
message.setContent(content);
//要留言的作品id
message.setWorksId(worksId);
//游客昵称
message.setTouristName(touristName);
messageService.addMessage(message);
return Result.set(200, "留言成功");
}
}
查看banner列表
@Controller
@RequestMapping("/task3")
public class ShowBannerController {
@Autowired
ShowBannerService showBannerService;
/**
* 查询banner列表接口
*
* @return
*/
@GetMapping("/banner")
@ResponseBody
public Map<String, Object> showBanner() {
List<Banner> banner = showBannerService.selectBannerList();
if (banner != null) {
if (!banner.isEmpty()) {
return Result.set(200, "查询banner成功", banner);
} else {
return Result.set(404, "查询banner失败");
}
} else {
return Result.set(404, "查询banner失败");
}
}
}
明天计划的事情:
整理逻辑,修改代码。
遇到的问题:
发现代码的实现逻辑很乱。
收获:
评论