This commit is contained in:
2026-01-05 15:11:12 +09:00
parent 8338df57c9
commit da33e34d4f
6 changed files with 330 additions and 245 deletions

View File

@@ -0,0 +1,59 @@
CREATE TABLE `v2_chg_history` (
`seq` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '순번',
`vr_sq` BIGINT(20) UNSIGNED NOT NULL COMMENT '검증요청순번',
`stat_cd` VARCHAR(6) NOT NULL COMMENT '상태코드' COLLATE 'utf8mb3_uca1400_ai_ci',
`chg_type` VARCHAR(10) NOT NULL COMMENT '변경유형' COLLATE 'utf8mb3_uca1400_ai_ci',
`memo` TEXT NULL DEFAULT NULL COMMENT '메모' COLLATE 'utf8mb3_uca1400_ai_ci',
`insert_id` VARCHAR(60) NOT NULL COMMENT '등록자ID' COLLATE 'utf8mb3_uca1400_ai_ci',
`insert_tm` DATETIME NOT NULL COMMENT '등록시간',
PRIMARY KEY (`seq`) USING BTREE,
INDEX `vr_sq` (`vr_sq`) USING BTREE
)
COMMENT='변경이력'
COLLATE='utf8mb3_uca1400_ai_ci'
ENGINE=InnoDB
AUTO_INCREMENT=81103559
;
<?php
namespace App\Models;
use CodeIgniter\Model;
class V2chgstatModel extends Model
{
protected $table = 'v2_chg_history';
protected $primaryKey = 'seq'; // 실제 PK 컬럼명으로 수정하세요 (st_date, cpid, gbn_cd가 복합키인 경우도 있음)
protected $allowedFields = ['vr_sq', 'stat_cd', 'chg_type', 'memo', 'insert_id', 'insert_tm'];
protected $useTimestamps = false; // insert_tm을 직접 넣으시므로 false
/**
* 상태 변경 이력 저장 (CI4 통합 버전)
* @param array $data ['vr_sq' => 값, 'stat_cd' => 값, ...]
* @param string $saveType 'I'(Upsert), 'U'(Update)
*/
public function v2_savehistory(array $data )
{
$payload = [
'vr_sq' => $data['vr_sq'],
'stat_cd' => $data['stat_cd'],
'chg_type' => $data['chg_type'],
'memo' => $data['memo'] ?? '',
'insert_id' => $data['insert_id'] ?? '0',
'insert_tm' => $data['insert_tm'] ?? db_now(),
];
// insert 수행
if (!$this->insert($payload)) {
return [
'error' => [
'code' => $this->db->error()['code'],
'message' => $this->db->error()['message'],
],
'query' => (string)$this->getLastQuery()
];
}
return ['error' => ['code' => 0, 'message' => ''], 'id' => $this->getInsertID()];
}
}