123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- declare (strict_types=1);
- namespace app\dao\system\attachment;
- use app\dao\BaseDao;
- use app\model\system\attachment\SystemAttachment;
- class SystemAttachmentDao extends BaseDao
- {
-
- protected function setModel(): string
- {
- return SystemAttachment::class;
- }
-
- public function search(array $where = [])
- {
- return parent::search($where)->when(isset($where['name']) && $where['name']!='', function ($query) use ($where) {
- $query->where('att_id|real_name|name', 'LIKE', '%' . trim($where['name']) . '%');
- });
- }
-
- public function getList(array $where, int $page, int $limit)
- {
- return $this->search($where)->where('module_type', 1)->page($page, $limit)->order('att_id DESC')->select()->toArray();
- }
-
- public function move(array $data)
- {
- return $this->getModel()->whereIn('att_id', $data['images'])->update(['pid' => $data['pid']]);
- }
-
- public function getLikeNameList(array $where, int $page, int $limit)
- {
- return $this->search($where)->page($page, $limit)->order('att_id desc')->select()->toArray();
- }
-
- public function getYesterday(int $type = 1, $relationId = 0)
- {
- return $this->getModel()->where('type', $type)->when($relationId, function ($query) use ($relationId) {
- $query->where('relation_id', $relationId);
- })->whereTime('time', 'yesterday')->where('module_type', 2)->field(['name', 'att_dir', 'att_id', 'image_type'])->select();
- }
-
- public function delYesterday()
- {
- $this->getModel()->whereTime('time', 'yesterday')->where('module_type', 2)->delete();
- }
-
- public function scanUploadImage($scan_token)
- {
- return $this->getModel()->where('scan_token', $scan_token)->field('att_dir,att_id')->select()->toArray();
- }
- }
|