dbmsv2 init...1

This commit is contained in:
choi.jh 2025-08-25 18:53:30 +09:00
parent 0ead124c33
commit 9eb78fb61e
19 changed files with 729 additions and 111 deletions

View File

@ -43,13 +43,13 @@ class ClientController extends CustomerController
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::create_process($formDatas);
// 생성 후, Client 코드값 재정의
$prefix = env("Client.Prefix.site.{$formDatas['site']}", false);
if (!$prefix) {
$format = env("Client.Prefix.{$formDatas['site']}.code.format", false);
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 prefix가 정의되지 않았습니다.");
}
$this->getService()->modify(
$this->entity,
['code' => $prefix . $this->entity->getPK()]
['code' => sprintf($format, (int) $this->entity->getPK() + 1000)]
);
}
//수정관련

View File

@ -59,11 +59,11 @@ class ServiceController extends CustomerController
parent::modify_process($entity, $formDatas);
}
//List 관련
protected function index_process(): void
protected function index_process(array $entities = []): array
{
//서비스별 미납 Count
$this->unPaids = $this->getPaymentService()->getUnPaidCount();
//부모함수처리
parent::index_process();
return parent::index_process($entities);
}
}

View File

@ -37,6 +37,7 @@ class ServerController extends EquipmentController
}
return $this->_helper;
}
//Index,FieldForm관련
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
@ -56,10 +57,35 @@ class ServerController extends EquipmentController
{
$format = env("Server.Prefix.code.format", false);
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 format이 정의되지 않았습니다.");
throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다.");
}
$default = (int)env("Server.Default.code", 0);
$this->setFormDatasDefault('code', $this->getService()->getLastestCode($format, $default));
$this->setFormDatasDefault('code', $this->getService()->getLastestCode($format, (int)env("Server.Default.code", 0)));
parent::create_form_process();
}
protected function create_process(array $formDatas): void
{
//코드 패턴체크
$pattern = env("Server.Prefix.code.pattern", false);
if (!$pattern) {
throw new \Exception(__METHOD__ . "에서 code의 prefix[Server.Prefix.code.pattern]가 정의되지 않았습니다.");
}
if (!array_key_exists('code', $formDatas)) {
throw new \Exception("Server코드가 정의되지 않았습니다");
}
if (!preg_match($pattern, $formDatas['code'])) {
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
}
parent::create_process($formDatas);
//추가 파트정보 생성
$partDatas = [];
foreach ($this->getService()::BaseParts as $basePart) {
$partDatas[$basePart] = [
"partinfo_uid" => $formDatas["partinfo_{$basePart}_uid"],
"cnt" => $this->request->getPost(index: "partinfo_{$basePart}_uid_cnt") ?? 1,
"extgra" => $this->request->getPost("partinfo_{$basePart}_uid_extra") ?? ""
];
}
$this->serverPartEntities = $this->getService()->createServerParts($this->entity, $partDatas);
}
}

View File

@ -35,4 +35,19 @@ class SwitchController extends EquipmentController
return $this->_helper;
}
//Index,FieldForm관
protected function create_process(array $formDatas): void
{
//코드 패턴체크
$pattern = env("Switch.Prefix.code.pattern", false);
if (!$pattern) {
throw new \Exception(__METHOD__ . "에서 code의 prefix[Switch.Prefix.code.pattern]가 정의되지 않았습니다.");
}
if (!array_key_exists('code', $formDatas)) {
throw new \Exception("Switch코드가 정의되지 않았습니다");
}
if (!preg_match($pattern, $formDatas['code'])) {
throw new \Exception("Switch코드[{$formDatas['code']}의 형식이 맞지않습니다");
}
parent::create_process($formDatas);
}
}

View File

@ -113,13 +113,13 @@ abstract class CommonController extends BaseController
//Field Rules정의
$this->_control['field_rules'] = [];
foreach ($fields as $field) {
$this->_control['field_rules'][$field] = $this->getService()->getFormFieldRule($action, $field);
$this->_control['field_rules'][$field] = $this->getFormFieldRule($action, $field);
}
//Form용 Options정의
$this->_control['filter_optons'] = [];
foreach ($this->getControlDatas('actionFilters') as $field) {
$this->_control['filter_optons'][$field] = [];
foreach ($this->getService()->getFormFieldOption($field) as $option) {
foreach ($this->getFormFieldOption($field) as $option) {
$this->_control['filter_optons'][$field][$option->getPK()] = $option;
}
}
@ -428,6 +428,31 @@ abstract class CommonController extends BaseController
//공통 기본 기능
//추가 개별 처리 기능
//FieldForm관련용
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
default:
$options = $this->getService()->getFormFieldOption($field, $options);
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
protected function getFormFieldRule(string $action, string $field): string
{
if (is_array($field)) {
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
default:
$rule = $this->getService()->getFormFieldRule($action, $field);
break;
}
return $rule;
}
//FormData Field별 전달값 처리
protected function getFormData_process(string $field, array $formDatas): array
{
@ -553,37 +578,37 @@ abstract class CommonController extends BaseController
//리스트관련
//조건절 처리
//Filter Field별 전달값 처리
protected function index_condition_filter_process(string $field, $default = null): mixed
protected function index_condition_filterfield_process(string $field, $filter_values = []): array
{
switch ($field) {
default:
$filter_value = $this->request->getVar($field);
if ($filter_value !== null && $filter_value !== '') {
$this->getService()->index_condition_filterField($field, $filter_value);
$filter_values[$field] = $filter_value;
}
break;
}
return $filter_value;
return $filter_values;
}
protected function index_condition_process(): void
{
//Paramter로 전달된 Filter값을 정의용
$filter_values = [];
foreach ($this->_control['actionFilters'] as $field) {
$filter_value = $this->index_condition_filter_process($field);
if ($filter_value !== null && $filter_value !== '') {
$this->getService()->setList_FormFilter($field, $filter_value);
$filter_values[] = $filter_value;
}
$filter_values = $this->index_condition_filterfield_process($field, $filter_values);
}
$this->_control['filter_values'][$field] = $filter_values;
$this->_control['filter_values'] = $filter_values;
//검색어조건절 처리
$this->word = $this->request->getVar('word');
if ($this->word !== null && $this->word !== '') {
$this->getService()->setList_WordFilter($this->word);
$this->getService()->index_condition_filterWord($this->word);
}
//날자검색
$this->start = $this->request->getVar('start');
$this->end = $this->request->getVar('end');
if ($this->start !== null && $this->start !== '' && $this->end !== null && $this->end !== '') {
$this->getService()->setList_DateFilter($this->start, $this->end);
$this->getService()->index_condition_filterDate($this->start, $this->end);
}
}
//PageNation 처리

View File

@ -10,7 +10,7 @@
"show": 511,
"database": 4,
"databaseName": "",
"canvasType": "ERD",
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
"language": 1,
"tableNameCase": 4,
"columnNameCase": 2,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,11 +12,20 @@ class ClientProcess implements MigrationProcessInterface
{
$this->db = $db;
}
private function getClientCode(string $site, string $client_code): string
{
$format = env("Client.Prefix.{$site}.code.format", false);
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 prefix[Client.Prefix.{$site}.code.format]가 정의되지 않았습니다.");
}
return sprintf($format, (int)substr($client_code, 1));
}
public function process(array $row, int $cnt): void
{
$temps = [];
$temps['site'] = 'prime';
$temps['code'] = 'PI' . $row['Client_Code'];
$temps['code'] = $this->getClientCode($temps['site'], $row['Client_Code']);
$temps['user_uid'] = 1;
$temps['role'] = $row['Client_Reseller'] == 30 ? "reseller" : "user";
$temps['name'] = $row['Client_Name'];

View File

@ -14,7 +14,11 @@ class SwitchCodeProcess implements MigrationProcessInterface
}
public function process(array $row, int $cnt): void
{
if (!preg_match('/^C ?\d{2}PA\d{2}$/', $row['service_sw'])) {
$pattern = env("Switch.Prefix.code.pattern", false);
if (!$pattern) {
throw new \Exception(__METHOD__ . "에서 code의 prefix[Switch.Prefix.code.pattern]가 정의되지 않았습니다.");
}
if (!preg_match($pattern, $row['service_sw'])) {
echo "{$cnt} {$row['service_sw']}-> SKIP SWITCHCODE\n";
return;
}

View File

@ -242,14 +242,4 @@ abstract class CommonModel extends Model
// dd($entity);
return $this->modify_process($entity);
}
//List 검색용
//FormFilter 조건절 처리
final public function setList_FormFilter(string $field, mixed $default_value): void {}
//검색어조건절처리
final public function setList_WordFilter(string $word): void {}
//날자검색
final public function setList_DateFilter(string $start, string $end): void {}
//OrderBy 처리
final public function setOrderBy(string $field, $value): void {}
}

View File

@ -52,11 +52,4 @@ class UserSNSModel extends CommonModel
}
return $rule;
}
//List 검색용
// public function setList_WordFilter(string $word): void
// {
// $this->orLike(self::TABLE . '.id', $word, 'both');
// $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
// $this->orLike(self::TABLE . '.email', $word, 'both');
// }
}

View File

@ -85,6 +85,10 @@ abstract class CommonService
foreach ($this->getEntities_process($where, $columns) as $entity) {
$entities[$entity->getPK()] = $this->getEntity_process($entity);
}
$debug = sprintf("debug.%s.%s", $this->getClassName(), __FUNCTION__);
if (env($debug, false)) {
echo $debug . "=>" . $this->getModel()->getLastQuery() . "<BR>";
}
return $entities;
} catch (\Exception $e) {
$message = sprintf(
@ -130,9 +134,6 @@ abstract class CommonService
}
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
public function getFormFieldRule(string $action, string $field): string
@ -191,22 +192,21 @@ abstract class CommonService
$this->getModel()->offset($offset);
}
//FormFilter 조건절 처리
public function setList_FormFilter(string $field, mixed $filter_value): void
public function index_condition_filterField(string $field, mixed $filter_value): void
{
switch ($field) {
default:
//일반검색
$this->getModel()->where("{$this->getModel()->getTable()}.{$field}", $filter_value);
break;
}
}
//검색어조건절처리
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
$this->getModel()->orLike($this->getModel()->getTable() . "." . $this->getModel()->getTitleField(), $word, 'both');
}
//날자검색
public function setList_DateFilter(string $start, string $end): void
public function index_condition_filterDate(string $start, string $end): void
{
$this->getModel()->where(sprintf("%s.created_at >= '%s 00:00:00'", $this->getModel()->getTable(), $start));
$this->getModel()->where(sprintf("%s.created_at <= '%s 23:59:59'", $this->getModel()->getTable(), $end));

View File

@ -80,9 +80,9 @@ class AccountService extends CustomerService
return parent::create($formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
$this->getModel()->orLike($this->getModel()->getTable() . '.alias', $word, 'both');
parent::setList_WordFilter($word);
parent::index_condition_filterWord($word);
}
}

View File

@ -138,7 +138,7 @@ class ClientService extends CustomerService
//List 검색용
//FormFilter 조건절 처리
public function setList_FormFilter(string $field, mixed $filter_value): void
public function index_condition_filterField(string $field, mixed $filter_value): void
{
switch ($field) {
case 'role':
@ -147,15 +147,15 @@ class ClientService extends CustomerService
$this->getModel()->where($where, null, false);
break;
default:
parent::setList_FormFilter($field, $filter_value);
parent::index_condition_filterField($field, $filter_value);
break;
}
}
//검색어조건절처리
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
$this->getModel()->orLike($this->getModel()->getTable() . '.email', $word, 'both');
parent::setList_WordFilter($word);
parent::index_condition_filterWord($word);
}
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void

View File

@ -149,12 +149,12 @@ class ServiceService extends CustomerService
}
//List 검색용
//검색어조건절처리
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
if ($this->isIPAddress($word, 'ipv4')) {
$this->setSearchIp($word);
} else {
parent::setList_WordFilter($word);
parent::index_condition_filterWord($word);
}
}
}

View File

@ -154,52 +154,17 @@ class ServerService extends EquipmentService
{
return $this->getModel()->getLastestCode($format, $default);
}
private function getConvertedFormDatas(array $formDatas): array
{
$convertedFormDatas = [];
$convertedFormDatas['code'] = $formDatas['code'];
$convertedFormDatas['type'] = $formDatas['type'];
$convertedFormDatas['title'] = $formDatas['title'];
$convertedFormDatas['price'] = $formDatas['price'];
$convertedFormDatas['manufactur_at'] = $formDatas['manufactur_at'];
if (array_key_exists('format_at', $formDatas) && $formDatas['format_at']) {
$convertedFormDatas['format_at'] = $formDatas['format_at'];
}
$convertedFormDatas['status'] = $formDatas['status'];
return $convertedFormDatas;
}
private function getPartLinkFormDatas(ServerEntity $entity, array $formDatas): array
{
$partFormDatas = [];
$partFormDatas["serverinfo_uid"] = $entity->getPK();
if ($entity->getServiceInfoUID()) { //서비스정보가 있다면
$partFormDatas["serviceinfo_uid"] = $entity->getServiceInfoUID();
}
// dd($formDatas);
$partFormDatas["billing_method"] = PAYMENT['BILLING']['METHOD_MONTH'];
$partLinkFormDatas = [];
foreach (self::BaseParts as $basePart) {
$field = "partinfo_{$basePart}_uid";
$partFormDatas["partinfo_uid"] = $formDatas[$field];
$partFormDatas["cnt"] = array_key_exists("{$field}_cnt", $formDatas) ? $formDatas["{$field}_cnt"] : 1;
$partFormDatas["extra"] = array_key_exists("{$field}_extra", $formDatas) ? $formDatas["{$field}_extra"] : "";
//part별로 link용 추가
$partLinkFormDatas[] = $partFormDatas;
}
return $partLinkFormDatas;
}
public function create(array $formDatas): ServerEntity
public function createServerParts(ServerEntity $entity, array $partDatas): array
{
//입력된 데이터를 기준으로 서버정보 재정의
$convertedFormDatas = $this->getConvertedFormDatas($formDatas);
$entity = parent::create($convertedFormDatas);
//파트정보 가져오기
$partLinkFormDatas = $this->getPartLinkFormDatas($entity, $formDatas);
foreach ($partLinkFormDatas as $partLinkFormData) {
$this->getServerPartModel()->create($partLinkFormData);
$serverPartEntities = [];
foreach (self::BaseParts as $basePart) {
$partDatas[$basePart]["serverinfo_uid"] = $entity->getPK();
$partDatas[$basePart]["serviceinfo_uid"] = $entity->getServiceInfoUID();
dd($partDatas);
$serverPartEntities[] = $this->getServerPartModel()->create($partDatas);
}
return $entity;
return $serverPartEntities;
}
//List 검색용

View File

@ -82,7 +82,7 @@ class MyLogService extends CommonService
return $this->create($formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
$this->getModel()->orLike($this->getModel()::TABLE . "." . $this->getModel()::TITLE, $word, 'both');
$this->getModel()->orLike($this->getModel()::TABLE . '.content', $word, 'both');

View File

@ -93,7 +93,7 @@ class UserService extends CommonService
}
//List 검색용
//FormFilter 조건절 처리
public function setList_FormFilter(string $field, mixed $filter_value): void
public function index_condition_filterField(string $field, mixed $filter_value): void
{
switch ($field) {
case 'role':
@ -102,15 +102,16 @@ class UserService extends CommonService
$this->getModel()->where($where, null, false);
break;
default:
parent::setList_FormFilter($field, $filter_value);
parent::index_condition_filterField($field, $filter_value);
break;
}
}
//검색어조건절처리
public function setList_WordFilter(string $word): void
public function index_condition_filterWord(string $word): void
{
$this->getModel()->orLike($this->getModel()->getTable() . '.id', $word, 'both');
$this->getModel()->orLike($this->getModel()->getTable() . "." . $this->getModel()::TITLE, $word, 'both');
$this->getModel()->orLike($this->getModel()->getTable() . '.email', $word, 'both');
parent::index_condition_filterWord($word);
}
}