├── .gitignore ├── README.md ├── music.sql ├── musicClient ├── .gitignore ├── .vscode │ └── extensions.json ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ └── vite.svg ├── src │ ├── App.vue │ ├── api │ │ ├── api.js │ │ ├── axios.js │ │ ├── request.js │ │ └── status.js │ ├── assets │ │ ├── logo.svg │ │ └── vue.svg │ ├── components │ │ ├── core │ │ │ ├── comment │ │ │ │ └── commentView.vue │ │ │ ├── login │ │ │ │ └── index.vue │ │ │ └── player │ │ │ │ ├── index.vue │ │ │ │ └── playList.vue │ │ └── edit │ │ │ └── userEditView.vue │ ├── layout │ │ ├── index.vue │ │ ├── mainView │ │ │ ├── index.vue │ │ │ ├── mainCenter │ │ │ │ ├── index.vue │ │ │ │ └── recommendView │ │ │ │ │ └── recommendView.vue │ │ │ └── navBar │ │ │ │ ├── index.vue │ │ │ │ ├── rankingList.vue │ │ │ │ ├── recentlyPlayed.vue │ │ │ │ ├── searchList.vue │ │ │ │ └── userSongList.vue │ │ └── sideBar │ │ │ └── sideBar.vue │ ├── main.js │ ├── router │ │ └── index.js │ ├── store │ │ ├── index.ts │ │ ├── searchDataInfo.ts │ │ ├── userDataInfo.ts │ │ └── userPlayInfo.ts │ ├── style.css │ └── utils │ │ └── audioToImage.js ├── tailwind.config.js ├── vite.config.js └── yarn.lock ├── musicManage ├── .gitignore ├── .vscode │ └── extensions.json ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ ├── icon.ico │ └── vite.svg ├── src │ ├── App.vue │ ├── api │ │ ├── api.js │ │ ├── axios.js │ │ ├── request.js │ │ └── status.js │ ├── assets │ │ ├── css │ │ │ └── base.less │ │ ├── images │ │ │ ├── audio.svg │ │ │ ├── audio │ │ │ │ ├── align-justify.svg │ │ │ │ ├── backward-step.svg │ │ │ │ ├── forward-step.svg │ │ │ │ ├── pause.svg │ │ │ │ └── play.svg │ │ │ ├── logo.png │ │ │ └── userLogo.png │ │ ├── utils │ │ │ └── dateUtils.js │ │ └── vue.svg │ ├── components │ │ ├── basic │ │ │ └── APlayer.vue │ │ └── core │ │ │ └── Login.vue │ ├── layout │ │ ├── content │ │ │ ├── index.vue │ │ │ ├── tab01 │ │ │ │ ├── charts │ │ │ │ │ ├── chartFive.vue │ │ │ │ │ ├── chartFour.vue │ │ │ │ │ ├── chartOne.vue │ │ │ │ │ ├── chartSix.vue │ │ │ │ │ ├── chartThree.vue │ │ │ │ │ └── chartTwo.vue │ │ │ │ ├── infoView.vue │ │ │ │ └── tables │ │ │ │ │ ├── tableFour.vue │ │ │ │ │ ├── tableOne.vue │ │ │ │ │ ├── tableThree.vue │ │ │ │ │ └── tableTwo.vue │ │ │ ├── tab02 │ │ │ │ └── userView.vue │ │ │ ├── tab03 │ │ │ │ ├── addSongView.vue │ │ │ │ └── singerView.vue │ │ │ └── tab04 │ │ │ │ ├── addSongView.vue │ │ │ │ └── songListView.vue │ │ ├── header │ │ │ └── index.vue │ │ └── index.vue │ ├── main.js │ ├── router │ │ └── index.js │ └── style.css ├── tailwind.config.js ├── vite.config.js └── yarn.lock └── musicServer ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── example │ │ └── musicserver │ │ ├── MusicServerApplication.java │ │ ├── common │ │ ├── net │ │ │ ├── ErrorMessage.java │ │ │ ├── FatalMessage.java │ │ │ ├── HttpConverterConfig.java │ │ │ ├── SuccessMessage.java │ │ │ └── WarningMessage.java │ │ └── utils │ │ │ ├── UploadImage.java │ │ │ └── UploadMusic.java │ │ ├── controller │ │ ├── AdminController.java │ │ ├── CommentController.java │ │ ├── ReplyController.java │ │ ├── SingerController.java │ │ ├── SongController.java │ │ ├── SongListController.java │ │ ├── UploadController.java │ │ ├── UserDataController.java │ │ └── UserSongListController.java │ │ ├── dao │ │ ├── AdminMapper.java │ │ ├── CommentMapper.java │ │ ├── ReplyMapper.java │ │ ├── SingerMapper.java │ │ ├── SongListMapper.java │ │ ├── SongMapper.java │ │ ├── UserDataMapper.java │ │ └── UserSongListMapper.java │ │ ├── entity │ │ ├── Admin.java │ │ ├── Comment.java │ │ ├── Reply.java │ │ ├── Singer.java │ │ ├── Song.java │ │ ├── SongList.java │ │ ├── UserData.java │ │ └── UserSongList.java │ │ └── service │ │ ├── AdminService.java │ │ ├── CommentService.java │ │ ├── Impl │ │ ├── AdminServiceImpl.java │ │ ├── CommentServiceImpl.java │ │ ├── ReplyServiceImpl.java │ │ ├── SingerServiceImpl.java │ │ ├── SongListServiceImpl.java │ │ ├── SongServiceImpl.java │ │ ├── UserDataServiceImpl.java │ │ └── UserSongListServiceImpl.java │ │ ├── ReplyService.java │ │ ├── SingerService.java │ │ ├── SongListService.java │ │ ├── SongService.java │ │ ├── UserDataService.java │ │ └── UserSongListService.java └── resources │ ├── application.yaml │ └── mapper │ ├── AdminMapper.xml │ ├── CommentMapper.xml │ ├── ReplyMapper.xml │ ├── SingerMapper.xml │ ├── SongListMapper.xml │ ├── SongMapper.xml │ ├── UserDataMapper.xml │ └── UserSongListMapper.xml └── test └── java └── com └── example └── musicserver ├── MusicServerApplicationTests.java ├── dao ├── AdminMapperTest.java ├── CommentMapperTest.java ├── ReplyMapperTest.java ├── SingerMapperTest.java ├── SongListMapperTest.java ├── SongMapperTest.java ├── UserDataMapperTest.java └── UserSongListMapperTest.java └── demo └── JvmTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # musicWebsite 2 | 基于Vue.js和Spring Boot前后端分离的音乐网站项目 3 | ## 主要功能 4 | ### 前台 5 | * 注册登录 6 | * 播放音乐 7 | * 检索音乐 8 | * 用户自建歌单 9 | ### 后台 10 | * 管理用户 11 | * 添加歌手 12 | * 上传音乐 13 | * 添加歌单 14 | ## 实际效果 15 | ### 前台 16 | #### 1.主界面 17 | image 18 | 19 | #### 2.音乐检索 20 | image 21 | 22 | #### 3.登录注册 23 | image 24 | 25 | #### 4.侧栏歌单歌曲列表 26 | image 27 | 28 | ### 后台 29 | #### 1.信息统计 30 | image 31 | 32 | #### 2.歌手管理 33 | image 34 | 35 | #### 3.歌曲管理 36 | image 37 | 38 | #### 4.歌单管理 39 | image 40 | 41 | 42 | -------------------------------------------------------------------------------- /musicClient/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /musicClient/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /musicClient/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + Vite 2 | 3 | This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` 20 | 21 | 22 | -------------------------------------------------------------------------------- /musicClient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "musicclient", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "animate.css": "^4.1.1", 13 | "axios": "^1.3.5", 14 | "element-plus": "^2.3.3", 15 | "gsap": "^3.11.5", 16 | "jsmediatags": "^3.9.7", 17 | "moment": "^2.29.4", 18 | "music-metadata-browser": "^2.5.9", 19 | "pinia": "^2.0.35", 20 | "pinia-plugin-persist": "^1.0.0", 21 | "pinia-plugin-persistedstate": "^3.1.0", 22 | "vue": "^3.2.47", 23 | "vue-router": "^4.1.6", 24 | "vue-simple-drawer": "^1.0.6" 25 | }, 26 | "devDependencies": { 27 | "@rollup/plugin-commonjs": "^24.1.0", 28 | "@rollup/plugin-node-resolve": "^15.0.2", 29 | "@types/node": "^18.15.11", 30 | "@vitejs/plugin-vue": "^4.1.0", 31 | "autoprefixer": "^10.4.14", 32 | "postcss": "^8.4.21", 33 | "tailwindcss": "^3.3.1", 34 | "vite": "^4.2.0", 35 | "vite-plugin-node-polyfills": "^0.8.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /musicClient/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /musicClient/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicClient/src/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 12 | 13 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /musicClient/src/api/api.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-09 19:19:12 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-05-13 15:35:30 6 | * @FilePath: /musicClient/src/api/api.js 7 | * @Description: null 8 | */ 9 | import { request } from './axios' 10 | 11 | /** 12 | * @description -封装User类型的接口方法 13 | */ 14 | export class UserService { // 模块一 15 | /** 16 | * @description 用户登录 17 | * @param {string} username - 用户名 18 | * @return {HttpResponse} result 19 | */ 20 | static async login1(params) { // 接口一 21 | return request('/login',params, 'post') 22 | } 23 | static async login2(params) { // 接口二 24 | return request('/login',params, 'post') 25 | } 26 | static async login3(params) { // 接口三 27 | return request('/login',params, 'post') 28 | } 29 | } 30 | 31 | export class UserDataService { 32 | static async getUserDataList(params) { 33 | return request('/userData/getUserList', params, 'post') 34 | } 35 | static async addUserData(params) { 36 | return request('/userData/addUserData', params, 'post') 37 | } 38 | static async userDataLogin(params) { 39 | return request('/userData/userLogin', params, 'post') 40 | } 41 | static async userDataUpdate(params) { 42 | return request('/userData/updateUserData', params, 'post') 43 | } 44 | } 45 | 46 | export class UserSongListService { 47 | static async getUserSongList(params) { 48 | return request('/userSongList/getUserSongList', params, 'post') 49 | } 50 | static async getSongList(params) { 51 | return request('/userSongList/getSongList', params, 'post') 52 | } 53 | static async addUserSongList(params) { 54 | return request('/userSongList/addUserSongLit', params, 'post') 55 | } 56 | static async updateUserSongList(params) { 57 | return request('/userSongList/updateUserSongList', params, 'post') 58 | } 59 | } 60 | 61 | export class SongDataService { 62 | static async getSongDataList(params) { 63 | return request('/song/selectSong', params, 'post') 64 | } 65 | 66 | static async addSongData(params) { 67 | return request('/song/addSong', params, 'post') 68 | } 69 | 70 | static async getSongRankingList(params) { 71 | return request('/song/getRankingList', params, 'post') 72 | } 73 | 74 | static async updateSongData(params) { 75 | return request('/song/updateSong', params, 'post') 76 | } 77 | 78 | static async updateSongRankingList(params) { 79 | return request('/song/updateSongRankingList', params, 'post') 80 | } 81 | } 82 | 83 | export class SongListDataService { 84 | static async getSongList(params) { 85 | return request('/songList/selectSongList', params, 'post') 86 | } 87 | static async getSongListMusic(params) { 88 | return request('/songList/getSongListMusic', params, 'post') 89 | } 90 | } 91 | 92 | export class SingerDataService { 93 | static async getSingerDataList(params) { 94 | return request('/singer/getSingerList', params, 'post') 95 | } 96 | 97 | static async addSingerData(params) { 98 | return request('/singer/addSinger', params, 'POST') 99 | } 100 | 101 | static async updateSingerData(params) { 102 | return request('/singer/updateByPrimaryKey',params, 'post') 103 | } 104 | } 105 | 106 | export class landRelevant { // 模块二 107 | /** 108 | * @description 获取地列表 109 | * @return {HttpResponse} result 110 | */ 111 | static async landList(params) { 112 | return request('/comment/song/details',params, 'get') 113 | } 114 | } -------------------------------------------------------------------------------- /musicClient/src/api/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import { showMessage } from "./status"; // 引入状态码文件 3 | import { ElMessage } from 'element-plus' // 引入el 提示框,这个项目里用什么组件库这里引什么 4 | 5 | // 设置接口超时时间 6 | axios.defaults.timeout = 60000; 7 | 8 | // 请求地址,这里是动态赋值的的环境变量,下一篇会细讲,这里跳过 9 | // @ts-ignore 10 | axios.defaults.baseURL = import.meta.env.VITE_API_DOMAIN; 11 | 12 | //http request 拦截器 13 | axios.interceptors.request.use( 14 | config => { 15 | // 配置请求头 16 | config.headers = { 17 | 'Content-Type':'application/x-www-form-urlencoded', // 传参方式表单 18 | // 'Content-Type':'application/json;charset=UTF-8', // 传参方式json 19 | // 'token':'80c483d59ca86ad0393cf8a98416e2a1' // 这里自定义配置,这里传的是token 20 | }; 21 | return config; 22 | }, 23 | error => { 24 | return Promise.reject(error); 25 | } 26 | ); 27 | 28 | //http response 拦截器 29 | axios.interceptors.response.use( 30 | response => { 31 | return response; 32 | }, 33 | error => { 34 | const {response} = error; 35 | if (response) { 36 | // 请求已发出,但是不在2xx的范围 37 | showMessage(response.status); // 传入响应码,匹配响应码对应信息 38 | return Promise.reject(response.data); 39 | } else { 40 | ElMessage.warning('网络连接异常,请稍后再试!'); 41 | } 42 | } 43 | ); 44 | 45 | // 封装 GET POST 请求并导出 46 | export function request(url = '', params = {}, type = ''){ 47 | //设置 url params type 的默认值 48 | return new Promise((resolve,reject)=>{ 49 | let promise 50 | if( type.toUpperCase() ==='GET' ){ 51 | promise = axios({ 52 | url, 53 | params 54 | }) 55 | }else if( type.toUpperCase() === 'POST' ){ 56 | promise = axios({ 57 | method:'POST', 58 | url, 59 | data: params 60 | }) 61 | } 62 | //处理返回 63 | promise.then(res=>{ 64 | resolve(res) 65 | }).catch(err=>{ 66 | reject(err) 67 | }) 68 | }) 69 | } -------------------------------------------------------------------------------- /musicClient/src/api/request.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | export function request(config) { 3 | 4 | const instance = axios.create({ 5 | baseURL: '/api', // 通过/api别名指定后端路由 6 | timeout: 5000, 7 | headers:{ 8 | }, 9 | }) 10 | 11 | // axios的拦截器(类似python的中间件的request) 12 | instance.interceptors.request.use(aaa => { 13 | 14 | // 多用于登录时的cookies判断 15 | return aaa 16 | }, err => { 17 | console.log(err); 18 | }) 19 | // 数据返回拦截 20 | instance.interceptors.response.use(aaa => { 21 | // 多用于登录时的cookies判断 22 | return aaa.data 23 | }, err => { 24 | console.log(err); 25 | }) 26 | // 直接返回 27 | return instance(config) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /musicClient/src/api/status.js: -------------------------------------------------------------------------------- 1 | export const showMessage = (status) => { 2 | let message = ""; 3 | switch (status) { 4 | case 400: 5 | message = "请求错误(400)"; 6 | break; 7 | case 401: 8 | message = "未授权,请重新登录(401)"; 9 | break; 10 | case 403: 11 | message = "拒绝访问(403)"; 12 | break; 13 | case 404: 14 | message = "请求出错(404)"; 15 | break; 16 | case 408: 17 | message = "请求超时(408)"; 18 | break; 19 | case 500: 20 | message = "服务器错误(500)"; 21 | break; 22 | case 501: 23 | message = "服务未实现(501)"; 24 | break; 25 | case 502: 26 | message = "网络错误(502)"; 27 | break; 28 | case 503: 29 | message = "服务不可用(503)"; 30 | break; 31 | case 504: 32 | message = "网络超时(504)"; 33 | break; 34 | case 505: 35 | message = "HTTP版本不受支持(505)"; 36 | break; 37 | default: 38 | message = `连接出错(${status})!`; 39 | } 40 | return `${message},请检查网络或联系管理员!`; 41 | }; -------------------------------------------------------------------------------- /musicClient/src/assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /musicClient/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicClient/src/components/core/comment/commentView.vue: -------------------------------------------------------------------------------- 1 | 9 | 12 | 13 | 25 | 26 | -------------------------------------------------------------------------------- /musicClient/src/components/core/player/playList.vue: -------------------------------------------------------------------------------- 1 | 9 | 71 | 72 | 104 | 105 | -------------------------------------------------------------------------------- /musicClient/src/components/edit/userEditView.vue: -------------------------------------------------------------------------------- 1 | 9 | 75 | 76 | 128 | 129 | -------------------------------------------------------------------------------- /musicClient/src/layout/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 79 | 80 | 116 | 117 | -------------------------------------------------------------------------------- /musicClient/src/layout/mainView/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 28 | 29 | 63 | 64 | -------------------------------------------------------------------------------- /musicClient/src/layout/mainView/mainCenter/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /musicClient/src/layout/mainView/navBar/rankingList.vue: -------------------------------------------------------------------------------- 1 | 65 | 66 | 137 | 138 | -------------------------------------------------------------------------------- /musicClient/src/layout/mainView/navBar/recentlyPlayed.vue: -------------------------------------------------------------------------------- 1 | 66 | 67 | 133 | 134 | -------------------------------------------------------------------------------- /musicClient/src/layout/mainView/navBar/searchList.vue: -------------------------------------------------------------------------------- 1 | 9 | 73 | 74 | 147 | 148 | -------------------------------------------------------------------------------- /musicClient/src/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-29 10:42:04 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-22 14:05:23 6 | * @FilePath: /musicClient/src/main.js 7 | * @Description: null 8 | */ 9 | import { createApp } from 'vue' 10 | import './style.css' 11 | import 'animate.css' 12 | import ElementPlus from 'element-plus' 13 | import App from './App.vue' 14 | import axios from 'axios' 15 | import router from './router' 16 | import store from './store' 17 | 18 | 19 | //设置axios请求地址默认是‘/api',这样根据第一步中配置会将/api替换为对应服务器地址 20 | axios.defaults.baseURL = "/api"; 21 | 22 | createApp(App).use(router).use(ElementPlus).use(store).mount('#app') 23 | -------------------------------------------------------------------------------- /musicClient/src/router/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-09 19:26:21 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-26 13:57:21 6 | * @FilePath: /musicClient/src/router/index.js 7 | * @Description: null 8 | */ 9 | import { createRouter, createWebHistory } from "vue-router"; 10 | import Index from '@/layout/index.vue' 11 | 12 | const router = createRouter({ 13 | history: createWebHistory(), 14 | routes: [ 15 | { 16 | component: Index, 17 | path: "/", 18 | meta: { 19 | title: 'Vite 音乐' 20 | } 21 | }, 22 | { 23 | path: "/test", 24 | name: "test", 25 | component: () => import('@/layout/sideBar/test.vue') 26 | }, 27 | { 28 | path: "/login", 29 | name: "login", 30 | component: () => import('coms/core/login/index.vue'), 31 | meta: { 32 | title: '登录' 33 | } 34 | } 35 | ] 36 | }) 37 | 38 | router.beforeEach((to, from, next) => { 39 | if(to.meta.title) { 40 | document.title = to.meta.title 41 | } 42 | next() 43 | }) 44 | 45 | export default router -------------------------------------------------------------------------------- /musicClient/src/store/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-22 10:18:46 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-22 14:33:26 6 | * @FilePath: /musicClient/src/store/index.ts 7 | * @Description: null 8 | */ 9 | import { createPinia } from 'pinia' 10 | //引入持久化插件 11 | import piniaPluginPersist from 'pinia-plugin-persist' 12 | 13 | const store = createPinia() 14 | 15 | store.use(piniaPluginPersist) 16 | 17 | export default store 18 | -------------------------------------------------------------------------------- /musicClient/src/store/searchDataInfo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-26 21:25:27 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-26 22:27:30 6 | * @FilePath: /musicClient/src/store/searchDataInfo.ts 7 | * @Description: null 8 | */ 9 | import { defineStore } from 'pinia' 10 | 11 | export const searchDataInfo = defineStore('searchDataInfo', { 12 | state: () => { 13 | return { 14 | searchList: [], 15 | showSearchList: false, 16 | searchValue: null 17 | } 18 | }, 19 | getters: { 20 | 21 | }, 22 | actions: { 23 | 24 | }, 25 | //持久化存储 26 | persist: { 27 | //开启持久化存储默认是绘画存储,页面关闭后消失 28 | enabled: true, 29 | strategies: [{ 30 | key: 'searchDataInfo', 31 | storage: localStorage 32 | }] 33 | } 34 | }) -------------------------------------------------------------------------------- /musicClient/src/store/userDataInfo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-25 18:47:30 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-05-13 13:46:16 6 | * @FilePath: /musicClient/src/store/userDataInfo.ts 7 | * @Description: null 8 | */ 9 | import { defineStore } from 'pinia' 10 | 11 | export const userDataInfo = defineStore('userDataInfo', { 12 | state: () => { 13 | return { 14 | userData: { 15 | userId: null, 16 | name: null, 17 | gender: null, 18 | birth: null, 19 | location: null, 20 | photo: null, 21 | introduction: null 22 | }, 23 | userDataEdit: false, 24 | userViewIndex: 1, 25 | //用户自建某单个歌单信息 26 | userSongListOne: null, 27 | //用户自建歌单列表 28 | userSongListData: [] 29 | } 30 | }, 31 | getters: { 32 | 33 | }, 34 | actions: { 35 | 36 | }, 37 | //持久化存储 38 | persist: { 39 | //开启持久化存储默认是绘画存储,页面关闭后消失 40 | enabled: true, 41 | strategies: [{ 42 | key: 'userDataInfo', 43 | storage: localStorage 44 | }] 45 | } 46 | }) -------------------------------------------------------------------------------- /musicClient/src/store/userPlayInfo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-22 11:07:50 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-22 15:48:48 6 | * @FilePath: /musicClient/src/store/userPlayInfo.ts 7 | * @Description: null 8 | */ 9 | import { defineStore } from 'pinia' 10 | 11 | export const userPlayInfo = defineStore('userPlayInfo', { 12 | state: () => { 13 | return { 14 | //当前播放歌曲 15 | player: { 16 | songId: null, 17 | name: "", 18 | album: "", 19 | url: "", 20 | lyric: [] as any[] 21 | }, 22 | //歌单 23 | playList: [], 24 | //播放音量 25 | playVolume: 0, 26 | //切换模式 27 | playType: 1, 28 | //侧边滑块 29 | playSlider: false, 30 | //在列表中的位置 31 | playIndex: 0, 32 | //是否自动播放 33 | playAuto: false, 34 | addLoveView: false, 35 | //最近播放歌单 36 | recentlyList: [] 37 | } 38 | }, 39 | getters: { 40 | 41 | }, 42 | actions: { 43 | updatePlayList( val: [] ) { 44 | this.playList = val 45 | }, 46 | updatePlayVolume( val: number ) { 47 | this.playVolume = val 48 | } 49 | }, 50 | //持久化存储 51 | persist: { 52 | //开启持久化存储默认是绘画存储,页面关闭后消失 53 | enabled: true, 54 | strategies: [{ 55 | key: 'userPlayInfo', 56 | storage: localStorage 57 | }] 58 | } 59 | }) -------------------------------------------------------------------------------- /musicClient/src/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | @tailwind base; 7 | @tailwind components; 8 | @tailwind utilities; -------------------------------------------------------------------------------- /musicClient/src/utils/audioToImage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-15 22:37:40 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-16 12:26:43 6 | * @FilePath: /musicClient/src/utils/audioToImage.js 7 | * @Description: null 8 | */ 9 | // 从网络上获取 MP3 文件的二进制数据 10 | import * as musicMetadata from 'music-metadata-browser' 11 | 12 | export async function audioToImage(mp3Url) { 13 | const metadata = await musicMetadata.fetchFromUrl(mp3Url); 14 | console.log("歌曲信息",metadata); 15 | const pictures = metadata.common.picture 16 | const pictureUrl = URL.createObjectURL(new Blob([pictures[0].data], { type: pictures[0].format })) 17 | return pictureUrl 18 | } -------------------------------------------------------------------------------- /musicClient/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-04-09 19:11:30 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-12 10:07:42 6 | * @FilePath: /musicClient/tailwind.config.js 7 | * @Description: null 8 | */ 9 | /** @type {import('tailwindcss').Config} */ 10 | export default { 11 | // purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 12 | // purge: [], 13 | content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 14 | // content: [], 15 | theme: { 16 | extend: {}, 17 | }, 18 | plugins: [], 19 | } 20 | 21 | -------------------------------------------------------------------------------- /musicClient/vite.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-29 10:42:04 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-16 13:24:54 6 | * @FilePath: /musicClient/vite.config.js 7 | * @Description: null 8 | */ 9 | import { defineConfig } from 'vite' 10 | import vue from '@vitejs/plugin-vue' 11 | import path from 'path' 12 | 13 | /** 14 | * 解决使用music-metadata-browser时浏览器无法获取Buffer的报错 15 | * Uncaught (in promise) ReferenceError: Buffer is not defined 16 | * 原因是在页面中使用了Buffer,但是浏览器中JS没有Buffer对象,它是存在Node中。 17 | */ 18 | 19 | import { nodePolyfills } from 'vite-plugin-node-polyfills' 20 | 21 | // https://vitejs.dev/config/ 22 | export default defineConfig({ 23 | plugins: [ 24 | vue(), 25 | nodePolyfills({ 26 | // Whether to polyfill `node:` protocol imports. 27 | protocolImports: true, 28 | }), 29 | ], 30 | // 配置路径别名 31 | resolve: { 32 | alias: { 33 | "@": path.resolve(__dirname, "src"), 34 | "coms": path.resolve(__dirname, "src/components"), 35 | } 36 | }, 37 | server: { 38 | //设置客户端启动端口号 39 | host: 'localhost', 40 | port: 8888, 41 | open: false, //是否自动打开浏览器 42 | //设置跨域代理 43 | proxy: { 44 | '/api': { 45 | target: 'http://localhost:9999', 46 | changeOrigin: true, 47 | rewrite: (path) => path.replace(/^\/api/, '') //不可省略rewrite 48 | } 49 | } 50 | } 51 | }) 52 | -------------------------------------------------------------------------------- /musicManage/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /musicManage/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /musicManage/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + Vite 2 | 3 | This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` 20 | 21 | 22 | -------------------------------------------------------------------------------- /musicManage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "musicmanage", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@element-plus/icons-vue": "^2.1.0", 13 | "@icon-park/vue-next": "^1.4.2", 14 | "animate.css": "^4.1.1", 15 | "aplayer": "^1.10.1", 16 | "axios": "^1.3.4", 17 | "echarts": "^5.4.2", 18 | "element-plus": "^2.3.1", 19 | "gsap": "^3.11.5", 20 | "moment": "^2.29.4", 21 | "vue": "^3.2.47", 22 | "vue-router": "4" 23 | }, 24 | "devDependencies": { 25 | "@vitejs/plugin-vue": "^4.1.0", 26 | "autoprefixer": "^10.4.14", 27 | "less": "^4.1.3", 28 | "less-loader": "^11.1.0", 29 | "postcss": "^8.4.21", 30 | "tailwindcss": "^3.3.1", 31 | "vite": "^4.2.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /musicManage/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /musicManage/public/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccnice-wp/viteMusic/0ca50f035c8e024786a8176b7d6b51bf7daab804/musicManage/public/icon.ico -------------------------------------------------------------------------------- /musicManage/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 12 | 13 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /musicManage/src/api/api.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 13:42:53 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-23 15:58:42 6 | * @FilePath: /musicManage/src/api/api.js 7 | * @Description: null 8 | */ 9 | import { request } from './axios' 10 | 11 | /** 12 | * @description -封装User类型的接口方法 13 | */ 14 | export class UserService { // 模块一 15 | /** 16 | * @description 用户登录 17 | * @param {string} username - 用户名 18 | * @return {HttpResponse} result 19 | */ 20 | static async login1(params) { // 接口一 21 | return request('/login',params, 'post') 22 | } 23 | static async login2(params) { // 接口二 24 | return request('/login',params, 'post') 25 | } 26 | static async login3(params) { // 接口三 27 | return request('/login',params, 'post') 28 | } 29 | } 30 | 31 | export class UserDataService { 32 | static async getUserDataList(params) { 33 | return request('/userData/getUserList', params, 'post') 34 | } 35 | } 36 | 37 | export class adminService { 38 | static async getInfo(params) { 39 | return request('admin/selectInfo', params, 'post') 40 | } 41 | } 42 | 43 | export class SongDataService { 44 | static async getSongDataList(params) { 45 | return request('/song/selectSong', params, 'post') 46 | } 47 | 48 | static async addSongData(params) { 49 | return request('/song/addSong', params, 'post') 50 | } 51 | 52 | static async updateSongData(params) { 53 | return request('/song/updateSong', params, 'post') 54 | } 55 | } 56 | 57 | export class SongListDataService { 58 | static async getSongListData(params) { 59 | return request('/songList/selectSongList', params, 'post') 60 | } 61 | static async addSongListData(params) { 62 | return request('/songList/addSongList', params, 'post') 63 | } 64 | static async updateSongListData(params) { 65 | return request('/songList/updateSongList', params, 'post') 66 | } 67 | static async getSongListMusic(params) { 68 | return request('/songList/getSongListMusic', params, 'post') 69 | } 70 | static async addSong(params) { 71 | return request('/songList/addSong', params, 'post') 72 | } 73 | } 74 | 75 | export class SingerDataService { 76 | static async getSingerDataList(params) { 77 | return request('/singer/getSingerList', params, 'post') 78 | } 79 | 80 | static async addSingerData(params) { 81 | return request('/singer/addSinger', params, 'POST') 82 | } 83 | 84 | static async updateSingerData(params) { 85 | return request('/singer/updateByPrimaryKey',params, 'post') 86 | } 87 | } 88 | 89 | export class landRelevant { // 模块二 90 | /** 91 | * @description 获取地列表 92 | * @return {HttpResponse} result 93 | */ 94 | static async landList(params) { 95 | return request('/comment/song/details',params, 'get') 96 | } 97 | } -------------------------------------------------------------------------------- /musicManage/src/api/axios.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 13:41:49 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-04 16:46:27 6 | * @FilePath: /musicManage/src/api/axios.js 7 | * @Description: null 8 | */ 9 | import axios from 'axios'; 10 | import { showMessage } from "./status"; // 引入状态码文件 11 | import { ElMessage } from 'element-plus' // 引入el 提示框,这个项目里用什么组件库这里引什么 12 | 13 | // 设置接口超时时间 14 | axios.defaults.timeout = 60000; 15 | 16 | // 请求地址,这里是动态赋值的的环境变量,下一篇会细讲,这里跳过 17 | // @ts-ignore 18 | axios.defaults.baseURL = import.meta.env.VITE_API_DOMAIN; 19 | 20 | //http request 拦截器 21 | axios.interceptors.request.use( 22 | config => { 23 | // 配置请求头 24 | config.headers = { 25 | 'Content-Type':'application/x-www-form-urlencoded', // 传参方式表单 26 | // 'Content-Type':'application/json;charset=UTF-8', // 传参方式json 27 | // 'token':'80c483d59ca86ad0393cf8a98416e2a1' // 这里自定义配置,这里传的是token 28 | }; 29 | return config; 30 | }, 31 | error => { 32 | return Promise.reject(error); 33 | } 34 | ); 35 | 36 | //http response 拦截器 37 | axios.interceptors.response.use( 38 | response => { 39 | return response; 40 | }, 41 | error => { 42 | const {response} = error; 43 | if (response) { 44 | // 请求已发出,但是不在2xx的范围 45 | showMessage(response.status); // 传入响应码,匹配响应码对应信息 46 | return Promise.reject(response.data); 47 | } else { 48 | ElMessage.warning('网络连接异常,请稍后再试!'); 49 | } 50 | } 51 | ); 52 | 53 | // 封装 GET POST 请求并导出 54 | export function request(url = '', params = {}, type = ''){ 55 | //设置 url params type 的默认值 56 | return new Promise((resolve,reject)=>{ 57 | let promise 58 | if( type.toUpperCase() ==='GET' ){ 59 | promise = axios({ 60 | url, 61 | params 62 | }) 63 | }else if( type.toUpperCase() === 'POST' ){ 64 | promise = axios({ 65 | method:'POST', 66 | url, 67 | data: params 68 | }) 69 | } 70 | //处理返回 71 | promise.then(res=>{ 72 | resolve(res) 73 | }).catch(err=>{ 74 | reject(err) 75 | }) 76 | }) 77 | } -------------------------------------------------------------------------------- /musicManage/src/api/request.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 12:47:11 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-03-31 12:47:16 6 | * @FilePath: /musicManage/src/api/request.js 7 | * @Description: null 8 | */ 9 | import axios from "axios"; 10 | export function request(config) { 11 | 12 | const instance = axios.create({ 13 | baseURL: '/api', // 通过/api别名指定后端路由 14 | timeout: 5000, 15 | headers:{ 16 | }, 17 | }) 18 | 19 | // axios的拦截器(类似python的中间件的request) 20 | instance.interceptors.request.use(aaa => { 21 | 22 | // 多用于登录时的cookies判断 23 | return aaa 24 | }, err => { 25 | console.log(err); 26 | }) 27 | // 数据返回拦截 28 | instance.interceptors.response.use(aaa => { 29 | // 多用于登录时的cookies判断 30 | return aaa.data 31 | }, err => { 32 | console.log(err); 33 | }) 34 | // 直接返回 35 | return instance(config) 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /musicManage/src/api/status.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 13:40:22 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-03-31 13:41:15 6 | * @FilePath: /musicManage/src/api/status.js 7 | * @Description: null 8 | */ 9 | export const showMessage = (status) => { 10 | let message = ""; 11 | switch (status) { 12 | case 400: 13 | message = "请求错误(400)"; 14 | break; 15 | case 401: 16 | message = "未授权,请重新登录(401)"; 17 | break; 18 | case 403: 19 | message = "拒绝访问(403)"; 20 | break; 21 | case 404: 22 | message = "请求出错(404)"; 23 | break; 24 | case 408: 25 | message = "请求超时(408)"; 26 | break; 27 | case 500: 28 | message = "服务器错误(500)"; 29 | break; 30 | case 501: 31 | message = "服务未实现(501)"; 32 | break; 33 | case 502: 34 | message = "网络错误(502)"; 35 | break; 36 | case 503: 37 | message = "服务不可用(503)"; 38 | break; 39 | case 504: 40 | message = "网络超时(504)"; 41 | break; 42 | case 505: 43 | message = "HTTP版本不受支持(505)"; 44 | break; 45 | default: 46 | message = `连接出错(${status})!`; 47 | } 48 | return `${message},请检查网络或联系管理员!`; 49 | }; -------------------------------------------------------------------------------- /musicManage/src/assets/css/base.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccnice-wp/viteMusic/0ca50f035c8e024786a8176b7d6b51bf7daab804/musicManage/src/assets/css/base.less -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio/align-justify.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio/backward-step.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio/forward-step.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio/pause.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/audio/play.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccnice-wp/viteMusic/0ca50f035c8e024786a8176b7d6b51bf7daab804/musicManage/src/assets/images/logo.png -------------------------------------------------------------------------------- /musicManage/src/assets/images/userLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccnice-wp/viteMusic/0ca50f035c8e024786a8176b7d6b51bf7daab804/musicManage/src/assets/images/userLogo.png -------------------------------------------------------------------------------- /musicManage/src/assets/utils/dateUtils.js: -------------------------------------------------------------------------------- 1 | import moment from "moment"; 2 | 3 | function dateFormat(data) { 4 | 5 | return moment(new Date(data).getTime()).format('YYYY-MM-DD HH:mm');; 6 | 7 | } 8 | 9 | 10 | export default dateFormat -------------------------------------------------------------------------------- /musicManage/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /musicManage/src/components/basic/APlayer.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /musicManage/src/components/core/Login.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 21 | 22 | 36 | 37 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartFive.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartFour.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartOne.vue: -------------------------------------------------------------------------------- 1 | 9 | 86 | 87 | 96 | 97 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartSix.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartThree.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/charts/chartTwo.vue: -------------------------------------------------------------------------------- 1 | 9 | 68 | 69 | 78 | 79 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/infoView.vue: -------------------------------------------------------------------------------- 1 | 9 | 20 | 21 | 22 | 34 | 35 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/tables/tableFour.vue: -------------------------------------------------------------------------------- 1 | 9 | 37 | 38 | 53 | 54 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/tables/tableOne.vue: -------------------------------------------------------------------------------- 1 | 9 | 37 | 38 | 53 | 54 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/tables/tableThree.vue: -------------------------------------------------------------------------------- 1 | 9 | 36 | 37 | 51 | 52 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab01/tables/tableTwo.vue: -------------------------------------------------------------------------------- 1 | 9 | 37 | 38 | 53 | 54 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab02/userView.vue: -------------------------------------------------------------------------------- 1 | 9 | 48 | 49 | 75 | 76 | -------------------------------------------------------------------------------- /musicManage/src/layout/content/tab03/addSongView.vue: -------------------------------------------------------------------------------- 1 | 9 | 87 | 88 | 154 | 155 | -------------------------------------------------------------------------------- /musicManage/src/layout/header/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 28 | 29 | 55 | 56 | -------------------------------------------------------------------------------- /musicManage/src/layout/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /musicManage/src/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 10:27:09 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-09 19:30:35 6 | * @FilePath: /musicManage/src/main.js 7 | * @Description: null 8 | */ 9 | import { createApp } from 'vue' 10 | // import moment from 'moment' 11 | import ElementPlus from 'element-plus' 12 | import './style.css' 13 | import 'animate.css' 14 | import App from './App.vue' 15 | import router from './router' 16 | import axios from 'axios' 17 | import * as ElementPlusIconsVue from '@element-plus/icons-vue' 18 | import 'element-plus/dist/index.css' 19 | 20 | //设置axios请求的地址默认是'/api',这样根据第一步中配置的会将/api替换为对应服务器地址 21 | axios.defaults.baseURL = "/api"; 22 | 23 | 24 | const app = createApp(App) 25 | for (const [key, component] of Object.entries(ElementPlusIconsVue)) { 26 | app.component(key, component) 27 | } 28 | 29 | 30 | app.use(router).use(ElementPlus).mount('#app') 31 | -------------------------------------------------------------------------------- /musicManage/src/router/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 11:07:14 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-03-31 11:46:49 6 | * @FilePath: /musicManage/src/router/index.js 7 | * @Description: null 8 | */ 9 | import { createRouter, createWebHistory } from 'vue-router' 10 | import Layout from '@/layout/index.vue' 11 | 12 | 13 | 14 | const router = createRouter({ 15 | history: createWebHistory(), 16 | routes: [ 17 | { 18 | component: Layout, 19 | path: '/', 20 | children: [ 21 | 22 | ] 23 | } 24 | ] 25 | }) 26 | 27 | export default router 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /musicManage/src/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | 6 | @tailwind base; 7 | @tailwind components; 8 | @tailwind utilities; 9 | -------------------------------------------------------------------------------- /musicManage/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 14:23:57 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-02 16:06:02 6 | * @FilePath: /musicManage/tailwind.config.js 7 | * @Description: null 8 | */ 9 | /** @type {import('tailwindcss').Config} */ 10 | export default { 11 | // purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 12 | content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], 13 | theme: { 14 | extend: {}, 15 | }, 16 | plugins: [], 17 | } 18 | 19 | -------------------------------------------------------------------------------- /musicManage/vite.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: ccnice whl0808_work@163.com 3 | * @Date: 2023-03-31 10:27:09 4 | * @LastEditors: ccnice whl0808_work@163.com 5 | * @LastEditTime: 2023-04-01 11:00:31 6 | * @FilePath: /musicManage/vite.config.js 7 | * @Description: null 8 | */ 9 | import { defineConfig } from 'vite' 10 | import vue from '@vitejs/plugin-vue' 11 | import path from 'path' 12 | 13 | // https://vitejs.dev/config/ 14 | export default defineConfig({ 15 | plugins: [vue()], 16 | resolve: { 17 | alias: { 18 | "@" :path.resolve(__dirname, "src"), 19 | "coms": path.resolve(__dirname, "src/components"), 20 | } 21 | }, 22 | server : { 23 | //设置客户端启动端口号 24 | host: 'localhost', 25 | port: 7777, 26 | open: false, 27 | //设置跨域代理 28 | proxy: { 29 | '/api': { 30 | target: 'http://localhost:9999/', 31 | changeOrigin: true, 32 | rewrite: (path) => path.replace(/^\/api/, '') // 不可以省略rewrite 33 | } 34 | } 35 | }, 36 | css: { 37 | preprocessorOptions: { 38 | less: { 39 | modifyVars: { 40 | hack: `true; @import (reference) "${path.resolve("src/assets/css/base.less")}";`, 41 | }, 42 | javascriptEnabled: true, 43 | }, 44 | }, 45 | }, 46 | }) 47 | -------------------------------------------------------------------------------- /musicServer/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /musicServer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccnice-wp/viteMusic/0ca50f035c8e024786a8176b7d6b51bf7daab804/musicServer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /musicServer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar 19 | -------------------------------------------------------------------------------- /musicServer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.0.4 9 | 10 | 11 | com.example 12 | musicServer 13 | 0.0.1-SNAPSHOT 14 | musicServer 15 | musicServer 16 | 17 | 17 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-devtools 28 | runtime 29 | true 30 | 31 | 32 | 33 | 34 | org.mybatis.spring.boot 35 | mybatis-spring-boot-starter 36 | 3.0.1 37 | 38 | 39 | 40 | 41 | mysql 42 | mysql-connector-java 43 | 8.0.32 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-jdbc 48 | 3.0.4 49 | 50 | 51 | 52 | xyz.downgoon 53 | snowflake 54 | 1.0.0 55 | 56 | 57 | 58 | 59 | com.alibaba.fastjson2 60 | fastjson2 61 | 2.0.26 62 | 63 | 64 | 65 | 66 | 67 | org.projectlombok 68 | lombok 69 | true 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-starter-test 74 | test 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-maven-plugin 83 | 84 | 85 | 86 | org.projectlombok 87 | lombok 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/MusicServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MusicServerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MusicServerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/net/ErrorMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.net; 2 | 3 | import com.alibaba.fastjson2.JSONArray; 4 | import com.fasterxml.jackson.annotation.JsonAlias; 5 | 6 | import java.util.HashMap; 7 | 8 | /** 9 | * @Author CCNICE 10 | * @Date 2023/3/26 11 | */ 12 | public class ErrorMessage { 13 | 14 | HashMap hashMap = new HashMap<>(); 15 | 16 | 17 | public ErrorMessage(String message) { 18 | hashMap.put("code", 200); 19 | hashMap.put("message", message); 20 | hashMap.put("success", false); 21 | hashMap.put("type", "error"); 22 | hashMap.put("data", null); 23 | } 24 | 25 | public String getMessage() { 26 | return JSONArray.toJSONString(hashMap); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/net/FatalMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.net; 2 | 3 | import com.alibaba.fastjson2.JSONArray; 4 | 5 | import java.util.HashMap; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public class FatalMessage { 12 | 13 | HashMap hashMap = new HashMap<>(); 14 | 15 | 16 | public FatalMessage(String message) { 17 | hashMap.put("code", 500); 18 | hashMap.put("message", message); 19 | hashMap.put("success", false); 20 | hashMap.put("type", "error"); 21 | hashMap.put("data", null); 22 | } 23 | 24 | public String getMessage() { 25 | return JSONArray.toJSONString(hashMap); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/net/HttpConverterConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.net; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * @author CCNICE 9 | * @date 2023/4/3 10 | * 11 | * 设置静态资源转换,访问图片,音乐等 12 | */ 13 | @Configuration 14 | public class HttpConverterConfig implements WebMvcConfigurer { 15 | 16 | @Override 17 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 18 | //其中image表示访问的前缀。"file:F:/img/"是文件真实的存储路径 19 | registry.addResourceHandler("/image/**").addResourceLocations("file:/Users/ccnice/Desktop/graduation project/code/musicServer/src/main/resources/static/images/"); 20 | registry.addResourceHandler("/music/**").addResourceLocations("file:/Users/ccnice/Desktop/graduation project/code/musicServer/src/main/resources/static/musics/"); 21 | registry.addResourceHandler("/musics/**").addResourceLocations("file:/Users/ccnice/Desktop/graduation project/code/musicServer/src/main/resources/static/music01/"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/net/SuccessMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.net; 2 | 3 | import com.alibaba.fastjson2.JSONArray; 4 | 5 | import java.util.HashMap; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public class SuccessMessage { 12 | 13 | HashMap hashMap = new HashMap<>(); 14 | 15 | 16 | public SuccessMessage(String message) { 17 | hashMap.put("code", 200); 18 | hashMap.put("message", message); 19 | hashMap.put("success", true); 20 | hashMap.put("type", "success"); 21 | hashMap.put("data", null); 22 | } 23 | 24 | public SuccessMessage(String message, T data) { 25 | hashMap.put("code", 200); 26 | hashMap.put("message", message); 27 | hashMap.put("success", true); 28 | hashMap.put("type", "success"); 29 | hashMap.put("data", data); 30 | } 31 | 32 | public String getMessage() { 33 | return JSONArray.toJSONString(hashMap); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/net/WarningMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.net; 2 | 3 | import com.alibaba.fastjson2.JSONArray; 4 | 5 | import java.util.HashMap; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public class WarningMessage { 12 | 13 | HashMap hashMap = new HashMap<>(); 14 | 15 | 16 | public WarningMessage(String message) { 17 | hashMap.put("code", 200); 18 | hashMap.put("message", message); 19 | hashMap.put("success", false); 20 | hashMap.put("type", "warning"); 21 | hashMap.put("data", null); 22 | } 23 | 24 | public String getMessage() { 25 | return JSONArray.toJSONString(hashMap); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/utils/UploadImage.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.utils; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.controller.SingerController; 6 | import com.example.musicserver.entity.Singer; 7 | import com.example.musicserver.service.Impl.SingerServiceImpl; 8 | import org.apache.ibatis.jdbc.Null; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | import org.springframework.web.multipart.MultipartFile; 13 | 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.util.UUID; 17 | 18 | /** 19 | * @author CCNICE 20 | * @date 2023/4/3 21 | * 22 | * 图片上传工具类 23 | */ 24 | 25 | public class UploadImage { 26 | 27 | //定义目标路径,图片最终放置的位置 28 | private final static String BASE_PATH = "/Users/ccnice/Desktop/graduation project/code/musicServer/src/main/resources/static/images/"; 29 | public String uploadImage(MultipartFile file) { 30 | 31 | 32 | //获取上传的图片名称 33 | String fileName = file.getOriginalFilename(); 34 | //使用UUID给上传的图片重新命名 35 | assert fileName != null; 36 | String newFileName = UUID.randomUUID().toString().replace("-", "") + fileName.substring(fileName.lastIndexOf(".")); 37 | //创建一个文件实例对象 38 | File image = new File(BASE_PATH + newFileName); 39 | 40 | //对文件进行上传操作 41 | try { 42 | file.transferTo(image); 43 | 44 | return "/api/image/"+newFileName; 45 | } catch (IOException e) { 46 | e.printStackTrace(); 47 | 48 | return new ErrorMessage("上传失败").getMessage(); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/common/utils/UploadMusic.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.common.utils; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.util.UUID; 9 | 10 | /** 11 | * @author CCNICE 12 | * @date 2023/4/6 13 | * 14 | * 音乐上传工具类 15 | */ 16 | public class UploadMusic { 17 | 18 | //定义目标路径,音乐最终放置的位置 19 | private final static String BASE_PATH = "/Users/ccnice/Desktop/graduation project/code/musicServer/src/main/resources/static/music01/"; 20 | public String uploadMusic(MultipartFile file) { 21 | 22 | 23 | //获取上传的音乐名称 24 | String fileName = file.getOriginalFilename(); 25 | 26 | //使用UUID给上传的音乐重新命名 27 | assert fileName != null; 28 | String newFileName = UUID.randomUUID().toString().replace("-", "") + fileName.substring(fileName.lastIndexOf(".")); 29 | //创建一个文件实例对象 30 | File music = new File(BASE_PATH + newFileName); 31 | 32 | //对文件进行上传操作 33 | try { 34 | file.transferTo(music); 35 | 36 | return "/api/musics/"+newFileName; 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | 40 | return new ErrorMessage("上传失败").getMessage(); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.dao.AdminMapper; 6 | import com.example.musicserver.dao.SongListMapper; 7 | import com.example.musicserver.dao.SongMapper; 8 | import com.example.musicserver.entity.Admin; 9 | import com.example.musicserver.entity.Song; 10 | import com.example.musicserver.entity.SongList; 11 | import com.example.musicserver.entity.UserData; 12 | import com.example.musicserver.service.Impl.AdminServiceImpl; 13 | import org.apache.ibatis.jdbc.Null; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.stereotype.Repository; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.ResponseBody; 21 | import xyz.downgoon.snowflake.Snowflake; 22 | 23 | import java.util.ArrayList; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | 27 | /** 28 | * @Author CCNICE 29 | * @Date 2023/3/26 30 | */ 31 | @Controller 32 | @ResponseBody 33 | public class AdminController { 34 | 35 | @Autowired 36 | private AdminServiceImpl adminService; 37 | @Autowired 38 | private AdminMapper adminMapper; 39 | 40 | @Autowired 41 | private SongMapper songMapper; 42 | 43 | @Autowired 44 | private SongListMapper songListMapper; 45 | 46 | static Snowflake snowflake = new Snowflake(1,1); 47 | 48 | @RequestMapping(value = "/admin/loginStatus",method = RequestMethod.POST) 49 | public String loginStatus(Admin admin) { 50 | 51 | if (adminService.verifyAdminPassword(admin.getName(), admin.getPassword())) { 52 | return new SuccessMessage("登录成功!").getMessage(); 53 | } else { 54 | return new ErrorMessage("用户名或密码错误!").getMessage(); 55 | } 56 | } 57 | 58 | @RequestMapping(value = "admin/selectInfo", method = RequestMethod.POST) 59 | public String selectInfo() { 60 | 61 | ArrayList objectsAns = new ArrayList<>(); 62 | 63 | ArrayList> objects = new ArrayList<>(); 64 | HashMap hashMap1 = new HashMap<>(); 65 | List userData1 = adminMapper.selectUserCount(); 66 | hashMap1.put("totalUsers", userData1.get(0).getTotalUsers()); 67 | hashMap1.put("recentUsers", userData1.get(0).getRecentUsers()); 68 | 69 | HashMap hashMap2 = new HashMap<>(); 70 | List userData2 = adminMapper.selectGenderCounter(); 71 | hashMap2.put("male", userData2.get(0).getGenderCount()); 72 | hashMap2.put("female", userData2.get(1).getGenderCount()); 73 | hashMap2.put("unknown", userData2.get(2).getGenderCount()); 74 | 75 | HashMap hashMap3 = new HashMap<>(); 76 | Song song = new Song(); 77 | List songs = songMapper.selectSong(song); 78 | hashMap3.put("totalSongs", String.valueOf(songs.size())); 79 | 80 | HashMap hashMap4 = new HashMap<>(); 81 | SongList songList = new SongList(); 82 | List songLists = songListMapper.selectSongList(songList); 83 | hashMap4.put("totalSongList", String.valueOf(songLists.size())); 84 | 85 | List songPlayNum = adminMapper.selectPlayNum(); 86 | 87 | objects.add(hashMap1); 88 | objects.add(hashMap2); 89 | objects.add(hashMap3); 90 | objects.add(hashMap4); 91 | 92 | objectsAns.add(objects); 93 | objectsAns.add(songPlayNum); 94 | 95 | return new SuccessMessage>("查询信息", objectsAns).getMessage(); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/CommentController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.Comment; 6 | import com.example.musicserver.service.Impl.CommentServiceImpl; 7 | import org.apache.ibatis.jdbc.Null; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import xyz.downgoon.snowflake.Snowflake; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @Author CCNICE 19 | * @Date 2023/3/26 20 | */ 21 | @Controller 22 | @ResponseBody 23 | public class CommentController { 24 | 25 | @Autowired 26 | private CommentServiceImpl commentService; 27 | 28 | static Snowflake snowflake = new Snowflake(1,2); 29 | 30 | //增加歌曲或者歌单的评论 31 | @RequestMapping(value = "/comment/add", method = RequestMethod.POST) 32 | public String commentAdd(Comment comment) { 33 | comment.setCommentId(String.valueOf(snowflake.nextId())); 34 | boolean b = commentService.commentAdd(comment); 35 | if (b) { 36 | return new SuccessMessage("评论成功!").getMessage(); 37 | } else { 38 | return new ErrorMessage("评论失败!").getMessage(); 39 | } 40 | } 41 | 42 | //删除歌曲或者歌单的评论 43 | @RequestMapping(value = "/comment/delete", method = RequestMethod.POST) 44 | public String deleteComment(String commentId) { 45 | boolean b = commentService.deleteComment(commentId); 46 | if (b) { 47 | return new SuccessMessage("评论删除成功!").getMessage(); 48 | } else { 49 | return new ErrorMessage("评论删除失败!").getMessage(); 50 | } 51 | } 52 | 53 | //获得指定歌曲的评论,前端应传入songId 54 | @RequestMapping(value = "/comment/song/details", method = RequestMethod.GET) 55 | public String selectSongComment(Comment comment) { 56 | List comments = commentService.selectCommentBySongId(comment); 57 | return new SuccessMessage>("歌曲评论",comments).getMessage(); 58 | } 59 | 60 | //获得指定歌单的评论,前端应传入songListId 61 | @RequestMapping(value = "/comment/songList/details", method = RequestMethod.GET) 62 | public String selectSongListComment(Comment comment) { 63 | List comments = commentService.selectCommentBySongId(comment); 64 | return new SuccessMessage>("歌单评论",comments).getMessage(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/ReplyController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.Reply; 6 | import com.example.musicserver.service.Impl.ReplyServiceImpl; 7 | import org.apache.ibatis.jdbc.Null; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.EnableMBeanExport; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.ResponseBody; 14 | import xyz.downgoon.snowflake.Snowflake; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * @Author CCNICE 20 | * @Date 2023/3/26 21 | */ 22 | @Controller 23 | @ResponseBody 24 | public class ReplyController { 25 | 26 | @Autowired 27 | private ReplyServiceImpl replyService; 28 | 29 | static Snowflake snowflake = new Snowflake(1,3); 30 | 31 | //回复评论 32 | @RequestMapping(value = "/reply/add", method = RequestMethod.POST) 33 | public String replyAdd(Reply reply) { 34 | reply.setReplyId(String.valueOf(snowflake.nextId())); 35 | boolean b = replyService.replyAdd(reply); 36 | if (b) { 37 | return new SuccessMessage("回复评论成功!").getMessage(); 38 | } else { 39 | return new ErrorMessage("回复评论失败!").getMessage(); 40 | } 41 | } 42 | 43 | //删除回复评论 44 | @RequestMapping(value = "/reply/delete", method = RequestMethod.POST) 45 | public String replyDelete(String replyId) { 46 | boolean b = replyService.deleteReplyByPrimaryKey(replyId); 47 | if (b) { 48 | return new SuccessMessage("删除成功!").getMessage(); 49 | } else { 50 | return new ErrorMessage("删除失败!").getMessage(); 51 | } 52 | } 53 | 54 | //根据评论Id插叙相应的回复评论 55 | @RequestMapping(value = "/reply/details", method = RequestMethod.GET) 56 | public String selectReplyByCommentId(String commentId) { 57 | List replies = replyService.selectReplyList(commentId); 58 | return new SuccessMessage>("回复评论",replies).getMessage(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/SingerController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.Singer; 6 | import com.example.musicserver.service.Impl.SingerServiceImpl; 7 | import com.example.musicserver.service.SingerService; 8 | import org.apache.ibatis.jdbc.Null; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | import xyz.downgoon.snowflake.Snowflake; 16 | 17 | import java.util.Date; 18 | import java.util.List; 19 | 20 | /** 21 | * @author CCNICE 22 | * @date 2023/4/3 23 | */ 24 | @Controller 25 | @ResponseBody 26 | public class SingerController { 27 | 28 | @Autowired 29 | private SingerServiceImpl singerService; 30 | 31 | static Snowflake snowflake = new Snowflake(1,4); 32 | 33 | 34 | @RequestMapping(value = "/singer/getSingerList", method = RequestMethod.POST) 35 | public String getSingerList(Singer singer) { 36 | 37 | List singerList = singerService.getSingerList(singer); 38 | 39 | return new SuccessMessage>("歌手列表", singerList).getMessage(); 40 | 41 | } 42 | 43 | @RequestMapping(value = "/singer/updateByPrimaryKey", method = RequestMethod.POST) 44 | public String updateByPrimaryKey(Singer singer) { 45 | boolean b = singerService.updateSingerByPrimaryKey(singer); 46 | 47 | if(b) { 48 | return new SuccessMessage("歌手信息更新成功").getMessage(); 49 | } else { 50 | return new ErrorMessage("歌手信息更新失败").getMessage(); 51 | } 52 | } 53 | 54 | @RequestMapping(value = "/singer/addSinger", method = RequestMethod.POST) 55 | public String addSinger(Singer singer) { 56 | 57 | singer.setSingerId(String.valueOf(snowflake.nextId())); 58 | singer.setCreatedTime(new Date().toString()); 59 | 60 | boolean b = singerService.addSinger(singer); 61 | 62 | if (b) { 63 | return new SuccessMessage("歌手信息添加成功").getMessage(); 64 | } else { 65 | return new ErrorMessage("歌手信息添加失败").getMessage(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/SongController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.common.utils.UploadMusic; 6 | import com.example.musicserver.entity.Song; 7 | import com.example.musicserver.service.Impl.SongServiceImpl; 8 | import org.apache.ibatis.jdbc.Null; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.ResponseBody; 14 | import org.springframework.web.multipart.MultipartFile; 15 | import xyz.downgoon.snowflake.Snowflake; 16 | 17 | import java.util.Date; 18 | import java.util.List; 19 | 20 | /** 21 | * @author CCNICE 22 | * @date 2023/4/5 23 | */ 24 | @Controller 25 | @ResponseBody 26 | public class SongController { 27 | 28 | @Autowired 29 | private SongServiceImpl songService; 30 | 31 | static Snowflake snowflake = new Snowflake(1, 5); 32 | static UploadMusic uploadMusic = new UploadMusic(); 33 | 34 | @RequestMapping(value = "/song/addSong", method = RequestMethod.POST) 35 | public String addSong(Song song) { 36 | 37 | song.setSongId(String.valueOf(snowflake.nextId())); 38 | song.setCreatedTime(new Date().toString()); 39 | song.setUpdateTime(new Date().toString()); 40 | boolean b = songService.addSong(song); 41 | 42 | if (b) { 43 | return new SuccessMessage("添加歌曲成功").getMessage(); 44 | } else { 45 | return new ErrorMessage("添加歌曲失败").getMessage(); 46 | } 47 | } 48 | 49 | @RequestMapping(value = "/song/selectSong", method = RequestMethod.POST) 50 | public String selectSong(Song song) { 51 | List songs = songService.selectSong(song); 52 | return new SuccessMessage>("歌曲列表查询成功", songs).getMessage(); 53 | } 54 | 55 | @RequestMapping(value = "/song/updateSong", method = RequestMethod.POST) 56 | public String updateSong(Song song) { 57 | 58 | boolean b = songService.updateSong(song); 59 | 60 | if (b) { 61 | return new SuccessMessage("歌曲信息更新成功").getMessage(); 62 | } else { 63 | return new ErrorMessage("歌曲信息更新失败").getMessage(); 64 | } 65 | } 66 | 67 | @RequestMapping(value = "/song/updateSongFile", method = RequestMethod.POST) 68 | public String updateSongFile(MultipartFile file, Song song) { 69 | 70 | String s = uploadMusic.uploadMusic(file); 71 | song.setUrl(s); 72 | boolean b = songService.updateSong(song); 73 | if (b) { 74 | return new SuccessMessage("音乐上传成功").getMessage(); 75 | } else { 76 | return new ErrorMessage("音乐上传失败").getMessage(); 77 | } 78 | } 79 | 80 | @RequestMapping(value = "/song/getRankingList", method = RequestMethod.POST) 81 | public String getRankingList() { 82 | List songs = songService.selectSongOrderByPhoto(); 83 | 84 | return new SuccessMessage>("排行榜获取成功", songs).getMessage(); 85 | } 86 | 87 | @RequestMapping(value = "/song/updateSongRankingList", method = RequestMethod.POST) 88 | public String updateSongRankingList(Song song) { 89 | 90 | List songs = songService.selectSong(song); 91 | songs.get(0).setPhoto(songs.get(0).getPhoto() + 1); 92 | 93 | boolean b = songService.updateSong(songs.get(0)); 94 | 95 | if (b) { 96 | return new SuccessMessage("歌曲信息更新成功").getMessage(); 97 | } else { 98 | return new ErrorMessage("歌曲信息更新失败").getMessage(); 99 | } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/SongListController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.Song; 6 | import com.example.musicserver.entity.SongList; 7 | import com.example.musicserver.service.Impl.SongListServiceImpl; 8 | import com.example.musicserver.service.Impl.SongServiceImpl; 9 | import org.apache.ibatis.jdbc.Null; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | import xyz.downgoon.snowflake.Snowflake; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Date; 19 | import java.util.List; 20 | 21 | /** 22 | * @author CCNICE 23 | * @date 2023/4/23 24 | */ 25 | @Controller 26 | @ResponseBody 27 | public class SongListController { 28 | 29 | @Autowired 30 | private SongListServiceImpl songListService; 31 | 32 | @Autowired 33 | private SongServiceImpl songService; 34 | 35 | static Snowflake snowflake = new Snowflake(1, 6); 36 | 37 | @RequestMapping(value = "/songList/selectSongList", method = RequestMethod.POST) 38 | public String selectSongList(SongList songList) { 39 | 40 | List songList1 = songListService.getSongList(songList); 41 | 42 | return new SuccessMessage>("列表查询成功", songList1).getMessage(); 43 | } 44 | 45 | @RequestMapping(value = "/songList/addSongList", method = RequestMethod.POST) 46 | public String addSongList(SongList songList) { 47 | 48 | songList.setSongListId(String.valueOf(snowflake.nextId())); 49 | songList.setCreatedTime(new Date().toString()); 50 | 51 | 52 | boolean b = songListService.addSongList(songList); 53 | 54 | if(b) { 55 | return new SuccessMessage("歌单添加成功").getMessage(); 56 | } else { 57 | return new ErrorMessage("歌单添加失败").getMessage(); 58 | } 59 | } 60 | 61 | @RequestMapping(value = "/songList/updateSongList", method = RequestMethod.POST) 62 | public String updateSongList(SongList songList) { 63 | 64 | boolean b = songListService.updateSongListByPrimaryKey(songList); 65 | 66 | if(b) { 67 | return new SuccessMessage("歌单信息更新成功").getMessage(); 68 | } else { 69 | return new ErrorMessage("歌单信息更新失败").getMessage(); 70 | } 71 | } 72 | 73 | @RequestMapping(value = "/songList/getSongListMusic", method = RequestMethod.POST) 74 | public String getSongListMusic(SongList songList) { 75 | 76 | List songList1 = songListService.getSongList(songList); 77 | 78 | if(songList1.size() > 0) { 79 | String songIdListStr = songList1.get(0).getSongIdList(); 80 | String[] songIdListArr = songIdListStr.split(","); 81 | List ansSongList = new ArrayList<>(); 82 | Song song = new Song(); 83 | if(songIdListArr.length > 0) { 84 | for (int i = 0; i < songIdListArr.length; i++) { 85 | song.setSongId(songIdListArr[i]); 86 | List songs = songService.selectSong(song); 87 | ansSongList.add(songs.get(0)); 88 | } 89 | return new SuccessMessage>("查询成功", ansSongList).getMessage(); 90 | } else { 91 | return new ErrorMessage("未查询到结果").getMessage(); 92 | } 93 | } else { 94 | return new ErrorMessage("未查询到结果").getMessage(); 95 | } 96 | } 97 | 98 | @RequestMapping(value = "/songList/addSong", method = RequestMethod.POST) 99 | public String addSong(Song song) { 100 | 101 | SongList songList = new SongList(); 102 | 103 | //此处的song.getName的值是songListId 104 | songList.setSongListId(song.getName()); 105 | List songList1 = songListService.getSongList(songList); 106 | if(songList1.get(0).getSongIdList() == null || songList1.get(0).getSongIdList().equals("")) { 107 | songList.setSongIdList(song.getSongId()); 108 | } else { 109 | songList.setSongIdList(songList1.get(0).getSongIdList() + "," + song.getSongId()); 110 | } 111 | boolean b = songListService.updateSongListByPrimaryKey(songList); 112 | 113 | if(b) { 114 | return new SuccessMessage("添加成功").getMessage(); 115 | } else { 116 | return new ErrorMessage("添加歌曲错误").getMessage(); 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.common.utils.UploadImage; 6 | import com.example.musicserver.entity.Singer; 7 | import com.example.musicserver.entity.Song; 8 | import com.example.musicserver.entity.SongList; 9 | import com.example.musicserver.entity.UserData; 10 | import com.example.musicserver.service.Impl.SingerServiceImpl; 11 | import com.example.musicserver.service.Impl.SongListServiceImpl; 12 | import com.example.musicserver.service.Impl.SongServiceImpl; 13 | import com.example.musicserver.service.Impl.UserDataServiceImpl; 14 | import org.apache.ibatis.jdbc.Null; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Controller; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RequestMethod; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | import org.springframework.web.multipart.MultipartFile; 21 | 22 | import java.io.IOException; 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * @author CCNICE 28 | * @date 2023/4/3 29 | */ 30 | @Controller 31 | @ResponseBody 32 | public class UploadController { 33 | @Autowired 34 | private SingerServiceImpl singerService; 35 | 36 | @Autowired 37 | private UserDataServiceImpl userDataService; 38 | 39 | @Autowired 40 | private SongListServiceImpl songListService; 41 | 42 | @RequestMapping(value = "upload/SingerImage", method = RequestMethod.POST) 43 | public String uploadSingerImage(MultipartFile file, Singer singer) throws IOException { 44 | //调用图片上传工具类 45 | UploadImage uploadImage = new UploadImage(); 46 | String s = uploadImage.uploadImage(file); 47 | 48 | Singer singer1 = new Singer(); 49 | singer1.setSingerId(singer.getSingerId()); 50 | singer1.setPhoto(s); 51 | 52 | singerService.updateSingerByPrimaryKey(singer1); 53 | 54 | return new SuccessMessage("图片上传成功").getMessage(); 55 | } 56 | 57 | @RequestMapping(value = "upload/SongListImage", method = RequestMethod.POST) 58 | public String uploadSongListImage(MultipartFile file, SongList songList) throws IOException { 59 | //调用图片上传工具类 60 | UploadImage uploadImage = new UploadImage(); 61 | String s = uploadImage.uploadImage(file); 62 | 63 | SongList songList1 = new SongList(); 64 | songList1.setSongListId(songList.getSongListId()); 65 | songList1.setPhoto(s); 66 | 67 | songListService.updateSongListByPrimaryKey(songList1); 68 | 69 | return new SuccessMessage("图片上传成功").getMessage(); 70 | } 71 | 72 | @RequestMapping(value = "/upload/userDataImage", method = RequestMethod.POST) 73 | public String userDataImage(MultipartFile file, UserData userData) throws IOException { 74 | //调用图片上传工具类 75 | UploadImage uploadImage = new UploadImage(); 76 | String s = uploadImage.uploadImage(file); 77 | UserData userData1 = new UserData(); 78 | userData1.setUserId(userData.getUserId()); 79 | userData1.setPhoto(s); 80 | 81 | userDataService.updateUserData(userData1); 82 | 83 | return new SuccessMessage("图片上传成功").getMessage(); 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/UserDataController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.UserData; 6 | import com.example.musicserver.service.Impl.UserDataServiceImpl; 7 | import org.apache.ibatis.jdbc.Null; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import xyz.downgoon.snowflake.Snowflake; 14 | 15 | import java.util.Date; 16 | import java.util.List; 17 | 18 | /** 19 | * @author CCNICE 20 | * @date 2023/4/2 21 | */ 22 | @Controller 23 | @ResponseBody 24 | public class UserDataController { 25 | 26 | @Autowired 27 | private UserDataServiceImpl userDataService; 28 | 29 | static Snowflake snowflake = new Snowflake(1,7); 30 | 31 | @RequestMapping(value = "/userData/getUserList", method = RequestMethod.POST) 32 | public String getUserList(UserData userData) { 33 | 34 | List userDataList = userDataService.getUserDataList(userData); 35 | 36 | return new SuccessMessage>("用户列表", userDataList).getMessage(); 37 | } 38 | 39 | @RequestMapping(value = "/userData/addUserData", method = RequestMethod.POST) 40 | public String addUserData(UserData userData) { 41 | 42 | boolean b = userDataService.verifyUserName(userData); 43 | 44 | if (b) { 45 | 46 | return new ErrorMessage("该用户名已被注册").getMessage(); 47 | } else { 48 | 49 | userData.setUserId(String.valueOf(snowflake.nextId())); 50 | userData.setCreatedTime(new Date().toString()); 51 | userData.setUpdateTime(new Date().toString()); 52 | 53 | boolean b1 = userDataService.addUserData(userData); 54 | if(b1) { 55 | return new SuccessMessage("注册成功").getMessage(); 56 | } else { 57 | return new ErrorMessage("注册失败").getMessage(); 58 | } 59 | } 60 | } 61 | 62 | @RequestMapping(value = "/userData/userLogin", method = RequestMethod.POST) 63 | public String userLogin(UserData userData) { 64 | 65 | boolean b = userDataService.verifyUserPassword(userData); 66 | 67 | if (b) { 68 | 69 | List userDataList = userDataService.getUserDataList(userData); 70 | 71 | return new SuccessMessage>("登录成功", userDataList).getMessage(); 72 | } else { 73 | return new ErrorMessage("登录失败").getMessage(); 74 | } 75 | } 76 | 77 | @RequestMapping(value = "/userData/updateUserData", method = RequestMethod.POST) 78 | public String updateUserData(UserData userData) { 79 | userData.setUpdateTime(new Date().toString()); 80 | userDataService.updateUserData(userData); 81 | return new SuccessMessage("更新成功").getMessage(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/controller/UserSongListController.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.controller; 2 | 3 | import com.example.musicserver.common.net.ErrorMessage; 4 | import com.example.musicserver.common.net.SuccessMessage; 5 | import com.example.musicserver.entity.Song; 6 | import com.example.musicserver.entity.UserSongList; 7 | import com.example.musicserver.service.Impl.SongServiceImpl; 8 | import com.example.musicserver.service.Impl.UserSongListServiceImpl; 9 | import org.apache.ibatis.jdbc.Null; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | import xyz.downgoon.snowflake.Snowflake; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Date; 19 | import java.util.List; 20 | 21 | /** 22 | * @author CCNICE 23 | * @date 2023/5/8 24 | */ 25 | @Controller 26 | @ResponseBody 27 | public class UserSongListController { 28 | 29 | @Autowired 30 | private UserSongListServiceImpl userSongListService; 31 | 32 | @Autowired 33 | private SongServiceImpl songService; 34 | 35 | static Snowflake snowflake = new Snowflake(1, 8); 36 | 37 | 38 | @RequestMapping(value = "/userSongList/getUserSongList", method = RequestMethod.POST) 39 | public String getUserSongList(UserSongList userSongList) { 40 | 41 | List userSongLists = userSongListService.selectUserSongList(userSongList); 42 | 43 | return new SuccessMessage>("查询用户歌单成功", userSongLists).getMessage(); 44 | } 45 | 46 | @RequestMapping(value = "/userSongList/getSongList", method = RequestMethod.POST) 47 | public String getSongList(UserSongList userSongList0) { 48 | UserSongList userSongList = new UserSongList(); 49 | userSongList.setUserSongListId(userSongList0.getUserSongListId()); 50 | List userSongLists = userSongListService.selectUserSongList(userSongList); 51 | List songs = new ArrayList<>(); 52 | 53 | if (userSongLists.get(0).getSongIdList() != null) { 54 | String[] arr = userSongLists.get(0).getSongIdList().split(","); 55 | Song song = new Song(); 56 | for (String s: arr) { 57 | if (s.equals("")) { 58 | continue; 59 | } 60 | song.setSongId(s); 61 | List songs1 = songService.selectSong(song); 62 | songs.add(songs1.get(0)); 63 | } 64 | } 65 | 66 | return new SuccessMessage>("查询成功", songs).getMessage(); 67 | } 68 | 69 | @RequestMapping(value = "/userSongList/addUserSongLit", method = RequestMethod.POST) 70 | public String addUserSongList(UserSongList userSongList) { 71 | 72 | userSongList.setUserSongListId(String.valueOf(snowflake.nextId())); 73 | userSongList.setCreatedTime(new Date().toString()); 74 | 75 | boolean b = userSongListService.addUserSongList(userSongList); 76 | 77 | if (b) { 78 | return new SuccessMessage("添加用户歌单成功").getMessage(); 79 | } else { 80 | return new ErrorMessage("添加用户歌单失败").getMessage(); 81 | } 82 | } 83 | 84 | @RequestMapping(value = "/userSongList/updateUserSongList", method = RequestMethod.POST) 85 | public String updateUserSongList(UserSongList userSongList) { 86 | 87 | System.out.println(userSongList); 88 | UserSongList userSongList1 = new UserSongList(); 89 | if (userSongList.getSongIdList() == null || userSongList.getSongIdList().equals("")) { 90 | userSongList1.setUserSongListId(userSongList.getUserSongListId()); 91 | userSongList1.setSongIdList(userSongList.getCreatedTime()); 92 | userSongListService.updateUserSongList(userSongList1); 93 | } else { 94 | userSongListService.updateUserSongList(userSongList); 95 | } 96 | 97 | UserSongList userSongList2 = new UserSongList(); 98 | userSongList2.setUserId(userSongList.getUserId()); 99 | List userSongLists = userSongListService.selectUserSongList(userSongList2); 100 | 101 | return new SuccessMessage>("添加成功", userSongLists).getMessage(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/AdminMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Admin; 4 | import com.example.musicserver.entity.Song; 5 | import com.example.musicserver.entity.UserData; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | @Repository 13 | public interface AdminMapper { 14 | 15 | //查询全部admin信息 16 | List queryAll(); 17 | 18 | //增加admin信息 19 | int insert(Admin admin); 20 | 21 | //根据主键查询admin信息 22 | List selectByPrimaryKey(String adminId); 23 | 24 | //根据主键更新admin信息 25 | int updateByPrimaryKey(Admin admin); 26 | 27 | //根据主键删除admin信息 28 | int deleteByPrimaryKey(String adminId); 29 | 30 | //验证密码 31 | int verifyPassword(String name, String password); 32 | 33 | //查询总注册用户与近一个月注册用户 34 | List selectUserCount(); 35 | 36 | //查询各个性别人数和未设置性别的人数 37 | List selectGenderCounter(); 38 | 39 | //查询前十的歌曲播放数量 40 | List selectPlayNum(); 41 | } 42 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/CommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Comment; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface CommentMapper { 16 | 17 | //根据主键删除评论 18 | int deletePrimaryKey(String commentId); 19 | 20 | //增加评论 21 | int insert(Comment comment); 22 | 23 | //根据主键查询评论 24 | List selectByPrimaryKey(String commentId); 25 | 26 | 27 | //查询评论 28 | List selectCommentList(Comment comment); 29 | } 30 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/ReplyMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Reply; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface ReplyMapper { 16 | 17 | //增加回复评论 18 | int insert(Reply reply); 19 | 20 | //根据主键删除评论 21 | int deleteByPrimaryKey(String replyId); 22 | 23 | //根据评论ID查询回复评论 24 | List selectReplyByCommentId(String commentId); 25 | } 26 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/SingerMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Singer; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface SingerMapper { 16 | 17 | //增加歌手信息 18 | int insert(Singer singer); 19 | 20 | //根据主键更新歌手信息 21 | int updateSingerByPrimaryKey(Singer singer); 22 | 23 | //根据主键删除歌手信息 24 | int deleteSingerByPrimaryKey(String singerId); 25 | 26 | //根据主键查询歌手信息 27 | List selectSinger(Singer singer); 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/SongListMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.SongList; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface SongListMapper { 16 | 17 | //增加歌单信息 18 | int insert(SongList songList); 19 | 20 | //删除歌单信息 21 | int deleteByPrimaryKey(String songListId); 22 | 23 | //更新歌单信息 24 | int updateByPrimaryKey(SongList songList); 25 | 26 | //查找歌单信息 27 | List selectSongList(SongList songList); 28 | } 29 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/SongMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Song; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/14 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface SongMapper { 16 | 17 | //增加歌曲信息 18 | int insert(Song song); 19 | 20 | //删除歌曲信息 21 | int deleteByPrimaryKey(String songId); 22 | 23 | //更新歌曲信息 24 | int updateByPrimaryKey(Song song); 25 | 26 | //查询歌曲信息 27 | List selectSong(Song song); 28 | 29 | //查询歌曲播放排名根据播放次数 30 | List selectSongOrderByPhoto(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/UserDataMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.UserData; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface UserDataMapper { 16 | 17 | //增加用户 18 | int insert(UserData userData); 19 | 20 | //删除用户 21 | int deleteByPrimaryKey(String userId); 22 | 23 | //更新用户 24 | int updateByPrimaryKey(UserData userData); 25 | 26 | //查找用户 27 | List selectUserData(UserData userData); 28 | 29 | //查看该用户名是否已被注册 30 | int verifyUserName(UserData userData); 31 | 32 | //验证用户名和密码 33 | int verifyUserPassword(UserData userData); 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/dao/UserSongListMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.UserSongList; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ChengJianhong 11 | * @date 2023/3/17 12 | */ 13 | @Mapper 14 | @Repository 15 | public interface UserSongListMapper { 16 | 17 | //创建用户歌单 18 | int insert(UserSongList userSongList); 19 | 20 | //删除用户歌单 21 | int deleteByPrimaryKey(String userSongListId); 22 | 23 | //更新用户歌单 24 | int updateByPrimaryKey(UserSongList userSongList); 25 | 26 | //查找用户歌单 27 | List selectUserSongList(UserSongList userSongList); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/Admin.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | 11 | //管理员表 12 | public class Admin { 13 | private String adminId; 14 | private String name; 15 | private String password; 16 | } 17 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/Comment.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | 15 | //歌曲评论 16 | public class Comment { 17 | 18 | private String commentId; //评论ID 19 | private String userId; //用户ID 20 | private String songId; //歌曲ID 21 | private String songListId; //歌单ID 22 | private String type; //区分是歌单评论(1)还是歌曲评论(0) 23 | private Integer stars; //评论点赞数 24 | private String content; //评论内容 25 | private String createdTime; //评论时间 26 | 27 | } 28 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/Reply.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | 15 | //评论回复 16 | public class Reply { 17 | 18 | private String replyId; //回复评论ID 19 | private String commentId; //评论ID 20 | private String userId; //回复用户ID 21 | private String content; //回复内容 22 | private String createdTime; //回复时间 23 | 24 | } 25 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/Singer.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | //歌手表 15 | public class Singer { 16 | 17 | private String singerId; //歌手ID 18 | private String name; //歌手姓名 19 | private String gender; //歌手性别 20 | private String photo; //歌手图片 21 | private String birth; //歌手出生日期 22 | private String location; //歌手地区 23 | private String introduction; //歌手介绍 24 | private String createdTime; //创建时间 25 | } 26 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/Song.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/14 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | 15 | //歌曲表 16 | public class Song { 17 | 18 | private String songId; //歌曲id 19 | private String singerId; //歌手ID 20 | private String singer; //歌手名字 21 | private String name; //歌曲名 22 | private String album; //专辑名 23 | private String lyric; //歌词 24 | private String url; //歌曲地址 25 | private int photo; //歌曲图片 26 | private String createdTime; //创建时间 27 | private String updateTime; //更新时间 28 | } 29 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/SongList.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | //歌单列表 15 | public class SongList { 16 | 17 | private String songListId; //歌单ID 18 | private String songIdList; //歌曲ID列表 19 | private String name; //歌单名 20 | private String photo; //歌单封面 21 | private String introduction; //歌单介绍 22 | private String style; //歌单风格 23 | private String createdTime; //创建时间 24 | } 25 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/UserData.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | 15 | //用户信息表 16 | public class UserData { 17 | 18 | private String userId; //用户ID 19 | private String name; //用户名 20 | private String password; //用户密码 21 | private String gender; //用户性别 22 | private String introduction; //用户介绍 23 | private String birth; //用户生日 24 | private String location; //用户家乡 25 | private String photo; //用户头像 26 | private String createdTime; //注册时间 27 | private String updateTime; //修改时间 28 | 29 | private String totalUsers; 30 | private String recentUsers; 31 | private String genderCount; 32 | } 33 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/entity/UserSongList.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author ChengJianhong 9 | * @date 2023/3/15 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | //用户歌单 15 | public class UserSongList { 16 | 17 | private String userSongListId; //用户歌单ID 18 | private String userId; //用户ID 19 | private String songIdList; //歌曲ID列表 20 | private String name; //用户歌单名 21 | private String photo; //用户歌单图片 22 | private String introduction; //用户歌单介绍 23 | private String createdTime; //创建时间 24 | 25 | } 26 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | /** 4 | * @Author CCNICE 5 | * @Date 2023/3/26 6 | */ 7 | public interface AdminService { 8 | 9 | //验证admin用户和密码 10 | boolean verifyAdminPassword(String name, String password); 11 | } 12 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.Comment; 4 | import com.example.musicserver.service.Impl.CommentServiceImpl; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @Author CCNICE 10 | * @Date 2023/3/26 11 | */ 12 | public interface CommentService { 13 | 14 | boolean commentAdd(Comment comment); 15 | 16 | boolean deleteComment(String commentId); 17 | 18 | List selectCommentBySongId(Comment comment); 19 | 20 | List selectCommentBySongListId(Comment comment); 21 | } 22 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/AdminServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.AdminMapper; 4 | import com.example.musicserver.service.AdminService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | /** 10 | * @Author CCNICE 11 | * @Date 2023/3/26 12 | */ 13 | @Service 14 | public class AdminServiceImpl implements AdminService { 15 | 16 | @Autowired 17 | private AdminMapper adminMapper; 18 | 19 | static Snowflake snowflake = new Snowflake(1,1); 20 | 21 | @Override 22 | public boolean verifyAdminPassword(String name, String password) { 23 | return adminMapper.verifyPassword(name, password) > 0; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/CommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.CommentMapper; 4 | import com.example.musicserver.entity.Comment; 5 | import com.example.musicserver.service.CommentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class CommentServiceImpl implements CommentService { 18 | 19 | @Autowired 20 | private CommentMapper commentMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,2); 23 | 24 | @Override 25 | public boolean commentAdd(Comment comment) { 26 | return commentMapper.insert(comment) > 0; 27 | } 28 | 29 | @Override 30 | public boolean deleteComment(String commentId) { 31 | return commentMapper.deletePrimaryKey(commentId) > 0; 32 | } 33 | 34 | @Override 35 | public List selectCommentBySongId(Comment comment) { 36 | return commentMapper.selectCommentList(comment); 37 | } 38 | 39 | @Override 40 | public List selectCommentBySongListId(Comment comment) { 41 | return commentMapper.selectCommentList(comment); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/ReplyServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.ReplyMapper; 4 | import com.example.musicserver.entity.Reply; 5 | import com.example.musicserver.service.ReplyService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class ReplyServiceImpl implements ReplyService { 18 | 19 | @Autowired 20 | private ReplyMapper replyMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,3); 23 | 24 | @Override 25 | public boolean replyAdd(Reply reply) { 26 | return replyMapper.insert(reply) > 0; 27 | } 28 | 29 | @Override 30 | public boolean deleteReplyByPrimaryKey(String replyId) { 31 | return replyMapper.deleteByPrimaryKey(replyId) > 0; 32 | } 33 | 34 | @Override 35 | public List selectReplyList(String commentId) { 36 | return replyMapper.selectReplyByCommentId(commentId); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/SingerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.SingerMapper; 4 | import com.example.musicserver.entity.Singer; 5 | import com.example.musicserver.service.SingerService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class SingerServiceImpl implements SingerService { 18 | 19 | @Autowired 20 | private SingerMapper singerMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,4); 23 | 24 | //查找singer 信息 25 | @Override 26 | public List getSingerList(Singer singer) { 27 | return singerMapper.selectSinger(singer); 28 | } 29 | 30 | //添加singer信息 31 | @Override 32 | public boolean addSinger(Singer singer) { 33 | return singerMapper.insert(singer) > 0; 34 | } 35 | 36 | //根据组件更新singer信息 37 | @Override 38 | public boolean updateSingerByPrimaryKey(Singer singer) { 39 | return singerMapper.updateSingerByPrimaryKey(singer) > 0; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/SongListServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.SongListMapper; 4 | import com.example.musicserver.entity.SongList; 5 | import com.example.musicserver.service.SongListService; 6 | import com.example.musicserver.service.SongService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import xyz.downgoon.snowflake.Snowflake; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @Author CCNICE 15 | * @Date 2023/3/26 16 | */ 17 | @Service 18 | public class SongListServiceImpl implements SongListService { 19 | 20 | @Autowired 21 | private SongListMapper songListMapper; 22 | 23 | static Snowflake snowflake = new Snowflake(1,5); 24 | 25 | @Override 26 | public List getSongList(SongList songList) { 27 | return songListMapper.selectSongList(songList); 28 | } 29 | 30 | @Override 31 | public boolean addSongList(SongList songList) { 32 | return songListMapper.insert(songList) > 0; 33 | } 34 | 35 | @Override 36 | public boolean updateSongListByPrimaryKey(SongList songList) { 37 | return songListMapper.updateByPrimaryKey(songList) > 0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/SongServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.SongMapper; 4 | import com.example.musicserver.entity.Song; 5 | import com.example.musicserver.service.SongService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class SongServiceImpl implements SongService { 18 | 19 | @Autowired 20 | private SongMapper songMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,6); 23 | 24 | @Override 25 | public List selectSongOrderByPhoto() { 26 | return songMapper.selectSongOrderByPhoto(); 27 | } 28 | 29 | //添加歌曲 30 | @Override 31 | public boolean addSong(Song song) { 32 | return songMapper.insert(song) > 0; 33 | } 34 | 35 | //查询歌曲 36 | @Override 37 | public List selectSong(Song song) { 38 | return songMapper.selectSong(song); 39 | } 40 | 41 | //更新歌曲 42 | @Override 43 | public boolean updateSong(Song song) { 44 | return songMapper.updateByPrimaryKey(song) > 0; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/UserDataServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.UserDataMapper; 4 | import com.example.musicserver.entity.UserData; 5 | import com.example.musicserver.service.UserDataService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class UserDataServiceImpl implements UserDataService { 18 | 19 | @Autowired 20 | private UserDataMapper userDataMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,7); 23 | 24 | 25 | @Override 26 | public List getUserDataList(UserData userData) { 27 | return userDataMapper.selectUserData(userData); 28 | } 29 | 30 | @Override 31 | public boolean addUserData(UserData userData) { 32 | return userDataMapper.insert(userData) > 0; 33 | } 34 | 35 | @Override 36 | public boolean verifyUserName(UserData userData) { 37 | return userDataMapper.verifyUserName(userData) > 0; 38 | } 39 | 40 | @Override 41 | public boolean updateUserData(UserData userData) { 42 | return userDataMapper.updateByPrimaryKey(userData) > 0; 43 | } 44 | 45 | //验证用户名和密码 46 | @Override 47 | public boolean verifyUserPassword(UserData userData) { 48 | return userDataMapper.verifyUserPassword(userData) > 0; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/Impl/UserSongListServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service.Impl; 2 | 3 | import com.example.musicserver.dao.UserSongListMapper; 4 | import com.example.musicserver.entity.UserSongList; 5 | import com.example.musicserver.service.UserSongListService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import xyz.downgoon.snowflake.Snowflake; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/26 15 | */ 16 | @Service 17 | public class UserSongListServiceImpl implements UserSongListService { 18 | 19 | @Autowired 20 | private UserSongListMapper userSongListMapper; 21 | 22 | static Snowflake snowflake = new Snowflake(1,8); 23 | 24 | 25 | @Override 26 | public boolean addUserSongList(UserSongList userSongList) { 27 | return userSongListMapper.insert(userSongList) > 0; 28 | } 29 | 30 | @Override 31 | public boolean deleteUserSongList(UserSongList userSongList) { 32 | return userSongListMapper.deleteByPrimaryKey(userSongList.getUserSongListId()) > 0; 33 | } 34 | 35 | @Override 36 | public boolean updateUserSongList(UserSongList userSongList) { 37 | return userSongListMapper.updateByPrimaryKey(userSongList) > 0; 38 | } 39 | 40 | @Override 41 | public List selectUserSongList(UserSongList userSongList) { 42 | return userSongListMapper.selectUserSongList(userSongList); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/ReplyService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.Reply; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public interface ReplyService { 12 | 13 | boolean replyAdd(Reply reply); 14 | 15 | boolean deleteReplyByPrimaryKey(String replyId); 16 | 17 | List selectReplyList(String commentId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/SingerService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.Singer; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public interface SingerService { 12 | 13 | List getSingerList(Singer singer); 14 | 15 | boolean addSinger(Singer singer); 16 | 17 | boolean updateSingerByPrimaryKey(Singer singer); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/SongListService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.SongList; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public interface SongListService { 12 | 13 | //查询歌单 14 | List getSongList(SongList songList); 15 | 16 | //添加歌单 17 | boolean addSongList(SongList songList); 18 | 19 | //更新歌单 20 | boolean updateSongListByPrimaryKey(SongList songList); 21 | } 22 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/SongService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.Song; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public interface SongService { 12 | 13 | boolean addSong(Song song); 14 | 15 | List selectSong(Song song); 16 | 17 | boolean updateSong(Song song); 18 | 19 | List selectSongOrderByPhoto(); 20 | } 21 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/UserDataService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.UserData; 4 | import org.springframework.boot.autoconfigure.security.SecurityProperties; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @Author CCNICE 10 | * @Date 2023/3/26 11 | */ 12 | public interface UserDataService { 13 | 14 | boolean verifyUserPassword(UserData userData); 15 | 16 | List getUserDataList(UserData userData); 17 | 18 | boolean addUserData(UserData userData); 19 | 20 | boolean verifyUserName(UserData userData); 21 | 22 | boolean updateUserData(UserData userData); 23 | } 24 | -------------------------------------------------------------------------------- /musicServer/src/main/java/com/example/musicserver/service/UserSongListService.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.service; 2 | 3 | import com.example.musicserver.entity.UserSongList; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Author CCNICE 9 | * @Date 2023/3/26 10 | */ 11 | public interface UserSongListService { 12 | 13 | boolean addUserSongList(UserSongList userSongList); 14 | 15 | boolean deleteUserSongList(UserSongList userSongList); 16 | 17 | boolean updateUserSongList(UserSongList userSongList); 18 | 19 | List selectUserSongList(UserSongList userSongList); 20 | } 21 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:mysql://localhost:3306/music?serverTimezone=Asia/Shanghai 4 | username: root 5 | password: 12345678 6 | driver-class-name: com.mysql.cj.jdbc.Driver 7 | application: 8 | name: musicserver 9 | devtools: 10 | restart: 11 | enabled: true 12 | additional-paths: src/main/java 13 | # 设置文件上传最大限制 14 | servlet: 15 | multipart: 16 | # 单个文件上传最大限制 17 | max-file-size: 100MB 18 | # 总文件大小限制 19 | max-request-size: 2000MB 20 | server: 21 | port: 9999 22 | 23 | 24 | mybatis: 25 | mapper-locations: classpath:mapper/*.xml 26 | type-aliases-package: com.example.musicserver.entity 27 | configuration: 28 | map-underscore-to-camel-case: true 29 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/AdminMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | insert into admin(admin_id,name,password) values (#{adminId,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR}) 14 | 15 | 16 | 17 | update admin set name = #{name,jdbcType=VARCHAR}, 18 | password = #{password,jdbcType=VARCHAR} 19 | where admin_id = #{adminId,jdbcType=VARCHAR} 20 | 21 | 22 | 23 | 24 | 25 | delete from admin where admin_id = #{adminId,jdbcType=VARCHAR} 26 | 27 | 28 | 29 | 32 | 33 | 34 | 39 | 40 | 41 | 44 | 45 | 46 | 51 | 52 | 55 | 56 | 57 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/CommentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | insert into comment(comment_id, user_id, song_id, song_list_id, content, stars, type, created_time) 7 | values (#{commentId,jdbcType=VARCHAR}, 8 | #{userId,jdbcType=VARCHAR}, 9 | #{songId,jdbcType=VARCHAR}, 10 | #{songListId,jdbcType=VARCHAR}, 11 | #{content,jdbcType=VARCHAR}, 12 | #{stars,jdbcType=INTEGER}, 13 | #{type,jdbcType=VARCHAR}, 14 | #{createdTime,jdbcType=VARCHAR}) 15 | 16 | 17 | 18 | 19 | delete from comment where comment_id = #{commentId} 20 | 21 | 22 | 23 | 28 | 29 | 30 | 34 | 35 | 36 | 40 | 41 | 42 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/ReplyMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into reply(reply_id, comment_id, user_id, content, created_time) 10 | values (#{replyId,jdbcType=VARCHAR}, 11 | #{commentId,jdbcType=VARCHAR}, 12 | #{userId,jdbcType=VARCHAR}, 13 | #{content,jdbcType=VARCHAR}, 14 | #{createdTime,jdbcType=VARCHAR}) 15 | 16 | 17 | 18 | 19 | delete from reply where reply_id = #{replyId,jdbcType=VARCHAR} 20 | 21 | 22 | 23 | 27 | 28 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/SingerMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | insert into singer(singer_id, name, gender, photo, birth, location, introduction, created_time) 9 | values (#{singerId,jdbcType=VARCHAR}, 10 | #{name,jdbcType=VARCHAR}, 11 | #{gender,jdbcType=VARCHAR}, 12 | #{photo,jdbcType=VARCHAR}, 13 | #{birth,jdbcType=VARCHAR}, 14 | #{location,jdbcType=VARCHAR}, 15 | #{introduction,jdbcType=VARCHAR}, 16 | #{createdTime,jdbcType=VARCHAR}) 17 | 18 | 19 | 20 | 21 | update singer 22 | 23 | 24 | name = #{name,jdbcType=VARCHAR}, 25 | 26 | 27 | gender = #{gender,jdbcType=VARCHAR}, 28 | 29 | 30 | photo = #{photo,jdbcType=VARCHAR}, 31 | 32 | 33 | birth = #{birth,jdbcType=VARCHAR}, 34 | 35 | 36 | location = #{location,jdbcType=VARCHAR}, 37 | 38 | 39 | introduction = #{introduction,jdbcType=VARCHAR}, 40 | 41 | 42 | where singer_id = #{singerId,jdbcType=VARCHAR} 43 | 44 | 45 | 46 | 47 | delete from singer where singer_id = #{singerId} 48 | 49 | 50 | 51 | 62 | 63 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/SongListMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into song_list(song_list_id, song_id_list, name, photo, introduction, style, created_time) 10 | values (#{songListId,jdbcType=VARCHAR}, 11 | #{songIdList,jdbcType=VARCHAR}, 12 | #{name,jdbcType=VARCHAR}, 13 | #{photo,jdbcType=VARCHAR}, 14 | #{introduction,jdbcType=VARCHAR}, 15 | #{style,jdbcType=VARCHAR}, 16 | #{createdTime,jdbcType=VARCHAR}) 17 | 18 | 19 | 20 | 21 | update song_list 22 | 23 | 24 | song_id_list = #{songIdList,jdbcType=VARCHAR}, 25 | 26 | 27 | name = #{name,jdbcType=VARCHAR}, 28 | 29 | 30 | introduction = #{introduction,jdbcType=VARCHAR}, 31 | 32 | 33 | photo = #{photo,jdbcType=VARCHAR}, 34 | 35 | 36 | style = #{style,jdbcType=VARCHAR}, 37 | 38 | 39 | where song_list_id = #{songListId,jdbcType=VARCHAR} 40 | 41 | 42 | 43 | 44 | delete from song_list where song_list_id = #{songListId,jdbcType=VARCHAR} 45 | 46 | 47 | 48 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/SongMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into song(song_id, singer_id, name, album, lyric, url, photo, created_time, update_time) 10 | values (#{songId,jdbcType=VARCHAR}, 11 | #{singerId,jdbcType=VARCHAR}, 12 | #{name,jdbcType=VARCHAR}, 13 | #{album,jdbcType=VARCHAR}, 14 | #{lyric,jdbcType=VARCHAR}, 15 | #{url,jdbcType=VARCHAR}, 16 | #{photo,jdbcType=VARCHAR}, 17 | #{createdTime,jdbcType=VARCHAR}, 18 | #{updateTime,jdbcType=VARCHAR}) 19 | 20 | 21 | 22 | 23 | update song 24 | 25 | 26 | singer_id = #{singerId,jdbcType=VARCHAR}, 27 | 28 | 29 | name = #{name,jdbcType=VARCHAR}, 30 | 31 | 32 | album = #{album,jdbcType=VARCHAR}, 33 | 34 | 35 | photo = #{photo,jdbcType=VARCHAR}, 36 | 37 | 38 | lyric = #{lyric,jdbcType=VARCHAR}, 39 | 40 | 41 | url = #{url,jdbcType=VARCHAR}, 42 | 43 | 44 | update_time = #{updateTime,jdbcType=VARCHAR}, 45 | 46 | 47 | where song_id = #{songId,jdbcType=VARCHAR} 48 | 49 | 50 | 51 | 52 | delete from song where song_id = #{songId,jdbcType=VARCHAR} 53 | 54 | 55 | 56 | 77 | 78 | 79 | 89 | 90 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/UserDataMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into user_data(user_id, name, password, gender, birth, location, photo, introduction, created_time, update_time) 10 | values (#{userId,jdbcType=VARCHAR}, 11 | #{name,jdbcType=VARCHAR}, 12 | #{password,jdbcType=VARCHAR}, 13 | #{gender,jdbcType=VARCHAR}, 14 | #{birth,jdbcType=VARCHAR}, 15 | #{location,jdbcType=VARCHAR}, 16 | #{photo,jdbcType=VARCHAR}, 17 | #{introduction,jdbcType=VARCHAR}, 18 | #{createdTime,jdbcType=VARCHAR}, 19 | #{updateTime,jdbcType=VARCHAR}) 20 | 21 | 22 | 23 | 24 | update user_data 25 | 26 | 27 | name = #{name,jdbcType=VARCHAR}, 28 | 29 | 30 | password = #{password,jdbcType=VARCHAR}, 31 | 32 | 33 | gender = #{gender,jdbcType=VARCHAR}, 34 | 35 | 36 | photo = #{photo,jdbcType=VARCHAR}, 37 | 38 | 39 | birth = #{birth,jdbcType=VARCHAR}, 40 | 41 | 42 | location = #{location,jdbcType=VARCHAR}, 43 | 44 | 45 | introduction = #{introduction,jdbcType=VARCHAR}, 46 | 47 | 48 | update_time = #{updateTime,jdbcType=VARCHAR}, 49 | 50 | 51 | where user_id = #{userId,jdbcType=VARCHAR} 52 | 53 | 54 | 55 | 56 | delete from user_data where user_id = #{userId,jdbcType=VARCHAR} 57 | 58 | 59 | 60 | 74 | 75 | 76 | 79 | 80 | 81 | 84 | 85 | -------------------------------------------------------------------------------- /musicServer/src/main/resources/mapper/UserSongListMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into user_song_list(user_song_list_id, user_id, song_id_list, name, photo, introduction, created_time) 10 | values (#{userSongListId,jdbcType=VARCHAR}, 11 | #{userId,jdbcType=VARCHAR}, 12 | #{songIdList,jdbcType=VARCHAR}, 13 | #{name,jdbcType=VARCHAR}, 14 | #{photo,jdbcType=VARCHAR}, 15 | #{introduction,jdbcType=VARCHAR}, 16 | #{createdTime,jdbcType=VARCHAR}) 17 | 18 | 19 | 20 | 21 | update user_song_list 22 | 23 | 24 | song_id_list = #{songIdList,jdbcType=VARCHAR}, 25 | 26 | 27 | name = #{name,jdbcType=VARCHAR}, 28 | 29 | 30 | photo = #{photo,jdbcType=VARCHAR}, 31 | 32 | 33 | where user_song_list_id = #{userSongListId,jdbcType=VARCHAR} 34 | 35 | 36 | 37 | 38 | delete from user_song_list where user_song_list_id = #{userSongListId,jdbcType=VARCHAR} 39 | 40 | 41 | 42 | 56 | 57 | -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/MusicServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver; 2 | 3 | import com.example.musicserver.dao.AdminMapper; 4 | import com.example.musicserver.dao.CommentMapper; 5 | import com.example.musicserver.entity.Admin; 6 | import com.example.musicserver.entity.Comment; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | 11 | import java.util.Date; 12 | 13 | @SpringBootTest 14 | class MusicServerApplicationTests { 15 | 16 | @Autowired 17 | private AdminMapper adminMapper; 18 | @Autowired 19 | private CommentMapper commentMapper; 20 | 21 | @Test 22 | void test() { 23 | Object o = new Object(); 24 | } 25 | 26 | @Test 27 | void adminTest() { 28 | 29 | Admin admin = new Admin(); 30 | admin.setAdminId("00002"); 31 | admin.setName("cc"); 32 | admin.setPassword("111111"); 33 | 34 | adminMapper.updateByPrimaryKey(admin); 35 | 36 | // adminMapper.deleteByPrimaryKey("00001"); 37 | 38 | System.out.println(adminMapper.verifyPassword("cc","11111")); 39 | } 40 | 41 | @Test 42 | void commentTest() { 43 | 44 | Comment comment = new Comment(); 45 | comment.setCommentId("000004"); 46 | comment.setUserId("000002"); 47 | // comment.setSongListId(""); 48 | comment.setContent("你好你好"); 49 | comment.setType("1"); 50 | comment.setStars(3); 51 | comment.setSongId("000004"); 52 | comment.setCreatedTime(new Date().toString()); 53 | System.out.println(commentMapper.selectByPrimaryKey("000004")); 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/AdminMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Song; 4 | import com.example.musicserver.entity.SongList; 5 | import com.example.musicserver.entity.UserData; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | 14 | /** 15 | * @author CCNICE 16 | * @date 2023/5/15 17 | */ 18 | @SpringBootTest 19 | class AdminMapperTest { 20 | @Autowired 21 | private AdminMapper adminMapper; 22 | 23 | @Autowired 24 | private SongMapper songMapper; 25 | 26 | @Autowired 27 | private SongListMapper songListMapper; 28 | 29 | @Test 30 | void test01() { 31 | 32 | ArrayList> objects = new ArrayList<>(); 33 | 34 | HashMap hashMap1 = new HashMap<>(); 35 | List userData1 = adminMapper.selectUserCount(); 36 | hashMap1.put("totalUsers", userData1.get(0).getTotalUsers()); 37 | hashMap1.put("recentUsers", userData1.get(0).getRecentUsers()); 38 | 39 | HashMap hashMap2 = new HashMap<>(); 40 | List userData2 = adminMapper.selectGenderCounter(); 41 | hashMap2.put("male", userData2.get(0).getGenderCount()); 42 | hashMap2.put("female", userData2.get(1).getGenderCount()); 43 | hashMap2.put("unknown", userData2.get(2).getGenderCount()); 44 | 45 | HashMap hashMap3 = new HashMap<>(); 46 | Song song = new Song(); 47 | List songs = songMapper.selectSong(song); 48 | hashMap3.put("totalSongs", String.valueOf(songs.size())); 49 | 50 | HashMap hashMap4 = new HashMap<>(); 51 | SongList songList = new SongList(); 52 | List songLists = songListMapper.selectSongList(songList); 53 | hashMap4.put("totalSongList", String.valueOf(songLists.size())); 54 | 55 | HashMap hashMap5 = new HashMap<>(); 56 | List songPlayNum = adminMapper.selectPlayNum(); 57 | hashMap5.put(songPlayNum.get(0).getName(), String.valueOf(songPlayNum.get(0).getPhoto())); 58 | hashMap5.put(songPlayNum.get(1).getName(), String.valueOf(songPlayNum.get(1).getPhoto())); 59 | hashMap5.put(songPlayNum.get(2).getName(), String.valueOf(songPlayNum.get(2).getPhoto())); 60 | hashMap5.put(songPlayNum.get(3).getName(), String.valueOf(songPlayNum.get(3).getPhoto())); 61 | hashMap5.put(songPlayNum.get(4).getName(), String.valueOf(songPlayNum.get(4).getPhoto())); 62 | hashMap5.put(songPlayNum.get(5).getName(), String.valueOf(songPlayNum.get(5).getPhoto())); 63 | hashMap5.put(songPlayNum.get(6).getName(), String.valueOf(songPlayNum.get(6).getPhoto())); 64 | hashMap5.put(songPlayNum.get(7).getName(), String.valueOf(songPlayNum.get(7).getPhoto())); 65 | hashMap5.put(songPlayNum.get(8).getName(), String.valueOf(songPlayNum.get(8).getPhoto())); 66 | hashMap5.put(songPlayNum.get(9).getName(), String.valueOf(songPlayNum.get(9).getPhoto())); 67 | 68 | objects.add(hashMap1); 69 | objects.add(hashMap2); 70 | objects.add(hashMap3); 71 | objects.add(hashMap4); 72 | objects.add(hashMap5); 73 | 74 | System.out.println(objects); 75 | } 76 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/CommentMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Comment; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | import static org.junit.jupiter.api.Assertions.*; 12 | 13 | /** 14 | * @Author CCNICE 15 | * @Date 2023/3/25 16 | */ 17 | @SpringBootTest 18 | class CommentMapperTest { 19 | 20 | @Autowired 21 | private CommentMapper commentMapper; 22 | @Test 23 | void test01() { 24 | // List comments = commentMapper.commentOfSongId("000004"); 25 | // System.out.println(comments); 26 | } 27 | 28 | @Test 29 | void test02() { 30 | Comment comment = new Comment(); 31 | comment.setCommentId("000005"); 32 | comment.setContent("000005"); 33 | comment.setSongId(""); 34 | comment.setSongListId("000003"); 35 | comment.setUserId("000002"); 36 | comment.setStars(100); 37 | comment.setType("1"); 38 | comment.setCreatedTime(new Date().toString()); 39 | 40 | commentMapper.insert(comment); 41 | 42 | // List comments = commentMapper.commentOfSongListId("000003"); 43 | // System.out.println(comments); 44 | } 45 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/ReplyMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Reply; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * @Author CCNICE 16 | * @Date 2023/3/25 17 | */ 18 | @SpringBootTest 19 | class ReplyMapperTest { 20 | 21 | @Autowired 22 | private ReplyMapper replyMapper; 23 | 24 | static Snowflake snowflake = new Snowflake(10,21); 25 | 26 | @Test 27 | void test02() { 28 | 29 | System.out.println(snowflake.nextId()); 30 | 31 | } 32 | 33 | @Test 34 | void test01() { 35 | Reply reply = new Reply(); 36 | reply.setReplyId(String.valueOf(snowflake.nextId())); 37 | reply.setUserId("000002"); 38 | reply.setCommentId("000003"); 39 | reply.setContent("test01"); 40 | reply.setCreatedTime(new Date().toString()); 41 | 42 | replyMapper.insert(reply); 43 | List replies = replyMapper.selectReplyByCommentId("000003"); 44 | System.out.println(replies); 45 | 46 | } 47 | 48 | @Test 49 | void test03() { 50 | replyMapper.deleteByPrimaryKey("000001"); 51 | } 52 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/SingerMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Singer; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author CCNICE 14 | * @Date 2023/3/25 15 | */ 16 | @SpringBootTest 17 | class SingerMapperTest { 18 | 19 | @Autowired 20 | private SingerMapper singerMapper; 21 | 22 | 23 | static Snowflake snowflake = new Snowflake(4,1); 24 | 25 | @Test 26 | void test04() { 27 | Singer singer = new Singer(); 28 | 29 | // singer.setSingerId("956909715961942016"); 30 | singer.setName("ccnice"); 31 | 32 | List singers = singerMapper.selectSinger(singer); 33 | System.out.println(singers); 34 | } 35 | 36 | @Test 37 | void test03() { 38 | //更新 39 | Singer singer = new Singer(); 40 | singer.setSingerId("956909715961942016"); 41 | singer.setBirth(new Date().toString()); 42 | singer.setName("ccnice"); 43 | singer.setGender("男"); 44 | singer.setLocation("China"); 45 | singer.setIntroduction("嘿嘿"); 46 | singer.setPhoto("demo"); 47 | singer.setCreatedTime(new Date().toString()); 48 | singerMapper.updateSingerByPrimaryKey(singer); 49 | } 50 | 51 | @Test 52 | void test02() { 53 | singerMapper.deleteSingerByPrimaryKey("956909564404961280"); 54 | } 55 | 56 | @Test 57 | void test01() { 58 | 59 | Singer singer = new Singer(); 60 | singer.setSingerId(String.valueOf(snowflake.nextId())); 61 | singer.setBirth(new Date().toString()); 62 | singer.setName("ccnice"); 63 | singer.setGender("男"); 64 | singer.setLocation("China"); 65 | singer.setIntroduction("demo"); 66 | singer.setPhoto("demo"); 67 | singer.setCreatedTime(new Date().toString()); 68 | 69 | singerMapper.insert(singer); 70 | } 71 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/SongListMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.SongList; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import static org.junit.jupiter.api.Assertions.*; 13 | 14 | /** 15 | * @Author CCNICE 16 | * @Date 2023/3/26 17 | */ 18 | @SpringBootTest 19 | class SongListMapperTest { 20 | 21 | @Autowired 22 | private SongListMapper songListMapper; 23 | 24 | static Snowflake snowflake = new Snowflake(5,1); 25 | 26 | @Test 27 | void test04() { 28 | //更新 29 | SongList songList = new SongList(); 30 | songList.setSongListId("957097728931401728"); 31 | songList.setSongIdList(String.valueOf(snowflake.nextId())); 32 | songList.setName("嘿嘿"); 33 | songList.setPhoto("aaaa"); 34 | songList.setStyle("asasa"); 35 | songList.setIntroduction("发生什么了"); 36 | songListMapper.updateByPrimaryKey(songList); 37 | 38 | } 39 | 40 | @Test 41 | void test03() { 42 | //查询 43 | 44 | SongList songList = new SongList(); 45 | songList.setSongListId("957097689395892224"); 46 | List songLists = songListMapper.selectSongList(songList); 47 | System.out.println(songLists); 48 | } 49 | 50 | @Test 51 | void test02() { 52 | songListMapper.deleteByPrimaryKey("957094778473418752"); 53 | } 54 | 55 | @Test 56 | void test01() { 57 | SongList songList = new SongList(); 58 | songList.setSongListId(String.valueOf(snowflake.nextId())); 59 | songList.setSongIdList(String.valueOf(snowflake.nextId())); 60 | songList.setName("demo"); 61 | songList.setPhoto("picture"); 62 | songList.setStyle("摇滚"); 63 | songList.setIntroduction("啦啦啦啦啦"); 64 | songList.setCreatedTime(new Date().toString()); 65 | 66 | songListMapper.insert(songList); 67 | } 68 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/SongMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.Song; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import static org.junit.jupiter.api.Assertions.*; 13 | 14 | /** 15 | * @Author CCNICE 16 | * @Date 2023/3/26 17 | */ 18 | @SpringBootTest 19 | class SongMapperTest { 20 | 21 | @Autowired 22 | private SongMapper songMapper; 23 | 24 | static Snowflake snowflake = new Snowflake(6,1); 25 | 26 | @Test 27 | void test05() { 28 | List songs = songMapper.selectSongOrderByPhoto(); 29 | for (Song song : songs) { 30 | System.out.println(song.getName()); 31 | } 32 | } 33 | 34 | @Test 35 | void test04() { 36 | Song song = new Song(); 37 | song.setName("辣"); 38 | List songs = songMapper.selectSong(song); 39 | System.out.println(songs); 40 | } 41 | 42 | @Test 43 | void test03() { 44 | Song song = new Song(); 45 | song.setSongId("957170141455192064"); 46 | song.setName("辣椒"); 47 | songMapper.updateByPrimaryKey(song); 48 | } 49 | 50 | @Test 51 | void test02() { 52 | songMapper.deleteByPrimaryKey("957166207302897664"); 53 | } 54 | 55 | @Test 56 | void test01() { 57 | Song song = new Song(); 58 | song.setSongId(String.valueOf(snowflake.nextId())); 59 | song.setName("黑夜"); 60 | song.setSingerId(String.valueOf(snowflake.nextId())); 61 | song.setLyric("歌词"); 62 | song.setUrl("歌曲地址"); 63 | song.setAlbum("黑椒"); 64 | // song.setPhoto("/234234234"); 65 | song.setCreatedTime(new Date().toString()); 66 | song.setUpdateTime(new Date().toString()); 67 | songMapper.insert(song); 68 | } 69 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/UserDataMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.UserData; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import xyz.downgoon.snowflake.Snowflake; 8 | 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | import static org.junit.jupiter.api.Assertions.*; 13 | 14 | /** 15 | * @Author CCNICE 16 | * @Date 2023/3/26 17 | */ 18 | @SpringBootTest 19 | class UserDataMapperTest { 20 | 21 | @Autowired 22 | private UserDataMapper userDataMapper; 23 | 24 | static Snowflake snowflake = new Snowflake(7,1); 25 | 26 | @Test 27 | void test05() { 28 | //用户名和密码验证 29 | UserData userData = new UserData(); 30 | userData.setPassword("111111"); 31 | userData.setName("ccnice"); 32 | int i = userDataMapper.verifyUserPassword(userData); 33 | System.out.println(i); 34 | } 35 | 36 | @Test 37 | void test04() { 38 | UserData userData = new UserData(); 39 | // userData.setUserId("1"); 40 | userData.setName("ccni"); 41 | // userData.setPassword("11111"); 42 | List userDataList = userDataMapper.selectUserData(userData); 43 | System.out.println(userDataList); 44 | } 45 | 46 | @Test 47 | void test03() { 48 | //修改 49 | UserData userData = new UserData(); 50 | userData.setUserId("957190288228356096"); 51 | userData.setGender("男"); 52 | userDataMapper.updateByPrimaryKey(userData); 53 | } 54 | 55 | @Test 56 | void test02() { 57 | //删除 58 | userDataMapper.deleteByPrimaryKey("957190533049880576"); 59 | } 60 | 61 | @Test 62 | void test01() { 63 | UserData userData = new UserData(); 64 | userData.setUserId(String.valueOf(snowflake.nextId())); 65 | userData.setName("x7"); 66 | userData.setPassword("111111"); 67 | userData.setGender("女"); 68 | userData.setBirth(new Date().toString()); 69 | userData.setLocation("China"); 70 | userData.setIntroduction("啦啦啦"); 71 | userData.setPhoto("不啦不啊了"); 72 | userData.setCreatedTime(new Date().toString()); 73 | userData.setUpdateTime(new Date().toString()); 74 | 75 | userDataMapper.insert(userData); 76 | } 77 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/dao/UserSongListMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.dao; 2 | 3 | import com.example.musicserver.entity.UserSongList; 4 | import org.assertj.core.annotations.Beta; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.context.annotation.Bean; 9 | import xyz.downgoon.snowflake.Snowflake; 10 | 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | import static org.junit.jupiter.api.Assertions.*; 15 | 16 | /** 17 | * @Author CCNICE 18 | * @Date 2023/3/26 19 | */ 20 | @SpringBootTest 21 | class UserSongListMapperTest { 22 | 23 | @Autowired 24 | private UserSongListMapper userSongListMapper; 25 | 26 | static Snowflake snowflake = new Snowflake(8,1); 27 | 28 | @Test 29 | void test04() { 30 | UserSongList userSongList = new UserSongList(); 31 | userSongList.setUserSongListId("95720215048024064"); 32 | List userSongLists = userSongListMapper.selectUserSongList(userSongList); 33 | System.out.println(userSongLists); 34 | } 35 | 36 | @Test 37 | void test03() { 38 | userSongListMapper.deleteByPrimaryKey("957210296937615360"); 39 | } 40 | 41 | @Test 42 | void test02() { 43 | //更新用户歌单 44 | UserSongList userSongList = new UserSongList(); 45 | userSongList.setUserSongListId("973556788312047616"); 46 | // userSongList.setName("快乐"); 47 | // userSongList.setPhoto("src"); 48 | userSongList.setSongIdList("test"); 49 | userSongListMapper.updateByPrimaryKey(userSongList); 50 | } 51 | 52 | @Test 53 | void test01() { 54 | 55 | UserSongList userSongList = new UserSongList(); 56 | userSongList.setUserSongListId(String.valueOf(snowflake.nextId())); 57 | userSongList.setUserId(String.valueOf(snowflake.nextId())); 58 | userSongList.setSongIdList(String.valueOf(snowflake.nextId())); 59 | userSongList.setName("睡觉"); 60 | userSongList.setPhoto("picture"); 61 | userSongList.setIntroduction("hello"); 62 | userSongList.setCreatedTime(new Date().toString()); 63 | 64 | userSongListMapper.insert(userSongList); 65 | 66 | } 67 | } -------------------------------------------------------------------------------- /musicServer/src/test/java/com/example/musicserver/demo/JvmTest.java: -------------------------------------------------------------------------------- 1 | package com.example.musicserver.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | /** 6 | * @author ChengJianhong 7 | * @date 2023/3/20 8 | */ 9 | public class JvmTest { 10 | 11 | class User { 12 | int id; 13 | String name; 14 | User(int id, String name) { 15 | this.id = id; 16 | this.name = name; 17 | } 18 | } 19 | 20 | void alloc(int i) { 21 | new User(i, "name"+i); 22 | } 23 | 24 | @Test 25 | public void test1() { 26 | JvmTest jvmTest = new JvmTest(); 27 | long s1 = System.currentTimeMillis(); 28 | for (int i = 0; i < 10000000; i++) { 29 | jvmTest.alloc(i); 30 | } 31 | long s2 = System.currentTimeMillis(); 32 | System.out.println(s2 - s1); 33 | } 34 | 35 | static void printMemoryInfo(){ 36 | System.out.println("total: " + Runtime.getRuntime().totalMemory()); 37 | System.out.println("free: " +Runtime.getRuntime().freeMemory()); 38 | } 39 | 40 | @Test 41 | public void test2() { 42 | printMemoryInfo(); 43 | 44 | 45 | byte[] b = new byte[1024*1024]; 46 | System.out.println("------------------"); 47 | 48 | printMemoryInfo(); 49 | 50 | } 51 | 52 | // 计算递归调用次数 53 | static int count = 0; 54 | 55 | /** 56 | * 递归查看栈深度 57 | */ 58 | static void foo() { 59 | count++; 60 | foo(); 61 | } 62 | 63 | @Test 64 | public void test3() { 65 | try { 66 | foo(); 67 | } catch (Throwable t) { 68 | System.out.println(count); 69 | t.printStackTrace();// 栈溢出,递归调用过深 70 | } 71 | } 72 | } 73 | --------------------------------------------------------------------------------