servermgrv2 init...

This commit is contained in:
최준흠 2023-07-26 10:30:51 +09:00
parent b4e3898fb8
commit ed4276402e
7 changed files with 64 additions and 34 deletions

View File

@ -54,4 +54,11 @@ abstract class BaseHierarchyModel extends BaseModel
$entity->grpdepth = $parent_entity->grpdepth + 1; $entity->grpdepth = $parent_entity->grpdepth + 1;
return parent::create_process($entity, $formDatas); return parent::create_process($entity, $formDatas);
} }
public function setIndexOrderBy($field, $order = "DESC")
{
parent::setIndexOrderBy($field, $order);
$this->orderBy("grpno", "DESC");
$this->orderBy("grporder", "ASC");
}
} }

View File

@ -49,6 +49,11 @@ abstract class BaseModel extends Model
} }
$this->validationRules = []; $this->validationRules = [];
} }
final public function getPrimaryKey(): string
{
return $this->primaryKey;
}
abstract public function getTitle(): string;
abstract public function getEntity($uid): BaseEntity; abstract public function getEntity($uid): BaseEntity;
abstract public function getEntitys($conditions): array; abstract public function getEntitys($conditions): array;
abstract public function getFieldFilters(): array; abstract public function getFieldFilters(): array;
@ -102,11 +107,6 @@ abstract class BaseModel extends Model
return $fields; return $fields;
} }
final public function getPrimaryKey()
{
return $this->primaryKey;
}
final public function getFieldFormOptions($conditions, $options = array()): array final public function getFieldFormOptions($conditions, $options = array()): array
{ {
foreach ($this->getEntitys($conditions) as $entity) { foreach ($this->getEntitys($conditions) as $entity) {
@ -226,6 +226,5 @@ abstract class BaseModel extends Model
} }
public function setIndexOrderBy($field, $order = "ASC") public function setIndexOrderBy($field, $order = "ASC")
{ {
$this->orderBy($field, $order);
} }
} }

View File

@ -15,17 +15,21 @@ class BoardConfigModel extends BaseModel
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()]; $this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitle(): string
{
return 'name';
}
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = [ $fields = [
"name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", $this->getTitle(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "head", "tail", "status", "head", "tail",
]; ];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return [ return [
"name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", $this->getTitle(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "created_at" "status", "created_at"
]; ];
break; 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] = "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}]" : ""; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break; break;
case "name": case $this->getTitle():
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break; break;
@ -120,7 +124,7 @@ class BoardConfigModel extends BaseModel
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)
{ {
parent::setIndexWordFilter($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("isaccess", $word, "both"); //befor , after , both
$this->orLike("isread", $word, "both"); //befor , after , both $this->orLike("isread", $word, "both"); //befor , after , both
$this->orLike("iswrite", $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") public function setIndexOrderBy($field, $order = "ASC")
{ {
$this->orderBy("name", "ASC");
parent::setIndexOrderBy($field, $order); parent::setIndexOrderBy($field, $order);
$this->orderBy($this->getTitle(), "ASC");
} }
} }

View File

@ -14,16 +14,20 @@ class BoardModel extends BaseHierarchyModel
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitle(): string
{
return 'title';
}
public function getFields(string $action = ""): array 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) { switch ($action) {
case "index": case "index":
case "excel": 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; break;
case "view": 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; break;
default: default:
return $fields; return $fields;
@ -40,7 +44,7 @@ class BoardModel extends BaseHierarchyModel
case "board_config_uid": 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}/]"; $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; break;
case "title": case $this->getTitle():
case "content": case "content":
$rules[$field] = "required|string"; $rules[$field] = "required|string";
break; break;
@ -83,13 +87,12 @@ class BoardModel extends BaseHierarchyModel
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)
{ {
parent::setIndexWordFilter($word); parent::setIndexWordFilter($word);
$this->orLike("title", $word, "both"); $this->orLike($this->getTitle(), $word, "both");
$this->orLike("content", $word, "both"); //befor , after , 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); parent::setIndexOrderBy($field, $order);
$this->orderBy($this->getTitle(), "ASC");
} }
} }

View File

@ -14,16 +14,20 @@ class HPILOModel extends BaseModel
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), 'model', 'processor', 'memory', 'health', 'power', 'detail',]; $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), 'model', 'processor', 'memory', 'health', 'power', 'detail',];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitle(): string
{
return 'customer';
}
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = ['customer', 'ip', 'port', 'id', 'passwd', 'status']; $fields = [$this->getTitle(), 'ip', 'port', 'id', 'passwd', 'status'];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": 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; break;
case "view": 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; break;
default: default:
return $fields; return $fields;
@ -105,11 +109,16 @@ class HPILOModel extends BaseModel
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)
{ {
parent::setIndexWordFilter($word); parent::setIndexWordFilter($word);
$this->orLike('customer', $word, 'both'); $this->orLike($this->getTitle(), $word, 'both');
} }
public function setIndexOrderBy($field, $order = 'ASC') public function setIndexOrderBy($field, $order = 'ASC')
{ {
$this->orderBy("health", "ASC"); $this->orderBy("health", "ASC");
parent::setIndexOrderBy($field, $order); parent::setIndexOrderBy($field, $order);
} }
public function setIndexOrderBy($field, $order = "ASC")
{
parent::setIndexOrderBy($field, $order);
$this->orderBy($this->getTitle(), "ASC");
}
} }

View File

@ -15,16 +15,20 @@ class UserModel extends BaseModel
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()]; $this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitle(): string
{
return 'name';
}
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = ["id", "passwd", "name", "email", "role", "status"]; $fields = ["id", "passwd", $this->getTitle(), "email", "role", "status"];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return ["id", "name", "email", "role", "status", 'created_at']; return ["id", $this->getTitle(), "email", "role", "status", 'created_at'];
break; break;
case "view": case "view":
return ["id", "name", "email", "role", "status", 'updated_at', 'created_at']; return ["id", $this->getTitle(), "email", "role", "status", 'updated_at', 'created_at'];
break; break;
default: default:
return $fields; return $fields;
@ -50,7 +54,7 @@ class UserModel extends BaseModel
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
$rules["confirmpassword"] = "required|trim|string|matches[passwd]"; $rules["confirmpassword"] = "required|trim|string|matches[passwd]";
break; break;
case "name": case $this->getTitle():
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
break; break;
case "email": case "email":
@ -103,11 +107,11 @@ class UserModel extends BaseModel
{ {
parent::setIndexWordFilter($word); parent::setIndexWordFilter($word);
$this->orLike("id", $word, "both"); $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") public function setIndexOrderBy($field, $order = "ASC")
{ {
$this->orderBy("name", "ASC");
parent::setIndexOrderBy($field, $order); parent::setIndexOrderBy($field, $order);
$this->orderBy($this->getTitle(), "ASC");
} }
} }

View File

@ -14,13 +14,17 @@ class UserSNSModel extends BaseModel
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitle(): string
{
return 'name';
}
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = ["site", "id", "name", "email", "detail", "status"]; $fields = ["site", "id", $this->getTitle(), "email", "detail", "status"];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return ["user_uid", "site", "id", "name", "email", "status", "created_at"]; return ["user_uid", "site", "id", $this->getTitle(), "email", "status", "created_at"];
break; break;
case "view": case "view":
return [...$fields, "updated_at", "created_at"]; return [...$fields, "updated_at", "created_at"];
@ -41,7 +45,7 @@ class UserSNSModel extends BaseModel
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break; break;
case "name": case $this->getTitle():
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
break; break;
case "email": case "email":
@ -82,12 +86,12 @@ class UserSNSModel extends BaseModel
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)
{ {
parent::setIndexWordFilter($word); parent::setIndexWordFilter($word);
$this->orLike("name", $word, "both"); $this->orLike($this->getTitle(), $word, "both");
$this->orLike("email", $word, "both"); //befor , after , both $this->orLike("email", $word, "both"); //befor , after , both
} }
public function setIndexOrderBy($field, $order = "ASC") public function setIndexOrderBy($field, $order = "ASC")
{ {
$this->orderBy("name", "ASC");
parent::setIndexOrderBy($field, $order); parent::setIndexOrderBy($field, $order);
$this->orderBy($this->getTitle(), "ASC");
} }
} }