其他分享
首页 > 其他分享> > 千峰商城-springboot项目搭建-57-轮播图接口开发-业务层和控制层

千峰商城-springboot项目搭建-57-轮播图接口开发-业务层和控制层

作者:互联网

业务层实现:

1.IndexImgService接口:

public interface IndexImgService {
    public ResultVO listIndexImgs();
}

 

 

2.IndexImgServiceImpl实现类:

@Service
public class IndexImgServiceImpl implements IndexImgService {

    @Autowired
    private IndexImgMapper indexImgMapper;

    public ResultVO listIndexImgs() {
        List<IndexImg> indexImgs = indexImgMapper.listIndexImgs();
        if (indexImgs.size()==0){
            return new ResultVO(ResStatus.NO,"fail",null);
        }else {
            return new ResultVO(ResStatus.OK,"success",indexImgs);
        }

    }
}

 

 3.控制层实现IndexController:
@RestController
@CrossOrigin
@RequestMapping("/index")
@Api(value = "提供首页数据显示所需的接口",tags = "首页管理")
public class IndexController {

    @Autowired
    private IndexImgService indexImgService;

    @GetMapping("/indeximg")
    @ApiOperation("首页轮播图接口")
    public ResultVO listIndexImgs(){
        return indexImgService.listIndexImgs();
    }
}

 

 

 

 

标签:return,springboot,57,ResultVO,IndexImgService,listIndexImgs,indexImgs,public,轮播
来源: https://www.cnblogs.com/lysboke/p/16479574.html