diff --git a/app/Config/Constants.php b/app/Config/Constants.php index c98800b..99bf708 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -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); } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index a6849a5..0695a87 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -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; diff --git a/app/Entities/ProductEntity.php b/app/Entities/ProductEntity.php index c493fd6..98f3a8c 100644 --- a/app/Entities/ProductEntity.php +++ b/app/Entities/ProductEntity.php @@ -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() { diff --git a/app/Views/front/product/index_b.php b/app/Views/front/product/index_b.php index 00a035a..ff1e68d 100644 --- a/app/Views/front/product/index_b.php +++ b/app/Views/front/product/index_b.php @@ -18,12 +18,24 @@ - +
- - - - + + +
- +
+
+ 판매가:getFinalPrice() ?>원 + + 원가:원 + - + 할인가:원 + +
+
+ 조회수: +
+