first commit

This commit is contained in:
root
2022-03-06 11:49:27 +00:00
commit 1984e55837
1387 changed files with 121949 additions and 0 deletions

25
lib/Db/Wiki.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace OCA\MyWiki\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Wiki extends Entity implements JsonSerializable {
protected $title;
protected $fileId;
protected $userId;
public function __construct() {
$this->addType('id','integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'file_id' => $this->file_id
];
}
}

50
lib/Db/WikiMapper.php Normal file
View File

@ -0,0 +1,50 @@
<?php
namespace OCA\MyWiki\Db;
use OCP\IDBConnection;
use OCP\AppFramework\Db\QBMapper;
class WikiMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'mywiki_wikis', Note::class);
}
public function usersCount(int $folderId) {
$qb = $this->db->getQueryBuilder();
// ToDo - get the count
$qb->select($qb->createFunction('COUNT()'))
->from($this->getTableName())
->where(
$qb->expr()->eq('folderId', $qb->createNamedParameter($folderId))
);
return $qb->getSQL();
}
public function find(int $id, string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id))
)->andWhere(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntity($qb);
}
public function findAll(string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntities($qb);
}
}