shoppingmallv2 init...
This commit is contained in:
parent
78b8a9cc7f
commit
4fb62f18fd
@ -141,7 +141,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
$routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2');
|
||||
});
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
|
||||
@ -629,13 +629,18 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
}
|
||||
//File Download관련
|
||||
final public function download(string $field, $uid)
|
||||
public function download_process($entity)
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
public function download(string $field, $uid)
|
||||
{
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
if (!$entity->$field) {
|
||||
throw new \Exception("첨부파일이 확인되지 않습니다.");
|
||||
}
|
||||
$entity = $this->download_process($entity);
|
||||
list($origin_filename, $filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field);
|
||||
if (is_file(WRITEPATH . PATHS['UPLOAD'] . "/" . $origin_filename)) {
|
||||
throw new \Exception("파일이 확인되지 않습니다.");
|
||||
|
||||
@ -20,6 +20,12 @@ class BoardController extends FrontController
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['title', "board_file", "passwd", "content"];
|
||||
try {
|
||||
//권한체크
|
||||
$this->isRole('upload');
|
||||
} catch (\Exception $e) {
|
||||
$fields = ['title', "passwd", "content"];
|
||||
}
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
@ -132,4 +138,11 @@ class BoardController extends FrontController
|
||||
$this->_model->where("status", DEFAULTS['STATUS']);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
//Download관련
|
||||
public function download_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('download');
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,12 @@ abstract class FrontController extends BaseController
|
||||
case 'view':
|
||||
$category_field = CATEGORY_ROLE_FIELDS['READ'];
|
||||
break;
|
||||
case 'upload':
|
||||
$category_field = CATEGORY_ROLE_FIELDS['UPLOAD'];
|
||||
break;
|
||||
case 'download':
|
||||
$category_field = CATEGORY_ROLE_FIELDS['DONWLOAD'];
|
||||
break;
|
||||
default:
|
||||
$category_field = CATEGORY_ROLE_FIELDS['ACCESS'];
|
||||
break;
|
||||
|
||||
@ -48,7 +48,6 @@ class ProductController extends FrontController
|
||||
$this->_model->addViewCount($entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
@ -63,4 +62,11 @@ class ProductController extends FrontController
|
||||
$this->_model->where("status", DEFAULTS['STATUS']);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
//Download관련
|
||||
public function download_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('download');
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user