['name'], ]; } /** * @notes 查看商城公告列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author ljj * @date 2021/8/23 2:12 下午 */ public function lists(): array { $lists = ShopNotice::field('id,name,image,views,likes,status,sort,create_time') ->append(['status_desc']) ->where($this->searchWhere) ->order('id','desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); return $lists; } /** * @notes 查看商城公告总数 * @return int * @author ljj * @date 2021/8/23 2:11 下午 */ public function count(): int { return ShopNotice::where($this->searchWhere)->count(); } /** * @notes 设置导出字段 * @return string[] * @author ljj * @date 2021/8/23 2:26 下午 */ public function setExcelFields(): array { return [ // '数据库字段名(支持别名) => 'Excel表字段名' 'id' => 'ID', 'name' => '公告标题', 'views' => '浏览量', 'likes' => '点赞量', 'status_desc' => '公告状态', 'sort' => '排序', 'create_time' => '创建时间', ]; } /** * @notes 设置默认表名 * @return string * @author ljj * @date 2021/8/23 2:27 下午 */ public function setFileName(): string { return '商城公告'; } }