Compare commits
No commits in common. "sixthlabwork" and "master" have entirely different histories.
sixthlabwo
...
master
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,7 +4,7 @@ build/
|
|||||||
!gradle/wrapper/gradle-wrapper.jar
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
!**/src/main/**/build/
|
!**/src/main/**/build/
|
||||||
!**/src/test/**/build/
|
!**/src/test/**/build/
|
||||||
node_modules
|
|
||||||
### STS ###
|
### STS ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
.classpath
|
.classpath
|
||||||
|
Binary file not shown.
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"ExpandedNodes": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"SelectedNode": "\\C:\\Users\\Alena\\Source\\Repos\\IP_PIbd-21_Yakhontov_OU",
|
|
||||||
"PreviewInSolutionExplorer": false
|
|
||||||
}
|
|
30
build.gradle
30
build.gradle
@ -4,7 +4,7 @@ plugins {
|
|||||||
id 'io.spring.dependency-management' version '1.1.0'
|
id 'io.spring.dependency-management' version '1.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.example'
|
group = 'LabWork'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '17'
|
||||||
|
|
||||||
@ -14,35 +14,9 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
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.security:spring-security-config:6.0.2'
|
|
||||||
implementation 'org.springframework.security:spring-security-web:6.1.0'
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
|
||||||
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
|
|
||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
|
||||||
implementation 'org.springframework.boot:spring-boot-devtools'
|
|
||||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
|
|
||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
|
||||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
|
||||||
|
|
||||||
implementation 'org.webjars:bootstrap:5.1.3'
|
|
||||||
implementation 'org.webjars:jquery:3.6.0'
|
|
||||||
implementation 'org.webjars:font-awesome:6.1.0'
|
|
||||||
|
|
||||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE'
|
|
||||||
implementation 'org.springframework.security:spring-security-test'
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
}
|
}
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Main-Class': 'com.example.demo'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
1564
data.trace.db
1564
data.trace.db
File diff suppressed because it is too large
Load Diff
23
frontend/.gitignore
vendored
23
frontend/.gitignore
vendored
@ -1,23 +0,0 @@
|
|||||||
.DS_Store
|
|
||||||
node_modules
|
|
||||||
/dist
|
|
||||||
|
|
||||||
|
|
||||||
# local env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
|
|
||||||
# Editor directories and files
|
|
||||||
.idea
|
|
||||||
.vscode
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
@ -1,24 +0,0 @@
|
|||||||
# project
|
|
||||||
|
|
||||||
## Project setup
|
|
||||||
```
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
### Compiles and hot-reloads for development
|
|
||||||
```
|
|
||||||
npm run serve
|
|
||||||
```
|
|
||||||
|
|
||||||
### Compiles and minifies for production
|
|
||||||
```
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Lints and fixes files
|
|
||||||
```
|
|
||||||
npm run lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customize configuration
|
|
||||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
'@vue/cli-plugin-babel/preset'
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es6",
|
|
||||||
"module": "esnext",
|
|
||||||
"baseUrl": "./",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"paths": {
|
|
||||||
"@/*": [
|
|
||||||
"src/*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"lib": [
|
|
||||||
"esnext",
|
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"scripthost"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
11664
frontend/package-lock.json
generated
11664
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "project",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"serve": "vue-cli-service serve",
|
|
||||||
"build": "vue-cli-service build",
|
|
||||||
"lint": "vue-cli-service lint"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"axios": "^1.4.0",
|
|
||||||
"core-js": "^3.8.3",
|
|
||||||
"vue": "^3.2.13",
|
|
||||||
"vue-router": "^4.0.3"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@babel/core": "^7.12.16",
|
|
||||||
"@babel/eslint-parser": "^7.12.16",
|
|
||||||
"@vue/cli-plugin-babel": "~5.0.0",
|
|
||||||
"@vue/cli-plugin-eslint": "~5.0.0",
|
|
||||||
"@vue/cli-plugin-router": "~5.0.0",
|
|
||||||
"@vue/cli-service": "~5.0.0",
|
|
||||||
"eslint": "^7.32.0",
|
|
||||||
"eslint-plugin-vue": "^8.0.3",
|
|
||||||
"sass": "^1.32.7",
|
|
||||||
"sass-loader": "^12.0.0"
|
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
||||||
"root": true,
|
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"plugin:vue/vue3-essential",
|
|
||||||
"eslint:recommended"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"parser": "@babel/eslint-parser"
|
|
||||||
},
|
|
||||||
"rules": {}
|
|
||||||
},
|
|
||||||
"browserslist": [
|
|
||||||
"> 1%",
|
|
||||||
"last 2 versions",
|
|
||||||
"not dead",
|
|
||||||
"not ie 11"
|
|
||||||
]
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<noscript>
|
|
||||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
||||||
</noscript>
|
|
||||||
<div id="app"></div>
|
|
||||||
<!-- built files will be auto injected -->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,30 +0,0 @@
|
|||||||
<template>
|
|
||||||
<nav>
|
|
||||||
<router-link to="/">Home</router-link> |
|
|
||||||
<router-link to="/about">About</router-link>
|
|
||||||
</nav>
|
|
||||||
<router-view/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
#app {
|
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
text-align: center;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav {
|
|
||||||
padding: 30px;
|
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2c3e50;
|
|
||||||
|
|
||||||
&.router-link-exact-active {
|
|
||||||
color: #42b983;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,137 +0,0 @@
|
|||||||
import axios from "axios";
|
|
||||||
|
|
||||||
const baseUrl = "http://localhost:8080/";
|
|
||||||
const config = {
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const appointmentCRUD = {
|
|
||||||
async createAppointment(appointmentName) {
|
|
||||||
console.log({ name: appointmentName })
|
|
||||||
return await axios.post(
|
|
||||||
baseUrl + "appointment/add",
|
|
||||||
{ name: appointmentName },
|
|
||||||
config
|
|
||||||
);
|
|
||||||
},
|
|
||||||
async getAppointmentList() {
|
|
||||||
console.log(baseUrl + "appointment/list")
|
|
||||||
return await axios.get(baseUrl + "appointment/list");
|
|
||||||
},
|
|
||||||
async editAppointment(id, data) {
|
|
||||||
return await axios.put(baseUrl + `appointment/${id}`, data, config);
|
|
||||||
},
|
|
||||||
async deleteAppointment(id) {
|
|
||||||
return await axios.delete(baseUrl + `appointment/${id}`, config);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const companyCRUD = {
|
|
||||||
async createCompany(
|
|
||||||
nameCompany,
|
|
||||||
legalAdressCompany,
|
|
||||||
adressCompany,
|
|
||||||
contactEmail
|
|
||||||
) {
|
|
||||||
return await axios.post(
|
|
||||||
baseUrl + "company",
|
|
||||||
{
|
|
||||||
nameCompany: nameCompany,
|
|
||||||
legalAdressCompany: legalAdressCompany,
|
|
||||||
adressCompany: adressCompany,
|
|
||||||
contactEmail: contactEmail,
|
|
||||||
},
|
|
||||||
config
|
|
||||||
);
|
|
||||||
},
|
|
||||||
async getCompanyList() {
|
|
||||||
return await axios.get(baseUrl + "company/list");
|
|
||||||
},
|
|
||||||
async editCompany(id, data) {
|
|
||||||
return await axios.put(baseUrl + `company/${id}`, data, config);
|
|
||||||
},
|
|
||||||
async deleteCompany(id) {
|
|
||||||
return await axios.delete(baseUrl + `company/${id}`, config);
|
|
||||||
},
|
|
||||||
async deleteAllCompanys() {
|
|
||||||
return await axios.delete(baseUrl + "company", config);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const requestCRUD = {
|
|
||||||
async createRequeset(
|
|
||||||
nameCompany,
|
|
||||||
comment,
|
|
||||||
createDate,
|
|
||||||
approveDate,
|
|
||||||
isActive,
|
|
||||||
sort,
|
|
||||||
type
|
|
||||||
) {
|
|
||||||
return await axios.post(
|
|
||||||
baseUrl + "requests",
|
|
||||||
{
|
|
||||||
nameCompany: nameCompany,
|
|
||||||
comment: comment,
|
|
||||||
createDate: createDate,
|
|
||||||
approveDate: approveDate,
|
|
||||||
isActive: isActive,
|
|
||||||
sort: sort,
|
|
||||||
type: type,
|
|
||||||
},
|
|
||||||
config
|
|
||||||
);
|
|
||||||
},
|
|
||||||
async getRequestList() {
|
|
||||||
return await axios.get(baseUrl + "request/all");
|
|
||||||
},
|
|
||||||
async getRequestByCompanyId() {
|
|
||||||
return await axios.get(baseUrl + "requests/Company={id}");
|
|
||||||
},
|
|
||||||
async editRequest(id, data) {
|
|
||||||
return await axios.put(baseUrl + `requests/${id}`, data, config);
|
|
||||||
},
|
|
||||||
async deleteRequest(id) {
|
|
||||||
return await axios.delete(baseUrl + `request/${id}`, config);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const employeeCRUD = {
|
|
||||||
async createEmployee(fio, appointment) {
|
|
||||||
return await axios.post(
|
|
||||||
baseUrl + "employee",
|
|
||||||
{
|
|
||||||
fio: fio,
|
|
||||||
appointment: appointment,
|
|
||||||
},
|
|
||||||
config
|
|
||||||
);
|
|
||||||
},
|
|
||||||
async getEmployeeById(id) {
|
|
||||||
return await axios.get(baseUrl + `employee/${id}`);
|
|
||||||
},
|
|
||||||
async getEmployeeList() {
|
|
||||||
return await axios.get(baseUrl + "employee/all");
|
|
||||||
},
|
|
||||||
async getEmployeeWorks(id) {
|
|
||||||
return await axios.get(baseUrl + "employee/id=" + id);
|
|
||||||
},
|
|
||||||
async getEmployeeByPostId(postId) {
|
|
||||||
return await axios.get(baseUrl + "employee/postId=" + postId);
|
|
||||||
},
|
|
||||||
async editEmployee(id, data) {
|
|
||||||
return await axios.put(baseUrl + `employee/${id}`, data, config);
|
|
||||||
},
|
|
||||||
async deleteEmployee(id) {
|
|
||||||
return await axios.delete(baseUrl + `employee/${id}`, config);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const API = {
|
|
||||||
...appointmentCRUD,
|
|
||||||
...companyCRUD,
|
|
||||||
...employeeCRUD,
|
|
||||||
...requestCRUD,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default API;
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.7 KiB |
@ -1,48 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="base">
|
|
||||||
<div class="create-apponiment">
|
|
||||||
<input type="text" v-model="appointmentName">
|
|
||||||
<button @click="createApponiment()">Создать</button>
|
|
||||||
</div>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>id</th>
|
|
||||||
<th>Название должности</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="item in data" :key="item.id">
|
|
||||||
<td>{{ item.id }}</td>
|
|
||||||
<td>{{ item.name }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import API from '@/api/api';
|
|
||||||
|
|
||||||
// @ is an alias to /src
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AppointmentsSheet',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
appointmentName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getApponiments()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getApponiments() {
|
|
||||||
API.getAppointmentList().then(response => this.data = response.data)
|
|
||||||
},
|
|
||||||
createApponiment() {
|
|
||||||
API.createAppointment(this.appointmentName).then(() => this.getApponiments())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,5 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import App from './App.vue'
|
|
||||||
import router from './router'
|
|
||||||
|
|
||||||
createApp(App).use(router).mount('#app')
|
|
@ -1,25 +0,0 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
|
||||||
import HomeView from '../views/HomeView.vue'
|
|
||||||
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
path: '/',
|
|
||||||
name: 'home',
|
|
||||||
component: HomeView
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// path: '/about',
|
|
||||||
// name: 'about',
|
|
||||||
// // route level code-splitting
|
|
||||||
// // this generates a separate chunk (about.[hash].js) for this route
|
|
||||||
// // which is lazy-loaded when the route is visited.
|
|
||||||
// component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
|
|
||||||
// }
|
|
||||||
]
|
|
||||||
|
|
||||||
const router = createRouter({
|
|
||||||
history: createWebHistory(process.env.BASE_URL),
|
|
||||||
routes
|
|
||||||
})
|
|
||||||
|
|
||||||
export default router
|
|
@ -1,19 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="home">
|
|
||||||
<img alt="Vue logo" src="../assets/logo.png">
|
|
||||||
<appointments-sheet></appointments-sheet>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import AppointmentsSheet from '@/components/AppointmentsSheet.vue';
|
|
||||||
|
|
||||||
// @ is an alias to /src
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'HomeView',
|
|
||||||
components: {
|
|
||||||
AppointmentsSheet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,4 +0,0 @@
|
|||||||
const { defineConfig } = require('@vue/cli-service')
|
|
||||||
module.exports = defineConfig({
|
|
||||||
transpileDependencies: true
|
|
||||||
})
|
|
@ -1 +1 @@
|
|||||||
rootProject.name = 'demo'
|
rootProject.name = 'DozorovaLabWork'
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package LabWork.DozorovaLabWork;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@RestController
|
||||||
|
public class DozorovaLabWorkApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(DozorovaLabWorkApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
public String Hello() {
|
||||||
|
return "Hello, user";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/sum")
|
||||||
|
public String Sum(@RequestParam(required = false, defaultValue = "0") float first,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") float second) {
|
||||||
|
return Float.toString(first + second);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/ras")
|
||||||
|
public String Ras(@RequestParam(required = false, defaultValue = "0") float first,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") float second) {
|
||||||
|
return Float.toString(first - second);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/pros")
|
||||||
|
public String Pros(@RequestParam(required = false, defaultValue = "1") float first,
|
||||||
|
@RequestParam(required = false, defaultValue = "1") float second) {
|
||||||
|
return Float.toString(first * second);
|
||||||
|
}
|
||||||
|
@GetMapping("/del")
|
||||||
|
public String Del(@RequestParam(required = false, defaultValue = "1") float first,
|
||||||
|
@RequestParam(required = false, defaultValue = "1") float second) {
|
||||||
|
if(second == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Float.toString(first/second);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
package com.example.demo;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@RestController
|
|
||||||
public class DemoApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(DemoApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.example.demo;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class WebConfiguration implements WebMvcConfigurer {
|
|
||||||
public static final String REST_API = "/api";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
|
||||||
WebMvcConfigurer.super.addViewControllers(registry);
|
|
||||||
registry.addViewController("login");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
registry.addMapping("/**").allowedMethods("*");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.example.demo.speaker;
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package com.example.demo.speaker;
|
|
||||||
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.MVCController.UserSignupMvcController;
|
|
||||||
import com.example.demo.speaker.model.UserRole;
|
|
||||||
import com.example.demo.speaker.service.UserService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
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.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebSecurity
|
|
||||||
@EnableMethodSecurity(
|
|
||||||
securedEnabled = true
|
|
||||||
)
|
|
||||||
public class SecurityConfiguration {
|
|
||||||
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
|
|
||||||
private static final String LOGIN_URL = "/login";
|
|
||||||
private final UserService userService;
|
|
||||||
|
|
||||||
public SecurityConfiguration(UserService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
createAdminOnStartup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createAdminOnStartup() {
|
|
||||||
final String admin = "admin";
|
|
||||||
if (userService.findByLogin(admin) == null) {
|
|
||||||
log.info("Admin user successfully created");
|
|
||||||
userService.createUser(admin, admin, admin, UserRole.ADMIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
|
||||||
http.headers().frameOptions().sameOrigin().and()
|
|
||||||
.cors().and()
|
|
||||||
.csrf().disable()
|
|
||||||
.authorizeHttpRequests()
|
|
||||||
.requestMatchers(UserSignupMvcController.SIGNUP_URL).permitAll()
|
|
||||||
.requestMatchers(HttpMethod.GET, LOGIN_URL).permitAll()
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
.and()
|
|
||||||
.formLogin()
|
|
||||||
.loginPage(LOGIN_URL).permitAll()
|
|
||||||
.defaultSuccessUrl("/appointment", true)
|
|
||||||
.and()
|
|
||||||
.logout().permitAll();
|
|
||||||
return http.userDetailsService(userService).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
|
||||||
return (web) -> web.ignoring()
|
|
||||||
.requestMatchers("/css/**")
|
|
||||||
.requestMatchers("/js/**")
|
|
||||||
.requestMatchers("/templates/**")
|
|
||||||
.requestMatchers("/webjars/**");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.service.AppointmentService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
//import javax.validation.Valid;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/appointment")
|
|
||||||
public class AppointmentController {
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
|
|
||||||
public AppointmentController(AppointmentService appointmentService) {
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
}
|
|
||||||
@PostMapping("/add")
|
|
||||||
public AppointmentDTO addAppointment(String name){
|
|
||||||
|
|
||||||
Random r = new Random();
|
|
||||||
var app = new Appointment(r.nextLong(), name);
|
|
||||||
return new AppointmentDTO(appointmentService.addAppointment(new AppointmentDTO(app)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public AppointmentDTO updateAppointment(@PathVariable Long id,@RequestBody AppointmentDTO appointmentDTO) {
|
|
||||||
return new AppointmentDTO(appointmentService.updateAppointment(id,appointmentDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public AppointmentDTO removeAppointment(@PathVariable Long id) {
|
|
||||||
return new AppointmentDTO(appointmentService.deleteAppointment(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
public void removeAllAppointments() {
|
|
||||||
appointmentService.deleteAllAppointments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public AppointmentDTO findAppointment(@PathVariable Long id) {
|
|
||||||
return new AppointmentDTO(appointmentService.findAppointment(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
public List<AppointmentDTO> findAllAppointments() {
|
|
||||||
return appointmentService.findAllAppointments()
|
|
||||||
.stream()
|
|
||||||
.map(AppointmentDTO::new)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.service.CompanyService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/company")
|
|
||||||
public class CompanyController {
|
|
||||||
private final CompanyService companyService;
|
|
||||||
|
|
||||||
public CompanyController(CompanyService _companyService) {
|
|
||||||
this.companyService = _companyService;
|
|
||||||
}
|
|
||||||
@PostMapping("/add")
|
|
||||||
public CompanyDTO addCompany(@RequestParam("name") String name, @RequestParam("legalAdressCompany") String legalAdressCompany,
|
|
||||||
@RequestParam("adressCompany") String adressCompany,
|
|
||||||
@RequestParam("contactEmail") String contactEmail) {
|
|
||||||
var company = new Company(name, legalAdressCompany, adressCompany, contactEmail);
|
|
||||||
return new CompanyDTO(companyService.addCompany(new CompanyDTO(company)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
public CompanyDTO updateCompany(@PathVariable Long id,@RequestBody CompanyDTO companyDTO) {
|
|
||||||
return new CompanyDTO(companyService.updateCompany(id,companyDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public CompanyDTO removeCompany(@PathVariable Long id) {
|
|
||||||
return new CompanyDTO(companyService.deleteCompany(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/remove")
|
|
||||||
public void removeAllCompanies() {
|
|
||||||
companyService.deleteAllCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public CompanyDTO findCompany(@PathVariable Long id) {
|
|
||||||
return new CompanyDTO(companyService.findCompany(id));
|
|
||||||
}
|
|
||||||
@GetMapping("/list")
|
|
||||||
public List<CompanyDTO> findAllCompanies() {
|
|
||||||
return companyService.findAllCompanies()
|
|
||||||
.stream()
|
|
||||||
.map(CompanyDTO::new)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
|
|
||||||
public class AppointmentDTO {
|
|
||||||
private long id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public AppointmentDTO(Appointment appointment)
|
|
||||||
{
|
|
||||||
this.id = appointment.getId();
|
|
||||||
this.name = appointment.getName();;
|
|
||||||
}
|
|
||||||
public AppointmentDTO(){}
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String nameAppointment){
|
|
||||||
this.name = nameAppointment;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import jakarta.persistence.CascadeType;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.OneToMany;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CompanyDTO {
|
|
||||||
private long id;
|
|
||||||
private String nameCompany;
|
|
||||||
private String legalAdressCompany;
|
|
||||||
private String adressCompany;
|
|
||||||
private String contactEmail;
|
|
||||||
// private List<RequestForCooperationDTO> requests = new ArrayList<>();
|
|
||||||
|
|
||||||
public CompanyDTO(Company company)
|
|
||||||
{
|
|
||||||
this.id = company.getId();
|
|
||||||
this.nameCompany = company.getNameCompany();
|
|
||||||
this.legalAdressCompany = company.getLegalAdressCompany();
|
|
||||||
this.adressCompany = company.getAdressCompany();
|
|
||||||
this.contactEmail = company.getContactEmail();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompanyDTO(){}
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAdressCompany() { return adressCompany; }
|
|
||||||
|
|
||||||
public String getNameCompany() { return nameCompany; }
|
|
||||||
|
|
||||||
public String getContactEmail() { return contactEmail; }
|
|
||||||
|
|
||||||
public String getLegalAdressCompany() { return legalAdressCompany; }
|
|
||||||
|
|
||||||
public void setNameCompany(String name)
|
|
||||||
{
|
|
||||||
this.nameCompany = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdressCompany(String adressCompany) {
|
|
||||||
this.adressCompany = adressCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContactEmail(String contactEmail) {
|
|
||||||
this.contactEmail = contactEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLegalAdressCompany(String legalAdressCompany) {
|
|
||||||
this.legalAdressCompany = legalAdressCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
|
|
||||||
public class EmployeeDTO {
|
|
||||||
private Long id;
|
|
||||||
private String fio;
|
|
||||||
private Long appointmentId;
|
|
||||||
|
|
||||||
public EmployeeDTO(Employee employee)
|
|
||||||
{
|
|
||||||
this.id = employee.getId();
|
|
||||||
this.fio = employee.getFio();
|
|
||||||
this.appointmentId = employee.getPost().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmployeeDTO(){}
|
|
||||||
public Long getId() { return id; }
|
|
||||||
|
|
||||||
public Long getAppointmentId() { return appointmentId; }
|
|
||||||
|
|
||||||
public String getFio() { return fio; }
|
|
||||||
|
|
||||||
public void setAppointment(Long appointment) {
|
|
||||||
this.appointmentId = appointment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFio(String fio) {
|
|
||||||
this.fio = fio;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class RequestForCooperationDTO {
|
|
||||||
private Long id;
|
|
||||||
private Company nameCompany;
|
|
||||||
private String comment;
|
|
||||||
private Date createDate;
|
|
||||||
private Date approveDate;
|
|
||||||
private Boolean isActive;
|
|
||||||
private EmployeeDTO sotr;
|
|
||||||
private TypeOfRequestEnum type;
|
|
||||||
|
|
||||||
public RequestForCooperationDTO(RequestForCooperation request)
|
|
||||||
{
|
|
||||||
this.id = request.getId();
|
|
||||||
this.nameCompany = request.getName();
|
|
||||||
this.comment = request.getComment();
|
|
||||||
this.approveDate = request.getApproveDate();
|
|
||||||
this.sotr = new EmployeeDTO(request.getWorker());
|
|
||||||
this.createDate = request.getCreateDate();
|
|
||||||
this.isActive = request.getActive();
|
|
||||||
this.type = request.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() { return this.id; }
|
|
||||||
|
|
||||||
public String getComment() { return comment; }
|
|
||||||
|
|
||||||
public Boolean getActive() { return isActive; }
|
|
||||||
|
|
||||||
public Company getNameCompany() { return nameCompany; }
|
|
||||||
|
|
||||||
public Date getApproveDate() { return approveDate; }
|
|
||||||
|
|
||||||
public Date getCreateDate() { return createDate; }
|
|
||||||
|
|
||||||
public EmployeeDTO getSotr() { return sotr; }
|
|
||||||
|
|
||||||
public TypeOfRequestEnum getType() {return type; }
|
|
||||||
|
|
||||||
public void setActive(Boolean active) {
|
|
||||||
isActive = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApproveDate(Date approveDate) {
|
|
||||||
this.approveDate = approveDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComment(String comment) {
|
|
||||||
this.comment = comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNameCompany(Company nameCompany) {
|
|
||||||
this.nameCompany = nameCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSotr(EmployeeDTO sotr) {
|
|
||||||
this.sotr = sotr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(TypeOfRequestEnum type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.User;
|
|
||||||
import com.example.demo.speaker.model.UserRole;
|
|
||||||
|
|
||||||
public class UserDTO {
|
|
||||||
private final long id;
|
|
||||||
private final String login;
|
|
||||||
private final UserRole role;
|
|
||||||
public UserDTO(User user) {
|
|
||||||
this.id = user.getId();
|
|
||||||
this.login = user.getLogin();
|
|
||||||
this.role = user.getRole();
|
|
||||||
}
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public String getLogin() {
|
|
||||||
return login;
|
|
||||||
}
|
|
||||||
public UserRole getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.DTO;
|
|
||||||
|
|
||||||
public class UserSignupDTO {
|
|
||||||
// @NotBlank
|
|
||||||
// @Size(min = 3, max = 64)
|
|
||||||
private String login;
|
|
||||||
// @NotBlank
|
|
||||||
// @Size(min = 6, max = 64)
|
|
||||||
private String password;
|
|
||||||
// @NotBlank
|
|
||||||
// @Size(min = 6, max = 64)
|
|
||||||
private String passwordConfirm;
|
|
||||||
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 String getPasswordConfirm() {
|
|
||||||
return passwordConfirm;
|
|
||||||
}
|
|
||||||
public void setPasswordConfirm(String passwordConfirm) {
|
|
||||||
this.passwordConfirm = passwordConfirm;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.service.AppointmentService;
|
|
||||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
|
||||||
import com.example.demo.speaker.service.EmployeeService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/employee")
|
|
||||||
public class EmployeeController {
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
private final RequestForCooperationService requestForCooperationService;
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
|
|
||||||
|
|
||||||
public EmployeeController(EmployeeService employeeService, RequestForCooperationService requestForCooperationService, AppointmentService appointmentService) {
|
|
||||||
this.employeeService = employeeService;
|
|
||||||
this.requestForCooperationService = requestForCooperationService;
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public Employee getWorker(@PathVariable Long id) {
|
|
||||||
return employeeService.findWorker(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
|
||||||
public List<Employee> getWorkers() {
|
|
||||||
return employeeService.findAllWorkers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add")
|
|
||||||
public EmployeeDTO createWorker(@RequestParam("name") String name, @RequestParam("appointmentId") Long appointmentId) {
|
|
||||||
var Employee = new Employee(name, appointmentService.findAppointment(appointmentId));
|
|
||||||
return new EmployeeDTO(employeeService.addWorker(new EmployeeDTO(Employee)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public EmployeeDTO updateWorker(@PathVariable Long id,@RequestBody EmployeeDTO employeeDTO) {
|
|
||||||
return new EmployeeDTO(employeeService.updateReportWorker(id, employeeDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public EmployeeDTO deleteWorker(@PathVariable Long id) {
|
|
||||||
return new EmployeeDTO(employeeService.deleteWorker(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/id={id}")
|
|
||||||
public List<RequestForCooperation> getListOfReports(@PathVariable Long id) {
|
|
||||||
var employee = employeeService.findWorker(id);
|
|
||||||
return employeeService.findAllRequestsOfEmployee(employee);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/postId={postId}")
|
|
||||||
public List<Employee> getListOfWorkers(@RequestParam("postId") Long id) {
|
|
||||||
final Appointment appointment = appointmentService.findAppointment(id);
|
|
||||||
return employeeService.findWorkerByPost(appointment);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.service.AppointmentService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/appointment")
|
|
||||||
public class AppointmentMVCController
|
|
||||||
{
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
|
|
||||||
public AppointmentMVCController(AppointmentService appointmentService) {
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String getAppointments(Model model) {
|
|
||||||
model.addAttribute("appointments",
|
|
||||||
appointmentService.findAllAppointments().stream()
|
|
||||||
.map(AppointmentDTO::new)
|
|
||||||
.toList());
|
|
||||||
model.addAttribute("appointmentDTO", new AppointmentDTO());
|
|
||||||
return "appointment";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
public String createAppointment(@ModelAttribute AppointmentDTO appointmentDTO, Model model){
|
|
||||||
|
|
||||||
Random r = new Random();
|
|
||||||
var app = new Appointment(r.nextLong(), appointmentDTO.getName());
|
|
||||||
appointmentService.addAppointment(new AppointmentDTO(app));
|
|
||||||
// model.addAttribute("appointmentName", name);
|
|
||||||
// model.addAttribute("appointmentDTO", new AppointmentDTO(appointmentService.addAppointment(new AppointmentDTO(app))));
|
|
||||||
return "redirect:/appointment";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("edit/{id}")
|
|
||||||
public String updateMVCAppointment(@PathVariable Long id, @ModelAttribute("appointment") AppointmentDTO appointment,
|
|
||||||
Model model) {
|
|
||||||
//appointmentService.updateAppointment(id, appointment);
|
|
||||||
model.addAttribute("appointmentId", id);
|
|
||||||
model.addAttribute("appointmentDTO", new AppointmentDTO(appointmentService.updateAppointment(id,appointment)));
|
|
||||||
return "redirect:/appointment";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("delete/{id}")
|
|
||||||
public String deleteAppointment(@PathVariable Long id) {
|
|
||||||
appointmentService.deleteAppointment(id);
|
|
||||||
return "redirect:/appointment";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
|
||||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.service.CompanyService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/company")
|
|
||||||
public class CompanyMVCController {
|
|
||||||
private final CompanyService companyService;
|
|
||||||
|
|
||||||
public CompanyMVCController(CompanyService _companyService) {
|
|
||||||
this.companyService = _companyService;
|
|
||||||
}
|
|
||||||
@PostMapping("/create")
|
|
||||||
public String addCompany(@ModelAttribute CompanyDTO companyDTO, Model model) {
|
|
||||||
companyService.addCompany(companyDTO);
|
|
||||||
return "redirect:company";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/edit/{id}")
|
|
||||||
public String updateCompany(@PathVariable Long id, @ModelAttribute CompanyDTO companyDTO) {
|
|
||||||
companyService.updateCompany(id,companyDTO);
|
|
||||||
return "company";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("delete/{id}")
|
|
||||||
public String removeCompany(@PathVariable Long id) {
|
|
||||||
companyService.deleteCompany(id);
|
|
||||||
return "company";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String findAllCompanies(Model model) {
|
|
||||||
model.addAttribute("companies", companyService.findAllCompanies()
|
|
||||||
.stream()
|
|
||||||
.map(CompanyDTO::new)
|
|
||||||
.toList());
|
|
||||||
model.addAttribute("companyDTO", new CompanyDTO());
|
|
||||||
return "company";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
|
||||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.service.AppointmentService;
|
|
||||||
import com.example.demo.speaker.service.EmployeeService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/employee")
|
|
||||||
public class EmployeeMVCController {
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
|
|
||||||
public List<Appointment> appointments;
|
|
||||||
|
|
||||||
|
|
||||||
public EmployeeMVCController(EmployeeService employeeService, AppointmentService appointmentService) {
|
|
||||||
this.employeeService = employeeService;
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
this.appointments = appointmentService.findAllAppointments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String getWorkers(Model model) {
|
|
||||||
model.addAttribute("employees",
|
|
||||||
employeeService.findAllWorkers().stream()
|
|
||||||
.map(EmployeeDTO::new)
|
|
||||||
.toList());
|
|
||||||
model.addAttribute("appointments",
|
|
||||||
appointmentService.findAllAppointments().stream().map(AppointmentDTO::new).toList());
|
|
||||||
model.addAttribute("employeeDTO", new EmployeeDTO());
|
|
||||||
|
|
||||||
return "employee";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
public String createWorker(@ModelAttribute EmployeeDTO employeeDTO, Model model) {
|
|
||||||
employeeService.addWorker(employeeDTO);
|
|
||||||
return "redirect:employee";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/edit/{id}")
|
|
||||||
public String updateWorker(@PathVariable Long id,@ModelAttribute("employeeDTO") EmployeeDTO employeeDTO, Model model) {
|
|
||||||
employeeService.updateReportWorker(id, employeeDTO);
|
|
||||||
// model.addAttribute("employees", employeeService.findAllWorkers());
|
|
||||||
// model.addAttribute("appointments", appointmentService.findAllAppointments());
|
|
||||||
return "redirect:employee";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/delete/{id}")
|
|
||||||
public String deleteWorker(@PathVariable Long id) {
|
|
||||||
employeeService.deleteWorker(id);
|
|
||||||
return "redirect:/employee";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
|
||||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
|
||||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
|
||||||
import com.example.demo.speaker.service.CompanyService;
|
|
||||||
import com.example.demo.speaker.service.EmployeeService;
|
|
||||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/request")
|
|
||||||
public class RequestMVCController {
|
|
||||||
private final RequestForCooperationService requestForCooperationService;
|
|
||||||
private final CompanyService companyService;
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
List<TypeOfRequestEnum> types;
|
|
||||||
List<Employee> employees;
|
|
||||||
List<Company> companies;
|
|
||||||
|
|
||||||
public RequestMVCController(RequestForCooperationService requestForCooperationService, CompanyService companyService, EmployeeService employeeService) {
|
|
||||||
this.requestForCooperationService = requestForCooperationService;
|
|
||||||
this.companyService = companyService;
|
|
||||||
this.employeeService = employeeService;
|
|
||||||
this.types = List.of(TypeOfRequestEnum.TRACKING, TypeOfRequestEnum.DEVELOP);
|
|
||||||
employees = employeeService.findAllWorkers();
|
|
||||||
companies = companyService.findAllCompanies();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String getRequests(Model model) {
|
|
||||||
model.addAttribute("requests", requestForCooperationService.findAllRequests()
|
|
||||||
.stream().map(RequestForCooperationDTO::new).toList());
|
|
||||||
model.addAttribute("types", types);
|
|
||||||
model.addAttribute("employees", employees.stream()
|
|
||||||
.map(EmployeeDTO::new).toList());
|
|
||||||
model.addAttribute("companies", companies.stream()
|
|
||||||
.map(CompanyDTO::new).toList());
|
|
||||||
return "request";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add")
|
|
||||||
public String createRequest(@PathVariable Long nameCompany,
|
|
||||||
@PathVariable String comment,
|
|
||||||
@PathVariable Integer isActive,
|
|
||||||
@PathVariable Long sort,
|
|
||||||
@PathVariable Long type,
|
|
||||||
Model model
|
|
||||||
){
|
|
||||||
|
|
||||||
//@RequestBody RequestForCooperationDTO requestDTO) {
|
|
||||||
var company = companyService.findCompany(nameCompany);
|
|
||||||
var emp = employeeService.findWorker(sort);
|
|
||||||
var request = new RequestForCooperation(company, new Date(), type == 0 ? TypeOfRequestEnum.DEVELOP : TypeOfRequestEnum.TRACKING, comment);
|
|
||||||
requestForCooperationService.addRequest(new RequestForCooperationDTO(request));
|
|
||||||
return "redirect:request";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public String updateRequest(@PathVariable Long id,
|
|
||||||
@ModelAttribute RequestForCooperationDTO request,
|
|
||||||
Model model) {
|
|
||||||
requestForCooperationService.updateRequest(request);
|
|
||||||
return "redirect:request";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/delete/{id}")
|
|
||||||
public String deleteRequest(@PathVariable Long id, Model model) {
|
|
||||||
requestForCooperationService.deleteRequest(id);
|
|
||||||
return "redirect:request";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.UserDTO;
|
|
||||||
import com.example.demo.speaker.model.UserRole;
|
|
||||||
import com.example.demo.speaker.service.UserService;
|
|
||||||
import org.springframework.security.access.annotation.Secured;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/users")
|
|
||||||
public class UserMVCController {
|
|
||||||
private final UserService userService;
|
|
||||||
public UserMVCController(UserService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
@GetMapping
|
|
||||||
@Secured({UserRole.AsString.ADMIN})
|
|
||||||
public String getUsers(@RequestParam(defaultValue = "1") int page,
|
|
||||||
@RequestParam(defaultValue = "5") int size,
|
|
||||||
Model model) {
|
|
||||||
final Page<UserDTO> users = userService.findAllPages(page, size)
|
|
||||||
.map(UserDTO::new);
|
|
||||||
model.addAttribute("users", users);
|
|
||||||
final int totalPages = users.getTotalPages();
|
|
||||||
final List<Integer> pageNumbers = IntStream.rangeClosed(1, totalPages)
|
|
||||||
.boxed()
|
|
||||||
.toList();
|
|
||||||
model.addAttribute("pages", pageNumbers);
|
|
||||||
model.addAttribute("totalPages", totalPages);
|
|
||||||
return "users";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller.MVCController;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.UserSignupDTO;
|
|
||||||
import com.example.demo.speaker.model.User;
|
|
||||||
import com.example.demo.speaker.service.UserService;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping(UserSignupMvcController.SIGNUP_URL)
|
|
||||||
public class UserSignupMvcController {
|
|
||||||
public static final String SIGNUP_URL = "/signup";
|
|
||||||
private final UserService userService;
|
|
||||||
public UserSignupMvcController(UserService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
@GetMapping
|
|
||||||
public String showSignupForm(Model model) {
|
|
||||||
model.addAttribute("UserDTO", new UserSignupDTO());
|
|
||||||
return "signup";
|
|
||||||
}
|
|
||||||
@PostMapping
|
|
||||||
public String signup(@ModelAttribute("UserDTO") UserSignupDTO userSignupDTO,
|
|
||||||
BindingResult bindingResult,
|
|
||||||
Model model) {
|
|
||||||
if (bindingResult.hasErrors()) {
|
|
||||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
|
||||||
return "signup";
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final User user = userService.createUser(
|
|
||||||
userSignupDTO.getLogin(), userSignupDTO.getPassword(), userSignupDTO.getPasswordConfirm());
|
|
||||||
return "redirect:/login?created=" + user.getLogin();
|
|
||||||
} catch (Exception e) {
|
|
||||||
//model.addAttribute("errors", e.getMessage());
|
|
||||||
return "signup";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package com.example.demo.speaker.controller;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
|
||||||
import com.example.demo.speaker.service.CompanyService;
|
|
||||||
import com.example.demo.speaker.service.EmployeeService;
|
|
||||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/requests")
|
|
||||||
public class RequestForCooperationController {
|
|
||||||
private final RequestForCooperationService requestForCooperationService;
|
|
||||||
private final CompanyService companyService;
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
|
|
||||||
public RequestForCooperationController(RequestForCooperationService requestForCooperationService, CompanyService companyService, EmployeeService employeeService) {
|
|
||||||
this.requestForCooperationService = requestForCooperationService;
|
|
||||||
this.companyService = companyService;
|
|
||||||
this.employeeService = employeeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public RequestForCooperation getRequest(@PathVariable Long id) {
|
|
||||||
return requestForCooperationService.findRequest(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
|
||||||
public List<RequestForCooperation> getRequests() {
|
|
||||||
return requestForCooperationService.findAllRequests();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add")
|
|
||||||
public RequestForCooperation createRequest(@PathVariable Long nameCompany,
|
|
||||||
@PathVariable String comment,
|
|
||||||
@PathVariable Integer isActive,
|
|
||||||
@PathVariable Long sort,
|
|
||||||
@PathVariable Long type
|
|
||||||
){
|
|
||||||
|
|
||||||
//@RequestBody RequestForCooperationDTO requestDTO) {
|
|
||||||
var company = companyService.findCompany(nameCompany);
|
|
||||||
var emp = employeeService.findWorker(sort);
|
|
||||||
var request = new RequestForCooperation(company, new Date(), type == 0 ? TypeOfRequestEnum.DEVELOP : TypeOfRequestEnum.TRACKING, comment);
|
|
||||||
return requestForCooperationService.addRequest(new RequestForCooperationDTO(request));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public RequestForCooperationDTO updateRequest(@PathVariable Long id, @RequestBody RequestForCooperationDTO requestDTO) {
|
|
||||||
return new RequestForCooperationDTO(requestForCooperationService.updateRequest(requestDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public RequestForCooperation deleteRequest(@PathVariable Long id) {
|
|
||||||
return requestForCooperationService.deleteRequest(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/Company={id}")
|
|
||||||
public List<RequestForCooperation> ListOfRequest(@PathVariable Long id) {
|
|
||||||
return requestForCooperationService.getRequestsOfCompany(companyService.findCompany(id));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class Appointment {
|
|
||||||
private String name;
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Appointment() { }
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public Appointment(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Appointment(Long id, String name)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Appointment appointment = (Appointment) o;
|
|
||||||
return Objects.equals(id, appointment.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Post{" +
|
|
||||||
"id=" + id +
|
|
||||||
",Name='" + name + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class Company {
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String nameCompany;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String legalAdressCompany;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String adressCompany;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String contactEmail;
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private List<RequestForCooperation> requests = new ArrayList<>();
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
public Company(){}
|
|
||||||
|
|
||||||
Random r = new Random();
|
|
||||||
public Company(String nameCompany, String legalAdressCompany, String adressCompany,
|
|
||||||
String contactEmail)
|
|
||||||
{
|
|
||||||
this.id = r.nextLong();
|
|
||||||
this.nameCompany = nameCompany;
|
|
||||||
this.adressCompany = adressCompany;
|
|
||||||
this.legalAdressCompany = legalAdressCompany;
|
|
||||||
this.contactEmail = contactEmail;
|
|
||||||
}
|
|
||||||
public Company(Long id, String nameCompany, String legalAdressCompany, String adressCompany,
|
|
||||||
String contactEmail)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.nameCompany = nameCompany;
|
|
||||||
this.adressCompany = adressCompany;
|
|
||||||
this.legalAdressCompany = legalAdressCompany;
|
|
||||||
this.contactEmail = contactEmail;
|
|
||||||
}
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
public String getNameCompany()
|
|
||||||
{
|
|
||||||
return this.nameCompany;
|
|
||||||
}
|
|
||||||
public String getLegalAdressCompany()
|
|
||||||
{
|
|
||||||
return this.legalAdressCompany;
|
|
||||||
}
|
|
||||||
public String getAdressCompany()
|
|
||||||
{
|
|
||||||
return this.adressCompany;
|
|
||||||
}
|
|
||||||
public String getContactEmail()
|
|
||||||
{
|
|
||||||
return this.contactEmail;
|
|
||||||
}
|
|
||||||
public void setNameCompany(String name)
|
|
||||||
{
|
|
||||||
this.nameCompany = name;
|
|
||||||
}
|
|
||||||
public void setLegalAdressCompany(String adressCompany)
|
|
||||||
{
|
|
||||||
this.legalAdressCompany = adressCompany;
|
|
||||||
}
|
|
||||||
public void setAdressCompany(String adressCompany)
|
|
||||||
{
|
|
||||||
this.adressCompany = adressCompany;
|
|
||||||
}
|
|
||||||
public void setContactEmail(String contactEmail)
|
|
||||||
{
|
|
||||||
this.contactEmail = contactEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setList(RequestForCooperation req) {
|
|
||||||
this.requests.add(req);
|
|
||||||
}
|
|
||||||
public List<RequestForCooperation> getList()
|
|
||||||
{
|
|
||||||
return requests;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Company company = (Company) o;
|
|
||||||
return Objects.equals(id, company.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Company{" +
|
|
||||||
"id=" + id +
|
|
||||||
",Name='" + nameCompany + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class Employee {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String fio;
|
|
||||||
//@OneToOne(fetch = FetchType.EAGER)
|
|
||||||
@OneToOne(cascade = {CascadeType.MERGE})
|
|
||||||
@JoinColumn(name = "appointment_id")
|
|
||||||
private Appointment appointment;
|
|
||||||
Random r = new Random();
|
|
||||||
|
|
||||||
|
|
||||||
public Employee(String fio, Appointment appointment) {
|
|
||||||
this.id = r.nextLong();
|
|
||||||
this.fio = fio;
|
|
||||||
this.appointment = appointment;
|
|
||||||
}
|
|
||||||
public Employee(Long id, String fio, Appointment appointment) {
|
|
||||||
this.id = id;
|
|
||||||
this.fio = fio;
|
|
||||||
this.appointment = appointment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Employee() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public String getFio()
|
|
||||||
{
|
|
||||||
return this.fio;
|
|
||||||
}
|
|
||||||
public Appointment getPost()
|
|
||||||
{
|
|
||||||
return this.appointment;
|
|
||||||
}
|
|
||||||
public void setFio(String fio)
|
|
||||||
{
|
|
||||||
this.fio = fio;
|
|
||||||
}
|
|
||||||
public void setPost(Appointment appointment)
|
|
||||||
{
|
|
||||||
this.appointment = appointment;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Employee employee = (Employee) o;
|
|
||||||
return Objects.equals(id, employee.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Worker{" +
|
|
||||||
"id=" + id +
|
|
||||||
", Name='" + fio + '\'' +
|
|
||||||
", Post='" + appointment.getName() + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class RequestForCooperation {
|
|
||||||
@jakarta.persistence.Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
|
||||||
private Company nameCompany;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String comment;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Date createDate;
|
|
||||||
private Date approveDate;
|
|
||||||
private Boolean isActive;
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
|
||||||
private Employee sotr;
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private TypeOfRequestEnum typeSotr;
|
|
||||||
|
|
||||||
public RequestForCooperation() {
|
|
||||||
}
|
|
||||||
Random r = new Random();
|
|
||||||
public RequestForCooperation(Company name, Date createDate, TypeOfRequestEnum type, String text) {
|
|
||||||
this.nameCompany = name;
|
|
||||||
this.createDate = createDate;
|
|
||||||
this.comment = text;
|
|
||||||
this.typeSotr = type;
|
|
||||||
this.id = r.nextLong();
|
|
||||||
}
|
|
||||||
public RequestForCooperation(Long id, Company name, Date createDate, TypeOfRequestEnum type, String text) {
|
|
||||||
this.nameCompany = name;
|
|
||||||
this.createDate = createDate;
|
|
||||||
this.comment = text;
|
|
||||||
this.typeSotr = type;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Company getName()
|
|
||||||
{
|
|
||||||
return this.nameCompany;
|
|
||||||
}
|
|
||||||
public TypeOfRequestEnum getType()
|
|
||||||
{
|
|
||||||
return this.typeSotr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreateDate()
|
|
||||||
{
|
|
||||||
return this.createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getApproveDate()
|
|
||||||
{
|
|
||||||
return this.approveDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Employee getWorker()
|
|
||||||
{
|
|
||||||
return this.sotr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment() { return this.comment; }
|
|
||||||
public void setWorker(Employee sotr)
|
|
||||||
{
|
|
||||||
this.sotr = sotr;
|
|
||||||
}
|
|
||||||
public Boolean getActive()
|
|
||||||
{
|
|
||||||
return this.isActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RequestForCooperation report = (RequestForCooperation) o;
|
|
||||||
return Objects.equals(id, report.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Report{" +
|
|
||||||
"id=" + id +
|
|
||||||
", NameCompany='" + nameCompany.toString() + '\'' +
|
|
||||||
", Type='" + typeSotr + '\'' +
|
|
||||||
", IsActive='" + isActive + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setApproveDate(Date date)
|
|
||||||
{
|
|
||||||
this.approveDate = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(Employee sotr)
|
|
||||||
{
|
|
||||||
this.sotr = sotr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(Boolean active)
|
|
||||||
{
|
|
||||||
this.isActive = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(TypeOfRequestEnum type)
|
|
||||||
{
|
|
||||||
this.typeSotr = type;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
public enum TypeOfRequestEnum {
|
|
||||||
TRACKING,
|
|
||||||
DEVELOP
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "users")
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
@Column(nullable = false, unique = true, length = 64)
|
|
||||||
// @NotBlank
|
|
||||||
// @Size(min = 3, max = 64)
|
|
||||||
private String login;
|
|
||||||
@Column(nullable = false, length = 64)
|
|
||||||
// @NotBlank
|
|
||||||
// @Size(min = 6, max = 64)
|
|
||||||
private String password;
|
|
||||||
private UserRole role;
|
|
||||||
|
|
||||||
public User() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(String login, String password) {
|
|
||||||
this(login, password, UserRole.USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(String login, String password, UserRole 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 UserRole getRole() {
|
|
||||||
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) && Objects.equals(login, user.login);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, login);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "User{" +
|
|
||||||
"id=" + id +
|
|
||||||
", login='" + login + '\'' +
|
|
||||||
", password='" + password + '\'' +
|
|
||||||
", role='" + role + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.example.demo.speaker.model;
|
|
||||||
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
|
|
||||||
public enum UserRole 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";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package com.example.demo.speaker.repository;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface IAppointmentRepository extends JpaRepository<Appointment, Long> {
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.example.demo.speaker.repository;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ICompanyRepository extends JpaRepository<Company, Long> {
|
|
||||||
@Query("SELECT DISTINCT p.requests FROM Company p where :company = p.id")
|
|
||||||
List<RequestForCooperation> getRequestsOfCompany(@Param("company") Long id);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.example.demo.speaker.repository;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IEmployeeRepository extends JpaRepository<Employee, Long> {
|
|
||||||
@Query("SELECT DISTINCT p.fio FROM Employee p where :appointment = p.appointment")
|
|
||||||
List<Employee> getEmployeeByAppointment(@Param("appointment") Appointment appointment);
|
|
||||||
|
|
||||||
@Query("SELECT DISTINCT p FROM RequestForCooperation p where :employee = p.sotr")
|
|
||||||
List<RequestForCooperation> getRequestsOfEmployee(@Param("employee") Employee employee);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.example.demo.speaker.repository;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IRequestForCooperationRepository extends JpaRepository<RequestForCooperation, Long> {
|
|
||||||
@Query("SELECT p.sotr FROM RequestForCooperation p where :id = p.id")
|
|
||||||
Employee findWorkerByRequest(@Param("id") RequestForCooperation request);
|
|
||||||
|
|
||||||
@Query("SELECT p.nameCompany FROM RequestForCooperation p where :company = p.nameCompany")
|
|
||||||
List<RequestForCooperation> findRequestByCompany(@Param("company") Company company);
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.example.demo.speaker.repository;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.User;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface IUserRepository extends JpaRepository<User, Long> {
|
|
||||||
User findOneByLoginIgnoreCase(String login);
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
public class AppointmentNotFoundException extends RuntimeException{
|
|
||||||
public AppointmentNotFoundException(Long id){
|
|
||||||
super(String.format("Appointment with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.repository.IAppointmentRepository;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class AppointmentService {
|
|
||||||
private final IAppointmentRepository appointmentRepository;
|
|
||||||
|
|
||||||
public AppointmentService(IAppointmentRepository appointmentRepository) {
|
|
||||||
this.appointmentRepository = appointmentRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Appointment addAppointment(AppointmentDTO appointmentDTO) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Appointment appointment = new Appointment(appointmentDTO.getName());
|
|
||||||
appointmentRepository.save(appointment);
|
|
||||||
return appointment;
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public Appointment findAppointment(Long id) {
|
|
||||||
final Optional<Appointment> appointment = appointmentRepository.findById(id);
|
|
||||||
return appointment.orElseThrow(()->new AppointmentNotFoundException(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public List<Appointment> findAllAppointments() {
|
|
||||||
return appointmentRepository.findAll();
|
|
||||||
}
|
|
||||||
@Transactional
|
|
||||||
public Appointment updateAppointment(Long id, AppointmentDTO appointmentDTO) {
|
|
||||||
final Appointment currentAppointment = findAppointment(id);
|
|
||||||
currentAppointment.setName(appointmentDTO.getName());
|
|
||||||
appointmentRepository.save(currentAppointment);
|
|
||||||
return currentAppointment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Appointment deleteAppointment(Long id) {
|
|
||||||
final Appointment currentAppointment = findAppointment(id);
|
|
||||||
appointmentRepository.delete(currentAppointment);
|
|
||||||
return currentAppointment;
|
|
||||||
}
|
|
||||||
@Transactional
|
|
||||||
public void deleteAllAppointments() {
|
|
||||||
appointmentRepository.deleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
public class CompanyNotFoundException extends RuntimeException{
|
|
||||||
public CompanyNotFoundException(Long id){
|
|
||||||
super(String.format("Company with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.repository.ICompanyRepository;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class CompanyService {
|
|
||||||
private final ICompanyRepository companyRepository;
|
|
||||||
|
|
||||||
public CompanyService(ICompanyRepository companyRepository) {
|
|
||||||
this.companyRepository = companyRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Company addCompany(CompanyDTO companyDTO) {
|
|
||||||
final Company company = new Company(companyDTO.getNameCompany(),
|
|
||||||
companyDTO.getLegalAdressCompany(),
|
|
||||||
companyDTO.getAdressCompany(),
|
|
||||||
companyDTO.getContactEmail());
|
|
||||||
companyRepository.save(company);
|
|
||||||
return company;
|
|
||||||
}
|
|
||||||
@Transactional
|
|
||||||
public Company addRequest(CompanyDTO companyDTO, List<RequestForCooperation> requests){
|
|
||||||
final Company currentCompany = findCompany(companyDTO.getId());
|
|
||||||
currentCompany.setList((RequestForCooperation) requests);
|
|
||||||
return currentCompany;
|
|
||||||
}
|
|
||||||
@Transactional
|
|
||||||
public Company updateCompany(Long id, CompanyDTO companyDTO) {
|
|
||||||
final Company currentCompany = findCompany(id);
|
|
||||||
currentCompany.setNameCompany(companyDTO.getNameCompany());
|
|
||||||
currentCompany.setAdressCompany(companyDTO.getAdressCompany());
|
|
||||||
currentCompany.setLegalAdressCompany(companyDTO.getLegalAdressCompany());
|
|
||||||
currentCompany.setContactEmail(companyDTO.getContactEmail());
|
|
||||||
companyRepository.save(currentCompany);
|
|
||||||
return currentCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public Company findCompany(Long id) {
|
|
||||||
final Optional<Company> company = companyRepository.findById(id);
|
|
||||||
return company.orElseThrow(()->new CompanyNotFoundException(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public List<Company> findAllCompanies() {
|
|
||||||
return companyRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Company deleteCompany(Long id) {
|
|
||||||
final Company currentCompany = findCompany(id);
|
|
||||||
companyRepository.delete(currentCompany);
|
|
||||||
return currentCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void deleteAllCompanies() {
|
|
||||||
companyRepository.deleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public List<RequestForCooperation> getTypesRequests(Long id)
|
|
||||||
{
|
|
||||||
return companyRepository.getRequestsOfCompany(id);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
public class EmployeeNotFoundException extends RuntimeException{
|
|
||||||
public EmployeeNotFoundException(Long id){
|
|
||||||
super(String.format("Employee with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
|
||||||
import com.example.demo.speaker.model.Appointment;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.repository.IEmployeeRepository;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class EmployeeService {
|
|
||||||
private final IEmployeeRepository employeeRepository;
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
|
|
||||||
public EmployeeService(IEmployeeRepository employeeRepository, AppointmentService appointmentService) {
|
|
||||||
this.employeeRepository = employeeRepository;
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Employee addWorker(EmployeeDTO employee) {
|
|
||||||
var appontment = appointmentService.findAppointment(employee.getAppointmentId());
|
|
||||||
Employee employeeNew = new Employee(employee.getFio(), appontment);
|
|
||||||
employeeRepository.save(employeeNew);
|
|
||||||
return employeeNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public Employee findWorker(Long id) {
|
|
||||||
final Optional<Employee> employee = employeeRepository.findById(id);
|
|
||||||
return employee.orElseThrow(()->new EmployeeNotFoundException(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public List<Employee> findAllWorkers() {
|
|
||||||
return employeeRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Employee updateReportWorker(Long id, EmployeeDTO employeeDTO) {
|
|
||||||
final Employee currentEmployee = findWorker(id);
|
|
||||||
currentEmployee.setFio(currentEmployee.getFio());
|
|
||||||
currentEmployee.setPost(currentEmployee.getPost());
|
|
||||||
employeeRepository.save(currentEmployee);
|
|
||||||
return currentEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public List<Employee> findWorkerByPost(Appointment appointment) {
|
|
||||||
if (appointment == null) {
|
|
||||||
throw new IllegalArgumentException("Post is null or empty");
|
|
||||||
}
|
|
||||||
List<Employee> list = employeeRepository.getEmployeeByAppointment(appointment);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public List<RequestForCooperation> findAllRequestsOfEmployee(Employee employee)
|
|
||||||
{
|
|
||||||
List<RequestForCooperation> list = employeeRepository.getRequestsOfEmployee(employee);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Employee deleteWorker(Long id) {
|
|
||||||
final Employee currentEmployee = findWorker(id);
|
|
||||||
employeeRepository.delete(currentEmployee);
|
|
||||||
return currentEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void deleteAllWorkers() {
|
|
||||||
employeeRepository.deleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
|
||||||
import com.example.demo.speaker.model.Company;
|
|
||||||
import com.example.demo.speaker.model.Employee;
|
|
||||||
import com.example.demo.speaker.model.RequestForCooperation;
|
|
||||||
import com.example.demo.speaker.repository.IRequestForCooperationRepository;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class RequestForCooperationService {
|
|
||||||
private final IRequestForCooperationRepository requestForCooperationRepository;
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
private final CompanyService companyService;
|
|
||||||
|
|
||||||
public RequestForCooperationService(IRequestForCooperationRepository requestForCooperationRepository, EmployeeService employeeRepository, CompanyService companyService) {
|
|
||||||
this.requestForCooperationRepository = requestForCooperationRepository;
|
|
||||||
this.employeeService = employeeRepository;
|
|
||||||
this.companyService = companyService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public RequestForCooperation addRequest(RequestForCooperationDTO requestDTO) {
|
|
||||||
final RequestForCooperation request = new RequestForCooperation(requestDTO.getNameCompany(),
|
|
||||||
requestDTO.getCreateDate(),
|
|
||||||
requestDTO.getType(),
|
|
||||||
requestDTO.getComment());
|
|
||||||
requestForCooperationRepository.save(request);
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public RequestForCooperation findRequest(Long id) {
|
|
||||||
final Optional<RequestForCooperation> report = requestForCooperationRepository.findById(id);
|
|
||||||
return report.orElseThrow(() -> new RequestNotFoundException(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public List<RequestForCooperation> findAllRequests() {
|
|
||||||
return requestForCooperationRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public RequestForCooperation updateRequest(RequestForCooperationDTO requestDTO) {
|
|
||||||
final RequestForCooperation currentReport = findRequest(requestDTO.getId());
|
|
||||||
currentReport.setApproveDate(requestDTO.getApproveDate());
|
|
||||||
currentReport.setActive(requestDTO.getActive());
|
|
||||||
currentReport.setUser(employeeService.findWorker(requestDTO.getSotr().getId()));
|
|
||||||
requestForCooperationRepository.save(currentReport);
|
|
||||||
return currentReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public RequestForCooperation deleteRequest(Long id) {
|
|
||||||
final RequestForCooperation currentReport = findRequest(id);
|
|
||||||
requestForCooperationRepository.delete(currentReport);
|
|
||||||
return currentReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void deleteAllRequests() {
|
|
||||||
requestForCooperationRepository.deleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Employee getEmployeeOfRequest(Long id)
|
|
||||||
{
|
|
||||||
return requestForCooperationRepository.findWorkerByRequest(findRequest(id));
|
|
||||||
}
|
|
||||||
@Transactional
|
|
||||||
public List<RequestForCooperation> getRequestsOfCompany(Company companyDTO)
|
|
||||||
{
|
|
||||||
Company company = companyService.findCompany(companyDTO.getId());
|
|
||||||
return requestForCooperationRepository.findRequestByCompany(company);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
public class RequestNotFoundException extends RuntimeException{
|
|
||||||
public RequestNotFoundException(Long id){
|
|
||||||
super(String.format("Request with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package com.example.demo.speaker.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.example.demo.speaker.model.User;
|
|
||||||
import com.example.demo.speaker.model.UserRole;
|
|
||||||
import com.example.demo.speaker.repository.IUserRepository;
|
|
||||||
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 java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UserService implements UserDetailsService {
|
|
||||||
private final IUserRepository userRepository;
|
|
||||||
private final PasswordEncoder passwordEncoder;
|
|
||||||
//private final ValidatorUtil validatorUtil;
|
|
||||||
public UserService(IUserRepository userRepository,
|
|
||||||
PasswordEncoder passwordEncoder
|
|
||||||
/*ValidatorUtil validatorUtil*/) {
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
this.passwordEncoder = passwordEncoder;
|
|
||||||
//this.validatorUtil = validatorUtil;
|
|
||||||
}
|
|
||||||
public Page<User> findAllPages(int page, int size) {
|
|
||||||
return userRepository.findAll(PageRequest.of(page - 1, size, Sort.by("id").ascending()));
|
|
||||||
}
|
|
||||||
public User findByLogin(String login) {
|
|
||||||
return userRepository.findOneByLoginIgnoreCase(login);
|
|
||||||
}
|
|
||||||
public User createUser(String login, String password, String passwordConfirm) {
|
|
||||||
return createUser(login, password, passwordConfirm, UserRole.USER);
|
|
||||||
}
|
|
||||||
public User createUser(String login, String password, String passwordConfirm, UserRole role) {
|
|
||||||
if (findByLogin(login) != null) {
|
|
||||||
//throw new ValidationException(String.format("User '%s' already exists", login));
|
|
||||||
}
|
|
||||||
final User user = new User(login, passwordEncoder.encode(password), role);
|
|
||||||
//validatorUtil.validate(user);
|
|
||||||
if (!Objects.equals(password, passwordConfirm)) {
|
|
||||||
//throw new ValidationException("Passwords not equals");
|
|
||||||
}
|
|
||||||
return userRepository.save(user);
|
|
||||||
}
|
|
||||||
@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.getRole()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1 @@
|
|||||||
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
|
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div>
|
|
||||||
<form action="#" th:action="@{/appointment/create}" th:object="${appointmentDTO}" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="name" class="form-label">Название</label>
|
|
||||||
<input type="text" class="form-control" id="name" th:field="${appointmentDTO.name}" required="true" style="width: 20%">
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<button type="submit" class="btn btn-info">
|
|
||||||
<span >Добавить</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Имя</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="appointment, iterator: ${appointments}">
|
|
||||||
<td th:text="${appointment.id}"/>
|
|
||||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
|
||||||
<form th:action="@{/appointment/edit/{id}(id=${appointment.id})}" th:object="${appointmentDTO}" th:method="post">
|
|
||||||
<input type="text" class="form-control" id="nameAppointment" th:field="${appointmentDTO.name}" th:placeholder="${appointment.name}" style="width: 60%; display: inline-block" >
|
|
||||||
<button class="btn btn-info"
|
|
||||||
type="submit" style="display: inline-block"> Изменить
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-info" style="display: inline-block"
|
|
||||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${appointment.id}').click()|">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form></td>
|
|
||||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
|
||||||
<td style="width: 10%">
|
|
||||||
|
|
||||||
<form th:action="@{/appointment/delete/{id}(id=${appointment.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${appointment.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div>
|
|
||||||
<form th:action="@{/company/create}" th:object="${companyDTO}" th:method="post">
|
|
||||||
<input type="text" class="form-control" id="nameCompanyNew" th:field="*{nameCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="legalAdressCompanyNew" th:field="*{legalAdressCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="adressCompanyNew" th:field="*{adressCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="contactEmailNew" th:field="*{contactEmail}" style="width: 15%; display: inline-block" >
|
|
||||||
<button class="btn btn-info"
|
|
||||||
type="submit" style="display: inline-block"> Создать
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Компания</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="company, iterator: ${companies}">
|
|
||||||
<td th:text="${company.id}"/>
|
|
||||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
|
||||||
<form th:action="@{/company/edit/{id}(id=${company.id})}" th:object="${companyDTO}" th:method="post">
|
|
||||||
<input type="text" class="form-control" id="nameCompany" th:placeholder="${company.nameCompany}" th:field="*{nameCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="legalAdressCompany" th:placeholder="${company.legalAdressCompany}" th:field="*{legalAdressCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="adressCompany" th:placeholder="${company.adressCompany}" th:field="*{adressCompany}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="contactEmail" th:placeholder="${company.contactEmail}" th:field="*{contactEmail}" style="width: 15%; display: inline-block" >
|
|
||||||
<button class="btn btn-info"
|
|
||||||
type="submit" style="display: inline-block"> Изменить
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-info" style="display: inline-block"
|
|
||||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${company.id}').click()|">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form></td>
|
|
||||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
|
||||||
<td style="width: 10%">
|
|
||||||
|
|
||||||
<form th:action="@{/company/delete/{id}(id=${company.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${company.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,53 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="ru"
|
|
||||||
xmlns:th="http://www.thymeleaf.org"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8"/>
|
|
||||||
<title>Site of Company</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
||||||
<link rel="icon" href="/favicon.svg">
|
|
||||||
<script type="text/javascript" src="/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<link rel="stylesheet" href="/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
|
|
||||||
<link rel="stylesheet" href="/webjars/font-awesome/6.1.0/css/all.min.css"/>
|
|
||||||
<link rel="stylesheet" href="/css/style.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="/">
|
|
||||||
<i class="fa-solid fa-font-awesome"></i>
|
|
||||||
Site of Company
|
|
||||||
</a>
|
|
||||||
<button class="navbar-toggler" type="button"
|
|
||||||
data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
|
||||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav"> <!--th:with="activeLink=${#request.requestURI}"-->
|
|
||||||
<a class="nav-link" href="/"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Главная</a>
|
|
||||||
<a class="nav-link" href="/appointment"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/appointment')} ? 'active' : ''">Appointment</a>
|
|
||||||
<a class="nav-link" href="/company"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/company')} ? 'active' : ''">Company</a>
|
|
||||||
<a class="nav-link" href="/employee"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/employee')} ? 'active' : ''">Employee</a>
|
|
||||||
<a class="nav-link" href="/request"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/request')} ? 'active' : ''">Request</a>
|
|
||||||
<a class="nav-link" href="/users" sec:authorize="hasRole('ROLE_ADMIN')" th:classappend="${#strings.equals(activeLink, '/users')} ? 'active' : ''">Пользователи</a>
|
|
||||||
<a class="nav-link" href="/logout" th:classappend="${#strings.equals(activeLink, '/login')} ? 'active' : ''">Выход</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="container container-padding" layout:fragment="content">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<th:block layout:fragment="scripts">
|
|
||||||
</th:block>
|
|
||||||
</html>
|
|
@ -1,73 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div>
|
|
||||||
<form action="#" th:action="@{/employee/create}" th:object="${employeeDTO}" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="name" class="form-label">Название</label>
|
|
||||||
<input type="text" class="form-control" id="name" th:field="${employeeDTO.fio}" required="true">
|
|
||||||
</div>
|
|
||||||
<select id="appointmentId" class="form-select" th:name="${employeeDTO.appointmentId}" style="width: 30%; display: inline-block">
|
|
||||||
<option th:each="app: ${appointments}" th:value="${app.id}">
|
|
||||||
<span th:text="${app.name}"></span>
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<div class="mb-3">
|
|
||||||
<button type="submit" class="btn btn-info">
|
|
||||||
<span >Добавить</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Сотрудник</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="employee, iterator: ${employees}">
|
|
||||||
<td th:text="${employee.id}"/>
|
|
||||||
<td >
|
|
||||||
<form th:action="@{/employee/edit/{id}(id=${employee.id})}" th:object="${employeeDTO}" th:method="post">
|
|
||||||
<input type="text" class="form-control" id="fio" th:field="${employeeDTO.fio}" th:placeholder="${employee.fio}" style="width: 30%; display: inline-block" >
|
|
||||||
|
|
||||||
<select id="appointment" class="form-select" th:name="${employeeDTO.appointmentId}" style="width: 30%; display: inline-block">
|
|
||||||
<option th:each="app: ${appointments}" th:value="${app.id}" th:selected="${employee.appointmentId} == ${app.id}">
|
|
||||||
<span th:text="${app.name}"></span>
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button class="btn btn-info"
|
|
||||||
type="submit" style="display: inline-block"> Изменить
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-info" style="display: inline-block"
|
|
||||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${employee.id}').click()|">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form></td>
|
|
||||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
|
||||||
<td style="width: 10%">
|
|
||||||
|
|
||||||
<form th:action="@{/employee/delete/{id}(id=${employee.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${employee.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<p>It's works!</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,34 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
xmlns:th="http://www.w3.org/1999/xhtml"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div th:if="${param.error}" class="alert alert-danger margin-bottom">
|
|
||||||
Пользователь не найден или пароль указан не верно
|
|
||||||
</div>
|
|
||||||
<div th:if="${param.logout}" class="alert alert-success margin-bottom">
|
|
||||||
Выход успешно произведен
|
|
||||||
</div>
|
|
||||||
<div th:if="${param.created}" class="alert alert-success margin-bottom">
|
|
||||||
Пользователь '<span th:text="${param.created}"></span>' успешно создан
|
|
||||||
</div>
|
|
||||||
<form th:action="@{/login}" method="post" class="container-padding">
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="text" name="username" id="username" class="form-control"
|
|
||||||
placeholder="Логин" required="true" autofocus="true"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="password" name="password" id="password" class="form-control"
|
|
||||||
placeholder="Пароль" required="true"/>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-success button-fixed">Войти</button>
|
|
||||||
<a class="btn btn-primary button-fixed" href="/signup">Регистрация</a>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,67 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Заявка</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="request, iterator: ${requests}">
|
|
||||||
<td th:text="${request.id}"/>
|
|
||||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
|
||||||
<form th:action="@{/request/edit/{id}(id=*{id})}" th:object="${request}" th:method="post">
|
|
||||||
<select id="company" class="form-select" th:name="company" style="width: 15%; display: inline-block">
|
|
||||||
<option th:each="value: ${companies}" th:selected="${request.getNameCompany().getNameCompany()} == ${value.nameCompany}">
|
|
||||||
<span th:text="${value.getNameCompany()}"></span>
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<input type="date" class="form-control" id="createDate" th:value="${request.getCreateDate()}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="date" class="form-control" id="approveDate" th:value="${request.getApproveDate()}" style="width: 15%; display: inline-block" >
|
|
||||||
<input type="text" class="form-control" id="comment" th:value="${request.getComment()}" style="width: 15%; display: inline-block" >
|
|
||||||
|
|
||||||
<select id="employee" class="form-select" th:name="employee" style="width: 30%; display: inline-block">
|
|
||||||
<option th:each="value: ${employees}" th:selected="${request.getSotr().getFio()} == ${value.getFio()}">
|
|
||||||
<span th:text="${value.getFio()}"></span>
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="types" class="form-select" th:name="type" style="width: 30%; display: inline-block">
|
|
||||||
<option th:each="value: ${types}" th:selected="${request.getType()} == ${value}">
|
|
||||||
<span th:text="${value}"></span>
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button class="btn btn-info"
|
|
||||||
type="submit" style="display: inline-block"> Изменить
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-info" style="display: inline-block"
|
|
||||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${employee.id}').click()|">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form></td>
|
|
||||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
|
||||||
<td style="width: 10%">
|
|
||||||
|
|
||||||
<form th:action="@{/employee/delete/{id}(id=${request.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${request.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,31 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
xmlns:th="http://www.w3.org/1999/xhtml"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container container-padding" layout:fragment="content">
|
|
||||||
<div th:if="${errors}" th:text="${errors}" class="margin-bottom alert alert-danger"></div>
|
|
||||||
<form action="#" th:action="@{/signup}" th:object="${UserDTO}" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="text" class="form-control" th:field="${UserDTO.login}"
|
|
||||||
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="password" class="form-control" th:field="${UserDTO.password}"
|
|
||||||
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="password" class="form-control" th:field="${UserDTO.passwordConfirm}"
|
|
||||||
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<button type="submit" class="btn btn-success button-fixed">Создать</button>
|
|
||||||
<a class="btn btn-primary button-fixed" href="/login">Назад</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,40 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
xmlns:th="http://www.w3.org/1999/xhtml"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container" layout:fragment="content">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table text-light">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Логин</th>
|
|
||||||
<th scope="col">Роль</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="user, iterator: ${users}">
|
|
||||||
<th scope="row" th:text="${iterator.index} + 1"></th>
|
|
||||||
<td th:text="${user.id}"></td>
|
|
||||||
<td th:text="${user.login}" style="width: 60%"></td>
|
|
||||||
<td th:text="${user.role}" style="width: 20%"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div th:if="${totalPages > 0}" class="pagination text-light">
|
|
||||||
<span style="float: left; padding: 5px 5px;">Страницы:</span>
|
|
||||||
<a th:each="page : ${pages}"
|
|
||||||
th:href="@{/users(page=${page}, size=${users.size})}"
|
|
||||||
th:text="${page}"
|
|
||||||
th:class="${page == users.number + 1} ? active">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package LabWork.DozorovaLabWork;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class DozorovaLabWorkApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package com.example.demo;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
|
|
||||||
@SpringBootTest
|
|
||||||
public class JPATests {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
spring.datasource.url=jdbc:h2:mem:testdb
|
|
||||||
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=create-drop
|
|
Loading…
x
Reference in New Issue
Block a user