| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\adminapi\lists\training;
- use app\adminapi\lists\BaseAdminDataLists;
- use app\common\model\goods_category\GoodsCategory;
- use app\common\model\training\TrainingTask;
- use app\common\lists\ListsSearchInterface;
- /**
- * TrainingTask列表
- * Class TrainingTaskLists
- * @package app\adminapi\lists
- */
- class TrainingTaskLists extends BaseAdminDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2025/02/14 17:45
- */
- public function setSearch(): array
- {
- if(isset($this->params['subclass']) && !empty($this->params['subclass'])) $this->params['subclass'] = end($this->params['subclass']);
- return [
- '=' => ['subclass','training_course_id'],
- '%like%' => ['task_name'],
- ];
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2025/02/14 17:45
- */
- public function lists(): array
- {
- $lists = TrainingTask::with(['goodsCategory'])->where($this->searchWhere)->where('master_worker_id',0)
- ->field(['*'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- foreach ($lists as &$item) {
- if($item['goodsCategory']){
- $item['category_id_text'] = $item['goodsCategory']['name'];
- $item['category_two_text'] = GoodsCategory::where('id',$item['goodsCategory']['pid']??0)->value('name')??'';
- $item['category_three_text'] = GoodsCategory::where('id',GoodsCategory::where('id',$item['goodsCategory']['pid'])->value('pid')??0)->value('name')??'';
- }
- }
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2025/02/14 17:45
- */
- public function count(): int
- {
- return TrainingTask::where($this->searchWhere)->count();
- }
- }
|