Commit 0ad2c7df authored by 冯超鹏's avatar 冯超鹏

提交新功能

parent 9eac874d
Pipeline #23 canceled with stages
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class swoole extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class SwooleCommandController {
}
\ No newline at end of file
......@@ -67,7 +67,7 @@ class DevicesController extends Controller
}
}
//返回逻辑删除的设备
//返回逻辑删除的设备和修复设备
public function physicsdelete(Request $request){
$deviceid = $request->input('deviceid');
$databadevice = DB::table('device');
......@@ -109,7 +109,35 @@ class DevicesController extends Controller
$type = new Device();
return $this->jsonSuccessData($type->adddevice($request->all()));
}
//编辑设备
public function updatedevice(Request $request){
$deid = $request->input('deid');
$data = $request->all();
if(is_null($deid)){
return $this->jsonErrorData(105,'设备ID不能为空');
}
if ($_POST){
$validator = Validator::make($request->all(), $this->getValidationRulesupdevice(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
foreach ($data as $k=>$v){
if ($k == 'deid') {
unset($data[$k]);
}
}
return $this->jsonSuccessData(Device::where('id','=',$deid)->update($data));
}else{
$devi = DB::table('device as de')
->where('de.id','=',$deid)
->leftjoin('device_type as dt','de.dtype','=','dt.tid')
->leftjoin('gas','de.status','=','gas.id')
->leftjoin('danwei as da','de.devicemonad','=','da.id')
->select('dt.*','gas.*','da.*','de.*')
->first();
return $this->jsonSuccessData($devi);
}
}
//返回设备类型和单位和介质
public function devicetype(){
$databadevice = DB::table('device_type')->get();
......@@ -132,7 +160,10 @@ class DevicesController extends Controller
->get()->toArray();
return $devicelist;
}
//批量上传设备
public function batchdevice(){
}
/**
* @param bool $isNew
......@@ -150,7 +181,27 @@ class DevicesController extends Controller
'status'=>'required',
'devicemonad'=>'required',
'deviceremark'=>'sometimes|required|max:15',
'devicecoord'=>'sometimes|required'
'devicecoord'=>'sometimes|required',
'contactsid'=>'sometimes|required',//绑定联系人id
'deviceinfo'=>'sometimes|required',
'devicenumber'=>'required|unique:device,devicenumber|max:40'
];
}
//更新设备列表
private function getValidationRulesupdevice($isNew = true)
{
return [
'username'=>'sometimes|required|unique:device,username|max:40',//设备名称
'devicephone'=> 'sometimes|required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman'=>'sometimes|required|max:15',
'dtype'=>'sometimes|required',
'status'=>'sometimes|required',
'devicemonad'=>'sometimes|required',
'deviceremark'=>'sometimes|required|max:15',//备注
'devicecoord'=>'sometimes|required',
'contactsid'=>'sometimes|required',//绑定联系人id
'deviceinfo'=>'sometimes|required',
'devicenumber'=>'sometimes|required|unique:device,devicenumber|max:40'
];
}
......
......@@ -31,8 +31,53 @@ class InstallerController extends Controller
$type = new Installer();
return $this->jsonSuccessData($type->addinstall($request->all()));
}
//更新用户操作
public function updateinstaller(Request $request){
$uid = $request->input('uid');//用户id
$data = $request->all();
if (is_null($uid)){
return $this->jsonErrorData(105,'用户id不能为空');
}
if ($_POST){
foreach ($data as $k => $v) {
if ($k == 'uid') {
unset($data[$k]);
}
}
$upin = Installer::where('id','=',(int)$uid)->update($data);
if($upin !== false){
return $this->jsonSuccessData($upin);
}
return $this->jsonErrorData(105,'更新失败');
}else{
return $this->jsonSuccessData(Installer::where('id','=',$uid)->first());
}
}
/*
*删除用户
* type 1== 物理 2==逻辑删除
* */
public function deleteinstaller(Request $request){
$type = $request->input('type');
$uid = $request->input('uid');
if(is_null($type)){
return $this->jsonErrorData(105,'type不能为空');
}
if (is_null($uid)){
return $this->jsonErrorData(105,'uid不能为空');
}
if ($type == 1){//物理删除
return $this->jsonSuccessData(Installer::where('id','=',$uid)->delete());
}elseif($type == 2){//逻辑删除
return $this->jsonSuccessData(Installer::where('id','=',$uid)->update(['delete'=>2]));
}
}
//验证用户提交表单
private function getValidationRulesinstaller($isNew = true){
return [
'username'=>'required|unique:installer,username|max:3',
......
......@@ -260,6 +260,12 @@ class UserController extends Controller
{
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
if(is_null($pagenNum)){
return $this->jsonErrorData(105,'page不能为空');
}
if(is_null($limit)){
return $this->jsonErrorData(105,'limt不能为空');
}
$users = DB::table('BackgroundUser as b')
->where('b.state', '=', '2')
->join('areachina as p', 'b.provinceid', '=', 'p.areaid')
......@@ -415,6 +421,34 @@ class UserController extends Controller
$isadmin = DB::table('contactsuser')->insert($data);
return $this->jsonSuccessData($isadmin);
}
//查看所有逻辑删除用户 和禁用用户
public function deupuser(Request $request){
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
if(is_null($pagenNum)){
return $this->jsonErrorData(105,'page不能为空');
}
if(is_null($limit)){
return $this->jsonErrorData(105,'limt不能为空');
}
$users = DB::table('BackgroundUser as b')
->where('b.state', '!=', '2')
->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid')
->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid')
->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid')
->orderBy('b.id', 'desc')
->select('b.username', 'b.state','b.nickname', 'b.email', 'b.state', 'a.area_name as area', 'c.area_name as city', 'p.area_name as province')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
if ($users) {
return $this->jsonSuccessData($users);
} else {
return $this->jsonErrorData(105, '获取失败');
}
}
/*
* 返回当前登入的联系人列表
* */
......
......@@ -13,12 +13,25 @@ class Installer extends Authenticatable
public $timestamps = false;
//添加装维人员
public function addinstall($data = []) : string {
$stringrand = $this->numsigng();
foreach ($data as $k => $value) {
if (is_null($k)) {
return '用户提交表单参数错误';
}
}
$datadevice['addtime'] = time();
return $this->insertGetId($datadevice);
$data['addtime'] = time();
$data['password'] = md5(md5($data['password']) . $stringrand);
$data['salt'] = $stringrand;
return $this->insertGetId($data);
}
//生成随机字符串
private function numsigng() : int{
$code = '';
for ($i=1;$i<7;$i++) {
$randcode = mt_rand(0,9);
$code .= $randcode;
}
return (int)$code;
}
}
\ No newline at end of file
......@@ -27,7 +27,8 @@
"laravel/tinker": "^2.0",
"league/flysystem-aws-s3-v3": "^1.0",
"predis/predis": "^1.1",
"spatie/laravel-permission": "^3.0"
"spatie/laravel-permission": "^3.0",
"swooletw/laravel-swoole": "^2.6"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
......
This diff is collapsed.
......@@ -174,7 +174,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
SwooleTW\Http\LaravelServiceProvider::class,
],
/*
......
......@@ -34,7 +34,8 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::match(['get','post'],'user/Upuser','UserController@Upuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新用户
Route::match(['get','post'],'user/areachina','UserController@areachina')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//获取地址列表
Route::post('user/addcontactsuser','UserController@addcontactsuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//添加联系人
Route::get('user/contactslist','UserController@contactslist');
Route::get('user/contactslist','UserController@contactslist');//返回当前登入的联系人列表
Route::get('user/deupuser','UserController@deupuser');//返回当前登入的联系人列表
});
//设备路由
......@@ -43,13 +44,17 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/devicetype','DevicesController@devicetype');//设备类型
Route::post('devices/deletedecice','DevicesController@deletedecice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除设备
Route::post('devices/adddevice','DevicesController@adddevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//新增设备
Route::match(['get','post'],'device/physicsdelete','DevicesController@physicsdelete')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
Route::match(['get','post'],'devices/physicsdelete','DevicesController@physicsdelete')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
Route::match(['get','post'],'devices/updatedevice','DevicesController@updatedevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新设备
});
//装维中心
Route::group(['middleware'=>'auth:api'],function (){
Route::get('installer/installerlist','InstallerController@installerlist');//装维人员列表
Route::post('installer/addinstaller','InstallerController@addinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//添加新的装维人员
Route::match(['get','post'],'installer/updateinstaller','InstallerController@updateinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
Route::get('installer/deleteinstaller','InstallerController@deleteinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除用户
});
// 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