Agenturdaten fertig
This commit is contained in:
parent
e78a8abd1e
commit
b2e61c67fb
|
|
@ -31,6 +31,7 @@ class AgencyController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*/
|
*/
|
||||||
|
|
@ -47,19 +48,20 @@ class AgencyController extends Controller {
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $content
|
* @param string $content
|
||||||
*/
|
*/
|
||||||
public function create(string $name) {
|
public function create(string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
|
||||||
return $this->service->create($name);
|
return $this->service->create($name, $inhaber, $street, $plz, $city, $agencymail, $phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param string $title
|
* @param string $title
|
||||||
*/
|
*/
|
||||||
public function update(int $id, string $name) {
|
public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
|
||||||
return $this->handleNotFound(function () use ($id, $name) {
|
return $this->handleNotFound(function () use ($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone) {
|
||||||
return $this->service->update($id, $name);
|
return $this->service->update($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@ use OCP\AppFramework\Db\Entity;
|
||||||
class Agency extends Entity implements JsonSerializable {
|
class Agency extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
protected $inhaber;
|
||||||
|
protected $street;
|
||||||
|
protected $plz;
|
||||||
|
protected $city;
|
||||||
|
protected $agencymail;
|
||||||
|
protected $phone;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('id','integer');
|
$this->addType('id','integer');
|
||||||
|
|
@ -16,7 +22,13 @@ class Agency extends Entity implements JsonSerializable {
|
||||||
public function jsonSerialize() {
|
public function jsonSerialize() {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->title,
|
'name' => $this->name,
|
||||||
|
'inhaber' => $this->inhaber,
|
||||||
|
'street' => $this->street,
|
||||||
|
'plz' => $this->plz,
|
||||||
|
'city' => $this->city,
|
||||||
|
'agencymail' => $this->agencymail,
|
||||||
|
'phone' => $this->phone,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ use OCP\AppFramework\Db\QBMapper;
|
||||||
class AgencyMapper extends QBMapper {
|
class AgencyMapper extends QBMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
parent::__construct($db, 'agencys', Note::class);
|
parent::__construct($db, 'agencys', Agency::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find(int $id) {
|
public function find(int $id) {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
if (!$schema->hasTable('agencys')) {
|
if (!$schema->hasTable('agencys')) {
|
||||||
$table = $schema->createTable('agencys');
|
$table = $schema->createTable('agencys');
|
||||||
|
|
||||||
$table->addColumn('id', 'integer', [
|
$table->addColumn('id', 'integer', [
|
||||||
'autoincrement' => true,
|
'autoincrement' => true,
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
|
|
@ -50,7 +51,7 @@
|
||||||
'length' => 5
|
'length' => 5
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$table->addColumn('agency_email', 'string', [
|
$table->addColumn('agencymail', 'string', [
|
||||||
'notnull' => false,
|
'notnull' => false,
|
||||||
'length' => 200
|
'length' => 200
|
||||||
]);
|
]);
|
||||||
|
|
@ -71,12 +72,12 @@
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$table->rColumn('agency', 'integer', [
|
$table->addColumn('agency', 'integer', [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 64
|
'length' => 64
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$table->rColumn('user', 'integer', [
|
$table->addColumn('user', 'integer', [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 64
|
'length' => 64
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class AgencyService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Find an Agency
|
||||||
public function find(int $id) {
|
public function find(int $id) {
|
||||||
try {
|
try {
|
||||||
return $this->mapper->find($id);
|
return $this->mapper->find($id);
|
||||||
|
|
@ -35,10 +36,33 @@ class AgencyService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(string $name) {
|
//Create an Agency
|
||||||
|
public function create(string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
|
||||||
$agency = new Agency();
|
$agency = new Agency();
|
||||||
$agency->setName($name);
|
$agency->setName($name);
|
||||||
|
$agency->setInhaber($inhaber);
|
||||||
|
$agency->setStreet($street);
|
||||||
|
$agency->setPlz($plz);
|
||||||
|
$agency->setCity($city);
|
||||||
|
$agency->setAgencymail($agencymail);
|
||||||
|
$agency->setPhone($phone);
|
||||||
return $this->mapper->insert($agency);
|
return $this->mapper->insert($agency);
|
||||||
}
|
}
|
||||||
|
//Update an Agency
|
||||||
|
public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
|
||||||
|
try {
|
||||||
|
$agency = $this->mapper->find($id);
|
||||||
|
} catch(Exception $e) {
|
||||||
|
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||||
|
}
|
||||||
|
$agency->setName($name);
|
||||||
|
$agency->setInhaber($inhaber);
|
||||||
|
$agency->setStreet($street);
|
||||||
|
$agency->setPlz($plz);
|
||||||
|
$agency->setCity($city);
|
||||||
|
$agency->setAgencymail($agencymail);
|
||||||
|
$agency->setPhone($phone);
|
||||||
|
return $this->mapper->update($agency);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,81 @@
|
||||||
<template>
|
<template>
|
||||||
<Content app-name="AgencyData">
|
<Content app-name="AgencyData">
|
||||||
<FormulateForm
|
<b-container class="bv-example-row">
|
||||||
@submit="submitHandler">
|
<h3>Agenturdaten</h3>
|
||||||
<FormulateInput name="name"
|
<FormulateForm
|
||||||
type="text" />
|
v-model="agency"
|
||||||
<FormulateInput
|
@submit="submitHandler">
|
||||||
type="submit"
|
<b-row cols="1"
|
||||||
label="Aktualisieren" />
|
cols-sm="1"
|
||||||
</FormulateForm>
|
cols-md="2"
|
||||||
|
cols-lg="4">
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="name"
|
||||||
|
label="Agenturname"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="inhaber"
|
||||||
|
label="Agenturinhaber"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<b-row cols="1"
|
||||||
|
cols-sm="1"
|
||||||
|
cols-md="2"
|
||||||
|
cols-lg="4">
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="street"
|
||||||
|
label="Straße"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="city"
|
||||||
|
label="Stadt"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<b-row cols="1"
|
||||||
|
cols-sm="1"
|
||||||
|
cols-md="2"
|
||||||
|
cols-lg="4">
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="plz"
|
||||||
|
label="PLZ"
|
||||||
|
validation="required|max:5|min:5"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="agencymail"
|
||||||
|
label="Agentur-Email-Adresse"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<b-row cols="1"
|
||||||
|
cols-sm="1"
|
||||||
|
cols-md="2"
|
||||||
|
cols-lg="4">
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput name="phone"
|
||||||
|
label="Telefonnummer"
|
||||||
|
type="text" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<b-row class="mt-2">
|
||||||
|
<b-col>
|
||||||
|
<FormulateInput
|
||||||
|
type="submit"
|
||||||
|
label="Aktualisieren" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
</FormulateForm>
|
||||||
|
</b-container>
|
||||||
</Content>
|
</Content>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Content from '@nextcloud/vue/dist/Components/Content'
|
import Content from '@nextcloud/vue/dist/Components/Content'
|
||||||
import { generateUrl } from '@nextcloud/router'
|
import { generateUrl } from '@nextcloud/router'
|
||||||
|
import '@braid/vue-formulate/themes/snow/snow.scss'
|
||||||
const axios = require('axios').default
|
const axios = require('axios').default
|
||||||
|
|
||||||
export default ({
|
export default ({
|
||||||
|
|
@ -22,11 +85,19 @@ export default ({
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
agency: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.fetchData()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async fetchData() {
|
||||||
|
const agencydata = await axios.get(generateUrl('/apps/agency/agencys/4'))
|
||||||
|
this.agency = agencydata.data
|
||||||
|
},
|
||||||
async submitHandler(data) {
|
async submitHandler(data) {
|
||||||
const response = await axios.post(generateUrl('/apps/agency/agencys'), data)
|
const response = await axios.put(generateUrl('/apps/agency/agencys/4'), data)
|
||||||
console.log(response)
|
console.log(response)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue