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 관련
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) {
if (!is_dir(WRITEPATH . $path)) {
mkdir(WRITEPATH . $path, 0640);
if (!is_dir($path)) {
mkdir($path, 0640);
}
}

View File

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

View File

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

View File

@ -18,12 +18,24 @@
</div>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<table class="table table-bordered table-hover table-striped">
<table class="table table-bordered">
<tr>
<td rowspan="3"><?= getFieldIndex_Row_ProductHelper('photo', $entity, $viewDatas) ?></td>
<td><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></td>
<td><?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>-<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?></td>
<td><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td>
<td width="10%"><img src="/upload_images/<?= $entity->getPhotoBlock() ?>"></td>
<td width="*">
<div style="text-align:left;"><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></div>
<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>
</table>
<?php $cnt++ ?>