From fb9f02a751d1e69e5a11bbed50f57f647b0e2563 Mon Sep 17 00:00:00 2001 From: yutou Date: Fri, 27 Nov 2020 18:33:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E4=B9=90=E6=94=B9=E6=88=90=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=BD=A2=E5=BC=8F=EF=BC=88=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=86=85=E5=AD=98=E7=88=86=E7=82=B8=EF=BC=89=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9EFFmpeg=E8=8E=B7=E5=8F=96=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=88=E6=97=A0=E6=B3=95=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=95=B0=E6=8D=AE=E9=83=BD=E8=83=BD=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=88=B0=EF=BC=89=20=E9=A2=84=E7=BD=AE=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E6=94=B6=E8=97=8F=E5=A4=B9=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E7=99=BB=E5=BD=95=E5=90=8E=E5=90=91?= =?UTF-8?q?=E7=BE=A4=E9=87=8C=E9=80=9A=E5=91=8A=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +- .../com/yutou/tools/ToolsApplication.java | 18 +- .../java/com/yutou/tools/ad/AdController.java | 126 -- .../com/yutou/tools/ad/Datas/AppData.java | 22 - .../yutou/tools/home/nas/Data/MusicData.java | 81 - .../yutou/tools/home/nas/MusicController.java | 72 +- .../home/nas/MusicFavoritesController.java | 13 + .../yutou/tools/mybatis/dao/MusicDataDao.java | 41 + .../tools/mybatis/dao/MusicFavoritesDao.java | 32 + .../yutou/tools/mybatis/model/MusicData.java | 117 ++ .../tools/mybatis/model/MusicDataExample.java | 1651 +++++++++++++++++ .../tools/mybatis/model/MusicFavorites.java | 19 + .../mybatis/model/MusicFavoritesExample.java | 401 ++++ .../java/com/yutou/tools/other/tools.java | 6 + .../yutou/tools/utils/ApplicationInit.java | 20 + .../utils/Interfaces/MusicToolsService.java | 29 + .../com/yutou/tools/utils/MusicTools.java | 400 ++-- .../com/yutou/tools/utils/QQBotManager.java | 3 + .../java/com/yutou/tools/utils/Tools.java | 42 + src/main/resources/mapper/MusicDataDao.xml | 496 +++++ .../resources/mapper/MusicFavoritesDao.xml | 173 ++ web/html/body/nas/music.html | 13 +- 22 files changed, 3375 insertions(+), 407 deletions(-) delete mode 100644 src/main/java/com/yutou/tools/ad/AdController.java delete mode 100644 src/main/java/com/yutou/tools/ad/Datas/AppData.java delete mode 100644 src/main/java/com/yutou/tools/home/nas/Data/MusicData.java create mode 100644 src/main/java/com/yutou/tools/home/nas/MusicFavoritesController.java create mode 100644 src/main/java/com/yutou/tools/mybatis/dao/MusicDataDao.java create mode 100644 src/main/java/com/yutou/tools/mybatis/dao/MusicFavoritesDao.java create mode 100644 src/main/java/com/yutou/tools/mybatis/model/MusicData.java create mode 100644 src/main/java/com/yutou/tools/mybatis/model/MusicDataExample.java create mode 100644 src/main/java/com/yutou/tools/mybatis/model/MusicFavorites.java create mode 100644 src/main/java/com/yutou/tools/mybatis/model/MusicFavoritesExample.java create mode 100644 src/main/java/com/yutou/tools/utils/ApplicationInit.java create mode 100644 src/main/java/com/yutou/tools/utils/Interfaces/MusicToolsService.java create mode 100644 src/main/resources/mapper/MusicDataDao.xml create mode 100644 src/main/resources/mapper/MusicFavoritesDao.xml diff --git a/pom.xml b/pom.xml index 476fc8d..b699b9b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.yutou tools - 1.0.10.4 + 1.0 tools Demo project for Spring Boot @@ -121,6 +121,11 @@ sqlite-jdbc 3.28.0 + + net.bramp.ffmpeg + ffmpeg + 0.6.2 + diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index fd3478c..d5e728c 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -1,27 +1,21 @@ package com.yutou.tools; import com.yutou.tools.home.nas.MusicController; -import com.yutou.tools.utils.*; +import com.yutou.tools.utils.ConfigTools; +import com.yutou.tools.utils.QQBotManager; +import com.yutou.tools.utils.RedisTools; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ConfigurableApplicationContext; - -import java.io.IOException; @SpringBootApplication public class ToolsApplication { + public static final String version="1.0.11"; public static void main(String[] args) { - System.out.println("当前版本号:1.0.10.4"); + System.out.println("当前版本号:"+version); SpringApplication.run(ToolsApplication.class, args); + MusicController.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); RedisTools.initRedisPoolSub(); - if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) { - MusicController.defaultMusicPath = "C:\\Users\\admin\\Music\\"; - MusicTools.getInstance().setMusicPath("C:\\Users\\admin\\Music\\"); - } else { - MusicController.defaultMusicPath = "/media/yutou/4t/public/音乐"; - MusicTools.getInstance().setMusicPath("/media/yutou/4t/public/音乐"); - } QQBotManager.getInstance(); } diff --git a/src/main/java/com/yutou/tools/ad/AdController.java b/src/main/java/com/yutou/tools/ad/AdController.java deleted file mode 100644 index dbb67c6..0000000 --- a/src/main/java/com/yutou/tools/ad/AdController.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.yutou.tools.ad; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.yutou.tools.sqlite.ADSQLiteManager; -import org.springframework.stereotype.Controller; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -import java.text.ParsePosition; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Locale; - -@Controller -@RequestMapping("ad/") -public class AdController { - - @RequestMapping("addApp.do") - @ResponseBody - public String addApp(String packageName, String appName) { - JSONObject json = new JSONObject(); - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - json.put("code", 0); - json.put("data", manager.addAppData(appName, packageName)); - return json.toJSONString(); - } - - @RequestMapping("addAppAd.do") - @ResponseBody - public String addAppAd(String appId, String adSrc, String adAppId, String adAppKey, String adOpenKey, String adInterKey, - String adBannerKey, String adVideoKey, String adNativeKey) { - JSONObject json = new JSONObject(); - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - json.put("code", 0); - json.put("data", manager.addAdData(appId, adSrc, adAppId, adAppKey, adOpenKey, adInterKey, adBannerKey, adVideoKey, adNativeKey)); - return json.toJSONString(); - } - - @RequestMapping("addAdLog.do") - @ResponseBody - public String addLog(String appId, String src, String type, String model) { - JSONObject json = new JSONObject(); - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - json.put("code", 0); - json.put("data", manager.addLog(appId, src, type, model)); - return json.toJSONString(); - } - - @RequestMapping("getAppAd.do") - @ResponseBody - public String getAppAd(String appId, String packageName) { - JSONObject json = new JSONObject(); - if (StringUtils.isEmpty(appId) && StringUtils.isEmpty(packageName)) { - json.put("code", -1); - json.put("msg", "参数为空"); - json.put("data", ""); - return json.toJSONString(); - } - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - json.put("code", 0); - if (StringUtils.isEmpty(appId)) { - json.put("data", manager.getAdDataOfPackageName(packageName)); - } else { - json.put("data", manager.getAdData(appId)); - } - return json.toJSONString(); - } - - @RequestMapping("getApp.do") - @ResponseBody - public String getApp(String appName, String packageName) { - JSONObject json = new JSONObject(); - json.put("code", 0); - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - if (StringUtils.isEmpty(appName) && StringUtils.isEmpty(packageName)) { - json.put("data", manager.getAllApp()); - return json.toJSONString(); - } - if (StringUtils.isEmpty(appName)) { - json.put("data", manager.getAppOfPackageName(packageName)); - } else { - json.put("data", manager.getAppOfAppName(appName)); - } - return json.toJSONString(); - } - @RequestMapping("getAdLog.do") - @ResponseBody - public String getLog(String appId, String startTime, String endTime) { - JSONObject json = new JSONObject(); - if (StringUtils.isEmpty(appId)) { - json.put("code", -1); - json.put("msg", "AppId为空"); - return json.toJSONString(); - } - String st = null; - String et = null; - //开始时间为空,则给当日开始时时间 - if (StringUtils.isEmpty(startTime) || (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime))) { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - st = calendar.getTimeInMillis() + ""; - } - //结束时间为空则取当前时间 - if (StringUtils.isEmpty(endTime)) { - et = System.currentTimeMillis() + ""; - } - try { - if (st == null) { - st = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(startTime).getTime() + ""; - } - if (et == null) { - et = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(endTime).getTime() + ""; - } - ADSQLiteManager manager = ADSQLiteManager.getInstance(); - json.put("data", manager.getLog(appId, st, et)); - } catch (Exception e) { - e.printStackTrace(); - } - - return json.toJSONString(); - } -} diff --git a/src/main/java/com/yutou/tools/ad/Datas/AppData.java b/src/main/java/com/yutou/tools/ad/Datas/AppData.java deleted file mode 100644 index dcdda24..0000000 --- a/src/main/java/com/yutou/tools/ad/Datas/AppData.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.yutou.tools.ad.Datas; - -import lombok.Data; - -@Data -public class AppData { - private String appName; - private String packageName; - private String appId; - - private String adSrc; - private String adAppId; - private String adAppKey; - private String adOpenKey; - private String adInterKey; - private String adBannerKey; - private String adVideoKey; - private String adNativeKey; -} -/* - {"file":"ad.db","table":[{"name":"app","item":[{"name":"id","type":"int","isNull":false,"isKey":true},{"name":"appName","type":"String","isNull":false,"isKey":false},{"name":"packageName","type":"String","isNull":false,"isKey":false},{"name":"appId","type":"String","isNull":false,"isKey":false}]},{"name":"app_ad","item":[{"name":"id","type":"int","isNull":false,"isKey":true},{"name":"appId","type":"String","isNull":false,"isKey":false},{"name":"show","type":"int","isNull":false,"isKey":false},{"name":"adSrc","type":"String","isNull":false,"isKey":false},{"name":"adAppId","type":"String","isNull":false,"isKey":false},{"name":"adAppKey","type":"String","isNull":false,"isKey":false},{"name":"adOpenKey","type":"String","isNull":true,"isKey":false},{"name":"adInterKey","type":"String","isNull":true,"isKey":false},{"name":"adBannerKey","type":"String","isNull":true,"isKey":false},{"name":"adVideoKey","type":"String","isNull":true,"isKey":false},{"name":"adNativeKey","type":"String","isNull":true,"isKey":false}]},{"name":"ad_log","item":[{"name":"id","type":"int","isNull":false,"isKey":true},{"name":"appId","type":"String","isNull":false,"isKey":false},{"name":"adSrc","type":"String","isNull":false,"isKey":false},{"name":"adType","type":"String","isNull":false,"isKey":false},{"name":"model","type":"String","isNull":false,"isKey":false},{"name":"subtime","type":"String","isNull":false,"isKey":false}]}]} - */ \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/home/nas/Data/MusicData.java b/src/main/java/com/yutou/tools/home/nas/Data/MusicData.java deleted file mode 100644 index 390d0c8..0000000 --- a/src/main/java/com/yutou/tools/home/nas/Data/MusicData.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.yutou.tools.home.nas.Data; - -import ealvatag.audio.AudioFile; -import ealvatag.audio.AudioFileIO; -import ealvatag.tag.NullTag; -import ealvatag.tag.Tag; -import ealvatag.tag.images.NullArtwork; -import lombok.Data; -import org.springframework.util.StringUtils; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Base64; - -@Data -public class MusicData { - private String artist;//艺术家 - private String album;//专辑 - private String title;//标题 - private String comment;//评论 - private String year;//年份 - private String track;//音轨号 - private String disc_no;//碟片编号 - private String composer;//作曲 - private String artist_sort;//分类 - private File file;//音乐文件 - private String lastDir;//上一个文件夹 - private boolean isDir = false; - - private int bitRate;//比特率 - private int sampleRate;//采样率 - private long noOfSamples;//采样数 - private int channelCount;//声道 - private String encodingType;//解码类型 - private double durationAsDouble;//持续时长 - private boolean lossless;//无损 - private boolean variableBitRate;//固定码率 - private String md5;//确保是同一个文件 - - - public void setFile(File file) { - this.file = file; - this.isDir = file.isDirectory(); - this.lastDir=file.getParentFile().getParent(); - } - - public String getTitle() { - if (StringUtils.isEmpty(title)) { - title = file.getName(); - } - return title; - } - - public byte[] readImage() throws Exception { - AudioFile audioFile = null; - audioFile = AudioFileIO.read(file); - Tag tag = audioFile.getTag().or(NullTag.INSTANCE); - byte[] bytes = tag.getFirstArtwork().or(NullArtwork.INSTANCE).getBinaryData(); - if (bytes.length == 0) { - return readImageFile(); - } - return bytes; - } - - private byte[] readImageFile() throws Exception { - String path = file.getAbsolutePath().replace(file.getName(), ""); - File img = new File(path, "cover.jpg"); - if (!img.exists()) { - img = new File(path, "Cover.jpg"); - if (!img.exists()) { - img = new File(path, "COVER.jpg"); - if (!img.exists()) { - throw new NullPointerException("没有cover文件"); - } - } - } - - return Files.readAllBytes(Paths.get(img.getAbsolutePath())); - } -} diff --git a/src/main/java/com/yutou/tools/home/nas/MusicController.java b/src/main/java/com/yutou/tools/home/nas/MusicController.java index fc82ca3..4a65365 100644 --- a/src/main/java/com/yutou/tools/home/nas/MusicController.java +++ b/src/main/java/com/yutou/tools/home/nas/MusicController.java @@ -2,9 +2,8 @@ package com.yutou.tools.home.nas; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.yutou.tools.home.nas.Data.MusicData; +import com.yutou.tools.mybatis.model.MusicData; import com.yutou.tools.nas.UpdateIp; -import com.yutou.tools.utils.APIFilter; import com.yutou.tools.utils.ConfigTools; import com.yutou.tools.utils.MusicTools; import com.yutou.tools.utils.Tools; @@ -15,6 +14,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import javax.annotation.Resource; import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -26,6 +26,8 @@ import java.util.List; public class MusicController { public static String defaultMusicPath="/media/yutou/4t/public/音乐"; + @Resource + MusicTools musicTools; @RequestMapping("all.do") @ResponseBody @@ -33,17 +35,16 @@ public class MusicController { JSONObject json = new JSONObject(); JSONObject data = new JSONObject(); json.put("code", 0); - MusicTools tools = MusicTools.getInstance(); - json.put("scan", tools.isScan()); - json.put("size", tools.getLength()); - json.put("data", JSONArray.toJSON(tools.getMusicList())); + json.put("scan", musicTools.isScan()); + json.put("size", musicTools.getLength()); + json.put("data", JSONArray.toJSON(musicTools.getMusicList())); return json.toJSONString(); } @RequestMapping("list.do") @ResponseBody public String getMusicListOfPath(String path,String type){ if(!StringUtils.isEmpty(path)&&!new File(path).exists()){ - path=base64ToString(path); + path=Tools.base64ToString(path); } if(StringUtils.isEmpty(path) ||path.equals("root") @@ -53,21 +54,43 @@ public class MusicController { } //path=path.replace(defaultMusicPath+File.separator,""); + boolean isDir= !StringUtils.isEmpty(type) && (type.equals("true")); JSONObject json=new JSONObject(); - JSONObject data = new JSONObject(); json.put("code", 0); - MusicTools tools = MusicTools.getInstance(); - json.put("scan", tools.isScan()); - json.put("size", tools.getLength()); - json.put("data", JSONArray.toJSON(tools.getPath(path,!StringUtils.isEmpty(type)))); + json.put("scan", musicTools.isScan()); + json.put("size", musicTools.getLength()); + json.put("data", JSONArray.toJSON(musicTools.getPath(path,isDir))); + return json.toJSONString(); + } + @ResponseBody + @RequestMapping("getAlbum.do") + public String getAlbum(String album){ + JSONObject json=new JSONObject(); + json.put("code",0); + if(StringUtils.isEmpty(album)){ + json.put("data",JSONArray.toJSON(musicTools.getAllAlbum())); + }else{ + json.put("data",JSONArray.toJSON(musicTools.selectAlbum(album))); + } + return json.toJSONString(); + } + @ResponseBody + @RequestMapping("getArtist.do") + public String getArtist(String artist){ + JSONObject json=new JSONObject(); + json.put("code",0); + if(StringUtils.isEmpty(artist)){ + json.put("data",JSONArray.toJSON(musicTools.getAllArtist())); + }else{ + json.put("data",JSONArray.toJSON(musicTools.selectArtist(artist))); + } return json.toJSONString(); - } @RequestMapping("reload.do") @ResponseBody public String reload(){ JSONObject json=new JSONObject(); - MusicTools.getInstance().scanMusic(); + musicTools.scanMusic(); json.put("msg","ok"); json.put("code",0); return json.toJSONString(); @@ -82,7 +105,7 @@ public class MusicController { return json.toJSONString(); } json.put("code",0); - json.put("data",MusicTools.getInstance().getMetadata(new File(base64ToString(path)))); + json.put("data",musicTools.getMusicData(path)); return json.toJSONString(); } @RequestMapping("getlocalhost.do") @@ -109,12 +132,12 @@ public class MusicController { json.put("data", ""); return json.toJSONString(); } - File file = new File(base64ToString(fileName)); + File file = new File(Tools.base64ToString(fileName)); try { if (file.exists()) { json.put("msg", "ok"); json.put("code", 0); - json.put("data", MusicTools.getInstance().getMetadata(file).readImage()); + json.put("data", musicTools.readImage(file.getAbsolutePath())); } else { json.put("msg", "文件不存在"); json.put("code", -1); @@ -132,12 +155,12 @@ public class MusicController { @RequestMapping("random.do") @ResponseBody public String random(){ - List list=MusicTools.getInstance().getMusicList(); + List list=musicTools.getMusicList(); MusicData data=list.get(Tools.randomCommon(0,list.size()-1,1)[0]); JSONObject json=new JSONObject(); json.put("code",0); try { - json.put("data", URLEncoder.encode(getBase64(data.getFile().getAbsolutePath()),"UTF-8")); + json.put("data", URLEncoder.encode(getBase64(data.getFile()),"UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } @@ -146,19 +169,16 @@ public class MusicController { private String getBase64(String str){ return new String(Base64.getEncoder().encode(str.getBytes())); } - private String base64ToString(String base){ - base=base.replace(" ","+"); - return new String(Base64.getDecoder().decode(base.replace("\r\n","").getBytes())); - } + @RequestMapping("play.do") public ResponseEntity play(String filePath,boolean random) { if(!StringUtils.isEmpty(filePath)){ - filePath=base64ToString(filePath); + filePath=Tools.base64ToString(filePath); } if(random){ - List list=MusicTools.getInstance().getMusicList(); + List list=musicTools.getMusicList(); MusicData data=list.get(Tools.randomCommon(0,list.size()-1,1)[0]); - filePath=data.getFile().getAbsolutePath(); + filePath=data.getFile(); } File file = new File(filePath); if (file.exists()) { diff --git a/src/main/java/com/yutou/tools/home/nas/MusicFavoritesController.java b/src/main/java/com/yutou/tools/home/nas/MusicFavoritesController.java new file mode 100644 index 0000000..a6a67e4 --- /dev/null +++ b/src/main/java/com/yutou/tools/home/nas/MusicFavoritesController.java @@ -0,0 +1,13 @@ +package com.yutou.tools.home.nas; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * 收藏夹相关 + */ +@Controller +@RequestMapping("/nas/music/") +public class MusicFavoritesController{ + +} diff --git a/src/main/java/com/yutou/tools/mybatis/dao/MusicDataDao.java b/src/main/java/com/yutou/tools/mybatis/dao/MusicDataDao.java new file mode 100644 index 0000000..419b91f --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/dao/MusicDataDao.java @@ -0,0 +1,41 @@ +package com.yutou.tools.mybatis.dao; + +import com.yutou.tools.mybatis.model.MusicData; +import com.yutou.tools.mybatis.model.MusicDataExample; +import java.util.List; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +@Mapper +public interface MusicDataDao { + long countByExample(MusicDataExample example); + + int deleteByExample(MusicDataExample example); + + int deleteByPrimaryKey(Integer id); + + int insert(MusicData record); + + int insertSelective(MusicData record); + + List selectByExample(MusicDataExample example); + + MusicData selectByPrimaryKey(Integer id); + + int updateByExampleSelective(@Param("record") MusicData record, @Param("example") MusicDataExample example); + + int updateByExample(@Param("record") MusicData record, @Param("example") MusicDataExample example); + + int updateByPrimaryKeySelective(MusicData record); + + int updateByPrimaryKey(MusicData record); + + void truncate(); + + List selectByRegexp(String regexp); + + List selectAllAlbum(); + List selectAllArtist(); + List selectAlbum(String album); + List selectArtist(String artist); +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/mybatis/dao/MusicFavoritesDao.java b/src/main/java/com/yutou/tools/mybatis/dao/MusicFavoritesDao.java new file mode 100644 index 0000000..f973413 --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/dao/MusicFavoritesDao.java @@ -0,0 +1,32 @@ +package com.yutou.tools.mybatis.dao; + +import com.yutou.tools.mybatis.model.MusicFavorites; +import com.yutou.tools.mybatis.model.MusicFavoritesExample; +import java.util.List; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +@Mapper +public interface MusicFavoritesDao { + long countByExample(MusicFavoritesExample example); + + int deleteByExample(MusicFavoritesExample example); + + int deleteByPrimaryKey(Integer id); + + int insert(MusicFavorites record); + + int insertSelective(MusicFavorites record); + + List selectByExample(MusicFavoritesExample example); + + MusicFavorites selectByPrimaryKey(Integer id); + + int updateByExampleSelective(@Param("record") MusicFavorites record, @Param("example") MusicFavoritesExample example); + + int updateByExample(@Param("record") MusicFavorites record, @Param("example") MusicFavoritesExample example); + + int updateByPrimaryKeySelective(MusicFavorites record); + + int updateByPrimaryKey(MusicFavorites record); +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/mybatis/model/MusicData.java b/src/main/java/com/yutou/tools/mybatis/model/MusicData.java new file mode 100644 index 0000000..2222164 --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/model/MusicData.java @@ -0,0 +1,117 @@ +package com.yutou.tools.mybatis.model; + +import java.io.Serializable; +import lombok.Data; + +/** + * music_data + * @author + */ +@Data +public class MusicData implements Serializable { + private Integer id; + + /** + * 艺术家 + */ + private String artist; + + /** + * 专辑 + */ + private String album; + + /** + * 标题 + */ + private String title; + + /** + * 评论 + */ + private String comment; + + /** + * 年份 + */ + private String year; + + /** + * 音轨号 + */ + private String track; + + /** + * 碟片编号 + */ + private String discNo; + + /** + * 作曲 + */ + private String composer; + + /** + * 分类 + */ + private String artistSort; + + /** + * 音乐文件路径 + */ + private String file; + + /** + * 上一个文件夹 + */ + private String lastdir; + + private Integer isdir; + + /** + * 比特率 + */ + private Integer bitrate; + + /** + * 采样率 + */ + private Integer samplerate; + + /** + * 采样数 + */ + private Long noofsamples; + + /** + * 声道 + */ + private Integer channelcount; + + /** + * 解码类型 + */ + private String encodingtype; + + /** + * 持续时长 + */ + private Double durationasdouble; + + /** + * 无损 + */ + private Integer lossless; + + /** + * 固定码率 + */ + private Integer variablebitrate; + + /** + * md5 + */ + private String md5; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/mybatis/model/MusicDataExample.java b/src/main/java/com/yutou/tools/mybatis/model/MusicDataExample.java new file mode 100644 index 0000000..f170d94 --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/model/MusicDataExample.java @@ -0,0 +1,1651 @@ +package com.yutou.tools.mybatis.model; + +import java.util.ArrayList; +import java.util.List; + +public class MusicDataExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public MusicDataExample() { + oredCriteria = new ArrayList<>(); + } + + 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 andArtistIsNull() { + addCriterion("artist is null"); + return (Criteria) this; + } + + public Criteria andArtistIsNotNull() { + addCriterion("artist is not null"); + return (Criteria) this; + } + + public Criteria andArtistEqualTo(String value) { + addCriterion("artist =", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistNotEqualTo(String value) { + addCriterion("artist <>", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistGreaterThan(String value) { + addCriterion("artist >", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistGreaterThanOrEqualTo(String value) { + addCriterion("artist >=", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistLessThan(String value) { + addCriterion("artist <", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistLessThanOrEqualTo(String value) { + addCriterion("artist <=", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistLike(String value) { + addCriterion("artist like", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistNotLike(String value) { + addCriterion("artist not like", value, "artist"); + return (Criteria) this; + } + + public Criteria andArtistIn(List values) { + addCriterion("artist in", values, "artist"); + return (Criteria) this; + } + + public Criteria andArtistNotIn(List values) { + addCriterion("artist not in", values, "artist"); + return (Criteria) this; + } + + public Criteria andArtistBetween(String value1, String value2) { + addCriterion("artist between", value1, value2, "artist"); + return (Criteria) this; + } + + public Criteria andArtistNotBetween(String value1, String value2) { + addCriterion("artist not between", value1, value2, "artist"); + return (Criteria) this; + } + + public Criteria andAlbumIsNull() { + addCriterion("album is null"); + return (Criteria) this; + } + + public Criteria andAlbumIsNotNull() { + addCriterion("album is not null"); + return (Criteria) this; + } + + public Criteria andAlbumEqualTo(String value) { + addCriterion("album =", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumNotEqualTo(String value) { + addCriterion("album <>", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumGreaterThan(String value) { + addCriterion("album >", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumGreaterThanOrEqualTo(String value) { + addCriterion("album >=", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumLessThan(String value) { + addCriterion("album <", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumLessThanOrEqualTo(String value) { + addCriterion("album <=", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumLike(String value) { + addCriterion("album like", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumNotLike(String value) { + addCriterion("album not like", value, "album"); + return (Criteria) this; + } + + public Criteria andAlbumIn(List values) { + addCriterion("album in", values, "album"); + return (Criteria) this; + } + + public Criteria andAlbumNotIn(List values) { + addCriterion("album not in", values, "album"); + return (Criteria) this; + } + + public Criteria andAlbumBetween(String value1, String value2) { + addCriterion("album between", value1, value2, "album"); + return (Criteria) this; + } + + public Criteria andAlbumNotBetween(String value1, String value2) { + addCriterion("album not between", value1, value2, "album"); + return (Criteria) this; + } + + public Criteria andTitleIsNull() { + addCriterion("title is null"); + return (Criteria) this; + } + + public Criteria andTitleIsNotNull() { + addCriterion("title is not null"); + return (Criteria) this; + } + + public Criteria andTitleEqualTo(String value) { + addCriterion("title =", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotEqualTo(String value) { + addCriterion("title <>", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThan(String value) { + addCriterion("title >", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThanOrEqualTo(String value) { + addCriterion("title >=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThan(String value) { + addCriterion("title <", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThanOrEqualTo(String value) { + addCriterion("title <=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLike(String value) { + addCriterion("title like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotLike(String value) { + addCriterion("title not like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleIn(List values) { + addCriterion("title in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotIn(List values) { + addCriterion("title not in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleBetween(String value1, String value2) { + addCriterion("title between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotBetween(String value1, String value2) { + addCriterion("title not between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andCommentIsNull() { + addCriterion("`comment` is null"); + return (Criteria) this; + } + + public Criteria andCommentIsNotNull() { + addCriterion("`comment` is not null"); + return (Criteria) this; + } + + public Criteria andCommentEqualTo(String value) { + addCriterion("`comment` =", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentNotEqualTo(String value) { + addCriterion("`comment` <>", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentGreaterThan(String value) { + addCriterion("`comment` >", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentGreaterThanOrEqualTo(String value) { + addCriterion("`comment` >=", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentLessThan(String value) { + addCriterion("`comment` <", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentLessThanOrEqualTo(String value) { + addCriterion("`comment` <=", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentLike(String value) { + addCriterion("`comment` like", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentNotLike(String value) { + addCriterion("`comment` not like", value, "comment"); + return (Criteria) this; + } + + public Criteria andCommentIn(List values) { + addCriterion("`comment` in", values, "comment"); + return (Criteria) this; + } + + public Criteria andCommentNotIn(List values) { + addCriterion("`comment` not in", values, "comment"); + return (Criteria) this; + } + + public Criteria andCommentBetween(String value1, String value2) { + addCriterion("`comment` between", value1, value2, "comment"); + return (Criteria) this; + } + + public Criteria andCommentNotBetween(String value1, String value2) { + addCriterion("`comment` not between", value1, value2, "comment"); + return (Criteria) this; + } + + public Criteria andYearIsNull() { + addCriterion("`year` is null"); + return (Criteria) this; + } + + public Criteria andYearIsNotNull() { + addCriterion("`year` is not null"); + return (Criteria) this; + } + + public Criteria andYearEqualTo(String value) { + addCriterion("`year` =", value, "year"); + return (Criteria) this; + } + + public Criteria andYearNotEqualTo(String value) { + addCriterion("`year` <>", value, "year"); + return (Criteria) this; + } + + public Criteria andYearGreaterThan(String value) { + addCriterion("`year` >", value, "year"); + return (Criteria) this; + } + + public Criteria andYearGreaterThanOrEqualTo(String value) { + addCriterion("`year` >=", value, "year"); + return (Criteria) this; + } + + public Criteria andYearLessThan(String value) { + addCriterion("`year` <", value, "year"); + return (Criteria) this; + } + + public Criteria andYearLessThanOrEqualTo(String value) { + addCriterion("`year` <=", value, "year"); + return (Criteria) this; + } + + public Criteria andYearLike(String value) { + addCriterion("`year` like", value, "year"); + return (Criteria) this; + } + + public Criteria andYearNotLike(String value) { + addCriterion("`year` not like", value, "year"); + return (Criteria) this; + } + + public Criteria andYearIn(List values) { + addCriterion("`year` in", values, "year"); + return (Criteria) this; + } + + public Criteria andYearNotIn(List values) { + addCriterion("`year` not in", values, "year"); + return (Criteria) this; + } + + public Criteria andYearBetween(String value1, String value2) { + addCriterion("`year` between", value1, value2, "year"); + return (Criteria) this; + } + + public Criteria andYearNotBetween(String value1, String value2) { + addCriterion("`year` not between", value1, value2, "year"); + return (Criteria) this; + } + + public Criteria andTrackIsNull() { + addCriterion("track is null"); + return (Criteria) this; + } + + public Criteria andTrackIsNotNull() { + addCriterion("track is not null"); + return (Criteria) this; + } + + public Criteria andTrackEqualTo(String value) { + addCriterion("track =", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackNotEqualTo(String value) { + addCriterion("track <>", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackGreaterThan(String value) { + addCriterion("track >", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackGreaterThanOrEqualTo(String value) { + addCriterion("track >=", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackLessThan(String value) { + addCriterion("track <", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackLessThanOrEqualTo(String value) { + addCriterion("track <=", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackLike(String value) { + addCriterion("track like", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackNotLike(String value) { + addCriterion("track not like", value, "track"); + return (Criteria) this; + } + + public Criteria andTrackIn(List values) { + addCriterion("track in", values, "track"); + return (Criteria) this; + } + + public Criteria andTrackNotIn(List values) { + addCriterion("track not in", values, "track"); + return (Criteria) this; + } + + public Criteria andTrackBetween(String value1, String value2) { + addCriterion("track between", value1, value2, "track"); + return (Criteria) this; + } + + public Criteria andTrackNotBetween(String value1, String value2) { + addCriterion("track not between", value1, value2, "track"); + return (Criteria) this; + } + + public Criteria andDiscNoIsNull() { + addCriterion("disc_no is null"); + return (Criteria) this; + } + + public Criteria andDiscNoIsNotNull() { + addCriterion("disc_no is not null"); + return (Criteria) this; + } + + public Criteria andDiscNoEqualTo(String value) { + addCriterion("disc_no =", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoNotEqualTo(String value) { + addCriterion("disc_no <>", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoGreaterThan(String value) { + addCriterion("disc_no >", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoGreaterThanOrEqualTo(String value) { + addCriterion("disc_no >=", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoLessThan(String value) { + addCriterion("disc_no <", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoLessThanOrEqualTo(String value) { + addCriterion("disc_no <=", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoLike(String value) { + addCriterion("disc_no like", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoNotLike(String value) { + addCriterion("disc_no not like", value, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoIn(List values) { + addCriterion("disc_no in", values, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoNotIn(List values) { + addCriterion("disc_no not in", values, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoBetween(String value1, String value2) { + addCriterion("disc_no between", value1, value2, "discNo"); + return (Criteria) this; + } + + public Criteria andDiscNoNotBetween(String value1, String value2) { + addCriterion("disc_no not between", value1, value2, "discNo"); + return (Criteria) this; + } + + public Criteria andComposerIsNull() { + addCriterion("composer is null"); + return (Criteria) this; + } + + public Criteria andComposerIsNotNull() { + addCriterion("composer is not null"); + return (Criteria) this; + } + + public Criteria andComposerEqualTo(String value) { + addCriterion("composer =", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerNotEqualTo(String value) { + addCriterion("composer <>", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerGreaterThan(String value) { + addCriterion("composer >", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerGreaterThanOrEqualTo(String value) { + addCriterion("composer >=", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerLessThan(String value) { + addCriterion("composer <", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerLessThanOrEqualTo(String value) { + addCriterion("composer <=", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerLike(String value) { + addCriterion("composer like", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerNotLike(String value) { + addCriterion("composer not like", value, "composer"); + return (Criteria) this; + } + + public Criteria andComposerIn(List values) { + addCriterion("composer in", values, "composer"); + return (Criteria) this; + } + + public Criteria andComposerNotIn(List values) { + addCriterion("composer not in", values, "composer"); + return (Criteria) this; + } + + public Criteria andComposerBetween(String value1, String value2) { + addCriterion("composer between", value1, value2, "composer"); + return (Criteria) this; + } + + public Criteria andComposerNotBetween(String value1, String value2) { + addCriterion("composer not between", value1, value2, "composer"); + return (Criteria) this; + } + + public Criteria andArtistSortIsNull() { + addCriterion("artist_sort is null"); + return (Criteria) this; + } + + public Criteria andArtistSortIsNotNull() { + addCriterion("artist_sort is not null"); + return (Criteria) this; + } + + public Criteria andArtistSortEqualTo(String value) { + addCriterion("artist_sort =", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortNotEqualTo(String value) { + addCriterion("artist_sort <>", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortGreaterThan(String value) { + addCriterion("artist_sort >", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortGreaterThanOrEqualTo(String value) { + addCriterion("artist_sort >=", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortLessThan(String value) { + addCriterion("artist_sort <", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortLessThanOrEqualTo(String value) { + addCriterion("artist_sort <=", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortLike(String value) { + addCriterion("artist_sort like", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortNotLike(String value) { + addCriterion("artist_sort not like", value, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortIn(List values) { + addCriterion("artist_sort in", values, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortNotIn(List values) { + addCriterion("artist_sort not in", values, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortBetween(String value1, String value2) { + addCriterion("artist_sort between", value1, value2, "artistSort"); + return (Criteria) this; + } + + public Criteria andArtistSortNotBetween(String value1, String value2) { + addCriterion("artist_sort not between", value1, value2, "artistSort"); + return (Criteria) this; + } + + public Criteria andFileIsNull() { + addCriterion("`file` is null"); + return (Criteria) this; + } + + public Criteria andFileIsNotNull() { + addCriterion("`file` is not null"); + return (Criteria) this; + } + + public Criteria andFileEqualTo(String value) { + addCriterion("`file` =", value, "file"); + return (Criteria) this; + } + + public Criteria andFileNotEqualTo(String value) { + addCriterion("`file` <>", value, "file"); + return (Criteria) this; + } + + public Criteria andFileGreaterThan(String value) { + addCriterion("`file` >", value, "file"); + return (Criteria) this; + } + + public Criteria andFileGreaterThanOrEqualTo(String value) { + addCriterion("`file` >=", value, "file"); + return (Criteria) this; + } + + public Criteria andFileLessThan(String value) { + addCriterion("`file` <", value, "file"); + return (Criteria) this; + } + + public Criteria andFileLessThanOrEqualTo(String value) { + addCriterion("`file` <=", value, "file"); + return (Criteria) this; + } + + public Criteria andFileLike(String value) { + addCriterion("`file` like", value, "file"); + return (Criteria) this; + } + + public Criteria andFileNotLike(String value) { + addCriterion("`file` not like", value, "file"); + return (Criteria) this; + } + + public Criteria andFileIn(List values) { + addCriterion("`file` in", values, "file"); + return (Criteria) this; + } + + public Criteria andFileNotIn(List values) { + addCriterion("`file` not in", values, "file"); + return (Criteria) this; + } + + public Criteria andFileBetween(String value1, String value2) { + addCriterion("`file` between", value1, value2, "file"); + return (Criteria) this; + } + + public Criteria andFileNotBetween(String value1, String value2) { + addCriterion("`file` not between", value1, value2, "file"); + return (Criteria) this; + } + + public Criteria andLastdirIsNull() { + addCriterion("lastDir is null"); + return (Criteria) this; + } + + public Criteria andLastdirIsNotNull() { + addCriterion("lastDir is not null"); + return (Criteria) this; + } + + public Criteria andLastdirEqualTo(String value) { + addCriterion("lastDir =", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirNotEqualTo(String value) { + addCriterion("lastDir <>", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirGreaterThan(String value) { + addCriterion("lastDir >", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirGreaterThanOrEqualTo(String value) { + addCriterion("lastDir >=", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirLessThan(String value) { + addCriterion("lastDir <", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirLessThanOrEqualTo(String value) { + addCriterion("lastDir <=", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirLike(String value) { + addCriterion("lastDir like", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirNotLike(String value) { + addCriterion("lastDir not like", value, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirIn(List values) { + addCriterion("lastDir in", values, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirNotIn(List values) { + addCriterion("lastDir not in", values, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirBetween(String value1, String value2) { + addCriterion("lastDir between", value1, value2, "lastdir"); + return (Criteria) this; + } + + public Criteria andLastdirNotBetween(String value1, String value2) { + addCriterion("lastDir not between", value1, value2, "lastdir"); + return (Criteria) this; + } + + public Criteria andIsdirIsNull() { + addCriterion("isDir is null"); + return (Criteria) this; + } + + public Criteria andIsdirIsNotNull() { + addCriterion("isDir is not null"); + return (Criteria) this; + } + + public Criteria andIsdirEqualTo(Integer value) { + addCriterion("isDir =", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirNotEqualTo(Integer value) { + addCriterion("isDir <>", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirGreaterThan(Integer value) { + addCriterion("isDir >", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirGreaterThanOrEqualTo(Integer value) { + addCriterion("isDir >=", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirLessThan(Integer value) { + addCriterion("isDir <", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirLessThanOrEqualTo(Integer value) { + addCriterion("isDir <=", value, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirIn(List values) { + addCriterion("isDir in", values, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirNotIn(List values) { + addCriterion("isDir not in", values, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirBetween(Integer value1, Integer value2) { + addCriterion("isDir between", value1, value2, "isdir"); + return (Criteria) this; + } + + public Criteria andIsdirNotBetween(Integer value1, Integer value2) { + addCriterion("isDir not between", value1, value2, "isdir"); + return (Criteria) this; + } + + public Criteria andBitrateIsNull() { + addCriterion("bitRate is null"); + return (Criteria) this; + } + + public Criteria andBitrateIsNotNull() { + addCriterion("bitRate is not null"); + return (Criteria) this; + } + + public Criteria andBitrateEqualTo(Integer value) { + addCriterion("bitRate =", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateNotEqualTo(Integer value) { + addCriterion("bitRate <>", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateGreaterThan(Integer value) { + addCriterion("bitRate >", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateGreaterThanOrEqualTo(Integer value) { + addCriterion("bitRate >=", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateLessThan(Integer value) { + addCriterion("bitRate <", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateLessThanOrEqualTo(Integer value) { + addCriterion("bitRate <=", value, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateIn(List values) { + addCriterion("bitRate in", values, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateNotIn(List values) { + addCriterion("bitRate not in", values, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateBetween(Integer value1, Integer value2) { + addCriterion("bitRate between", value1, value2, "bitrate"); + return (Criteria) this; + } + + public Criteria andBitrateNotBetween(Integer value1, Integer value2) { + addCriterion("bitRate not between", value1, value2, "bitrate"); + return (Criteria) this; + } + + public Criteria andSamplerateIsNull() { + addCriterion("sampleRate is null"); + return (Criteria) this; + } + + public Criteria andSamplerateIsNotNull() { + addCriterion("sampleRate is not null"); + return (Criteria) this; + } + + public Criteria andSamplerateEqualTo(Integer value) { + addCriterion("sampleRate =", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateNotEqualTo(Integer value) { + addCriterion("sampleRate <>", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateGreaterThan(Integer value) { + addCriterion("sampleRate >", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateGreaterThanOrEqualTo(Integer value) { + addCriterion("sampleRate >=", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateLessThan(Integer value) { + addCriterion("sampleRate <", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateLessThanOrEqualTo(Integer value) { + addCriterion("sampleRate <=", value, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateIn(List values) { + addCriterion("sampleRate in", values, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateNotIn(List values) { + addCriterion("sampleRate not in", values, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateBetween(Integer value1, Integer value2) { + addCriterion("sampleRate between", value1, value2, "samplerate"); + return (Criteria) this; + } + + public Criteria andSamplerateNotBetween(Integer value1, Integer value2) { + addCriterion("sampleRate not between", value1, value2, "samplerate"); + return (Criteria) this; + } + + public Criteria andNoofsamplesIsNull() { + addCriterion("noOfSamples is null"); + return (Criteria) this; + } + + public Criteria andNoofsamplesIsNotNull() { + addCriterion("noOfSamples is not null"); + return (Criteria) this; + } + + public Criteria andNoofsamplesEqualTo(Long value) { + addCriterion("noOfSamples =", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesNotEqualTo(Long value) { + addCriterion("noOfSamples <>", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesGreaterThan(Long value) { + addCriterion("noOfSamples >", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesGreaterThanOrEqualTo(Long value) { + addCriterion("noOfSamples >=", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesLessThan(Long value) { + addCriterion("noOfSamples <", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesLessThanOrEqualTo(Long value) { + addCriterion("noOfSamples <=", value, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesIn(List values) { + addCriterion("noOfSamples in", values, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesNotIn(List values) { + addCriterion("noOfSamples not in", values, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesBetween(Long value1, Long value2) { + addCriterion("noOfSamples between", value1, value2, "noofsamples"); + return (Criteria) this; + } + + public Criteria andNoofsamplesNotBetween(Long value1, Long value2) { + addCriterion("noOfSamples not between", value1, value2, "noofsamples"); + return (Criteria) this; + } + + public Criteria andChannelcountIsNull() { + addCriterion("channelCount is null"); + return (Criteria) this; + } + + public Criteria andChannelcountIsNotNull() { + addCriterion("channelCount is not null"); + return (Criteria) this; + } + + public Criteria andChannelcountEqualTo(Integer value) { + addCriterion("channelCount =", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountNotEqualTo(Integer value) { + addCriterion("channelCount <>", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountGreaterThan(Integer value) { + addCriterion("channelCount >", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountGreaterThanOrEqualTo(Integer value) { + addCriterion("channelCount >=", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountLessThan(Integer value) { + addCriterion("channelCount <", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountLessThanOrEqualTo(Integer value) { + addCriterion("channelCount <=", value, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountIn(List values) { + addCriterion("channelCount in", values, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountNotIn(List values) { + addCriterion("channelCount not in", values, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountBetween(Integer value1, Integer value2) { + addCriterion("channelCount between", value1, value2, "channelcount"); + return (Criteria) this; + } + + public Criteria andChannelcountNotBetween(Integer value1, Integer value2) { + addCriterion("channelCount not between", value1, value2, "channelcount"); + return (Criteria) this; + } + + public Criteria andEncodingtypeIsNull() { + addCriterion("encodingType is null"); + return (Criteria) this; + } + + public Criteria andEncodingtypeIsNotNull() { + addCriterion("encodingType is not null"); + return (Criteria) this; + } + + public Criteria andEncodingtypeEqualTo(String value) { + addCriterion("encodingType =", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeNotEqualTo(String value) { + addCriterion("encodingType <>", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeGreaterThan(String value) { + addCriterion("encodingType >", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeGreaterThanOrEqualTo(String value) { + addCriterion("encodingType >=", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeLessThan(String value) { + addCriterion("encodingType <", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeLessThanOrEqualTo(String value) { + addCriterion("encodingType <=", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeLike(String value) { + addCriterion("encodingType like", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeNotLike(String value) { + addCriterion("encodingType not like", value, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeIn(List values) { + addCriterion("encodingType in", values, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeNotIn(List values) { + addCriterion("encodingType not in", values, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeBetween(String value1, String value2) { + addCriterion("encodingType between", value1, value2, "encodingtype"); + return (Criteria) this; + } + + public Criteria andEncodingtypeNotBetween(String value1, String value2) { + addCriterion("encodingType not between", value1, value2, "encodingtype"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleIsNull() { + addCriterion("durationAsDouble is null"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleIsNotNull() { + addCriterion("durationAsDouble is not null"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleEqualTo(Double value) { + addCriterion("durationAsDouble =", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleNotEqualTo(Double value) { + addCriterion("durationAsDouble <>", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleGreaterThan(Double value) { + addCriterion("durationAsDouble >", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleGreaterThanOrEqualTo(Double value) { + addCriterion("durationAsDouble >=", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleLessThan(Double value) { + addCriterion("durationAsDouble <", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleLessThanOrEqualTo(Double value) { + addCriterion("durationAsDouble <=", value, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleIn(List values) { + addCriterion("durationAsDouble in", values, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleNotIn(List values) { + addCriterion("durationAsDouble not in", values, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleBetween(Double value1, Double value2) { + addCriterion("durationAsDouble between", value1, value2, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andDurationasdoubleNotBetween(Double value1, Double value2) { + addCriterion("durationAsDouble not between", value1, value2, "durationasdouble"); + return (Criteria) this; + } + + public Criteria andLosslessIsNull() { + addCriterion("lossless is null"); + return (Criteria) this; + } + + public Criteria andLosslessIsNotNull() { + addCriterion("lossless is not null"); + return (Criteria) this; + } + + public Criteria andLosslessEqualTo(Integer value) { + addCriterion("lossless =", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessNotEqualTo(Integer value) { + addCriterion("lossless <>", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessGreaterThan(Integer value) { + addCriterion("lossless >", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessGreaterThanOrEqualTo(Integer value) { + addCriterion("lossless >=", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessLessThan(Integer value) { + addCriterion("lossless <", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessLessThanOrEqualTo(Integer value) { + addCriterion("lossless <=", value, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessIn(List values) { + addCriterion("lossless in", values, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessNotIn(List values) { + addCriterion("lossless not in", values, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessBetween(Integer value1, Integer value2) { + addCriterion("lossless between", value1, value2, "lossless"); + return (Criteria) this; + } + + public Criteria andLosslessNotBetween(Integer value1, Integer value2) { + addCriterion("lossless not between", value1, value2, "lossless"); + return (Criteria) this; + } + + public Criteria andVariablebitrateIsNull() { + addCriterion("variableBitRate is null"); + return (Criteria) this; + } + + public Criteria andVariablebitrateIsNotNull() { + addCriterion("variableBitRate is not null"); + return (Criteria) this; + } + + public Criteria andVariablebitrateEqualTo(Integer value) { + addCriterion("variableBitRate =", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateNotEqualTo(Integer value) { + addCriterion("variableBitRate <>", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateGreaterThan(Integer value) { + addCriterion("variableBitRate >", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateGreaterThanOrEqualTo(Integer value) { + addCriterion("variableBitRate >=", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateLessThan(Integer value) { + addCriterion("variableBitRate <", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateLessThanOrEqualTo(Integer value) { + addCriterion("variableBitRate <=", value, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateIn(List values) { + addCriterion("variableBitRate in", values, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateNotIn(List values) { + addCriterion("variableBitRate not in", values, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateBetween(Integer value1, Integer value2) { + addCriterion("variableBitRate between", value1, value2, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andVariablebitrateNotBetween(Integer value1, Integer value2) { + addCriterion("variableBitRate not between", value1, value2, "variablebitrate"); + return (Criteria) this; + } + + public Criteria andMd5IsNull() { + addCriterion("md5 is null"); + return (Criteria) this; + } + + public Criteria andMd5IsNotNull() { + addCriterion("md5 is not null"); + return (Criteria) this; + } + + public Criteria andMd5EqualTo(String value) { + addCriterion("md5 =", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5NotEqualTo(String value) { + addCriterion("md5 <>", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5GreaterThan(String value) { + addCriterion("md5 >", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5GreaterThanOrEqualTo(String value) { + addCriterion("md5 >=", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5LessThan(String value) { + addCriterion("md5 <", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5LessThanOrEqualTo(String value) { + addCriterion("md5 <=", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5Like(String value) { + addCriterion("md5 like", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5NotLike(String value) { + addCriterion("md5 not like", value, "md5"); + return (Criteria) this; + } + + public Criteria andMd5In(List values) { + addCriterion("md5 in", values, "md5"); + return (Criteria) this; + } + + public Criteria andMd5NotIn(List values) { + addCriterion("md5 not in", values, "md5"); + return (Criteria) this; + } + + public Criteria andMd5Between(String value1, String value2) { + addCriterion("md5 between", value1, value2, "md5"); + return (Criteria) this; + } + + public Criteria andMd5NotBetween(String value1, String value2) { + addCriterion("md5 not between", value1, value2, "md5"); + 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/mybatis/model/MusicFavorites.java b/src/main/java/com/yutou/tools/mybatis/model/MusicFavorites.java new file mode 100644 index 0000000..2b2ee25 --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/model/MusicFavorites.java @@ -0,0 +1,19 @@ +package com.yutou.tools.mybatis.model; + +import java.io.Serializable; +import lombok.Data; + +/** + * music_favorites + * @author + */ +@Data +public class MusicFavorites implements Serializable { + private Integer id; + + private String title; + + private String musisMd5; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/mybatis/model/MusicFavoritesExample.java b/src/main/java/com/yutou/tools/mybatis/model/MusicFavoritesExample.java new file mode 100644 index 0000000..147f668 --- /dev/null +++ b/src/main/java/com/yutou/tools/mybatis/model/MusicFavoritesExample.java @@ -0,0 +1,401 @@ +package com.yutou.tools.mybatis.model; + +import java.util.ArrayList; +import java.util.List; + +public class MusicFavoritesExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public MusicFavoritesExample() { + oredCriteria = new ArrayList<>(); + } + + 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 andTitleIsNull() { + addCriterion("title is null"); + return (Criteria) this; + } + + public Criteria andTitleIsNotNull() { + addCriterion("title is not null"); + return (Criteria) this; + } + + public Criteria andTitleEqualTo(String value) { + addCriterion("title =", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotEqualTo(String value) { + addCriterion("title <>", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThan(String value) { + addCriterion("title >", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThanOrEqualTo(String value) { + addCriterion("title >=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThan(String value) { + addCriterion("title <", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThanOrEqualTo(String value) { + addCriterion("title <=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLike(String value) { + addCriterion("title like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotLike(String value) { + addCriterion("title not like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleIn(List values) { + addCriterion("title in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotIn(List values) { + addCriterion("title not in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleBetween(String value1, String value2) { + addCriterion("title between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotBetween(String value1, String value2) { + addCriterion("title not between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andMusisMd5IsNull() { + addCriterion("musis_md5 is null"); + return (Criteria) this; + } + + public Criteria andMusisMd5IsNotNull() { + addCriterion("musis_md5 is not null"); + return (Criteria) this; + } + + public Criteria andMusisMd5EqualTo(String value) { + addCriterion("musis_md5 =", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5NotEqualTo(String value) { + addCriterion("musis_md5 <>", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5GreaterThan(String value) { + addCriterion("musis_md5 >", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5GreaterThanOrEqualTo(String value) { + addCriterion("musis_md5 >=", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5LessThan(String value) { + addCriterion("musis_md5 <", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5LessThanOrEqualTo(String value) { + addCriterion("musis_md5 <=", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5Like(String value) { + addCriterion("musis_md5 like", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5NotLike(String value) { + addCriterion("musis_md5 not like", value, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5In(List values) { + addCriterion("musis_md5 in", values, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5NotIn(List values) { + addCriterion("musis_md5 not in", values, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5Between(String value1, String value2) { + addCriterion("musis_md5 between", value1, value2, "musisMd5"); + return (Criteria) this; + } + + public Criteria andMusisMd5NotBetween(String value1, String value2) { + addCriterion("musis_md5 not between", value1, value2, "musisMd5"); + 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java index 1725834..7c88dde 100644 --- a/src/main/java/com/yutou/tools/other/tools.java +++ b/src/main/java/com/yutou/tools/other/tools.java @@ -2,6 +2,7 @@ package com.yutou.tools.other; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.yutou.tools.ToolsApplication; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -61,4 +62,9 @@ public class tools { return str; //return "function test(){ return \"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588139022200&di=8cc8405f7514dd54bd82fcd070349603&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg\" }"; } + @RequestMapping("/public/version.do") + @ResponseBody + public String getVersion(){ + return ToolsApplication.version; + } } diff --git a/src/main/java/com/yutou/tools/utils/ApplicationInit.java b/src/main/java/com/yutou/tools/utils/ApplicationInit.java new file mode 100644 index 0000000..4c26626 --- /dev/null +++ b/src/main/java/com/yutou/tools/utils/ApplicationInit.java @@ -0,0 +1,20 @@ +package com.yutou.tools.utils; + +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 服务启动后执行 + */ +@Component +public class ApplicationInit implements ApplicationRunner { + @Resource + MusicTools musicTools; + @Override + public void run(ApplicationArguments args) throws Exception { + musicTools.init();//初始化音乐库 + } +} diff --git a/src/main/java/com/yutou/tools/utils/Interfaces/MusicToolsService.java b/src/main/java/com/yutou/tools/utils/Interfaces/MusicToolsService.java new file mode 100644 index 0000000..5600fc0 --- /dev/null +++ b/src/main/java/com/yutou/tools/utils/Interfaces/MusicToolsService.java @@ -0,0 +1,29 @@ +package com.yutou.tools.utils.Interfaces; + +import com.yutou.tools.mybatis.model.MusicData; + +import java.util.List; + +public interface MusicToolsService { + void init(); + + void scanMusic(); + + List getPath(String path, boolean isDir); + + MusicData getMusicData(String md5); + + List findOfTitle(String title); + + List findOfArtist(String by); + + List getMusicList(); + + int getLength(); + + boolean isScan(); + + String getMusicPath(); + + byte[] readImage(String path) throws Exception; +} diff --git a/src/main/java/com/yutou/tools/utils/MusicTools.java b/src/main/java/com/yutou/tools/utils/MusicTools.java index 2685f70..74b728b 100644 --- a/src/main/java/com/yutou/tools/utils/MusicTools.java +++ b/src/main/java/com/yutou/tools/utils/MusicTools.java @@ -1,9 +1,10 @@ package com.yutou.tools.utils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.yutou.tools.home.nas.Data.MusicData; import com.yutou.tools.home.nas.MusicController; +import com.yutou.tools.mybatis.dao.MusicDataDao; +import com.yutou.tools.mybatis.model.MusicData; +import com.yutou.tools.mybatis.model.MusicDataExample; +import com.yutou.tools.utils.Interfaces.MusicToolsService; import ealvatag.audio.AudioFile; import ealvatag.audio.AudioFileIO; import ealvatag.audio.AudioHeader; @@ -11,31 +12,44 @@ import ealvatag.audio.exceptions.CannotReadException; import ealvatag.tag.FieldKey; import ealvatag.tag.NullTag; import ealvatag.tag.Tag; -import ealvatag.tag.flac.FlacTag; +import ealvatag.tag.images.NullArtwork; +import net.bramp.ffmpeg.FFmpeg; +import net.bramp.ffmpeg.FFprobe; +import net.bramp.ffmpeg.probe.FFmpegFormat; +import net.bramp.ffmpeg.probe.FFmpegProbeResult; +import net.bramp.ffmpeg.probe.FFmpegStream; +import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.io.*; +import javax.annotation.Resource; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.*; -public class MusicTools { +@Service("musicToolsService") +public class MusicTools implements MusicToolsService { public static final int FIND_TITLE = 1; public static final int FIND_ARTIST = 2; - private static MusicTools tools; private String musicPath = "/media/yutou/4t/public/音乐"; - private final List musicList = new ArrayList<>(); - private HashMap> musicMap = new HashMap>(); private boolean isScan = false; - public static MusicTools getInstance() { - if (tools == null) { - tools = new MusicTools(); - } - return tools; - } + @Resource + MusicDataDao musicDataDao; + private MusicTools() { + + } + + @Override + public void init() { + musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); scanMusic(); new Timer().schedule(new TimerTask() { @Override @@ -49,36 +63,26 @@ public class MusicTools { }, 0, 10 * 1000); } - public synchronized void scanMusic() { - if (isScan) { + @Override + public void scanMusic() { + if (isScan || true) { return; } - System.out.println("执行扫描"); - musicList.clear(); - musicMap.clear(); + musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); + musicDataDao.truncate(); + System.out.println("执行扫描:" + musicPath); new Thread(() -> { + long startTime = System.currentTimeMillis(); + QQBotManager.getInstance().sendMessage("开始扫描音乐夹"); isScan = true; scan(new File(musicPath)); isScan = false; System.out.println("扫描完成"); + QQBotManager.getInstance().sendMessage("音乐扫描完成,共" + getLength() + "首歌,耗时:" + + (System.currentTimeMillis() - startTime)); }).start(); } - public List scan(File path, boolean isScanDir) { - if (isScanDir) { - scan(path); - return musicList; - } else { - if (path.exists() && path.isDirectory()) { - List list = new ArrayList<>(); - for (File file : path.listFiles()) { - list.add(getMetadata(file)); - } - return list; - } - } - return null; - } private void scan(File path) { if (path.isFile()) { @@ -105,6 +109,7 @@ public class MusicTools { } } + /** * 获取指定目录下的音乐 * @@ -112,46 +117,48 @@ public class MusicTools { * @param isDir 是否扫描目录下的所有文件,false则仅为当前目录 * @return 音乐列表 */ + @Override public List getPath(String path, boolean isDir) { List list = new ArrayList<>(); + List main; + MusicDataExample example = new MusicDataExample(); + String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/"; if (isDir) { - if (new File(path).isDirectory() && !path.equals(MusicController.defaultMusicPath)) { - for (String key : musicMap.keySet()) { - if (key.startsWith(path)) { - list.addAll(musicMap.get(key)); - } - } - return list; - } - } - if (musicMap.containsKey(path)) { - MusicData tmp = musicMap.get(path).isEmpty() ? null : musicMap.get(path).get(0); - if (tmp != null) { - if (!tmp.getFile().getParent().equals(MusicController.defaultMusicPath)) { - MusicData t2 = new MusicData(); - t2.setTitle("返回"); - t2.setFile(new File(tmp.getLastDir())); - list.add(t2); - } - - } - getDirList(path, list); - list.addAll(musicMap.get(path)); - return list; + example.createCriteria().andFileLike(path.replace(File.separator, replacement) + "%"); + main = musicDataDao.selectByExample(example); } else { - if (path.contains(MusicController.defaultMusicPath)) { - MusicData t2 = new MusicData(); - t2.setTitle("返回"); - t2.setFile(new File(path).getParentFile()); - if (!path.equals(MusicController.defaultMusicPath)) { - list.add(t2); - } - getDirList(path, list); - return list; - } - + main = musicDataDao.selectByRegexp(path.replace(File.separator, replacement) + replacement + "([^" + replacement + "]+)$"); } - return new ArrayList<>(); + System.out.println(path + " " + isDir); + if (!path.equals(MusicController.defaultMusicPath) && !path.equals("root") && main.size() > 0) { + MusicData tmp = main.get(0); + System.out.println(tmp); + MusicData t2 = new MusicData(); + t2.setTitle("返回"); + t2.setFile(new File(tmp.getLastdir()).getAbsolutePath()); + t2.setIsdir(1); + list.add(t2); + } + getDirList(path, list); + list.addAll(main); + System.out.println(list.size()); + return list; + } + + public List getAllAlbum() { + return musicDataDao.selectAllAlbum(); + } + + public List getAllArtist() { + return musicDataDao.selectAllArtist(); + } + + public List selectAlbum(String album) { + return musicDataDao.selectAlbum(album); + } + + public List selectArtist(String artist) { + return musicDataDao.selectArtist(artist); } private void getDirList(String path, List list) { @@ -160,7 +167,8 @@ public class MusicTools { if (listFile.isDirectory()) { MusicData data = new MusicData(); data.setTitle(listFile.getName()); - data.setFile(listFile); + data.setIsdir(1); + data.setFile(listFile.getAbsolutePath()); list.add(data); } } @@ -169,19 +177,28 @@ public class MusicTools { private void add(File file) { MusicData data = getMetadata(file); if (data != null) { - musicList.add(data); - String path = file.getAbsolutePath().replace(File.separator + file.getName(), ""); - List list; - if (musicMap.containsKey(path)) { - list = musicMap.get(path); - } else { - list = new ArrayList<>(); + try { + musicDataDao.insert(data); + } catch (Exception e) { + e.printStackTrace(); + QQBotManager.getInstance().sendMessage("音乐文件添加失败:" + data.toString()); } - list.add(data); - musicMap.put(path, list); + } } + @Override + public MusicData getMusicData(String path) { + MusicDataExample example = new MusicDataExample(); + example.createCriteria().andFileEqualTo(Tools.base64ToString(path)); + List list = musicDataDao.selectByExample(example); + if (list != null && list.size() > 0) { + return list.get(0); + } + return null; + } + + public MusicData getMetadata(File file) { try { if (file.getName().endsWith(".lrc") @@ -208,7 +225,7 @@ public class MusicTools { } catch (Exception e) { } try { - data.setArtist_sort(tag.getFirst(FieldKey.ARTIST_SORT)); + data.setArtistSort(tag.getFirst(FieldKey.ARTIST_SORT)); } catch (Exception e) { } try { @@ -220,7 +237,7 @@ public class MusicTools { } catch (Exception e) { } try { - data.setDisc_no(tag.getFirst(FieldKey.DISC_NO)); + data.setDiscNo(tag.getFirst(FieldKey.DISC_NO)); } catch (Exception e) { } try { @@ -240,30 +257,27 @@ public class MusicTools { data.setYear(tag.getFirst(FieldKey.YEAR)); } catch (Exception e) { } - data.setFile(file); + data.setFile(file.getAbsolutePath()); + data.setIsdir(file.isDirectory() ? 1 : 0); + data.setLastdir(file.getParentFile().getParent()); AudioHeader header = audioFile.getAudioHeader(); - data.setBitRate(header.getBitRate()); - data.setSampleRate(header.getSampleRate()); - data.setNoOfSamples(header.getNoOfSamples()); - data.setChannelCount(header.getChannelCount()); - data.setEncodingType(header.getEncodingType()); - data.setDurationAsDouble(header.getDurationAsDouble()); - data.setLossless(header.isLossless()); - data.setVariableBitRate(header.isVariableBitRate()); + data.setBitrate(header.getBitRate()); + data.setSamplerate(header.getSampleRate()); + data.setNoofsamples(header.getNoOfSamples()); + data.setChannelcount(header.getChannelCount()); + data.setEncodingtype(header.getEncodingType()); + data.setDurationasdouble(header.getDurationAsDouble()); + data.setLossless(header.isLossless() ? 1 : 0); + data.setVariablebitrate(header.isVariableBitRate() ? 1 : 0); try { data.setMd5(header.getClass().getMethod("getMd5").invoke(header).toString()); } catch (Exception ignored) { - data.setMd5(Base64.getEncoder().encodeToString(file.getAbsolutePath().getBytes())); + data.setMd5(Tools.getFileMD5(file)); } return data; } catch (CannotReadException e) { - MusicData data = getMetadata_jthink(file); - if (data == null) - data = new MusicData(); - data.setTitle(file.getName()); - data.setFile(file); - return data; + return getMetadata_jthink(file); } catch (Exception e) { e.printStackTrace(); } @@ -284,7 +298,7 @@ public class MusicTools { } catch (Exception ignored) { } try { - data.setArtist_sort(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST_SORT)); + data.setArtistSort(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST_SORT)); } catch (Exception ignored) { } try { @@ -296,7 +310,7 @@ public class MusicTools { } catch (Exception ignored) { } try { - data.setDisc_no(tag.getFirst(org.jaudiotagger.tag.FieldKey.DISC_NO)); + data.setDiscNo(tag.getFirst(org.jaudiotagger.tag.FieldKey.DISC_NO)); } catch (Exception ignored) { } try { @@ -316,60 +330,166 @@ public class MusicTools { data.setYear(tag.getFirst(org.jaudiotagger.tag.FieldKey.YEAR)); } catch (Exception ignored) { } - data.setFile(file); + data.setFile(file.getAbsolutePath()); + data.setIsdir(file.isDirectory() ? 1 : 0); + data.setLastdir(file.getParentFile().getParent()); org.jaudiotagger.audio.AudioHeader header = audioFile.getAudioHeader(); - data.setBitRate(Integer.parseInt(header.getBitRate())); - data.setSampleRate(Integer.parseInt(header.getSampleRate())); - data.setNoOfSamples(header.getSampleRateAsNumber()); - data.setChannelCount(Integer.parseInt(header.getChannels())); - data.setEncodingType(header.getEncodingType() + ""); - data.setDurationAsDouble(header.getTrackLength()); - data.setLossless(header.isLossless()); - data.setVariableBitRate(header.isVariableBitRate()); + data.setBitrate(Integer.parseInt(header.getBitRate())); + data.setSamplerate(Integer.parseInt(header.getSampleRate())); + data.setNoofsamples(Long.parseLong(header.getSampleRateAsNumber() + "")); + data.setChannelcount(Integer.parseInt(header.getChannels())); + data.setEncodingtype(header.getEncodingType() + ""); + data.setDurationasdouble(Double.parseDouble(header.getTrackLength() + "")); + data.setLossless(header.isLossless() ? 1 : 0); + data.setVariablebitrate(header.isVariableBitRate() ? 1 : 0); try { data.setMd5(header.getClass().getMethod("getMd5").invoke(header).toString()); } catch (Exception ignored) { - data.setMd5(Base64.getEncoder().encodeToString(file.getAbsolutePath().getBytes())); + data.setMd5(Tools.getFileMD5(file)); } return data; } catch (Exception e) { - e.printStackTrace(); + return getMetadataOfFFmpeg(file); } - return null; } + private MusicData getMetadataOfFFmpeg(File file) { + MusicData data; + try { + data = new MusicData(); + FFprobe fFprobe = new FFprobe((String) ConfigTools.load(ConfigTools.CONFIG, "ffprobe")); + FFmpegProbeResult result = fFprobe.probe(file.getAbsolutePath()); + FFmpegFormat format = result.getFormat(); + FFmpegStream stream = null; + for (FFmpegStream tmp : result.getStreams()) { + if (tmp.index == 0) { + stream = tmp; + } + } + Map tag = format.tags; + data.setTitle(getTitle(tag)); + data.setAlbum(getAlbum(tag)); + data.setArtist(getArtist(tag)); + data.setDiscNo(tag.get("disc") == null ? tag.get("disc".toUpperCase()) : tag.get("disc")); + data.setTrack(tag.get("track") == null ? tag.get("track".toUpperCase()) : tag.get("track")); + data.setYear(getYear(tag)); + data.setArtistSort(tag.get("album_artist") == null ? tag.get("album_artist".toUpperCase()) : tag.get("album_artist")); + data.setDurationasdouble(format.duration); + data.setBitrate((int) (format.bit_rate / 1000)); + if (stream != null) { + if (data.getBitrate() == 0) + data.setBitrate((int) (stream.bit_rate / 1000)); + data.setChannelcount(stream.channels); + data.setLossless(0); + data.setSamplerate(stream.sample_rate); + data.setNoofsamples(stream.duration_ts); + } + data.setEncodingtype(format.format_long_name); + data.setComment(""); + data.setComposer(""); + data.setVariablebitrate(0); + data.setFile(file.getAbsolutePath()); + data.setLastdir(file.getParentFile().getParent()); + data.setIsdir(file.isDirectory() ? 1 : 0); + if (data.getYear() == null) { + data.setYear("0000"); + } + data.setMd5(Tools.getFileMD5(file)); + } catch (Exception e) { + e.printStackTrace(); + data = new MusicData(); + data.setTitle(file.getName()); + data.setFile(file.getAbsolutePath()); + data.setIsdir(file.isDirectory() ? 1 : 0); + data.setLastdir(file.getParentFile().getParent()); + data.setMd5(Tools.getFileMD5(file)); + } + return data; + } + + private String getTitle(Map tag) { + String title = tag.get("title"); + if (StringUtils.isEmpty(title)) { + title = tag.get("TITLE"); + if (StringUtils.isEmpty(title)) { + title = tag.get("Title"); + } + } + return title; + } + + private String getArtist(Map tag) { + String title = tag.get("artist"); + if (StringUtils.isEmpty(title)) { + title = tag.get("ARTIST"); + if (StringUtils.isEmpty(title)) { + title = tag.get("Artist"); + } + } + return title; + } + + private String getAlbum(Map tag) { + String title = tag.get("album"); + if (StringUtils.isEmpty(title)) { + title = tag.get("ALBUM"); + if (StringUtils.isEmpty(title)) { + title = tag.get("Album"); + } + } + return title; + } + + private String getYear(Map tag) { + String title = tag.get("year"); + if (StringUtils.isEmpty(title)) { + title = tag.get("YEAR"); + if (StringUtils.isEmpty(title)) { + title = tag.get("Year"); + } + } + return title; + } + + @Override public List findOfTitle(String title) { return find(title, FIND_TITLE); } + @Override public List findOfArtist(String by) { return find(by, FIND_ARTIST); } public List getMusicList() { - return musicList; + return musicDataDao.selectByExample(new MusicDataExample()); } + @Override public int getLength() { - return tools.musicList.size(); + return musicDataDao.selectByExample(new MusicDataExample()).size(); } + @Override public boolean isScan() { return isScan; } private List find(String title, int type) { - List list = new ArrayList<>(); - for (MusicData data : musicList) { - if (data.getTitle().contains(title)) { - list.add(data); - } + List list; + MusicDataExample example = new MusicDataExample(); + if (type == FIND_TITLE) { + example.createCriteria().andTitleEqualTo(title); + } else if (type == FIND_ARTIST) { + example.createCriteria().andArtistEqualTo(title); } + list = musicDataDao.selectByExample(example); + return list; } - + @Override public String getMusicPath() { return musicPath; } @@ -378,26 +498,40 @@ public class MusicTools { this.musicPath = musicPath; } - private void saveImage(MusicData data) { - try { - File file = new File(data.getTitle() + ".jpg"); - if (!file.exists()) { - if (!file.createNewFile()) { - return; + @Override + public byte[] readImage(String path) throws Exception { + File file = new File(path); + AudioFile audioFile = null; + audioFile = AudioFileIO.read(file); + Tag tag = audioFile.getTag().or(NullTag.INSTANCE); + byte[] bytes = tag.getFirstArtwork().or(NullArtwork.INSTANCE).getBinaryData(); + if (bytes.length == 0) { + return readImageFile(file); + } + return bytes; + } + + private byte[] readImageFile(File file) throws Exception { + String path = file.getAbsolutePath().replace(file.getName(), ""); + File img = new File(path, "cover.jpg"); + if (!img.exists()) { + img = new File(path, "Cover.jpg"); + if (!img.exists()) { + img = new File(path, "COVER.jpg"); + if (!img.exists()) { + throw new NullPointerException("没有cover文件"); } } - OutputStream outputStream = new FileOutputStream(file); - outputStream.write(data.readImage()); - outputStream.flush(); - outputStream.close(); - } catch (Exception e) { - e.printStackTrace(); } + + return Files.readAllBytes(Paths.get(img.getAbsolutePath())); } public static void main(String[] args) throws Exception { File file = new File("Z:\\音乐\\总之就是非常酸\\ED\\カノエラナ - 月と星空\\カノエラナ.wav"); - System.out.println(new MusicTools().getMetadata(file)); + file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac"); + // file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape"); + System.out.println(new MusicTools().getMetadataOfFFmpeg(file)); } diff --git a/src/main/java/com/yutou/tools/utils/QQBotManager.java b/src/main/java/com/yutou/tools/utils/QQBotManager.java index 36ff6a3..dfa1c67 100644 --- a/src/main/java/com/yutou/tools/utils/QQBotManager.java +++ b/src/main/java/com/yutou/tools/utils/QQBotManager.java @@ -54,8 +54,11 @@ public class QQBotManager { } }); Events.registerEvents(bot, new MessageListener()); + bot.login(); + sendMessage("姬妻酱上线拉~"); bot.join(); + } }).start(); diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java index 04d7e99..b7c2fdb 100644 --- a/src/main/java/com/yutou/tools/utils/Tools.java +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -18,6 +18,8 @@ import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; +import java.security.MessageDigest; +import java.util.Base64; import java.util.Date; import java.util.Random; @@ -334,4 +336,44 @@ public class Tools { headers.add("ETag", String.valueOf(System.currentTimeMillis())); return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file)); } + public static String getFileMD5(File file) { + if (!file.isFile()) { + return null; + } + MessageDigest digest = null; + FileInputStream in = null; + byte buffer[] = new byte[1024]; + int len; + try { + digest = MessageDigest.getInstance("MD5"); + in = new FileInputStream(file); + while ((len = in.read(buffer, 0, 1024)) != -1) { + digest.update(buffer, 0, len); + } + in.close(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return bytesToHexString(digest.digest()); + } + private static String bytesToHexString(byte[] src) { + StringBuilder stringBuilder = new StringBuilder(""); + if (src == null || src.length <= 0) { + return null; + } + for (byte aSrc : src) { + int v = aSrc & 0xFF; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + stringBuilder.append(0); + } + stringBuilder.append(hv); + } + return stringBuilder.toString(); + } + public static String base64ToString(String base){ + base=base.replace(" ","+"); + return new String(Base64.getDecoder().decode(base.replace("\r\n","").getBytes())); + } } diff --git a/src/main/resources/mapper/MusicDataDao.xml b/src/main/resources/mapper/MusicDataDao.xml new file mode 100644 index 0000000..b6438fa --- /dev/null +++ b/src/main/resources/mapper/MusicDataDao.xml @@ -0,0 +1,496 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, artist, album, title, `comment`, `year`, track, disc_no, composer, artist_sort, + `file`, lastDir, isDir, bitRate, sampleRate, noOfSamples, channelCount, encodingType, + durationAsDouble, lossless, variableBitRate, md5 + + + + + delete from music_data + where id = #{id,jdbcType=INTEGER} + + + delete from music_data + + + + + + insert into music_data (artist, album, title, + `comment`, `year`, track, + disc_no, composer, artist_sort, + `file`, lastDir, isDir, + bitRate, sampleRate, noOfSamples, + channelCount, encodingType, durationAsDouble, + lossless, variableBitRate, md5 + ) + values (#{artist,jdbcType=VARCHAR}, #{album,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, + #{comment,jdbcType=VARCHAR}, #{year,jdbcType=VARCHAR}, #{track,jdbcType=VARCHAR}, + #{discNo,jdbcType=VARCHAR}, #{composer,jdbcType=VARCHAR}, #{artistSort,jdbcType=VARCHAR}, + #{file,jdbcType=VARCHAR}, #{lastdir,jdbcType=VARCHAR}, #{isdir,jdbcType=INTEGER}, + #{bitrate,jdbcType=INTEGER}, #{samplerate,jdbcType=INTEGER}, #{noofsamples,jdbcType=BIGINT}, + #{channelcount,jdbcType=INTEGER}, #{encodingtype,jdbcType=VARCHAR}, #{durationasdouble,jdbcType=DOUBLE}, + #{lossless,jdbcType=INTEGER}, #{variablebitrate,jdbcType=INTEGER}, #{md5,jdbcType=VARCHAR} + ) + + + insert into music_data + + + artist, + + + album, + + + title, + + + `comment`, + + + `year`, + + + track, + + + disc_no, + + + composer, + + + artist_sort, + + + `file`, + + + lastDir, + + + isDir, + + + bitRate, + + + sampleRate, + + + noOfSamples, + + + channelCount, + + + encodingType, + + + durationAsDouble, + + + lossless, + + + variableBitRate, + + + md5, + + + + + #{artist,jdbcType=VARCHAR}, + + + #{album,jdbcType=VARCHAR}, + + + #{title,jdbcType=VARCHAR}, + + + #{comment,jdbcType=VARCHAR}, + + + #{year,jdbcType=VARCHAR}, + + + #{track,jdbcType=VARCHAR}, + + + #{discNo,jdbcType=VARCHAR}, + + + #{composer,jdbcType=VARCHAR}, + + + #{artistSort,jdbcType=VARCHAR}, + + + #{file,jdbcType=VARCHAR}, + + + #{lastdir,jdbcType=VARCHAR}, + + + #{isdir,jdbcType=INTEGER}, + + + #{bitrate,jdbcType=INTEGER}, + + + #{samplerate,jdbcType=INTEGER}, + + + #{noofsamples,jdbcType=BIGINT}, + + + #{channelcount,jdbcType=INTEGER}, + + + #{encodingtype,jdbcType=VARCHAR}, + + + #{durationasdouble,jdbcType=DOUBLE}, + + + #{lossless,jdbcType=INTEGER}, + + + #{variablebitrate,jdbcType=INTEGER}, + + + #{md5,jdbcType=VARCHAR}, + + + + + + + + + + + update music_data + + + id = #{record.id,jdbcType=INTEGER}, + + + artist = #{record.artist,jdbcType=VARCHAR}, + + + album = #{record.album,jdbcType=VARCHAR}, + + + title = #{record.title,jdbcType=VARCHAR}, + + + `comment` = #{record.comment,jdbcType=VARCHAR}, + + + `year` = #{record.year,jdbcType=VARCHAR}, + + + track = #{record.track,jdbcType=VARCHAR}, + + + disc_no = #{record.discNo,jdbcType=VARCHAR}, + + + composer = #{record.composer,jdbcType=VARCHAR}, + + + artist_sort = #{record.artistSort,jdbcType=VARCHAR}, + + + `file` = #{record.file,jdbcType=VARCHAR}, + + + lastDir = #{record.lastdir,jdbcType=VARCHAR}, + + + isDir = #{record.isdir,jdbcType=INTEGER}, + + + bitRate = #{record.bitrate,jdbcType=INTEGER}, + + + sampleRate = #{record.samplerate,jdbcType=INTEGER}, + + + noOfSamples = #{record.noofsamples,jdbcType=BIGINT}, + + + channelCount = #{record.channelcount,jdbcType=INTEGER}, + + + encodingType = #{record.encodingtype,jdbcType=VARCHAR}, + + + durationAsDouble = #{record.durationasdouble,jdbcType=DOUBLE}, + + + lossless = #{record.lossless,jdbcType=INTEGER}, + + + variableBitRate = #{record.variablebitrate,jdbcType=INTEGER}, + + + md5 = #{record.md5,jdbcType=VARCHAR}, + + + + + + + + update music_data + set id = #{record.id,jdbcType=INTEGER}, + artist = #{record.artist,jdbcType=VARCHAR}, + album = #{record.album,jdbcType=VARCHAR}, + title = #{record.title,jdbcType=VARCHAR}, + `comment` = #{record.comment,jdbcType=VARCHAR}, + `year` = #{record.year,jdbcType=VARCHAR}, + track = #{record.track,jdbcType=VARCHAR}, + disc_no = #{record.discNo,jdbcType=VARCHAR}, + composer = #{record.composer,jdbcType=VARCHAR}, + artist_sort = #{record.artistSort,jdbcType=VARCHAR}, + `file` = #{record.file,jdbcType=VARCHAR}, + lastDir = #{record.lastdir,jdbcType=VARCHAR}, + isDir = #{record.isdir,jdbcType=INTEGER}, + bitRate = #{record.bitrate,jdbcType=INTEGER}, + sampleRate = #{record.samplerate,jdbcType=INTEGER}, + noOfSamples = #{record.noofsamples,jdbcType=BIGINT}, + channelCount = #{record.channelcount,jdbcType=INTEGER}, + encodingType = #{record.encodingtype,jdbcType=VARCHAR}, + durationAsDouble = #{record.durationasdouble,jdbcType=DOUBLE}, + lossless = #{record.lossless,jdbcType=INTEGER}, + variableBitRate = #{record.variablebitrate,jdbcType=INTEGER}, + md5 = #{record.md5,jdbcType=VARCHAR} + + + + + + update music_data + + + artist = #{artist,jdbcType=VARCHAR}, + + + album = #{album,jdbcType=VARCHAR}, + + + title = #{title,jdbcType=VARCHAR}, + + + `comment` = #{comment,jdbcType=VARCHAR}, + + + `year` = #{year,jdbcType=VARCHAR}, + + + track = #{track,jdbcType=VARCHAR}, + + + disc_no = #{discNo,jdbcType=VARCHAR}, + + + composer = #{composer,jdbcType=VARCHAR}, + + + artist_sort = #{artistSort,jdbcType=VARCHAR}, + + + `file` = #{file,jdbcType=VARCHAR}, + + + lastDir = #{lastdir,jdbcType=VARCHAR}, + + + isDir = #{isdir,jdbcType=INTEGER}, + + + bitRate = #{bitrate,jdbcType=INTEGER}, + + + sampleRate = #{samplerate,jdbcType=INTEGER}, + + + noOfSamples = #{noofsamples,jdbcType=BIGINT}, + + + channelCount = #{channelcount,jdbcType=INTEGER}, + + + encodingType = #{encodingtype,jdbcType=VARCHAR}, + + + durationAsDouble = #{durationasdouble,jdbcType=DOUBLE}, + + + lossless = #{lossless,jdbcType=INTEGER}, + + + variableBitRate = #{variablebitrate,jdbcType=INTEGER}, + + + md5 = #{md5,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update music_data + set artist = #{artist,jdbcType=VARCHAR}, + album = #{album,jdbcType=VARCHAR}, + title = #{title,jdbcType=VARCHAR}, + `comment` = #{comment,jdbcType=VARCHAR}, + `year` = #{year,jdbcType=VARCHAR}, + track = #{track,jdbcType=VARCHAR}, + disc_no = #{discNo,jdbcType=VARCHAR}, + composer = #{composer,jdbcType=VARCHAR}, + artist_sort = #{artistSort,jdbcType=VARCHAR}, + `file` = #{file,jdbcType=VARCHAR}, + lastDir = #{lastdir,jdbcType=VARCHAR}, + isDir = #{isdir,jdbcType=INTEGER}, + bitRate = #{bitrate,jdbcType=INTEGER}, + sampleRate = #{samplerate,jdbcType=INTEGER}, + noOfSamples = #{noofsamples,jdbcType=BIGINT}, + channelCount = #{channelcount,jdbcType=INTEGER}, + encodingType = #{encodingtype,jdbcType=VARCHAR}, + durationAsDouble = #{durationasdouble,jdbcType=DOUBLE}, + lossless = #{lossless,jdbcType=INTEGER}, + variableBitRate = #{variablebitrate,jdbcType=INTEGER}, + md5 = #{md5,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + + TRUNCATE music_data; + + \ No newline at end of file diff --git a/src/main/resources/mapper/MusicFavoritesDao.xml b/src/main/resources/mapper/MusicFavoritesDao.xml new file mode 100644 index 0000000..d49d07d --- /dev/null +++ b/src/main/resources/mapper/MusicFavoritesDao.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, title, musis_md5 + + + + + delete from music_favorites + where id = #{id,jdbcType=INTEGER} + + + delete from music_favorites + + + + + + insert into music_favorites (title, musis_md5) + values (#{title,jdbcType=VARCHAR}, #{musisMd5,jdbcType=VARCHAR}) + + + insert into music_favorites + + + title, + + + musis_md5, + + + + + #{title,jdbcType=VARCHAR}, + + + #{musisMd5,jdbcType=VARCHAR}, + + + + + + update music_favorites + + + id = #{record.id,jdbcType=INTEGER}, + + + title = #{record.title,jdbcType=VARCHAR}, + + + musis_md5 = #{record.musisMd5,jdbcType=VARCHAR}, + + + + + + + + update music_favorites + set id = #{record.id,jdbcType=INTEGER}, + title = #{record.title,jdbcType=VARCHAR}, + musis_md5 = #{record.musisMd5,jdbcType=VARCHAR} + + + + + + update music_favorites + + + title = #{title,jdbcType=VARCHAR}, + + + musis_md5 = #{musisMd5,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update music_favorites + set title = #{title,jdbcType=VARCHAR}, + musis_md5 = #{musisMd5,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/web/html/body/nas/music.html b/web/html/body/nas/music.html index e4bf8f6..ffee3f4 100644 --- a/web/html/body/nas/music.html +++ b/web/html/body/nas/music.html @@ -46,7 +46,7 @@