12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\api\model;
- use think\Collection;
- use think\Model;
- /**
- * Created by PhpStorm
- * Author: ihavoc
- * Date: 2020/11/22
- * Time: 16:24
- *
- */
- class Ccjc extends model{
- protected $table = 't_ccjc';
- protected $pk = 'id';
- function undertake()
- {
- return $this->hasMany('undertake', 'task_id', 'id');
- }
- function orgs()
- {
- return $this->hasOne('orgs', 'task_id', 'id');
- }
- public function selectUndertakeData($where_undertake,$where,$pageNum,$pageSize)
- {
- $result = Ccjc::hasWhere('undertake', function ($query) use ($where_undertake) {
- $query->where($where_undertake);
- })->where($where)->page((int)$pageNum,(int)$pageSize)->select();
- return $result;
- }
- public function countUndertakeData($where_undertake,$where)
- {
- $result = Ccjc::hasWhere('undertake', function ($query) use ($where_undertake) {
- $query->where($where_undertake);
- })->where($where)->count();
- return $result;
- }
- //查询任务列表数据
- public function getInfoByTaskClass($where,$pageNum=1,$pageSize=10)
- {
- return $this->where($where)->page($pageNum,$pageSize)->select();
- }
- public function getInfoListCount($where='')
- {
- return $this->where($where)->select()->count();
- }
- public function updateInfoByTaskID($task_id,$data)
- {
- return $this->where('id','=',$task_id)->save($data);
- }
- //删除任务
- public function deleteItemById($task_id)
- {
- return $this->where('id', '=', $task_id)->delete();
- }
- //添加任务 返回添加数据的主键id
- public function createTask($data)
- {
- return $this->insertGetId($data);
- }
- public function getTaskInfoByTaskID($task_id)
- {
- return $this->where('id','=',$task_id)->find();
- }
- public function getTaskInfoByModelId($model_id)
- {
- return $this->where('test_model_id', '=', $model_id)->find();
- }
- public function updateTaskByArrCondition($arr_condition)
- {
- if (empty($arr_condition)) {
- return false;
- }
- $result = $this->saveAll($arr_condition);
- return $result;
- }
- }
|