作者 Your Name

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

... ... @@ -81,7 +81,7 @@ class BaseController extends Controller
$this->order = $v;
break;
case 'page':
$this->p = $v;
$this->page = $v;
break;
case 'row':
$this->row = $v;
... ...
<?php
namespace App\Http\Controllers\Bside\News;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\News\NewsCategory as NewsCategoryModel;
class NewsCategoryController extends BaseController
{
/**
* @name :新闻列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(NewsCategoryModel $newsCategoryModel){
$lists = $newsCategoryModel->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
<?php
namespace App\Http\Controllers\Bside\News;
use App\Http\Controllers\Bside\BaseController;
class NewsController extends BaseController
{
/**
* @name :获取新闻列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(){
}
}
... ...
<?php
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Models\Product as ProductModel;
use App\Models\ProductClassify as ProductClassifyModel;
use Illuminate\Support\Facades\Validator;
/**
* @name:产品表
*/
class ProductController extends BaseController
{
/**
* @name : 产品列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(){
//获取当前登录用户下的产品列表
$this->map['project_id'] = $this->user['project_id'];
$productModel = new ProductModel();
$lists = $productModel->lists($this->map,$this->p,$this->row,$this->order);
$this->allCount = $productModel->allCount;
$this->response('success',Code::SUCCESS, $lists);
}
/**
* @name :添加产品
* @return void
* @author :liyuhang
* @method
*/
public function add(){
//参数验证
$rules = [
'name'=>'required|max:11',
'image'=>'required',
'describe'=>'required',
'keywords'=>'required|max:50',
];
//验证的提示信息
$message = [
'name.required'=>'名称必须填写',
'name.max' => '名称不大于16字符.',
'image.required'=>'图片必须上传',
'describe.required'=>'描述必须填写',
'keywords.required'=>'关键字必须填写',
];
$validate = Validator::make($this->param, $rules, $message);
if($validate->fails()){
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
}
//TODO::关联项目
$this->param['project_id'] = $this->user['project_id'];
$productModel = new ProductModel();
$this->param['image'] = $this->uploads();
$rs = $productModel->add($this->param);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS);
}
public function edit(){
//参数验证
$rules = [
'name'=>'required|max:11',
'image'=>'required',
'describe'=>'required',
'keywords'=>'required|max:50',
];
//验证的提示信息
$message = [
'name.required'=>'名称必须填写',
'name.max' => '名称不大于16字符.',
'image.required'=>'图片必须上传',
'describe.required'=>'描述必须填写',
'keywords.required'=>'关键字必须填写',
];
$validate = Validator::make($this->param, $rules, $message);
if($validate->fails()){
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
}
if(isset($this->param['image'])){
//TODO::删除上一次的图片
$this->param['image'] = $this->uploads();
}
$productModel = new ProductModel();
$rs = $productModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS);
}
/**
* @name :修改产品状态
* @return void
* @author :liyuhang
* @method
*/
public function status(){
//参数验证
$rules = [
'id'=>'required',
'status'=>'required',
];
//验证的提示信息
$message = [
'id.required'=>'主键必须填写',
'status.required'=>'状态必须填写',
];
$validate = Validator::make($this->param, $rules, $message);
if($validate->fails()){
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
}
$productModel = new ProductModel();
$rs = $productModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS);
}
/**
* @name :删除产品
* @return void
* @author :liyuhang
* @method
*/
public function del(){
//参数验证
$rules = [
'id'=>'required',
];
//验证的提示信息
$message = [
'id.required'=>'主键必须填写',
];
$validate = Validator::make($this->param, $rules, $message);
if($validate->fails()){
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
}
$productModel = new ProductModel();
$info = $productModel->read(['id'=>$this->param['id']],['image']);
//TODO::删除添加的图片
shell_exec('rm -rf '.request()->path().'../../'.$info['image']);
$rs = $productModel->del(['id'=>$this->param['id']]);
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS);
}
}
... ... @@ -24,7 +24,7 @@ class ProjectRoleController extends BaseController
$this->map['status'] = 0;
$this->map['project_id'] = $this->user['project_id'];
//获取当前登录用户自己的菜单栏
$lists = $projectRoleModel->lists($this->map,$this->p,$this->row,$this->order);
$lists = $projectRoleModel->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -19,7 +19,7 @@ class UserController extends BaseController
public function lists(UserModel $userModel){
//TODO::搜索参数处理
$this->map['project_id'] = $this->user['project_id'];
$lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile','created_at']);
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']);
if(empty($lists)){
$this->response('请求失败',Code::USER_ERROR,[]);
}
... ...
<?php
namespace App\Http\Requests\Bside\News;
use Illuminate\Foundation\Http\FormRequest;
class NewsCategoryRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name'=>'required',
];
}
public function messages()
{
return [
'name.required'=>'名称必须填写',
];
}
}
... ...
<?php
namespace App\Http\Requests\Bside\News;
use Illuminate\Foundation\Http\FormRequest;
class NewsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name'=>'required',
];
}
public function messages()
{
return [
'name.required'=>'名称必须填写',
];
}
}
... ...
... ... @@ -32,9 +32,9 @@ class Base extends Model
* @author :liyuhang
* @method
*/
public function lists($map, $p, $row, $order = 'id', $fields = ['*']){
public function lists($map, $page, $row, $order = 'id', $fields = ['*']){
$query = $this->formatQuery($map);
$lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $p);
$lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $page);
if (empty($lists)) {
return false;
}
... ...
<?php
namespace App\Models\News;
use App\Models\Base;
class News extends Base
{
protected $table = 'gl_news';
}
... ...
<?php
namespace App\Models\News;
use App\Models\Base;
class NewsCategory extends Base
{
protected $table = 'gl_news_category';
}
... ...