shoppingmallv2 init...
This commit is contained in:
parent
5742aa555a
commit
633a3497b5
@ -95,7 +95,11 @@ class BoardController extends FrontController
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
//조회수 올리기
|
||||
echo var_export($entity, true);
|
||||
echo "<HR>";
|
||||
$entity = $this->_model->addViewCount($entity);
|
||||
echo var_export($entity, true);
|
||||
exit;
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
//Index관련
|
||||
|
||||
@ -77,6 +77,7 @@ abstract class BaseModel extends Model
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->primaryKey:
|
||||
//수동입력인경우
|
||||
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] .= $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)
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->primaryKey:
|
||||
//primaryKey가 자동입력이 아니면
|
||||
if (!$this->useAutoIncrement) {
|
||||
$pk = $this->primaryKey;
|
||||
$entity->$pk = $this->getUUID();
|
||||
}
|
||||
break;
|
||||
case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
//관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용
|
||||
@ -219,7 +213,7 @@ abstract class BaseModel extends Model
|
||||
return $entity;
|
||||
}
|
||||
|
||||
final protected function save_process($entity)
|
||||
final protected function save_process($entity): BaseEntity
|
||||
{
|
||||
// echo var_export($entity, true);
|
||||
// exit;
|
||||
@ -229,28 +223,30 @@ abstract class BaseModel extends Model
|
||||
log_message("error", implode("\n", $this->errors()));
|
||||
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 {
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n 기존정보와 동일하여 수정되지 않았습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process($entity, array $formDatas)
|
||||
protected function create_process($entity, array $formDatas): BaseEntity
|
||||
{
|
||||
// echo var_export($entity);
|
||||
// exit;
|
||||
foreach ($this->allowedFields as $field) {
|
||||
foreach ($this->formDatas as $field => $value) {
|
||||
$entity = $this->changeFormData('create', $field, $formDatas, $entity);
|
||||
}
|
||||
// echo var_export($this->allowedFields);
|
||||
// exit
|
||||
return $this->save_process($entity);
|
||||
//primaryKey가 수동입력이면
|
||||
if (!$this->useAutoIncrement) {
|
||||
$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) {
|
||||
if ($field != $this->primaryKey) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user