Automation init...1
This commit is contained in:
parent
b33eead7a9
commit
f61113074f
@ -17,10 +17,10 @@ class Crawler extends BaseController
|
||||
try {
|
||||
$isDebug = in_array("debug", $params);
|
||||
//1.Yamap사이트에서 자유게시판에서 최근 게시물 데이터 가져오기
|
||||
$yamap = new YamapLibrary();
|
||||
$yamap->setDebug($isDebug);
|
||||
if (!in_array("skip_build", $params)) {
|
||||
$yamap = new YamapLibrary();
|
||||
$yamap->setDebug($isDebug);
|
||||
list($title, $nickname, $mediaInfos, $mediaTags) = $yamap->execute();
|
||||
list($item, $fileInfos, $mediaTags) = $yamap->execute();
|
||||
}
|
||||
// //2. 사이트 로그인 처리
|
||||
// if (!in_array("skip_login", $params)) {
|
||||
@ -39,8 +39,10 @@ class Crawler extends BaseController
|
||||
|
||||
//미디어관련정보 entity에 넣기
|
||||
$entity = new BoardEntity();
|
||||
$entity->title = $title;
|
||||
$entity->user_name = $nickname;
|
||||
$entity->title = $item["title"];
|
||||
$entity->user_name = $item["nickname"];
|
||||
$entity->reg_date = $item['time'];
|
||||
$entity->hit = $item['hit'];
|
||||
$entity->data_type = "html";
|
||||
$entity->editor_type = "S";
|
||||
$entity->content = is_array($mediaTags) ? implode("\n", $mediaTags) : $mediaTags;
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Controllers\CLI;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Models\Mangboard\UserModel;
|
||||
use App\Libraries\Mangboard\UserLibrary;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
class Mangboard extends BaseController
|
||||
{
|
||||
@ -12,7 +12,7 @@ class Mangboard extends BaseController
|
||||
{
|
||||
try {
|
||||
$isDebug = in_array("debug", $params);
|
||||
$user = new UserLibrary();
|
||||
$user = new UserLibrary(new UserModel);
|
||||
$user->setDebug($isDebug);
|
||||
$user->setLevel();
|
||||
log_message("notice", "Mangboard->level 작업이 완료되었습니다.");
|
||||
|
||||
@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Controllers\Mangboard\Admin;
|
||||
|
||||
use App\Controllers\Admin\AdminController;
|
||||
use App\Models\Mangboard\UserModel;
|
||||
use App\Libraries\Mangboard\UserLibrary;
|
||||
use App\Controllers\Admin\AdminController;
|
||||
|
||||
class UserController extends AdminController
|
||||
{
|
||||
@ -24,7 +25,7 @@ class UserController extends AdminController
|
||||
$point = intval($this->request->getVar("point"));
|
||||
$sign = $this->request->getVar("point") ?? "+";
|
||||
|
||||
$user = new UserLibrary();
|
||||
$user = new UserLibrary(new UserModel());
|
||||
$user->setPoint($id, $point, $sign);
|
||||
return "완료되었습니다.";
|
||||
} catch (\Exception $e) {
|
||||
|
||||
22
app/Entities/Mangboard/FileEntity.php
Normal file
22
app/Entities/Mangboard/FileEntity.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Mangboard;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
|
||||
class FileEntity extends CommonEntity
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return "{$this->getPK()}:{$this->getTitle()}";
|
||||
}
|
||||
public function getPK(): int
|
||||
{
|
||||
return $this->attributes['pid'];
|
||||
}
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['file_name'];
|
||||
}
|
||||
//Common Function
|
||||
}
|
||||
@ -15,4 +15,9 @@ abstract class CommonLibrary
|
||||
{
|
||||
$this->_debug = $debug;
|
||||
}
|
||||
|
||||
final public function getFileMimeType($file): string
|
||||
{
|
||||
return image_type_to_mime_type(exif_imagetype($file));
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class BoardLibrary extends CommonLibrary
|
||||
parent::__construct();
|
||||
$this->_model = $model;
|
||||
}
|
||||
protected function getModel(): mixed
|
||||
public function getModel(): mixed
|
||||
{
|
||||
return $this->_model;
|
||||
}
|
||||
|
||||
33
app/Libraries/Mangboard/FileLibrary.php
Normal file
33
app/Libraries/Mangboard/FileLibrary.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Mangboard;
|
||||
|
||||
|
||||
use App\Models\Mangboard\FileModel;
|
||||
use App\Libraries\MyStorage\FileLibrary as MyStorageLibrary;
|
||||
|
||||
class FileLibrary extends MyStorageLibrary
|
||||
{
|
||||
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 save($content): bool
|
||||
{
|
||||
if (!parent::save($content)) {
|
||||
return false;
|
||||
}
|
||||
//mb_files 모델작업
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,8 @@
|
||||
namespace App\Libraries\Mangboard;
|
||||
|
||||
use App\Models\Mangboard\UserModel;
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Libraries\CommonLibrary;
|
||||
|
||||
class UserLibrary extends CommonLibrary
|
||||
{
|
||||
@ -13,10 +13,11 @@ class UserLibrary extends CommonLibrary
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
private function getModel(): UserModel
|
||||
|
||||
public function getModel(): UserModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserModel();
|
||||
return $this->_model = new UserModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
|
||||
@ -41,18 +41,60 @@ abstract class MyCrawlerLibrary extends CommonLibrary
|
||||
$downloadInfos = [];
|
||||
$nodes = $this->getNodes($crawler, $options);
|
||||
foreach ($nodes as $node) {
|
||||
$original = $node->attr($options["attr"]);
|
||||
list($fileName, $content) = $this->getMySocket()->download($original);
|
||||
$this->getMyStorage()->setFileName($fileName);
|
||||
if (!$this->getMyStorage()->save($content)) {
|
||||
continue;
|
||||
}
|
||||
$downloadInfos[] = [
|
||||
"orignal" => $node->html(),
|
||||
"path" => $this->getMyStorage()->getPath(),
|
||||
"fileName" => $fileName,
|
||||
];
|
||||
$downloadInfos[] = $this->getMySocket()->download($node->attr($options["attr"]));
|
||||
}
|
||||
return $downloadInfos;
|
||||
}
|
||||
|
||||
final protected function save(array $downloadInfos, $fileInfos = []): array
|
||||
{
|
||||
foreach ($downloadInfos as $downloadInfo) {
|
||||
$this->getMyStorage()->setFileName($downloadInfo['fileName']);
|
||||
if (!$this->getMyStorage()->save($downloadInfo['content'])) {
|
||||
continue;
|
||||
}
|
||||
$fileInfos[] = [
|
||||
"url" => $downloadInfo['url'],
|
||||
"path" => $this->getMyStorage()->getPath(),
|
||||
"fileType" => $this->getMyStorage()->getFieType(),
|
||||
"fileName" => $this->getMyStorage()->getFieName(),
|
||||
];
|
||||
}
|
||||
return $fileInfos;
|
||||
}
|
||||
final protected function getMediaTags(array $fileInfos, array $mediaTags = []): array
|
||||
{
|
||||
switch ($fileInfos['fileType']) {
|
||||
case "jpeg":
|
||||
if ($this->getMySocket()->isContainsHttpOrHttps($fileInfos['orignal'])) {
|
||||
$mediaTags[] = $fileInfos['orignal'];
|
||||
} else {
|
||||
$mediaTags[] = sprintf(
|
||||
"<img src=\"/%s/%s/%s\" alt=\"%s\">",
|
||||
$this->getMyStorage()->getUploadPath(),
|
||||
$fileInfos["path"],
|
||||
$fileInfos["fileName"],
|
||||
$fileInfos["fileName"]
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "mp4":
|
||||
if ($this->getMySocket()->isContainsHttpOrHttps($fileInfos['orignal'])) {
|
||||
$mediaTags[] = $fileInfos['orignal'];
|
||||
} else {
|
||||
$mediaTags[] = sprintf(
|
||||
"<video src=\"/%s/%s/%s\" alt=\"%s\">",
|
||||
$this->getMyStorage()->getUploadPath(),
|
||||
$fileInfos["path"],
|
||||
$fileInfos["fileName"],
|
||||
$fileInfos["fileName"]
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$mediaTags[] = $fileInfos['orignal'];
|
||||
break;
|
||||
}
|
||||
return $mediaTags;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
namespace App\Libraries\MyCrawler;
|
||||
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use App\Libraries\MySocket\WebLibrary;
|
||||
use App\Libraries\MyStorage\FileLibrary;
|
||||
use App\Libraries\MySocket\WebLibrary as MySocket;
|
||||
use App\Libraries\Mangboard\FileLibrary as MyStorage;
|
||||
|
||||
class YamapLibrary extends MyCrawlerLibrary
|
||||
{
|
||||
@ -18,7 +18,7 @@ class YamapLibrary extends MyCrawlerLibrary
|
||||
public function getMySocket()
|
||||
{
|
||||
if ($this->_mySocket === null) {
|
||||
$this->_mySocket = new WebLibrary(getenv('yamap.host.url'));
|
||||
$this->_mySocket = new MySocket(getenv('yamap.host.url'));
|
||||
}
|
||||
return $this->_mySocket;
|
||||
}
|
||||
@ -26,7 +26,7 @@ class YamapLibrary extends MyCrawlerLibrary
|
||||
public function getMyStorage()
|
||||
{
|
||||
if ($this->_myStorage === null) {
|
||||
$this->_myStorage = new FileLibrary(getenv('yamap.storage.upload.path'));
|
||||
$this->_myStorage = new MyStorage(getenv('yamap.storage.upload.path'));
|
||||
}
|
||||
return $this->_myStorage;
|
||||
}
|
||||
@ -34,92 +34,62 @@ class YamapLibrary extends MyCrawlerLibrary
|
||||
private function mainPage(string $url): array
|
||||
{
|
||||
$crawler = $this->getContent($url, getenv("yamap.list.tag"));
|
||||
$item_tag = getenv("yamap.list.item.tag");
|
||||
$item_link_tag = getenv("yamap.list.item.link.tag");
|
||||
$item_nickname_tag = getenv("yamap.list.item.nickname.tag");
|
||||
$item_nickname_except = getenv("yamap.list.item.nickname.except");
|
||||
|
||||
$lists = [];
|
||||
$items = [];
|
||||
//div.bbs_item를 가진 객체를 찾아서 같은 형식의 객체(sibling)를 배열로 넘김
|
||||
$crawler->filter($item_tag)->each(
|
||||
function (Crawler $node) use (
|
||||
&$item_link_tag,
|
||||
&$item_nickname_tag,
|
||||
&$item_nickname_except,
|
||||
&$lists
|
||||
): void {
|
||||
$crawler->filter(getenv("yamap.list.item.tag"))->each(
|
||||
function (Crawler $node) use (&$items): void {
|
||||
//bbs_item에서 span.g_nickname 객체를 찾아서 작성자가 "관리자" 아닌지 확인 후 Return Bool
|
||||
$nickname = $node->filter($item_nickname_tag)->text();
|
||||
log_message("debug", $item_nickname_tag . ":" . $nickname);
|
||||
if ($nickname != $item_nickname_except) {
|
||||
$nickname = $node->filter(getenv("yamap.list.item.nickname.tag"))->text();
|
||||
$time = date("Y-m-d") . " " . $node->filter(getenv("yamap.list.item.time.tag "))->text();
|
||||
$hit = intval($node->filter(getenv("yamap.list.item.hit.tag "))->text());
|
||||
if ($nickname != getenv("yamap.list.item.nickname.except")) {
|
||||
//작성자가 "관리자"가 아니 게시물이면 해당 bbs_item에서 a.list_subject 객체를 찾아서
|
||||
$link_node = $node->filter($item_link_tag);
|
||||
$url = $link_node->attr("href");
|
||||
$link_node = $node->filter(getenv("yamap.list.item.link.tag"));
|
||||
$detail_url = $link_node->attr("href");
|
||||
$title = $link_node->children()->last()->text();
|
||||
$lists[] = ['title' => $title, 'nickname' => $nickname, 'url' => $url];
|
||||
$items[] = ['title' => $title, 'nickname' => $nickname, 'detail_url' => $detail_url, 'time' => $time, 'hit' => $hit];
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!count($lists)) {
|
||||
if (!count($items)) {
|
||||
throw new \Exception("Target URL이 없습니다.");
|
||||
}
|
||||
return array($lists[0]["title"], $lists[0]["nickname"], $lists[0]["url"]);
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function detailPage(string $url): array
|
||||
{
|
||||
$crawler = $this->getContent($url, getenv("yamap.view.content.tag"));
|
||||
$mediaInfos = [];
|
||||
$mediaTags = [];
|
||||
//3. Image 처리
|
||||
$downloadInfos = $this->download($crawler, ["tag" => "img", "attr" => "src"]);
|
||||
foreach ($downloadInfos as $downloadInfo) {
|
||||
if ($this->getMySocket()->isContainsHttpOrHttps($downloadInfo['orignal'])) {
|
||||
$mediaTags[] = $downloadInfos['orignal'];
|
||||
} else {
|
||||
$mediaTags[] = sprintf(
|
||||
"<img src=\"/%s/%s/%s\" alt=\"%s\">",
|
||||
$this->getMyStorage()->getUploadPath(),
|
||||
$downloadInfo["path"],
|
||||
$downloadInfo["fileName"],
|
||||
$downloadInfo["fileName"]
|
||||
);
|
||||
};
|
||||
$mediaInfos[] = $downloadInfo;
|
||||
}
|
||||
$fileInfos = $this->save($downloadInfos);
|
||||
$mediaTags = $this->getMediaTags($fileInfos);
|
||||
//4. Video(mp4) 처리
|
||||
$downloadInfos = $this->download($crawler, ["tag" => "video", "attr" => "src"]);
|
||||
foreach ($downloadInfos as $downloadInfo) {
|
||||
if ($this->getMySocket()->isContainsHttpOrHttps($downloadInfo['orignal'])) {
|
||||
$mediaTags[] = $downloadInfos['orignal'];
|
||||
} else {
|
||||
$mediaTags[] = sprintf(
|
||||
"<video src=\"/%s/%s/%s\" alt=\"%s\" controls autoplay>",
|
||||
$this->getMyStorage()->getUploadPath(),
|
||||
$downloadInfo["path"],
|
||||
$downloadInfo["fileName"],
|
||||
$downloadInfo["fileName"]
|
||||
);
|
||||
};
|
||||
$mediaInfos[] = $downloadInfo;
|
||||
}
|
||||
$fileInfos = $this->save($downloadInfos);
|
||||
$mediaTags = $this->getMediaTags($fileInfos);
|
||||
log_message("debug", "-----mediaTags-----");
|
||||
log_message("debug", var_export($mediaTags, true));
|
||||
return array($mediaInfos, $mediaTags);
|
||||
return array($fileInfos, $mediaTags);
|
||||
}
|
||||
|
||||
public function execute(): array
|
||||
{
|
||||
$items = [];
|
||||
//1. 해당사이트 MainPage 처리
|
||||
if ($this->getDebug()) {
|
||||
$title = getenv("yamap.view.test.title");
|
||||
$nickname = getenv("yamap.view.test.nickname");
|
||||
$detail_url = getenv("yamap.view.test.url");
|
||||
$items[] = [
|
||||
'title' => getenv("yamap.view.test.title"),
|
||||
'nickname' => getenv("yamap.view.test.nickname"),
|
||||
'detail_url' => getenv("yamap.view.test.url"),
|
||||
'time' => date("Y-m-d H:i:s"),
|
||||
'hit' => 1
|
||||
];
|
||||
} else {
|
||||
list($title, $nickname, $detail_url) = $this->mainPage(getenv("yamap.list.url"));
|
||||
$items = $this->mainPage(getenv("yamap.list.url"));
|
||||
}
|
||||
//2. DetailPage 처리 : bbs_view > div.contents 가진 객체를 찾아서 처리
|
||||
list($mediaInfos, $mediaTags) = $this->detailPage($detail_url);
|
||||
return array($title, $nickname, $mediaInfos, $mediaTags);
|
||||
list($fileInfos, $mediaTags) = $this->detailPage($items[0]["detail_url"]);
|
||||
return array($items[0], $fileInfos, $mediaTags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,6 @@ class WebLibrary extends MySocketLibrary
|
||||
}
|
||||
log_message("notice", "{$fileName} 파일이 다운로드되었습니다!");
|
||||
}
|
||||
return array($fileName, $content);
|
||||
return ["url" => $url, "fileName" => $fileName, "content" => $content];
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ class FileLibrary extends MyStorageLibrary
|
||||
{
|
||||
private $_path = "";
|
||||
private $_fileName = "";
|
||||
private $_fileType = "";
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct();
|
||||
@ -25,7 +26,12 @@ class FileLibrary extends MyStorageLibrary
|
||||
$this->_fileName = $fileName;
|
||||
}
|
||||
|
||||
final public function save($content): bool
|
||||
final public function getFileType(): string
|
||||
{
|
||||
return $this->_fileType;
|
||||
}
|
||||
|
||||
public function save($content): bool
|
||||
{
|
||||
$fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath();
|
||||
if (!is_dir($fullPath)) {
|
||||
@ -34,6 +40,7 @@ class FileLibrary extends MyStorageLibrary
|
||||
}
|
||||
}
|
||||
$saveFile = $fullPath . DIRECTORY_SEPARATOR . $this->getFileName();
|
||||
$this->_fileType = $this->getFileMimeType($saveFile);
|
||||
log_message("debug", "Storage Save-> " . $saveFile);
|
||||
return file_put_contents($saveFile, $content);
|
||||
}
|
||||
|
||||
@ -5,6 +5,67 @@ namespace App\Models\Mangboard;
|
||||
use App\Models\CommonModel;
|
||||
use App\Entities\Mangboard\BoardEntity;
|
||||
|
||||
// +-----------------+---------------------+------+-----+---------------------+----------------+
|
||||
// | Field | Type | Null | Key | Default | Extra |
|
||||
// +-----------------+---------------------+------+-----+---------------------+----------------+
|
||||
// | pid | int(10) unsigned | NO | PRI | NULL | auto_increment |
|
||||
// | gid | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | reply | int(10) unsigned | NO | | 0 | |
|
||||
// | depth | int(10) unsigned | NO | | 0 | |
|
||||
// | user_id | varchar(150) | NO | MUL | | |
|
||||
// | user_name | varchar(100) | NO | MUL | | |
|
||||
// | title | varchar(255) | NO | MUL | | |
|
||||
// | passwd | varchar(100) | NO | | | |
|
||||
// | homepage | varchar(255) | NO | | | |
|
||||
// | email | varchar(255) | NO | | | |
|
||||
// | address | varchar(255) | NO | | | |
|
||||
// | phone | varchar(50) | NO | | | |
|
||||
// | reg_date | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | modify_date | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | calendar_date | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | hit | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | user_pid | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | parent_pid | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | parent_user_pid | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | level | tinyint(3) unsigned | NO | | 0 | |
|
||||
// | file_count | int(10) unsigned | NO | | 0 | |
|
||||
// | comment_count | int(10) unsigned | NO | | 0 | |
|
||||
// | vote_good_count | int(10) unsigned | NO | | 0 | |
|
||||
// | vote_bad_count | int(10) unsigned | NO | | 0 | |
|
||||
// | vote_type | int(10) unsigned | NO | | 0 | |
|
||||
// | ip | varchar(40) | NO | | | |
|
||||
// | agent | varchar(30) | NO | | | |
|
||||
// | is_notice | tinyint(3) unsigned | NO | MUL | 0 | |
|
||||
// | is_secret | tinyint(3) unsigned | NO | | 0 | |
|
||||
// | status | varchar(30) | NO | MUL | publish | |
|
||||
// | is_show | tinyint(3) unsigned | NO | MUL | 1 | |
|
||||
// | reply_email | tinyint(3) | NO | | 0 | |
|
||||
// | text | mediumtext | NO | | NULL | |
|
||||
// | content | mediumtext | NO | | NULL | |
|
||||
// | content_type | varchar(20) | NO | | | |
|
||||
// | data_type | varchar(20) | NO | | text | |
|
||||
// | editor_type | varchar(10) | NO | | N | |
|
||||
// | tag | varchar(255) | NO | | | |
|
||||
// | category1 | varchar(100) | NO | MUL | | |
|
||||
// | category2 | varchar(100) | NO | | | |
|
||||
// | category3 | varchar(100) | NO | | | |
|
||||
// | image_path | varchar(255) | NO | | | |
|
||||
// | site_link1 | varchar(255) | NO | | | |
|
||||
// | site_link2 | varchar(255) | NO | | | |
|
||||
// | gps_latitude | decimal(10,8) | NO | MUL | 0.00000000 | |
|
||||
// | gps_longitude | decimal(11,8) | NO | | 0.00000000 | |
|
||||
// | ext1 | varchar(255) | NO | | | |
|
||||
// | ext2 | varchar(255) | NO | | | |
|
||||
// | ext3 | varchar(255) | NO | | | |
|
||||
// | ext4 | varchar(255) | NO | | | |
|
||||
// | ext5 | varchar(255) | NO | | | |
|
||||
// | ext6 | varchar(255) | NO | | | |
|
||||
// | ext7 | varchar(255) | NO | | | |
|
||||
// | ext8 | varchar(255) | NO | | | |
|
||||
// | ext9 | varchar(255) | NO | | | |
|
||||
// | ext10 | varchar(255) | NO | | | |
|
||||
// +-----------------+---------------------+------+-----+---------------------+----------------+
|
||||
|
||||
class BoardModel extends CommonModel
|
||||
{
|
||||
// protected $table = 'mb_board_free';
|
||||
@ -14,7 +75,7 @@ class BoardModel extends CommonModel
|
||||
public function __construct(string $table)
|
||||
{
|
||||
$this->table = $table;
|
||||
$fields = ["title", "user_name", "data_type", "editor_type", "content"];
|
||||
$fields = ["title", "user_name", "data_type", "editor_type", "reg_date", "hit", "content"];
|
||||
parent::__construct($fields);
|
||||
}
|
||||
public function getTitleField(): string
|
||||
@ -33,9 +94,15 @@ class BoardModel extends CommonModel
|
||||
case "editor_type":
|
||||
$rules[$field] = "if_exist|trim|in_list[N,S]";
|
||||
break;
|
||||
case "reg_date":
|
||||
$rules[$field] = "if_exist|valid_date";
|
||||
break;
|
||||
case "content":
|
||||
$rules[$field] = "required|trim|string";
|
||||
break;
|
||||
case 'hit':
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
break;
|
||||
|
||||
93
app/Models/Mangboard/FileModel.php
Normal file
93
app/Models/Mangboard/FileModel.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Mangboard;
|
||||
|
||||
use App\Models\CommonModel;
|
||||
use App\Entities\Mangboard\FileEntity;
|
||||
|
||||
// +------------------+----------------------+------+-----+---------------------+----------------+
|
||||
// | Field | Type | Null | Key | Default | Extra |
|
||||
// +------------------+----------------------+------+-----+---------------------+----------------+
|
||||
// | pid | int(10) unsigned | NO | PRI | NULL | auto_increment |
|
||||
// | user_pid | int(10) unsigned | NO | | 0 | |
|
||||
// | user_name | varchar(100) | NO | MUL | | |
|
||||
// | board_name | varchar(50) | NO | MUL | | |
|
||||
// | table_name | varchar(100) | NO | MUL | | |
|
||||
// | board_pid | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | file_name | varchar(255) | NO | MUL | | |
|
||||
// | file_path | varchar(255) | NO | MUL | | |
|
||||
// | file_type | varchar(255) | NO | MUL | | |
|
||||
// | file_caption | varchar(255) | NO | | | |
|
||||
// | file_alt | varchar(255) | NO | | | |
|
||||
// | file_description | text | NO | | NULL | |
|
||||
// | file_size | int(10) unsigned | NO | MUL | 0 | |
|
||||
// | link_count | int(10) unsigned | NO | | 0 | |
|
||||
// | download_count | int(10) unsigned | NO | | 0 | |
|
||||
// | file_sequence | smallint(5) unsigned | NO | MUL | 1 | |
|
||||
// | is_download | tinyint(3) unsigned | NO | | 0 | |
|
||||
// | reg_date | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | ip | varchar(40) | NO | | | |
|
||||
// | agent | varchar(30) | NO | | | |
|
||||
// +------------------+----------------------+------+-----+---------------------+----------------+
|
||||
|
||||
class FileModel extends CommonModel
|
||||
{
|
||||
protected $table = 'mb_files';
|
||||
protected $primaryKey = 'pid';
|
||||
protected $returnType = FileEntity::class;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$fields = ["user_pid", "user_name", "board_name", "table_name", "file_name", "file_path", "file_type", "reg_date"];
|
||||
parent::__construct($fields);
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'file_name';
|
||||
}
|
||||
public function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "user_pid":
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
case "board_name":
|
||||
case "table_name":
|
||||
case "file_name":
|
||||
case "file_path":
|
||||
case "file_type":
|
||||
$rules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "reg_date":
|
||||
$rules[$field] = "if_exist|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getEntityByPK(int $uid): null | FileEntity
|
||||
{
|
||||
$this->where($this->getPKField(), $uid);
|
||||
return $this->getEntity();
|
||||
}
|
||||
public function getEntityByID(string $id): null | FileEntity
|
||||
{
|
||||
$this->where('user_id', $id);
|
||||
return $this->getEntity();
|
||||
}
|
||||
|
||||
//create용
|
||||
public function create(FileEntity $entity): FileEntity
|
||||
{
|
||||
return $this->create_process($entity);
|
||||
}
|
||||
|
||||
//modify용
|
||||
public function modify(FileEntity $entity): FileEntity
|
||||
{
|
||||
return $this->modify_process($entity);
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,95 @@ namespace App\Models\Mangboard;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Models\CommonModel;
|
||||
|
||||
// +-------------------+----------------------+------+-----+---------------------+----------------+
|
||||
// | Field | Type | Null | Key | Default | Extra |
|
||||
// +-------------------+----------------------+------+-----+---------------------+----------------+
|
||||
// | pid | int(10) unsigned | NO | PRI | NULL | auto_increment |
|
||||
// | wp_user_pid | int(10) unsigned | NO | | 0 | |
|
||||
// | user_id | varchar(150) | NO | UNI | | |
|
||||
// | passwd | varchar(255) | NO | | | |
|
||||
// | user_name | varchar(100) | NO | | | |
|
||||
// | user_state | varchar(255) | NO | | | |
|
||||
// | user_level | tinyint(3) unsigned | NO | | 1 | |
|
||||
// | user_group | varchar(255) | NO | MUL | home | |
|
||||
// | user_platform | varchar(100) | NO | | mb | |
|
||||
// | user_email | varchar(255) | NO | | | |
|
||||
// | user_point | int(10) unsigned | NO | | 0 | |
|
||||
// | user_money | int(10) unsigned | NO | | 0 | |
|
||||
// | user_coin | int(10) unsigned | NO | | 0 | |
|
||||
// | payment_count | smallint(5) unsigned | NO | | 0 | |
|
||||
// | payment_total | int(10) unsigned | NO | | 0 | |
|
||||
// | user_birthday | varchar(50) | NO | | | |
|
||||
// | user_phone | varchar(50) | NO | | | |
|
||||
// | user_picture | varchar(255) | NO | | | |
|
||||
// | user_icon | varchar(255) | NO | | | |
|
||||
// | user_messenger | varchar(255) | NO | | | |
|
||||
// | user_homepage | varchar(255) | NO | | | |
|
||||
// | user_blog | varchar(255) | NO | | | |
|
||||
// | user_sex | tinyint(3) | NO | | 0 | |
|
||||
// | home_postcode | varchar(20) | NO | | | |
|
||||
// | home_address1 | varchar(255) | NO | | | |
|
||||
// | home_address2 | varchar(255) | NO | | | |
|
||||
// | home_tel | varchar(50) | NO | | | |
|
||||
// | office_postcode | varchar(20) | NO | | | |
|
||||
// | office_address1 | varchar(255) | NO | | | |
|
||||
// | office_address2 | varchar(255) | NO | | | |
|
||||
// | office_tel | varchar(50) | NO | | | |
|
||||
// | office_fax | varchar(50) | NO | | | |
|
||||
// | company_name | varchar(255) | NO | | | |
|
||||
// | job_title | varchar(255) | NO | | | |
|
||||
// | gps_latitude | decimal(10,8) | NO | | 0.00000000 | |
|
||||
// | gps_longitude | decimal(11,8) | NO | | 0.00000000 | |
|
||||
// | allow_mailing | tinyint(3) unsigned | NO | MUL | 1 | |
|
||||
// | allow_message | tinyint(3) unsigned | NO | | 1 | |
|
||||
// | allow_push | tinyint(3) unsigned | NO | | 1 | |
|
||||
// | allow_sms | tinyint(3) unsigned | NO | | 1 | |
|
||||
// | followers | int(10) unsigned | NO | | 0 | |
|
||||
// | following | int(10) unsigned | NO | | 0 | |
|
||||
// | new_memo | smallint(5) unsigned | NO | | 0 | |
|
||||
// | login_count | int(10) unsigned | NO | | 0 | |
|
||||
// | write_count | int(10) unsigned | NO | | 0 | |
|
||||
// | reply_count | int(10) unsigned | NO | | 0 | |
|
||||
// | comment_count | int(10) unsigned | NO | | 0 | |
|
||||
// | send_count | int(10) unsigned | NO | | 0 | |
|
||||
// | api_count | int(10) unsigned | NO | | 0 | |
|
||||
// | item1_count | int(10) unsigned | NO | | 0 | |
|
||||
// | item2_count | int(10) unsigned | NO | | 0 | |
|
||||
// | item3_count | int(10) unsigned | NO | | 0 | |
|
||||
// | review_count | int(10) unsigned | NO | | 0 | |
|
||||
// | review_star_sum | int(10) unsigned | NO | | 0 | |
|
||||
// | reg_mail | tinyint(3) | NO | | 0 | |
|
||||
// | reg_phone | tinyint(3) | NO | | 0 | |
|
||||
// | push_pid | int(10) unsigned | NO | | 0 | |
|
||||
// | reg_date | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | last_login | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
||||
// | user_memo | varchar(255) | NO | | | |
|
||||
// | admin_memo | varchar(255) | NO | | | |
|
||||
// | recommender_id | varchar(255) | NO | | | |
|
||||
// | user_auth_key | varchar(255) | NO | | | |
|
||||
// | user_access_token | varchar(255) | NO | | | |
|
||||
// | ext1 | varchar(255) | NO | | | |
|
||||
// | ext2 | varchar(255) | NO | | | |
|
||||
// | ext3 | varchar(255) | NO | | | |
|
||||
// | ext4 | varchar(255) | NO | | | |
|
||||
// | ext5 | varchar(255) | NO | | | |
|
||||
// | ext6 | varchar(255) | NO | | | |
|
||||
// | ext7 | varchar(255) | NO | | | |
|
||||
// | ext8 | varchar(255) | NO | | | |
|
||||
// | ext9 | varchar(255) | NO | | | |
|
||||
// | ext10 | varchar(255) | NO | | | |
|
||||
// | ext11 | varchar(255) | NO | | | |
|
||||
// | ext12 | varchar(255) | NO | | | |
|
||||
// | ext13 | varchar(255) | NO | | | |
|
||||
// | ext14 | varchar(255) | NO | | | |
|
||||
// | ext15 | varchar(255) | NO | | | |
|
||||
// | ext16 | varchar(255) | NO | | | |
|
||||
// | ext17 | varchar(255) | NO | | | |
|
||||
// | ext18 | varchar(255) | NO | | | |
|
||||
// | ext19 | varchar(255) | NO | | | |
|
||||
// | ext20 | varchar(255) | NO | | | |
|
||||
// +-------------------+----------------------+------+-----+---------------------+----------------+
|
||||
|
||||
class UserModel extends CommonModel
|
||||
{
|
||||
protected $table = 'mb_users';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user