123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shaoguo
- * Date: 2020/4/24
- * Time: 3:31 PM
- */
- namespace app\web\controller;
- use model\Community;
- use model\HouseInfo;
- use model\UserInfo;
- use service\DepartmentService;
- use service\HouseMemberService;
- use service\HouseService;
- use service\PositionService;
- use think\Controller;
- use think\helper\Arr;
- class CommonController extends Controller
- {
- public function province(){
- return json([
- 'code'=>200,
- 'data'=>db('provinces')->where(['code'=>"32"])->field('code,name')->select()
- ]);
- }
- public function city(){
- $code=$this->request->param('code');
- return json([
- 'code'=>200,
- 'data'=>db('cities')->where('province_code',$code)->where('code',3205)->field('code,name')->select()
- ]);
- }
- public function area(){
- $code=$this->request->param('code');
- return json([
- 'code'=>200,
- 'data'=>db('areas')->where('city_code',$code)->field('code,name')->select()
- ]);
- }
- public function street(){
- $code=$this->request->param('code');
- return json([
- 'code'=>200,
- 'data'=>db('streets')->where('area_code',$code)->field('code,name')->select()
- ]);
- }
- public function village(){
- $code=$this->request->param('code');
- return json([
- 'code'=>200,
- 'data'=>db('villages')->where('street_code',$code)->field('code,name')->select()
- ]);
- }
- public function community(){
- $data=$this->request->get();
- $where[]=array('is_delete','=',0);
- if(isset($data['code']) && !empty($data['code'])){
- $where[]=['province_code|city_code|areas_code|street_code|village_code','=',$data['code']];
- }
- if(isset($data['id']) && !empty($data['id']))$where[]=['id','=',$data['id']];
- $communities=Community::where($where)->select();
- return json([
- 'code'=>200,
- 'data'=>$communities
- ]);
- }
- /**
- * @name 获取家庭
- */
- public function getHouse(){
- $where[]=['House.is_delete','=',0];
- $data=$this->request->param();
- if(isset($data['keyword']) && !empty($data['keyword'])){
- $where[]=['House.name','like','%'.$data['keyword'].'%'];
- }
- $lists=HouseService::get($where,"id,name",['House.create_time'=>'desc'],'',true);
- $count=HouseService::get($where,"id,name",['House.create_time'=>'desc'])->count();
- $result['item']=$lists->items();
- $result['count']=$count;
- $result = [
- 'code' => 1,
- 'msg' => 'ok',
- 'time' => time(),
- 'data' => $result,
- ];
- return json($result,200);
- }
- /**
- * @name 获取家庭
- */
- public function getInfo(){
- $where[]=['is_delete','=',0];
- $data=$this->request->param();
- if(isset($data['keyword']) && !empty($data['keyword'])){
- $where[]=['name','like','%'.$data['keyword'].'%'];
- }
- $lists=HouseMemberService::get($where,"user_id as id,name",['create_time'=>'desc'],true);
- $count=HouseMemberService::get($where,"user_id as id,name",['create_time'=>'desc'])->count();
- $result['item']=$lists->items();
- $result['count']=$count;
- $result = [
- 'code' => 1,
- 'msg' => 'ok',
- 'time' => time(),
- 'data' => $result,
- ];
- return json($result,200);
- }
- /**
- * @name 获取员工
- */
- public function user_info(){
- $with_where=array();
- $data=$this->request->param();
- if(isset($data['id']) && !empty($data['id']))$with_where[]=['pivot.department_id','=',$data['id']];
- $userinfos=DepartmentService::getOne([['id','=',$data['id']]])->userInfo;
- $result = [
- 'code' => 1,
- 'msg' => 'ok',
- 'time' => time(),
- 'data' => $userinfos,
- ];
- return json($result,200);
- }
- public function position(){
- $id=$this->request->param('id');
- $where=array(['delete_time','=',0]);
- if(!empty($id)){
- $where[]=['id','in',$id];
- }
- $positions=PositionService::get($where);
- $result = [
- 'code' => 1,
- 'msg' => 'ok',
- 'time' => time(),
- 'data' => $positions,
- ];
- return json($result,200);
- }
- }
|