[ 'status'], '%like%'=>['title'], ]; } /** * @notes 地址信息列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author ljj * @date 2022/2/16 3:18 下午 */ public function lists(): array { $lists = (new AssetArea())->field('id,title,create_time') ->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->Order('sort desc') ->select() ->toArray(); return $lists; } /** * @notes 地址信息数量 * @return int * @author ljj * @date 2022/2/16 3:18 下午 */ public function count(): int { return (new AssetArea())->where($this->searchWhere)->count(); } /** * @notes 添加地址 * @param array $params * @author heshihu * @date 2022/2/22 9:57 */ public static function add(array $params) { AssetArea::create([ 'title' => $params['title'], 'sort' => $params['sort']??0 ]); } /** * @notes 编辑地址 * @param array $params * @return bool * @author heshihu * @date 2022/2/22 10:12 */ public static function edit(array $params) : bool { try { AssetArea::update([ 'id' => $params['id'], 'title' => $params['title'], 'sort' => $params['sort']??0 ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } /** * @notes 删除地址 * @param array $params * @author heshihu * @date 2022/2/22 10:17 */ public static function delete(array $params) { AssetArea::destroy($params['id']); } /** * @notes 查看地址详情 * @param $params * @return array * @author heshihu * @date 2022/2/22 10:15 */ public static function detail($params) : array { return AssetArea::findOrEmpty($params['id'])->toArray(); } public static function updateStatus(array $params) { AssetArea::update([ 'id' => $params['id'], 'status' => $params['status'] ]); return true; } }