setttle
This commit is contained in:
@@ -2,6 +2,7 @@ package com.sasiedzi.event.service;
|
|||||||
|
|
||||||
import com.sasiedzi.event.domain.Event;
|
import com.sasiedzi.event.domain.Event;
|
||||||
import com.sasiedzi.event.repository.EventRepository;
|
import com.sasiedzi.event.repository.EventRepository;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -111,4 +112,8 @@ public class EventService {
|
|||||||
LOG.debug("Request to delete Event : {}", id);
|
LOG.debug("Request to delete Event : {}", id);
|
||||||
eventRepository.deleteById(id);
|
eventRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Event> settle(@Valid Event event) {
|
||||||
|
return eventRepository.findById(event.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ public class EventResource {
|
|||||||
.body(event);
|
.body(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/settle")
|
||||||
|
public ResponseEntity<Optional<Event>> settleEvent(@RequestBody Optional<Event> event) throws URISyntaxException {
|
||||||
|
event = eventService.settle(event.orElse(null));
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, event.get().getId().toString()))
|
||||||
|
.body(event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code PUT /events/:id} : Updates an existing event.
|
* {@code PUT /events/:id} : Updates an existing event.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { IRegistration } from '@/shared/model/registration.model';
|
|||||||
import RegistrationService from '@/entities/registration/registration.service';
|
import RegistrationService from '@/entities/registration/registration.service';
|
||||||
import UserService from '@/entities/user/user.service';
|
import UserService from '@/entities/user/user.service';
|
||||||
import type AccountService from '@/account/account.service';
|
import type AccountService from '@/account/account.service';
|
||||||
|
// import type EventService from '@/account/account.service';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
@@ -105,6 +106,7 @@ export default defineComponent({
|
|||||||
alertService,
|
alertService,
|
||||||
hasAnyAuthorityValues,
|
hasAnyAuthorityValues,
|
||||||
accountService,
|
accountService,
|
||||||
|
eventService,
|
||||||
event,
|
event,
|
||||||
...dataUtils,
|
...dataUtils,
|
||||||
formatDateShort,
|
formatDateShort,
|
||||||
@@ -127,5 +129,21 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
return this.hasAnyAuthorityValues[authorities] ?? false;
|
return this.hasAnyAuthorityValues[authorities] ?? false;
|
||||||
},
|
},
|
||||||
|
settle(): void {
|
||||||
|
this.isSaving = true;
|
||||||
|
if (this.event.id) {
|
||||||
|
this.eventService()
|
||||||
|
.settle(this.event)
|
||||||
|
.then(param => {
|
||||||
|
this.isSaving = false;
|
||||||
|
// this.previousState();
|
||||||
|
this.alertService.showInfo(`The event has been settled up`);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.isSaving = false;
|
||||||
|
this.alertService.showHttpError(error.response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,6 +40,9 @@
|
|||||||
<font-awesome-icon icon="plus"></font-awesome-icon> <span>Dołącz do wydarzenia</span>
|
<font-awesome-icon icon="plus"></font-awesome-icon> <span>Dołącz do wydarzenia</span>
|
||||||
</button>
|
</button>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<button class="btn btn-primary float-right" v-if="hasAnyAuthority('ROLE_ADMIN')" @click="settle()">
|
||||||
|
<font-awesome-icon icon="sync"></font-awesome-icon> <span>Rozlicz wydarzenie</span>
|
||||||
|
</button>
|
||||||
<div class="table-responsive" v-if="event.registrations && event.registrations.length > 0">
|
<div class="table-responsive" v-if="event.registrations && event.registrations.length > 0">
|
||||||
<table class="table table-striped" aria-describedby="event.registrations">
|
<table class="table table-striped" aria-describedby="event.registrations">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -57,6 +57,19 @@ export default class EventService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public settle(entity: IEvent): Promise<IEvent> {
|
||||||
|
return new Promise<IEvent>((resolve, reject) => {
|
||||||
|
axios
|
||||||
|
.post(`${baseApiUrl}/${entity.id}/settle`, entity)
|
||||||
|
.then(res => {
|
||||||
|
resolve(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public update(entity: IEvent): Promise<IEvent> {
|
public update(entity: IEvent): Promise<IEvent> {
|
||||||
return new Promise<IEvent>((resolve, reject) => {
|
return new Promise<IEvent>((resolve, reject) => {
|
||||||
axios
|
axios
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const createRouter = () =>
|
|||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: '/event/1551/view',
|
redirect: '/event/1/view',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/forbidden',
|
path: '/forbidden',
|
||||||
|
|||||||
Reference in New Issue
Block a user