Tool.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\middleware\Auth;
  5. use app\admin\model\Notice as NoticeModel;
  6. use think\facade\Db;
  7. /**
  8. * Description of Tool
  9. *
  10. * @author sgq
  11. */
  12. class Tool extends BaseController {
  13. //protected $middleware = [Auth::class];
  14. public function findChildDictBatch() {
  15. $result = [];
  16. for ($i = 0; $i < count($this->request->param()); $i++) {
  17. if ($obj = $this->request->param($i)) {
  18. $code = $obj["code"];
  19. $dict = \app\common\model\Dict::where("code", $code)->findOrEmpty()->toArray();
  20. $childs = \app\common\model\Dict::where("pid", $dict["id"])->order("num")->select();
  21. $result[$obj["name"]] = $childs;
  22. }
  23. }
  24. return json(["code" => "200", "msg" => "", "obj" => $result]);
  25. }
  26. public function findCommonFileType() {
  27. }
  28. public function getProvinceSelect() {
  29. $where = [];
  30. $where[] = ["code", "like", "%0000"];
  31. return json(Db::table("un_common_location")->where($where)->select()->toArray());
  32. }
  33. public function findCityByProvinceSelect() {
  34. $code = $this->request->param("code");
  35. $province_prefix = substr($code, 0, 2);
  36. return json(Db::table("un_common_location")->where("code", "like", $province_prefix . "%00")->select()->toArray());
  37. }
  38. public function findCountyByCitySelect() {
  39. $code = $this->request->param("code");
  40. $city_prefix = substr($code, 0, 4);
  41. return json(Db::table("un_common_location")->where("code", "like", $city_prefix . "%")->select()->toArray());
  42. }
  43. }