HouseemailController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace backend\controllers;
  3. use backend\base\CommonController;
  4. use backend\base\Help;
  5. use common\models\HouseEmail;
  6. use Yii;
  7. /**
  8. * 给楼盘设置单独发送的邮箱
  9. * Class HouseemailController
  10. * @package backend\controllers
  11. */
  12. class HouseemailController extends CommonController
  13. {
  14. /**
  15. * @return string
  16. */
  17. public function actionIndex()
  18. {
  19. return $this->render($this->action->id);
  20. }
  21. /**
  22. * 查询数据
  23. * @return mixed
  24. */
  25. public function actionIndexform()
  26. {
  27. $Post = Yii::$app->request->post();
  28. $Model = new HouseEmail();
  29. $List = $Model->getList($Post);
  30. if ($List) {
  31. foreach ($List as &$val) {
  32. $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
  33. }
  34. return Help::JsonData(0, Yii::t('app', 'get_success'), $Model->Total($Post), $List);
  35. }
  36. return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
  37. }
  38. /**
  39. * @return string
  40. */
  41. public function actionAdd()
  42. {
  43. return $this->render($this->action->id);
  44. }
  45. /**
  46. * 添加数据
  47. * @return mixed
  48. */
  49. public function actionAddform()
  50. {
  51. $Model = new HouseEmail();
  52. $Model->scenario = 'add';
  53. if ($Model->load(Yii::$app->request->post(), '') && $Model->save()) {
  54. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
  55. }
  56. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_error'), $Model->errors);
  57. }
  58. /**
  59. * @return string
  60. */
  61. public function actionEdit()
  62. {
  63. $Row = HouseEmail::findOne(Yii::$app->request->get('id'));
  64. if ($Row) {
  65. return $this->render($this->action->id, ['row' => $Row]);
  66. }
  67. }
  68. /**
  69. * 修改数据
  70. * @return mixed
  71. * @throws \Throwable
  72. * @throws \yii\db\StaleObjectException
  73. */
  74. public function actionEditform()
  75. {
  76. $Row = HouseEmail::findOne(Yii::$app->request->post('id'));
  77. $Row->scenario = 'edit';
  78. if ($Row->load(Yii::$app->request->post(), '') && $Row->save()) {
  79. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
  80. }
  81. return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $Row->errors);
  82. }
  83. /**
  84. * 删除数据
  85. * @return mixed
  86. * @throws \Throwable
  87. * @throws \yii\db\StaleObjectException
  88. */
  89. public function actionDelemail()
  90. {
  91. $Row = HouseEmail::findOne(Yii::$app->request->post('id'));
  92. if ($Row->delete()) {
  93. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'del_success'));
  94. }
  95. return Help::JsonCode(Help::ERROR, Yii::t('app', 'del_error'), $Row->errors);
  96. }
  97. }