发表于: 2021-01-27 23:53:03
1 1211
今天完成的事情:
编写controller,postman测试
明天计划的事情:
遇到的问题:
收获:
package com.kbk.kbk_controller;
import com.kbk.Rest.Restful;
import com.kbk.model.Banner;
import com.kbk.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Controller
public class BannerController {
@Autowired
BannerService bannerService;
/**
* banner接口*
* @return
*/
@GetMapping("/banner")
@ResponseBody
public Map<String, Object> showBanner() {
List<Banner> banner = bannerService.selectBannerList();
if (banner != null && !banner.isEmpty()) {
return Restful.set(200, "查询banner成功", banner);
} else {
return Restful.set(404, "查询banner失败");
}
}
}
测试失败:
评论