1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\service;
- use app\model\Base;
- use think\console\command\Lists;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- class BaseService
- {
- public static function getBaseInfoByQydm($page,$qydm){
- $map[] =["qydm","=",$qydm];
- $res["row"]=Base::where($map)->page($page["page"],$page["size"])->field("t_base.*,x.xzqmc as cityname,e.xzqmc as countyname,f.xzqmc as townsname")->leftJoin("t_zd_xzq x","t_base.city=x.xzqdm")->leftJoin("t_zd_xzq e","t_base.county=e.xzqdm")->leftJoin("t_zd_xzq f","t_base.towns=f.xzqdm")->select();
- $res["count"]=Base::where($map)->count();
- return $res;
- }
- /**
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- */
- public static function getBaseInfoById($id){
- return (new Base)->field("t_base.*,x.xzqmc as cityname,e.xzqmc as countyname,f.xzqmc as townsname")->where("t_base.id",$id)->leftJoin("t_zd_xzq x","t_base.city=x.xzqdm")->leftJoin("t_zd_xzq e","t_base.county=e.xzqdm")->leftJoin("t_zd_xzq f","t_base.towns=f.xzqdm")->find();
- }
- public static function editBaseInfo($info,$id): Base
- {
- return Base::update($info,["id"=>$id]);
- }
- public static function addBase($info): bool
- {
- return (new Base)->save($info);
- }
- public static function delBase($id): bool
- {
- return Base::destroy($id);
- }
- }
|