toData('400', '参错错误'); } $where =[]; if (!empty($param['name'])) { $where['name'] = $param['name']; } $list = ConfigModel::where($where)->order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); return $this->toData('0', 'SUCCESS', [ 'list' => $list->items(), 'total' => $list->total(), 'page' => $list->currentPage(), 'last_page' => $list->lastPage(), ]); } catch (\Exception $e) { return $this->toData('500', '系统错误', [$e->getMessage(), $e->getTrace()]); } } // 获取邮箱模板列表 public function emailTemplateList($param) { try { if (empty($param['page']) || !is_numeric($param['page'])) { return $this->toData('400', '参错错误'); } if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('400', '参错错误'); } $where = []; if (isset($param['tpl_type'])) { $where['tpl_type'] = $param['tpl_type']; } $list = EmailTemplateModel::where($where)->order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); return $this->toData('0', 'SUCCESS', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码 'total' => $list->total(), // 总记录数 'last_page' => $list->lastPage(), // 最后一页页码 ]); } catch (\Exception $e) { return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]); } } // 编辑邮箱模板 public function editEmailTemplate($param) { try { if (empty($param['id']) || !is_numeric($param['id'])) { return $this->toData('400', '参错错误'); } if (empty($param['title']) || empty($param['content'])) { return $this->toData('400', '参错错误'); } $emailTemplate = EmailTemplateModel::where(['id'=>$param['id']])->find(); if (empty($emailTemplate)) { return $this->toData('500', '修改的模板数据不存在'); } $emailTemplate->email = $param['email'] ?? ""; $emailTemplate->title = $param['title']; $emailTemplate->content = $param['content']; $emailTemplate->save(); return $this->toData('0', 'success'); } catch (\Exception $e) { return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]); } } // 短息模板列表 public function smsTemplateList($param) { try { if (empty($param['page']) || !is_numeric($param['page'])) { return $this->toData('400', '参错错误'); } if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('400', '参错错误'); } $where = []; if (isset($param['tpl_type'])) { $where['tpl_type'] = $param['tpl_type']; } $list = SmsTemplateModel::where($where)->order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); return $this->toData('0', 'SUCCESS', [ 'list' => $list->items(), 'page' => $list->currentPage(), 'total' => $list->total(), 'last_page' => $list->lastPage(), ]); } catch (\Exception $e) { return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]); } } // 编辑短信模板 public function editSmsTemplate($param) { try { if (empty($param['id']) || !is_numeric($param['id'])) { return $this->toData('400', '参错错误'); } if (empty($param['content'])) { return $this->toData('400', '参错错误'); } $smsTemplate = SmsTemplateModel::where(['id'=>$param['id']])->find(); if (empty($smsTemplate)) { return $this->toData('500', '修改的模板数据不存在'); } $smsTemplate->content = $param['content']; $smsTemplate->save(); return $this->toData('0', 'success'); } catch (\Exception $e) { return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]); } } }