Index.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace plugin\ali_sms\controller;
  3. use laytp\controller\Backend;
  4. use plugin\ali_sms\model\AliSms;
  5. /**
  6. * 邮件管理
  7. */
  8. class Index extends Backend
  9. {
  10. /**
  11. * email模型对象
  12. * @var \plugin\email\model\Email
  13. */
  14. protected $model;
  15. protected $hasSoftDel=1;//是否拥有删除功能
  16. public function _initialize()
  17. {
  18. $this->model = new AliSms();
  19. }
  20. //设置状态
  21. public function setStatus()
  22. {
  23. $id = $this->request->post('id');
  24. $fieldVal = $this->request->post('field_val');
  25. $isRecycle = $this->request->post('is_recycle');
  26. $update['status'] = $fieldVal;
  27. try {
  28. if($isRecycle) {
  29. $updateRes = $this->model->onlyTrashed()->where('id', '=', $id)->update($update);
  30. } else {
  31. $updateRes = $this->model->where('id', '=', $id)->update($update);
  32. }
  33. if ($updateRes) {
  34. return $this->success('操作成功');
  35. } else if ($updateRes === 0) {
  36. return $this->success('未作修改');
  37. } else {
  38. return $this->error('操作失败');
  39. }
  40. } catch (\Exception $e) {
  41. return $this->error('数据库异常,操作失败');
  42. }
  43. }
  44. }