From ed4276402ed726f534c099c7a14475e4eea36bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 26 Jul 2023 10:30:51 +0900 Subject: [PATCH] servermgrv2 init... --- app/Models/BaseHierarchyModel.php | 7 +++++++ app/Models/BaseModel.php | 11 +++++------ app/Models/BoardConfigModel.php | 14 +++++++++----- app/Models/BoardModel.php | 19 +++++++++++-------- app/Models/HPILOModel.php | 17 +++++++++++++---- app/Models/UserModel.php | 16 ++++++++++------ app/Models/UserSNSModel.php | 14 +++++++++----- 7 files changed, 64 insertions(+), 34 deletions(-) diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php index 663cad0..f4c619c 100644 --- a/app/Models/BaseHierarchyModel.php +++ b/app/Models/BaseHierarchyModel.php @@ -54,4 +54,11 @@ abstract class BaseHierarchyModel extends BaseModel $entity->grpdepth = $parent_entity->grpdepth + 1; return parent::create_process($entity, $formDatas); } + + public function setIndexOrderBy($field, $order = "DESC") + { + parent::setIndexOrderBy($field, $order); + $this->orderBy("grpno", "DESC"); + $this->orderBy("grporder", "ASC"); + } } diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index ab36209..e9ba1b6 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -49,6 +49,11 @@ abstract class BaseModel extends Model } $this->validationRules = []; } + final public function getPrimaryKey(): string + { + return $this->primaryKey; + } + abstract public function getTitle(): string; abstract public function getEntity($uid): BaseEntity; abstract public function getEntitys($conditions): array; abstract public function getFieldFilters(): array; @@ -102,11 +107,6 @@ abstract class BaseModel extends Model return $fields; } - final public function getPrimaryKey() - { - return $this->primaryKey; - } - final public function getFieldFormOptions($conditions, $options = array()): array { foreach ($this->getEntitys($conditions) as $entity) { @@ -226,6 +226,5 @@ abstract class BaseModel extends Model } public function setIndexOrderBy($field, $order = "ASC") { - $this->orderBy($field, $order); } } diff --git a/app/Models/BoardConfigModel.php b/app/Models/BoardConfigModel.php index 3d475e5..7418be9 100644 --- a/app/Models/BoardConfigModel.php +++ b/app/Models/BoardConfigModel.php @@ -15,17 +15,21 @@ class BoardConfigModel extends BaseModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields()]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } + public function getTitle(): string + { + return 'name'; + } public function getFields(string $action = ""): array { $fields = [ - "name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + $this->getTitle(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status", "head", "tail", ]; switch ($action) { case "index": case "excel": return [ - "name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + $this->getTitle(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status", "created_at" ]; break; @@ -53,7 +57,7 @@ class BoardConfigModel extends BaseModel $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; break; - case "name": + case $this->getTitle(): $rules[$field] = "required|trim|string"; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; break; @@ -120,7 +124,7 @@ class BoardConfigModel extends BaseModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike("name", $word, "both"); //befor , after , both + $this->orLike($this->getTitle(), $word, "both"); //befor , after , both $this->orLike("isaccess", $word, "both"); //befor , after , both $this->orLike("isread", $word, "both"); //befor , after , both $this->orLike("iswrite", $word, "both"); //befor , after , both @@ -130,7 +134,7 @@ class BoardConfigModel extends BaseModel } public function setIndexOrderBy($field, $order = "ASC") { - $this->orderBy("name", "ASC"); parent::setIndexOrderBy($field, $order); + $this->orderBy($this->getTitle(), "ASC"); } } diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 9bfaf54..6f02d3c 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -14,16 +14,20 @@ class BoardModel extends BaseHierarchyModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } + public function getTitle(): string + { + return 'title'; + } public function getFields(string $action = ""): array { - $fields = ["board_config_uid", "title", "board_file", "passwd", "status", "content"]; + $fields = ["board_config_uid", $this->getTitle(), "board_file", "passwd", "status", "content"]; switch ($action) { case "index": case "excel": - return ["board_config_uid", "user_uid", "title", "board_file", "view_cnt", "status", "created_at"]; + return ["board_config_uid", "user_uid", $this->getTitle(), "board_file", "view_cnt", "status", "created_at"]; break; case "view": - return ["board_config_uid", "user_uid", "title", "board_file", "view_cnt", "status", "created_at", "content"]; + return ["board_config_uid", "user_uid", $this->getTitle(), "board_file", "view_cnt", "status", "created_at", "content"]; break; default: return $fields; @@ -40,7 +44,7 @@ class BoardModel extends BaseHierarchyModel case "board_config_uid": $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; break; - case "title": + case $this->getTitle(): case "content": $rules[$field] = "required|string"; break; @@ -83,13 +87,12 @@ class BoardModel extends BaseHierarchyModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike("title", $word, "both"); + $this->orLike($this->getTitle(), $word, "both"); $this->orLike("content", $word, "both"); //befor , after , both } - public function setIndexOrderBy($field, $order = "DESC") + public function setIndexOrderBy($field, $order = "ASC") { - $this->orderBy("grpno", "DESC"); - $this->orderBy("grporder", "ASC"); parent::setIndexOrderBy($field, $order); + $this->orderBy($this->getTitle(), "ASC"); } } diff --git a/app/Models/HPILOModel.php b/app/Models/HPILOModel.php index 2d27a43..0176bce 100644 --- a/app/Models/HPILOModel.php +++ b/app/Models/HPILOModel.php @@ -14,16 +14,20 @@ class HPILOModel extends BaseModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), 'model', 'processor', 'memory', 'health', 'power', 'detail',]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } + public function getTitle(): string + { + return 'customer'; + } public function getFields(string $action = ""): array { - $fields = ['customer', 'ip', 'port', 'id', 'passwd', 'status']; + $fields = [$this->getTitle(), 'ip', 'port', 'id', 'passwd', 'status']; switch ($action) { case "index": case "excel": - return ['customer', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'status', 'created_at']; + return [$this->getTitle(), 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'status', 'created_at']; break; case "view": - return ['customer', 'ip', 'port', 'id', 'model', 'processor', 'memory', 'health', 'power', 'detail', 'status', 'updated_at', 'created_at']; + return [$this->getTitle(), 'ip', 'port', 'id', 'model', 'processor', 'memory', 'health', 'power', 'detail', 'status', 'updated_at', 'created_at']; break; default: return $fields; @@ -105,11 +109,16 @@ class HPILOModel extends BaseModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike('customer', $word, 'both'); + $this->orLike($this->getTitle(), $word, 'both'); } public function setIndexOrderBy($field, $order = 'ASC') { $this->orderBy("health", "ASC"); parent::setIndexOrderBy($field, $order); } + public function setIndexOrderBy($field, $order = "ASC") + { + parent::setIndexOrderBy($field, $order); + $this->orderBy($this->getTitle(), "ASC"); + } } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 1056725..ee73ec2 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -15,16 +15,20 @@ class UserModel extends BaseModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields()]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } + public function getTitle(): string + { + return 'name'; + } public function getFields(string $action = ""): array { - $fields = ["id", "passwd", "name", "email", "role", "status"]; + $fields = ["id", "passwd", $this->getTitle(), "email", "role", "status"]; switch ($action) { case "index": case "excel": - return ["id", "name", "email", "role", "status", 'created_at']; + return ["id", $this->getTitle(), "email", "role", "status", 'created_at']; break; case "view": - return ["id", "name", "email", "role", "status", 'updated_at', 'created_at']; + return ["id", $this->getTitle(), "email", "role", "status", 'updated_at', 'created_at']; break; default: return $fields; @@ -50,7 +54,7 @@ class UserModel extends BaseModel $rules[$field] = "required|trim|string"; $rules["confirmpassword"] = "required|trim|string|matches[passwd]"; break; - case "name": + case $this->getTitle(): $rules[$field] = "required|trim|string"; break; case "email": @@ -103,11 +107,11 @@ class UserModel extends BaseModel { parent::setIndexWordFilter($word); $this->orLike("id", $word, "both"); - $this->orLike("name", $word, "both"); //befor , after , both + $this->orLike($this->getTitle(), $word, "both"); //befor , after , both } public function setIndexOrderBy($field, $order = "ASC") { - $this->orderBy("name", "ASC"); parent::setIndexOrderBy($field, $order); + $this->orderBy($this->getTitle(), "ASC"); } } diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index e678b09..64cab5c 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -14,13 +14,17 @@ class UserSNSModel extends BaseModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } + public function getTitle(): string + { + return 'name'; + } public function getFields(string $action = ""): array { - $fields = ["site", "id", "name", "email", "detail", "status"]; + $fields = ["site", "id", $this->getTitle(), "email", "detail", "status"]; switch ($action) { case "index": case "excel": - return ["user_uid", "site", "id", "name", "email", "status", "created_at"]; + return ["user_uid", "site", "id", $this->getTitle(), "email", "status", "created_at"]; break; case "view": return [...$fields, "updated_at", "created_at"]; @@ -41,7 +45,7 @@ class UserSNSModel extends BaseModel $rules[$field] = "required|trim|string"; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; break; - case "name": + case $this->getTitle(): $rules[$field] = "required|trim|string"; break; case "email": @@ -82,12 +86,12 @@ class UserSNSModel extends BaseModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike("name", $word, "both"); + $this->orLike($this->getTitle(), $word, "both"); $this->orLike("email", $word, "both"); //befor , after , both } public function setIndexOrderBy($field, $order = "ASC") { - $this->orderBy("name", "ASC"); parent::setIndexOrderBy($field, $order); + $this->orderBy($this->getTitle(), "ASC"); } }