Ccjc.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\api\model;
  3. use think\Collection;
  4. use think\Model;
  5. /**
  6. * Created by PhpStorm
  7. * Author: ihavoc
  8. * Date: 2020/11/22
  9. * Time: 16:24
  10. *
  11. */
  12. class Ccjc extends model{
  13. protected $table = 't_ccjc';
  14. protected $pk = 'id';
  15. function undertake()
  16. {
  17. return $this->hasMany('undertake', 'task_id', 'id');
  18. }
  19. function orgs()
  20. {
  21. return $this->hasOne('orgs', 'task_id', 'id');
  22. }
  23. public function selectUndertakeData($where_undertake,$where,$pageNum,$pageSize)
  24. {
  25. $result = Ccjc::hasWhere('undertake', function ($query) use ($where_undertake) {
  26. $query->where($where_undertake);
  27. })->where($where)->page((int)$pageNum,(int)$pageSize)->select();
  28. return $result;
  29. }
  30. public function countUndertakeData($where_undertake,$where)
  31. {
  32. $result = Ccjc::hasWhere('undertake', function ($query) use ($where_undertake) {
  33. $query->where($where_undertake);
  34. })->where($where)->count();
  35. return $result;
  36. }
  37. //查询任务列表数据
  38. public function getInfoByTaskClass($where,$pageNum=1,$pageSize=10)
  39. {
  40. return $this->where($where)->page($pageNum,$pageSize)->select();
  41. }
  42. public function getInfoListCount($where='')
  43. {
  44. return $this->where($where)->select()->count();
  45. }
  46. public function updateInfoByTaskID($task_id,$data)
  47. {
  48. return $this->where('id','=',$task_id)->save($data);
  49. }
  50. //删除任务
  51. public function deleteItemById($task_id)
  52. {
  53. return $this->where('id', '=', $task_id)->delete();
  54. }
  55. //添加任务 返回添加数据的主键id
  56. public function createTask($data)
  57. {
  58. return $this->insertGetId($data);
  59. }
  60. public function getTaskInfoByTaskID($task_id)
  61. {
  62. return $this->where('id','=',$task_id)->find();
  63. }
  64. public function getTaskInfoByModelId($model_id)
  65. {
  66. return $this->where('test_model_id', '=', $model_id)->find();
  67. }
  68. public function updateTaskByArrCondition($arr_condition)
  69. {
  70. if (empty($arr_condition)) {
  71. return false;
  72. }
  73. $result = $this->saveAll($arr_condition);
  74. return $result;
  75. }
  76. }