Fix swagger deps
This commit is contained in:
parent
28f068c890
commit
f63210272d
28 changed files with 307 additions and 310 deletions
|
@ -31,7 +31,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, onMounted, PropType, ref } from "vue";
|
||||
import { BillsService, service_Bill, service_BillItem } from "@/services/openapi";
|
||||
import { BillsService, controller_Bill, controller_BillItem } from "@/services/openapi";
|
||||
import { convertToEur } from "@/utils";
|
||||
import WaveSpinner from "@/components/UI/WaveSpinner.vue";
|
||||
import moment from "moment";
|
||||
|
@ -39,10 +39,10 @@ import moment from "moment";
|
|||
export default defineComponent({
|
||||
name: "BillModal",
|
||||
components: { WaveSpinner },
|
||||
props: { bill: { type: Object as PropType<service_Bill>, required: true } },
|
||||
props: { bill: { type: Object as PropType<controller_Bill>, required: true } },
|
||||
setup(props) {
|
||||
const isLoading = ref(true);
|
||||
const billItems = ref<service_BillItem[]>();
|
||||
const billItems = ref<controller_BillItem[]>();
|
||||
const date = computed(() => props.bill.created_at && moment.unix(props.bill.created_at).format("DD.MM.YYYY"));
|
||||
const time = computed(() => props.bill.created_at && moment.unix(props.bill.created_at).format("HH:mm") + " Uhr");
|
||||
onMounted(() => {
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, PropType, ref, watch } from "vue";
|
||||
import BaseCard from "@/components/UI/BaseCard.vue";
|
||||
import { OrderItemsService, service_OrderItem } from "@/services/openapi";
|
||||
import { OrderItemsService, controller_OrderItem } from "@/services/openapi";
|
||||
import InputText from "primevue/inputtext";
|
||||
import { FilterMatchMode } from "primevue/api";
|
||||
import DataTable from "primevue/datatable";
|
||||
|
@ -95,8 +95,8 @@ export default defineComponent({
|
|||
// eslint-disable-next-line
|
||||
components: { BaseCard, InputText, DataTable, Column, Button, Dialog, InputNumber, ConfirmDialog },
|
||||
props: {
|
||||
orderItems: { type: Array as PropType<service_OrderItem[]>, default: () => [] },
|
||||
emptyOrderItem: { type: Object as PropType<service_OrderItem>, default: () => ({}) },
|
||||
orderItems: { type: Array as PropType<controller_OrderItem[]>, default: () => [] },
|
||||
emptyOrderItem: { type: Object as PropType<controller_OrderItem>, default: () => ({}) },
|
||||
title: { type: String, default: "" },
|
||||
},
|
||||
emits: ["orderItemChanged", "orderItemDeleted", "orderItemCreated"],
|
||||
|
@ -108,8 +108,8 @@ export default defineComponent({
|
|||
const filters = ref({
|
||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||
});
|
||||
const orderItem = ref<service_OrderItem>({ ...props.emptyOrderItem });
|
||||
function editOrderItem(item: service_OrderItem) {
|
||||
const orderItem = ref<controller_OrderItem>({ ...props.emptyOrderItem });
|
||||
function editOrderItem(item: controller_OrderItem) {
|
||||
orderItem.value = { ...item };
|
||||
modal.value = true;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
|
||||
function confirmDeleteProduct(item: service_OrderItem) {
|
||||
function confirmDeleteProduct(item: controller_OrderItem) {
|
||||
if (isDisabled.value) return;
|
||||
confirm.require({
|
||||
message: item.description + " löschen?",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, onMounted, onUnmounted, PropType, ref } from "vue";
|
||||
import { service_Order, types_ItemType } from "@/services/openapi";
|
||||
import { controller_Order, controller_ItemType } from "@/services/openapi";
|
||||
import { convertToEur, getCurrentTimeSince, lessThan15SecondsAgo } from "@/utils";
|
||||
import Button from "primevue/button";
|
||||
import moment from "moment";
|
||||
|
@ -26,9 +26,9 @@ export default defineComponent({
|
|||
// eslint-disable-next-line
|
||||
components: { SmallCard, TheBadge, Button },
|
||||
props: {
|
||||
order: { type: Object as PropType<service_Order>, required: true },
|
||||
order: { type: Object as PropType<controller_Order>, required: true },
|
||||
isDisabled: { type: Boolean, default: false },
|
||||
itemType: { type: Number as PropType<types_ItemType>, required: false },
|
||||
itemType: { type: Number as PropType<controller_ItemType>, required: false },
|
||||
},
|
||||
emits: ["orderDone"],
|
||||
setup(props) {
|
||||
|
@ -37,7 +37,7 @@ export default defineComponent({
|
|||
let ticker: any;
|
||||
const since = ref(getCurrentTimeSince(props.order.updated_at));
|
||||
const newOrder = ref(lessThan15SecondsAgo(props.order.updated_at));
|
||||
const badgeTwo = computed(() => props.itemType === types_ItemType.ColdDrink);
|
||||
const badgeTwo = computed(() => props.itemType === controller_ItemType.ColdDrink);
|
||||
|
||||
onMounted(() => {
|
||||
ticker = setInterval(() => {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, inject, PropType, ref } from "vue";
|
||||
import { OrdersService, service_Order, types_ItemType } from "@/services/openapi";
|
||||
import { OrdersService, controller_Order, controller_ItemType } from "@/services/openapi";
|
||||
import { detailedItemTypeIcon, detailedItemTypeString, errorToast, lessThan15SecondsAgo } from "@/utils";
|
||||
import OrderCard from "@/components/Orders/OrderCard.vue";
|
||||
import BaseToolbar from "@/components/UI/BaseToolbar.vue";
|
||||
|
@ -28,10 +28,10 @@ export default defineComponent({
|
|||
name: "OrderSection",
|
||||
components: { OrderCard, BaseToolbar },
|
||||
props: {
|
||||
orders: { type: Object as PropType<service_Order[]>, required: true },
|
||||
orders: { type: Object as PropType<controller_Order[]>, required: true },
|
||||
icon: { type: String, required: false },
|
||||
title: { type: String, required: false },
|
||||
itemType: { type: Number as PropType<types_ItemType>, required: false },
|
||||
itemType: { type: Number as PropType<controller_ItemType>, required: false },
|
||||
},
|
||||
emits: ["filterOrders"],
|
||||
setup(props, { emit }) {
|
||||
|
@ -46,7 +46,7 @@ export default defineComponent({
|
|||
});
|
||||
}
|
||||
|
||||
function orderDone(order: service_Order) {
|
||||
function orderDone(order: controller_Order) {
|
||||
isDisabled.value = true;
|
||||
order.is_served = true;
|
||||
OrdersService.putOrders(order)
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from "vue";
|
||||
import { service_Order } from "@/services/openapi";
|
||||
import { controller_Order } from "@/services/openapi";
|
||||
|
||||
export default defineComponent({
|
||||
name: "OrderAmountChange",
|
||||
props: {
|
||||
order: { type: Object as PropType<service_Order>, required: true },
|
||||
order: { type: Object as PropType<controller_Order>, required: true },
|
||||
isDisabled: { type: Boolean, default: false },
|
||||
},
|
||||
emits: ["incrementOrder", "decrementOrder"],
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, inject, PropType, ref } from "vue";
|
||||
import { OrdersService, service_Order } from "@/services/openapi";
|
||||
import { OrdersService, controller_Order } from "@/services/openapi";
|
||||
import { convertToEur, generalItemTypeString, generalItemTypeIcon } from "@/utils";
|
||||
import BaseToolbar from "@/components/UI/BaseToolbar.vue";
|
||||
import TableOrderCard from "@/components/Tables/TableOrderCard.vue";
|
||||
|
@ -24,7 +24,7 @@ export default defineComponent({
|
|||
name: "OverviewPerType",
|
||||
components: { TableOrderCard, BaseToolbar, OrderAmountChange },
|
||||
props: {
|
||||
orders: { type: Array as PropType<service_Order[]>, default: () => [] },
|
||||
orders: { type: Array as PropType<controller_Order[]>, default: () => [] },
|
||||
type: { type: Array as PropType<number[]>, required: true },
|
||||
},
|
||||
emits: ["openModal", "getData"],
|
||||
|
@ -32,12 +32,12 @@ export default defineComponent({
|
|||
const OrdersForType = computed(() => props.orders.filter((order) => props.type.includes(order.order_item.item_type)));
|
||||
const isLoading = inject(loading, ref(false));
|
||||
|
||||
function incrementOrder(order: service_Order) {
|
||||
function incrementOrder(order: controller_Order) {
|
||||
isLoading.value = true;
|
||||
OrdersService.postOrders(order.order_item_id, order.table_id).finally(() => emit("getData"));
|
||||
}
|
||||
|
||||
function decrementOrder(order: service_Order) {
|
||||
function decrementOrder(order: controller_Order) {
|
||||
isLoading.value = true;
|
||||
OrdersService.deleteOrders(order.order_item_id, order.table_id).finally(() => emit("getData"));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted, onUnmounted, PropType, ref } from "vue";
|
||||
import { service_Table } from "@/services/openapi";
|
||||
import { controller_Table } from "@/services/openapi";
|
||||
import moment from "moment";
|
||||
import { convertToEur, getCurrentTimeSince } from "@/utils";
|
||||
import TheBadge from "@/components/UI/TheBadge.vue";
|
||||
|
@ -22,7 +22,7 @@ import SmallCard from "@/components/UI/SmallCard.vue";
|
|||
export default defineComponent({
|
||||
name: "TableCard",
|
||||
components: { TheBadge, SmallCard },
|
||||
props: { table: { type: Object as PropType<service_Table>, required: true } },
|
||||
props: { table: { type: Object as PropType<controller_Table>, required: true } },
|
||||
setup(props) {
|
||||
moment.locale("de");
|
||||
// eslint-disable-next-line
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, PropType } from "vue";
|
||||
import { service_Order, types_ItemType } from "@/services/openapi";
|
||||
import { controller_Order, controller_ItemType } from "@/services/openapi";
|
||||
import { convertToEur } from "@/utils";
|
||||
import SmallCard from "@/components/UI/SmallCard.vue";
|
||||
|
||||
|
@ -19,12 +19,12 @@ export default defineComponent({
|
|||
name: "TableOrderCard",
|
||||
components: { SmallCard },
|
||||
props: {
|
||||
order: { type: Object as PropType<service_Order>, required: true },
|
||||
order: { type: Object as PropType<controller_Order>, required: true },
|
||||
},
|
||||
emits: ["decrementOrder", "incrementOrder"],
|
||||
setup(props) {
|
||||
const showTotal = computed(() => props.order.order_item.price !== props.order.total);
|
||||
return { convertToEur, types_ItemType, showTotal };
|
||||
return { convertToEur, controller_ItemType, showTotal };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -3,8 +3,13 @@
|
|||
<Transition>
|
||||
<WaveSpinner v-if="initialLoading" />
|
||||
<div v-else>
|
||||
<OverviewPerType :type="[types_ItemType.Food]" :orders="orders" @getData="getData" @openModal="(t) => addBeverage(t)" />
|
||||
<OverviewPerType :type="[types_ItemType.ColdDrink, types_ItemType.HotDrink]" :orders="orders" @getData="getData" @openModal="(t) => addBeverage(t)" />
|
||||
<OverviewPerType :type="[controller_ItemType.Food]" :orders="orders" @getData="getData" @openModal="(t) => addBeverage(t)" />
|
||||
<OverviewPerType
|
||||
:type="[controller_ItemType.ColdDrink, controller_ItemType.HotDrink]"
|
||||
:orders="orders"
|
||||
@getData="getData"
|
||||
@openModal="(t) => addBeverage(t)"
|
||||
/>
|
||||
<div class="h-4rem"></div>
|
||||
|
||||
<BottomNavigation>
|
||||
|
@ -56,7 +61,7 @@
|
|||
import { computed, defineComponent, provide, ref } from "vue";
|
||||
import BaseCard from "@/components/UI/BaseCard.vue";
|
||||
import { useStore } from "vuex";
|
||||
import { OrdersService, service_Order, service_OrderItem, types_ItemType } from "@/services/openapi";
|
||||
import { OrdersService, controller_Order, controller_OrderItem, controller_ItemType } from "@/services/openapi";
|
||||
import BottomNavigation from "@/components/UI/BottomNavigation.vue";
|
||||
import Button from "primevue/button";
|
||||
import { convertToEur } from "@/utils";
|
||||
|
@ -82,7 +87,7 @@ export default defineComponent({
|
|||
const total = ref(0);
|
||||
const orderItems = computed(() => store.getters.getOrderItems);
|
||||
const options = ref();
|
||||
const orders = ref<service_Order[]>([]);
|
||||
const orders = ref<controller_Order[]>([]);
|
||||
|
||||
store.dispatch("getAllOrderItems");
|
||||
|
||||
|
@ -110,13 +115,13 @@ export default defineComponent({
|
|||
total.value = temp;
|
||||
}
|
||||
|
||||
function addBeverage(itemType: types_ItemType[]) {
|
||||
function addBeverage(itemType: controller_ItemType[]) {
|
||||
newOrderModal.value = true;
|
||||
options.value = [];
|
||||
itemType.forEach((type) => {
|
||||
options.value = options.value.concat(orderItems.value.get(type));
|
||||
});
|
||||
options.value.sort((a: service_OrderItem, b: service_OrderItem) => {
|
||||
options.value.sort((a: controller_OrderItem, b: controller_OrderItem) => {
|
||||
const x = a.description.toLowerCase();
|
||||
const y = b.description.toLowerCase();
|
||||
if (x < y) return -1;
|
||||
|
@ -142,7 +147,7 @@ export default defineComponent({
|
|||
total,
|
||||
convertToEur,
|
||||
addBeverage,
|
||||
types_ItemType,
|
||||
controller_ItemType,
|
||||
postOrder,
|
||||
orders,
|
||||
getData,
|
||||
|
|
|
@ -24,7 +24,7 @@ import Menubar from "primevue/menubar";
|
|||
import { useStore } from "vuex";
|
||||
import Button from "primevue/button";
|
||||
import { useRoute } from "vue-router";
|
||||
import { TablesService, types_ItemType } from "@/services/openapi";
|
||||
import { TablesService, controller_ItemType } from "@/services/openapi";
|
||||
import { detailedItemTypeString, errorToast } from "@/utils";
|
||||
import { useToast } from "primevue/usetoast";
|
||||
import { visible } from "@/keys";
|
||||
|
@ -84,9 +84,9 @@ export default defineComponent({
|
|||
label: "Artikel",
|
||||
icon: "pi pi-fw pi-shopping-cart",
|
||||
items: [
|
||||
{ label: detailedItemTypeString(types_ItemType.Food), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + types_ItemType.Food },
|
||||
{ label: detailedItemTypeString(types_ItemType.ColdDrink), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + types_ItemType.ColdDrink },
|
||||
{ label: detailedItemTypeString(types_ItemType.HotDrink), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + types_ItemType.HotDrink },
|
||||
{ label: detailedItemTypeString(controller_ItemType.Food), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + controller_ItemType.Food },
|
||||
{ label: detailedItemTypeString(controller_ItemType.ColdDrink), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + controller_ItemType.ColdDrink },
|
||||
{ label: detailedItemTypeString(controller_ItemType.HotDrink), icon: "pi pi-fw pi-shopping-cart", to: "/items/" + controller_ItemType.HotDrink },
|
||||
],
|
||||
visible: () => editor.value,
|
||||
},
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
import { computed, defineComponent, inject, ref } from "vue";
|
||||
import Sidebar from "primevue/sidebar";
|
||||
import { visible } from "@/keys";
|
||||
import { user_User, UsersService } from "@/services/openapi";
|
||||
import { controller_User, UsersService } from "@/services/openapi";
|
||||
import InputSwitch from "primevue/inputswitch";
|
||||
import { useStore } from "vuex";
|
||||
import { errorToast } from "@/utils";
|
||||
|
@ -30,7 +30,7 @@ export default defineComponent({
|
|||
const toast = useToast();
|
||||
const isLoading = ref(false);
|
||||
const isVisible = inject(visible, ref(false));
|
||||
const user = computed<user_User>(() => store.getters.getUser);
|
||||
const user = computed<controller_User>(() => store.getters.getUser);
|
||||
|
||||
function updateUser() {
|
||||
isLoading.value = true;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { createStore } from "vuex";
|
||||
import tableStore from "@/store/tables";
|
||||
import orderItemStore from "@/store/orderItems";
|
||||
import { user_User } from "@/services/openapi";
|
||||
import { controller_User } from "@/services/openapi";
|
||||
|
||||
interface AppStateModel {
|
||||
user: user_User;
|
||||
user: controller_User;
|
||||
groups: string[];
|
||||
}
|
||||
export default createStore({
|
||||
|
@ -28,7 +28,7 @@ export default createStore({
|
|||
},
|
||||
},
|
||||
mutations: {
|
||||
setUser(state: AppStateModel, _user: user_User) {
|
||||
setUser(state: AppStateModel, _user: controller_User) {
|
||||
state.user = _user;
|
||||
},
|
||||
setGroups(state: AppStateModel, groups: string[]) {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { OrderItemsService, service_OrderItem, types_ItemType } from "@/services/openapi";
|
||||
import { OrderItemsService, controller_OrderItem, controller_ItemType } from "@/services/openapi";
|
||||
|
||||
interface AppStateModel {
|
||||
orderItems: Map<number, service_OrderItem[]>;
|
||||
orderItems: Map<number, controller_OrderItem[]>;
|
||||
}
|
||||
|
||||
interface mutationOrderItems {
|
||||
orderItems: service_OrderItem[];
|
||||
orderType: types_ItemType;
|
||||
orderItems: controller_OrderItem[];
|
||||
orderType: controller_ItemType;
|
||||
}
|
||||
|
||||
const orderItemStore = {
|
||||
state: () => ({
|
||||
orderItems: new Map<number, service_OrderItem[]>(),
|
||||
orderItems: new Map<number, controller_OrderItem[]>(),
|
||||
}),
|
||||
getters: {
|
||||
getOrderItems(state: AppStateModel) {
|
||||
|
@ -22,52 +22,52 @@ const orderItemStore = {
|
|||
setOrderItems(state: AppStateModel, payload: mutationOrderItems) {
|
||||
state.orderItems.set(payload.orderType, payload.orderItems);
|
||||
},
|
||||
pushOrderItem(state: AppStateModel, orderItem: service_OrderItem) {
|
||||
pushOrderItem(state: AppStateModel, orderItem: controller_OrderItem) {
|
||||
const tempOrderItems = state.orderItems.get(orderItem.item_type);
|
||||
tempOrderItems && tempOrderItems.push(orderItem);
|
||||
},
|
||||
filterOrderItem(state: AppStateModel, orderItem: service_OrderItem) {
|
||||
filterOrderItem(state: AppStateModel, orderItem: controller_OrderItem) {
|
||||
const tempOrderItems = state.orderItems.get(orderItem.item_type);
|
||||
tempOrderItems &&
|
||||
state.orderItems.set(
|
||||
orderItem.item_type,
|
||||
tempOrderItems.filter((origItem: service_OrderItem) => origItem.id !== orderItem.id)
|
||||
tempOrderItems.filter((origItem: controller_OrderItem) => origItem.id !== orderItem.id)
|
||||
);
|
||||
},
|
||||
putOrderItem(state: AppStateModel, orderItem: service_OrderItem) {
|
||||
putOrderItem(state: AppStateModel, orderItem: controller_OrderItem) {
|
||||
const tempOrderItems = state.orderItems.get(orderItem.item_type);
|
||||
tempOrderItems &&
|
||||
state.orderItems.set(
|
||||
orderItem.item_type,
|
||||
tempOrderItems.map((origItem: service_OrderItem) => (origItem.id === orderItem.id ? orderItem : origItem))
|
||||
tempOrderItems.map((origItem: controller_OrderItem) => (origItem.id === orderItem.id ? orderItem : origItem))
|
||||
);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// eslint-disable-next-line
|
||||
async getAllOrderItems(context: any) {
|
||||
await context.dispatch("getOrderItems", types_ItemType.Food);
|
||||
await context.dispatch("getOrderItems", types_ItemType.ColdDrink);
|
||||
await context.dispatch("getOrderItems", types_ItemType.HotDrink);
|
||||
await context.dispatch("getOrderItems", controller_ItemType.Food);
|
||||
await context.dispatch("getOrderItems", controller_ItemType.ColdDrink);
|
||||
await context.dispatch("getOrderItems", controller_ItemType.HotDrink);
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
async getOrderItems(context: any, orderType: types_ItemType) {
|
||||
async getOrderItems(context: any, orderType: controller_ItemType) {
|
||||
const orderTypeArray = context.getters.getOrderItems;
|
||||
if (!orderTypeArray.get(orderType)) {
|
||||
const orderItems: service_OrderItem[] | null = await OrderItemsService.getOrdersItems(orderType);
|
||||
const orderItems: controller_OrderItem[] | null = await OrderItemsService.getOrdersItems(orderType);
|
||||
context.commit("setOrderItems", { orderItems, orderType });
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
addOrderItem(context: any, orderItem: service_OrderItem) {
|
||||
addOrderItem(context: any, orderItem: controller_OrderItem) {
|
||||
context.commit("pushOrderItem", orderItem);
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
deleteOrderItem(context: any, orderItem: service_OrderItem) {
|
||||
deleteOrderItem(context: any, orderItem: controller_OrderItem) {
|
||||
context.commit("filterOrderItem", orderItem);
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
updateOrderItem(context: any, orderItem: service_OrderItem) {
|
||||
updateOrderItem(context: any, orderItem: controller_OrderItem) {
|
||||
context.commit("putOrderItem", orderItem);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { service_Table, TablesService } from "@/services/openapi";
|
||||
import { controller_Table, TablesService } from "@/services/openapi";
|
||||
|
||||
interface AppStateModel {
|
||||
tables: service_Table[] | null;
|
||||
tables: controller_Table[] | null;
|
||||
}
|
||||
|
||||
const tableStore = {
|
||||
|
@ -17,13 +17,13 @@ const tableStore = {
|
|||
},
|
||||
},
|
||||
mutations: {
|
||||
setTables(state: AppStateModel, tables: service_Table[]) {
|
||||
setTables(state: AppStateModel, tables: controller_Table[]) {
|
||||
state.tables = tables;
|
||||
},
|
||||
popTables(state: AppStateModel) {
|
||||
state.tables && state.tables.pop();
|
||||
},
|
||||
pushTable(state: AppStateModel, table: service_Table) {
|
||||
pushTable(state: AppStateModel, table: controller_Table) {
|
||||
state.tables && state.tables.push(table);
|
||||
},
|
||||
},
|
||||
|
@ -38,7 +38,7 @@ const tableStore = {
|
|||
context.commit("popTables");
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
addTable(context: any, table: service_Table) {
|
||||
addTable(context: any, table: controller_Table) {
|
||||
context.commit("pushTable", table);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
import { service_Bill, service_Order, types_ItemType } from "@/services/openapi";
|
||||
import { controller_Bill, controller_Order, controller_ItemType } from "@/services/openapi";
|
||||
|
||||
export function convertToEur(value: number | undefined) {
|
||||
const temp: number = value ? value : 0;
|
||||
return temp.toLocaleString("de-DE", { style: "currency", currency: "EUR" });
|
||||
}
|
||||
|
||||
export function detailedItemTypeString(type: types_ItemType | undefined) {
|
||||
export function detailedItemTypeString(type: controller_ItemType | undefined) {
|
||||
switch (type) {
|
||||
case types_ItemType.Food:
|
||||
case controller_ItemType.Food:
|
||||
return "Speisen";
|
||||
case types_ItemType.ColdDrink:
|
||||
case controller_ItemType.ColdDrink:
|
||||
return "Kaltgetränke";
|
||||
default:
|
||||
return "Heiß/Eiskaffee";
|
||||
}
|
||||
}
|
||||
|
||||
export function generalItemTypeString(type: types_ItemType[]) {
|
||||
if (type.includes(types_ItemType.Food)) {
|
||||
export function generalItemTypeString(type: controller_ItemType[]) {
|
||||
if (type.includes(controller_ItemType.Food)) {
|
||||
return "Speisen";
|
||||
} else {
|
||||
return "Getränke";
|
||||
}
|
||||
}
|
||||
|
||||
export function detailedItemTypeIcon(type: types_ItemType | undefined) {
|
||||
export function detailedItemTypeIcon(type: controller_ItemType | undefined) {
|
||||
switch (type) {
|
||||
case types_ItemType.Food:
|
||||
case controller_ItemType.Food:
|
||||
return "fa-cheese";
|
||||
case types_ItemType.ColdDrink:
|
||||
case controller_ItemType.ColdDrink:
|
||||
return "fa-champagne-glasses";
|
||||
case types_ItemType.HotDrink:
|
||||
case controller_ItemType.HotDrink:
|
||||
return "fa-mug-hot";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export function generalItemTypeIcon(type: types_ItemType[]) {
|
||||
if (type.includes(types_ItemType.Food)) {
|
||||
export function generalItemTypeIcon(type: controller_ItemType[]) {
|
||||
if (type.includes(controller_ItemType.Food)) {
|
||||
return "fa-cheese";
|
||||
} else {
|
||||
return "fa-champagne-glasses";
|
||||
|
@ -47,7 +47,7 @@ export function generalItemTypeIcon(type: types_ItemType[]) {
|
|||
|
||||
export interface WebSocketMsg {
|
||||
type: NotifierType;
|
||||
payload: service_Order[];
|
||||
payload: controller_Order[];
|
||||
}
|
||||
|
||||
export enum NotifierType {
|
||||
|
@ -75,4 +75,4 @@ export function lessThan15SecondsAgo(updated_at: number | undefined) {
|
|||
return moment().diff(updated, "seconds") < 15;
|
||||
}
|
||||
|
||||
export const emptyBill: service_Bill = { table_id: 0, total: 0 };
|
||||
export const emptyBill: controller_Bill = { table_id: 0, total: 0 };
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
import { defineComponent, ref, watch } from "vue";
|
||||
import BaseCard from "@/components/UI/BaseCard.vue";
|
||||
import Calendar from "primevue/calendar";
|
||||
import { BillsService, service_Bill } from "@/services/openapi";
|
||||
import { BillsService, controller_Bill } from "@/services/openapi";
|
||||
import Sidebar from "primevue/sidebar";
|
||||
import BillModal from "@/components/Bills/BillModal.vue";
|
||||
import { convertToEur, emptyBill, errorToast } from "@/utils";
|
||||
|
@ -80,11 +80,11 @@ export default defineComponent({
|
|||
const confirm = useConfirm();
|
||||
const toast = useToast();
|
||||
const today = ref(new Date());
|
||||
const bills = ref<service_Bill[]>([]);
|
||||
const bills = ref<controller_Bill[]>([]);
|
||||
const isLoading = ref(false);
|
||||
const isDisabled = ref(false);
|
||||
const billModal = ref(false);
|
||||
const bill = ref<service_Bill>({ ...emptyBill });
|
||||
const bill = ref<controller_Bill>({ ...emptyBill });
|
||||
const filters = ref({
|
||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||
});
|
||||
|
@ -104,7 +104,7 @@ export default defineComponent({
|
|||
|
||||
function openBill(billId: number) {
|
||||
if (isDisabled.value) return;
|
||||
const temp: service_Bill | undefined = bills.value.find((bill) => bill.id === billId);
|
||||
const temp: controller_Bill | undefined = bills.value.find((bill) => bill.id === billId);
|
||||
temp && (bill.value = temp);
|
||||
billModal.value = true;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, ref, watch } from "vue";
|
||||
import { BillsService, OrdersService, service_Bill, service_Order } from "@/services/openapi";
|
||||
import { BillsService, OrdersService, controller_Bill, controller_Order } from "@/services/openapi";
|
||||
import Checkbox from "primevue/checkbox";
|
||||
import { convertToEur, emptyBill, errorToast } from "@/utils";
|
||||
import Button from "primevue/button";
|
||||
|
@ -80,13 +80,13 @@ export default defineComponent({
|
|||
const toast = useToast();
|
||||
const router = useRouter();
|
||||
const table = computed(() => parseInt(props.id));
|
||||
const orders = ref<service_Order[]>([]);
|
||||
const orders = ref<controller_Order[]>([]);
|
||||
const orderFilter = ref<number[]>([]);
|
||||
const isLoading = ref(false);
|
||||
const applyFilterLoading = ref(false);
|
||||
const checkAll = ref(false);
|
||||
const total = ref(0);
|
||||
const bill = ref<service_Bill>({ ...emptyBill });
|
||||
const bill = ref<controller_Bill>({ ...emptyBill });
|
||||
const billModal = ref(false);
|
||||
|
||||
function checkAllCheck() {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<script lang="ts">
|
||||
import { computed, defineComponent, reactive, ref, watch } from "vue";
|
||||
import BaseCard from "@/components/UI/BaseCard.vue";
|
||||
import { service_OrderItem, types_ItemType } from "@/services/openapi";
|
||||
import { controller_OrderItem, controller_ItemType } from "@/services/openapi";
|
||||
import OrderItemList from "@/components/OrderItem/OrderItemList.vue";
|
||||
import { useStore } from "vuex";
|
||||
import WaveSpinner from "@/components/UI/WaveSpinner.vue";
|
||||
|
@ -31,8 +31,8 @@ export default defineComponent({
|
|||
const isLoading = ref(true);
|
||||
const orderItems = computed(() => store.getters.getOrderItems);
|
||||
const currentOrderItems = ref();
|
||||
const emptyOrderItem = reactive<service_OrderItem>({ description: "", item_type: 0, price: 0 });
|
||||
const intId = ref<types_ItemType>(parseInt(props.id));
|
||||
const emptyOrderItem = reactive<controller_OrderItem>({ description: "", item_type: 0, price: 0 });
|
||||
const intId = ref<controller_ItemType>(parseInt(props.id));
|
||||
|
||||
getData();
|
||||
async function getData() {
|
||||
|
@ -50,15 +50,15 @@ export default defineComponent({
|
|||
|
||||
watch(props, () => getData());
|
||||
|
||||
function orderItemChanged(item: service_OrderItem) {
|
||||
function orderItemChanged(item: controller_OrderItem) {
|
||||
store.dispatch("updateOrderItem", item);
|
||||
refreshMap();
|
||||
}
|
||||
function orderItemDeleted(item: service_OrderItem) {
|
||||
function orderItemDeleted(item: controller_OrderItem) {
|
||||
store.dispatch("deleteOrderItem", item);
|
||||
refreshMap();
|
||||
}
|
||||
function orderItemCreated(item: service_OrderItem) {
|
||||
function orderItemCreated(item: controller_OrderItem) {
|
||||
store.dispatch("addOrderItem", item);
|
||||
refreshMap();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
/>
|
||||
</template>
|
||||
<template v-if="user.show_cold_drinks">
|
||||
<OrderSection :orders="coldOrders" :itemType="types_ItemType.ColdDrink" @filterOrders="(id) => filterOrder(id)" />
|
||||
<OrderSection :orders="coldOrders" :itemType="controller_ItemType.ColdDrink" @filterOrders="(id) => filterOrder(id)" />
|
||||
</template>
|
||||
</div>
|
||||
</Transition>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<script lang="ts">
|
||||
import { computed, defineComponent, onUnmounted, provide, ref } from "vue";
|
||||
import BaseCard from "@/components/UI/BaseCard.vue";
|
||||
import { OrdersService, service_Order, types_ItemType, user_User } from "@/services/openapi";
|
||||
import { OrdersService, controller_Order, controller_ItemType, controller_User } from "@/services/openapi";
|
||||
import { detailedItemTypeIcon, detailedItemTypeString, NotifierType, WebSocketMsg } from "@/utils";
|
||||
import { API_ENDPOINT_URL } from "@/main";
|
||||
import EmptyView from "@/views/Empty.vue";
|
||||
|
@ -43,8 +43,8 @@ export default defineComponent({
|
|||
const isDisabled = ref(false);
|
||||
provide(disabled, isDisabled);
|
||||
provide(loading, isDisabled);
|
||||
const orders = ref<service_Order[]>([]);
|
||||
const user = computed<user_User>(() => store.getters.getUser);
|
||||
const orders = ref<controller_Order[]>([]);
|
||||
const user = computed<controller_User>(() => store.getters.getUser);
|
||||
|
||||
const empty = computed(() => {
|
||||
return (
|
||||
|
@ -55,9 +55,9 @@ export default defineComponent({
|
|||
});
|
||||
|
||||
const otherOrders = computed(() => {
|
||||
const temp = new Map<number, service_Order[]>();
|
||||
const temp = new Map<number, controller_Order[]>();
|
||||
orders.value.forEach((order) => {
|
||||
if (order.order_item.item_type === types_ItemType.ColdDrink) return;
|
||||
if (order.order_item.item_type === controller_ItemType.ColdDrink) return;
|
||||
const existing = temp.get(order.table_id);
|
||||
if (existing) {
|
||||
existing.push(order);
|
||||
|
@ -67,7 +67,7 @@ export default defineComponent({
|
|||
});
|
||||
return new Map([...temp.entries()].sort());
|
||||
});
|
||||
const coldOrders = computed(() => orders.value.filter((order) => order.order_item.item_type === types_ItemType.ColdDrink));
|
||||
const coldOrders = computed(() => orders.value.filter((order) => order.order_item.item_type === controller_ItemType.ColdDrink));
|
||||
const sse = ref<EventSource | null>(null);
|
||||
|
||||
getData();
|
||||
|
@ -118,7 +118,7 @@ export default defineComponent({
|
|||
otherOrders,
|
||||
coldOrders,
|
||||
filterOrder,
|
||||
types_ItemType,
|
||||
controller_ItemType,
|
||||
isLoading,
|
||||
isDisabled,
|
||||
detailedItemTypeString,
|
||||
|
|
|
@ -4,8 +4,6 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -17,13 +15,13 @@ type (
|
|||
}
|
||||
|
||||
BillItem struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id" validate:"optional"`
|
||||
BillID uint64 `json:"bill_id" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Total float32 `json:"total" validate:"required"`
|
||||
Price float32 `json:"price" validate:"required"`
|
||||
Amount uint64 `json:"amount" validate:"required"`
|
||||
ItemType types.ItemType `json:"item_type" validate:"required"`
|
||||
ID uint64 `gorm:"primaryKey" json:"id" validate:"optional"`
|
||||
BillID uint64 `json:"bill_id" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Total float32 `json:"total" validate:"required"`
|
||||
Price float32 `json:"price" validate:"required"`
|
||||
Amount uint64 `json:"amount" validate:"required"`
|
||||
ItemType ItemType `json:"item_type" validate:"required"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -31,7 +29,7 @@ func (c *Controller) DoesBillExist(id string) (Bill, error) {
|
|||
var bill Bill
|
||||
result := c.orm.Limit(1).Find(&bill, id)
|
||||
if result.RowsAffected == 0 {
|
||||
return bill, fmt.Errorf(types.CannotFind.String())
|
||||
return bill, fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
return bill, nil
|
||||
}
|
||||
|
@ -40,7 +38,7 @@ func (c *Controller) GetAllBillItems(billId uint64) ([]BillItem, error) {
|
|||
var billItems []BillItem
|
||||
result := c.orm.Where("bill_id = ?", billId).Find(&billItems)
|
||||
if result.RowsAffected == 0 {
|
||||
return billItems, fmt.Errorf(types.CannotFind.String())
|
||||
return billItems, fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
return billItems, nil
|
||||
}
|
||||
|
@ -48,19 +46,19 @@ func (c *Controller) GetAllBillItems(billId uint64) ([]BillItem, error) {
|
|||
func getDate(year string, month string, day string) (time.Time, error) {
|
||||
yearI, yearErr := strconv.Atoi(year)
|
||||
if yearErr != nil {
|
||||
return time.Time{}, fmt.Errorf("jahr " + types.CannotParse.String())
|
||||
return time.Time{}, fmt.Errorf("jahr " + CannotParse.String())
|
||||
}
|
||||
monthI, monthErr := strconv.Atoi(month)
|
||||
if monthErr != nil {
|
||||
return time.Time{}, fmt.Errorf("monat " + types.CannotParse.String())
|
||||
return time.Time{}, fmt.Errorf("monat " + CannotParse.String())
|
||||
}
|
||||
dayI, dayErr := strconv.Atoi(day)
|
||||
if dayErr != nil {
|
||||
return time.Time{}, fmt.Errorf("tag " + types.CannotParse.String())
|
||||
return time.Time{}, fmt.Errorf("tag " + CannotParse.String())
|
||||
}
|
||||
loc, locErr := time.LoadLocation("Local")
|
||||
if locErr != nil {
|
||||
return time.Time{}, fmt.Errorf("timezone " + types.CannotParse.String())
|
||||
return time.Time{}, fmt.Errorf("timezone " + CannotParse.String())
|
||||
}
|
||||
return time.Date(yearI, time.Month(monthI), dayI, 0, 0, 0, 0, loc), nil
|
||||
}
|
||||
|
@ -88,7 +86,7 @@ func (c *Controller) createBill(options GetOrderOptions) (Bill, error) {
|
|||
bill.Total = total
|
||||
err := c.orm.Create(&bill).Error
|
||||
if err != nil {
|
||||
return bill, fmt.Errorf(types.CannotCreate.String())
|
||||
return bill, fmt.Errorf(CannotCreate.String())
|
||||
}
|
||||
for _, order := range orders {
|
||||
billItem := BillItem{
|
||||
|
@ -104,10 +102,10 @@ func (c *Controller) createBill(options GetOrderOptions) (Bill, error) {
|
|||
ordersToDelete := c.getAllOrdersForTable(GetOrderOptions{TableId: options.TableId, Grouped: false, Filter: options.Filter})
|
||||
err = c.orm.Delete(&ordersToDelete).Error
|
||||
if err != nil {
|
||||
return bill, fmt.Errorf(types.CannotDelete.String())
|
||||
return bill, fmt.Errorf(CannotDelete.String())
|
||||
}
|
||||
c.publishMessage(StatusMessage{
|
||||
Type: types.DeleteAll,
|
||||
Type: DeleteAll,
|
||||
Payload: ordersToDelete,
|
||||
})
|
||||
return bill, nil
|
||||
|
@ -116,7 +114,7 @@ func (c *Controller) createBill(options GetOrderOptions) (Bill, error) {
|
|||
func (c *Controller) deleteBill(bill *Bill) error {
|
||||
err := c.orm.Delete(bill).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotDelete.String())
|
||||
return fmt.Errorf(CannotDelete.String())
|
||||
}
|
||||
billItemsToDelete, _ := c.GetAllBillItems(bill.ID)
|
||||
c.orm.Delete(&billItemsToDelete)
|
||||
|
|
|
@ -4,14 +4,21 @@ import (
|
|||
"encoding/json"
|
||||
|
||||
"github.com/r3labs/sse/v2"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
const ServerSideEvent = "sse"
|
||||
|
||||
type NotifierType uint
|
||||
|
||||
const (
|
||||
Create NotifierType = iota
|
||||
Delete
|
||||
DeleteAll
|
||||
)
|
||||
|
||||
type StatusMessage struct {
|
||||
Type types.NotifierType `json:"type"`
|
||||
Payload []Order `json:"payload"`
|
||||
Type NotifierType `json:"type"`
|
||||
Payload []Order `json:"payload"`
|
||||
}
|
||||
|
||||
func (c *Controller) setupEventChannel() {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -21,10 +20,10 @@ type (
|
|||
}
|
||||
|
||||
OrderItem struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id" validate:"optional"`
|
||||
ItemType types.ItemType `json:"item_type" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Price float32 `json:"price" validate:"required"`
|
||||
ID uint64 `gorm:"primaryKey" json:"id" validate:"optional"`
|
||||
ItemType ItemType `json:"item_type" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
Price float32 `json:"price" validate:"required"`
|
||||
}
|
||||
|
||||
GetOrderOptions struct {
|
||||
|
@ -55,7 +54,7 @@ func (c *Controller) doesOrderItemExist(id string) (OrderItem, error) {
|
|||
var orderItem OrderItem
|
||||
result := c.orm.Limit(1).Find(&orderItem, id)
|
||||
if result.RowsAffected == 0 {
|
||||
return orderItem, fmt.Errorf(types.CannotFind.String())
|
||||
return orderItem, fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
return orderItem, nil
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ func (c *Controller) doesOrderExist(id string) (Order, error) {
|
|||
var order Order
|
||||
result := c.orm.Limit(1).Find(&order, id)
|
||||
if result.RowsAffected == 0 {
|
||||
return order, fmt.Errorf(types.CannotFind.String())
|
||||
return order, fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
return order, nil
|
||||
}
|
||||
|
@ -96,11 +95,11 @@ func (c *Controller) getAllOrdersForTable(options GetOrderOptions) []Order {
|
|||
func (c *Controller) createOrder(order *Order) error {
|
||||
err := c.orm.Create(order).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotCreate.String())
|
||||
return fmt.Errorf(CannotCreate.String())
|
||||
}
|
||||
c.orm.Model(&Order{}).Joins("OrderItem").First(order)
|
||||
c.publishMessage(StatusMessage{
|
||||
Type: types.Create,
|
||||
Type: Create,
|
||||
Payload: []Order{*order},
|
||||
})
|
||||
return nil
|
||||
|
@ -109,11 +108,11 @@ func (c *Controller) createOrder(order *Order) error {
|
|||
func (c *Controller) updateOrder(old *Order, new *Order) error {
|
||||
err := c.orm.First(old).Updates(new).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotUpdate.String())
|
||||
return fmt.Errorf(CannotUpdate.String())
|
||||
}
|
||||
if new.IsServed {
|
||||
c.publishMessage(StatusMessage{
|
||||
Type: types.Delete,
|
||||
Type: Delete,
|
||||
Payload: []Order{*new},
|
||||
})
|
||||
}
|
||||
|
@ -124,14 +123,14 @@ func (c *Controller) deleteOrder(tableId string, orderItemId string) error {
|
|||
var order Order
|
||||
err := c.orm.Where("table_id = ? AND order_item_id = ?", tableId, orderItemId).Last(&order).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotFind.String())
|
||||
return fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
err = c.orm.Delete(&order).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotDelete.String())
|
||||
return fmt.Errorf(CannotDelete.String())
|
||||
}
|
||||
c.publishMessage(StatusMessage{
|
||||
Type: types.Delete,
|
||||
Type: Delete,
|
||||
Payload: []Order{order},
|
||||
})
|
||||
return nil
|
||||
|
@ -139,14 +138,14 @@ func (c *Controller) deleteOrder(tableId string, orderItemId string) error {
|
|||
|
||||
func (c *Controller) getOrderItemsForType(itemType string) []OrderItem {
|
||||
var orderItems []OrderItem
|
||||
c.orm.Order("description").Where("item_type = ?", types.ParseItemType(itemType)).Find(&orderItems)
|
||||
c.orm.Order("description").Where("item_type = ?", ParseItemType(itemType)).Find(&orderItems)
|
||||
return orderItems
|
||||
}
|
||||
|
||||
func (c *Controller) createOrderItem(oderItem *OrderItem) error {
|
||||
err := c.orm.Create(oderItem).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotCreate.String())
|
||||
return fmt.Errorf(CannotCreate.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -154,7 +153,7 @@ func (c *Controller) createOrderItem(oderItem *OrderItem) error {
|
|||
func (c *Controller) updateOrderItem(old *OrderItem, new *OrderItem) error {
|
||||
err := c.orm.First(old).Updates(new).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotUpdate.String())
|
||||
return fmt.Errorf(CannotUpdate.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -162,7 +161,7 @@ func (c *Controller) updateOrderItem(old *OrderItem, new *OrderItem) error {
|
|||
func (c *Controller) deleteOrderItem(oderItem *OrderItem) error {
|
||||
err := c.orm.Delete(oderItem).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotDelete.String())
|
||||
return fmt.Errorf(CannotDelete.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -6,25 +6,24 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all bills
|
||||
// @Description gets all bills as array
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param year query int true "year"
|
||||
// @Param month query int true "month (1-12)"
|
||||
// @Param day query int true "day (1-31)"
|
||||
// @Success 200 {array} Bill
|
||||
// @Router /bills [get]
|
||||
// @Schemes
|
||||
// @Summary get all bills
|
||||
// @Description gets all bills as array
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param year query int true "year"
|
||||
// @Param month query int true "month (1-12)"
|
||||
// @Param day query int true "day (1-31)"
|
||||
// @Success 200 {array} Bill
|
||||
// @Router /bills [get]
|
||||
func (c *Controller) GetBills(ctx echo.Context) error {
|
||||
year := ctx.QueryParam("year")
|
||||
month := ctx.QueryParam("month")
|
||||
day := ctx.QueryParam("day")
|
||||
if year == "" || month == "" || day == "" {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, MissingInformation.String())
|
||||
}
|
||||
bills, err := c.GetAllBills(year, month, day)
|
||||
if err != nil {
|
||||
|
@ -33,14 +32,14 @@ func (c *Controller) GetBills(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, bills)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all billItems
|
||||
// @Description gets all billItems for bill
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param bill query int true "Bill ID"
|
||||
// @Success 200 {array} BillItem
|
||||
// @Router /bills/items [get]
|
||||
// @Schemes
|
||||
// @Summary get all billItems
|
||||
// @Description gets all billItems for bill
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param bill query int true "Bill ID"
|
||||
// @Success 200 {array} BillItem
|
||||
// @Router /bills/items [get]
|
||||
func (c *Controller) GetBillItems(ctx echo.Context) error {
|
||||
bill, err := c.DoesBillExist(ctx.QueryParam("bill"))
|
||||
if err != nil {
|
||||
|
@ -53,21 +52,21 @@ func (c *Controller) GetBillItems(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, billItems)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new bill
|
||||
// @Description creates a new bill and returns it
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param table query int true "Table ID"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 201 {object} Bill
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /bills [post]
|
||||
// @Schemes
|
||||
// @Summary create new bill
|
||||
// @Description creates a new bill and returns it
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param table query int true "Table ID"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 201 {object} Bill
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /bills [post]
|
||||
func (c *Controller) CreateBill(ctx echo.Context) error {
|
||||
table, tableErr := strconv.ParseUint(ctx.QueryParam("table"), 10, 64)
|
||||
if tableErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
stringFiler := ctx.QueryParam("filter")
|
||||
var filter []string
|
||||
|
@ -81,16 +80,16 @@ func (c *Controller) CreateBill(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusCreated, bill)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete a bill
|
||||
// @Description deletes a bill
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param id path int true "Bill ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /bills/{id} [delete]
|
||||
// @Schemes
|
||||
// @Summary delete a bill
|
||||
// @Description deletes a bill
|
||||
// @Tags bills
|
||||
// @Produce json
|
||||
// @Param id path int true "Bill ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /bills/{id} [delete]
|
||||
func (c *Controller) DeleteBill(ctx echo.Context) error {
|
||||
id := ctx.Param("id")
|
||||
bill, err := c.DoesBillExist(id)
|
||||
|
|
|
@ -6,19 +6,18 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all orders
|
||||
// @Description gets all orders as array
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param table query int false "Table ID"
|
||||
// @Param grouping query bool false "grouping"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 200 {array} Order
|
||||
// @Router /orders [get]
|
||||
// @Schemes
|
||||
// @Summary get all orders
|
||||
// @Description gets all orders as array
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param table query int false "Table ID"
|
||||
// @Param grouping query bool false "grouping"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 200 {array} Order
|
||||
// @Router /orders [get]
|
||||
func (c *Controller) GetOrders(ctx echo.Context) error {
|
||||
table, _ := strconv.ParseUint(ctx.QueryParam("table"), 10, 64)
|
||||
grouping, _ := strconv.ParseBool(ctx.QueryParam("grouping"))
|
||||
|
@ -37,23 +36,23 @@ func (c *Controller) GetOrders(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, orders)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new order
|
||||
// @Description creates a new order and returns it
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 201 {object} Order
|
||||
// @Failure 400
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [post]
|
||||
// @Schemes
|
||||
// @Summary create new order
|
||||
// @Description creates a new order and returns it
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 201 {object} Order
|
||||
// @Failure 400
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [post]
|
||||
func (c *Controller) CreateOrder(ctx echo.Context) error {
|
||||
table, err1 := strconv.ParseUint(ctx.QueryParam("table"), 10, 64)
|
||||
item, err2 := strconv.ParseUint(ctx.QueryParam("item"), 10, 64)
|
||||
if err1 != nil || err2 != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
order := Order{TableID: table, OrderItemID: item, IsServed: false}
|
||||
err := c.createOrder(&order)
|
||||
|
@ -63,22 +62,22 @@ func (c *Controller) CreateOrder(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusCreated, order)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete an order
|
||||
// @Description deletes an order from the database
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [delete]
|
||||
// @Schemes
|
||||
// @Summary delete an order
|
||||
// @Description deletes an order from the database
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [delete]
|
||||
func (c *Controller) DeleteOrder(ctx echo.Context) error {
|
||||
item := ctx.QueryParam("item")
|
||||
table := ctx.QueryParam("table")
|
||||
if table == "" || item == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
err := c.deleteOrder(table, item)
|
||||
if err != nil {
|
||||
|
@ -87,18 +86,18 @@ func (c *Controller) DeleteOrder(ctx echo.Context) error {
|
|||
return ctx.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary update an order
|
||||
// @Description updates an order with provided information
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body Order true "updated Order"
|
||||
// @Success 200 {object} Order
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [put]
|
||||
// @Schemes
|
||||
// @Summary update an order
|
||||
// @Description updates an order with provided information
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body Order true "updated Order"
|
||||
// @Success 200 {object} Order
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [put]
|
||||
func (c *Controller) UpdateOrder(ctx echo.Context) error {
|
||||
var newOrder Order
|
||||
err := ctx.Bind(&newOrder)
|
||||
|
@ -116,33 +115,33 @@ func (c *Controller) UpdateOrder(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, newOrder)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all orderItems
|
||||
// @Description gets all orderItems as array
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param type query int true "ItemType"
|
||||
// @Success 200 {array} OrderItem
|
||||
// @Router /orders/items [get]
|
||||
// @Schemes
|
||||
// @Summary get all orderItems
|
||||
// @Description gets all orderItems as array
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param type query int true "ItemType"
|
||||
// @Success 200 {array} OrderItem
|
||||
// @Router /orders/items [get]
|
||||
func (c *Controller) GetOrderItems(ctx echo.Context) error {
|
||||
orderType := ctx.QueryParam("type")
|
||||
if orderType == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
return ctx.JSON(http.StatusOK, c.getOrderItemsForType(orderType))
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new orderItem
|
||||
// @Description creates a new orderItem and returns it
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body OrderItem true "OrderItem ID"
|
||||
// @Success 201 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [post]
|
||||
// @Schemes
|
||||
// @Summary create new orderItem
|
||||
// @Description creates a new orderItem and returns it
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body OrderItem true "OrderItem ID"
|
||||
// @Success 201 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [post]
|
||||
func (c *Controller) CreateOrderItem(ctx echo.Context) error {
|
||||
var orderItem OrderItem
|
||||
err := ctx.Bind(&orderItem)
|
||||
|
@ -156,18 +155,18 @@ func (c *Controller) CreateOrderItem(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusCreated, orderItem)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary update a orderItem
|
||||
// @Description updates a orderItem with provided information
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderItem body OrderItem true "updated OrderItem"
|
||||
// @Success 200 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [put]
|
||||
// @Schemes
|
||||
// @Summary update a orderItem
|
||||
// @Description updates a orderItem with provided information
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderItem body OrderItem true "updated OrderItem"
|
||||
// @Success 200 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [put]
|
||||
func (c *Controller) UpdateOrderItem(ctx echo.Context) error {
|
||||
var newOrderItem OrderItem
|
||||
err := ctx.Bind(&newOrderItem)
|
||||
|
@ -185,16 +184,16 @@ func (c *Controller) UpdateOrderItem(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, newOrderItem)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete an orderItem
|
||||
// @Description deletes an orderItem from the database
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param id path int true "OrderItem ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items/{id} [delete]
|
||||
// @Schemes
|
||||
// @Summary delete an orderItem
|
||||
// @Description deletes an orderItem from the database
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param id path int true "OrderItem ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items/{id} [delete]
|
||||
func (c *Controller) DeleteOrderItem(ctx echo.Context) error {
|
||||
id := ctx.Param("id")
|
||||
orderItem, err := c.doesOrderItemExist(id)
|
||||
|
|
|
@ -3,7 +3,6 @@ package controller
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
)
|
||||
|
||||
|
@ -42,7 +41,7 @@ func (c *Controller) CreateNewTable() (Table, error) {
|
|||
err = c.orm.Unscoped().Save(&table).Error
|
||||
}
|
||||
if err != nil {
|
||||
return table, fmt.Errorf(types.CannotCreate.String())
|
||||
return table, fmt.Errorf(CannotCreate.String())
|
||||
}
|
||||
return table, nil
|
||||
}
|
||||
|
@ -61,14 +60,14 @@ func (c *Controller) DeleteLatestTable() error {
|
|||
"tables.id",
|
||||
).Last(&table).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotFind.String())
|
||||
return fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
if table.OrderCount != 0 {
|
||||
return fmt.Errorf(types.StillInUse.String())
|
||||
return fmt.Errorf(StillInUse.String())
|
||||
}
|
||||
err = c.orm.Delete(&table).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotDelete.String())
|
||||
return fmt.Errorf(CannotDelete.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
package types
|
||||
package controller
|
||||
|
||||
type (
|
||||
ErrorResponses uint
|
||||
ItemType uint
|
||||
NotifierType uint
|
||||
)
|
||||
|
||||
const (
|
||||
Create NotifierType = iota
|
||||
Delete
|
||||
DeleteAll
|
||||
)
|
||||
|
||||
const (
|
||||
Food ItemType = iota
|
||||
ColdDrink
|
||||
HotDrink
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -28,17 +15,6 @@ const (
|
|||
CannotParse
|
||||
)
|
||||
|
||||
func ParseItemType(itemType string) ItemType {
|
||||
switch itemType {
|
||||
case "0":
|
||||
return Food
|
||||
case "1":
|
||||
return ColdDrink
|
||||
default:
|
||||
return HotDrink
|
||||
}
|
||||
}
|
||||
|
||||
func (e ErrorResponses) String() string {
|
||||
switch e {
|
||||
case MissingInformation:
|
||||
|
@ -57,3 +33,20 @@ func (e ErrorResponses) String() string {
|
|||
return "kann nicht verarbeitet werden"
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
Food ItemType = iota
|
||||
ColdDrink
|
||||
HotDrink
|
||||
)
|
||||
|
||||
func ParseItemType(itemType string) ItemType {
|
||||
switch itemType {
|
||||
case "0":
|
||||
return Food
|
||||
case "1":
|
||||
return ColdDrink
|
||||
default:
|
||||
return HotDrink
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@ package controller
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
|
@ -16,7 +14,7 @@ func (c *Controller) doesUserExist(username string) (User, error) {
|
|||
var user User
|
||||
result := c.orm.Limit(1).Find(&user, "username = ?", username)
|
||||
if result.RowsAffected == 0 {
|
||||
return user, fmt.Errorf(types.CannotFind.String())
|
||||
return user, fmt.Errorf(CannotFind.String())
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
@ -25,7 +23,7 @@ func (c *Controller) getUserOrCreate(username string) (User, error) {
|
|||
var user User
|
||||
err := c.orm.Where(User{Username: username}).Attrs(User{ShowHotDrinks: true, ShowColdDrinks: true}).FirstOrCreate(&user).Error
|
||||
if err != nil {
|
||||
return user, fmt.Errorf(types.CannotCreate.String())
|
||||
return user, fmt.Errorf(CannotCreate.String())
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
@ -36,7 +34,7 @@ func (c *Controller) updateUser(old *User, new *User) error {
|
|||
"ShowColdDrinks": new.ShowColdDrinks,
|
||||
"ShowHotDrinks": new.ShowHotDrinks}).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf(types.CannotUpdate.String())
|
||||
return fmt.Errorf(CannotUpdate.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ case $action in
|
|||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
;;
|
||||
"init")
|
||||
swag init --dir internal/controller -g ../router/router.go -pd
|
||||
swag init --dir internal/controller -g ../router/router.go
|
||||
;;
|
||||
"format")
|
||||
swag fmt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue