PesticideListService.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\service;
  3. use app\model\PesticideList;
  4. use think\db\exception\DataNotFoundException;
  5. use think\db\exception\DbException;
  6. use think\db\exception\ModelNotFoundException;
  7. use think\Model;
  8. class PesticideListService
  9. {
  10. public static function addPesticide($info): bool
  11. {
  12. $pesticidelist =new PesticideList();
  13. return $pesticidelist->save($info);
  14. }
  15. public static function deletePesticideList($info): bool
  16. {
  17. return PesticideList::destroy($info['id']);
  18. }
  19. public static function editPesticideListInfo($info,$id): PesticideList
  20. {
  21. return PesticideList::update($info,["id"=>$id]);
  22. }
  23. /**
  24. * @throws ModelNotFoundException
  25. * @throws DataNotFoundException
  26. * @throws DbException
  27. */
  28. public static function getQPesticideList($page, $xzqdm)
  29. {
  30. switch (strlen($xzqdm) ){
  31. case 4:
  32. $map[]=["xzqdm","like",'%'.$xzqdm.'%'];
  33. break;
  34. case 6:
  35. $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
  36. break;
  37. case 9:
  38. $map[] = ["xzqdm","like",'%'.$xzqdm.'%'];
  39. break;
  40. default:
  41. $map[]=[];
  42. }
  43. return (new PesticideList())->where($map)->page($page["page"],$page["size"])->select();
  44. }
  45. }