BrochureController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Controllers\Api;
  3. use CodeIgniter\HTTP\ResponseInterface;
  4. class BrochureController extends BaseApiController
  5. {
  6. /**
  7. * Get brochure request list
  8. */
  9. public function index()
  10. {
  11. $auth = $this->requireAuth();
  12. if ($auth instanceof ResponseInterface) {
  13. return $auth;
  14. }
  15. $params = $this->getPaginationParams();
  16. $builder = $this->getDB()->table('brochure_requests');
  17. // Search by applicant name
  18. $name = $this->request->getGet('name');
  19. if ($name) {
  20. $builder->like('applicant_name', $name);
  21. }
  22. $builder->orderBy('id', 'DESC');
  23. $result = $this->paginatedResponse($builder, $params);
  24. return $this->respondSuccess($result);
  25. }
  26. /**
  27. * Update brochure request status
  28. */
  29. public function updateStatus($id)
  30. {
  31. $auth = $this->requireAuth();
  32. if ($auth instanceof ResponseInterface) {
  33. return $auth;
  34. }
  35. $json = $this->request->getJSON();
  36. $data = [
  37. 'status' => $json->status ?? '접수',
  38. 'updated_at' => date('Y-m-d H:i:s')
  39. ];
  40. $builder = $this->getDB()->table('brochure_requests');
  41. $builder->where('id', $id)->update($data);
  42. return $this->respondSuccess(null, '상태가 변경되었습니다.');
  43. }
  44. /**
  45. * Delete brochure request
  46. */
  47. public function delete($id = null)
  48. {
  49. $auth = $this->requireAuth();
  50. if ($auth instanceof ResponseInterface) {
  51. return $auth;
  52. }
  53. $builder = $this->getDB()->table('brochure_requests');
  54. $builder->where('id', $id)->delete();
  55. return $this->respondSuccess(null, '브로셔 요청이 삭제되었습니다.');
  56. }
  57. /**
  58. * Export to Excel
  59. */
  60. public function exportExcel()
  61. {
  62. $auth = $this->requireAuth();
  63. if ($auth instanceof ResponseInterface) {
  64. return $auth;
  65. }
  66. // TODO: Implement Excel export logic
  67. return $this->respondSuccess(null, 'Excel export endpoint');
  68. }
  69. }