servermgrv2 init...1
This commit is contained in:
parent
c2066abca2
commit
bbd2c11f28
@ -23,7 +23,7 @@ class UserController extends \App\Controllers\Admin\AdminController
|
|||||||
'passwd' => 'required|trim|min_length[4]|max_length[130]',
|
'passwd' => 'required|trim|min_length[4]|max_length[130]',
|
||||||
'name' => 'required|min_length[2]|max_length[20]',
|
'name' => 'required|min_length[2]|max_length[20]',
|
||||||
'email' => 'required|valid_email',
|
'email' => 'required|valid_email',
|
||||||
'role' => 'required|in_list[member,manager,cloudflare,director,master]',
|
'role' => 'required|in_list[user,manager,cloudflare,director,master]',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
@ -33,7 +33,7 @@ class UserController extends \App\Controllers\Admin\AdminController
|
|||||||
'passwd' => 'required|trim|min_length[4]|max_length[30]',
|
'passwd' => 'required|trim|min_length[4]|max_length[30]',
|
||||||
'name' => 'required|min_length[2]|max_length[20]',
|
'name' => 'required|min_length[2]|max_length[20]',
|
||||||
'email' => 'required|valid_email',
|
'email' => 'required|valid_email',
|
||||||
'role' => 'required|in_list[member,manager,cloudflare,director,master]',
|
'role' => 'required|in_list[user,manager,cloudflare,director,master]',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'view' => [
|
'view' => [
|
||||||
@ -57,21 +57,6 @@ class UserController extends \App\Controllers\Admin\AdminController
|
|||||||
$this->_viewDatas['className'] = $this->_className;
|
$this->_viewDatas['className'] = $this->_className;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Insert관련
|
|
||||||
protected function insert_process()
|
|
||||||
{
|
|
||||||
//암호값 hash작업
|
|
||||||
$this->_viewDatas['fieldDatas']['passwd'] = password_hash($this->_viewDatas['fieldDatas']['passwd'], PASSWORD_DEFAULT);
|
|
||||||
return parent::insert_process();
|
|
||||||
}
|
|
||||||
//Update관련
|
|
||||||
protected function update_process($entity)
|
|
||||||
{
|
|
||||||
//암호값 hash작업
|
|
||||||
$entity->passwd = password_hash($entity->passwd, PASSWORD_DEFAULT);
|
|
||||||
return parent::update_process($entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
////Action 모음
|
////Action 모음
|
||||||
//Insert관련
|
//Insert관련
|
||||||
final public function insert()
|
final public function insert()
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
|
|
||||||
class CommonController extends BaseController
|
class CommonController extends BaseController
|
||||||
{
|
{
|
||||||
use CommonTrait;
|
use \App\Controllers\Trait\CommonTrait;
|
||||||
|
|
||||||
protected $_className = '';
|
protected $_className = '';
|
||||||
protected $_model = null;
|
protected $_model = null;
|
||||||
@ -28,6 +28,49 @@ class CommonController extends BaseController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Field별 Form Option용
|
||||||
|
protected function getFieldFormOption(string $field): array
|
||||||
|
{
|
||||||
|
switch ($field) {
|
||||||
|
default:
|
||||||
|
$temps = lang($this->_className . '.' . strtoupper($field));
|
||||||
|
if (!is_array($temps)) {
|
||||||
|
throw new \Exception(__FUNCTION__ . "에서 {$field}의 데이터가 array가 아닙니다.\n" . var_export($temps, true));
|
||||||
|
}
|
||||||
|
return array_merge(
|
||||||
|
[DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택'],
|
||||||
|
lang($this->_className . '.' . strtoupper($field))
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Field별 Form Option용
|
||||||
|
final protected function getFieldFormOptions(array $fieldFilters): array
|
||||||
|
{
|
||||||
|
$fieldFormOptions = array();
|
||||||
|
foreach ($fieldFilters as $field) {
|
||||||
|
if (is_array($field)) {
|
||||||
|
throw new \Exception(__FUNCTION__ . "에서 field가 array 입니다.\n" . var_export($fieldFilters, true));
|
||||||
|
}
|
||||||
|
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
|
||||||
|
}
|
||||||
|
return $fieldFormOptions;
|
||||||
|
}
|
||||||
|
//Field별 Form Rule용
|
||||||
|
final protected function getFieldRules(array $fields, array $fieldRules): array
|
||||||
|
{
|
||||||
|
$tempRules = $this->_model->getValidationRules(['only' => $fields]);
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if (is_array($field)) {
|
||||||
|
throw new \Exception(__FUNCTION__ . "에서 field가 array 입니다.\n" . var_export($fieldRules, true));
|
||||||
|
}
|
||||||
|
if (array_key_exists($field, $fieldRules)) {
|
||||||
|
$tempRules[$field] = $fieldRules[$field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tempRules;
|
||||||
|
}
|
||||||
|
|
||||||
//Insert관련
|
//Insert관련
|
||||||
protected function insert_init()
|
protected function insert_init()
|
||||||
{
|
{
|
||||||
@ -58,16 +101,16 @@ class CommonController extends BaseController
|
|||||||
|
|
||||||
protected function insert_validate()
|
protected function insert_validate()
|
||||||
{
|
{
|
||||||
//변경할 값 확인
|
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//변경된 값 적용
|
//변경된 값 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'][$field] = rtrim($this->request->getVar($field));
|
$this->_viewDatas['fieldDatas'][$field] = rtrim($this->request->getVar($field));
|
||||||
Log::add("info", "{$field} : {$this->_viewDatas['fieldDatas'][$field]}");
|
Log::add("info", "{$field} : {$this->_viewDatas['fieldDatas'][$field]}");
|
||||||
}
|
}
|
||||||
|
//변경할 값 확인
|
||||||
|
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected function insert_process()
|
protected function insert_process()
|
||||||
{
|
{
|
||||||
@ -84,7 +127,6 @@ class CommonController extends BaseController
|
|||||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||||
return alert_CommonHelper($message, session()->get(LOGINS['RETURN_URL']));
|
return alert_CommonHelper($message, session()->get(LOGINS['RETURN_URL']));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception($e->getMessage());
|
|
||||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||||
Log::add("warning", $e->getMessage());
|
Log::add("warning", $e->getMessage());
|
||||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||||
@ -124,10 +166,6 @@ class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
protected function update_validate($entity)
|
protected function update_validate($entity)
|
||||||
{
|
{
|
||||||
//변경할 값 확인
|
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//변경된 값 적용
|
//변경된 값 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
@ -142,6 +180,10 @@ class CommonController extends BaseController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//변경할 값 확인
|
||||||
|
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||||
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function update_process($entity)
|
protected function update_process($entity)
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers\Common;
|
|
||||||
|
|
||||||
trait CommonTrait
|
|
||||||
{
|
|
||||||
//Field별 Form Option용
|
|
||||||
protected function getFieldFormOption(string $field): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
default:
|
|
||||||
$temps = lang($this->_className . '.' . strtoupper($field));
|
|
||||||
if (!is_array($temps)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 데이터가 array가 아닙니다.\n" . var_export($temps, true));
|
|
||||||
}
|
|
||||||
return array_merge(
|
|
||||||
[DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택'],
|
|
||||||
lang($this->_className . '.' . strtoupper($field))
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Field별 Form Option용
|
|
||||||
final protected function getFieldFormOptions(array $fieldFilters): array
|
|
||||||
{
|
|
||||||
$fieldFormOptions = array();
|
|
||||||
foreach ($fieldFilters as $field) {
|
|
||||||
if (is_array($field)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 field가 array 입니다.\n" . var_export($fieldFilters, true));
|
|
||||||
}
|
|
||||||
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
|
|
||||||
}
|
|
||||||
return $fieldFormOptions;
|
|
||||||
}
|
|
||||||
//Field별 Form Rule용
|
|
||||||
final protected function getFieldRules(array $fields, array $fieldRules): array
|
|
||||||
{
|
|
||||||
$tempRules = $this->_model->getValidationRules(['only' => $fields]);
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if (is_array($field)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 field가 array 입니다.\n" . var_export($fieldRules, true));
|
|
||||||
}
|
|
||||||
if (array_key_exists($field, $fieldRules)) {
|
|
||||||
$tempRules[$field] = $fieldRules[$field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $tempRules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7
app/Controllers/Trait/CommonTrait.php
Normal file
7
app/Controllers/Trait/CommonTrait.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers\Trait;
|
||||||
|
|
||||||
|
trait CommonTrait
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -12,7 +12,6 @@ CREATE TABLE user (
|
|||||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
PRIMARY KEY (uid),
|
PRIMARY KEY (uid),
|
||||||
UNIQUE KEY id (id),
|
UNIQUE KEY id (id),
|
||||||
UNIQUE KEY email (email)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='사용자 정보';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='사용자 정보';
|
||||||
|
|
||||||
DROP TABLE IF EXISTS user_sns;
|
DROP TABLE IF EXISTS user_sns;
|
||||||
|
|||||||
@ -3,9 +3,8 @@
|
|||||||
namespace App\Entities;
|
namespace App\Entities;
|
||||||
|
|
||||||
use CodeIgniter\Entity\Entity;
|
use CodeIgniter\Entity\Entity;
|
||||||
use JsonSerializable;
|
|
||||||
|
|
||||||
class CommonEntity extends Entity implements JsonSerializable
|
class CommonEntity extends Entity
|
||||||
{
|
{
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,8 +30,8 @@ class UserEntity extends CommonEntity
|
|||||||
{
|
{
|
||||||
return $this->attributes['passwd'];
|
return $this->attributes['passwd'];
|
||||||
}
|
}
|
||||||
public function setPassword(string $password)
|
public function getEncryptedPassword(string $password)
|
||||||
{
|
{
|
||||||
$this->attributes['passwd'] = password_hash($password, PASSWORD_DEFAULT);
|
return password_hash($password, PASSWORD_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class GoogleAdapter extends Adapter
|
|||||||
// 'verifiedEmail' => true,
|
// 'verifiedEmail' => true,
|
||||||
// ))
|
// ))
|
||||||
//조건에 해당하는 사용자가 있는지 검사
|
//조건에 해당하는 사용자가 있는지 검사
|
||||||
$snsEntity = $this->getUserModel()->asObject(UserSNSEntity::class)->where(
|
$snsEntity = $this->getUserSNSModel()->asObject(UserSNSEntity::class)->where(
|
||||||
array("site" => $this->getSiteName(), "uid" => $result['id'])
|
array("site" => $this->getSiteName(), "uid" => $result['id'])
|
||||||
)->first();
|
)->first();
|
||||||
if (is_null($snsEntity)) {
|
if (is_null($snsEntity)) {
|
||||||
|
|||||||
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Libraries\Log\Log;
|
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
|
use App\Libraries\Log\Log;
|
||||||
|
|
||||||
class CommonModel extends Model
|
class CommonModel extends Model
|
||||||
{
|
{
|
||||||
// use CommonTrait;
|
use Trait\CommonTrait;
|
||||||
|
|
||||||
protected $DBGroup = 'default';
|
protected $DBGroup = 'default';
|
||||||
// protected $table = 'user';
|
// protected $table = 'user';
|
||||||
@ -42,6 +42,31 @@ class CommonModel extends Model
|
|||||||
protected $beforeDelete = [];
|
protected $beforeDelete = [];
|
||||||
protected $afterDelete = [];
|
protected $afterDelete = [];
|
||||||
|
|
||||||
|
final protected function create_process($entity)
|
||||||
|
{
|
||||||
|
if (!$this->save($entity)) {
|
||||||
|
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
||||||
|
Log::add("error", implode("\n", $this->errors()));
|
||||||
|
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true));
|
||||||
|
}
|
||||||
|
$pk = $this->primaryKey;
|
||||||
|
$entity->$pk = $this->insertID();
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
final protected function modify_process($entity)
|
||||||
|
{
|
||||||
|
if ($entity->hasChanged()) {
|
||||||
|
if (!$this->save($entity)) {
|
||||||
|
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
||||||
|
Log::add("error", implode("\n", $this->errors()));
|
||||||
|
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new \Exception(__FUNCTION__ . " 오류 발생.\n 기존정보와 동일하여 수정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
public function setIndexWordFilter(string $word)
|
public function setIndexWordFilter(string $word)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Libraries\Log\Log;
|
|
||||||
|
|
||||||
trait CommonTrait
|
|
||||||
{
|
|
||||||
private function setEntityDatas_CommonTrait($entity, array $datas)
|
|
||||||
{
|
|
||||||
foreach ($this->allowedFields as $field) {
|
|
||||||
if ($entity->$field != $datas[$field]) {
|
|
||||||
$entity->$field = $datas[$field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
protected function create_CommonTrait($entity, array $datas)
|
|
||||||
{
|
|
||||||
$entity = $this->setEntityDatas_CommonTrait($entity, $datas);
|
|
||||||
if (!$this->save($entity)) {
|
|
||||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
|
||||||
Log::add("error", implode("\n", $this->errors()));
|
|
||||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true));
|
|
||||||
}
|
|
||||||
$entity->$this->primaryKey = $this->insertID();
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
protected function modify_CommonTrait($entity, array $datas)
|
|
||||||
{
|
|
||||||
$entity = $this->setEntityDatas_CommonTrait($entity, $datas);
|
|
||||||
if ($entity->hasChanged()) {
|
|
||||||
if (!$this->save($entity)) {
|
|
||||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
|
||||||
Log::add("error", implode("\n", $this->errors()));
|
|
||||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -37,11 +37,16 @@ class HPILOModel extends CommonModel
|
|||||||
}
|
}
|
||||||
public function create(array $datas): HPILOEntity
|
public function create(array $datas): HPILOEntity
|
||||||
{
|
{
|
||||||
return $this->create_CommonTrait(new HPILOEntity($datas), $datas);
|
return $this->create_process(new HPILOEntity($datas));
|
||||||
}
|
}
|
||||||
public function modify(HPILOEntity $entity, array $datas): HPILOEntity
|
public function modify(HPILOEntity $entity, array $datas): HPILOEntity
|
||||||
{
|
{
|
||||||
return $this->modify_CommonTrait($entity, $datas);
|
foreach ($datas as $field => $value) {
|
||||||
|
if ($entity->$field != $datas[$field]) {
|
||||||
|
$entity->$field = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->modify_process($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class LoggerModel extends CommonModel
|
|||||||
protected $table = 'logger';
|
protected $table = 'logger';
|
||||||
// protected $primaryKey = 'uid';
|
// protected $primaryKey = 'uid';
|
||||||
// protected $useAutoIncrement = true;
|
// protected $useAutoIncrement = true;
|
||||||
protected $allowedFields = ['user_uid', 'title', 'content', 'status', 'created_at'];
|
protected $allowedFields = ['user_uid', 'title', 'content', 'status', 'updated_at'];
|
||||||
protected $validationRules = [
|
protected $validationRules = [
|
||||||
'uid' => 'if_exist|numeric',
|
'uid' => 'if_exist|numeric',
|
||||||
'user_uid' => 'if_exist|numeric',
|
'user_uid' => 'if_exist|numeric',
|
||||||
@ -30,12 +30,18 @@ class LoggerModel extends CommonModel
|
|||||||
}
|
}
|
||||||
public function create(array $datas): LoggerEntity
|
public function create(array $datas): LoggerEntity
|
||||||
{
|
{
|
||||||
$datas['user_uid'] = session()->get('uid');
|
$entity = new LoggerEntity($datas);
|
||||||
return $this->create_CommonTrait(new LoggerEntity($datas), $datas);
|
$entity->user_uid = session()->get('uid');
|
||||||
|
return parent::modify_process($entity);
|
||||||
}
|
}
|
||||||
public function modify(LoggerEntity $entity, array $datas): LoggerEntity
|
public function modify(LoggerEntity $entity, array $datas): LoggerEntity
|
||||||
{
|
{
|
||||||
return $this->modify_CommonTrait($entity, $datas);
|
foreach ($datas as $field => $value) {
|
||||||
|
if ($entity->$field != $datas[$field]) {
|
||||||
|
$entity->$field = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent::modify_process($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
|||||||
7
app/Models/Trait/CommonTrait.php
Normal file
7
app/Models/Trait/CommonTrait.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Trait;
|
||||||
|
|
||||||
|
trait CommonTrait
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ class UserModel extends CommonModel
|
|||||||
protected $table = 'user';
|
protected $table = 'user';
|
||||||
// protected $primaryKey = 'uid';
|
// protected $primaryKey = 'uid';
|
||||||
// protected $useAutoIncrement = true;
|
// protected $useAutoIncrement = true;
|
||||||
protected $allowedFields = ['id', 'passwd', 'name', 'email', 'role', 'oauth_id', 'status', 'updated_at', 'created_at'];
|
protected $allowedFields = ['id', 'passwd', 'name', 'email', 'role', 'status', 'updated_at'];
|
||||||
protected $validationRules = [
|
protected $validationRules = [
|
||||||
'uid' => 'if_exist|numeric',
|
'uid' => 'if_exist|numeric',
|
||||||
'id' => 'if_exist|min_length[4]|max_length[20]',
|
'id' => 'if_exist|min_length[4]|max_length[20]',
|
||||||
@ -18,7 +18,6 @@ class UserModel extends CommonModel
|
|||||||
'name' => 'if_exist|min_length[2]|max_length[20]',
|
'name' => 'if_exist|min_length[2]|max_length[20]',
|
||||||
'email' => 'if_exist|valid_email',
|
'email' => 'if_exist|valid_email',
|
||||||
'role' => 'if_exist|in_list[user,manager,cloudflare,director,master]',
|
'role' => 'if_exist|in_list[user,manager,cloudflare,director,master]',
|
||||||
'oauth_id' => 'if_exist|trim|min_length[4]',
|
|
||||||
'status' => 'if_exist|in_list[use,unuse,standby]',
|
'status' => 'if_exist|in_list[use,unuse,standby]',
|
||||||
'updated_at' => 'if_exist|valid_date',
|
'updated_at' => 'if_exist|valid_date',
|
||||||
'created_at' => 'if_exist|valid_date',
|
'created_at' => 'if_exist|valid_date',
|
||||||
@ -34,11 +33,20 @@ class UserModel extends CommonModel
|
|||||||
}
|
}
|
||||||
public function create(array $datas): UserEntity
|
public function create(array $datas): UserEntity
|
||||||
{
|
{
|
||||||
return $this->create_CommonTrait(new UserEntity($datas), $datas);
|
$entity = new UserEntity();
|
||||||
|
foreach ($datas as $field => $value) {
|
||||||
|
$entity->$field = $field === 'passwd' ? $entity->getEncryptedPassword($value) : $value;
|
||||||
|
}
|
||||||
|
return parent::create_process($entity);
|
||||||
}
|
}
|
||||||
public function modify(UserEntity $entity, array $datas): UserEntity
|
public function modify(UserEntity $entity, array $datas): UserEntity
|
||||||
{
|
{
|
||||||
return $this->modify_CommonTrait($entity, $datas);
|
foreach ($datas as $field => $value) {
|
||||||
|
if ($entity->$field != $datas[$field]) {
|
||||||
|
$entity->$field = $field === 'passwd' ? $entity->getEncryptedPassword($value) : $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent::modify_process($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
|||||||
@ -37,11 +37,16 @@ class UserSNSModel extends CommonModel
|
|||||||
$entity->name = $datas['name'];
|
$entity->name = $datas['name'];
|
||||||
$entity->email = $datas['email'];
|
$entity->email = $datas['email'];
|
||||||
$entity->status = "standby";
|
$entity->status = "standby";
|
||||||
return $this->create_CommonTrait($entity, $datas);
|
return $this->create_process($entity);
|
||||||
}
|
}
|
||||||
public function modify(UserSNSEntity $entity, array $datas): UserSNSEntity
|
public function modify(UserSNSEntity $entity, array $datas): UserSNSEntity
|
||||||
{
|
{
|
||||||
return $this->modify_CommonTrait($entity, $datas);
|
foreach ($datas as $field => $value) {
|
||||||
|
if ($entity->$field != $datas[$field]) {
|
||||||
|
$entity->$field = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->modify_process($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user