Compare commits
10 Commits
ba1c0e747c
...
ed72511ed4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed72511ed4 | ||
|
|
1f26015bad | ||
|
|
f573660325 | ||
|
|
9fb5cdf87c | ||
|
|
0cb15aae70 | ||
|
|
da188a65a4 | ||
|
|
1fdf084a25 | ||
|
|
d9f5a32486 | ||
|
|
8bc3501998 | ||
|
|
5abfc4d6c3 |
@@ -5,7 +5,7 @@ COPY . /build/source
|
|||||||
WORKDIR /build/source
|
WORKDIR /build/source
|
||||||
RUN mvn -am clean package
|
RUN mvn -am clean package
|
||||||
# Создание образа my-bar
|
# Создание образа my-bar
|
||||||
FROM openjdk:17-jdk-slim as my-bar
|
FROM openjdk:17-ea-jdk-slim as my-bar
|
||||||
COPY --from=build /build/source/target/*.jar /data/app/my-bar.jar
|
COPY --from=build /build/source/target/*.jar /data/app/my-bar.jar
|
||||||
WORKDIR /data/app
|
WORKDIR /data/app
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|||||||
@@ -12,23 +12,34 @@ import Toolbar from "@mui/material/Toolbar";
|
|||||||
import AddCircleIcon from '@mui/icons-material/AddCircle';
|
import AddCircleIcon from '@mui/icons-material/AddCircle';
|
||||||
import {BarCreateModal} from "../../components/BarCreateModal";
|
import {BarCreateModal} from "../../components/BarCreateModal";
|
||||||
import PowerIcon from '@mui/icons-material/Power';
|
import PowerIcon from '@mui/icons-material/Power';
|
||||||
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||||
import {barClient} from "../../lib/clients/BarClient";
|
import {barClient} from "../../lib/clients/BarClient";
|
||||||
|
|
||||||
export function BarChangePage() {
|
export function BarChangePage() {
|
||||||
const [bars, setBars] = useState([])
|
const [bars, setBars] = useState([])
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const {createError, createSuccess, createWarning} = useAlert();
|
const [oldId, setOldId] = useState(null);
|
||||||
|
const {createError, createSuccess, createWarning, notImplement} = useAlert();
|
||||||
|
|
||||||
const createHandler = (name) => barClient.createBar(name, bars, createSuccess, createError, setBars, setOpen)
|
const createHandler = (id, name) => {
|
||||||
|
if (id) {
|
||||||
|
barClient.copyBar(id, name, setBars, bars, createError, createSuccess, setOpen)
|
||||||
|
} else {
|
||||||
|
barClient.createBar(name, bars, createSuccess, createError, setBars, setOpen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => barClient.getBarList(setBars, createError), []);
|
useEffect(() => barClient.getBarList(setBars, createError), []);
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<BarCreateModal open={open} setOpen={setOpen} create={createHandler}/>
|
<BarCreateModal open={open} setOpen={setOpen} create={createHandler} id={oldId}/>
|
||||||
<Paper sx={{p: 1}}>
|
<Paper sx={{p: 1}}>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<Typography variant='h6'>Списки ингредиентов (бары)</Typography>
|
<Typography variant='h6'>Списки ингредиентов (бары)</Typography>
|
||||||
<IconButton edge="end" onClick={() => setOpen(true)}>
|
<IconButton edge="end" onClick={() => {
|
||||||
|
setOldId(null);
|
||||||
|
setOpen(true);
|
||||||
|
}}>
|
||||||
<AddCircleIcon/>
|
<AddCircleIcon/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
@@ -36,18 +47,27 @@ export function BarChangePage() {
|
|||||||
return <Card key={b.id} sx={{m: 2, p: 2}}>
|
return <Card key={b.id} sx={{m: 2, p: 2}}>
|
||||||
<Stack direction='row' justifyContent={'space-between'}>
|
<Stack direction='row' justifyContent={'space-between'}>
|
||||||
<Typography>{b.name}</Typography>
|
<Typography>{b.name}</Typography>
|
||||||
{b.active && <IconButton disabled>
|
<Box>
|
||||||
<PowerIcon/>
|
<IconButton onClick={() => {
|
||||||
</IconButton>}
|
setOldId(b.id)
|
||||||
{!b.active && <Box>
|
setOpen(true);
|
||||||
<IconButton onClick={() => barClient.deleteBar(b, bars, createError, createSuccess, setBars)}>
|
}}>
|
||||||
<DeleteIcon/>
|
<ContentCopyIcon/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
{b.active && <IconButton disabled>
|
||||||
onClick={() => barClient.changeBar(b.id, bars, createWarning, createSuccess, createError, setBars)}>
|
<PowerIcon/>
|
||||||
<ElectricalServicesIcon/>
|
</IconButton>}
|
||||||
</IconButton>
|
{!b.active && <>
|
||||||
</Box>}
|
<IconButton
|
||||||
|
onClick={() => barClient.deleteBar(b, bars, createError, createSuccess, setBars)}>
|
||||||
|
<DeleteIcon/>
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
onClick={() => barClient.changeBar(b.id, bars, createWarning, createSuccess, createError, setBars)}>
|
||||||
|
<ElectricalServicesIcon/>
|
||||||
|
</IconButton>
|
||||||
|
</>}
|
||||||
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export function CalcPage() {
|
|||||||
const {createError} = useAlert();
|
const {createError} = useAlert();
|
||||||
const [cocktails, setCocktails] = React.useState([]);
|
const [cocktails, setCocktails] = React.useState([]);
|
||||||
const [load, setLoad] = React.useState(false);
|
const [load, setLoad] = React.useState(false);
|
||||||
const [cocktailMap, setCocktailMap] = React.useState([]);
|
const [cocktailMap, setCocktailMap] = React.useState({});
|
||||||
|
|
||||||
const changeHandler = (id, value) => {
|
const changeHandler = (id, value) => {
|
||||||
setCocktailMap((prev) => ({
|
setCocktailMap((prev) => ({
|
||||||
@@ -67,6 +67,8 @@ export function CalcPage() {
|
|||||||
setCocktails(state);
|
setCocktails(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(cocktailMap)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box padding={2}>
|
<Box padding={2}>
|
||||||
<Typography variant="h4" align="center">Коктейли</Typography>
|
<Typography variant="h4" align="center">Коктейли</Typography>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import DialogActions from "@mui/material/DialogActions";
|
|||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
|
|
||||||
export function BarCreateModal({open, setOpen, create}) {
|
export function BarCreateModal({open, setOpen, create, id}) {
|
||||||
const [value, setValue] = useState("");
|
const [value, setValue] = useState("");
|
||||||
return (
|
return (
|
||||||
<Dialog fullWidth={true}
|
<Dialog fullWidth={true}
|
||||||
@@ -26,13 +26,17 @@ export function BarCreateModal({open, setOpen, create}) {
|
|||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<TextField sx={{width: '75%'}}
|
<TextField sx={{width: '75%'}}
|
||||||
label={"Название списка"} variant='outlined'
|
label={<Typography pt={'4px'}>
|
||||||
|
Название списка</Typography>} variant='outlined'
|
||||||
value={!value ? "" : value}
|
value={!value ? "" : value}
|
||||||
onChange={(e) => setValue(e.target.value)}
|
onChange={(e) => setValue(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={() => create(value)}>Создать</Button>
|
<Button onClick={() => {
|
||||||
|
create(id, value);
|
||||||
|
setValue("");
|
||||||
|
}}>Создать</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ export function FilterBlock({filter, handleFilterChange, handleClearFilter, barm
|
|||||||
{/*Фильтр по категории*/}
|
{/*Фильтр по категории*/}
|
||||||
{category.length > 0 && (
|
{category.length > 0 && (
|
||||||
<CheckMarks rows={category} name={"Категории"} filterValue={filter.category}
|
<CheckMarks rows={category} name={"Категории"} filterValue={filter.category}
|
||||||
filterName={"category"} handleChange={handleFilterChange} identity/>)}
|
filterName={"category"} handleChange={handleFilterChange}/>)}
|
||||||
{/*Фильтр по посуде*/}
|
{/*Фильтр по посуде*/}
|
||||||
{glass.length > 0 && (<CheckMarks rows={glass} name={"Подача"} handleChange={handleFilterChange}
|
{glass.length > 0 && (<CheckMarks rows={glass} name={"Подача"} handleChange={handleFilterChange}
|
||||||
filterValue={filter.glass} filterName={"glass"} identity/>)}
|
filterValue={filter.glass} filterName={"glass"}/>)}
|
||||||
{/*Фильтр по нехватке ингредиентов*/}
|
{/*Фильтр по нехватке ингредиентов*/}
|
||||||
{(barmen && filter.all) && (<CheckMarks rows={ingredientCount} name={"Не хватает ингредиентов"}
|
{(barmen && filter.all) && (<CheckMarks rows={ingredientCount} name={"Не хватает ингредиентов"}
|
||||||
handleChange={handleFilterChange}
|
handleChange={handleFilterChange}
|
||||||
|
|||||||
@@ -58,6 +58,17 @@ class BarClient {
|
|||||||
setOpen(false)
|
setOpen(false)
|
||||||
}).catch(() => createError("Ошибка создания списка"))
|
}).catch(() => createError("Ошибка создания списка"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyBar(oldId, newName, setBars, bars, createError, createSuccess, setOpen) {
|
||||||
|
api().post(requests.bar.crud + "copy/" + oldId + "/" + newName)
|
||||||
|
.then((r) => {
|
||||||
|
const state = bars;
|
||||||
|
state.push(r.data)
|
||||||
|
setBars(state);
|
||||||
|
createSuccess("Бар скопирован")
|
||||||
|
setOpen(false)
|
||||||
|
}).catch(() => createError("Ошибка при копировании бара"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const barClient = new BarClient();
|
export const barClient = new BarClient();
|
||||||
@@ -76,8 +76,13 @@ class CocktailClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCocktails(data);
|
setCocktails(data);
|
||||||
let map = [];
|
let map = {};
|
||||||
map = data.map((d) => map[d.id] = 1)
|
data.forEach((d) => {
|
||||||
|
map = {
|
||||||
|
...map,
|
||||||
|
[d.id]: 1
|
||||||
|
}
|
||||||
|
})
|
||||||
setCocktailMap(map);
|
setCocktailMap(map);
|
||||||
setLoad(true);
|
setLoad(true);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {tokenUtil} from "./TokenUtil";
|
import {tokenUtil} from "./TokenUtil";
|
||||||
|
|
||||||
const host = "localhost:8080"; //дебаг вместе с беком
|
// const host = "localhost:8080"; //дебаг вместе с беком
|
||||||
// const host = "192.168.1.100:8091"; //дебаг фронта
|
// const host = "192.168.1.100:8091"; //дебаг фронта
|
||||||
// const host = "bar.kayashov.keenetic.pro"; //прод
|
const host = "bar.kayashov.keenetic.pro"; //прод
|
||||||
export const api = () => {
|
export const api = () => {
|
||||||
const result = axios;
|
const result = axios;
|
||||||
result.defaults.baseURL = `${window.location.protocol}//${host}/`;
|
result.defaults.baseURL = `${window.location.protocol}//${host}/`;
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ public class BarController {
|
|||||||
barService.changeActiveBar(id);
|
barService.changeActiveBar(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/copy/{id}/{name}")
|
||||||
|
public BarResponseDto copyActiveBar(@PathVariable Long id, @PathVariable String name) {
|
||||||
|
return barService.copyBar(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public void deleteBar(@PathVariable Long id) {
|
public void deleteBar(@PathVariable Long id) {
|
||||||
barService.deleteBar(id);
|
barService.deleteBar(id);
|
||||||
|
|||||||
@@ -92,6 +92,26 @@ public class BarService {
|
|||||||
return BarResponseDto.mapToDto(bar);
|
return BarResponseDto.mapToDto(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public BarResponseDto copyBar(Long id, String name) {
|
||||||
|
BarEntity barEntity = barEntityRepository.findById(id).orElseThrow();
|
||||||
|
|
||||||
|
BarEntity entity = new BarEntity();
|
||||||
|
entity.setName(name);
|
||||||
|
entity.setActive(false);
|
||||||
|
entity.setIngredients(new ArrayList<>());
|
||||||
|
barEntityRepository.save(entity);
|
||||||
|
List<IngredientEntity> ingredients = barEntity.getIngredients()
|
||||||
|
.stream()
|
||||||
|
.peek(i -> i.getBars().add(entity))
|
||||||
|
.toList();
|
||||||
|
entity.setIngredients(ingredients);
|
||||||
|
ingredientRepository.saveAll(ingredients);
|
||||||
|
log.info("Бар {} - {}, скопирован как {} - {}", barEntity.getId(), barEntity.getName(), entity.getId(), name);
|
||||||
|
|
||||||
|
return BarResponseDto.mapToDto(entity);
|
||||||
|
}
|
||||||
|
|
||||||
private List<CocktailEntity> findAllowedCocktails(List<IngredientEntity> ingredients) {
|
private List<CocktailEntity> findAllowedCocktails(List<IngredientEntity> ingredients) {
|
||||||
List<CocktailEntity> result = new ArrayList<>();
|
List<CocktailEntity> result = new ArrayList<>();
|
||||||
for (IngredientEntity ingredient : ingredients) {
|
for (IngredientEntity ingredient : ingredients) {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ spring.application.name=myBar
|
|||||||
cocktail.photo.path=${COCKTAIL_PHOTO_PATH:/mnt/sdb1/my-bar-front/build/assets/cocktails}
|
cocktail.photo.path=${COCKTAIL_PHOTO_PATH:/mnt/sdb1/my-bar-front/build/assets/cocktails}
|
||||||
|
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
spring.datasource.url=${DB_URL:jdbc:postgresql://192.168.1.100:5432/drinks}
|
spring.datasource.url=${DB_URL:jdbc:postgresql://localhost:5433/drink}
|
||||||
spring.datasource.username=${DB_NAME:nextcloud}
|
spring.datasource.username=${DB_NAME:postgres}
|
||||||
spring.datasource.password=${DB_PASSWORD:kayash73}
|
spring.datasource.password=${DB_PASSWORD:pgpass}
|
||||||
spring.datasource.hikari.minimum-idle=15
|
spring.datasource.hikari.minimum-idle=15
|
||||||
spring.datasource.hikari.maximum-pool-size=50
|
spring.datasource.hikari.maximum-pool-size=50
|
||||||
spring.datasource.hikari.idle-timeout=30000
|
spring.datasource.hikari.idle-timeout=30000
|
||||||
@@ -16,3 +16,5 @@ spring.jpa.generate-ddl=true
|
|||||||
token.signing.key=${SIGNING_KEY:ThisIsKayashovBarSecretKey-1.0.0Version}
|
token.signing.key=${SIGNING_KEY:ThisIsKayashovBarSecretKey-1.0.0Version}
|
||||||
|
|
||||||
spring.jpa.show-sql=false
|
spring.jpa.show-sql=false
|
||||||
|
|
||||||
|
#server.port=8081
|
||||||
Reference in New Issue
Block a user