109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries\MyStorage;
|
|
|
|
|
|
use App\Libraries\MyStorage\FileLibrary as MyStorageLibrary;
|
|
use App\Models\Mangboard\FileModel;
|
|
use App\Entities\Mangboard\UserEntity;
|
|
use App\Entities\Mangboard\FileEntity;
|
|
|
|
class MangboardLibrary extends MyStorageLibrary
|
|
{
|
|
private $_user = null;
|
|
private $_boardName = "";
|
|
private $_boardTable = "";
|
|
private $_boardLevel = 1;
|
|
private $_model = null;
|
|
public function __construct(string $path)
|
|
{
|
|
parent::__construct($path);
|
|
}
|
|
public function getModel(): FileModel
|
|
{
|
|
if ($this->_model === null) {
|
|
return $this->_model = new FileModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
public function getFileEntity(): FileEntity
|
|
{
|
|
return new FileEntity();
|
|
}
|
|
public function getUser(): UserEntity
|
|
{
|
|
if ($this->_user === null) {
|
|
throw new \Exception("사용자정보가 없습니다.");
|
|
}
|
|
return $this->_user;
|
|
}
|
|
public function setUser(UserEntity $user): void
|
|
{
|
|
$this->_user = $user;
|
|
}
|
|
public function getBoardName(): string
|
|
{
|
|
if ($this->_boardName === null) {
|
|
throw new \Exception("BoardModel이 지정되지 않았습니다.");
|
|
}
|
|
return $this->_boardName;
|
|
}
|
|
public function setBoardName(string $boardName): void
|
|
{
|
|
$this->_boardName = $boardName;
|
|
}
|
|
public function getBoardTable(): string
|
|
{
|
|
if ($this->_boardTable === null) {
|
|
throw new \Exception("BoardModel이 지정되지 않았습니다.");
|
|
}
|
|
return $this->_boardTable;
|
|
}
|
|
public function setBoardTable(string $boardTable): void
|
|
{
|
|
$this->_boardTable = $boardTable;
|
|
}
|
|
public function getBoardLevel(): int
|
|
{
|
|
if ($this->_boardLevel === null) {
|
|
throw new \Exception("BoardModel Level이 지정되지 않았습니다.");
|
|
}
|
|
return intval($this->_boardLevel);
|
|
}
|
|
public function setBoardLevel(string $boardLevel): void
|
|
{
|
|
$this->_boardLevel = $boardLevel;
|
|
}
|
|
|
|
|
|
public function save(string $fileName, string $mediaType, string $content, int $file_sequence): FileEntity
|
|
{
|
|
$entity = parent::save($fileName, $mediaType, $content, $file_sequence);
|
|
log_message("debug", "{$file_sequence}번째 File DB등록 준비->{$entity->getTitle()}|{$entity->getMimeType()}");
|
|
//망보드 파일관리 table에 등록
|
|
$entity->user_pid = $this->getUser()->getPK();
|
|
$entity->user_name = $this->getUser()->getTitle();
|
|
$entity->board_name = $this->getBoardName();
|
|
$entity->table_name = $this->getBoardTable();
|
|
$entity->reg_date = date("Y-m-d H:i:s");
|
|
$entity->file_caption = $fileName;
|
|
$entity->file_alt = $entity->getTitle();
|
|
$entity->file_description = "Filedata";
|
|
log_message("debug", var_export($entity, true));
|
|
$entity = $this->getModel()->create($entity);
|
|
exit;
|
|
log_message("debug", "{$file_sequence}번째 File DB등록 완료->{$entity}");
|
|
return $entity;
|
|
}
|
|
|
|
public function setBoardPID(array $fileEntitys, int $board_pid)
|
|
{
|
|
//망보드 파일관리툴에 등록된 파일게시물에 등록한 게시판번호 수정하기
|
|
foreach ($fileEntitys as $fileEntity) {
|
|
$fileEntity->board_pid = $board_pid;
|
|
$this->getModel()->setFields(["board_pid"]);
|
|
$this->getModel()->modify($fileEntity);
|
|
}
|
|
}
|
|
}
|