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.

97 lines
3.1 KiB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class Management extends REST_Controller
  5. {
  6. /**
  7. * 팝업 목록
  8. */
  9. function popups_get() {
  10. $page_rows = $this->input->get('take', TRUE, 15);
  11. $start = $this->input->get('skip', TRUE);
  12. $this->db
  13. ->select('SQL_CALC_FOUND_ROWS P.*, M.mem_nickname AS upd_username', FALSE)
  14. ->from('popup AS P')
  15. ->join('member AS M','M.mem_idx=P.upd_user','inner')
  16. ->where('pop_status', 'Y')
  17. ->order_by('pop_idx DESC')
  18. ->limit($page_rows, $start);
  19. $result = $this->db->get();
  20. $return['lists'] = $result->result_array();
  21. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  22. foreach($return['lists'] as $i=>&$row)
  23. {
  24. $row['nums'] = $return['totalCount'] - $i - $start;
  25. $row['pop_state'] = (strtotime($row['pop_start']) <= time() && strtotime($row['pop_end']) >= time())?'표시중':'미표시중';
  26. }
  27. $this->response($return, 200);
  28. }
  29. /**
  30. * 팝업 삭제
  31. */
  32. function popups_delete()
  33. {
  34. $pop_idx = $this->delete('pop_idx', TRUE);
  35. $mem_idx = $this->member->is_login();
  36. if(empty($pop_idx)) $this->response('잘못된 접근입니다.', 400);
  37. $data['upd_datetime'] = date('Y-m-d H:i:s');
  38. $data['upd_user'] = $mem_idx;
  39. $data['pop_status'] = 'N';
  40. $this->db->where('pop_idx', $pop_idx);
  41. $this->db->update('popup', $data);
  42. }
  43. /**
  44. * 사이트맵 목록
  45. */
  46. function sitemaps_get()
  47. {
  48. $page_rows = $this->input->get('take', TRUE, 15);
  49. $start = $this->input->get('skip', TRUE);
  50. $this->db
  51. ->select('SQL_CALC_FOUND_ROWS S.*, M.mem_nickname AS upd_username', FALSE)
  52. ->from('sitemap AS S')
  53. ->join('member AS M','M.mem_idx=S.upd_user','inner')
  54. ->order_by('sit_idx DESC')
  55. ->limit($page_rows, $start);
  56. $result = $this->db->get();
  57. $return['lists'] = $result->result_array();
  58. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  59. $this->response($return, 200);
  60. }
  61. function sitemaps_delete()
  62. {
  63. $sit_idx = $this->delete('sit_idx', TRUE);
  64. if(empty($sit_idx)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  65. $this->db->where('sit_idx', $sit_idx)->delete('sitemap');
  66. }
  67. /**
  68. * 공용 에디트
  69. */
  70. function updates_post()
  71. {
  72. $table = $this->post('table', TRUE);
  73. $key_column = $this->post('key_column', TRUE);
  74. $key = $this->post('key', TRUE);
  75. $values = $this->post('values', TRUE);
  76. if(empty($table) OR empty($key_column) OR empty($key)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  77. $values['upd_datetime'] = date('Y-m-d H:i:s');
  78. $values['upd_user'] = $this->member->is_login();
  79. $this->db->where($key_column, $key);
  80. $this->db->update($table, $values);
  81. }
  82. }