shoppingmallv2 init...

This commit is contained in:
최준흠git config git config --helpgit config --global user.name 최준흠 2023-08-05 22:17:59 +09:00
parent c717aab6e9
commit f25082ed36
4 changed files with 35 additions and 17 deletions

View File

@ -181,11 +181,15 @@ define('AUTH_ADAPTERS', [
//Upload , Download 관련 //Upload , Download 관련
define('PATHS', [ define('PATHS', [
'EXCEL' => "excel/", 'UPLOAD' => "uploads/", 'DOWNLOAD' => "download/", 'API' => "api/", 'EXCEL' => WRITEPATH . "excel/",
'UPLOAD' => WRITEPATH . "uploads/",
'UPLOAD_PHOTO' => FCPATH . 'upload_images/',
'DOWNLOAD' => WRITEPATH . "download/",
'API' => WRITEPATH . "api/",
]); ]);
foreach (PATHS as $key => $path) { foreach (PATHS as $key => $path) {
if (!is_dir(WRITEPATH . $path)) { if (!is_dir($path)) {
mkdir(WRITEPATH . $path, 0640); mkdir($path, 0640);
} }
} }

View File

@ -97,13 +97,10 @@ abstract class BaseController extends Controller
//Upload FIle관련 //Upload FIle관련
private function upload_file_process(UploadedFile $upfile) private function upload_file_process(UploadedFile $upfile)
{ {
if (!is_dir(WRITEPATH . PATHS['UPLOAD'])) {
mkdir(WRITEPATH . PATHS['UPLOAD'], 0640);
}
$fileName = null; $fileName = null;
if ($upfile->isValid() && !$upfile->hasMoved()) { if ($upfile->isValid() && !$upfile->hasMoved()) {
$originName = $upfile->getName(); $originName = $upfile->getName();
$upfile->move(WRITEPATH . PATHS['UPLOAD'], $upfile->getRandomName()); $upfile->move(PATHS['UPLOAD'], $upfile->getRandomName());
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요 //move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
$fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $upfile->getName(); $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $upfile->getName();
} }
@ -111,9 +108,6 @@ abstract class BaseController extends Controller
} }
private function upload_image_process(UploadedFile $upfile, $sizeX = 100, $sizeY = 100) private function upload_image_process(UploadedFile $upfile, $sizeX = 100, $sizeY = 100)
{ {
if (!is_dir(FCPATH . '/upload_images')) {
mkdir(FCPATH . '/upload_images', 0640);
}
//참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/ //참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/
$fileName = null; $fileName = null;
if ($upfile->isValid() && !$upfile->hasMoved()) { if ($upfile->isValid() && !$upfile->hasMoved()) {
@ -122,8 +116,8 @@ abstract class BaseController extends Controller
$image = \Config\Services::image(); $image = \Config\Services::image();
$image->withFile($upfile) $image->withFile($upfile)
->resize($sizeX, $sizeY, true, 'height') ->resize($sizeX, $sizeY, true, 'height')
->save(FCPATH . '/upload_images/' . $fileName); ->save(PATHS['UPLOAD_PHOTO'] . $fileName);
$upfile->move(FCPATH . '/upload_images/', "original_" . $fileName); $upfile->move(PATHS['UPLOAD_PHOTO'], "original_" . $fileName);
$fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $fileName; $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $fileName;
} }
return $fileName; return $fileName;

View File

@ -40,10 +40,18 @@ class ProductEntity extends BaseEntity
{ {
return $this->attributes['sale']; return $this->attributes['sale'];
} }
public function getFinalPrice()
{
return $this->getPrice() - $this->getSale();
}
public function getPhoto() public function getPhoto()
{ {
return $this->attributes['photo']; return $this->attributes['photo'];
} }
public function getPhotoBlock()
{
return explode(DEFAULTS['DELIMITER_FILE'], $this->attributes['photo'])[1];
}
public function getContent() public function getContent()
{ {

View File

@ -18,12 +18,24 @@
</div> </div>
<?php $cnt = 0 ?> <?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?> <?php foreach ($viewDatas['entitys'] as $entity) : ?>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered">
<tr> <tr>
<td rowspan="3"><?= getFieldIndex_Row_ProductHelper('photo', $entity, $viewDatas) ?></td> <td width="10%"><img src="/upload_images/<?= $entity->getPhotoBlock() ?>"></td>
<td><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></td> <td width="*">
<td><?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>-<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?></td> <div style="text-align:left;"><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></div>
<td><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td> <div style="text-align:left;">
<b style="font-size:18px;">판매가:<?= $entity->getFinalPrice() ?>원</b>
<span style="font-size:12px;">
원가:<?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>
-
할인가:<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?>
</span>
</div>
<div style="text-align:left;">
조회수:<?= getFieldIndex_Row_ProductHelper('view_cnt', $entity, $viewDatas) ?>
</div>
</td>
<td width="10%"><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td>
</tr> </tr>
</table> </table>
<?php $cnt++ ?> <?php $cnt++ ?>