移除nas、机器人、讯飞等部分,项目完全分离

This commit is contained in:
yutou 2021-04-07 15:30:21 +08:00
parent 95c3f42583
commit fc91057f5b
27 changed files with 18 additions and 2227 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
msc32.dll

Binary file not shown.

BIN
msc64.dll

Binary file not shown.

63
pom.xml
View File

@ -16,7 +16,6 @@
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.4.10</kotlin.version>
</properties>
<repositories>
<repository>
@ -96,77 +95,19 @@
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>net.jthink</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.ealva</groupId>
<artifactId>ealvatag</artifactId>
<version>0.4.3</version>
</dependency>
<dependency>
<groupId>net.mamoe</groupId>
<artifactId>mirai-core-jvm</artifactId>
<version>2.0.0-dev-2</version> <!-- 替换版本为你需要的版本 -->
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.28.0</version>
</dependency>
<dependency>
<groupId>net.bramp.ffmpeg</groupId>
<artifactId>ffmpeg</artifactId>
<version>0.6.2</version>
</dependency>
<dependency>
<groupId>com.iflytek</groupId>
<artifactId>msc</artifactId>
<version>4.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Msc.jar</systemPath>
</dependency>
<dependency>
<groupId>com.iflytek</groupId>
<artifactId>json</artifactId>
<version>4.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/json-jena-1.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

View File

@ -1,22 +1,14 @@
package com.yutou.tools;
import com.yutou.tools.home.nas.MusicController;
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;
@SpringBootApplication
public class ToolsApplication {
public static final String version="1.0.18";
public static final String version="1.1.0";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);
SpringApplication.run(ToolsApplication.class, args);
MusicController.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
RedisTools.initRedisPoolSub();
QQBotManager.getInstance();
}
}

View File

@ -1,330 +0,0 @@
package com.yutou.tools.bangumi;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.utils.HttpTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class BangumiTools {
private static final String url = "http://api.bgm.tv/";
private static final String toDayBangumi = url + "calendar";
private static final String BangumiInfo = url + "/subject/%s?responseGroup=large";
private static final String SearchBangumi = url + "/search/subject/%s?responseGroup=large";
/**
* 获取番剧列表
*
* @param day 周几-1为全部,非1~7范围则为当天
* @return 当日数据
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
JSONArray main = JSONArray.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
return json;
}
if (day < 1 || day > 7) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(new Date());
day = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (day == 0) {
day = 7;
}
}
if (main != null)
for (Object o : main) {
JSONObject json = (JSONObject) o;
if (json.getJSONObject("weekday").getInteger("id") == day) {
return json;
}
}
return null;
}
/**
* 获取番剧详细信息
*
* @param id 剧集id
* @return 详细信息
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
return JSONObject.parseObject(str);
}
/**
* 搜索番剧
*
* @param key 关键词
* @return 详细信息
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, key));
return JSONObject.parseObject(str);
}
/**
* 获取下一集播放日期
*
* @param id 番剧id
* @return 日期
*/
public static String getPlayNextTime(int id) {
JSONObject info = getBangumiInfo(id);
JSONArray eps = info.getJSONArray("eps");
String toDayTime = Tools.getToDayTime();
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
String time = ep.getString("airdate");
try {
if (new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime() >=
new SimpleDateFormat("yyyy-MM-dd").parse(toDayTime).getTime()) {
return time;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 格式化字符串输出番剧详细信息
*
* @param id 番剧id
* @return 详细内容
*/
public static String reportBangumiInfo(int id) {
JSONObject json = getBangumiInfo(id);
if(json.containsKey("code")){
return json.getString("error");
}
JSONArray eps = json.getJSONArray("eps");
JSONArray crts = json.getJSONArray("crt");
JSONArray staffs = json.getJSONArray("staff");
StringBuilder builder = new StringBuilder();
builder.append("<img ").append(json.getJSONObject("images").getString("large")).append(" /img>").append("\n");
builder.append("标题:").append(json.getString("name_cn")).append("\n");
builder.append("日文标题:").append(json.getString("name")).append("\n");
builder.append("首播时间:").append(json.getString("air_date")).append("\n");
builder.append("每周").append(json.getInteger("air_weekday")).append("放送").append("\n");
builder.append("Bangumi地址:").append(json.getString("url")).append("\n");
builder.append("Bangumi评分:").append(json.getJSONObject("rating").getFloat("score")).append("\n");
builder.append("预计放送集数:").append(json.getInteger("eps_count")).append("\n");
if (eps != null) {
builder.append("已放送集:").append("\n");
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
if (ep.getString("status").equals("Air")) {
builder.append("· 第").append(ep.getInteger("sort")).append("话:");
builder.append(ep.getString("name"));
builder.append("[").append(ep.getString("name_cn")).append("]").append("\n");
builder.append("播放日期:").append(ep.getString("airdate")).append(";\n");
builder.append("播放时长:").append(ep.getString("duration")).append(";\n");
builder.append("单集介绍:").append(ep.getString("desc"));
builder.append("\n\n");
} else {
builder.append("下一话:");
builder.append("").append(ep.getInteger("sort")).append("话:");
builder.append("播放日期:").append(ep.getString("airdate")).append("\n\n");
break;
}
}
}
if (crts != null) {
builder.append("角色介绍:").append("\n");
for (Object o : crts) {
JSONObject crt = (JSONObject) o;
JSONObject info = crt.getJSONObject("info");
builder.append(crt.getString("role_name")).append(":");
builder.append(crt.getString("name"));
builder.append("(").append(crt.getString("name_cn")).append(")").append(" ");
builder.append("CV:").append(crt.getJSONArray("actors").getJSONObject(0).getString("name"));
builder.append("(").append(info.getString("gender")).append(")");
builder.append("\n");
}
}
Map<String, List<JSONObject>> map = new HashMap<>();
for (Object o : staffs) {
JSONObject staff = (JSONObject) o;
for (Object jobs : staff.getJSONArray("jobs")) {
String job = (String) jobs;
List<JSONObject> list;
if (!map.containsKey(job)) {
list = new ArrayList<>();
} else {
list = map.get(job);
}
list.add(staff);
map.put(job, list);
}
}
if (!map.isEmpty()) {
builder.append("staff:").append("\n");
for (String key : map.keySet()) {
builder.append(key).append(":");
for (JSONObject staff : map.get(key)) {
builder.append(staff.getString("name_cn"));
builder.append("(").append(staff.getString("name")).append(")");
builder.append("");
}
builder.append("\n");
}
}
return builder.toString();
}
/**
* 格式化输出新番列表
* @return 新番信息
*/
public static String reportBangumiList(){
try {
JSONObject json=getBangumi(-1);
StringBuilder builder=new StringBuilder();
assert json != null;
JSONArray array=json.getJSONArray("bangumi");
for (Object o : array) {
JSONObject data= (JSONObject) o;
JSONObject weekday=data.getJSONObject("weekday");
JSONArray items=data.getJSONArray("items");
builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
builder.append(":").append("\n");
reportBangumi(builder, items,false);
builder.append("\n");
}
return builder.toString();
}catch (Exception e){
e.printStackTrace();
return e.getMessage();
}
}
private static void reportBangumi(StringBuilder builder, JSONArray items,boolean reportEp) {
int epIndex = 0;
String epName = "N/A";
for (Object oj : items) {
JSONObject item = (JSONObject) oj;
builder.append("[").append(item.getInteger("id")).append("]");
builder.append(StringUtils.isEmpty(item.getString("name_cn"))
?item.getString("name"):item.getString("name_cn"));
if(!reportEp){
builder.append("\n");
continue;
}
JSONObject info=getBangumiInfo(item.getInteger("id"));
if(info.get("eps")==null){
continue;
}
JSONArray eps = info.getJSONArray("eps");
for (Object oe : eps) {
JSONObject ep = (JSONObject) oe;
if (ep.getString("status").equals("Air")) {
epIndex = ep.getInteger("sort");
epName = ep.getString("name");
} else {
break;
}
}
builder.append("").append(epIndex).append("话:");
builder.append(epName);
builder.append("\n");
}
}
/**
* 格式化字符串输出今日播放番剧列表
*
* @return 番剧列表
*/
public static String reportToDayBangumi() {
String toDayTime = Tools.getToDayTime();
if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
RedisTools.set("reportToDayBangumi", toDayTime);
StringBuilder builder = new StringBuilder();
JSONObject toDay = getBangumi(0);
if (toDay == null) {
builder.append("今天没有任何番剧放送~");
} else {
JSONObject weekday = toDay.getJSONObject("weekday");
JSONArray items = toDay.getJSONArray("items");
builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
builder.append(" 放送列表:").append("\n");
reportBangumi(builder, items,true);
}
RedisTools.set("toDayBangumi", builder.toString());
return builder.toString();
} else {
return RedisTools.get("toDayBangumi");
}
}
/**
* 格式化字符串输出搜索动画
*
* @param key 关键词
* @return 详细内容
*/
public static String reportSearchBangumi(String key) {
JSONObject main = search(key);
if (main.getInteger("results") > 0) {
StringBuilder builder = new StringBuilder();
List<JSONObject> list = main.getJSONArray("list").toJavaList(JSONObject.class);
Collections.reverse(list);
for (Object items : list) {
JSONObject item = (JSONObject) items;
builder.append("标题:").append(item.getString("name_cn")).append("\n");
builder.append("日文标题:").append(item.getString("name")).append("\n");
String type;
switch (item.getInteger("type")) {
case 1:
type = "书籍";
break;
case 2:
type = "动画";
break;
case 3:
type = "音乐";
break;
case 4:
type = "游戏";
break;
case 6:
type = "真人剧(Real)";
break;
default:
type = item.getInteger("type") + "";
}
builder.append("类型:").append(type).append("\n");
builder.append("id:").append(item.getInteger("id")).append("\n");
if (item.containsKey("rating"))
builder.append("Bangumi评分:").append(item.getJSONObject("rating").getFloat("score")).append("\n");
builder.append("首播时间:").append(item.getString("air_date")).append("\n");
builder.append("每周 ").append(item.getInteger("air_weekday")).append(" 放送").append("\n");
builder.append("放送集数:").append(item.getInteger("eps")).append("\n");
builder.append("Bangumi地址:").append(item.getString("url")).append("\n");
builder.append("介绍:").append(item.getString("summary")).append("\n");
builder.append("\n").append("\n");
}
return builder.toString();
} else {
return "搜索不到任何内容:" + key;
}
}
public static void main(String[] args) {
String str = reportBangumiList();
System.out.println(str);
}
}

View File

@ -1,215 +0,0 @@
package com.yutou.tools.home.nas;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.model.MusicData;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.MusicTools;
import com.yutou.tools.utils.Tools;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
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;
import java.util.Base64;
import java.util.List;
@Controller
@RequestMapping("/nas/music/")
public class MusicController {
public static String defaultMusicPath = "/media/yutou/4t/public/音乐";
@Resource
MusicTools musicTools;
@RequestMapping("all.do")
@ResponseBody
public String getAllMusicList() {
JSONObject json = new JSONObject();
JSONObject data = new JSONObject();
json.put("code", 0);
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(@RequestBody JSONObject body) {
String path = body.getString("path");
boolean type = body.containsKey("type") ? body.getBoolean("type") : false;
System.out.println("接收到地址:" + path);
if (StringUtils.isEmpty(path)
|| path.equals("root")
|| !path.contains(defaultMusicPath)
) {
path = defaultMusicPath;
}
//path=path.replace(defaultMusicPath+File.separator,"");
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("scan", musicTools.isScan());
json.put("size", musicTools.getLength());
json.put("data", JSONArray.toJSON(musicTools.getPath(path, type)));
return json.toJSONString();
}
@ResponseBody
@RequestMapping("getAlbum.do")
public String getAlbum(@RequestBody JSONObject body) {
String album = body.getString("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(@RequestBody JSONObject body) {
String artist = body.getString("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.scanMusic();
json.put("msg", "ok");
json.put("code", 0);
return json.toJSONString();
}
@RequestMapping("find/file.do")
@ResponseBody
public String findFile(@RequestBody JSONObject body) {
String path = body.getString("path");
if (!path.startsWith(defaultMusicPath)) {
path = Tools.base64ToString(path);
}
JSONObject json = new JSONObject();
if (StringUtils.isEmpty(path)) {
json.put("code", -1);
json.put("msg", "地址为空");
return json.toJSONString();
}
json.put("code", 0);
json.put("data", musicTools.getMusicData(path));
return json.toJSONString();
}
@RequestMapping("getlocalhost.do")
@ResponseBody
public String getLocalHost() {
JSONObject json = new JSONObject();
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
json.put("data", "");
} else {
json.put("data", "http://" + UpdateIp.nas_ip);
}
json.put("code", 0);
return json.toJSONString();
}
@RequestMapping(value = "web/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public byte[] getImage(String fileName, String type) {
JSONObject json = new JSONObject();
json.put("fileName", fileName);
if (StringUtils.isEmpty(type)) {
json.put("type", "file");
} else {
json.put("type", type);
}
return getImage(json);
}
@RequestMapping(value = "image.do", produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public byte[] getImage(@RequestBody JSONObject body) {
String fileName = body.getString("fileName");
if (!fileName.startsWith(defaultMusicPath)) {
fileName = Tools.base64ToString(fileName);
}
List<MusicData> list = null;
if (body.getString("type").equals("album")) {
list = musicTools.selectAlbum(fileName);
}
File file;
if (list != null && !list.isEmpty()) {
fileName = list.get(0).getFile();
}
file = new File(fileName);
if (file.exists()) {
try {
return musicTools.readImage(file.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
@RequestMapping("random.do")
@ResponseBody
public String random() {
List<MusicData> 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()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return json.toJSONString();
}
private String getBase64(String str) {
return new String(Base64.getEncoder().encode(str.getBytes()));
}
@RequestMapping("play.do")
public ResponseEntity<FileSystemResource> play(String filePath, String random) {
String _filePath;
boolean _random;
_random = !StringUtils.isEmpty(random) && random.equals("true");
_filePath = Tools.base64ToString(filePath);
if (_random) {
List<MusicData> list = musicTools.getMusicList();
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
_filePath = data.getFile();
}
File file = new File(_filePath);
if (file.exists()) {
return Tools.getFile(file);
} else {
return null;
}
}
}

View File

@ -1,165 +0,0 @@
package com.yutou.tools.home.nas;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.MusicDataDao;
import com.yutou.tools.mybatis.dao.MusicFavoritesDao;
import com.yutou.tools.mybatis.dao.MusicFavoritesDirDao;
import com.yutou.tools.mybatis.model.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
/**
* 收藏夹相关
*/
@Controller
@RequestMapping("/nas/music/favorite/")
public class MusicFavoritesController {
@Resource
MusicFavoritesDao favoritesDao;
@Resource
MusicFavoritesDirDao favoritesDirDao;
@Resource
MusicDataDao musicDataDao;
@RequestMapping("dir/add.do")
@ResponseBody
public String addFavoriteDir(@RequestBody JSONObject body) {
String favorite = body.getString("favorite");
JSONObject json = new JSONObject();
MusicFavoritesDirExample example = new MusicFavoritesDirExample();
example.createCriteria().andTitleEqualTo(favorite);
if (!favoritesDirDao.selectByExample(example).isEmpty()) {
json.put("code", -1);
json.put("msg", "已有该收藏夹");
} else {
MusicFavoritesDir favoritesDir = new MusicFavoritesDir();
favoritesDir.setTitle(favorite);
int ret = favoritesDirDao.insert(favoritesDir);
json.put("code", ret == 0 ? -1 : 0);
json.put("msg", ret == 0 ? "添加失败" : "添加成功");
}
return json.toJSONString();
}
@RequestMapping("dir/list.do")
@ResponseBody
public String getAllFavoriteDir() {
JSONObject json = new JSONObject();
json.put("code", 0);
List<MusicFavoritesDir> list = favoritesDirDao.selectByExample(new MusicFavoritesDirExample());
JSONArray array = new JSONArray();
for (MusicFavoritesDir favoritesDir : list) {
JSONObject data = new JSONObject();
data.put("id", favoritesDir.getId());
data.put("title", favoritesDir.getTitle());
MusicFavoritesExample example = new MusicFavoritesExample();
example.createCriteria().andFavoriteidEqualTo(favoritesDir.getId());
data.put("count", favoritesDao.countByExample(example));
array.add(data);
}
json.put("data", array);
return json.toJSONString();
}
@RequestMapping("dir/rename.do")
@ResponseBody
public String renameFavoriteDir(@RequestBody JSONObject body) {
int id = body.getInteger("id");
String title = body.getString("title");
JSONObject json = new JSONObject();
MusicFavoritesDir favoritesDir = favoritesDirDao.selectByPrimaryKey(id);
if (favoritesDir == null) {
json.put("code", -1);
json.put("msg", "没有该收藏夹");
} else {
favoritesDir.setTitle(title);
favoritesDirDao.updateByPrimaryKey(favoritesDir);
json.put("code", 0);
json.put("msg", "更新成功");
}
return json.toJSONString();
}
@RequestMapping("add.do")
@ResponseBody
public String addFavorite(@RequestBody JSONObject body) {
JSONObject json = new JSONObject();
JSONArray array = body.getJSONArray("md5s");
int fid = body.getInteger("fid");
if (array == null || fid == -1) {
json.put("code", -1);
json.put("msg", "参数异常: " + body);
return json.toJSONString();
}
for (Object md5 : array) {
MusicFavoritesExample example = new MusicFavoritesExample();
example.createCriteria().andMusisMd5EqualTo((String) md5);
if (favoritesDao.countByExample(example) == 0) {
MusicFavorites favorites = new MusicFavorites();
favorites.setMusisMd5((String) md5);
favorites.setFavoriteid(fid);
favorites.setSubTime(new Date());
favoritesDao.insert(favorites);
}
}
json.put("code", 0);
json.put("msg", "添加成功");
return json.toJSONString();
}
@RequestMapping("remove.do")
@ResponseBody
public String removeFavorite(@RequestBody JSONObject body) {
JSONArray md5s = body.getJSONArray("data");
JSONObject json = new JSONObject();
for (Object md5 : md5s) {
LinkedHashMap<String,Object> js= (LinkedHashMap<String, Object>) md5;
MusicFavoritesExample example = new MusicFavoritesExample();
example.createCriteria().andMusisMd5EqualTo((String) js.get("md5"))
.andFavoriteidEqualTo((Integer) js.get("fid"));
favoritesDao.deleteByExample(example);
}
json.put("code", 0);
json.put("msg", "已从收藏夹中移除");
return json.toJSONString();
}
@RequestMapping("get.do")
@ResponseBody
public String getFavorite(@RequestBody JSONObject body) {
int fid = body.getInteger("fid");
JSONObject json = new JSONObject();
try {
MusicFavoritesExample example = new MusicFavoritesExample();
example.createCriteria().andFavoriteidEqualTo(fid);
List<MusicFavorites> list = favoritesDao.selectByExample(example);
List<MusicData> dataList = new ArrayList<>();
for (MusicFavorites favorites : list) {
MusicDataExample dataExample = new MusicDataExample();
dataExample.createCriteria().andMd5EqualTo(favorites.getMusisMd5());
try {
dataList.add(musicDataDao.selectByExample(dataExample).get(0));
} catch (Exception ignored) {
}
}
list.clear();
json.put("code", 0);
json.put("data", JSONArray.toJSON(dataList));
} catch (Exception e) {
e.printStackTrace();
json.put("code", -1);
json.put("msg", e.getLocalizedMessage());
json.put("data", new ArrayList<>());
}
return json.toJSONString();
}
}

View File

@ -1,84 +0,0 @@
package com.yutou.tools.home.nas;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.utils.OSSTools;
import com.yutou.tools.utils.QQBotManager;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.Jedis;
import java.io.File;
import java.util.Base64;
import java.util.UUID;
@Controller
@RequestMapping("/qq/bot")
public class QQBot {
@RequestMapping("test.do")
@ResponseBody
public String test(){
return "123";
}
@RequestMapping("send.do")
@ResponseBody
public String send(String msg,String imgUrl){
JSONObject json=new JSONObject();
try {
String ret;
if(StringUtils.isEmpty(imgUrl)){
ret= QQBotManager.getInstance().sendMessage(msg);
}else{
Tools.download(imgUrl, new DownloadInterface() {
@Override
public void onDownload(String file) {
super.onDownload(file);
QQBotManager.getInstance().sendMessage(new File(file),msg);
}
@Override
public void onError(Exception e) {
super.onError(e);
QQBotManager.getInstance().sendMessage(imgUrl+"\n"+msg);
}
});
ret="图片下载中";
}
json.put("code",0);
json.put("msg",ret);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@RequestMapping("sendAndImg.do")
@ResponseBody
public String botMsg(String msg,@RequestParam("file") MultipartFile file){
JSONObject json=new JSONObject();
if(file==null){
json.put("code",-1);
json.put("msg","图片为空");
return json.toJSONString();
}
String ret;
try {
String path = Tools.createFile("qq_image",file, file.getName());
ret=QQBotManager.getInstance().sendMessage(new File(path),msg);
} catch (Exception e) {
e.printStackTrace();
ret=e.getLocalizedMessage();
}
json.put("code",0);
json.put("msg",ret);
return json.toJSONString();
}
}

View File

@ -1,45 +0,0 @@
package com.yutou.tools.home.nas;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.utils.HttpTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
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 javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@Controller
public class ToolsController {
@ResponseBody
@RequestMapping("/tools/openpc.do")
public String open_pc(HttpServletRequest request, String type) {
if (StringUtils.isEmpty(type)) {
if (Tools.checkWebLogin(request) == 1) {
HttpTools.get("http://" + UpdateIp.nas_ip + ":8000/tools/openpc.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor&type=nas");
}
} else {
if (type.equals("nas")) {
try {
Process process = Runtime.getRuntime().exec("wakeonlan 00:D8:61:6F:02:2F");
RedisTools.processOut(process.getInputStream());
RedisTools.processOut(process.getErrorStream());
process.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return "ok";
}
@ResponseBody
@RequestMapping("/tools/server.do")
public String sendServerManager(String title, String msg) {
Tools.sendServer(title, msg);
return "ok";
}
}

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.NasAdminAddressDao;
import com.yutou.tools.mybatis.model.NasAdminAddress;
import com.yutou.tools.mybatis.model.NasAdminAddressExample;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
@ -16,7 +17,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Controller
@ -154,4 +154,13 @@ public class NasManager {
e.printStackTrace();
}
}
@RequestMapping("/nas/music/getlocalhost.do")
@ResponseBody
public String getLocalHost() {
JSONObject json = new JSONObject();
json.put("data", "http://" + UpdateIp.nas_ip);
json.put("code", 0);
return json.toJSONString();
}
}

View File

@ -1,15 +1,12 @@
package com.yutou.tools.nas;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.File;

View File

@ -1,9 +0,0 @@
package com.yutou.tools.other;
import com.yutou.tools.utils.AudioTools;
public class QQAudio {
public static void playText(String text){
AudioTools.playText(text);
}
}

View File

@ -1,202 +0,0 @@
package com.yutou.tools.other;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.utils.QQBotManager;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import net.mamoe.mirai.event.events.GroupMessageEvent;
import net.mamoe.mirai.message.data.At;
import net.mamoe.mirai.message.data.Image;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
public class QQSetu {
public static void printTodaySetu() {
String redisKey=Tools.getToDayTime() + "_setu";
System.out.println("redisKey = " + redisKey);
String js = RedisTools.get(redisKey, 1);
if (js != null) {
JSONObject json = JSONObject.parseObject(js);
if(json.containsKey("isPrint")&&json.getBoolean("isPrint")){
return;
}
Map<String,Float> groupAverage=new HashMap<>();
Map<String,String> groupImage=new HashMap<>();
JSONObject setu=null;
for (String id : json.keySet()) {
String group=json.getJSONObject(id).getJSONObject("info").getLong("group")+"";
if(groupAverage.containsKey(group)){
if(groupAverage.get(group)<=json.getJSONObject(id).getFloat("average")){
groupAverage.put(group,json.getJSONObject(id).getFloat("average"));
groupImage.put(group,id);
}
}else{
groupAverage.put(group,json.getJSONObject(id).getFloat("average"));
groupImage.put(group,id);
}
}
for (String id : groupImage.keySet()) {
setu=json.getJSONObject(groupImage.get(id));
if(setu!=null){
json.put("isPrint",true);
RedisTools.set(1,redisKey,json.toJSONString());
JSONObject info=setu.getJSONObject("info");
JSONObject score=setu.getJSONObject("score");
MessageChainBuilder builder = new MessageChainBuilder();
builder.append(Image.fromId(info.getString("id")));
builder.append("本日最佳涩图由").append(new At(info.getLong("sourQQ"))).append("提供\n");
builder.append("获得分数 ").append(String.valueOf(setu.getFloat("average"))).append("\n");
builder.append("共有 ").append(String.valueOf(score.getIntValue("userNumber"))).append(" 人参与投票");
QQBotManager.getInstance().sendMessage(info.getLong("group"),builder);
}
}
}
}
private boolean isSetu(Image image) {
String url = Image.queryUrl(image);
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
int length = connection.getContentLength();
connection.disconnect();
if (length > 50000) {
return true;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return false;
}
private void setuBuilder(Image image, GroupMessageEvent event) {
if (!isSetu(image)) {
return;
}
if (RedisTools.get(event.getGroup().getId()+"setu") != null) {
printSetu(event.getGroup().getId());
}
setuScore.clear();
JSONObject json = new JSONObject();
json.put("id", image.getImageId());
json.put("sourName", event.getSenderName());
json.put("sourQQ", event.getSender().getId());
json.put("group", event.getGroup().getId());
RedisTools.set(event.getGroup().getId()+"setu", json.toJSONString(),6*60);
if (timer != null) {
timer.cancel();
timer = null;
}
startTimer(event.getGroup().getId());
}
private void startTimer(long group) {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if(!setuScore.isEmpty()){
printSetu(group);
}
timer = null;
}
}, 5 * 60 * 1000);
}
private void printSetu(long group) {
JSONObject jt = JSONObject.parseObject(RedisTools.get(group+"setu"));
String id = jt.getString("id");
float average = 0;
float max = 0;
float min = 10;
float length = 0;
String maxName = "";
String minName = "";
if(setuScore.size()<=1){
return;
}
for (String name : setuScore.keySet()) {
length += setuScore.get(name);
average += setuScore.get(name);
if (setuScore.get(name) > max) {
max = setuScore.get(name);
maxName = name.split("\\|")[0];
}
if (setuScore.get(name) < min) {
min = setuScore.get(name);
minName = name.split("\\|")[0];
}
}
JSONObject score = new JSONObject();
score.put("max", max);
score.put("min", min);
score.put("sum", length);
score.put("maxName", maxName);
score.put("minName", minName);
score.put("userNumber", setuScore.size());
average = average / setuScore.size();
String builder = "涩图评分:" + average +"\n "+
"其中最高分由:" + maxName + " 给与:" + max +"\n "+
"其中最低分由:" + minName + " 给与:" + min;
QQBotManager.getInstance().sendMessage(group, builder);
String st = RedisTools.get(Tools.getToDayTime() + "_setu", 1);
JSONObject json;
if (st == null) {
json = new JSONObject();
} else {
json = JSONObject.parseObject(st);
}
if (!json.containsKey(id)) {
JSONObject item;
if (json.containsKey("item")) {
item = json.getJSONObject("item");
} else {
item = new JSONObject();
}
item.put("score", score);
item.put("info", jt);
item.put("average", average);
json.put(id, item);
RedisTools.set(1, Tools.getToDayTime() + "_setu", json.toJSONString());
}
RedisTools.remove(group+"setu",0);
setuScore.clear();
}
public void setu(String msg, GroupMessageEvent event) {
if (msg.trim().equals("[图片]")) {
Image image = (Image) event.getMessage().stream().filter(Image.class::isInstance).findFirst().orElse(null);
if (image != null) {
setuBuilder(image, event);
return;
}
}
try {
if(msg.trim().length()>3){
return;
}
float i = Float.parseFloat(msg.trim());
if (i > 0 && i <= 10) {
String name = event.getSenderName();
String qq=event.getSender().getId()+"";
if (!setuScore.containsKey(name)) {
setuScore.put(name+"|"+qq, i);
}
}
} catch (Exception ignored) {
}
}
private Timer timer;
private static Map<String, Float> setuScore = new HashMap<>();
}

View File

@ -6,13 +6,11 @@ import com.yutou.tools.ToolsApplication;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey;
import com.yutou.tools.mybatis.model.UKeyExample;
import com.yutou.tools.utils.QQBotManager;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;

View File

@ -1,11 +1,9 @@
package com.yutou.tools.utils;
import com.yutou.tools.other.QQSetu;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
@ -16,25 +14,20 @@ import java.util.TimerTask;
*/
@Component
public class ApplicationInit implements ApplicationRunner {
@Resource
MusicTools musicTools;
@Override
public void run(ApplicationArguments args) throws Exception {
AudioTools.init();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
String time = new SimpleDateFormat("HH:mm").format(new Date());
switch (time){
case "00:00":
musicTools.scanMusic();
break;
case "08:00":
case "20:00":
QQBotManager.getInstance().reportToDayBangumi();
break;
case "23:59":
QQSetu.printTodaySetu();
break;
}

View File

@ -1,66 +0,0 @@
package com.yutou.tools.utils;
import com.iflytek.cloud.speech.*;
public class AudioTools {
private static boolean init = false;
synchronized static void init() {
if (init) {
return;
}
SpeechUtility.createUtility(SpeechConstant.APPID + "=601f7f7d");
SpeechUtility.getUtility().setParameter(SpeechConstant.VOLUME,"100");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_64,"/media/yutou/4t/public/servier/tools/");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_32,"/media/yutou/4t/public/servier/tools/");
init = true;
System.out.println("讯飞语音已初始化");
}
public static void playText(String text) {
SpeechSynthesizer mss = SpeechSynthesizer.createSynthesizer();
mss.startSpeaking(text, new SynthesizerListener() {
@Override
public void onBufferProgress(int progress, int beginPos, int endPos,
String info) {
if (progress == 100) {
mss.destroy();
}
}
@Override
public void onSpeakBegin() {
}
@Override
public void onSpeakProgress(int i, int i1, int i2) {
}
@Override
public void onSpeakPaused() {
}
@Override
public void onSpeakResumed() {
}
@Override
public void onCompleted(SpeechError speechError) {
System.out.println(speechError.getErrorDesc() + " code " + speechError.getErrorCode());
}
@Override
public void onEvent(int i, int i1, int i2, int i3, Object o, Object o1) {
}
});
}
public static void main(String[] args) {
init();
playText("小爱同学,开灯");
}
}

View File

@ -1,9 +1,7 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.utils.Interfaces.NetworkInterface;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
@ -13,9 +11,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class HttpTools {
public static String get(String url) {

View File

@ -1,541 +0,0 @@
package com.yutou.tools.utils;
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;
import ealvatag.audio.exceptions.CannotReadException;
import ealvatag.tag.FieldKey;
import ealvatag.tag.NullTag;
import ealvatag.tag.Tag;
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 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.*;
@Service("musicToolsService")
public class MusicTools implements MusicToolsService {
public static final int FIND_TITLE = 1;
public static final int FIND_ARTIST = 2;
private String musicPath = "/media/yutou/4t/public/音乐";
private boolean isScan = false;
@Resource
MusicDataDao musicDataDao;
private MusicTools() {
}
@Override
public void init() {
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
scanMusic();
}
@Override
public void scanMusic() {
if (isScan) {
return;
}
if(ConfigTools.load(ConfigTools.CONFIG,"musicScan").equals("false")){
return;
}
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();
}
private void scan(File path) {
if (path.isFile()) {
add(path);
} else if (path.isDirectory()) {
for (File file : Objects.requireNonNull(path.listFiles())) {
if (file.isDirectory()) {
scan(file);
} else {
add(file);
}
}
}
}
public void getPathOrDir(String path, List<MusicData> list) {
File files = new File(path);
for (File file : files.listFiles()) {
if (file.isFile()) {
list.add(getMetadata(file));
} else {
getPathOrDir(file.getAbsolutePath(), list);
}
}
}
/**
* 获取指定目录下的音乐
*
* @param path 指定目录
* @param isDir 是否扫描目录下的所有文件false则仅为当前目录
* @return 音乐列表
*/
@Override
public List<MusicData> getPath(String path, boolean isDir) {
List<MusicData> list = new ArrayList<>();
List<MusicData> main=new ArrayList<>();
MusicDataExample example = new MusicDataExample();
String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/";
String tmpPath=path;
if (isDir) {
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%");
main = musicDataDao.selectByExample(example);
}
tmpPath=tmpPath.replace(File.separator, replacement)
.replace("[","\\[")
.replace("(","\\(")
.replace(")","\\)")
.replace("]","\\]");
main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$"));
if (!path.equals(MusicController.defaultMusicPath) && !path.equals("root")) {
MusicData t2 = new MusicData();
t2.setTitle("返回");
if(main.isEmpty()){
t2.setFile("root");
}else {
MusicData tmp = main.get(0);
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
}
System.out.println("查询地址:"+path+" 设置返回地址:"+t2.getFile());
t2.setIsdir(1);
list.add(t2);
}
getDirList(path, list);
list.addAll(main);
return list;
}
public List<String> getAllAlbum() {
return musicDataDao.selectAllAlbum();
}
public List<String> getAllArtist() {
return musicDataDao.selectAllArtist();
}
public List<MusicData> selectAlbum(String album) {
return musicDataDao.selectAlbum(album);
}
public List<MusicData> selectArtist(String artist) {
return musicDataDao.selectArtist(artist);
}
private void getDirList(String path, List<MusicData> list) {
File file = new File(path);
for (File listFile : file.listFiles()) {
if (listFile.isDirectory()) {
MusicData data = new MusicData();
data.setTitle(listFile.getName());
data.setIsdir(1);
data.setFile(listFile.getAbsolutePath());
list.add(data);
}
}
}
private void add(File file) {
MusicData data = getMetadata(file);
if (data != null) {
try {
musicDataDao.insert(data);
} catch (Exception e) {
e.printStackTrace();
QQBotManager.getInstance().sendMessage("音乐文件添加失败:" + data.toString());
}
}
}
@Override
public MusicData getMusicData(String path) {
MusicDataExample example = new MusicDataExample();
example.createCriteria().andFileEqualTo(path);
List<MusicData> 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")
|| file.getName().endsWith(".jpg")
|| file.getName().endsWith(".ini")
|| file.getName().endsWith(".png")
|| file.getName().endsWith(".torrent")
|| file.getName().endsWith(".log")
|| file.getName().endsWith(".mkv")
|| file.getName().endsWith(".dff")
|| file.getName().endsWith(".cue")
|| file.getName().endsWith(".m3u")
) {
return null;
}
AudioFile audioFile = AudioFileIO.read(file);
Tag tag = audioFile.getTag().or(NullTag.INSTANCE);
MusicData data = new MusicData();
try {
data.setAlbum(tag.getFirst(FieldKey.ALBUM));
} catch (Exception e) {
}
try {
data.setArtist(tag.getFirst(FieldKey.ARTIST));
} catch (Exception e) {
}
try {
data.setArtistSort(tag.getFirst(FieldKey.ARTIST_SORT));
} catch (Exception e) {
}
try {
data.setComment(tag.getFirst(FieldKey.COMMENT));
} catch (Exception e) {
}
try {
data.setComposer(tag.getFirst(FieldKey.COMPOSER));
} catch (Exception e) {
}
try {
data.setDiscNo(tag.getFirst(FieldKey.DISC_NO));
} catch (Exception e) {
}
try {
if (StringUtils.isEmpty(tag.getFirst(FieldKey.TITLE))) {
data.setTitle(file.getName());
} else {
data.setTitle(tag.getFirst(FieldKey.TITLE));
}
} catch (Exception e) {
data.setTitle(file.getName());
}
try {
data.setTrack(tag.getFirst(FieldKey.TRACK));
} catch (Exception e) {
}
try {
data.setYear(tag.getFirst(FieldKey.YEAR));
} catch (Exception e) {
}
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() ? 1 : 0);
data.setVariablebitrate(header.isVariableBitRate() ? 1 : 0);
try {
data.setMd5(header.getClass().getMethod("getMd5").invoke(header).toString());
} catch (Exception ignored) {
data.setMd5(Tools.getFileMD5(file));
}
return data;
} catch (CannotReadException e) {
return getMetadata_jthink(file);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public MusicData getMetadata_jthink(File file) {
try {
org.jaudiotagger.audio.AudioFile audioFile = org.jaudiotagger.audio.AudioFileIO.read(file);
org.jaudiotagger.tag.Tag tag = audioFile.getTag();
MusicData data = new MusicData();
try {
data.setAlbum(tag.getFirst(org.jaudiotagger.tag.FieldKey.ALBUM));
} catch (Exception ignored) {
}
try {
data.setArtist(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST));
} catch (Exception ignored) {
}
try {
data.setArtistSort(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST_SORT));
} catch (Exception ignored) {
}
try {
data.setComment(tag.getFirst(org.jaudiotagger.tag.FieldKey.COMMENT));
} catch (Exception ignored) {
}
try {
data.setComposer(tag.getFirst(org.jaudiotagger.tag.FieldKey.COMPOSER));
} catch (Exception ignored) {
}
try {
data.setDiscNo(tag.getFirst(org.jaudiotagger.tag.FieldKey.DISC_NO));
} catch (Exception ignored) {
}
try {
if (StringUtils.isEmpty(tag.getFirst(org.jaudiotagger.tag.FieldKey.TITLE))) {
data.setTitle(file.getName());
} else {
data.setTitle(tag.getFirst(org.jaudiotagger.tag.FieldKey.TITLE));
}
} catch (Exception e) {
data.setTitle(file.getName());
}
try {
data.setTrack(tag.getFirst(org.jaudiotagger.tag.FieldKey.TRACK));
} catch (Exception ignored) {
}
try {
data.setYear(tag.getFirst(org.jaudiotagger.tag.FieldKey.YEAR));
} catch (Exception ignored) {
}
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(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(Tools.getFileMD5(file));
}
return data;
} catch (Exception e) {
return getMetadataOfFFmpeg(file);
}
}
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<String, String> 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));
QQBotManager.getInstance().sendMessage("添加音乐文件失败:\n"+data.toString()+"\n"+Tools.getExceptionString(e));
}
return data;
}
private String getTitle(Map<String, String> 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<String, String> 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<String, String> 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<String, String> 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<MusicData> findOfTitle(String title) {
return find(title, FIND_TITLE);
}
@Override
public List<MusicData> findOfArtist(String by) {
return find(by, FIND_ARTIST);
}
public List<MusicData> getMusicList() {
return musicDataDao.selectByExample(new MusicDataExample());
}
@Override
public int getLength() {
return musicDataDao.selectByExample(new MusicDataExample()).size();
}
@Override
public boolean isScan() {
return isScan;
}
private List<MusicData> find(String title, int type) {
List<MusicData> 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;
}
public void setMusicPath(String musicPath) {
this.musicPath = musicPath;
}
@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文件");
}
}
}
return Files.readAllBytes(Paths.get(img.getAbsolutePath()));
}
public static void main(String[] args) throws Exception {
File file = new File("Z:\\音乐\\总之就是非常酸\\ED\\カノエラナ - 月と星空\\カノエラナ.wav");
file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac");
// file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape");
System.out.println(new MusicTools().getMetadataOfFFmpeg(file));
}
}

View File

@ -1,340 +0,0 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.ToolsApplication;
import com.yutou.tools.bangumi.BangumiTools;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.other.QQAudio;
import com.yutou.tools.other.QQSetu;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.BotFactory;
import net.mamoe.mirai.event.GlobalEventChannel;
import net.mamoe.mirai.event.events.GroupMessageEvent;
import net.mamoe.mirai.message.data.Image;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import net.mamoe.mirai.utils.BotConfiguration;
import net.mamoe.mirai.utils.ExternalResource;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class QQBotManager {
private static class QQCommands {
private final static String QQ_HELP = "!help";
private final static String QQ_UPDATE_IP = "!更新ip";
private final static String QQ_GET_IP = "!ip";
private final static String QQ_OPEN_PC = "!开机";
private final static String QQ_GET_VERSION = "!version";
private final static String QQ_CMD = "!cmd";
private final static String QQ_BANGUMI_TODAY = "!今日动画";
private final static String QQ_BANGUMI_LIST = "!新番";
private final static String QQ_BANGUMI_SUB = "!查动画";
private final static String QQ_AUDIO = "!语音";
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
}
private static QQBotManager botManager = null;
private Bot bot;
private static final long qqGroup = 891655174L;
private boolean isLogin = false;
private static boolean isInit = false;
private QQBotManager() {
Object isRun = ConfigTools.load(ConfigTools.CONFIG, "qq_bot");
if (isRun != null && (boolean) isRun) {
isLogin = true;
isInit = true;
init();
}
}
private void init() {
new Thread(new Runnable() {
@Override
public void run() {
long qq = 2476945931L;
String password = "zhang34864394";
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
qq = 3620756944L;
password = "UAs6YBYMyxJU";
}
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
{
setProtocol(MiraiProtocol.ANDROID_PAD);
fileBasedDeviceInfo("qq_bot_devices_info.json");
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
noBotLog();
noNetworkLog();
}
}
});
//Events.registerEvents(bot, new MessageListener());
GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessageEvent.class, new MessageListener());
bot.login();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String str = sendMessage("姬妻酱上线拉~");
System.out.println(str);
}
}).start();
bot.join();
}
}).start();
}
public static QQBotManager getInstance() {
if (botManager == null && !isInit) {
botManager = new QQBotManager();
}
return botManager;
}
public boolean isLogin() {
return isLogin;
}
private Image getImage(File file) {
if (bot != null) {
return Objects.requireNonNull(bot.getGroup(qqGroup)).uploadImage(ExternalResource.create(file));
}
return null;
}
private String getNotLoginQQ() {
return "没有登录QQ";
}
public void reportToDayBangumi() {
getInstance().sendMessage(BangumiTools.reportToDayBangumi());
}
public String sendMessage(String text) {
if (bot != null) {
try {
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(text).toString();
} catch (Exception e) {
e.printStackTrace();
}
}
return getNotLoginQQ();
}
public String sendMessage(Long group, String text) {
if (bot != null) {
try {
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(text).toString();
} catch (Exception e) {
e.printStackTrace();
}
}
return getNotLoginQQ();
}
public void sendMessage(Long group, MessageChainBuilder builder) {
if (bot != null) {
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
}
}
public String sendMessage(File imageFile, String text) {
try {
if (bot != null) {
Image image = getImage(imageFile);
MessageChainBuilder builder = new MessageChainBuilder();
if (image != null) {
builder.append(image);
}
builder.append(text);
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(builder.asMessageChain()).toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return getNotLoginQQ();
}
public String sendMessage(List<File> imgs, String text) {
if (bot != null) {
MessageChainBuilder builder = new MessageChainBuilder();
for (File img : imgs) {
builder.append(Objects.requireNonNull(getImage(img)));
}
builder.append(text);
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(builder.asMessageChain()).toString();
}
return getNotLoginQQ();
}
public static List<String> getImages(String str) {
List<String> list = new ArrayList<>();
String regex = "<img(.*?)/img>";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
list.add(matcher.group().replace("<img", "")
.replace("/img>", "")
.trim());
}
return list;
}
public static void main(String[] args) {
getInstance();
}
private static class MessageListener implements Consumer<GroupMessageEvent> {
@Override
public void accept(GroupMessageEvent event) {
String msg = event.getMessage().contentToString();
switch (event.getGroup().getId() + "") {
case qqGroup + "":
myGroup(msg);
case "570197155":
new QQSetu().setu(msg, event);
}
}
private void myGroup(String msg) {
msg = msg.replace("", "!").toLowerCase();
switch (msg) {
case QQCommands.QQ_OPEN_PC:
RedisTools.Consumer.system("openPC", null);
String time = new SimpleDateFormat("HH").format(new Date());
if (Integer.parseInt(time) < 18) {
break;
}
case QQCommands.QQ_AUDIO_OPEN_LAMP:
QQAudio.playText("小爱同学,开灯");
break;
case QQCommands.QQ_AUDIO_OPEN_AIR:
QQAudio.playText("小爱同学,开空调");
break;
case QQCommands.QQ_UPDATE_IP:
RedisTools.Consumer.system("updateIP", null);
break;
case QQCommands.QQ_GET_IP:
RedisTools.Consumer.bot("getip");
break;
case QQCommands.QQ_GET_VERSION:
sendVersion();
break;
case QQCommands.QQ_BANGUMI_TODAY:
QQBotManager.getInstance().sendMessage(BangumiTools.reportToDayBangumi());
break;
case QQCommands.QQ_BANGUMI_LIST:
getInstance().sendMessage("获取中...");
getInstance().sendMessage(BangumiTools.reportBangumiList());
break;
case QQCommands.QQ_HELP:
StringBuilder builder = new StringBuilder();
for (Field field : QQCommands.class.getDeclaredFields()) {
try {
field.setAccessible(true);
builder.append(field.get(null)).append("\n");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
getInstance().sendMessage(builder.toString());
break;
default:
if (msg.startsWith(QQCommands.QQ_CMD)) {
RedisTools.Consumer.system("cmd", msg.replace(QQCommands.QQ_CMD, ""));
} else if (msg.startsWith(QQCommands.QQ_BANGUMI_SUB)) {
String info = null;
try {
int id = Integer.parseInt(msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim());
info = BangumiTools.reportBangumiInfo(id);
} catch (Exception e) {
String key = msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim();
info = BangumiTools.reportSearchBangumi(key);
}
List<String> imgs = new ArrayList<>();
if (info.contains("<img") && info.contains(" /img>")) {
imgs = getImages(info);
for (String img : imgs) {
info = info.replace("<img " + img + " /img>", "");
}
}
sendImagesMsg(imgs, info);
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
}
}
}
private List<File> files;
private int index = 0;
private void sendImagesMsg(List<String> imgs, String text) {
files = new ArrayList<>();
index = 0;
if (imgs.size() == 0) {
getInstance().sendMessage(text);
return;
}
for (String img : imgs) {
Tools.download(img, new DownloadInterface() {
@Override
public void onDownload(String file) {
super.onDownload(file);
files.add(new File(file));
send(imgs.size(), text);
}
@Override
public void onError(Exception e) {
super.onError(e);
index++;
send(imgs.size(), text);
}
});
}
}
private void send(int size, String text) {
if ((files.size() + index) == size) {
String str = getInstance().sendMessage(files, text);
System.out.println("str = " + str);
}
}
private void sendVersion() {
String localVersion = ToolsApplication.version;
String serverVersion = HttpTools.get("http://tools.yutou233.cn:8000/public/version.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor");
String msg = "本地版本:" + localVersion + "\n" + "服务器版本:" + serverVersion;
QQBotManager.getInstance().sendMessage(msg);
Tools.sendServer("服务版本查询", msg);
}
}
}

View File

@ -1,100 +0,0 @@
package com.yutou.tools.utils;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
public class RedisConfig extends CachingConfigurerSupport {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值默认使用JDK的序列化方式
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}

View File

@ -269,7 +269,6 @@ public class RedisTools {
case "getip":
JSONObject json = JSONObject.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
String ip = json.getString("ip");
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
break;
}
}
@ -289,7 +288,6 @@ public class RedisTools {
e.printStackTrace();
}
System.out.println("cmd > " + str);
QQBotManager.getInstance().sendMessage(str.toString());
System.out.println("线程结束");
}
public static void main(String[] args) {

View File

@ -94,39 +94,7 @@ public class Tools {
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
("title="+URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8),
null);
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
String img = null;
msg = msg.replace("<br/>", "\n");
if (msg.contains("![logo]")) {
try {
img = msg.split("!\\[logo\\]\\(")[1].split("\\)")[0];
msg = msg.replace("![logo](" + img + ")", "");
} catch (Exception e) {
e.printStackTrace();
}
}
if (img == null) {
QQBotManager.getInstance().sendMessage(title + "\n" + msg);
} else {
String finalMsg = msg;
String finalImg = img;
if (QQBotManager.getInstance().isLogin()) {
download(img, new DownloadInterface() {
@Override
public void onDownload(String file) {
super.onDownload(file);
QQBotManager.getInstance().sendMessage(new File(file), title + "\n" + finalMsg);
}
@Override
public void onError(Exception e) {
super.onError(e);
QQBotManager.getInstance().sendMessage(title + "\n" + finalMsg + "\n" + finalImg);
}
});
}
}
} else if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
String img = null;
msg = msg.replace("<br/>", "\n");
if (msg.contains("![logo]")) {

View File

@ -1,6 +1,5 @@
package com.yutou.tools.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.Tools.GoogleAccount;
@ -13,13 +12,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.UUID;
@Controller