diff --git a/appinfo/routes.php b/appinfo/routes.php
index 2c8f1e9..7d387f6 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -5,5 +5,6 @@ return [
],
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
+ ['name' => 'agency#getagencyidbyuser', 'url' => '/getagencyidbyuser', 'verb' => 'GET'],
]
];
diff --git a/lib/Controller/AgencyController.php b/lib/Controller/AgencyController.php
index 99bb223..094168d 100644
--- a/lib/Controller/AgencyController.php
+++ b/lib/Controller/AgencyController.php
@@ -4,22 +4,31 @@ declare(strict_types=1);
namespace OCA\Agency\Controller;
use OCP\IRequest;
+use OCP\IUserSession;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Controller;
use OCA\Agency\Service\AgencyService;
+use OCA\Agency\Service\AgencyUserService;
class AgencyController extends Controller {
+ protected $userManager;
private $service;
+ private $agencyuserservice;
private $Id;
+ protected $userSession;
+ protected $request;
use Errors;
- public function __construct(string $AppName, IRequest $request,
- AgencyService $service){
+ public function __construct(string $AppName, IRequest $request, IUserSession $userSession, AgencyService $service, AgencyUserService $agencyuserservice){
parent::__construct($AppName, $request);
$this->service = $service;
+ $this->agencyuserservice = $agencyuserservice;
+ $this->userSession = $userSession;
+ $this->request = $request;
}
/**
@@ -29,6 +38,16 @@ class AgencyController extends Controller {
return new DataResponse($this->service->findAll($this->Id));
}
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
+ public function getagencyidbyuser() {
+ $user = $this->userSession->getUser()->getUid();
+ $params = $this->agencyuserservice->getAgencyIdByUserUid($user);
+ return new JSONResponse($params);
+ }
+
/**
* @NoAdminRequired
* @NoCSRFRequired
@@ -43,7 +62,6 @@ class AgencyController extends Controller {
/**
* @NoAdminRequired
- * @NoCSRFRequired
*
* @param string $title
* @param string $content
diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php
new file mode 100644
index 0000000..001359d
--- /dev/null
+++ b/lib/Controller/GroupController.php
@@ -0,0 +1,57 @@
+service = $service;
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function index() {
+ return new DataResponse($this->service->findAll($this->Id));
+ }
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ *
+ * @param int $id
+ */
+ public function show(int $id) {
+ return $this->handleNotFound(function () use ($id) {
+ return $this->service->find($id);
+ });
+ }
+
+
+
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $id
+ */
+ public function destroy(int $id) {
+ return $this->handleNotFound(function () use ($id) {
+ return $this->service->delete($id);
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Db/AgencyMapper.php b/lib/Db/AgencyMapper.php
index 3f866ad..1cbc7b8 100644
--- a/lib/Db/AgencyMapper.php
+++ b/lib/Db/AgencyMapper.php
@@ -21,5 +21,4 @@ class AgencyMapper extends QBMapper {
return $this->findEntity($qb);
}
-
}
\ No newline at end of file
diff --git a/lib/Db/AgencyUser.php b/lib/Db/AgencyUser.php
new file mode 100644
index 0000000..275e4bf
--- /dev/null
+++ b/lib/Db/AgencyUser.php
@@ -0,0 +1,24 @@
+addType('id','integer');
+ }
+
+ public function jsonSerialize() {
+ return [
+ 'id' => $this->id,
+ 'agency' => $this->agency,
+ 'user' => $this->user,
+ ];
+ }
+}
\ No newline at end of file
diff --git a/lib/Db/AgencyUserMapper.php b/lib/Db/AgencyUserMapper.php
new file mode 100644
index 0000000..63ef13a
--- /dev/null
+++ b/lib/Db/AgencyUserMapper.php
@@ -0,0 +1,34 @@
+db->getQueryBuilder();
+
+ $qb->select('*')
+ ->from($this->getTableName())
+ ->where(
+ $qb->expr()->eq('id', $qb->createNamedParameter($id))
+ );
+ return $this->findEntity($qb);
+ }
+
+ public function getAgencyIdByUserUid(string $useruid) {
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('*')
+ ->from($this->getTableName())
+ ->where(
+ $qb->expr()->eq('user', $qb->createNamedParameter($useruid))
+ );
+ return $this->findEntity($qb);
+ }
+}
\ No newline at end of file
diff --git a/lib/Migration/Version000001Date20210521125400.php b/lib/Migration/Version000001Date20210521125400.php
index f741e62..fc0bf65 100644
--- a/lib/Migration/Version000001Date20210521125400.php
+++ b/lib/Migration/Version000001Date20210521125400.php
@@ -77,9 +77,9 @@
'length' => 64
]);
- $table->addColumn('user', 'integer', [
+ $table->addColumn('user', 'string', [
'notnull' => true,
- 'length' => 64
+ 'length' => 200
]);
$table->setPrimaryKey(['id']);
diff --git a/lib/Service/AgencyUserService.php b/lib/Service/AgencyUserService.php
new file mode 100644
index 0000000..8746c40
--- /dev/null
+++ b/lib/Service/AgencyUserService.php
@@ -0,0 +1,48 @@
+mapper = $mapper;
+ }
+
+ private function handleException ($e) {
+ if ($e instanceof DoesNotExistException ||
+ $e instanceof MultipleObjectsReturnedException) {
+ throw new NotFoundException($e->getMessage());
+ } else {
+ throw $e;
+ }
+ }
+
+ //Find an Agency
+ public function find(int $id) {
+ try {
+ return $this->mapper->find($id);
+ } catch(Exception $e) {
+ $this->handleException($e);
+ }
+ }
+
+ //Find an Agency
+ public function getAgencyIdByUserUid(string $useruid) {
+ return $this->mapper->getAgencyIdByUserUid($useruid);
+ //try {
+ // return $this->mapper->getAgencyIdByUserUid($useruid);
+ //} catch(Exception $e) {
+ // $this->handleException($e);
+ //}
+ }
+}
\ No newline at end of file
diff --git a/lib/Service/GroupService.php b/lib/Service/GroupService.php
new file mode 100644
index 0000000..5622778
--- /dev/null
+++ b/lib/Service/GroupService.php
@@ -0,0 +1,34 @@
+getMessage());
+ } else {
+ throw $e;
+ }
+ }
+
+ //Find an Agency
+ public function find(int $id) {
+ try {
+ return $this->mapper->find($id);
+ } catch(Exception $e) {
+ $this->handleException($e);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Service/ServiceExcpetion.php b/lib/Service/ServiceException.php
similarity index 100%
rename from lib/Service/ServiceExcpetion.php
rename to lib/Service/ServiceException.php
diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue
index 94d7905..37cc7d5 100644
--- a/src/components/Navigation.vue
+++ b/src/components/Navigation.vue
@@ -4,6 +4,9 @@
+
diff --git a/src/router/routes.js b/src/router/routes.js
index 4047631..28015f4 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -1,4 +1,5 @@
import AgencyData from '../views/AgencyData'
+import GroupManagement from '../views/GroupManagement'
export default [
{
@@ -6,4 +7,9 @@ export default [
name: 'agencydata',
component: AgencyData,
},
+ {
+ path: '/groupmanagement',
+ name: 'groupmanagemenet',
+ component: GroupManagement,
+ },
]
diff --git a/src/views/AgencyData.vue b/src/views/AgencyData.vue
index 1517fa8..d9d2153 100644
--- a/src/views/AgencyData.vue
+++ b/src/views/AgencyData.vue
@@ -1,6 +1,6 @@
-
+
Agenturdaten
@@ -70,6 +69,9 @@
+
+
+