123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- namespace app\common\dao\system\config;
- use app\common\dao\BaseDao;
- use app\common\model\BaseModel;
- use app\common\model\system\config\SystemConfigClassify;
- use think\Collection;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\Model;
- class SystemConfigClassifyDao extends BaseDao
- {
-
- protected function getModel(): string
- {
- return SystemConfigClassify::class;
- }
-
- public function getOptions()
- {
- return SystemConfigClassify::column('pid,classify_name', 'config_classify_id');
- }
-
- public function getTopOptions()
- {
- return SystemConfigClassify::getDB()->where('pid', 0)->column('classify_name', 'config_classify_id');
- }
-
- public function all()
- {
- return SystemConfigClassify::getDB()->select();
- }
-
- public function count()
- {
- return SystemConfigClassify::getDB()->count();
- }
-
- public function children(int $pid, string $field = 'id,classify_name')
- {
- return SystemConfigClassify::getDB()->where('pid', $pid)->field($field)->select();
- }
-
- public function existsChild(int $id): bool
- {
- return $this->fieldExists('pid', $id);
- }
-
- public function keyExists($key, ?int $except = null): bool
- {
- return $this->fieldExists('classify_key', $key, $except);
- }
-
- public function pidExists(int $pid, ?int $except = null): bool
- {
- return $this->fieldExists('config_classify_id', $pid, $except);
- }
-
- public function keyById(string $key)
- {
- return SystemConfigClassify::getDB()->where('classify_key', $key)->value('config_classify_id');
- }
-
- public function keyByData(string $key)
- {
- return SystemConfigClassify::getDB()->where('classify_key', $key)->find();
- }
- }
|