点击此处查看原视频
核心Bean:
package edu.sut.iov.bean;
public class Music {
private int id;
private String name;
private String author;
private int size;
private int duration;
private String url;
private String imageurl;
public String getImageurl() {
return imageurl;
}
public void setImageurl(String imageurl) {
this.imageurl = imageurl;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
核心Controller:
package edu.sut.iov.controller;
import edu.sut.iov.bean.Music;
import edu.sut.iov.service.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("music")
public class MusicController {
@Autowired
MusicService service;
@RequestMapping("/getallinfo")
public List<Music> getAllInfo(){
return service.getAllInfo();
}
}
核心DAO:
package edu.sut.iov.dao;
import edu.sut.iov.bean.Music;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface MusicDao {
@Select("select * from music")
List<Music> getAllInfo();
}
核心Service:
package edu.sut.iov.service;
import edu.sut.iov.bean.Music;
import edu.sut.iov.dao.MusicDao;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class MusicService {
@Resource
MusicDao dao;
public List<Music> getAllInfo(){
return dao.getAllInfo();
}
}
效果图: