Skip to content

Commit bd5e026

Browse files
committed
Merge branch 'develop'
2 parents b7b8182 + cebe515 commit bd5e026

25 files changed

+1133
-1266
lines changed

admin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -w -r 0"
2020
},
2121
"dependencies": {
22-
"axios": "^0.19.2",
22+
"axios": ">=0.21.1",
2323
"echarts": "^4.8.0",
2424
"element-ui": "2.7.2",
2525
"js-cookie": "2.2.0",
2626
"layui-src": "^2.5.5",
27-
"mavon-editor": "^2.9.0",
27+
"mavon-editor": "^2.9.1",
2828
"normalize.css": "7.0.0",
2929
"nprogress": "0.2.0",
3030
"path-to-regexp": "2.4.0",

laravel/app/Helper/functions.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function show($varName)
3030
function cacheUserRolesAndPermissions($user_id, $flash = false)
3131
{
3232
if ($flash) {
33-
Cache::forget('user_r_p_'.$user_id);
33+
Cache::forget('user_r_p_' . $user_id);
3434
return cacheUserRolesAndPermissions($user_id, false);
3535
} else {
36-
return Cache::remember('user_r_p_'.$user_id, 3600 * 24 * 30, function() use ($user_id) {
36+
return Cache::remember('user_r_p_' . $user_id, 3600 * 24 * 30, function () use ($user_id) {
3737
$res = collect(DB::table('role_user')
3838
->where('role_user.user_id', $user_id)
3939
->join('roles', 'roles.id', '=', 'role_user.role_id')
@@ -57,10 +57,10 @@ function cacheUserRolesAndPermissions($user_id, $flash = false)
5757
function cacheTotalExcel($api_excel_id, $file_path, $flash = false)
5858
{
5959
if ($flash) {
60-
Cache::forget('api_excel_total_'.$api_excel_id);
60+
Cache::forget('api_excel_total_' . $api_excel_id);
6161
return cacheTotalExcel($api_excel_id, false);
6262
} else {
63-
return Cache::remember('api_excel_total_'.$api_excel_id, 60, function() use ($api_excel_id, $file_path) {
63+
return Cache::remember('api_excel_total_' . $api_excel_id, 60, function () use ($api_excel_id, $file_path) {
6464
$excel = \App\Http\Repository\MultithreadingRepository::getInstent();
6565
$data = $excel->getExcelData($file_path);
6666
return isset($data['data']) ? count($data['data']) : 0;
@@ -91,7 +91,7 @@ function isName($name)
9191
*/
9292
function convertUnderline($str)
9393
{
94-
$str = preg_replace_callback('/([-_]+([a-z]{1}))/i', function($matches) {
94+
$str = preg_replace_callback('/([-_]+([a-z]{1}))/i', function ($matches) {
9595
return strtoupper($matches[2]);
9696
}, $str);
9797
return $str;
@@ -104,8 +104,34 @@ function convertUnderline($str)
104104
*/
105105
function humpToLine($str)
106106
{
107-
$str = preg_replace_callback('/([A-Z]{1})/', function($matches) {
108-
return '_'.strtolower($matches[0]);
107+
$str = preg_replace_callback('/([A-Z]{1})/', function ($matches) {
108+
return '_' . strtolower($matches[0]);
109109
}, $str);
110110
return $str;
111111
}
112+
113+
/**
114+
* 加密算法: AES/ECB/PKCS5Padding
115+
* @param $aesKey
116+
* @param $data
117+
* @param string $iv
118+
* @return string
119+
*/
120+
function aesEncrypt($aesKey, $data, $iv = '')
121+
{
122+
$encrypted = openssl_encrypt($data, 'aes-128-ecb', $aesKey, OPENSSL_RAW_DATA, $iv);
123+
return base64_encode($encrypted);
124+
}
125+
126+
/**
127+
* 解密算法: AES/ECB/PKCS5Padding
128+
* @param $aesKey
129+
* @param $data
130+
* @param string $iv
131+
* @return false|string
132+
*/
133+
function aesDecrypt($aesKey, $data, $iv = '')
134+
{
135+
$encrypted = base64_decode($data);
136+
return openssl_decrypt($encrypted, 'aes-128-ecb', $aesKey, OPENSSL_RAW_DATA, $iv);
137+
}

laravel/app/Http/Controllers/Api/ApiExcelController.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function __construct(Request $request)
4343
/**
4444
* Display a listing of the resource.
4545
*
46-
* @return \Illuminate\Http\Response
46+
* @return \Illuminate\Http\JsonResponse
4747
*/
48-
public function index(Request $request)
48+
public function index()
4949
{
5050
$user_id = auth('api')->user()['id'];
5151

@@ -54,8 +54,7 @@ public function index(Request $request)
5454
if ($user_id != 1) {
5555
$where = ['uid' => $user_id];
5656
}
57-
$perPage = intval($request->input('perPage'));
58-
$perPage = $perPage ?? 20;
57+
$perPage = $this->getPerPage();
5958
$list = ApiExcel::with('apiParam')->where($where)->orderBy('id', 'desc')->paginate($perPage);
6059
// 获取完成进度情况
6160
$list = ApiRepository::getInstent()->workProgress($list);
@@ -72,7 +71,7 @@ public function index(Request $request)
7271
*
7372
* @param Request $request
7473
*
75-
* @return \Illuminate\Http\Response
74+
* @return \Illuminate\Http\JsonResponse
7675
*/
7776
public function upload(Request $request)
7877
{
@@ -109,7 +108,7 @@ public function upload(Request $request)
109108
/**
110109
* 将任务放入队列处理
111110
*
112-
* @return \Illuminate\Http\Response
111+
* @return \Illuminate\Http\JsonResponse
113112
*/
114113
public function startTask(Request $request)
115114
{
@@ -163,7 +162,7 @@ public function startTask(Request $request)
163162
/**
164163
* Show the form for creating a new resource.
165164
*
166-
* @return \Illuminate\Http\Response
165+
* @return \Illuminate\Http\JsonResponse
167166
*/
168167
public function create()
169168
{
@@ -175,7 +174,7 @@ public function create()
175174
* 新增入库操作
176175
*
177176
* @param Store $request
178-
* @return \Illuminate\Http\Response
177+
* @return \Illuminate\Http\JsonResponse
179178
*/
180179
public function store(Store $request)
181180
{
@@ -198,7 +197,7 @@ public function store(Store $request)
198197
*
199198
* @param ApiExcel $apiExcel
200199
*
201-
* @return \Illuminate\Http\Response
200+
* @return \Illuminate\Http\JsonResponse
202201
*/
203202
public function show(ApiExcel $apiExcel)
204203
{
@@ -211,7 +210,7 @@ public function show(ApiExcel $apiExcel)
211210
*
212211
* @param int $id
213212
*
214-
* @return \Illuminate\Http\Response
213+
* @return \Illuminate\Http\JsonResponse
215214
*/
216215
public function edit($id)
217216
{
@@ -225,7 +224,7 @@ public function edit($id)
225224
*
226225
* @param Update $request
227226
* @param int $id
228-
* @return \Illuminate\Http\Response
227+
* @return \Illuminate\Http\JsonResponse
229228
*/
230229
public function update(Update $request, $id)
231230
{
@@ -245,7 +244,7 @@ public function update(Update $request, $id)
245244
* Remove the specified resource from storage.
246245
*
247246
* @param int $id
248-
* @return \Illuminate\Http\Response
247+
* @return \Illuminate\Http\JsonResponse
249248
*/
250249
public function destroy($id)
251250
{
@@ -262,7 +261,7 @@ public function destroy($id)
262261
*
263262
* @param $id
264263
*
265-
* @return \Illuminate\Http\Response
264+
* @return \Illuminate\Http\JsonResponse
266265
*/
267266
public function restore($id)
268267
{
@@ -276,7 +275,7 @@ public function restore($id)
276275
*
277276
* @param $id
278277
*
279-
* @return \Illuminate\Http\Response
278+
* @return \Illuminate\Http\JsonResponse
280279
*/
281280
public function forceDelete($id)
282281
{
@@ -288,7 +287,7 @@ public function forceDelete($id)
288287
/**
289288
* 下载已完成数据
290289
*
291-
* @return \Illuminate\Http\Response
290+
* @return \Illuminate\Http\JsonResponse
292291
*/
293292
public function downloadLog(Request $request)
294293
{

laravel/app/Http/Controllers/Api/ApiParamController.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use App\Http\Requests\ApiParam\Update;
77
use App\Models\ApiParam;
88
use App\Http\Controllers\Controller;
9-
use Illuminate\Http\Request;
109

1110
class ApiParamController extends Controller
1211
{
@@ -21,7 +20,7 @@ class ApiParamController extends Controller
2120
*
2221
* @return void
2322
*/
24-
public function __construct(Request $request)
23+
public function __construct()
2524
{
2625
// 这里额外注意了:官方文档样例中只除外了『login』
2726
// 这样的结果是,token 只能在有效期以内进行刷新,过期无法刷新
@@ -35,20 +34,20 @@ public function __construct(Request $request)
3534
/**
3635
* Display a listing of the resource.
3736
*
38-
* @return \Illuminate\Http\Response
37+
* @return \Illuminate\Http\JsonResponse
3938
*/
40-
public function index(Request $request)
39+
public function index()
4140
{
42-
$perPage = intval($request->input('perPage'));
43-
$perPage = $perPage ?? 20;
44-
$list = ApiParam::orderBy('id', 'desc')->paginate($perPage);
41+
$perPage = $this->getPerPage();
42+
// 1. 增加customer用户,并增加排序操作
43+
$list = ApiParam::orderBy('sort_index', 'desc')->orderBy('id', 'desc')->where('state', 1)->paginate($perPage);
4544
return $this->out(200, $list);
4645
}
4746

4847
/**
4948
* Show the form for creating a new resource.
5049
*
51-
* @return \Illuminate\Http\Response
50+
* @return \Illuminate\Http\JsonResponse
5251
*/
5352
public function create()
5453
{
@@ -60,7 +59,7 @@ public function create()
6059
* 新增入库操作
6160
*
6261
* @param Store $request
63-
* @return \Illuminate\Http\Response
62+
* @return \Illuminate\Http\JsonResponse
6463
*/
6564
public function store(Store $request)
6665
{
@@ -83,7 +82,7 @@ public function store(Store $request)
8382
*
8483
* @param ApiParam $apiParam
8584
*
86-
* @return \Illuminate\Http\Response
85+
* @return \Illuminate\Http\JsonResponse
8786
*/
8887
public function show(ApiParam $apiParam)
8988
{
@@ -96,7 +95,7 @@ public function show(ApiParam $apiParam)
9695
*
9796
* @param int $id
9897
*
99-
* @return \Illuminate\Http\Response
98+
* @return \Illuminate\Http\JsonResponse
10099
*/
101100
public function edit($id)
102101
{
@@ -110,7 +109,7 @@ public function edit($id)
110109
*
111110
* @param Update $request
112111
* @param int $id
113-
* @return \Illuminate\Http\Response
112+
* @return \Illuminate\Http\JsonResponse
114113
*/
115114
public function update(Update $request, $id)
116115
{
@@ -130,7 +129,7 @@ public function update(Update $request, $id)
130129
* Remove the specified resource from storage.
131130
*
132131
* @param int $id
133-
* @return \Illuminate\Http\Response
132+
* @return \Illuminate\Http\JsonResponse
134133
* @throws \Exception
135134
*/
136135
public function destroy($id)

laravel/app/Http/Controllers/Api/ArticleController.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
use App\Http\Requests\Article\Update;
77
use App\Models\Article;
88
use App\Http\Controllers\Controller;
9-
use Illuminate\Http\Request;
109

1110
class ArticleController extends Controller
1211
{
13-
/**
14-
* @var int 默认分页条数
15-
*/
16-
public $perPage = 10;
17-
1812
/**
1913
* Create a new AuthController instance.
2014
* 要求附带email和password(数据来源users表)
2115
*
2216
* @return void
2317
*/
24-
public function __construct(Request $request)
18+
public function __construct()
2519
{
2620
// 这里额外注意了:官方文档样例中只除外了『login』
2721
// 这样的结果是,token 只能在有效期以内进行刷新,过期无法刷新
@@ -30,26 +24,23 @@ public function __construct(Request $request)
3024
$this->middleware(['auth:api', 'role']);
3125
// 另外关于上面的中间件,官方文档写的是『auth:api』
3226
// 但是我推荐用 『jwt.auth』,效果是一样的,但是有更加丰富的报错信息返回
33-
34-
$perPage = intval($request->input('perPage'));
35-
$this->perPage = $perPage ?? 11;
3627
}
3728

3829
/**
3930
* Display a listing of the resource.
4031
*
41-
* @return \Illuminate\Http\Response
32+
* @return \Illuminate\Http\JsonResponse
4233
*/
4334
public function index()
4435
{
45-
$list = Article::orderBy('id', 'DESC')->select('id', 'title', 'author', 'keywords', 'created_at')->paginate($this->perPage);
36+
$list = Article::orderBy('id', 'DESC')->select('id', 'title', 'author', 'keywords', 'created_at')->paginate($this->getPerPage());
4637
return $this->out(200, $list);
4738
}
4839

4940
/**
5041
* Show the form for creating a new resource.
5142
*
52-
* @return \Illuminate\Http\Response
43+
* @return \Illuminate\Http\JsonResponse
5344
*/
5445
public function create()
5546
{
@@ -61,7 +52,7 @@ public function create()
6152
* 新增入库操作
6253
*
6354
* @param Store $request
64-
* @return \Illuminate\Http\Response
55+
* @return \Illuminate\Http\JsonResponse
6556
*/
6657
public function store(Store $request)
6758
{
@@ -83,7 +74,7 @@ public function store(Store $request)
8374
*
8475
* @param Article $article
8576
*
86-
* @return \Illuminate\Http\Response
77+
* @return \Illuminate\Http\JsonResponse
8778
*/
8879
public function show(Article $article)
8980
{
@@ -96,7 +87,7 @@ public function show(Article $article)
9687
*
9788
* @param int $id
9889
*
99-
* @return \Illuminate\Http\Response
90+
* @return \Illuminate\Http\JsonResponse
10091
*/
10192
public function edit($id)
10293
{
@@ -110,7 +101,7 @@ public function edit($id)
110101
*
111102
* @param Update $request
112103
* @param int $id
113-
* @return \Illuminate\Http\Response
104+
* @return \Illuminate\Http\JsonResponse
114105
*/
115106
public function update(Update $request, $id)
116107
{
@@ -132,7 +123,7 @@ public function update(Update $request, $id)
132123
* Remove the specified resource from storage.
133124
*
134125
* @param int $id
135-
* @return \Illuminate\Http\Response
126+
* @return \Illuminate\Http\JsonResponse
136127
* @throws \Exception
137128
*/
138129
public function destroy($id)

0 commit comments

Comments
 (0)