Compare commits
No commits in common. "main" and "lab06(Vue)" have entirely different histories.
main
...
lab06(Vue)
55
.gitignore
vendored
55
.gitignore
vendored
@ -1,26 +1,37 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
HELP.md
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
56
build.gradle
Normal file
56
build.gradle
Normal file
@ -0,0 +1,56 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '2.6.3'
|
||||
id 'io.spring.dependency-management' version '1.1.0'
|
||||
}
|
||||
|
||||
group = 'ru.ulstu.is'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
jar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'com.h2database:h2:2.1.210'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'com.auth0:java-jwt:4.4.0'
|
||||
|
||||
implementation 'org.hibernate.validator:hibernate-validator'
|
||||
|
||||
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
// annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
|
||||
// implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
// implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
// implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
// implementation 'com.auth0:java-jwt:4.4.0'
|
||||
// implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
// implementation 'org.springframework.boot:spring-boot-devtools'
|
||||
// implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
|
||||
// implementation 'org.webjars:bootstrap:5.1.3'
|
||||
// implementation 'org.webjars:jquery:3.6.0'
|
||||
// implementation 'org.webjars:font-awesome:6.1.0'
|
||||
// implementation 'com.h2database:h2:2.1.210'
|
||||
// implementation 'jakarta.validation:jakarta.validation-api:3.0.0'
|
||||
// implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final'
|
||||
// implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
||||
// testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
24
front/.gitignore
vendored
Normal file
24
front/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
7
front/README.md
Normal file
7
front/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Vue 3 + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
16
front/index.html
Normal file
16
front/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<link rel="stylesheet" href="./src/style.css">
|
||||
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js" type="module"></script>
|
||||
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Streaming Service</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
847
front/package-lock.json
generated
Normal file
847
front/package-lock.json
generated
Normal file
@ -0,0 +1,847 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "front",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"bootstrap": "^5.3.0",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.1.0",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/parser": {
|
||||
"version": "7.22.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz",
|
||||
"integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==",
|
||||
"bin": {
|
||||
"parser": "bin/babel-parser.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz",
|
||||
"integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz",
|
||||
"integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz",
|
||||
"integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz",
|
||||
"integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz",
|
||||
"integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz",
|
||||
"integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz",
|
||||
"integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz",
|
||||
"integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz",
|
||||
"integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz",
|
||||
"integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz",
|
||||
"integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz",
|
||||
"integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz",
|
||||
"integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz",
|
||||
"integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz",
|
||||
"integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.4.15",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
|
||||
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg=="
|
||||
},
|
||||
"node_modules/@popperjs/core": {
|
||||
"version": "2.11.8",
|
||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
|
||||
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/popperjs"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitejs/plugin-vue": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-4.2.3.tgz",
|
||||
"integrity": "sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4.0.0",
|
||||
"vue": "^3.2.25"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-core": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.4.tgz",
|
||||
"integrity": "sha512-cquyDNvZ6jTbf/+x+AgM2Arrp6G4Dzbb0R64jiG804HRMfRiFXWI6kqUVqZ6ZR0bQhIoQjB4+2bhNtVwndW15g==",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.21.3",
|
||||
"@vue/shared": "3.3.4",
|
||||
"estree-walker": "^2.0.2",
|
||||
"source-map-js": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-dom": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.4.tgz",
|
||||
"integrity": "sha512-wyM+OjOVpuUukIq6p5+nwHYtj9cFroz9cwkfmP9O1nzH68BenTTv0u7/ndggT8cIQlnBeOo6sUT/gvHcIkLA5w==",
|
||||
"dependencies": {
|
||||
"@vue/compiler-core": "3.3.4",
|
||||
"@vue/shared": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-sfc": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.4.tgz",
|
||||
"integrity": "sha512-6y/d8uw+5TkCuzBkgLS0v3lSM3hJDntFEiUORM11pQ/hKvkhSKZrXW6i69UyXlJQisJxuUEJKAWEqWbWsLeNKQ==",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.20.15",
|
||||
"@vue/compiler-core": "3.3.4",
|
||||
"@vue/compiler-dom": "3.3.4",
|
||||
"@vue/compiler-ssr": "3.3.4",
|
||||
"@vue/reactivity-transform": "3.3.4",
|
||||
"@vue/shared": "3.3.4",
|
||||
"estree-walker": "^2.0.2",
|
||||
"magic-string": "^0.30.0",
|
||||
"postcss": "^8.1.10",
|
||||
"source-map-js": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-ssr": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.4.tgz",
|
||||
"integrity": "sha512-m0v6oKpup2nMSehwA6Uuu+j+wEwcy7QmwMkVNVfrV9P2qE5KshC6RwOCq8fjGS/Eak/uNb8AaWekfiXxbBB6gQ==",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.3.4",
|
||||
"@vue/shared": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/devtools-api": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.5.0.tgz",
|
||||
"integrity": "sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q=="
|
||||
},
|
||||
"node_modules/@vue/reactivity": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.4.tgz",
|
||||
"integrity": "sha512-kLTDLwd0B1jG08NBF3R5rqULtv/f8x3rOFByTDz4J53ttIQEDmALqKqXY0J+XQeN0aV2FBxY8nJDf88yvOPAqQ==",
|
||||
"dependencies": {
|
||||
"@vue/shared": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/reactivity-transform": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.4.tgz",
|
||||
"integrity": "sha512-MXgwjako4nu5WFLAjpBnCj/ieqcjE2aJBINUNQzkZQfzIZA4xn+0fV1tIYBJvvva3N3OvKGofRLvQIwEQPpaXw==",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.20.15",
|
||||
"@vue/compiler-core": "3.3.4",
|
||||
"@vue/shared": "3.3.4",
|
||||
"estree-walker": "^2.0.2",
|
||||
"magic-string": "^0.30.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-core": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.4.tgz",
|
||||
"integrity": "sha512-R+bqxMN6pWO7zGI4OMlmvePOdP2c93GsHFM/siJI7O2nxFRzj55pLwkpCedEY+bTMgp5miZ8CxfIZo3S+gFqvA==",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.3.4",
|
||||
"@vue/shared": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-dom": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.4.tgz",
|
||||
"integrity": "sha512-Aj5bTJ3u5sFsUckRghsNjVTtxZQ1OyMWCr5dZRAPijF/0Vy4xEoRCwLyHXcj4D0UFbJ4lbx3gPTgg06K/GnPnQ==",
|
||||
"dependencies": {
|
||||
"@vue/runtime-core": "3.3.4",
|
||||
"@vue/shared": "3.3.4",
|
||||
"csstype": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/server-renderer": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.4.tgz",
|
||||
"integrity": "sha512-Q6jDDzR23ViIb67v+vM1Dqntu+HUexQcsWKhhQa4ARVzxOY2HbC7QRW/ggkDBd5BU+uM1sV6XOAP0b216o34JQ==",
|
||||
"dependencies": {
|
||||
"@vue/compiler-ssr": "3.3.4",
|
||||
"@vue/shared": "3.3.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/shared": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.4.tgz",
|
||||
"integrity": "sha512-7OjdcV8vQ74eiz1TZLzZP4JwqM5fA94K6yntPS5Z25r9HDuGNzaGdgvwKYq6S+MxwF0TFRwe50fIR/MYnakdkQ=="
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
|
||||
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bootstrap": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.0.tgz",
|
||||
"integrity": "sha512-UnBV3E3v4STVNQdms6jSGO2CvOkjUMdDAVR2V5N4uCMdaIkaQjbcEAMqRimDHIs4uqBYzDAKCQwCB+97tJgHQw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/twbs"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bootstrap"
|
||||
}
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@popperjs/core": "^2.11.7"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
|
||||
"integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ=="
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz",
|
||||
"integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/android-arm": "0.17.19",
|
||||
"@esbuild/android-arm64": "0.17.19",
|
||||
"@esbuild/android-x64": "0.17.19",
|
||||
"@esbuild/darwin-arm64": "0.17.19",
|
||||
"@esbuild/darwin-x64": "0.17.19",
|
||||
"@esbuild/freebsd-arm64": "0.17.19",
|
||||
"@esbuild/freebsd-x64": "0.17.19",
|
||||
"@esbuild/linux-arm": "0.17.19",
|
||||
"@esbuild/linux-arm64": "0.17.19",
|
||||
"@esbuild/linux-ia32": "0.17.19",
|
||||
"@esbuild/linux-loong64": "0.17.19",
|
||||
"@esbuild/linux-mips64el": "0.17.19",
|
||||
"@esbuild/linux-ppc64": "0.17.19",
|
||||
"@esbuild/linux-riscv64": "0.17.19",
|
||||
"@esbuild/linux-s390x": "0.17.19",
|
||||
"@esbuild/linux-x64": "0.17.19",
|
||||
"@esbuild/netbsd-x64": "0.17.19",
|
||||
"@esbuild/openbsd-x64": "0.17.19",
|
||||
"@esbuild/sunos-x64": "0.17.19",
|
||||
"@esbuild/win32-arm64": "0.17.19",
|
||||
"@esbuild/win32-ia32": "0.17.19",
|
||||
"@esbuild/win32-x64": "0.17.19"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.0",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz",
|
||||
"integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.13"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.6",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
|
||||
"integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.4.24",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz",
|
||||
"integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.6",
|
||||
"picocolors": "^1.0.0",
|
||||
"source-map-js": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "3.24.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-3.24.0.tgz",
|
||||
"integrity": "sha512-OgraHOIg2YpHQTjl0/ymWfFNBEyPucB7lmhXrQUh38qNOegxLapSPFs9sNr0qKR75awW41D93XafoR2QfhBdUQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.18.0",
|
||||
"npm": ">=8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
||||
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "4.3.9",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz",
|
||||
"integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.17.5",
|
||||
"postcss": "^8.4.23",
|
||||
"rollup": "^3.21.0"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">= 14",
|
||||
"less": "*",
|
||||
"sass": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vue": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.3.4.tgz",
|
||||
"integrity": "sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw==",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.3.4",
|
||||
"@vue/compiler-sfc": "3.3.4",
|
||||
"@vue/runtime-dom": "3.3.4",
|
||||
"@vue/server-renderer": "3.3.4",
|
||||
"@vue/shared": "3.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/vue-router": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.2.2.tgz",
|
||||
"integrity": "sha512-cChBPPmAflgBGmy3tBsjeoe3f3VOSG6naKyY5pjtrqLGbNEXdzCigFUHgBvp9e3ysAtFtEx7OLqcSDh/1Cq2TQ==",
|
||||
"dependencies": {
|
||||
"@vue/devtools-api": "^6.5.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/posva"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
front/package.json
Normal file
21
front/package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "front",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"bootstrap": "^5.3.0",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.1.0",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
}
|
1
front/public/vite.svg
Normal file
1
front/public/vite.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
57
front/src/App.vue
Normal file
57
front/src/App.vue
Normal file
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<Header :user="userFromServer" :role="roleFromServer"></Header>
|
||||
<main class="main mt-2">
|
||||
<router-view @login="saveServerData"></router-view>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Header from './components/Header.vue';
|
||||
export default{
|
||||
components:{
|
||||
Header
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tokenFromServer: undefined,
|
||||
userFromServer: undefined,
|
||||
roleFromServer: undefined,
|
||||
securityError: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const self = this
|
||||
window.addEventListener('storage', function(e){
|
||||
console.log(e)
|
||||
if(e.key === "token")
|
||||
if(this.tokenFromServer !== e.newValue) {
|
||||
self.storageSecurity()
|
||||
}
|
||||
if(e.key === "user")
|
||||
if(this.userFromServer !== e.newValue) {
|
||||
self.storageSecurity()
|
||||
}
|
||||
if(e.key === "role")
|
||||
if(this.roleFromServer !== e.newValue) {
|
||||
self.storageSecurity()
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
storageSecurity(){
|
||||
localStorage.clear()
|
||||
this.$router.push("/login")
|
||||
this.securityError = true
|
||||
},
|
||||
saveServerData(data){
|
||||
this.tokenFromServer = data.token
|
||||
this.roleFromServer = data.role
|
||||
this.userFromServer = data.user
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
1
front/src/assets/vue.svg
Normal file
1
front/src/assets/vue.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
After Width: | Height: | Size: 496 B |
61
front/src/components/Header.vue
Normal file
61
front/src/components/Header.vue
Normal file
@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav justify-content-center">
|
||||
<li class="nav-item">
|
||||
<router-link to="/songs" class="nav-link">Песни</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/albums" class="nav-link">Альбомы</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/artists" class="nav-link">Исполнители</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/find" class="nav-link">Поиск</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/users" class="nav-link">Пользователи</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/login" class="nav-link" @click="logout()">Выход</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
|
||||
<style>
|
||||
.navbar-brand {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
transition: color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
logout(){
|
||||
localStorage.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
10
front/src/main.js
Normal file
10
front/src/main.js
Normal file
@ -0,0 +1,10 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(router)
|
||||
|
||||
app.mount('#app')
|
7
front/src/models/Album.js
Normal file
7
front/src/models/Album.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default class Album{
|
||||
constructor(data) {
|
||||
this.id = data?.id;
|
||||
this.albumName = data?.albumName;
|
||||
this.artistIds = data?.artistIds;
|
||||
}
|
||||
}
|
7
front/src/models/Artist.js
Normal file
7
front/src/models/Artist.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default class Artist{
|
||||
constructor(data) {
|
||||
this.id = data?.id;
|
||||
this.artistName = data?.artistName;
|
||||
this.albumIds = data?.albumIds;
|
||||
}
|
||||
}
|
8
front/src/models/Song.js
Normal file
8
front/src/models/Song.js
Normal file
@ -0,0 +1,8 @@
|
||||
export default class Song{
|
||||
constructor(data) {
|
||||
this.id = data?.id;
|
||||
this.songName = data?.songName;
|
||||
this.duration = data?.duration;
|
||||
this.album = data?.album;
|
||||
}
|
||||
}
|
8
front/src/models/User.js
Normal file
8
front/src/models/User.js
Normal file
@ -0,0 +1,8 @@
|
||||
export default class User{
|
||||
constructor(data) {
|
||||
this.id = data?.id;
|
||||
this.login = data?.login;
|
||||
this.password = data?.password;
|
||||
this.role = data?.role;
|
||||
}
|
||||
}
|
488
front/src/pages/albums.vue
Normal file
488
front/src/pages/albums.vue
Normal file
@ -0,0 +1,488 @@
|
||||
<template>
|
||||
<div class="container mt-4">
|
||||
<h1 class="text-center mb-4">Альбомы</h1>
|
||||
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Альбомы</th>
|
||||
<th>Исполнители</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="alb in albums" :key="alb.id">
|
||||
<td>{{ alb.albumName }}</td>
|
||||
<td>
|
||||
<div class="d-flex flex-column">
|
||||
<button class="btn btn-primary mb-2" @click="OpenModelForSongs(); getSongsFromAlbum(alb.id)">Просмотр песен</button>
|
||||
<button class="btn btn-primary mb-2" @click="OpenModelForAddSongs(alb); getSongsFromUndefinedAlbum()">Добавить песен в альбом</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex flex-column">
|
||||
<button class="btn btn-primary mb-2" @click="OpenModelForArtists(); getArtistsInAlbum(alb.id)">Просмотр исполнителей</button>
|
||||
<button class="btn btn-primary mb-2" @click="OpenModelForAddArtists('edit', alb);">Добавить исполнителей в альбом</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex flex-column">
|
||||
<button class="btn btn-primary mb-2" @click="openModal('edit', alb)">Изменить</button>
|
||||
<button class="btn btn-danger mb-2" @click="deleteAlbum(alb.id)">Удалить</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--Форма для привязки артиста и альбомов -->
|
||||
<div class="modal" tabindex="-1" id="openModalForAddArtists">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Добавить исполнителей</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-album">
|
||||
<label for="albumName">Имя:</label>
|
||||
<input readonly type="text" class="form-control" id="albumName" name="albumName" v-model="album.albumName">
|
||||
</div>
|
||||
<div class="form-album">
|
||||
<label for="name">Выберите исполнителей:</label>
|
||||
<ul class="list-album">
|
||||
<li class="list-album-item" v-for="artist in artists" :key="artist.id">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" v-model="selectedArtists" :value="artist.id" v-bind:checked="open.includes(artist.id)" id="albumCheck{{ artist.id }}">
|
||||
<label class="form-check-label" for="albumCheck{{ artist.id }}">{{ artist.artistName }}</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModalForAddArtists()">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" @click="addArtistToAlbum(album.id, selectedArtists)">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Модальное окно песен в альбом-->
|
||||
<div class="modal" tabindex="-1" id="ModalForAddSongs">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Добавить песни</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-album">
|
||||
<label for="albumName">Название:</label>
|
||||
<input type="text" class="form-control" id="albumName" name="albumName" v-model="album.albumName">
|
||||
</div>
|
||||
<div class="form-album">
|
||||
<label for="name">Выберите песни:</label>
|
||||
<ul class="list-album">
|
||||
<li class="list-album-item" v-for="song in songs" :key="song.id">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" :id="'songCheck' + song.id" :value="song.id" v-model="selectedSongs">
|
||||
<label class="form-check-label" :for="'songCheck' + song.id">{{ song.songName }}</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="CloseModalForAddSongs()">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" @click="saveSongs(album.id)">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Модальное окно и изменения-->
|
||||
<div class="modal" tabindex="-1" id="editModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Альбом</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-album">
|
||||
<label for="albumName">Название:</label>
|
||||
<input type="text" class="form-control" id="albumName" name="albumName" v-model="album.albumName">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal()">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" v-if="album.status === 'create'" @click="addAlbum(album)">Создать</button>
|
||||
<button type="button" class="btn btn-primary" v-else @click="editAlbum(album)">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Модальное окно для просмотра песен в альбоме-->
|
||||
<div class="modal" tabindex="-1" id="ModelForSongs">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Песни</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-album">
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Продолжительность</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="son in songs" :key="son.id">
|
||||
<td>{{ son.songName }}</td>
|
||||
<td>{{ son.duration }}</td>
|
||||
<td>
|
||||
<td>
|
||||
<button class="btn btn-danger mr-2" @click="deleteSongFromAlbum(son.id)">Удалить</button>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="ModelForSongs" @click="closeModelForSongs()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Модальное окно для просмотра исполнителей в альбоме-->
|
||||
<div class="modal" tabindex="-1" id="ModelForArtists">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Исполнители</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-album">
|
||||
<table class="thead-inverse table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="art in artistsInAlbum" :key="art.id">
|
||||
<td>{{ art.artistName }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="ModelForArtists" @click="closeModelForArtists()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Модальное окно для просмотра исполнителей в альбоме-->
|
||||
<div class="modal" tabindex="-1" id="ModelForArtists">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Исполнители</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Жанр</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="art in artistsInAlbum" :key="art.id">
|
||||
<td>{{ art.artistName }}</td>
|
||||
<td>{{ art.genre }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="ModelForArtists" @click="closeModelForArtists()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import 'axios';
|
||||
import axios from "axios";
|
||||
import Album from "@/models/Album";
|
||||
import Song from "@/models/Song";
|
||||
import Artist from "@/models/Artist";
|
||||
export default {
|
||||
created() {
|
||||
this.getAlbums();
|
||||
this.getArtists();
|
||||
},
|
||||
data() {
|
||||
return{
|
||||
albums: [],
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
album: new Album(),
|
||||
songs: [],
|
||||
artists: [],
|
||||
selectedSongs: [],
|
||||
open: [],
|
||||
albumId: undefined,
|
||||
selectedArtists: [],
|
||||
artistsInAlbum: [],
|
||||
getAllInfo: new Object() ,
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getArtistsInAlbum(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${id}/getAllArtists`)
|
||||
.then(response => {
|
||||
this.artistsInAlbum = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getArtistsInAlbum(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${id}/getAllArtists`)
|
||||
.then(response => {
|
||||
this.artistsInAlbum = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getAlbums(){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "album")
|
||||
.then(response => {
|
||||
this.albums = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
addAlbum(album) {
|
||||
console.log(this.album);
|
||||
axios
|
||||
.create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}
|
||||
})
|
||||
.post(this.URL + "album", album)
|
||||
.then(() => {
|
||||
this.getAlbums();
|
||||
this.closeModal();
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.response && error.response.status === 403) {
|
||||
console.error("Forbidden: User does not have permission to perform this operation");
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteAlbum(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `album/${id}`)
|
||||
.then(() =>{
|
||||
this.getAlbums();
|
||||
})
|
||||
},
|
||||
editAlbum(album){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `album/${album.id}`, album)
|
||||
.then(() =>{
|
||||
const index = this.albums.findIndex((s) => s.id === album.id);
|
||||
if (index !== -1) {
|
||||
this.albums[index] = { ...album };
|
||||
}
|
||||
this.closeModal();
|
||||
this.getAlbums();
|
||||
})
|
||||
this.closeModal();
|
||||
},
|
||||
openModal(status, album = null) {
|
||||
if (status === "create") {
|
||||
this.album = new Album();
|
||||
this.album.status = "create";
|
||||
} else if (status === "edit" && album) {
|
||||
this.album = { ...album };
|
||||
this.album.status = "edit";
|
||||
}
|
||||
document.getElementById("editModal").style.display = "block";
|
||||
},
|
||||
closeModal() {
|
||||
document.getElementById("editModal").style.display = "none";
|
||||
},
|
||||
getSongsFromAlbum(albumId){
|
||||
this.selectedSongs = [];
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${albumId}/songs`)
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
OpenModelForSongs() {
|
||||
document.getElementById("ModelForSongs").style.display = "block";
|
||||
},
|
||||
closeModelForSongs() {
|
||||
document.getElementById("ModelForSongs").style.display = "none";
|
||||
},
|
||||
OpenModelForArtists() {
|
||||
document.getElementById("ModelForArtists").style.display = "block";
|
||||
},
|
||||
closeModelForArtists() {
|
||||
document.getElementById("ModelForArtists").style.display = "none";
|
||||
},
|
||||
OpenModelForAddSongs(album) {
|
||||
this.album = { ...album };
|
||||
document.getElementById("ModalForAddSongs").style.display = "block";
|
||||
},
|
||||
CloseModalForAddSongs() {
|
||||
document.getElementById("ModalForAddSongs").style.display = "none";
|
||||
},
|
||||
saveSongs(id) {
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).post(this.URL + `album/${id}/addSongs`, this.selectedSongs)
|
||||
.then(() => {
|
||||
this.getSongsFromAlbum(id);
|
||||
this.CloseModalForAddSongs();
|
||||
console.log(this.songs);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getSongsFromUndefinedAlbum(){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/getSongsUndefined`)
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
deleteSongFromAlbum(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `album/deleteSongFromAlbum/${id}`)
|
||||
.then(() =>{
|
||||
this.getSongsFromAlbum();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
OpenModelForAddArtists(status, album = null) {
|
||||
if (status === "create") {
|
||||
this.album = new Album();
|
||||
this.album.status = "create";
|
||||
} else if (status === "edit" && album) {
|
||||
this.album = { ...album };
|
||||
this.album.status = "edit";
|
||||
}
|
||||
this.open = this.album.artistIds ? [...this.album.artistIds] : []; // Создаём новый массив, чтобы избежать проблем с ссылками
|
||||
this.loadSelectedArtists(); // Загрузка выбранных альбомов при открытии модального окна
|
||||
document.getElementById("openModalForAddArtists").style.display = "block";
|
||||
},
|
||||
closeModalForAddArtists() {
|
||||
document.getElementById("openModalForAddArtists").style.display = "none";
|
||||
this.open = [...this.selectedArtists]; // Обновление массива open значениями из selectedAlbums
|
||||
this.selectedArtists = []; // Сброс выбранных альбомов
|
||||
this.album = new Album(); // Сброс текущего предмета при закрытии модального окна
|
||||
},
|
||||
loadSelectedArtists() {
|
||||
// Загрузка выбранных альбомов из массива open
|
||||
this.selectedArtists = [...this.open];
|
||||
},
|
||||
addArtistToAlbum(id, list) {
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.post(this.URL + `album/${id}/addArtistToAlbum`, list)
|
||||
.then(() => {
|
||||
this.closeModalForAddArtists();
|
||||
this.getAlbums(); // Обновляем список исполнителей после успешного добавления
|
||||
this.open = [...this.selectedArtists]; // Обновляем массив выбранных альбомов
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getArtists(){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "artist")
|
||||
.then(response => {
|
||||
this.artists = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
</style>
|
147
front/src/pages/artists.vue
Normal file
147
front/src/pages/artists.vue
Normal file
@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<div class="container mt-4">
|
||||
<h1 class="text-center mb-4">Исполнители</h1>
|
||||
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Жанр</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="art in artists" :key="art.id">
|
||||
<td>{{ art.artistName }}</td>
|
||||
<td>{{ art.genre }}</td>
|
||||
<td>
|
||||
<td>
|
||||
<button class="btn btn-primary mr-2" @click="openModal('edit', art)">Изменить</button>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" @click="deleteArtist(art.id)">Удалить</button>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--Форма для создания и добавления исполнителей -->
|
||||
<div class="modal" tabindex="-1" id="editModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Исполнитель</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="artistName">Имя:</label>
|
||||
<input type="text" class="form-control" id="artistName" name="artistName" v-model="artist.artistName">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="genre">Жанр:</label>
|
||||
<input type="text" class="form-control" id="genre" name="genre" v-model="artist.genre">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal()">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" v-if="artist.status === 'create'" @click="addArtist(artist)">Создать</button>
|
||||
<button type="button" class="btn btn-primary" v-else @click="editArtist(artist)">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import 'axios';
|
||||
import axios from "axios";
|
||||
import Artist from "@/models/Artist";
|
||||
import Album from "@/models/Album";
|
||||
export default {
|
||||
created() {
|
||||
this.getArtists();
|
||||
},
|
||||
data() {
|
||||
return{
|
||||
artists: [],
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
artist: new Artist(),
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getArtists(){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "artist")
|
||||
.then(response => {
|
||||
this.artists = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
addArtist(artist){
|
||||
console.log(artist);
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).post(this.URL + "artist", artist)
|
||||
.then(() => {
|
||||
this.getArtists();
|
||||
this.closeModal();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
deleteArtist(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `artist/${id}`)
|
||||
.then(() =>{
|
||||
this.getArtists();
|
||||
})
|
||||
},
|
||||
editArtist(artist){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `artist/${artist.id}`, artist)
|
||||
.then(() =>{
|
||||
const index = this.artists.findIndex((s) => s.id === artist.id);
|
||||
if (index !== -1) {
|
||||
this.artists[index] = { ...artist };
|
||||
}
|
||||
this.closeModal();
|
||||
this.getArtists();
|
||||
})
|
||||
this.closeModal();
|
||||
},
|
||||
openModal(status, artist = null) {
|
||||
if (status === "create") {
|
||||
this.artist = new Artist();
|
||||
this.artist.status = "create";
|
||||
} else if (status === "edit" && artist) {
|
||||
this.artist = { ...artist };
|
||||
this.artist.status = "edit";
|
||||
}
|
||||
document.getElementById("editModal").style.display = "block";
|
||||
},
|
||||
closeModal() {
|
||||
document.getElementById("editModal").style.display = "none";
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
</style>
|
9
front/src/pages/error.vue
Normal file
9
front/src/pages/error.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<a>Ошибка доступа</a>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
85
front/src/pages/find.vue
Normal file
85
front/src/pages/find.vue
Normal file
@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="search-box">
|
||||
<label for="searchName"><h2>Введите имя для поиска:</h2></label>
|
||||
<input type="text" class="form-control" id="searchName" v-model="name" @input="onInput">
|
||||
<br>
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary" @click="getByName(name)">Поиск</button>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<h2>Результат поиска "{{ name }}"</h2>
|
||||
<div v-if="searchResult">
|
||||
<h3>Песни</h3>
|
||||
<ul>
|
||||
<li v-for="song in searchResult.songs" :key="song.id">
|
||||
{{ song.songName }}
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Альбомы</h3>
|
||||
<ul>
|
||||
<li v-for="album in searchResult.albums" :key="album.id">
|
||||
{{ album.albumName }}
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Исполнители</h3>
|
||||
<ul>
|
||||
<li v-for="artist in searchResult.artists" :key="artist.id">
|
||||
{{ artist.artistName }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>Поиск не дал результатов</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import 'axios';
|
||||
import axios from "axios";
|
||||
import Album from "@/models/Album";
|
||||
import Song from "@/models/Song";
|
||||
import Artist from "@/models/Artist";
|
||||
export default {
|
||||
name: 'example',
|
||||
data() {
|
||||
return {
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
name: undefined,
|
||||
albums: [],
|
||||
songs: [],
|
||||
artists: [],
|
||||
searchResult: new Object(),
|
||||
};
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onInput(event) {
|
||||
this.name = event.target.value;
|
||||
},
|
||||
getByName(name){
|
||||
console.log(name);
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `find/get/${name}`)
|
||||
.then(response => {
|
||||
this.searchResult = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
83
front/src/pages/login.vue
Normal file
83
front/src/pages/login.vue
Normal file
@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="login">
|
||||
<form @submit.prevent class="login__form" action="/">
|
||||
<div class="form__login">
|
||||
<input class="login-input form-control"
|
||||
id="login" v-model="newUser.login"
|
||||
validate="false"
|
||||
placeholder="Логин"
|
||||
type="text"
|
||||
name="Логин">
|
||||
</div>
|
||||
<div class="form__password">
|
||||
<input class="password-input form-control"
|
||||
id="password" v-model="newUser.password"
|
||||
validate="false"
|
||||
placeholder="Пароль"
|
||||
type="password"
|
||||
name="Пароль">
|
||||
</div>
|
||||
<div class="login__buttons mt-5">
|
||||
<button type="submit" class="login__confirm btn btn-primary" id="login__confirm" @click="login">Войти</button>
|
||||
<a class="login__registration" href="registration">Регистрация</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
export default {
|
||||
mounted(){
|
||||
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
newUser: new Object,
|
||||
token: '',
|
||||
user: '',
|
||||
role: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async login() {
|
||||
await this.getRole()
|
||||
try {
|
||||
const response = await axios.post(`http://localhost:8080/jwt/login`, this.newUser);
|
||||
if (response.status === 200) {
|
||||
localStorage.setItem("token", response.data);
|
||||
localStorage.setItem("user", this.newUser.login);
|
||||
this.token = response.data;
|
||||
this.user = this.newUser.login;
|
||||
this.$emit('login', {
|
||||
token: this.token,
|
||||
user: this.newUser.login,
|
||||
role: this.role,
|
||||
});
|
||||
this.$router.push("/")
|
||||
} else {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
localStorage.removeItem("role");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
async getRole(){
|
||||
await axios.get(`http://localhost:8080/who_am_i?userLogin=${this.newUser.login}`)
|
||||
.then((response) => {
|
||||
localStorage.setItem("role", response.data)
|
||||
this.role = response.data
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
47
front/src/pages/registration.vue
Normal file
47
front/src/pages/registration.vue
Normal file
@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div class="registration">
|
||||
<form @submit.prevent="registration" class="registration__form" action="#">
|
||||
<div class="form__login">
|
||||
<input class="login-input form-control" v-model="login" id="login" required="" validate="false" placeholder="Логин" type="text" name="Логин">
|
||||
</div>
|
||||
<div class="form__password">
|
||||
<input class="password-input form-control" v-model="password" id="password" required="" validate="false" placeholder="Пароль" type="password" name="Пароль">
|
||||
</div>
|
||||
<br>
|
||||
<div class="registration__buttons">
|
||||
<button class="registration__confirm btn btn-primary" id="reg_btn" type="submit">Зарегестрироваться</button><a class="registration__login" href="/login">Уже есть аккаунт</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
export default {
|
||||
data(){
|
||||
return{
|
||||
login: "",
|
||||
password: "",
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
registration(){
|
||||
// Отправляем данные формы на сервер
|
||||
let user = {
|
||||
login: this.login,
|
||||
password: this.password,
|
||||
passwordConfirm: this.password
|
||||
}
|
||||
axios.post(`http://localhost:8080/sign_up`, user)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
alert(response.data);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
this.$router.push('/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
180
front/src/pages/songs.vue
Normal file
180
front/src/pages/songs.vue
Normal file
@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div class="container mt-4">
|
||||
<h1 class="text-center mb-4">Песни</h1>
|
||||
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Продолжительность</th>
|
||||
<th>Альбом</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="son in songs" :key="son.id">
|
||||
<td>{{ son.songName }}</td>
|
||||
<td>{{ son.duration }}</td>
|
||||
<td>{{ son.albumName || 'No Album'}}</td>
|
||||
<td>
|
||||
<td>
|
||||
<button class="btn btn-primary mr-2" @click="openModal('edit', son)">Изменить</button>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" @click="deleteSong(son.id)">Удалить</button>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal" tabindex="-1" id="editModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Песня</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="songName">Название:</label>
|
||||
<input type="text" class="form-control" id="songName" name="songName" v-model="editedSong.songName">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="duration">Продолжительность:</label>
|
||||
<input type="number" class="form-control" id="duration" name="duration" step="0.1" v-model="editedSong.duration">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal()">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" v-if="editedSong.status === 'create'" @click="addSong(editedSong)">Создать</button>
|
||||
<button type="button" class="btn btn-primary" v-else @click="editSong(editedSong)">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import 'axios';
|
||||
import axios from "axios";
|
||||
import Song from "@/models/Song";
|
||||
export default {
|
||||
name: 'Songs',
|
||||
emits: ['login'],
|
||||
created() {
|
||||
this.getSongs();
|
||||
this.getAlbums();
|
||||
},
|
||||
mounted() {
|
||||
const addModal = document.getElementById('editModal');
|
||||
addModal.addEventListener('shown.bs.modal', function () {
|
||||
})
|
||||
},
|
||||
|
||||
data() {
|
||||
return{
|
||||
songs: [],
|
||||
albums: [],
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
song: new Song(),
|
||||
editedSong: new Song(),
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSongs(){
|
||||
axios
|
||||
.create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.get(this.URL + "song")
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getAlbums() {
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "song/albums")
|
||||
.then(response => {
|
||||
this.albums = response.data;
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
addSong(song) {
|
||||
console.log(song);
|
||||
song.album = null;
|
||||
console.log(song);
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.post(this.URL + "song", song)
|
||||
.then(() => {
|
||||
this.getSongs();
|
||||
this.closeModal();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
deleteSong(id){
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `song/${id}`)
|
||||
.then(() =>{
|
||||
this.getSongs();
|
||||
})
|
||||
},
|
||||
openModal(status, song = null) {
|
||||
if (status === "create") {
|
||||
this.editedSong = new Song();
|
||||
this.editedSong.status = "create";
|
||||
} else if (status === "edit" && song) {
|
||||
this.editedSong = { ...song };
|
||||
this.editedSong.status = "edit";
|
||||
}
|
||||
|
||||
document.getElementById("editModal").style.display = "block";
|
||||
},
|
||||
closeModal() {
|
||||
document.getElementById("editModal").style.display = "none";
|
||||
},
|
||||
editSong(song) {
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `song/${song.id}`, song)
|
||||
.then(() => {
|
||||
const index = this.songs.findIndex((s) => s.id === song.id);
|
||||
if (index !== -1) {
|
||||
this.songs[index] = { ...song };
|
||||
}
|
||||
this.closeModal();
|
||||
this.getSongs();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
</style>
|
64
front/src/pages/users.vue
Normal file
64
front/src/pages/users.vue
Normal file
@ -0,0 +1,64 @@
|
||||
<template >
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Логин</th>
|
||||
<th scope="col">Роль</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(user, index) in users" :key="index">
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.login }}</td>
|
||||
<td>{{ user.userRole }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
data(){
|
||||
return{
|
||||
users: [],
|
||||
userRole: "",
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
created(){
|
||||
const getTokenForHeader = function () {
|
||||
return "Bearer " + localStorage.getItem("token");
|
||||
}
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Authorization": getTokenForHeader(),
|
||||
}
|
||||
};
|
||||
axios.create({
|
||||
headers: {'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get('http://localhost:8080', requestParams)
|
||||
.then(response => {
|
||||
this.users = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.response && error.response.status === 403) {
|
||||
console.error("Forbidden: User does not have permission to perform this operation");
|
||||
} else {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style >
|
||||
|
||||
</style>
|
48
front/src/router/index.js
Normal file
48
front/src/router/index.js
Normal file
@ -0,0 +1,48 @@
|
||||
import artists from "../pages/artists.vue"
|
||||
import albums from "../pages/albums.vue"
|
||||
import songs from "../pages/songs.vue"
|
||||
import find from "../pages/find.vue"
|
||||
import users from "../pages/users.vue";
|
||||
import login from "../pages/login.vue";
|
||||
import registration from "../pages/registration.vue";
|
||||
import error from "../pages/error.vue";
|
||||
|
||||
import {createRouter, createWebHistory} from "vue-router"
|
||||
|
||||
const routes = [
|
||||
{path: '/songs', component: songs, meta: { requiresAuth: true }},
|
||||
{path: '/albums', component: albums, meta: { requiresAuth: true }},
|
||||
{path: '/artists', component: artists, meta: { requiresAuth: true }},
|
||||
{path: '/find', component: find, meta: { requiresAuth: true }},
|
||||
{ path: "/users", component: users, meta: { requiresAuth: true, requiresAdmin: true }},
|
||||
{ path: "/login", component: login},
|
||||
{ path: "/registration", component: registration},
|
||||
{ path: "/error", component: error, meta: { requiresAuth: true }},
|
||||
{ path: "/", component: songs, meta: { requiresAuth: true }},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
linkActiveClass: 'active',
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const isAuthenticated = localStorage.getItem("token");
|
||||
if (to.matched.some((route) => route.meta.requiresAuth)) {
|
||||
if (!isAuthenticated) {
|
||||
next("/login");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const isAdmin = localStorage.getItem("role") === "ADMIN";
|
||||
if (to.matched.some((route) => route.meta.requiresAdmin)) {
|
||||
if (!isAdmin) {
|
||||
next("/error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
export default router;
|
0
front/src/style.css
Normal file
0
front/src/style.css
Normal file
15
front/src/views/AboutView.vue
Normal file
15
front/src/views/AboutView.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<h1>This is an about page</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@media (min-width: 1024px) {
|
||||
.about {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
9
front/src/views/HomeView.vue
Normal file
9
front/src/views/HomeView.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<script setup>
|
||||
import TheWelcome from '../components/TheWelcome.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<TheWelcome />
|
||||
</main>
|
||||
</template>
|
14
front/vite.config.js
Normal file
14
front/vite.config.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
}
|
||||
})
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
240
gradlew
vendored
Normal file
240
gradlew
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
91
gradlew.bat
vendored
Normal file
91
gradlew.bat
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "PIbd-22_Artamonova_T.V._IP",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'sbapp'
|
@ -0,0 +1,13 @@
|
||||
package ru.ulstu.is.sbapp.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import ru.ulstu.is.sbapp.database.model.Album;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IAlbumRepository extends JpaRepository<Album, Long> {
|
||||
|
||||
@Query("SELECT a FROM Album a WHERE a.albumName = :name")
|
||||
List<Album> getAlbumsByName(String name);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ru.ulstu.is.sbapp.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IArtistRepository extends JpaRepository<Artist, Long> {
|
||||
@Query(value = "SELECT * FROM artist_album", nativeQuery = true)
|
||||
List<Object[]> getAllArtistAlbum();
|
||||
|
||||
@Query("SELECT a FROM Artist a WHERE a.artistName = :name")
|
||||
List<Artist> getArtistsByName(String name);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.ulstu.is.sbapp.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISongRepository extends JpaRepository<Song, Long> {
|
||||
@Query("SELECT s.songs FROM Album s WHERE :song MEMBER OF s.songs")
|
||||
List<Song> findSongsInAlbum(@Param("song") Song song);
|
||||
|
||||
@Query("SELECT s FROM Song s WHERE s.songName = :name")
|
||||
List<Song> getSongsByName(String name);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package ru.ulstu.is.sbapp.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import ru.ulstu.is.sbapp.database.model.User;
|
||||
|
||||
public interface IUserRepository extends JpaRepository<User, Long> {
|
||||
@Query("SELECT u FROM User u WHERE u.login = :login")
|
||||
User findOneByLoginIgnoreCase(String login);
|
||||
}
|
13
src/main/java/ru/ulstu/is/sbapp/SbappApplication.java
Normal file
13
src/main/java/ru/ulstu/is/sbapp/SbappApplication.java
Normal file
@ -0,0 +1,13 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
|
||||
public class SbappApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SbappApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
public class JwtException extends RuntimeException {
|
||||
public JwtException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public JwtException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
70
src/main/java/ru/ulstu/is/sbapp/configuration/JwtFilter.java
Normal file
70
src/main/java/ru/ulstu/is/sbapp/configuration/JwtFilter.java
Normal file
@ -0,0 +1,70 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
import ru.ulstu.is.sbapp.database.service.UserService;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class JwtFilter extends GenericFilterBean {
|
||||
private static final String AUTHORIZATION = "Authorization";
|
||||
public static final String TOKEN_BEGIN_STR = "Bearer ";
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public JwtFilter(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
private String getTokenFromRequest(HttpServletRequest request) {
|
||||
String bearer = request.getHeader(AUTHORIZATION);
|
||||
if (StringUtils.hasText(bearer) && bearer.startsWith(TOKEN_BEGIN_STR)) {
|
||||
return bearer.substring(TOKEN_BEGIN_STR.length());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void raiseException(ServletResponse response, int status, String message) throws IOException {
|
||||
if (response instanceof final HttpServletResponse httpResponse) {
|
||||
httpResponse.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
httpResponse.setStatus(status);
|
||||
final byte[] body = new ObjectMapper().writeValueAsBytes(message);
|
||||
response.getOutputStream().write(body);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request,
|
||||
ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
if (request instanceof final HttpServletRequest httpRequest) {
|
||||
final String token = getTokenFromRequest(httpRequest);
|
||||
if (StringUtils.hasText(token)) {
|
||||
try {
|
||||
final UserDetails user = userService.loadUserByToken(token);
|
||||
final UsernamePasswordAuthenticationToken auth =
|
||||
new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
} catch (JwtException e) {
|
||||
raiseException(response, HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
raiseException(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
String.format("Internal error: %s", e.getMessage()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "jwt", ignoreInvalidFields = true)
|
||||
public class JwtProperties {
|
||||
private String devToken = "";
|
||||
private Boolean isDev = true;
|
||||
|
||||
public String getDevToken() {
|
||||
return devToken;
|
||||
}
|
||||
|
||||
public void setDevToken(String devToken) {
|
||||
this.devToken = devToken;
|
||||
}
|
||||
|
||||
public Boolean isDev() {
|
||||
return isDev;
|
||||
}
|
||||
|
||||
public void setDev(Boolean dev) {
|
||||
isDev = dev;
|
||||
}
|
||||
}
|
108
src/main/java/ru/ulstu/is/sbapp/configuration/JwtProvider.java
Normal file
108
src/main/java/ru/ulstu/is/sbapp/configuration/JwtProvider.java
Normal file
@ -0,0 +1,108 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTVerificationException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.auth0.jwt.interfaces.JWTVerifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class JwtProvider {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(JwtProvider.class);
|
||||
|
||||
private final static byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
|
||||
private final static String ISSUER = "auth0";
|
||||
|
||||
private final Algorithm algorithm;
|
||||
private final JWTVerifier verifier;
|
||||
|
||||
public JwtProvider(JwtProperties jwtProperties) {
|
||||
if (!jwtProperties.isDev()) {
|
||||
LOG.info("Generate new JWT key for prod");
|
||||
try {
|
||||
final MessageDigest salt = MessageDigest.getInstance("SHA-256");
|
||||
salt.update(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
|
||||
LOG.info("Use generated JWT key for prod \n{}", bytesToHex(salt.digest()));
|
||||
algorithm = Algorithm.HMAC256(bytesToHex(salt.digest()));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new JwtException(e);
|
||||
}
|
||||
} else {
|
||||
LOG.info("Use default JWT key for dev \n{}", jwtProperties.getDevToken());
|
||||
algorithm = Algorithm.HMAC256(jwtProperties.getDevToken());
|
||||
}
|
||||
verifier = JWT.require(algorithm)
|
||||
.withIssuer(ISSUER)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
byte[] hexChars = new byte[bytes.length * 2];
|
||||
for (int j = 0; j < bytes.length; j++) {
|
||||
int v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
|
||||
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
|
||||
}
|
||||
return new String(hexChars, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public String generateToken(String login) {
|
||||
final Date issueDate = Date.from(LocalDate.now()
|
||||
.atStartOfDay(ZoneId.systemDefault())
|
||||
.toInstant());
|
||||
final Date expireDate = Date.from(LocalDate.now()
|
||||
.plusDays(15)
|
||||
.atStartOfDay(ZoneId.systemDefault())
|
||||
.toInstant());
|
||||
var temp = JWT.create();
|
||||
var temp2 = temp.withIssuer(ISSUER);
|
||||
var temp3 = temp2.withIssuedAt(issueDate);
|
||||
var temp4 = temp3.withExpiresAt(expireDate);
|
||||
var temp5 = temp4.withSubject(login);
|
||||
var temp6 = temp5.sign(algorithm);
|
||||
return temp6;
|
||||
}
|
||||
|
||||
private DecodedJWT validateToken(String token) {
|
||||
try {
|
||||
return verifier.verify(token);
|
||||
} catch (JWTVerificationException e) {
|
||||
throw new JwtException(String.format("Token verification error: %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTokenValid(String token) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
validateToken(token);
|
||||
return true;
|
||||
} catch (JwtException e) {
|
||||
LOG.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<String> getLoginFromToken(String token) {
|
||||
try {
|
||||
return Optional.ofNullable(validateToken(token).getSubject());
|
||||
} catch (JwtException e) {
|
||||
LOG.error(e.getMessage());
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class OpenAPI30Configuration {
|
||||
public static final String API_PREFIX = "/api/1.0";
|
||||
|
||||
@Bean
|
||||
public OpenAPI customizeOpenAPI() {
|
||||
final String securitySchemeName = JwtFilter.TOKEN_BEGIN_STR;
|
||||
return new OpenAPI()
|
||||
.addSecurityItem(new SecurityRequirement()
|
||||
.addList(securitySchemeName))
|
||||
.components(new Components()
|
||||
.addSecuritySchemes(securitySchemeName, new SecurityScheme()
|
||||
.name(securitySchemeName)
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.scheme("bearer")
|
||||
.bearerFormat("JWT")));
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class PasswordEncoderConfiguration {
|
||||
@Bean
|
||||
public PasswordEncoder createPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import ru.ulstu.is.sbapp.controllers.UserController;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.service.UserService;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableMethodSecurity(securedEnabled = true, proxyTargetClass = true)
|
||||
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
|
||||
public static final String SPA_URL_MASK = "/{path:[^\\.]*}";
|
||||
private final UserService userService;
|
||||
private final JwtFilter jwtFilter;
|
||||
public SecurityConfiguration(UserService userService) {
|
||||
this.userService = userService;
|
||||
this.jwtFilter = new JwtFilter(userService);
|
||||
createAdminOnStartup();
|
||||
}
|
||||
private void createAdminOnStartup() {
|
||||
final String admin = "admin";
|
||||
if (userService.findByLogin(admin) == null) {
|
||||
log.info("Admin user successfully created");
|
||||
userService.addUser(admin, admin, admin, Role.ADMIN);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
log.info("Creating security configuration");
|
||||
http.cors()
|
||||
.and()
|
||||
.csrf().disable()
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/", SPA_URL_MASK).permitAll()
|
||||
.antMatchers("/who_i_am").permitAll()
|
||||
.antMatchers(HttpMethod.POST, UserController.URL_LOGIN).permitAll()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.anonymous().and().logout().permitAll();
|
||||
}
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder builder) throws Exception {
|
||||
builder.userDetailsService(userService);
|
||||
}
|
||||
@Override
|
||||
public void configure(WebSecurity web) {
|
||||
web.ignoring()
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**")
|
||||
.antMatchers("/**/*.{js,html,css,png}")
|
||||
.antMatchers("/swagger-ui/index.html")
|
||||
.antMatchers("/webjars/**")
|
||||
.antMatchers("/swagger-resources/**")
|
||||
.antMatchers("/v3/api-docs/**");
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package ru.ulstu.is.sbapp.configuration;
|
||||
|
||||
import org.springframework.boot.web.server.ErrorPage;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController(SecurityConfiguration.SPA_URL_MASK).setViewName("forward:/");
|
||||
registry.addViewController("/notFound").setViewName("forward:/");
|
||||
}
|
||||
@Bean
|
||||
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() {
|
||||
return container -> container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notFound"));
|
||||
}
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.configuration.OpenAPI30Configuration;
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
import ru.ulstu.is.sbapp.database.service.AlbumService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(OpenAPI30Configuration.API_PREFIX + "/album")
|
||||
public class AlbumController {
|
||||
private final AlbumService albumService;
|
||||
|
||||
public AlbumController(AlbumService albumService) {
|
||||
this.albumService = albumService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public AlbumDTO getAlbum(@PathVariable Long id){
|
||||
return new AlbumDTO(albumService.findAlbum(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<AlbumDTO> getAlbums(){
|
||||
return albumService.findAllAlbums().stream()
|
||||
.map(AlbumDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
|
||||
public AlbumDTO createAlbum(@RequestBody @Valid AlbumDTO albumDTO){
|
||||
return new AlbumDTO(albumService.addAlbum(albumDTO.getAlbumName(), albumDTO.getArtistIds()));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public AlbumDTO updateAlbum(@PathVariable Long id, @RequestBody @Valid AlbumDTO albumDTO){
|
||||
return new AlbumDTO(albumService.updateAlbum(id, albumDTO.getAlbumName()));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public AlbumDTO deleteAlbum(@PathVariable Long id){
|
||||
return new AlbumDTO(albumService.deleteAlbum(id));
|
||||
}
|
||||
|
||||
@GetMapping("/{albumId}/songs")
|
||||
public ResponseEntity<List<Song>> getSongsFromAlbum(@PathVariable Long albumId) {
|
||||
List<Song> songs = albumService.getSongFromAlbum(albumId);
|
||||
return ResponseEntity.ok(songs);
|
||||
}
|
||||
|
||||
@GetMapping("/{albumId}/getAllArtists")
|
||||
public ResponseEntity<List<Artist>> getArtistsInAlbum(@PathVariable Long albumId){
|
||||
List<Artist> artists = albumService.getArtistInAlbum(albumId);
|
||||
return ResponseEntity.ok(artists);
|
||||
}
|
||||
|
||||
@GetMapping("/getSongsUndefined")
|
||||
public ResponseEntity<List<Song>> getSongsFromUndefinedAlbum(){
|
||||
List<Song> songs = albumService.getSongsUndefined();
|
||||
return ResponseEntity.ok(songs);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/addSongs")
|
||||
public void addSongToAlbum(@PathVariable Long id, @RequestBody @Valid List<Long> songsIds){
|
||||
albumService.addSongToAlbum(id, songsIds);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteSongFromAlbum/{id}")
|
||||
public void deleteSongFromAlbum(@PathVariable Long id){
|
||||
albumService.deleteSongFromAlbum(id);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/addArtistToAlbum")
|
||||
public void addArtistToAlbum(@PathVariable Long id, @RequestBody @Valid List<Long> artistIds){
|
||||
albumService.addArtistToAlbum(id, artistIds);
|
||||
}
|
||||
}
|
39
src/main/java/ru/ulstu/is/sbapp/controllers/AlbumDTO.java
Normal file
39
src/main/java/ru/ulstu/is/sbapp/controllers/AlbumDTO.java
Normal file
@ -0,0 +1,39 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
import ru.ulstu.is.sbapp.database.model.Album;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AlbumDTO {
|
||||
private Long id;
|
||||
private String albumName;
|
||||
private List<Long> artistIds;
|
||||
public AlbumDTO(){
|
||||
|
||||
}
|
||||
public AlbumDTO(Album album){
|
||||
this.id = album.getId();
|
||||
this.albumName = album.getAlbumName();
|
||||
this.artistIds = artistIds != null ? artistIds : new ArrayList<Long>();
|
||||
}
|
||||
|
||||
public Long getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAlbumName(){
|
||||
return albumName;
|
||||
}
|
||||
|
||||
public void setId(Long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAlbumName(String name){
|
||||
this.albumName = name;
|
||||
}
|
||||
|
||||
public List<Long> getArtistIds(){
|
||||
return artistIds;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.configuration.OpenAPI30Configuration;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.service.ArtistService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(OpenAPI30Configuration.API_PREFIX + "/artist")
|
||||
public class ArtistController {
|
||||
private final ArtistService artistService;
|
||||
|
||||
public ArtistController(ArtistService artistService) {
|
||||
this.artistService = artistService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ArtistDTO getArtist(@PathVariable Long id){
|
||||
return new ArtistDTO(artistService.findArtist(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<ArtistDTO> getArtist(){
|
||||
return artistService.findAllArtists().stream()
|
||||
.map(ArtistDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
|
||||
public ArtistDTO createArtist(@RequestBody @Valid ArtistDTO artistDTO){
|
||||
return new ArtistDTO(artistService.addArtist(artistDTO.getArtistName(), artistDTO.getGenre()));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ArtistDTO updateArtist(@PathVariable Long id, @RequestBody @Valid ArtistDTO artistDTO){
|
||||
return new ArtistDTO(artistService.updateArtist(id, artistDTO.getArtistName(), artistDTO.getGenre()));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ArtistDTO deleteArtist(@PathVariable Long id){
|
||||
return new ArtistDTO(artistService.deleteArtist(id));
|
||||
}
|
||||
|
||||
@GetMapping("/getAllArtistAlbum")
|
||||
public List<Object[]> getAllArtistAlbum(){
|
||||
return artistService.getAllArtistAlbum();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/addArtistToAlbum")
|
||||
public void addArtistToAlbum(@PathVariable Long id, @RequestBody @Valid List<Long> groupsIds){
|
||||
artistService.addArtistToAlbum(id, groupsIds);
|
||||
}
|
||||
}
|
45
src/main/java/ru/ulstu/is/sbapp/controllers/ArtistDTO.java
Normal file
45
src/main/java/ru/ulstu/is/sbapp/controllers/ArtistDTO.java
Normal file
@ -0,0 +1,45 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArtistDTO {
|
||||
private Long id;
|
||||
private String artistName;
|
||||
private String genre;
|
||||
private List<Long> albumIds;
|
||||
public ArtistDTO(){
|
||||
|
||||
}
|
||||
public ArtistDTO(Artist artist){
|
||||
this.id = artist.getId();
|
||||
this.artistName = artist.getArtistName();
|
||||
this.genre = artist.getGenre();
|
||||
this.albumIds = artist.getAlbumIds();
|
||||
}
|
||||
|
||||
public Long getId(){
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getArtistName(){
|
||||
return artistName;
|
||||
}
|
||||
|
||||
public String getGenre(){
|
||||
return genre;
|
||||
}
|
||||
|
||||
public void setGenre(String genre){
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
public List<Long> getAlbumIds(){
|
||||
return albumIds;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.is.sbapp.service.ServiceType;
|
||||
|
||||
@RestController
|
||||
public class MainController {
|
||||
private final ServiceType Service;
|
||||
|
||||
public MainController(ServiceType service) {
|
||||
Service = service;
|
||||
}
|
||||
|
||||
@GetMapping("/Func1")
|
||||
public Object Func1(@RequestParam(value = "Type") String Type,
|
||||
@RequestParam(value = "value1") Object value1,
|
||||
@RequestParam(value = "value2") Object value2){
|
||||
return Service.Func1(value1,value2,Type);
|
||||
}
|
||||
|
||||
@GetMapping("/Func2")
|
||||
public Object Func2(@RequestParam(value = "Type") String Type,
|
||||
@RequestParam(value = "value1") Object value1,
|
||||
@RequestParam(value = "value2") Object value2){
|
||||
return Service.Func2(value1, value2, Type);
|
||||
}
|
||||
|
||||
@GetMapping("/Func3")
|
||||
public Object Func3(@RequestParam(value = "Type") String Type,
|
||||
@RequestParam(value = "value1") Object value1,
|
||||
@RequestParam(value = "value2") Object value2){
|
||||
return Service.Func3(value1,value2,Type);
|
||||
}
|
||||
|
||||
@GetMapping("/Func4")
|
||||
public Object Func4(@RequestParam(value = "Type") String Type,
|
||||
@RequestParam(value = "value1") Object value1,
|
||||
@RequestParam(value = "value2") Object value2){
|
||||
return Service.Func4(value1,value2,Type);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.is.sbapp.configuration.OpenAPI30Configuration;
|
||||
import ru.ulstu.is.sbapp.database.service.FindByNameService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(OpenAPI30Configuration.API_PREFIX + "/find")
|
||||
public class SearchController {
|
||||
private final FindByNameService findService;
|
||||
|
||||
public SearchController(FindByNameService findService) {
|
||||
this.findService = findService;
|
||||
}
|
||||
|
||||
@GetMapping("/get/{name}")
|
||||
public Map<String, List<Object>> getByName(@PathVariable String name){
|
||||
return findService.GetByName(name);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.configuration.OpenAPI30Configuration;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.service.AlbumService;
|
||||
import ru.ulstu.is.sbapp.database.service.SongService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(OpenAPI30Configuration.API_PREFIX + "/song")
|
||||
public class SongController {
|
||||
private final SongService songService;
|
||||
private final AlbumService albumService;
|
||||
|
||||
public SongController(SongService songService, AlbumService albumService) {
|
||||
this.songService = songService;
|
||||
this.albumService = albumService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public SongDTO getSong(@PathVariable Long id){
|
||||
return new SongDTO(songService.findSong(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<SongDTO> getSongs(){
|
||||
return songService.findAllSongs().stream()
|
||||
.map(SongDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
|
||||
public SongDTO createSong(@RequestBody @Valid SongDTO songDTO){
|
||||
return new SongDTO(songService.addSong(songDTO.getSongName(), songDTO.getDuration()));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public SongDTO updateSong(@PathVariable Long id, @RequestBody @Valid SongDTO songDTO) {
|
||||
return new SongDTO(songService.updateSong(id, songDTO.getSongName(), songDTO.getDuration()));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public SongDTO deleteSong(@PathVariable Long id){
|
||||
return new SongDTO(songService.deleteSong(id));
|
||||
}
|
||||
|
||||
@GetMapping("/albums")
|
||||
public List<AlbumDTO> getAlbums() {
|
||||
return albumService.findAllAlbums().stream()
|
||||
.map(AlbumDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
57
src/main/java/ru/ulstu/is/sbapp/controllers/SongDTO.java
Normal file
57
src/main/java/ru/ulstu/is/sbapp/controllers/SongDTO.java
Normal file
@ -0,0 +1,57 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
public class SongDTO {
|
||||
private Long id;
|
||||
private String songName;
|
||||
private Double duration;
|
||||
private Long albumId;
|
||||
private String albumName;
|
||||
|
||||
public SongDTO() {
|
||||
}
|
||||
public SongDTO(Song song) {
|
||||
this.id = song.getId();
|
||||
this.songName = song.getSongName();
|
||||
this.duration = song.getDuration();
|
||||
if(song.getAlbum() != null){
|
||||
this.albumName = song.getAlbum().getAlbumName();
|
||||
}
|
||||
}
|
||||
|
||||
public String getAlbumName() {
|
||||
return albumName;
|
||||
}
|
||||
public Long getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getSongName(){
|
||||
return songName;
|
||||
}
|
||||
|
||||
public Double getDuration(){
|
||||
return duration;
|
||||
}
|
||||
|
||||
public Long getAlbumId(){
|
||||
return albumId;
|
||||
}
|
||||
|
||||
public void setAlbumId(long id){
|
||||
this.albumId = id;
|
||||
}
|
||||
|
||||
public void setId(long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setSongName(String name){
|
||||
this.songName = name;
|
||||
}
|
||||
|
||||
public void setDuration(Double duration){
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.database.model.User;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.service.UserService;
|
||||
import ru.ulstu.is.sbapp.database.util.validation.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
public static final String URL_LOGIN = "/jwt/login";
|
||||
public static final String URL_SIGN_UP = "/sign_up";
|
||||
public static final String URL_WHO_AM_I = "/who_am_i";
|
||||
private final UserService userService;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
@PostMapping(URL_LOGIN)
|
||||
public String login(@RequestBody @Valid UserDTO userDto) {
|
||||
return userService.loginAndGetToken(userDto);
|
||||
}
|
||||
@GetMapping(URL_WHO_AM_I)
|
||||
public String role(@RequestParam("userLogin") String userLogin) {
|
||||
return userService.findByLogin(userLogin).getUserRole().name();
|
||||
}
|
||||
@PostMapping(URL_SIGN_UP)
|
||||
public String signUp(@RequestBody @Valid UserSignUpDTO userSignupDto) {
|
||||
try {
|
||||
final User user = userService.addUser(userSignupDto.getLogin(),
|
||||
userSignupDto.getPassword(), userSignupDto.getPasswordConfirm(), Role.USER);
|
||||
return "created " + user.getLogin();
|
||||
} catch (ValidationException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
@GetMapping("/{id}")
|
||||
public UserDTO getUser(@PathVariable Long id) {
|
||||
return new UserDTO(userService.findUser(id));
|
||||
}
|
||||
@GetMapping("/")
|
||||
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
|
||||
public List<UserDTO> getUsers() {
|
||||
return userService.findAllUsers().stream()
|
||||
.map(UserDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public UserDTO updateUser(@RequestBody @Valid UserDTO userDto){
|
||||
return new UserDTO(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public void deleteUser(@PathVariable Long id) {
|
||||
userService.deleteUser(id);
|
||||
}
|
||||
}
|
52
src/main/java/ru/ulstu/is/sbapp/controllers/UserDTO.java
Normal file
52
src/main/java/ru/ulstu/is/sbapp/controllers/UserDTO.java
Normal file
@ -0,0 +1,52 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
import ru.ulstu.is.sbapp.database.model.User;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
|
||||
public class UserDTO {
|
||||
private Long id;
|
||||
private Role role;
|
||||
private String login;
|
||||
private String password;
|
||||
|
||||
public UserDTO(){}
|
||||
|
||||
public UserDTO(User user) {
|
||||
this.id=user.getId();
|
||||
this.login= user.getLogin();
|
||||
this.password = user.getPassword();
|
||||
this.role = user.getUserRole();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLogin()
|
||||
{
|
||||
return login;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public Role getUserRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setLogin(String login)
|
||||
{
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ru.ulstu.is.sbapp.controllers;
|
||||
|
||||
|
||||
public class UserSignUpDTO {
|
||||
private String login;
|
||||
|
||||
private String password;
|
||||
|
||||
private String passwordConfirm;
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public String getPasswordConfirm() {
|
||||
return passwordConfirm;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setPasswordConfirm(String passwordConfirm) {
|
||||
this.passwordConfirm = passwordConfirm;
|
||||
}
|
||||
}
|
104
src/main/java/ru/ulstu/is/sbapp/database/model/Album.java
Normal file
104
src/main/java/ru/ulstu/is/sbapp/database/model/Album.java
Normal file
@ -0,0 +1,104 @@
|
||||
package ru.ulstu.is.sbapp.database.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "albums")
|
||||
public class Album {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String albumName;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(cascade = CascadeType.MERGE, mappedBy = "album")
|
||||
private List<Song> songs;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "artist_album",
|
||||
joinColumns = {@JoinColumn(name = "album_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "artist_id")})
|
||||
private List<Artist> artists;
|
||||
|
||||
public Album() {
|
||||
this.songs = new ArrayList<>();
|
||||
this.artists = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Album(String name) {
|
||||
this.albumName = name;
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getAlbumName() { return albumName; }
|
||||
public void setAlbumName(String name) { this.albumName = name; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Album album = (Album) o;
|
||||
return Objects.equals(id, album.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Album{" +
|
||||
"id=" + id +
|
||||
", name='" + albumName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public void setSong(Song song){
|
||||
this.songs.add(song);
|
||||
if(song.getAlbum() != this){
|
||||
song.setAlbum(this);
|
||||
}
|
||||
}
|
||||
public List<Song> getSongs(){
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void setSongs(List<Song> songs) {
|
||||
this.songs = songs;
|
||||
}
|
||||
|
||||
public List<Artist> getArtists(){
|
||||
return artists;
|
||||
}
|
||||
|
||||
public void setArtists(List<Artist> artists) {
|
||||
this.artists = artists != null ? artists : new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addArtist(Artist artist) {
|
||||
artists.add(artist);
|
||||
artist.getAlbums().add(this);
|
||||
}
|
||||
|
||||
public List<Long> getArtistIds() {
|
||||
if (artists.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Long> artistIds = new ArrayList<>();
|
||||
for (Artist artist : artists) {
|
||||
if (!artistIds.contains(artist.getId())) {
|
||||
artistIds.add(artist.getId());
|
||||
}
|
||||
}
|
||||
return artistIds;
|
||||
}
|
||||
}
|
||||
}
|
81
src/main/java/ru/ulstu/is/sbapp/database/model/Artist.java
Normal file
81
src/main/java/ru/ulstu/is/sbapp/database/model/Artist.java
Normal file
@ -0,0 +1,81 @@
|
||||
package ru.ulstu.is.sbapp.database.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "artists")
|
||||
public class Artist {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String artistName;
|
||||
private String genre;
|
||||
@JsonBackReference
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "artist_album",
|
||||
joinColumns = {@JoinColumn(name = "artist_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "album_id")})
|
||||
private List<Album> albums = new ArrayList<>();
|
||||
|
||||
public Artist() {
|
||||
}
|
||||
|
||||
public Artist(String name, String genre) {
|
||||
this.artistName = name;
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getArtistName() { return artistName; }
|
||||
public void setArtistName(String name) { this.artistName = name; }
|
||||
public String getGenre() { return genre; }
|
||||
public void setGenre(String genre) { this.genre = genre; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Artist artist = (Artist) o;
|
||||
return Objects.equals(id, artist.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Artist{" +
|
||||
"id=" + id +
|
||||
", name='" + artistName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public List<Album> getAlbums(){
|
||||
return albums;
|
||||
}
|
||||
|
||||
public void setAlbums(List<Album> albums) {
|
||||
this.albums = albums;
|
||||
}
|
||||
|
||||
public List<Long> getAlbumIds() {
|
||||
if (albums.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Long> albumIds = new ArrayList<>();
|
||||
for (Album album : albums) {
|
||||
if (!albumIds.contains(album.getId())) {
|
||||
albumIds.add(album.getId());
|
||||
}
|
||||
}
|
||||
return albumIds;
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/java/ru/ulstu/is/sbapp/database/model/Role.java
Normal file
20
src/main/java/ru/ulstu/is/sbapp/database/model/Role.java
Normal file
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.is.sbapp.database.model;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
public enum Role implements GrantedAuthority {
|
||||
ADMIN,
|
||||
USER;
|
||||
|
||||
private static final String PREFIX = "ROLE_";
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return PREFIX + this.name();
|
||||
}
|
||||
|
||||
public static final class AsString {
|
||||
public static final String ADMIN = PREFIX + "ADMIN";
|
||||
public static final String USER = PREFIX + "USER";
|
||||
}
|
||||
}
|
76
src/main/java/ru/ulstu/is/sbapp/database/model/Song.java
Normal file
76
src/main/java/ru/ulstu/is/sbapp/database/model/Song.java
Normal file
@ -0,0 +1,76 @@
|
||||
package ru.ulstu.is.sbapp.database.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "songs")
|
||||
public class Song {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String songName;
|
||||
private Double duration;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "album_id", nullable = true)
|
||||
private Album album;
|
||||
|
||||
public Song() {
|
||||
}
|
||||
|
||||
public Song(String songName, Double duration) {
|
||||
this.songName = songName;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getSongName() { return songName; }
|
||||
public void setSongName(String songName) { this.songName = songName; }
|
||||
public Double getDuration() { return duration;}
|
||||
public void setDuration(Double duration) { this.duration = duration; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Song song = (Song) o;
|
||||
return Objects.equals(id, song.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String albumStr = (album != null) ? album.getAlbumName() : "No Album";
|
||||
return "Song{" +
|
||||
"id=" + id +
|
||||
", songName='" + songName + '\'' +
|
||||
", duration='" + duration + '\'' +
|
||||
", album='" + albumStr + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Album getAlbum() {
|
||||
return album;
|
||||
}
|
||||
|
||||
public void setAlbum(Album album) {
|
||||
if (this.album != album) {
|
||||
if (this.album != null) {
|
||||
this.album.getSongs().remove(this);
|
||||
}
|
||||
this.album = album;
|
||||
if (album != null && !album.getSongs().contains(this)) {
|
||||
album.getSongs().add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
src/main/java/ru/ulstu/is/sbapp/database/model/User.java
Normal file
72
src/main/java/ru/ulstu/is/sbapp/database/model/User.java
Normal file
@ -0,0 +1,72 @@
|
||||
package ru.ulstu.is.sbapp.database.model;
|
||||
|
||||
import ru.ulstu.is.sbapp.controllers.UserSignUpDTO;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String login;
|
||||
|
||||
private String password;
|
||||
|
||||
private Role role;
|
||||
|
||||
public User(){
|
||||
}
|
||||
|
||||
public User(UserSignUpDTO userDto){
|
||||
this.login = userDto.getLogin();
|
||||
this.password = userDto.getPassword();
|
||||
this.role = Role.USER;
|
||||
}
|
||||
|
||||
public User(String login, String password, Role role){
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Long getId(){return id;}
|
||||
|
||||
public String getLogin(){return login;}
|
||||
|
||||
public void setLogin(String login){this.login = login;}
|
||||
|
||||
public String getPassword(){return password;}
|
||||
|
||||
public void setPassword(String password){this.password = password;}
|
||||
|
||||
public Role getUserRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", login='" + login + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
public class AlbumNotFoundException extends RuntimeException{
|
||||
public AlbumNotFoundException(Long id){
|
||||
super(String.format("Album with id [%s] is not found", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Repository.IAlbumRepository;
|
||||
import ru.ulstu.is.sbapp.database.model.Album;
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AlbumService {
|
||||
private final IAlbumRepository albumRepository;
|
||||
private final SongService songService;
|
||||
private final ArtistService artistService;
|
||||
|
||||
public AlbumService(IAlbumRepository albumRepository, SongService songService, @Lazy ArtistService artistService) {
|
||||
this.albumRepository = albumRepository;
|
||||
this.songService = songService;
|
||||
this.artistService = artistService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Album addAlbum(String name, List<Long> artistIds){
|
||||
if (!StringUtils.hasText(name)) {
|
||||
throw new IllegalArgumentException("Album name is null or empty");
|
||||
}
|
||||
final Album album = new Album(name);
|
||||
return albumRepository.save(album);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Album findAlbum(Long id){
|
||||
final Optional<Album> album = albumRepository.findById(id);
|
||||
return album.orElseThrow(() -> new AlbumNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Album> findAllAlbums() {
|
||||
return albumRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Album updateAlbum(Long id, String name) {
|
||||
if (!StringUtils.hasText(name)) {
|
||||
throw new IllegalArgumentException("Album name is null or empty");
|
||||
}
|
||||
final Album currentAlbum = findAlbum(id);
|
||||
currentAlbum.setAlbumName(name);
|
||||
return albumRepository.save(currentAlbum);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Album deleteAlbum(Long id) {
|
||||
final Album currentAlbum = findAlbum(id);
|
||||
albumRepository.delete(currentAlbum);
|
||||
return currentAlbum;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllAlbums() {
|
||||
albumRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Song> getSongFromAlbum(Long albumId){
|
||||
Optional<Album> albumOptional = albumRepository.findById(albumId);
|
||||
if (albumOptional.isPresent()) {
|
||||
Album album = albumOptional.get();
|
||||
return album.getSongs();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Album not found with id: " + albumId);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Artist> getArtistInAlbum(Long albumId){
|
||||
Optional<Album> albumOptional = albumRepository.findById(albumId);
|
||||
if (albumOptional.isPresent()) {
|
||||
Album album = albumOptional.get();
|
||||
return album.getArtists();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Album not found with id: " + albumId);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Song> getSongsUndefined(){
|
||||
List<Song> songs = new ArrayList<>();
|
||||
for(Song song : songService.findAllSongs()){
|
||||
if(song.getAlbum() == null){
|
||||
songs.add(song);
|
||||
}
|
||||
}
|
||||
return songs;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addSongToAlbum(Long albumId, List<Long> songIds){
|
||||
final Album currentAlbum = findAlbum(albumId);
|
||||
for(Long songId : songIds) {
|
||||
songService.findSong(songId).setAlbum(currentAlbum);
|
||||
}
|
||||
albumRepository.save(currentAlbum);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteSongFromAlbum(Long id){
|
||||
songService.findSong(id).setAlbum(null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addArtistToAlbum(Long albumId, List<Long> artistIds){
|
||||
final Album currentAlbum = findAlbum(albumId);
|
||||
currentAlbum.setArtists(new ArrayList<>());
|
||||
for(Long artistId : artistIds) {
|
||||
currentAlbum.getArtists().add(artistService.findArtist(artistId));
|
||||
}
|
||||
albumRepository.save(currentAlbum);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
public class ArtistNotFoundException extends RuntimeException{
|
||||
public ArtistNotFoundException(Long id){
|
||||
super(String.format("Artist with id [%s] is not found", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Repository.IArtistRepository;
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ArtistService {
|
||||
private final IArtistRepository artistRepository;
|
||||
private final AlbumService albumService;
|
||||
|
||||
public ArtistService(IArtistRepository artistRepository, AlbumService albumService) {
|
||||
this.artistRepository = artistRepository;
|
||||
this.albumService = albumService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Artist addArtist(String artistName, String genre){
|
||||
if (!StringUtils.hasText(artistName) || !StringUtils.hasText(genre)) {
|
||||
throw new IllegalArgumentException("Artist name or genre is null or empty");
|
||||
}
|
||||
final Artist artist = new Artist(artistName, genre);
|
||||
return artistRepository.save(artist);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Artist findArtist(Long id){
|
||||
final Optional<Artist> artist = artistRepository.findById(id);
|
||||
return artist.orElseThrow(() -> new ArtistNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Artist> findAllArtists() {
|
||||
return artistRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Artist updateArtist(Long id, String name, String genre) {
|
||||
if (!StringUtils.hasText(name) || !StringUtils.hasText(genre)) {
|
||||
throw new IllegalArgumentException("Artist name or genre is null or empty");
|
||||
}
|
||||
final Artist currentArtist = findArtist(id);
|
||||
currentArtist.setArtistName(name);
|
||||
return artistRepository.save(currentArtist);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Artist deleteArtist(Long id) {
|
||||
final Artist currentArtist = findArtist(id);
|
||||
currentArtist.getAlbums().clear(); // Удаляем все связи с альбомами
|
||||
artistRepository.delete(currentArtist);
|
||||
return currentArtist;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllArtists() {
|
||||
artistRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Object[]> getAllArtistAlbum(){
|
||||
return artistRepository.getAllArtistAlbum();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addArtistToAlbum(Long artistId, List<Long> albumIds){
|
||||
final Artist currentArtist = findArtist(artistId);
|
||||
currentArtist.setAlbums(new ArrayList<>());
|
||||
for(Long albumId : albumIds) {
|
||||
currentArtist.getAlbums().add(albumService.findAlbum(albumId));
|
||||
}
|
||||
artistRepository.save(currentArtist);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.is.sbapp.Repository.IAlbumRepository;
|
||||
import ru.ulstu.is.sbapp.Repository.IArtistRepository;
|
||||
import ru.ulstu.is.sbapp.Repository.ISongRepository;
|
||||
import ru.ulstu.is.sbapp.database.model.Album;
|
||||
import ru.ulstu.is.sbapp.database.model.Artist;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class FindByNameService {
|
||||
private final IAlbumRepository albumRepository;
|
||||
private final ISongRepository songRepository;
|
||||
private final IArtistRepository artistRepository;
|
||||
|
||||
|
||||
public FindByNameService(IAlbumRepository albumRepository, ISongRepository songRepository, IArtistRepository artistRepository) {
|
||||
this.albumRepository = albumRepository;
|
||||
this.songRepository = songRepository;
|
||||
this.artistRepository = artistRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Map<String, List<Object>> GetByName(String name) {
|
||||
Map<String, List<Object>> resultMap = new HashMap<>();
|
||||
|
||||
List<Song> songs = songRepository.getSongsByName(name).stream().toList();
|
||||
List<Object> songsResult = new ArrayList<>(songs);
|
||||
resultMap.put("songs", songsResult);
|
||||
|
||||
List<Album> albums = albumRepository.getAlbumsByName(name).stream().toList();
|
||||
List<Object> albumsResult = new ArrayList<>(albums);
|
||||
resultMap.put("albums", albumsResult);
|
||||
|
||||
List<Artist> artists = artistRepository.getArtistsByName(name).stream().toList();
|
||||
List<Object> artistsResult = new ArrayList<>(artists);
|
||||
resultMap.put("artists", artistsResult);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
public class SongNotFoundException extends RuntimeException {
|
||||
public SongNotFoundException(Long id){
|
||||
super(String.format("Song with id [%s] is not found", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Repository.ISongRepository;
|
||||
import ru.ulstu.is.sbapp.database.model.Song;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SongService {
|
||||
|
||||
private final ISongRepository songRepository;
|
||||
private final AlbumService albumService;
|
||||
|
||||
public SongService(ISongRepository songRepository, @Lazy AlbumService albumService) {
|
||||
this.songRepository = songRepository;
|
||||
this.albumService = albumService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Song addSong(String songName, Double duration){
|
||||
if (!StringUtils.hasText(songName) || !StringUtils.hasText(String.valueOf(duration))) {
|
||||
throw new IllegalArgumentException("Song name or duration is null or empty");
|
||||
}
|
||||
final Song song = new Song(songName, duration);
|
||||
return songRepository.save(song);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Song findSong(Long id) {
|
||||
final Optional<Song> song = songRepository.findById(id);
|
||||
return song.orElseThrow(() -> new SongNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Song> findAllSongs() {
|
||||
return songRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Song updateSong(Long id, String name, Double duration) {
|
||||
if (!StringUtils.hasText(name) || !StringUtils.hasText(String.valueOf(duration))) {
|
||||
throw new IllegalArgumentException("Song name or duration is null or empty");
|
||||
}
|
||||
final Song currentSong = findSong(id);
|
||||
currentSong.setSongName(name);
|
||||
currentSong.setDuration(duration);
|
||||
return songRepository.save(currentSong);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Song deleteSong(Long id) {
|
||||
final Song currentSong = findSong(id);
|
||||
songRepository.delete(currentSong);
|
||||
return currentSong;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllSong() {
|
||||
songRepository.deleteAll();
|
||||
}
|
||||
|
||||
// @Transactional
|
||||
// public void AddSongToAlbum(Long idSong, Long idAlbum){
|
||||
// Song song = findSong(idSong);
|
||||
// Album album = em.find(Album.class, idAlbum);
|
||||
// if (album == null || song == null) {
|
||||
// throw new EntityNotFoundException("Album or Song not found");
|
||||
// }
|
||||
// song.setAlbum(album);
|
||||
// em.merge(song);
|
||||
// }
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
public class UserExistsException extends RuntimeException {
|
||||
public UserExistsException(String login) {
|
||||
super(String.format("User '%s' already exists", login));
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
public class UserNotFoundException extends RuntimeException {
|
||||
public UserNotFoundException(Long id) {
|
||||
super(String.format("User not found '%s'", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package ru.ulstu.is.sbapp.database.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Repository.IUserRepository;
|
||||
import ru.ulstu.is.sbapp.configuration.JwtException;
|
||||
import ru.ulstu.is.sbapp.configuration.JwtProvider;
|
||||
import ru.ulstu.is.sbapp.controllers.UserDTO;
|
||||
import ru.ulstu.is.sbapp.controllers.UserSignUpDTO;
|
||||
import ru.ulstu.is.sbapp.database.model.User;
|
||||
import ru.ulstu.is.sbapp.database.model.Role;
|
||||
import ru.ulstu.is.sbapp.database.util.validation.ValidationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class UserService implements UserDetailsService {
|
||||
private final IUserRepository userRepository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final JwtProvider jwtProvider;
|
||||
|
||||
public UserService(IUserRepository userRepository,
|
||||
PasswordEncoder passwordEncoder,
|
||||
JwtProvider jwtProvider){
|
||||
this.userRepository = userRepository;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.jwtProvider = jwtProvider;
|
||||
}
|
||||
public User findByLogin(String login) {
|
||||
return userRepository.findOneByLoginIgnoreCase(login);
|
||||
}
|
||||
public Page<User> findAllPages(int page, int size) {
|
||||
return userRepository.findAll(PageRequest.of(page - 1, size, Sort.by("id").ascending()));
|
||||
}
|
||||
@Transactional
|
||||
public User addUser(UserSignUpDTO userDto){
|
||||
final User user = new User(userDto);
|
||||
userRepository.save(user);
|
||||
return user;
|
||||
}
|
||||
@Transactional
|
||||
public User addUser(String login, String password,
|
||||
String passwordConfirm,
|
||||
Role role){
|
||||
if (findByLogin(login) != null) {
|
||||
throw new ValidationException(String.format("User '%s' already exists", login));
|
||||
}
|
||||
if (!Objects.equals(password, passwordConfirm)) {
|
||||
throw new ValidationException("Passwords not equals");
|
||||
}
|
||||
final User user = new User(login,passwordEncoder.encode(password),role);
|
||||
return userRepository.save(user);
|
||||
}
|
||||
@Transactional(readOnly = true)
|
||||
public User findUser(Long id) {
|
||||
final Optional<User> user = userRepository.findById(id);
|
||||
return user.orElseThrow(() -> new UserNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<User> findAllUsers() {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public User updateUser(UserDTO userDto) {
|
||||
final User currentUser = findUser(userDto.getId());
|
||||
currentUser.setLogin(userDto.getLogin());
|
||||
currentUser.setPassword(userDto.getPassword());
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
@Transactional
|
||||
public User updateUser(Long id,String login, String password) {
|
||||
if (!StringUtils.hasText(login) || !StringUtils.hasText(password)) {
|
||||
throw new IllegalArgumentException("User name, login or password is null or empty");
|
||||
}
|
||||
final User currentUser = findUser(id);
|
||||
currentUser.setLogin(login);
|
||||
currentUser.setPassword(password);
|
||||
return userRepository.save(currentUser);
|
||||
}
|
||||
@Transactional
|
||||
public void deleteUser(Long id) {
|
||||
userRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllUsers() {
|
||||
userRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
final User userEntity = findByLogin(username);
|
||||
if (userEntity == null) {
|
||||
throw new UsernameNotFoundException(username);
|
||||
}
|
||||
return new org.springframework.security.core.userdetails.User(
|
||||
userEntity.getLogin(), userEntity.getPassword(), Collections.singleton(userEntity.getUserRole()));
|
||||
}
|
||||
public String loginAndGetToken(UserDTO userDto) {
|
||||
final User user = findByLogin(userDto.getLogin());
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(userDto.getId());
|
||||
}
|
||||
if (!passwordEncoder.matches(userDto.getPassword(), user.getPassword())) {
|
||||
throw new UserNotFoundException(user.getId());
|
||||
}
|
||||
return jwtProvider.generateToken(user.getLogin());
|
||||
}
|
||||
public UserDetails loadUserByToken(String token) throws UsernameNotFoundException {
|
||||
if (!jwtProvider.isTokenValid(token)) {
|
||||
throw new JwtException("Bad token");
|
||||
}
|
||||
final String userLogin = jwtProvider.getLoginFromToken(token)
|
||||
.orElseThrow(() -> new JwtException("Token is not contain Login"));
|
||||
return loadUserByUsername(userLogin);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ru.ulstu.is.sbapp.database.util.error;
|
||||
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import ru.ulstu.is.sbapp.database.service.AlbumNotFoundException;
|
||||
import ru.ulstu.is.sbapp.database.service.ArtistNotFoundException;
|
||||
import ru.ulstu.is.sbapp.database.service.SongNotFoundException;
|
||||
import ru.ulstu.is.sbapp.database.util.validation.ValidationException;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
@ExceptionHandler({
|
||||
AlbumNotFoundException.class,
|
||||
ArtistNotFoundException.class,
|
||||
SongNotFoundException.class,
|
||||
ValidationException.class
|
||||
})
|
||||
public ResponseEntity<Object> handleException(Throwable e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<Object> handleBindException(MethodArgumentNotValidException e) {
|
||||
final ValidationException validationException = new ValidationException(
|
||||
e.getBindingResult().getAllErrors().stream()
|
||||
.map(DefaultMessageSourceResolvable::getDefaultMessage)
|
||||
.collect(Collectors.toSet()));
|
||||
return handleException(validationException);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<Object> handleUnknownException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package ru.ulstu.is.sbapp.database.util.validation;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ValidationException extends RuntimeException {
|
||||
public ValidationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public ValidationException(Set<String> errors) {
|
||||
super(String.join("\n", errors));
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.is.sbapp.database.util.validation;
|
||||
|
||||
import javax.validation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ValidatorUtil {
|
||||
private final Validator validator;
|
||||
|
||||
public ValidatorUtil() {
|
||||
try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
|
||||
this.validator = factory.getValidator();
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void validate(T object) {
|
||||
final Set<ConstraintViolation<T>> errors = validator.validate(object);
|
||||
if (!errors.isEmpty()) {
|
||||
throw new ValidationException(errors.stream()
|
||||
.map(ConstraintViolation::getMessage)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
}
|
23
src/main/java/ru/ulstu/is/sbapp/interfaces/DoubleType.java
Normal file
23
src/main/java/ru/ulstu/is/sbapp/interfaces/DoubleType.java
Normal file
@ -0,0 +1,23 @@
|
||||
package ru.ulstu.is.sbapp.interfaces;
|
||||
|
||||
public class DoubleType implements ITypeOfData<Double> {
|
||||
@Override
|
||||
public Double Func1(Double value1, Double value2) {
|
||||
return value1 + value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double Func2(Double value1, Double value2) {
|
||||
return Math.min(value1, value2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double Func3(Double value1, Double value2) {
|
||||
return Math.max(value1, value2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double Func4(Double value1, Double value2) {
|
||||
return Math.pow(value1,value2);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package ru.ulstu.is.sbapp.interfaces;
|
||||
|
||||
public interface ITypeOfData <T>{
|
||||
T Func1(T value1, T value2);
|
||||
T Func2(T value1, T value2);
|
||||
T Func3(T value1, T value2);
|
||||
T Func4(T value1, T value2);
|
||||
}
|
26
src/main/java/ru/ulstu/is/sbapp/interfaces/StringType.java
Normal file
26
src/main/java/ru/ulstu/is/sbapp/interfaces/StringType.java
Normal file
@ -0,0 +1,26 @@
|
||||
package ru.ulstu.is.sbapp.interfaces;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class StringType implements ITypeOfData<String> {
|
||||
@Override
|
||||
public String Func1(String value1, String value2) {
|
||||
return value1 + value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Func2(String value1, String value2) {
|
||||
return value1.toUpperCase() + value2.toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Func3(String value1, String value2) {
|
||||
String[] array = value1.split(value2);
|
||||
return String.join(" ", array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Func4(String value1, String value2) {
|
||||
return value1.toLowerCase() + value2.toLowerCase();
|
||||
}
|
||||
}
|
58
src/main/java/ru/ulstu/is/sbapp/service/ServiceType.java
Normal file
58
src/main/java/ru/ulstu/is/sbapp/service/ServiceType.java
Normal file
@ -0,0 +1,58 @@
|
||||
package ru.ulstu.is.sbapp.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import ru.ulstu.is.sbapp.interfaces.ITypeOfData;
|
||||
|
||||
@Service
|
||||
public class ServiceType {
|
||||
private final ApplicationContext applicationContext;
|
||||
private ITypeOfData _type;
|
||||
private Object _value1;
|
||||
private Object _value2;
|
||||
|
||||
public ServiceType(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
private void ValidateParams(Object value1, Object value2, String type){
|
||||
_type = (ITypeOfData)applicationContext.getBean(type);
|
||||
|
||||
switch (type) {
|
||||
case "double" -> {
|
||||
try {
|
||||
_value1 = Double.valueOf(value1.toString());
|
||||
_value2 = Double.valueOf(value2.toString());
|
||||
}catch (Exception ex){
|
||||
_value1 = 0.0;
|
||||
_value2 = 0.0;
|
||||
}
|
||||
}
|
||||
case "str" -> {
|
||||
_value1 = value1;
|
||||
_value2 = value2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Object Func1(Object value1, Object value2, String type){
|
||||
ValidateParams(value1,value2,type);
|
||||
return String.format("%s", _type.Func1(_value1,_value2));
|
||||
}
|
||||
|
||||
public Object Func2(Object value1, Object value2, String type){
|
||||
ValidateParams(value1,value2,type);
|
||||
return String.format("%s", _type.Func2(_value1, _value2));
|
||||
}
|
||||
|
||||
public Object Func3(Object value1, Object value2, String type){
|
||||
ValidateParams(value1,value2,type);
|
||||
return String.format("%s", _type.Func3(_value1,_value2));
|
||||
}
|
||||
|
||||
public Object Func4(Object value1, Object value2, String type){
|
||||
ValidateParams(value1,value2,type);
|
||||
return String.format("%s", _type.Func4(_value1,_value2));
|
||||
}
|
||||
}
|
14
src/main/resources/application.properties
Normal file
14
src/main/resources/application.properties
Normal file
@ -0,0 +1,14 @@
|
||||
spring.main.banner-mode=off
|
||||
server.port=8080
|
||||
spring.datasource.url=jdbc:h2:file:./data
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.settings.trace=false
|
||||
spring.h2.console.settings.web-allow-others=false
|
||||
jwt.dev-token=my-secret-jwt
|
||||
jwt.dev=true
|
||||
jwt.secret = my-secret-jwt
|
@ -0,0 +1,4 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
public class SbappApplicationTests {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user