音乐播放器 SSM整合简单小项目(分模块开发)(超详细解释)

1、项目简介

       1.1  本项目是一个简单的Java音乐播放器微信小程序,开发工具为微信开发者工

具、IDEA2019、PostMan、SqlYog 用到的框架为 MyBatis、Spring、SpringMVC实

现的功能为音乐的查找、播放,暂停、上一首、下一首,歌单的查询、创建。

 

源码我放在群里了

 

 2、项目结构

        1.1 MySQL:

 很简单的两张表,我也将这两张表的数据导出来了,复制运行一下就ok了

/*
SQLyog Ultimate v13.1.1 (64 bit)
MySQL - 5.7.29 : Database - wyy_music
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`wyy_music` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `wyy_music`;

/*Table structure for table `tb_music` */

DROP TABLE IF EXISTS `tb_music`;

CREATE TABLE `tb_music` (
  `music_id` int(11) NOT NULL AUTO_INCREMENT,
  `music_name` varchar(255) NOT NULL,
  `music_album_name` varchar(255) NOT NULL,
  `music_album_picUrl` varchar(255) NOT NULL,
  `music_mp3Url` varchar(255) NOT NULL,
  `music_artist_name` varchar(255) NOT NULL,
  `sheet_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`music_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

/*Data for the table `tb_music` */

insert  into `tb_music`(`music_id`,`music_name`,`music_album_name`,`music_album_picUrl`,`music_mp3Url`,`music_artist_name`,`sheet_id`) values 
(1,'光年之外','光年之外','https://imgessl.kugou.com/stdmusic/20161229/20161229233400375274.jpg','https://webfs.ali.kugou.com/202110231001/f8ce61782b9164c18fb5f351e63893b9/KGTX/CLTX001/f87095bff0de7c636c3a3b8aac702d76.mp3','G.E.M.邓紫棋',1),
(2,'夜空中最亮的星','世界','https://imgessl.kugou.com/stdmusic/20150719/20150719010047203836.jpg','https://webfs.ali.kugou.com/202110231000/1bbc218df11c188d157670bb9394bbdc/G202/M04/1B/13/aocBAF55G0-ADd0HAD2Y88Efqbw072.mp3','逃跑计划',1),
(3,'只要平凡','只要平凡','https://y.qq.com/music/photo_new/T002R300x300M000000K7srf1rZtOX.jpg?max_age=2592000','https://webfs.tx.kugou.com/202110230959/454d79bdb51b3853bdbef16cdeabad0f/KGTX/CLTX001/38aead7ed546b0736791ebb25c3a3951.mp3','张杰/张碧晨',2),
(4,'你要跳舞吗','生命因你而火热','https://imgessl.kugou.com/stdmusic/20160407/20160407002744966139.jpg','https://webfs.ali.kugou.com/202110230959/4a0cf46bfc3a8c564ee035dc28062d14/KGTX/CLTX001/58ffa0221ed9397e7ad9b889cdbe1a4a.mp3','新裤子乐队',2),
(5,'Timber','Timber','https://imgessl.kugou.com/stdmusic/20190517/20190517155803444871.jpg','https://webfs.ali.kugou.com/202110231008/84aa125fef71bba4becb6d4a23f14f9b/G192/M07/03/01/YIcBAF5ajbWAD3zrADH2ScRvxNQ240.mp3','pitbull',1);

/*Table structure for table `tb_sheet` */

DROP TABLE IF EXISTS `tb_sheet`;

CREATE TABLE `tb_sheet` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sheet_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

/*Data for the table `tb_sheet` */

insert  into `tb_sheet`(`id`,`sheet_name`) values 
(1,'热歌榜'),
(2,'新歌榜'),
(3,'原创榜'),

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

tb_music

 音乐表中的数据必为 音乐Id、专辑名称、演唱者名称、这首音乐的图片(这里用的是酷狗音乐的url)、音乐MP3(这里也是用的酷狗的url)、歌手名字、所对应的列表

因为音乐和图片都是用的网络资源,可能过段时间就访问不到了,因此有两种解决方式

        第一种就是每次运行前就去酷狗音乐找到几个音乐的url 加入到数据库中,使用谷歌浏览器在网页点击右键--->检查,url不要找错、否则会没有效果的

         第二种就是自己再解压一个tomcat下载到本地的服务器里面,url改成本地的,每次运行前先启动资源服务器,具体方法这里就不过多演示了

        2.2 maven

        spring-ssm-parent为父工程 

        spring-dao 和 spring-service为spring-ssm-parent两个子模块

         spring-web为父模块外的web服务模块,用来和前端交互

 其中spring-dao、spring-service的结构为:

 spring-web的结构为:

 3、代码

        1.1 dao (我这里除了QuerryVo 其他的类、接口和对应的mapper文件都是通过逆向工程实现的,节省了很多时间,我也建议大家通过逆向工程去自己生成这些文件,可以避免很多错误,至于逆向工程怎么实现的可以参考我下面这篇文章。

https://blog.csdn.net/layonly/article/details/120712564?spm=1001.2014.3001.5502https://blog.csdn.net/layonly/article/details/120712564?spm=1001.2014.3001.5502https://blog.csdn.net/layonly/article/details/120712564?spm=1001.2014.3001.5502

        dao层的代码可能会有点多,因为这99%都是通过逆向工程生成的,有很多方法都没用的到,不要担心蛤

咱们先配置一下pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>spring-ssm-parent</artifactId>
        <groupId>com.ssm</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.26</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.6</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.7</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.20</version>
        </dependency>
    </dependencies>
    <artifactId>spring-dao</artifactId>


</project>

1.1.1  TbMusicMapper 接口

package com.qwz.dao;

import java.util.List;

import com.qwz.entity.TbMusic;
import com.qwz.entity.TbMusicExample;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

//这个注解是讲本类交给spring管理
@Repository
public interface TbMusicMapper {
    long countByExample(TbMusicExample example);

    int deleteByExample(TbMusicExample example);

    int deleteByPrimaryKey(Integer musicId);

    int insert(TbMusic record);

    int insertSelective(TbMusic record);

    List<TbMusic> selectByExample(TbMusicExample example);

    TbMusic selectByPrimaryKey(Integer musicId);

    int updateByExampleSelective(@Param("record") TbMusic record, @Param("example") TbMusicExample example);

    int updateByExample(@Param("record") TbMusic record, @Param("example") TbMusicExample example);

    int updateByPrimaryKeySelective(TbMusic record);

    int updateByPrimaryKey(TbMusic record);

}

 1.1.2 TbSheetMapper 接口

package com.qwz.dao;

import com.qwz.entity.TbSheet;
import com.qwz.entity.TbSheetExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface TbSheetMapper {
    long countByExample(TbSheetExample example);

    int deleteByExample(TbSheetExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(TbSheet record);

    int insertSelective(TbSheet record);

    List<TbSheet> selectByExample(TbSheetExample example);

    TbSheet selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") TbSheet record, @Param("example") TbSheetExample example);

    int updateByExample(@Param("record") TbSheet record, @Param("example") TbSheetExample example);

    int updateByPrimaryKeySelective(TbSheet record);

    int updateByPrimaryKey(TbSheet record);

    void insertSheet(String sheetName);
}

        1.2 entity

1.2.1 TbMusic、TbMusicExample

package com.qwz.entity;

public class TbMusic {
    private Integer musicId;

    private String musicName;

    private String musicAlbumName;

    private String musicAlbumPicurl;

    private String musicMp3url;

    private String musicArtistName;

    private Integer sheetId;

    public Integer getMusicId() {
        return musicId;
    }

    public void setMusicId(Integer musicId) {
        this.musicId = musicId;
    }

    public String getMusicName() {
        return musicName;
    }

    public void setMusicName(String musicName) {
        this.musicName = musicName == null ? null : musicName.trim();
    }

    public String getMusicAlbumName() {
        return musicAlbumName;
    }

    public void setMusicAlbumName(String musicAlbumName) {
        this.musicAlbumName = musicAlbumName == null ? null : musicAlbumName.trim();
    }

    public String getMusicAlbumPicurl() {
        return musicAlbumPicurl;
    }

    public void setMusicAlbumPicurl(String musicAlbumPicurl) {
        this.musicAlbumPicurl = musicAlbumPicurl == null ? null : musicAlbumPicurl.trim();
    }

    public String getMusicMp3url() {
        return musicMp3url;
    }

    public void setMusicMp3url(String musicMp3url) {
        this.musicMp3url = musicMp3url == null ? null : musicMp3url.trim();
    }

    public String getMusicArtistName() {
        return musicArtistName;
    }

    public void setMusicArtistName(String musicArtistName) {
        this.musicArtistName = musicArtistName == null ? null : musicArtistName.trim();
    }

    public Integer getSheetId() {
        return sheetId;
    }

    public void setSheetId(Integer sheetId) {
        this.sheetId = sheetId;
    }
}
package com.qwz.entity;

import java.util.ArrayList;
import java.util.List;

public class TbMusicExample {
    protected String orderByClause;

    protected boolean distinct;

    protected List<Criteria> oredCriteria;

    public TbMusicExample() {
        oredCriteria = new ArrayList<Criteria>();
    }

    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    public String getOrderByClause() {
        return orderByClause;
    }

    public void setDistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isDistinct() {
        return distinct;
    }

    public List<Criteria> getOredCriteria() {
        return oredCriteria;
    }

    public void or(Criteria criteria) {
        oredCriteria.add(criteria);
    }

    public Criteria or() {
        Criteria criteria = createCriteriaInternal();
        oredCriteria.add(criteria);
        return criteria;
    }

    public Criteria createCriteria() {
        Criteria criteria = createCriteriaInternal();
        if (oredCriteria.size() == 0) {
            oredCriteria.add(criteria);
        }
        return criteria;
    }

    protected Criteria createCriteriaInternal() {
        Criteria criteria = new Criteria();
        return criteria;
    }

    public void clear() {
        oredCriteria.clear();
        orderByClause = null;
        distinct = false;
    }

    protected abstract static class GeneratedCriteria {
        protected List<Criterion> criteria;

        protected GeneratedCriteria() {
            super();
            criteria = new ArrayList<Criterion>();
        }

        public boolean isValid() {
            return criteria.size() > 0;
        }

        public List<Criterion> getAllCriteria() {
            return criteria;
        }

        public List<Criterion> getCriteria() {
            return criteria;
        }

        protected void addCriterion(String condition) {
            if (condition == null) {
                throw new RuntimeException("Value for condition cannot be null");
            }
            criteria.add(new Criterion(condition));
        }

        protected void addCriterion(String condition, Object value, String property) {
            if (value == null) {
                throw new RuntimeException("Value for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value));
        }

        protected void addCriterion(String condition, Object value1, Object value2, String property) {
            if (value1 == null || value2 == null) {
                throw new RuntimeException("Between values for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value1, value2));
        }

        public Criteria andMusicIdIsNull() {
            addCriterion("music_id is null");
            return (Criteria) this;
        }

        public Criteria andMusicIdIsNotNull() {
            addCriterion("music_id is not null");
            return (Criteria) this;
        }

        public Criteria andMusicIdEqualTo(Integer value) {
            addCriterion("music_id =", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdNotEqualTo(Integer value) {
            addCriterion("music_id <>", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdGreaterThan(Integer value) {
            addCriterion("music_id >", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdGreaterThanOrEqualTo(Integer value) {
            addCriterion("music_id >=", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdLessThan(Integer value) {
            addCriterion("music_id <", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdLessThanOrEqualTo(Integer value) {
            addCriterion("music_id <=", value, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdIn(List<Integer> values) {
            addCriterion("music_id in", values, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdNotIn(List<Integer> values) {
            addCriterion("music_id not in", values, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdBetween(Integer value1, Integer value2) {
            addCriterion("music_id between", value1, value2, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicIdNotBetween(Integer value1, Integer value2) {
            addCriterion("music_id not between", value1, value2, "musicId");
            return (Criteria) this;
        }

        public Criteria andMusicNameIsNull() {
            addCriterion("music_name is null");
            return (Criteria) this;
        }

        public Criteria andMusicNameIsNotNull() {
            addCriterion("music_name is not null");
            return (Criteria) this;
        }

        public Criteria andMusicNameEqualTo(String value) {
            addCriterion("music_name =", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameNotEqualTo(String value) {
            addCriterion("music_name <>", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameGreaterThan(String value) {
            addCriterion("music_name >", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameGreaterThanOrEqualTo(String value) {
            addCriterion("music_name >=", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameLessThan(String value) {
            addCriterion("music_name <", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameLessThanOrEqualTo(String value) {
            addCriterion("music_name <=", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameLike(String value) {
            addCriterion("music_name like", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameNotLike(String value) {
            addCriterion("music_name not like", value, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameIn(List<String> values) {
            addCriterion("music_name in", values, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameNotIn(List<String> values) {
            addCriterion("music_name not in", values, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameBetween(String value1, String value2) {
            addCriterion("music_name between", value1, value2, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicNameNotBetween(String value1, String value2) {
            addCriterion("music_name not between", value1, value2, "musicName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameIsNull() {
            addCriterion("music_album_name is null");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameIsNotNull() {
            addCriterion("music_album_name is not null");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameEqualTo(String value) {
            addCriterion("music_album_name =", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameNotEqualTo(String value) {
            addCriterion("music_album_name <>", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameGreaterThan(String value) {
            addCriterion("music_album_name >", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameGreaterThanOrEqualTo(String value) {
            addCriterion("music_album_name >=", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameLessThan(String value) {
            addCriterion("music_album_name <", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameLessThanOrEqualTo(String value) {
            addCriterion("music_album_name <=", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameLike(String value) {
            addCriterion("music_album_name like", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameNotLike(String value) {
            addCriterion("music_album_name not like", value, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameIn(List<String> values) {
            addCriterion("music_album_name in", values, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameNotIn(List<String> values) {
            addCriterion("music_album_name not in", values, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameBetween(String value1, String value2) {
            addCriterion("music_album_name between", value1, value2, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumNameNotBetween(String value1, String value2) {
            addCriterion("music_album_name not between", value1, value2, "musicAlbumName");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlIsNull() {
            addCriterion("music_album_picUrl is null");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlIsNotNull() {
            addCriterion("music_album_picUrl is not null");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlEqualTo(String value) {
            addCriterion("music_album_picUrl =", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlNotEqualTo(String value) {
            addCriterion("music_album_picUrl <>", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlGreaterThan(String value) {
            addCriterion("music_album_picUrl >", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlGreaterThanOrEqualTo(String value) {
            addCriterion("music_album_picUrl >=", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlLessThan(String value) {
            addCriterion("music_album_picUrl <", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlLessThanOrEqualTo(String value) {
            addCriterion("music_album_picUrl <=", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlLike(String value) {
            addCriterion("music_album_picUrl like", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlNotLike(String value) {
            addCriterion("music_album_picUrl not like", value, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlIn(List<String> values) {
            addCriterion("music_album_picUrl in", values, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlNotIn(List<String> values) {
            addCriterion("music_album_picUrl not in", values, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlBetween(String value1, String value2) {
            addCriterion("music_album_picUrl between", value1, value2, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicAlbumPicurlNotBetween(String value1, String value2) {
            addCriterion("music_album_picUrl not between", value1, value2, "musicAlbumPicurl");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlIsNull() {
            addCriterion("music_mp3Url is null");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlIsNotNull() {
            addCriterion("music_mp3Url is not null");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlEqualTo(String value) {
            addCriterion("music_mp3Url =", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlNotEqualTo(String value) {
            addCriterion("music_mp3Url <>", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlGreaterThan(String value) {
            addCriterion("music_mp3Url >", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlGreaterThanOrEqualTo(String value) {
            addCriterion("music_mp3Url >=", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlLessThan(String value) {
            addCriterion("music_mp3Url <", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlLessThanOrEqualTo(String value) {
            addCriterion("music_mp3Url <=", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlLike(String value) {
            addCriterion("music_mp3Url like", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlNotLike(String value) {
            addCriterion("music_mp3Url not like", value, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlIn(List<String> values) {
            addCriterion("music_mp3Url in", values, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlNotIn(List<String> values) {
            addCriterion("music_mp3Url not in", values, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlBetween(String value1, String value2) {
            addCriterion("music_mp3Url between", value1, value2, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicMp3urlNotBetween(String value1, String value2) {
            addCriterion("music_mp3Url not between", value1, value2, "musicMp3url");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameIsNull() {
            addCriterion("music_artist_name is null");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameIsNotNull() {
            addCriterion("music_artist_name is not null");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameEqualTo(String value) {
            addCriterion("music_artist_name =", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameNotEqualTo(String value) {
            addCriterion("music_artist_name <>", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameGreaterThan(String value) {
            addCriterion("music_artist_name >", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameGreaterThanOrEqualTo(String value) {
            addCriterion("music_artist_name >=", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameLessThan(String value) {
            addCriterion("music_artist_name <", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameLessThanOrEqualTo(String value) {
            addCriterion("music_artist_name <=", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameLike(String value) {
            addCriterion("music_artist_name like", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameNotLike(String value) {
            addCriterion("music_artist_name not like", value, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameIn(List<String> values) {
            addCriterion("music_artist_name in", values, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameNotIn(List<String> values) {
            addCriterion("music_artist_name not in", values, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameBetween(String value1, String value2) {
            addCriterion("music_artist_name between", value1, value2, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andMusicArtistNameNotBetween(String value1, String value2) {
            addCriterion("music_artist_name not between", value1, value2, "musicArtistName");
            return (Criteria) this;
        }

        public Criteria andSheetIdIsNull() {
            addCriterion("sheet_id is null");
            return (Criteria) this;
        }

        public Criteria andSheetIdIsNotNull() {
            addCriterion("sheet_id is not null");
            return (Criteria) this;
        }

        public Criteria andSheetIdEqualTo(Integer value) {
            addCriterion("sheet_id =", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdNotEqualTo(Integer value) {
            addCriterion("sheet_id <>", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdGreaterThan(Integer value) {
            addCriterion("sheet_id >", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdGreaterThanOrEqualTo(Integer value) {
            addCriterion("sheet_id >=", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdLessThan(Integer value) {
            addCriterion("sheet_id <", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdLessThanOrEqualTo(Integer value) {
            addCriterion("sheet_id <=", value, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdIn(List<Integer> values) {
            addCriterion("sheet_id in", values, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdNotIn(List<Integer> values) {
            addCriterion("sheet_id not in", values, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdBetween(Integer value1, Integer value2) {
            addCriterion("sheet_id between", value1, value2, "sheetId");
            return (Criteria) this;
        }

        public Criteria andSheetIdNotBetween(Integer value1, Integer value2) {
            addCriterion("sheet_id not between", value1, value2, "sheetId");
            return (Criteria) this;
        }
    }

    public static class Criteria extends GeneratedCriteria {

        protected Criteria() {
            super();
        }
    }

    public static class Criterion {
        private String condition;

        private Object value;

        private Object secondValue;

        private boolean noValue;

        private boolean singleValue;

        private boolean betweenValue;

        private boolean listValue;

        private String typeHandler;

        public String getCondition() {
            return condition;
        }

        public Object getValue() {
            return value;
        }

        public Object getSecondValue() {
            return secondValue;
        }

        public boolean isNoValue() {
            return noValue;
        }

        public boolean isSingleValue() {
            return singleValue;
        }

        public boolean isBetweenValue() {
            return betweenValue;
        }

        public boolean isListValue() {
            return listValue;
        }

        public String getTypeHandler() {
            return typeHandler;
        }

        protected Criterion(String condition) {
            super();
            this.condition = condition;
            this.typeHandler = null;
            this.noValue = true;
        }

        protected Criterion(String condition, Object value, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typeHandler = typeHandler;
            if (value instanceof List<?>) {
                this.listValue = true;
            } else {
                this.singleValue = true;
            }
        }

        protected Criterion(String condition, Object value) {
            this(condition, value, null);
        }

        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondValue = secondValue;
            this.typeHandler = typeHandler;
            this.betweenValue = true;
        }

        protected Criterion(String condition, Object value, Object secondValue) {
            this(condition, value, secondValue, null);
        }
    }
}

1.2.2  TbSheet、TbSheetExample

package com.qwz.entity;

public class TbSheet {
    private Integer id;

    private String sheetName;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSheetName() {
        return sheetName;
    }

    public void setSheetName(String sheetName) {
        this.sheetName = sheetName == null ? null : sheetName.trim();
    }
}
package com.qwz.entity;

import java.util.ArrayList;
import java.util.List;

public class TbSheetExample {
    protected String orderByClause;

    protected boolean distinct;

    protected List<Criteria> oredCriteria;

    public TbSheetExample() {
        oredCriteria = new ArrayList<Criteria>();
    }

    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    public String getOrderByClause() {
        return orderByClause;
    }

    public void setDistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isDistinct() {
        return distinct;
    }

    public List<Criteria> getOredCriteria() {
        return oredCriteria;
    }

    public void or(Criteria criteria) {
        oredCriteria.add(criteria);
    }

    public Criteria or() {
        Criteria criteria = createCriteriaInternal();
        oredCriteria.add(criteria);
        return criteria;
    }

    public Criteria createCriteria() {
        Criteria criteria = createCriteriaInternal();
        if (oredCriteria.size() == 0) {
            oredCriteria.add(criteria);
        }
        return criteria;
    }

    protected Criteria createCriteriaInternal() {
        Criteria criteria = new Criteria();
        return criteria;
    }

    public void clear() {
        oredCriteria.clear();
        orderByClause = null;
        distinct = false;
    }

    protected abstract static class GeneratedCriteria {
        protected List<Criterion> criteria;

        protected GeneratedCriteria() {
            super();
            criteria = new ArrayList<Criterion>();
        }

        public boolean isValid() {
            return criteria.size() > 0;
        }

        public List<Criterion> getAllCriteria() {
            return criteria;
        }

        public List<Criterion> getCriteria() {
            return criteria;
        }

        protected void addCriterion(String condition) {
            if (condition == null) {
                throw new RuntimeException("Value for condition cannot be null");
            }
            criteria.add(new Criterion(condition));
        }

        protected void addCriterion(String condition, Object value, String property) {
            if (value == null) {
                throw new RuntimeException("Value for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value));
        }

        protected void addCriterion(String condition, Object value1, Object value2, String property) {
            if (value1 == null || value2 == null) {
                throw new RuntimeException("Between values for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value1, value2));
        }

        public Criteria andIdIsNull() {
            addCriterion("id is null");
            return (Criteria) this;
        }

        public Criteria andIdIsNotNull() {
            addCriterion("id is not null");
            return (Criteria) this;
        }

        public Criteria andIdEqualTo(Integer value) {
            addCriterion("id =", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdNotEqualTo(Integer value) {
            addCriterion("id <>", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdGreaterThan(Integer value) {
            addCriterion("id >", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
            addCriterion("id >=", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdLessThan(Integer value) {
            addCriterion("id <", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdLessThanOrEqualTo(Integer value) {
            addCriterion("id <=", value, "id");
            return (Criteria) this;
        }

        public Criteria andIdIn(List<Integer> values) {
            addCriterion("id in", values, "id");
            return (Criteria) this;
        }

        public Criteria andIdNotIn(List<Integer> values) {
            addCriterion("id not in", values, "id");
            return (Criteria) this;
        }

        public Criteria andIdBetween(Integer value1, Integer value2) {
            addCriterion("id between", value1, value2, "id");
            return (Criteria) this;
        }

        public Criteria andIdNotBetween(Integer value1, Integer value2) {
            addCriterion("id not between", value1, value2, "id");
            return (Criteria) this;
        }

        public Criteria andSheetNameIsNull() {
            addCriterion("sheet_name is null");
            return (Criteria) this;
        }

        public Criteria andSheetNameIsNotNull() {
            addCriterion("sheet_name is not null");
            return (Criteria) this;
        }

        public Criteria andSheetNameEqualTo(String value) {
            addCriterion("sheet_name =", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameNotEqualTo(String value) {
            addCriterion("sheet_name <>", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameGreaterThan(String value) {
            addCriterion("sheet_name >", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameGreaterThanOrEqualTo(String value) {
            addCriterion("sheet_name >=", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameLessThan(String value) {
            addCriterion("sheet_name <", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameLessThanOrEqualTo(String value) {
            addCriterion("sheet_name <=", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameLike(String value) {
            addCriterion("sheet_name like", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameNotLike(String value) {
            addCriterion("sheet_name not like", value, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameIn(List<String> values) {
            addCriterion("sheet_name in", values, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameNotIn(List<String> values) {
            addCriterion("sheet_name not in", values, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameBetween(String value1, String value2) {
            addCriterion("sheet_name between", value1, value2, "sheetName");
            return (Criteria) this;
        }

        public Criteria andSheetNameNotBetween(String value1, String value2) {
            addCriterion("sheet_name not between", value1, value2, "sheetName");
            return (Criteria) this;
        }
    }

    public static class Criteria extends GeneratedCriteria {

        protected Criteria() {
            super();
        }
    }

    public static class Criterion {
        private String condition;

        private Object value;

        private Object secondValue;

        private boolean noValue;

        private boolean singleValue;

        private boolean betweenValue;

        private boolean listValue;

        private String typeHandler;

        public String getCondition() {
            return condition;
        }

        public Object getValue() {
            return value;
        }

        public Object getSecondValue() {
            return secondValue;
        }

        public boolean isNoValue() {
            return noValue;
        }

        public boolean isSingleValue() {
            return singleValue;
        }

        public boolean isBetweenValue() {
            return betweenValue;
        }

        public boolean isListValue() {
            return listValue;
        }

        public String getTypeHandler() {
            return typeHandler;
        }

        protected Criterion(String condition) {
            super();
            this.condition = condition;
            this.typeHandler = null;
            this.noValue = true;
        }

        protected Criterion(String condition, Object value, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typeHandler = typeHandler;
            if (value instanceof List<?>) {
                this.listValue = true;
            } else {
                this.singleValue = true;
            }
        }

        protected Criterion(String condition, Object value) {
            this(condition, value, null);
        }

        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondValue = secondValue;
            this.typeHandler = typeHandler;
            this.betweenValue = true;
        }

        protected Criterion(String condition, Object value, Object secondValue) {
            this(condition, value, secondValue, null);
        }
    }
}

1.2.3  QueryVo

package com.qwz.vo;

import lombok.Data;
//这里创建实体类的作用是查询用的
//这个是使用了lombok插件,意思就是帮你创建好get、set等方法
@Data
public class QueryVo {
    private String musicName;
    private String artistName;
    private Integer[] sheetId;
}

1.2.4 TbMusicMapper、TbSheetMapper

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qwz.dao.TbMusicMapper">
  <resultMap id="BaseResultMap" type="com.qwz.entity.TbMusic">
    <id column="music_id" jdbcType="INTEGER" property="musicId" />
    <result column="music_name" jdbcType="VARCHAR" property="musicName" />
    <result column="music_album_name" jdbcType="VARCHAR" property="musicAlbumName" />
    <result column="music_album_picUrl" jdbcType="VARCHAR" property="musicAlbumPicurl" />
    <result column="music_mp3Url" jdbcType="VARCHAR" property="musicMp3url" />
    <result column="music_artist_name" jdbcType="VARCHAR" property="musicArtistName" />
    <result column="sheet_id" jdbcType="INTEGER" property="sheetId" />
  </resultMap>

  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    music_id, music_name, music_album_name, music_album_picUrl, music_mp3Url, music_artist_name, 
    sheet_id
  </sql>
  <select id="selectByExample" parameterType="com.qwz.entity.TbMusicExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tb_music
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tb_music
    where music_id = #{musicId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_music
    where music_id = #{musicId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.qwz.entity.TbMusicExample">
    delete from tb_music
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.qwz.entity.TbMusic">
    insert into tb_music (music_id, music_name, music_album_name, 
      music_album_picUrl, music_mp3Url, music_artist_name, 
      sheet_id)
    values (#{musicId,jdbcType=INTEGER}, #{musicName,jdbcType=VARCHAR}, #{musicAlbumName,jdbcType=VARCHAR}, 
      #{musicAlbumPicurl,jdbcType=VARCHAR}, #{musicMp3url,jdbcType=VARCHAR}, #{musicArtistName,jdbcType=VARCHAR}, 
      #{sheetId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.qwz.entity.TbMusic">
    insert into tb_music
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="musicId != null">
        music_id,
      </if>
      <if test="musicName != null">
        music_name,
      </if>
      <if test="musicAlbumName != null">
        music_album_name,
      </if>
      <if test="musicAlbumPicurl != null">
        music_album_picUrl,
      </if>
      <if test="musicMp3url != null">
        music_mp3Url,
      </if>
      <if test="musicArtistName != null">
        music_artist_name,
      </if>
      <if test="sheetId != null">
        sheet_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="musicId != null">
        #{musicId,jdbcType=INTEGER},
      </if>
      <if test="musicName != null">
        #{musicName,jdbcType=VARCHAR},
      </if>
      <if test="musicAlbumName != null">
        #{musicAlbumName,jdbcType=VARCHAR},
      </if>
      <if test="musicAlbumPicurl != null">
        #{musicAlbumPicurl,jdbcType=VARCHAR},
      </if>
      <if test="musicMp3url != null">
        #{musicMp3url,jdbcType=VARCHAR},
      </if>
      <if test="musicArtistName != null">
        #{musicArtistName,jdbcType=VARCHAR},
      </if>
      <if test="sheetId != null">
        #{sheetId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.qwz.entity.TbMusicExample" resultType="java.lang.Long">
    select count(*) from tb_music
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update tb_music
    <set>
      <if test="record.musicId != null">
        music_id = #{record.musicId,jdbcType=INTEGER},
      </if>
      <if test="record.musicName != null">
        music_name = #{record.musicName,jdbcType=VARCHAR},
      </if>
      <if test="record.musicAlbumName != null">
        music_album_name = #{record.musicAlbumName,jdbcType=VARCHAR},
      </if>
      <if test="record.musicAlbumPicurl != null">
        music_album_picUrl = #{record.musicAlbumPicurl,jdbcType=VARCHAR},
      </if>
      <if test="record.musicMp3url != null">
        music_mp3Url = #{record.musicMp3url,jdbcType=VARCHAR},
      </if>
      <if test="record.musicArtistName != null">
        music_artist_name = #{record.musicArtistName,jdbcType=VARCHAR},
      </if>
      <if test="record.sheetId != null">
        sheet_id = #{record.sheetId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update tb_music
    set music_id = #{record.musicId,jdbcType=INTEGER},
      music_name = #{record.musicName,jdbcType=VARCHAR},
      music_album_name = #{record.musicAlbumName,jdbcType=VARCHAR},
      music_album_picUrl = #{record.musicAlbumPicurl,jdbcType=VARCHAR},
      music_mp3Url = #{record.musicMp3url,jdbcType=VARCHAR},
      music_artist_name = #{record.musicArtistName,jdbcType=VARCHAR},
      sheet_id = #{record.sheetId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.qwz.entity.TbMusic">
    update tb_music
    <set>
      <if test="musicName != null">
        music_name = #{musicName,jdbcType=VARCHAR},
      </if>
      <if test="musicAlbumName != null">
        music_album_name = #{musicAlbumName,jdbcType=VARCHAR},
      </if>
      <if test="musicAlbumPicurl != null">
        music_album_picUrl = #{musicAlbumPicurl,jdbcType=VARCHAR},
      </if>
      <if test="musicMp3url != null">
        music_mp3Url = #{musicMp3url,jdbcType=VARCHAR},
      </if>
      <if test="musicArtistName != null">
        music_artist_name = #{musicArtistName,jdbcType=VARCHAR},
      </if>
      <if test="sheetId != null">
        sheet_id = #{sheetId,jdbcType=INTEGER},
      </if>
    </set>
    where music_id = #{musicId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.qwz.entity.TbMusic">
    update tb_music
    set music_name = #{musicName,jdbcType=VARCHAR},
      music_album_name = #{musicAlbumName,jdbcType=VARCHAR},
      music_album_picUrl = #{musicAlbumPicurl,jdbcType=VARCHAR},
      music_mp3Url = #{musicMp3url,jdbcType=VARCHAR},
      music_artist_name = #{musicArtistName,jdbcType=VARCHAR},
      sheet_id = #{sheetId,jdbcType=INTEGER}
    where music_id = #{musicId,jdbcType=INTEGER}
  </update>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qwz.dao.TbSheetMapper">
  <resultMap id="BaseResultMap" type="com.qwz.entity.TbSheet">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="sheet_name" jdbcType="VARCHAR" property="sheetName" />
  </resultMap>
<!--这里是添加了增加歌单的sql语句-->
  <insert id="insertSheet">
    insert into tb_sheet(sheet_name) values (#{sheetName})
  </insert>

  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, sheet_name
  </sql>
  <select id="selectByExample" parameterType="com.qwz.entity.TbSheetExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tb_sheet
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tb_sheet
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_sheet
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.qwz.entity.TbSheetExample">
    delete from tb_sheet
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.qwz.entity.TbSheet">
    insert into tb_sheet (id, sheet_name)
    values (#{id,jdbcType=INTEGER}, #{sheetName,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.qwz.entity.TbSheet">
    insert into tb_sheet
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="sheetName != null">
        sheet_name,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="sheetName != null">
        #{sheetName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.qwz.entity.TbSheetExample" resultType="java.lang.Long">
    select count(*) from tb_sheet
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update tb_sheet
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.sheetName != null">
        sheet_name = #{record.sheetName,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update tb_sheet
    set id = #{record.id,jdbcType=INTEGER},
      sheet_name = #{record.sheetName,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.qwz.entity.TbSheet">
    update tb_sheet
    <set>
      <if test="sheetName != null">
        sheet_name = #{sheetName,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.qwz.entity.TbSheet">
    update tb_sheet
    set sheet_name = #{sheetName,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>

1.2.5 application.xml、db.properties、mybatis-config.xml(这三个文件的名字不要搞错蛤)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->

        <context:component-scan base-package="com.qwz"></context:component-scan>

        <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>

        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="username" value="${db.username}"></property>
            <property name="password" value="${db.password}"></property>
            <property name="url" value="${db.url}"></property>
            <property name="driverClassName" value="${db.driverClassName}"></property>
        </bean>

        <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"></property>
            <property name="configLocation" value="classpath:mybatis-config.xml"></property>
            <property name="plugins">
                <array>
                    <bean class="com.github.pagehelper.PageInterceptor">
                        <property name="properties">
                            <!--使用下面的方式配置参数,一行配置一个 -->
                            <value>
                                helperDialect=mysql
                                reasonable=true
                                supportMethodsArguments=true
                            </value>
                        </property>
                    </bean>
                </array>
            </property>
        </bean>
    <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.qwz.dao"></property>
    </bean>


</beans>
db.driverClassName = com.mysql.cj.jdbc.Driver
#url、username、password记着改成你们自己的数据库的蛤
db.url = jdbc:mysql://localhost:3306/wyy_music?serverTimezone=Asia/Shanghai&characterEncoding=UTF8
db.username=root
db.password=1234
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

</configuration>

        1.2  sping-service(spring-dao写完之后,要记得先打成jar包)

 接着在pom.xml中添加依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>spring-ssm-parent</artifactId>
        <groupId>com.ssm</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <packaging>jar</packaging>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spring-service</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.ssm</groupId>
            <artifactId>spring-dao</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

<!--        事务-->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.9.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>5.3.10</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
    </dependencies>
</project>

 1.2.1 MusicService、SheetService

package com.qwz.service;

import com.qwz.entity.TbMusic;
import com.qwz.vo.QueryVo;


import java.util.List;

public interface MusicService {

    List<TbMusic> findAll();

    TbMusic findById(Integer id);

    List<TbMusic> findByQueryVo(QueryVo queryVo);

    TbMusic findLastMusic(Integer musicId);

    TbMusic findBeforeMusic(Integer musicId);
}
package com.qwz.service;

import com.qwz.entity.TbSheet;

import java.util.List;

public interface SheetService {

    List<TbSheet> findAllSheet();

    void addSheet(String sheetName);

}

1.2.2 MusicServiceImpl、SheetServiceImpl

package com.qwz.service.impl;

import com.qwz.dao.TbMusicMapper;
import com.qwz.entity.TbMusic;
import com.qwz.entity.TbMusicExample;
import com.qwz.service.MusicService;
import com.qwz.vo.QueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class MusicServiceImpl implements MusicService {

//    通过spring注解注入对象
    @Autowired
    private TbMusicMapper tbMusicMapper;
//查找全部歌曲的方法
    @Override
    public List<TbMusic> findAll() {
        return tbMusicMapper.selectByExample(null);
    }
//通过id查找音乐的方法
    @Override
    public TbMusic findById(Integer id) {
        return tbMusicMapper.selectByPrimaryKey(id);
    }
//模糊查找的方法
    @Override
    public List<TbMusic> findByQueryVo(QueryVo queryVo) {
        TbMusicExample tbMusicExample = new TbMusicExample();
        TbMusicExample.Criteria criteria = tbMusicExample.createCriteria();
//        添加条件
        if (queryVo.getMusicName()!=null) {
            criteria.andMusicNameLike("%" + queryVo.getMusicName() + "%");
        }
        if (queryVo.getArtistName()!=null) {
            criteria.andMusicArtistNameEqualTo(queryVo.getArtistName());
        }
        if (queryVo.getSheetId()!=null) {
            criteria.andSheetIdIn(Arrays.asList(queryVo.getSheetId()));
        }

        List<TbMusic> tbMusics = tbMusicMapper.selectByExample(tbMusicExample);

        return tbMusics;
    }
//切换到下一首歌的方法
    @Override
    public TbMusic findLastMusic(Integer musicId) {
        List<TbMusic> tbMusics = tbMusicMapper.selectByExample(null);
        int size = tbMusics.size();
        if (musicId==size){
            return tbMusicMapper.selectByPrimaryKey(1);
        }else {
            return tbMusicMapper.selectByPrimaryKey(musicId+1);
        }
    }
//切换到上一首歌曲的方法
    @Override
    public TbMusic findBeforeMusic(Integer musicId) {
        List<TbMusic> tbMusics = tbMusicMapper.selectByExample(null);
        int size = tbMusics.size();
        if (musicId==1){
            return tbMusicMapper.selectByPrimaryKey(size);
        }else {
            return tbMusicMapper.selectByPrimaryKey(musicId-1);
        }
    }
}
package com.qwz.service.impl;

import com.qwz.dao.TbSheetMapper;
import com.qwz.entity.TbSheet;
import com.qwz.service.SheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SheetServiceImpl implements SheetService {
//这里也是通过spring注入对象
    @Autowired
    private TbSheetMapper sheetMapper;
//查找全部的歌单
    @Override
    public List<TbSheet> findAllSheet() {
        return sheetMapper.selectByExample(null);
    }
//添加歌单
    @Override
    public void addSheet(String sheetName) {
       sheetMapper.insertSheet(sheetName);
    }
}

1.2.3 applicationContext.xml(这里的datasource会报红,但是不影响运行)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->

<!--    事务管理平台-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>

<!--    配置事务通知-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="transfer" read-only="false" isolation="REPEATABLE_READ" propagation="REQUIRED"/>
            <tx:method name="find*" read-only="true" propagation="REQUIRED" isolation="REPEATABLE_READ"/>
        </tx:attributes>
    </tx:advice>
    
<!--    配置事务切面-->
    <aop:config>
        <aop:pointcut id="txPc" expression="execution(* com.qwz.service.impl.*ServiceImpl.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPc"></aop:advisor>
    </aop:config>
</beans>

1.3 spring-web(创建的时候需要创建web工程!!!接着在main中加添加java和resources包并标记就行)(同时也是需要把spring-service打包 如果打包失败的话可以先把父工程打包,再打包子模块)

先在pom.xml导入依赖

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ssm</groupId>
  <artifactId>spring-ssm-web</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>spring-ssm-web Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <dependencies>
    <dependency>
      <groupId>com.ssm</groupId>
      <artifactId>spring-service</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.3.10</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.13.0</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>
</project>

1.1 MusicController

package com.qwz.controller;

import com.qwz.entity.TbMusic;
import com.qwz.service.MusicService;
import com.qwz.vo.QueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("music")
public class MusicController {
    @Autowired
    private MusicService musicService;

    @RequestMapping("findAll")
    public List<TbMusic> findAll(){
        return musicService.findAll();
    }

    @RequestMapping(value = "findById")
    public TbMusic findById(@RequestParam("musicId") Integer id){
        return musicService.findById(id);
    }

    @RequestMapping("query")
    public List<TbMusic> queryVo(QueryVo queryVo){
        return musicService.findByQueryVo(queryVo);

    }

    @RequestMapping("findBeforeMusic")
    public TbMusic findBeforeMusic(@RequestParam("currentId") Integer musicId){
        return musicService.findBeforeMusic(musicId);
    }

    @RequestMapping("findLastMusic")
    public TbMusic findLastMusic(@RequestParam("currentId") Integer musicId){
        return musicService.findLastMusic(musicId);
    }
}

1.2 SheetController

package com.qwz.controller;

import com.qwz.entity.TbSheet;
import com.qwz.service.SheetService;
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("sheet")
public class SheetController {

    @Autowired
    private SheetService sheetService;

    @RequestMapping("findAll")
    public List<TbSheet> findAll(){
        return sheetService.findAllSheet();
    }

    @RequestMapping("addSheet")
    public void addSheet(String sheetName){
        sheetService.addSheet(sheetName);
    }
}

1.3 springmvc-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->

<!--    扫描注解-->
    <context:component-scan base-package="com.qwz.controller"></context:component-scan>
<!--    放行静态资源-->
    <mvc:default-servlet-handler></mvc:default-servlet-handler>
<!--    配置-->
    <mvc:annotation-driven></mvc:annotation-driven>
</beans>

1.4 webapp下面WEB-INF中的web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc-config.xml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

4、到这为止,后端的代码就over了 剩下的就是前端的,我这个是前后端分离的通过json数据进行传递的,如果有小伙伴想要源码或者哪里不了解的可以加群

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宇智波波奶茶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值