@RestController就是@ResponseBody+@Controller
@RestController
public class SortProductController {
@Autowired
private SortProductService sortProductService;
@RequestMapping("/test")
public AjaxResult test(String storeCode) {
if(storeCode==null){
return AjaxResult.ok().msg("storeCode不能为空");
}
List<SortProductEntity> list = new ArrayList<>();
list = sortProductService.findSortProductByStore(storeCode);
if (list == null){
return AjaxResult.ok().msg("storeCode不存在或数据为空");
}else{
return AjaxResult.ok().data(list);
}
}
等价于
@Controller
public class SortProductController {
@Autowired
private SortProductService sortProductService;
@RequestMapping("/test")
@ResponseBody
public AjaxResult test(String storeCode) {
if(storeCode==null){
return AjaxResult.ok().msg("storeCode不能为空");
}
List<SortProductEntity> list = new ArrayList<>();
list = sortProductService.findSortProductByStore(storeCode);
if (list == null){
return AjaxResult.ok().msg("storeCode不存在或数据为空");
}else{
return AjaxResult.ok().data(list);
}
}