dao = $dao; $this->attachmentCategoryRepository = $attachmentCategoryRepository; } /** * @param array $where * @param int $page * @param int $limit * @return array * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author zfy * @day 2020-04-15 */ public function getList(array $where, int $page, int $limit) { $query = $this->search($where); $count = $query->count($this->dao->getPk()); $list = $query->page($page, $limit)->hidden(['upload_type', 'user_type', 'user_id']) ->select(); return compact('count', 'list'); } /** * @param int $uploadType * @param int $userType * @param int $userId * @param array $data * @return BaseDao|Model * @author zfy * @day 2020-04-15 */ public function create(int $uploadType, int $userType, int $userId, array $data) { $data['upload_type'] = $uploadType; $data['user_type'] = $userType; $data['user_id'] = $userId; return $this->dao->create($data); } /** * @param array $ids * @param int $categoryId * @param int $merId * @return int * @throws DbException * @author zfy * @day 2020-04-16 */ public function batchChangeCategory(array $ids, int $categoryId, $merId = 0) { return $this->dao->batchChange($ids, ['attachment_category_id' => $categoryId], $merId); } public function form(int $id,int $merId) { if ($merId) { $action = 'merchantAttachmentUpdate'; } else { $action = 'systemAttachmentUpdate'; } $formData = $this->dao->get($id)->toArray(); $form = Elm::createForm(Route::buildUrl($action, is_null($id) ? [] : ['id' => $id])->build()); $form->setRule([ Elm::input('attachment_name', '名称')->required(), ]); return $form->setTitle('编辑配置')->formData($formData); } }