Undertake.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/13
  6. */
  7. namespace app\api\model;
  8. use think\Model;
  9. class Undertake extends Model
  10. {
  11. public function insert(array $data = [], bool $getLastInsID = false)
  12. {
  13. return parent::insert($data, $getLastInsID); // TODO: Change the autogenerated stub
  14. }
  15. public function deleteInfoByID($id_arr)
  16. {
  17. return $this->select($id_arr)->delete();
  18. }
  19. public function selectUndertakeInfoByTaskIdAndUnitId($task_id,$unit_id='',$bear_id='',$report_id='',$pageNum=1,$pageSize=null)
  20. {
  21. $where=[
  22. ['task_id', '=', $task_id],
  23. ];
  24. if ($unit_id!='') {
  25. array_push($where, ['unit_id', '=', $unit_id]);
  26. }
  27. if ($bear_id!='') {
  28. array_push($where, ['bear_id', '=', $bear_id]);
  29. }
  30. if ($report_id!='') {
  31. array_push($where,['report_id', '=', $report_id]);
  32. }
  33. return $this->where($where)->page($pageNum,$pageSize)->select();
  34. }
  35. public function countUndertakeInfoByTaskIdAndUnitId($task_id,$unit_id='',$bear_id='',$report_id='')
  36. {
  37. $where=[
  38. ['task_id', '=', $task_id],
  39. ];
  40. if ($unit_id != '') {
  41. array_push($where, ['unit_id', '=', $unit_id]);
  42. }
  43. if ($bear_id != '') {
  44. array_push($where, ['bear_id', '=', $bear_id]);
  45. }
  46. if ($report_id != '') {
  47. array_push($where,['report_id', '=', $report_id]);
  48. }
  49. return $this->where($where)->count();
  50. }
  51. }