You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.6 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. /**************************************************************
  5. * FAQ API
  6. *************************************************************/
  7. class Faq extends REST_Controller {
  8. function __construct()
  9. {
  10. parent::__construct();
  11. if( !$this->input->is_ajax_request() ) $this->response(["result"=>FALSE,"message"=>langs('공통/msg/invalid_access')], 400);
  12. }
  13. function info_delete()
  14. {
  15. $this->load->model('faq_model');
  16. $faq_idx = $this->delete('faq_idx', TRUE);
  17. if (empty($faq_idx)) $this->error_return("FAQ 고유키값이 없습니다.", 400);
  18. // 기존 FAQ 값을 불러온다.
  19. $faq = $this->faq_model->get_faq($faq_idx);
  20. $this->db->where('faq_idx', $faq_idx)->set('faq_status','N')->update('faq');
  21. $this->faq_model->update_category_count($faq['fac_idx']);
  22. }
  23. function sort_post()
  24. {
  25. $sort_idx = $this->input->post("sort_idx", TRUE);
  26. for($i=1; $i<=count($sort_idx); $i++)
  27. {
  28. $this->db->where("faq_idx", $sort_idx[$i-1]);
  29. $this->db->set("faq_sort", $i);
  30. $this->db->update("faq");
  31. }
  32. }
  33. function category_get()
  34. {
  35. $this->load->model('faq_model');
  36. $fac_idx = trim($this->get('fac_idx', TRUE));
  37. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  38. $result = $this->faq_model->get_category($fac_idx);
  39. $this->response($result, 200);
  40. }
  41. function category_sort_post()
  42. {
  43. $sort_idx = $this->input->post("sort_idx", TRUE);
  44. for($i=1; $i<=count($sort_idx); $i++)
  45. {
  46. $this->db->where("fac_idx", $sort_idx[$i-1]);
  47. $this->db->set("fac_sort", $i);
  48. $this->db->update("faq_category");
  49. }
  50. }
  51. function category_delete()
  52. {
  53. $fac_idx = $this->delete('fac_idx', TRUE);
  54. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  55. $this->db->where('fac_idx', $fac_idx)->set('fac_status','N')->set('fac_sort','0')->update('faq_category');
  56. $this->db->where('fac_idx', $fac_idx)->set('faq_status','N')->set('faq_sort','0')->update('faq');
  57. }
  58. function lists_get()
  59. {
  60. $this->load->model('faq_model');
  61. $fac_idx = trim($this->get('fac_idx', TRUE));
  62. if (empty($fac_idx)) $this->error_return("FAQ 그룹 고유키값이 없습니다.", 400);
  63. $faq_list = $this->faq_model->get_detail_list($fac_idx);
  64. $this->response($faq_list, 200);
  65. }
  66. }