作者 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 @@ -81,7 +81,7 @@ class BaseController extends Controller
81 $this->order = $v; 81 $this->order = $v;
82 break; 82 break;
83 case 'page': 83 case 'page':
84 - $this->p = $v; 84 + $this->page = $v;
85 break; 85 break;
86 case 'row': 86 case 'row':
87 $this->row = $v; 87 $this->row = $v;
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\News;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Models\News\NewsCategory as NewsCategoryModel;
  8 +
  9 +class NewsCategoryController extends BaseController
  10 +{
  11 + /**
  12 + * @name :新闻列表
  13 + * @return void
  14 + * @author :liyuhang
  15 + * @method
  16 + */
  17 + public function lists(NewsCategoryModel $newsCategoryModel){
  18 + $lists = $newsCategoryModel->lists($this->map,$this->page,$this->row);
  19 + $this->response('success',Code::SUCCESS,$lists);
  20 + }
  21 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\News;
  4 +
  5 +use App\Http\Controllers\Bside\BaseController;
  6 +
  7 +class NewsController extends BaseController
  8 +{
  9 + /**
  10 + * @name :获取新闻列表
  11 + * @return void
  12 + * @author :liyuhang
  13 + * @method
  14 + */
  15 + public function lists(){
  16 +
  17 + }
  18 +}
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Bside;  
4 -  
5 -use App\Enums\Common\Code;  
6 -use App\Models\Product as ProductModel;  
7 -use App\Models\ProductClassify as ProductClassifyModel;  
8 -use Illuminate\Support\Facades\Validator;  
9 -  
10 -/**  
11 - * @name:产品表  
12 - */  
13 -class ProductController extends BaseController  
14 -{  
15 - /**  
16 - * @name : 产品列表  
17 - * @return void  
18 - * @author :liyuhang  
19 - * @method  
20 - */  
21 - public function lists(){  
22 - //获取当前登录用户下的产品列表  
23 - $this->map['project_id'] = $this->user['project_id'];  
24 - $productModel = new ProductModel();  
25 - $lists = $productModel->lists($this->map,$this->p,$this->row,$this->order);  
26 - $this->allCount = $productModel->allCount;  
27 - $this->response('success',Code::SUCCESS, $lists);  
28 - }  
29 -  
30 - /**  
31 - * @name :添加产品  
32 - * @return void  
33 - * @author :liyuhang  
34 - * @method  
35 - */  
36 - public function add(){  
37 - //参数验证  
38 - $rules = [  
39 - 'name'=>'required|max:11',  
40 - 'image'=>'required',  
41 - 'describe'=>'required',  
42 - 'keywords'=>'required|max:50',  
43 - ];  
44 - //验证的提示信息  
45 - $message = [  
46 - 'name.required'=>'名称必须填写',  
47 - 'name.max' => '名称不大于16字符.',  
48 - 'image.required'=>'图片必须上传',  
49 - 'describe.required'=>'描述必须填写',  
50 - 'keywords.required'=>'关键字必须填写',  
51 - ];  
52 - $validate = Validator::make($this->param, $rules, $message);  
53 - if($validate->fails()){  
54 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
55 - }  
56 - //TODO::关联项目  
57 - $this->param['project_id'] = $this->user['project_id'];  
58 - $productModel = new ProductModel();  
59 - $this->param['image'] = $this->uploads();  
60 - $rs = $productModel->add($this->param);  
61 - if($rs === false){  
62 - $this->response('error',Code::USER_ERROR);  
63 - }  
64 - $this->response('success',Code::SUCCESS);  
65 - }  
66 -  
67 - public function edit(){  
68 - //参数验证  
69 - $rules = [  
70 - 'name'=>'required|max:11',  
71 - 'image'=>'required',  
72 - 'describe'=>'required',  
73 - 'keywords'=>'required|max:50',  
74 - ];  
75 - //验证的提示信息  
76 - $message = [  
77 - 'name.required'=>'名称必须填写',  
78 - 'name.max' => '名称不大于16字符.',  
79 - 'image.required'=>'图片必须上传',  
80 - 'describe.required'=>'描述必须填写',  
81 - 'keywords.required'=>'关键字必须填写',  
82 - ];  
83 - $validate = Validator::make($this->param, $rules, $message);  
84 - if($validate->fails()){  
85 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
86 - }  
87 - if(isset($this->param['image'])){  
88 - //TODO::删除上一次的图片  
89 - $this->param['image'] = $this->uploads();  
90 - }  
91 - $productModel = new ProductModel();  
92 - $rs = $productModel->edit($this->param,['id'=>$this->param['id']]);  
93 - if($rs === false){  
94 - $this->response('error',Code::USER_ERROR);  
95 - }  
96 - $this->response('success',Code::SUCCESS);  
97 - }  
98 -  
99 - /**  
100 - * @name :修改产品状态  
101 - * @return void  
102 - * @author :liyuhang  
103 - * @method  
104 - */  
105 - public function status(){  
106 - //参数验证  
107 - $rules = [  
108 - 'id'=>'required',  
109 - 'status'=>'required',  
110 - ];  
111 - //验证的提示信息  
112 - $message = [  
113 - 'id.required'=>'主键必须填写',  
114 - 'status.required'=>'状态必须填写',  
115 - ];  
116 - $validate = Validator::make($this->param, $rules, $message);  
117 - if($validate->fails()){  
118 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
119 - }  
120 - $productModel = new ProductModel();  
121 - $rs = $productModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);  
122 - if($rs === false){  
123 - $this->response('error',Code::USER_ERROR);  
124 - }  
125 - $this->response('success',Code::SUCCESS);  
126 - }  
127 -  
128 - /**  
129 - * @name :删除产品  
130 - * @return void  
131 - * @author :liyuhang  
132 - * @method  
133 - */  
134 - public function del(){  
135 - //参数验证  
136 - $rules = [  
137 - 'id'=>'required',  
138 - ];  
139 - //验证的提示信息  
140 - $message = [  
141 - 'id.required'=>'主键必须填写',  
142 - ];  
143 - $validate = Validator::make($this->param, $rules, $message);  
144 - if($validate->fails()){  
145 - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);  
146 - }  
147 - $productModel = new ProductModel();  
148 - $info = $productModel->read(['id'=>$this->param['id']],['image']);  
149 - //TODO::删除添加的图片  
150 - shell_exec('rm -rf '.request()->path().'../../'.$info['image']);  
151 - $rs = $productModel->del(['id'=>$this->param['id']]);  
152 - if($rs === false){  
153 - $this->response('error',Code::USER_ERROR);  
154 - }  
155 - $this->response('success',Code::SUCCESS);  
156 - }  
157 -}  
@@ -24,7 +24,7 @@ class ProjectRoleController extends BaseController @@ -24,7 +24,7 @@ class ProjectRoleController extends BaseController
24 $this->map['status'] = 0; 24 $this->map['status'] = 0;
25 $this->map['project_id'] = $this->user['project_id']; 25 $this->map['project_id'] = $this->user['project_id'];
26 //获取当前登录用户自己的菜单栏 26 //获取当前登录用户自己的菜单栏
27 - $lists = $projectRoleModel->lists($this->map,$this->p,$this->row,$this->order); 27 + $lists = $projectRoleModel->lists($this->map,$this->page,$this->row,$this->order);
28 $this->response('success',Code::SUCCESS,$lists); 28 $this->response('success',Code::SUCCESS,$lists);
29 } 29 }
30 30
@@ -19,7 +19,7 @@ class UserController extends BaseController @@ -19,7 +19,7 @@ class UserController extends BaseController
19 public function lists(UserModel $userModel){ 19 public function lists(UserModel $userModel){
20 //TODO::搜索参数处理 20 //TODO::搜索参数处理
21 $this->map['project_id'] = $this->user['project_id']; 21 $this->map['project_id'] = $this->user['project_id'];
22 - $lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile','created_at']); 22 + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']);
23 if(empty($lists)){ 23 if(empty($lists)){
24 $this->response('请求失败',Code::USER_ERROR,[]); 24 $this->response('请求失败',Code::USER_ERROR,[]);
25 } 25 }
  1 +<?php
  2 +
  3 +namespace App\Http\Requests\Bside\News;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class NewsCategoryRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 +
  19 + /**
  20 + * Get the validation rules that apply to the request.
  21 + *
  22 + * @return array
  23 + */
  24 + public function rules()
  25 + {
  26 + return [
  27 + 'name'=>'required',
  28 + ];
  29 + }
  30 +
  31 + public function messages()
  32 + {
  33 + return [
  34 + 'name.required'=>'名称必须填写',
  35 + ];
  36 + }
  37 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Requests\Bside\News;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class NewsRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 +
  19 + /**
  20 + * Get the validation rules that apply to the request.
  21 + *
  22 + * @return array
  23 + */
  24 + public function rules()
  25 + {
  26 + return [
  27 + 'name'=>'required',
  28 + ];
  29 + }
  30 +
  31 + public function messages()
  32 + {
  33 + return [
  34 + 'name.required'=>'名称必须填写',
  35 + ];
  36 + }
  37 +}
@@ -32,9 +32,9 @@ class Base extends Model @@ -32,9 +32,9 @@ class Base extends Model
32 * @author :liyuhang 32 * @author :liyuhang
33 * @method 33 * @method
34 */ 34 */
35 - public function lists($map, $p, $row, $order = 'id', $fields = ['*']){ 35 + public function lists($map, $page, $row, $order = 'id', $fields = ['*']){
36 $query = $this->formatQuery($map); 36 $query = $this->formatQuery($map);
37 - $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $p); 37 + $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $page);
38 if (empty($lists)) { 38 if (empty($lists)) {
39 return false; 39 return false;
40 } 40 }
  1 +<?php
  2 +
  3 +namespace App\Models\News;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class News extends Base
  8 +{
  9 + protected $table = 'gl_news';
  10 +}
  1 +<?php
  2 +
  3 +namespace App\Models\News;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class NewsCategory extends Base
  8 +{
  9 + protected $table = 'gl_news_category';
  10 +}