202 lines
6.4 KiB
PHP
Executable File
202 lines
6.4 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lock
|
|
* Date: 2021/7/30
|
|
* Time: 9:11 AM
|
|
*/
|
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
use app\common\classLibrary\ClWechat;
|
|
use think\Request;
|
|
|
|
class SysAdmin extends Common
|
|
{
|
|
/**
|
|
* lists
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
|
|
*/
|
|
public function lists()
|
|
{
|
|
$url = config('api_domain').'/admin/lists';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['is_count'] = 1;
|
|
$params['is_admin'] = 0;
|
|
$params['debug'] = 1;
|
|
$params['page'] = 1;
|
|
$params['pageSize'] = 10;
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
$this->assign('count',$json_arr['count']);
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* add
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
|
|
*/
|
|
public function add()
|
|
{
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* auth
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
|
|
*/
|
|
public function auth()
|
|
{
|
|
$id = Request::instance()->param('id');
|
|
$url = config('api_domain').'/auth/tmpList';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['id'] = $id;
|
|
$params['debug'] = 1;
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
$this->assign('lists',$json_arr['lists']);
|
|
$this->assign('user_id',$json_arr['user_id']);
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* update
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
|
|
*/
|
|
public function edit()
|
|
{
|
|
$id = Request::instance()->param('id');
|
|
$url = config('api_domain').'/admin/get';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['id'] = $id;
|
|
$params['debug'] = 1;
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
$this->assign('info',$json_arr['info']);
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* actionLists
|
|
* @return \think\response\Json
|
|
*/
|
|
public function actionLists()
|
|
{
|
|
$field_arr = array(
|
|
array('field_name' => 'page','rule' => 'require|number'),
|
|
array('field_name' => 'pageSize','rule' => 'require|number')
|
|
);
|
|
$check_arr = $this->checkHave($field_arr);
|
|
if($check_arr[self::$error_code_name] == 0)
|
|
{
|
|
$url = config('api_domain').'/admin/lists';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['debug'] = 1;
|
|
$params['is_count'] = 1;
|
|
$params['is_admin'] = 0;
|
|
$params['page'] = $check_arr[self::$data_name]['page'];
|
|
$params['pageSize'] = $check_arr[self::$data_name]['pageSize'];
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
$json_arr['code'] = $json_arr['error_code'];
|
|
$json_arr['data'] = $json_arr['lists'];
|
|
self::$result = $json_arr;
|
|
}
|
|
return json(self::$result);
|
|
}
|
|
|
|
/**
|
|
* actionAdd
|
|
* @return \think\response\Json
|
|
*/
|
|
public function actionAdd()
|
|
{
|
|
$field_arr = array(
|
|
array('field_name' => 'user_name','rule' => ''),
|
|
array('field_name' => 'password','rule' => '')
|
|
);
|
|
$check_arr = $this->checkHave($field_arr);
|
|
if($check_arr[self::$error_code_name] == 0)
|
|
{
|
|
$url = config('api_domain').'/admin/add';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['debug'] = 1;
|
|
if (array_key_exists('user_name',$check_arr[self::$data_name]))
|
|
{
|
|
$params['user_name'] = $check_arr[self::$data_name]['user_name'];
|
|
}
|
|
if (array_key_exists('password',$check_arr[self::$data_name]))
|
|
{
|
|
$params['password'] = $check_arr[self::$data_name]['password'];
|
|
}
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
self::$result = $json_arr;
|
|
}
|
|
return json(self::$result);
|
|
}
|
|
|
|
/**
|
|
* actionUpdate
|
|
* @return \think\response\Json
|
|
*/
|
|
public function actionUpdate()
|
|
{
|
|
$field_arr = array(
|
|
array('field_name' => 'id','rule' => 'require|number'),
|
|
array('field_name' => 'user_name','rule' => ''),
|
|
array('field_name' => 'password','rule' => '')
|
|
);
|
|
$check_arr = $this->checkHave($field_arr);
|
|
if($check_arr[self::$error_code_name] == 0)
|
|
{
|
|
$url = config('api_domain').'/admin/update';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['debug'] = 1;
|
|
$params['id'] = $check_arr[self::$data_name]['id'];
|
|
if (array_key_exists('user_name',$check_arr[self::$data_name]))
|
|
{
|
|
$params['user_name'] = $check_arr[self::$data_name]['user_name'];
|
|
}
|
|
if (array_key_exists('password',$check_arr[self::$data_name]))
|
|
{
|
|
$params['password'] = $check_arr[self::$data_name]['password'];
|
|
}
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
self::$result = $json_arr;
|
|
}
|
|
return json(self::$result);
|
|
}
|
|
|
|
/**
|
|
* actionDelete
|
|
* @return \think\response\Json
|
|
*/
|
|
public function actionDelete()
|
|
{
|
|
$field_arr = array(
|
|
array('field_name' => 'id','rule' => 'require|number')
|
|
);
|
|
$check_arr = $this->checkHave($field_arr);
|
|
if($check_arr[self::$error_code_name] == 0)
|
|
{
|
|
$url = config('api_domain').'/admin/delete';
|
|
$params = array();
|
|
$params['access_token'] = $this->createAccessToken();
|
|
$params['id'] = $check_arr[self::$data_name]['id'];
|
|
$params['debug'] = 1;
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
self::$result = $json_arr;
|
|
}
|
|
return json(self::$result);
|
|
}
|
|
} |