Commit e9d76e70 authored by 冯超鹏's avatar 冯超鹏

uinapp 查找模块

parent bd897ea1
Pipeline #133 canceled with stages
......@@ -20,16 +20,81 @@ use Validator;
class UinappHomeController extends Controller
{
public function devicedatainfo($id){
public function devicedatainfo($id)
{
$data = DB::table('device as d')
->join('device_type as t','d.dtype','=','t.tid')
->join('gas as g','d.status','=','g.id')
->join('danwei as w','d.devicemonad','=','w.id')
->join('status as s','d.devicepolice','=','s.id')
->join('users as u','d.uid','=','u.id')
->where('d.id','=',$id)
->select('d.*','t.tname','g.gas','w.danwei','s.status_name','u.username as nameh','u.isadmin')
->join('device_type as t', 'd.dtype', '=', 't.tid')
->join('gas as g', 'd.status', '=', 'g.id')
->join('danwei as w', 'd.devicemonad', '=', 'w.id')
->join('status as s', 'd.devicepolice', '=', 's.id')
->join('users as u', 'd.uid', '=', 'u.id')
->where('d.id', '=', $id)
->select('d.*', 't.tname', 'g.gas', 'w.danwei', 's.status_name', 'u.username as nameh', 'u.isadmin')
->first();
return $this->jsonSuccessData($data);
}
//获取模糊查询设备
public function imitation(Request $request)
{
$imitationdata = $request->input('imitationdata');
if ($this->isKanji($imitationdata)) {
$data = DB::table('device as d')
->join('device_type as t', 'd.dtype', '=', 't.tid')
->join('gas as g', 'd.status', '=', 'g.id')
->join('danwei as w', 'd.devicemonad', '=', 'w.id')
->join('status as s', 'd.devicepolice', '=', 's.id')
->join('users as u', 'd.uid', '=', 'u.id')
->where('d.username', 'like', '%' . $imitationdata . '%')
->select('d.*', 't.tname', 'g.gas', 'w.danwei', 's.status_name', 'u.username as nameh', 'u.isadmin')
->get();
} else {
$data = DB::table('device as d')
->join('device_type as t', 'd.dtype', '=', 't.tid')
->join('gas as g', 'd.status', '=', 'g.id')
->join('danwei as w', 'd.devicemonad', '=', 'w.id')
->join('status as s', 'd.devicepolice', '=', 's.id')
->join('users as u', 'd.uid', '=', 'u.id')
->where('d.devicenum', 'like', '%' . $imitationdata . '%')
->select('d.*', 't.tname', 'g.gas', 'w.danwei', 's.status_name', 'u.username as nameh', 'u.isadmin')
->get();
}
return $this->jsonSuccessData($data);
}
//指定查询
public function setseachdata (Request $request){
$setdata = $request->input('setseachdata');
if ($this->isKanji($setdata)){
$data = DB::table('device as d')
->join('device_type as t', 'd.dtype', '=', 't.tid')
->join('gas as g', 'd.status', '=', 'g.id')
->join('danwei as w', 'd.devicemonad', '=', 'w.id')
->join('status as s', 'd.devicepolice', '=', 's.id')
->join('users as u', 'd.uid', '=', 'u.id')
->where('d.username','=',$setdata)
->select('d.*', 't.tname', 'g.gas', 'w.danwei', 's.status_name', 'u.username as nameh', 'u.isadmin')
->first();
}else{
$data = DB::table('device as d')
->join('device_type as t', 'd.dtype', '=', 't.tid')
->join('gas as g', 'd.status', '=', 'g.id')
->join('danwei as w', 'd.devicemonad', '=', 'w.id')
->join('status as s', 'd.devicepolice', '=', 's.id')
->join('users as u', 'd.uid', '=', 'u.id')
->where('d.devicenum','=',$setdata)
->select('d.*', 't.tname', 'g.gas', 'w.danwei', 's.status_name', 'u.username as nameh', 'u.isadmin')
->first();
}
return $this->jsonSuccessData($data);
}
//监测是否是汉子
private function isKanji($str)
{
if (preg_match("/^[" . chr(0x80) . "-" . chr(0xff) . "] $/", $str)) {
return true;
} else {
return false;
}
}
}
\ No newline at end of file
......@@ -123,6 +123,9 @@ Route::group(['middleware'=>'auth:api'],function (){
//uinapp 接口
Route::group(['middleware'=>'auth:api'],function (){
Route::get('huinapphome/devicedatainfo/{id}','UinappHomeController@devicedatainfo');//设备详情
Route::post('huinapphome/imitation','UinappHomeController@imitation');//模糊查询
Route::post('huinapphome/setseachdata','UinappHomeController@setseachdata');//指定查询
});
// Fake APIs
Route::get('/table/list', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment