cfmgrv3 init...3
This commit is contained in:
parent
ba9b26c293
commit
e15f1a8d2f
@ -175,9 +175,17 @@ class CommonController extends BaseController
|
||||
//변경된 값 적용
|
||||
$fieldDatas = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$fieldDatas[$field] = rtrim($this->request->getVar($field));
|
||||
Log::add("info", "{$entity->getTitle()}의 {$field} : {$entity->$field}=>{$fieldDatas[$field]}");
|
||||
$entity->$field = $fieldDatas[$field];
|
||||
$logs = array();
|
||||
$value = rtrim($this->request->getVar($field));
|
||||
if ($entity->$field != $value) {
|
||||
$entity->$field = $fieldDatas[$field] = $value;
|
||||
$log = "{$entity->getTitle()}의 {$field} : {$entity->$field}=>{$value}";
|
||||
Log::add("info", $log);
|
||||
array_push($logs, $log);
|
||||
}
|
||||
}
|
||||
if ($entity->hasChanged()) {
|
||||
throw new \Exception("새로 변경된 값이 없습니다." . var_export($logs, true));
|
||||
}
|
||||
$this->_viewDatas['fieldDatas'] = $fieldDatas;
|
||||
//변경할 값 확인
|
||||
@ -188,14 +196,10 @@ class CommonController extends BaseController
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
if ($entity->hasChanged()) {
|
||||
if (!$this->_model->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
} else {
|
||||
throw new \Exception(__FUNCTION__ . " 변경된값 없음.\n" . var_export($entity, true));
|
||||
if (!$this->_model->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
@ -227,32 +231,11 @@ class CommonController extends BaseController
|
||||
}
|
||||
protected function toggle_validate($entity)
|
||||
{
|
||||
//변경된 값 적용
|
||||
$fieldDatas = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$fieldDatas[$field] = $this->request->getVar($field);
|
||||
Log::add("info", "{$entity->getTitle()}의 {$field} : {$entity->$field}=>{$fieldDatas[$field]}");
|
||||
$entity->$field = $fieldDatas[$field];
|
||||
}
|
||||
$this->_viewDatas['fieldDatas'] = $fieldDatas;
|
||||
//변경할 값 확인
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
return $entity;
|
||||
return $this->update_validate($entity);
|
||||
}
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
if ($entity->hasChanged()) {
|
||||
if (!$this->_model->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
} else {
|
||||
throw new \Exception(__FUNCTION__ . " 변경된값 없음.\n" . var_export($entity, true));
|
||||
}
|
||||
return $entity;
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
protected function toggle_procedure($uid, string $field)
|
||||
{
|
||||
@ -292,32 +275,11 @@ class CommonController extends BaseController
|
||||
}
|
||||
protected function batchjob_validate($entity)
|
||||
{
|
||||
//변경된 값 적용
|
||||
$fieldDatas = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$fieldDatas[$field] = $this->request->getVar($field);
|
||||
Log::add("info", "{$entity->getTitle()}의 {$field} : {$entity->$field}=>{$fieldDatas[$field]}");
|
||||
$entity->$field = $fieldDatas[$field];
|
||||
}
|
||||
$this->_viewDatas['fieldDatas'] = $fieldDatas;
|
||||
//변경할 값 확인
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
return $entity;
|
||||
return $this->update_validate($entity);
|
||||
}
|
||||
protected function batchjob_process($entity)
|
||||
{
|
||||
if ($entity->hasChanged()) {
|
||||
if (!$this->_model->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
} else {
|
||||
throw new \Exception(__FUNCTION__ . " 변경된값 없음.\n" . var_export($entity, true));
|
||||
}
|
||||
return $entity;
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
protected function batchjob_procedure()
|
||||
{
|
||||
@ -334,11 +296,11 @@ class CommonController extends BaseController
|
||||
$entity = $this->batchjob_validate($entity);
|
||||
$entity = $this->batchjob_process($entity);
|
||||
}
|
||||
$message = "총: " . count($uids) . "의 수정(Batchjob)을 완료하였습니다.";
|
||||
$message = "총: " . count($uids) . "개의 수정(Batchjob)을 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, session()->get(RETURN_URL));
|
||||
} catch (\Exception $e) {
|
||||
$message = "총: " . count($uids) . "의 수정(Batchjob)을 실패하였습니다.";
|
||||
$message = "총: " . count($uids) . "개의 수정(Batchjob)을 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", false);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user