shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-24 09:36:33 +09:00
parent 55b17f1cff
commit 0d494e82cb
3 changed files with 45 additions and 67 deletions

View File

@ -78,20 +78,6 @@ class ProductController extends AdminController
} }
//Insert관련 //Insert관련
protected function insert_validate()
{
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
}
}
protected function insert_process() protected function insert_process()
{ {
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
@ -99,34 +85,6 @@ class ProductController extends AdminController
} }
//Update관련 //Update관련
protected function update_validate($entity)
{
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
}
//변견된 데이터 Log로 남기기
foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
log_message(
"info",
sprintf(
"{$field} 변경: ---원본--\n%s\n---변경---\n%s",
$entity->$field,
var_export($value, true)
)
);
}
}
}
protected function update_process($entity) protected function update_process($entity)
{ {
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();

View File

@ -173,16 +173,17 @@ abstract class BaseController extends Controller
} }
protected function insert_validate() protected function insert_validate()
{ {
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용 //fieldData 적용
$this->_viewDatas['fieldDatas'] = array(); $this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) { foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field); $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
} }
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
} }
protected function insert_process() protected function insert_process()
{ {
@ -229,17 +230,18 @@ abstract class BaseController extends Controller
} }
protected function update_validate($entity) protected function update_validate($entity)
{ {
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용 //fieldData 적용
$this->_viewDatas['fieldDatas'] = array(); $this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) { foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity); $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
} }
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//변견된 데이터 Log로 남기기 //변견된 데이터 Log로 남기기
foreach ($this->_viewDatas['fieldDatas'] as $field => $value) { foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다. if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
@ -302,16 +304,17 @@ abstract class BaseController extends Controller
} }
protected function reply_validate($entity) protected function reply_validate($entity)
{ {
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용 //fieldData 적용
$this->_viewDatas['fieldDatas'] = array(); $this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) { foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity); $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
} }
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
} }
protected function reply_process($entity) protected function reply_process($entity)
{ {
@ -340,16 +343,17 @@ abstract class BaseController extends Controller
//Toggle 관련 //Toggle 관련
protected function toggle_validate($entity) protected function toggle_validate($entity)
{ {
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용 //fieldData 적용
$this->_viewDatas['fieldDatas'] = array(); $this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) { foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity); $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
} }
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
} }
protected function toggle_process($entity) protected function toggle_process($entity)
{ {
@ -376,16 +380,17 @@ abstract class BaseController extends Controller
//Batchjob 관련 //Batchjob 관련
protected function batchjob_validate($entity) protected function batchjob_validate($entity)
{ {
//Upload된 파일 검증(photo)때문에 먼처 체크
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
//fieldData 적용 //fieldData 적용
$this->_viewDatas['fieldDatas'] = array(); $this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) { foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity); $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
} }
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
} }
protected function batchjob_process($entity) protected function batchjob_process($entity)
{ {

View File

@ -121,6 +121,21 @@ class CardController extends BillingController
} }
return $response; return $response;
} }
//특수한형태의 Field(card_number,card_expiration) 때문에 먼저 데이터를 받아서 변환한후 validation 체크를 하기위해
protected function update_validate($entity)
{
//fieldData 적용
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
}
$this->_validation->setRules($this->_viewDatas['fieldRules']);
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
}
}
protected function update_process($entity) protected function update_process($entity)
{ {
//카드결제 //카드결제