@@ -32,11 +32,9 @@ class Baseconfig extends Api
//启动广告图
public function start_advert(){
$info = Db::name('start_advert')->where('is_show',1)->order('id desc')->find();
- if(empty($info)){
- $this->success('success',(object)[]);
- }
+
$info = info_domain_image($info,['image']);
- $this->success('success',$info);
+ $this->success_find('success',$info);
}
//个人资料的一下枚举
@@ -178,6 +178,17 @@ class Api
$this->result($msg, $data, $code, $type, $header);
+ //find查询出来的结果如果为空数组,强制转换object
+ protected function success_find($msg = '', $data = null, $code = 1, $type = null, array $header = [])
+ {
+ if(empty($msg)){
+ $msg = '操作成功';
+ }
+ if(is_null($data) || $data === []){
+ $data = (object)[];
+ $this->result($msg, $data, $code, $type, $header);
/**
* 操作失败返回的数据