Setting_model.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * 短信/邮件配置
  4. */
  5. class Setting_model extends CI_Model
  6. {
  7. private $collection_name = 'setting';
  8. public function __construct()
  9. {
  10. parent::__construct();
  11. }
  12. private $model = array(
  13. "setting_id" => "",
  14. "is_sms" => "0",
  15. "sms_type" => "10",
  16. "serial_port" =>"",
  17. "baud_rate" =>"",
  18. "sms_cneter_num" =>"",
  19. "product" => "Dysmsapi",
  20. "access_key_id" => "",
  21. "access_key_secret" => "",
  22. "template_codes" => array(0=>'',1=>'',2=>'',3=>'',4=>'',5=>'',6=>''),
  23. "sign_name"=>"",
  24. "test_phone" =>"",
  25. "is_email" => "0",
  26. "server" => "",
  27. "smtp_secure"=>"",
  28. "port" => "",
  29. "sender" =>"",
  30. "secret_key" => "",
  31. "tester" =>"",
  32. "save_time" =>""
  33. );
  34. /**
  35. * 获取短信/邮箱设置Model
  36. * @return array
  37. */
  38. public function get_model(){
  39. return $this->model;
  40. }
  41. /**
  42. * 获取短信/邮箱设置
  43. * @return mixed
  44. */
  45. public function get_setting(){
  46. $setting = $this->mongo_db->find_one($this->collection_name);
  47. if(!$setting){
  48. $setting = $this->model;
  49. }
  50. return $setting;
  51. }
  52. /**
  53. * 保存短信/邮箱设置
  54. * @param $send_type
  55. * @return mixed
  56. */
  57. public function save_setting($setting){
  58. return $this->mongo_db->insert($this->collection_name,$setting);
  59. }
  60. /**
  61. * 更新短信/邮箱设置
  62. * @param $send_type
  63. * @return mixed
  64. */
  65. public function update_setting($setting){
  66. $data['filter'] = array("setting_id"=>$setting['setting_id']);
  67. $data['update'] = $setting;
  68. return $this->mongo_db->update($this->collection_name,$data);
  69. }
  70. }