admin No.1
This commit is contained in:
parent
bef6e5011a
commit
b645f18064
@ -4,6 +4,9 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Models\MenuModel;
|
use App\Models\MenuModel;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
|
use App\Models\NodeGroup;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\UserNodeLine;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -87,6 +90,22 @@ class InitAdmin extends Command
|
|||||||
Log::error('顶级权限插入失败');
|
Log::error('顶级权限插入失败');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//初始化超级管理员
|
||||||
|
$nodeGroupList = ["name"=>"超级管理员","node_ids"=>"all","created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())];
|
||||||
|
$admin = ["nickname"=>env('ADMIN_NICKNAME'),"account"=>env('ADMIN_ACCOUNT'),"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())];
|
||||||
|
NodeGroup::truncate();
|
||||||
|
$res3 = NodeGroup::insert($nodeGroupList);
|
||||||
|
$res4 = User::insert($admin);
|
||||||
|
if ($res3 && $res4){
|
||||||
|
$node_group_id = NodeGroup::where('name','超级管理员')->value('id');
|
||||||
|
$user_id = User::where('account',env('ADMIN_ACCOUNT'))->value('id');
|
||||||
|
UserNodeLine::insert(['user_id'=>$user_id,'node_group_id'=>$node_group_id]);
|
||||||
|
Log::info('初始化超级管理员成功');
|
||||||
|
}else{
|
||||||
|
Log::error('初始化超级管理员失败');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMenuChildren($id,$name){
|
private function getMenuChildren($id,$name){
|
||||||
@ -122,6 +141,7 @@ class InitAdmin extends Command
|
|||||||
]; break;
|
]; break;
|
||||||
case 'CEBG' : $node = [
|
case 'CEBG' : $node = [
|
||||||
["name"=>"申请列表","controller"=>"ApplyController","action"=>"index","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
["name"=>"申请列表","controller"=>"ApplyController","action"=>"index","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
||||||
|
["name"=>"查看申请","controller"=>"ApplyController","action"=>"show","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
||||||
["name"=>"提交申请","controller"=>"ApplyController","action"=>"create","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
["name"=>"提交申请","controller"=>"ApplyController","action"=>"create","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
||||||
["name"=>"撤销申请","controller"=>"ApplyController","action"=>"destroy","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
["name"=>"撤销申请","controller"=>"ApplyController","action"=>"destroy","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
||||||
["name"=>"通过申请","controller"=>"ApplyController","action"=>"pass","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
["name"=>"通过申请","controller"=>"ApplyController","action"=>"pass","pid"=>$id,"created_at"=>date('Y-m-d H:i:s',time()),"updated_at"=>date('Y-m-d H:i:s',time())],
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\ApplyModel;
|
use App\Models\ApplyModel;
|
||||||
|
use App\Models\MintModel;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserNodeLine;
|
use App\Models\UserNodeLine;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class ApplyController extends Controller
|
class ApplyController extends Controller
|
||||||
{
|
{
|
||||||
@ -28,7 +30,25 @@ class ApplyController extends Controller
|
|||||||
}
|
}
|
||||||
//当用户是执行组
|
//当用户是执行组
|
||||||
if ($type==3){
|
if ($type==3){
|
||||||
$data = ApplyModel::where('state',1)->orderBy('id','desc')->paginate($size)->toArray();
|
$data = ApplyModel::with('mint')->where('state',1)->orderBy('id','desc')->paginate($size)->toArray();
|
||||||
|
|
||||||
|
if ($data['data'] ){
|
||||||
|
$arr = $data['data'];
|
||||||
|
foreach ($arr as $key=>$item){
|
||||||
|
if ($arr[$key]['mint'] && ! $arr[$key]['mint']['suspend'] && ! $arr[$key]['mint']['done']){
|
||||||
|
$arr[$key]['execute_state'] = 1;
|
||||||
|
}
|
||||||
|
if ($arr[$key]['mint'] && $arr[$key]['mint']['done']){
|
||||||
|
$arr[$key]['execute_state'] = 2;
|
||||||
|
}
|
||||||
|
if ($arr[$key]['mint'] && $arr[$key]['mint']['suspend']){
|
||||||
|
$arr[$key]['execute_state'] = 3;
|
||||||
|
}
|
||||||
|
unset($arr[$key]['mint']);
|
||||||
|
}
|
||||||
|
// dump($arr);
|
||||||
|
$data['data'] = $arr;
|
||||||
|
}
|
||||||
return $this->success($data);
|
return $this->success($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,6 +67,32 @@ class ApplyController extends Controller
|
|||||||
return $this->error(ERROR_CODE_PARAM_INVALID,$validator->errors()->first());
|
return $this->error(ERROR_CODE_PARAM_INVALID,$validator->errors()->first());
|
||||||
}
|
}
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
$param1 = [
|
||||||
|
'c' => 'BcService',
|
||||||
|
'a' => 'isValidItem',
|
||||||
|
'item_id' => $data['item_id'],
|
||||||
|
];
|
||||||
|
$response1 = Http::get(env('WEB3_HELPER_URL'), $param1);
|
||||||
|
if (!$response1->successful()) {
|
||||||
|
return $this->error(ERROR_CODE_INTERNAL_ERROR, 'WEB3服务出现错误');
|
||||||
|
}
|
||||||
|
$response1 = $response1->json();
|
||||||
|
if ($response1['errcode']){
|
||||||
|
return $this->error(ERROR_CODE_PARAM_INVALID, $response1['errmsg']);
|
||||||
|
}
|
||||||
|
$param2 = [
|
||||||
|
'c' => 'BcService',
|
||||||
|
'a' => 'isValidAccount',
|
||||||
|
'account' => $data['send_account'],
|
||||||
|
];
|
||||||
|
$response2 = Http::get(env('WEB3_HELPER_URL'), $param2);
|
||||||
|
if (!$response2->successful()) {
|
||||||
|
return $this->error(ERROR_CODE_INTERNAL_ERROR, 'WEB3服务出现错误');
|
||||||
|
}
|
||||||
|
$response2 = $response2->json();
|
||||||
|
if ($response2['errcode']){
|
||||||
|
return $this->error(ERROR_CODE_PARAM_INVALID, $response2['errmsg']);
|
||||||
|
}
|
||||||
$data['creator_account'] = auth()->user()->account;
|
$data['creator_account'] = auth()->user()->account;
|
||||||
if (Cache::has('unikey_id')){
|
if (Cache::has('unikey_id')){
|
||||||
$unikey_id = Cache::get("unikey_id");
|
$unikey_id = Cache::get("unikey_id");
|
||||||
@ -123,4 +169,40 @@ class ApplyController extends Controller
|
|||||||
};
|
};
|
||||||
return $this->success([]);
|
return $this->success([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function execute($id){
|
||||||
|
if (! is_numeric($id)){
|
||||||
|
return $this->error(ERROR_CODE_PARAM_INVALID,'参数格式不对');
|
||||||
|
}
|
||||||
|
$data = ApplyModel::find($id);
|
||||||
|
if (!$data){
|
||||||
|
return $this->error(ERROR_CODE_NO,'数据不存在');
|
||||||
|
}
|
||||||
|
if (MintModel::where('unikey',$data->unikey)->count()>0){
|
||||||
|
return $this->error(ERROR_CODE_NO,'无法再次执行');
|
||||||
|
}
|
||||||
|
|
||||||
|
$param = [
|
||||||
|
'c' => 'BcService',
|
||||||
|
'a' => 'presentItem',
|
||||||
|
'account' => $data->send_account,
|
||||||
|
'unikey' => $data->unikey,
|
||||||
|
'item_id' => $data->item_id
|
||||||
|
];
|
||||||
|
$response = Http::get(env('WEB3_HELPER_URL'), $param);
|
||||||
|
if (!$response->successful()) {
|
||||||
|
return $this->error(ERROR_CODE_INTERNAL_ERROR, 'WEB3服务出现错误');
|
||||||
|
}
|
||||||
|
$response = $response->json();
|
||||||
|
if ($response['errcode']){
|
||||||
|
return $this->error(ERROR_CODE_PARAM_INVALID, $response['errmsg']);
|
||||||
|
}
|
||||||
|
$data->execute_account = auth()->user()->account;
|
||||||
|
$data->execute_time = time();
|
||||||
|
$res = $data->save();
|
||||||
|
if(! $res){
|
||||||
|
return $this->error(ERROR_CODE_NO,'系统繁忙,稍后再试');
|
||||||
|
};
|
||||||
|
return $this->success([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//修改昵称
|
//修改昵称
|
||||||
public function update($account,Request $request){
|
public function update(Request $request){
|
||||||
|
|
||||||
$validator = Validator::make($request->all(),[
|
$validator = Validator::make($request->all(),[
|
||||||
'nickname' => 'required',
|
'nickname' => 'required',
|
||||||
@ -123,6 +123,7 @@ class UserController extends Controller
|
|||||||
if ($validator->fails()){
|
if ($validator->fails()){
|
||||||
return $this->error(ERROR_CODE_PARAM_INVALID,$validator->errors()->first());
|
return $this->error(ERROR_CODE_PARAM_INVALID,$validator->errors()->first());
|
||||||
}
|
}
|
||||||
|
$account = auth()->user()->account;
|
||||||
$res = User::where('account',$account)->update($request->input());
|
$res = User::where('account',$account)->update($request->input());
|
||||||
if (! $res){
|
if (! $res){
|
||||||
return $this->error(ERROR_CODE_NO,'系统繁忙,稍后再试');
|
return $this->error(ERROR_CODE_NO,'系统繁忙,稍后再试');
|
||||||
@ -134,8 +135,15 @@ class UserController extends Controller
|
|||||||
$user = User::with([
|
$user = User::with([
|
||||||
'menu' => function ($query) {
|
'menu' => function ($query) {
|
||||||
$query->where('state', 1);
|
$query->where('state', 1);
|
||||||
}
|
},
|
||||||
|
'nodeGroup'
|
||||||
])->find(auth()->id())->toArray();
|
])->find(auth()->id())->toArray();
|
||||||
|
|
||||||
|
if ($user['node_group'] && in_array('超级管理员',array_column($user['node_group'],'name'))){
|
||||||
|
$arr = MenuModel::orderByDesc('id')->get()->toArray();
|
||||||
|
$menu = getTreeList($arr);
|
||||||
|
return $this->success($menu);
|
||||||
|
}
|
||||||
$pid = [];
|
$pid = [];
|
||||||
if (!empty($user['menu'])) {
|
if (!empty($user['menu'])) {
|
||||||
foreach ($user['menu'] as $k => $v) {
|
foreach ($user['menu'] as $k => $v) {
|
||||||
|
@ -35,4 +35,8 @@ class ApplyModel extends Model
|
|||||||
}
|
}
|
||||||
return date('Y-m-d H:i:s',$value);
|
return date('Y-m-d H:i:s',$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mint(){
|
||||||
|
return $this->hasOne(MintModel::class,'unikey','unikey');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ Route::middleware('auth:api')->group(function () {
|
|||||||
Route::get('logout',[\App\Http\Controllers\MeteMaskLoginController::class,'logout']);
|
Route::get('logout',[\App\Http\Controllers\MeteMaskLoginController::class,'logout']);
|
||||||
Route::get('home',[\App\Http\Controllers\IndexController::class,'index']);
|
Route::get('home',[\App\Http\Controllers\IndexController::class,'index']);
|
||||||
Route::get('my-menu',[\App\Http\Controllers\UserController::class,'myMenu']);
|
Route::get('my-menu',[\App\Http\Controllers\UserController::class,'myMenu']);
|
||||||
|
Route::get('update-nickname',[\App\Http\Controllers\UserController::class,'update']);
|
||||||
|
|
||||||
|
|
||||||
Route::middleware('check.node')->group(function () {
|
Route::middleware('check.node')->group(function () {
|
||||||
@ -35,6 +36,7 @@ Route::middleware('auth:api')->group(function () {
|
|||||||
Route::delete('apply/{id}',[\App\Http\Controllers\ApplyController::class,'destroy']);
|
Route::delete('apply/{id}',[\App\Http\Controllers\ApplyController::class,'destroy']);
|
||||||
Route::get('apply/pass/{id}',[\App\Http\Controllers\ApplyController::class,'pass']);
|
Route::get('apply/pass/{id}',[\App\Http\Controllers\ApplyController::class,'pass']);
|
||||||
Route::get('apply/no-pass/{id}',[\App\Http\Controllers\ApplyController::class,'noPass']);
|
Route::get('apply/no-pass/{id}',[\App\Http\Controllers\ApplyController::class,'noPass']);
|
||||||
|
Route::get('apply/execute/{id}',[\App\Http\Controllers\ApplyController::class,'execute']);
|
||||||
|
|
||||||
|
|
||||||
Route::Resource('user',\App\Http\Controllers\UserController::class);
|
Route::Resource('user',\App\Http\Controllers\UserController::class);
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user