shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-08 11:45:28 +09:00
parent 5742aa555a
commit 633a3497b5
2 changed files with 21 additions and 21 deletions

View File

@ -95,7 +95,11 @@ class BoardController extends FrontController
//권한체크 //권한체크
$this->isRole('view', $entity); $this->isRole('view', $entity);
//조회수 올리기 //조회수 올리기
echo var_export($entity, true);
echo "<HR>";
$entity = $this->_model->addViewCount($entity); $entity = $this->_model->addViewCount($entity);
echo var_export($entity, true);
exit;
return parent::view_process($entity); return parent::view_process($entity);
} }
//Index관련 //Index관련

View File

@ -77,6 +77,7 @@ abstract class BaseModel extends Model
{ {
switch ($field) { switch ($field) {
case $this->primaryKey: case $this->primaryKey:
//수동입력인경우
if (!$this->useAutoIncrement) { if (!$this->useAutoIncrement) {
$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}]" : "";
@ -183,13 +184,6 @@ abstract class BaseModel extends Model
protected function changeFormData(string $action, string $field, array $formDatas, $entity) protected function changeFormData(string $action, string $field, array $formDatas, $entity)
{ {
switch ($field) { switch ($field) {
case $this->primaryKey:
//primaryKey가 자동입력이 아니면
if (!$this->useAutoIncrement) {
$pk = $this->primaryKey;
$entity->$pk = $this->getUUID();
}
break;
case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가 case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가
if (array_key_exists($field, $formDatas)) { if (array_key_exists($field, $formDatas)) {
//관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용 //관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용
@ -219,7 +213,7 @@ abstract class BaseModel extends Model
return $entity; return $entity;
} }
final protected function save_process($entity) final protected function save_process($entity): BaseEntity
{ {
// echo var_export($entity, true); // echo var_export($entity, true);
// exit; // exit;
@ -229,28 +223,30 @@ abstract class BaseModel extends Model
log_message("error", implode("\n", $this->errors())); log_message("error", implode("\n", $this->errors()));
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . $this->getLastQuery() . "\n" . var_export($this->errors(), true)); throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . $this->getLastQuery() . "\n" . var_export($this->errors(), true));
} }
//primaryKey가 자동입력이면
if ($this->useAutoIncrement) {
$pk = $this->primaryKey;
$entity->$pk = $this->insertID();
}
} else { } else {
throw new \Exception(__FUNCTION__ . " 오류 발생.\n 기존정보와 동일하여 수정되지 않았습니다."); throw new \Exception(__FUNCTION__ . " 오류 발생.\n 기존정보와 동일하여 수정되지 않았습니다.");
} }
return $entity; return $entity;
} }
protected function create_process($entity, array $formDatas) protected function create_process($entity, array $formDatas): BaseEntity
{ {
// echo var_export($entity); foreach ($this->formDatas as $field => $value) {
// exit;
foreach ($this->allowedFields as $field) {
$entity = $this->changeFormData('create', $field, $formDatas, $entity); $entity = $this->changeFormData('create', $field, $formDatas, $entity);
} }
// echo var_export($this->allowedFields); //primaryKey가 수동입력이면
// exit if (!$this->useAutoIncrement) {
return $this->save_process($entity); $pk = $this->primaryKey;
$entity->$pk = $this->getUUID();
}
$entity = $this->save_process($entity);
//primaryKey가 자동입력이면
if ($this->useAutoIncrement) {
$pk = $this->primaryKey;
$entity->$pk = $this->insertID();
}
return $entity;
} }
final protected function modify_process($entity, array $formDatas) final protected function modify_process($entity, array $formDatas): BaseEntity
{ {
foreach ($this->allowedFields as $field) { foreach ($this->allowedFields as $field) {
if ($field != $this->primaryKey) { if ($field != $this->primaryKey) {