作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

<?php
use Illuminate\Support\Facades\Log;
define('HTTP_OPENAI_URL','http://openai.waimaoq.com');
if(!function_exists('http_post')){
/**
... ...
... ... @@ -117,7 +117,7 @@ class BaseController extends Controller
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $data,
'data' => $this->_extents($data),
];
$this->header['Content-Type'] = $type;
$this->header['token'] = $this->token;
... ... @@ -144,5 +144,26 @@ class BaseController extends Controller
return $new_arr ? $new_arr : false;
}
protected function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
foreach ($data as $k => $v) {
if (is_array($v)) {
$data[$k] = $this->_extents($v);
} else {
if (is_null($v)) {
$data[$k] = '';
continue;
}
switch ((string) $k) {
case 'image':
$v['image_link'] = file_get_contents($v);
break;
}
}
}
return $data;
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Blog;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Blog\BlogLabelLogic;
use App\Http\Requests\Bside\Blog\BlogLabelRequest;
use App\Models\Blog\BlogLabel as BlogLabelModel;
use Illuminate\Http\Request;
... ... @@ -27,15 +28,9 @@ class BlogLabelController extends BaseController
* @author :liyuhang
* @method
*/
public function add(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){
public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){
$request->validated();
$this->param['create_id'] = $this->uid;
$this->param['Operator_id'] = $this->uid;
$this->param['project_id'] = $this->user['project_id'];
$rs = $blogLabelModel->add($this->param);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$blogLabelLogic->add_blog_label();
//TODO::写入日志
$this->response('success');
}
... ... @@ -46,18 +41,13 @@ class BlogLabelController extends BaseController
* @author :liyuhang
* @method
*/
public function edit(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){
public function edit(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$this->param['operator_id'] = $this->uid;
$rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]);
//TODO::路由映射
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$blogLabelLogic->edit_blog_label();
//TODO::写入日志
$this->response('success');
}
... ... @@ -68,17 +58,13 @@ class BlogLabelController extends BaseController
* @author :liyuhang
* @method
*/
public function status(Request $request,BlogLabelModel $blogLabelModel){
public function status(Request $request,BlogLabelLogic $blogLabelLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$this->param['Operator_id'] = $this->uid;
$rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$blogLabelLogic->edit_blog_label();
//TODO::写入日志
$this->response('success');
}
... ... @@ -89,17 +75,13 @@ class BlogLabelController extends BaseController
* @author :liyuhang
* @method
*/
public function del(Request $request,BlogLabelModel $blogLabelModel){
public function del(Request $request,BlogLabelLogic $blogLabelLogic){
$request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$this->param['id'] = ['in',$this->param['id']];
$rs = $blogLabelModel->del($this->param);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$blogLabelLogic->del_blog_label();
$this->response('success');
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Logic\Bside\Blog;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\BlogLabel as BlogLabelModel;
... ... @@ -14,4 +15,52 @@ class BlogLabelLogic extends BaseLogic
$this->model = new BlogLabelModel();
$this->param = $this->requestAll;
}
/**
* @name :新增标签
* @return void
* @author :liyuhang
* @method
*/
public function add_blog_label(){
$this->param['create_id'] = $this->user['id'];
$this->param['Operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error',Code::USER_ERROR);
}
return $this->success();
}
/**
* @name :编辑标签
* @return void
* @author :liyuhang
* @method
*/
public function edit_blog_label(){
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
//TODO::路由映射
if($rs === false){
$this->fail('error',Code::USER_ERROR);
}
return $this->success();
}
/**
* @name :删除标签
* @return array
* @author :liyuhang
* @method
*/
public function del_blog_label(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error',Code::USER_ERROR);
}
return $this->success();
}
}
... ...
... ... @@ -93,7 +93,7 @@ class RoleLogic extends BaseLogic
}
}
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del(['id'=>$this->param['id']]);
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error',Code::USER_ERROR);
}
... ... @@ -131,7 +131,7 @@ class RoleLogic extends BaseLogic
foreach ($lists as $k => $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = $this->_get_child($v['id'], $lists);
$v['sub'] = _get_child($v['id'], $lists);
$menu[] = $v;
}
}
... ...
... ... @@ -85,11 +85,11 @@ class UserLogic extends BaseLogic
* @method
*/
public function user_info(){
$rs = $this->model->read($this->param);
if($rs === false){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('error',Code::USER_ERROR);
}
return $this->success();
return $this->success($info);
}
/**
... ... @@ -100,7 +100,7 @@ class UserLogic extends BaseLogic
*/
public function user_del(){
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);
if($rs === false){
$this->fail('error',Code::USER_ERROR);
}
... ...