Skip to content

Commit 6394edf

Browse files
committed
fix bug
1 parent 4af674c commit 6394edf

21 files changed

+775
-66
lines changed

app/Command/InitCommand.php

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace App\Command;
66

77
use App\Model\Auth\User;
8+
use App\Model\System\DictData;
9+
use App\Model\System\DictType;
810
use Hyperf\Command\Command as HyperfCommand;
911
use Hyperf\Command\Annotation\Command;
1012
use Donjan\Permission\Models\Permission;
@@ -73,6 +75,17 @@ public function handle()
7375
$this->line('添加权限成功----------------------------' . $permission['display_name']);
7476
}
7577

78+
//初始化字典数据
79+
$dictTypeList = config('dictData.dict_type');
80+
foreach ($dictTypeList as $dictType) {
81+
if (empty(DictType::query()->find($dictType['dict_id']))) DictType::query()->insert($dictType);
82+
}
83+
$dictDataList = config('dictData.dict_data');
84+
foreach ($dictDataList as $dictData) {
85+
if (empty(DictData::query()->find($dictData['dict_code']))) DictData::query()->insert($dictData);
86+
}
87+
$this->line('初始化字典数据成功', 'info');
88+
7689
//添加默认角色到默认用户
7790
$user->assignRole($super_role->name);
7891
// 通过内置方法 line 在 Console 输出 Hello Hyperf.

app/Controller/Auth/UserController.php

+17-10
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function store()
100100
//配置验证
101101
$rules = [
102102
'username' => 'required|min:4|max:18|unique:users',
103-
'password' => 'required|confirmed:password_confirmation',
103+
'password' => 'required|min:6|max:18|confirmed:password_confirmation',
104104
'password_confirmation' => 'required',
105105
'status' => 'required',
106106
'mobile' => 'required',
@@ -116,6 +116,8 @@ public function store()
116116
'roleData.array' => '[roleData]必须为数组',
117117
'username.min' => '[username]最少4位',
118118
'username.max' => '[username]最多18位',
119+
'password.min' => '[password]最少6位',
120+
'password.max' => '[password]最多18位',
119121
'password.confirmed' => '两次密码输入不一致',
120122
'mobile.required' => '手机号码不能为空',
121123
];
@@ -133,6 +135,7 @@ public function store()
133135
$user->desc = $postData['desc'] ?? '';
134136
$user->mobile = $postData['mobile'] ?? '';
135137
$user->email = $postData['email'] ?? '';
138+
$user->address = $postData['address'] ?? '';
136139
$user->sex = $postData['sex'] ?? 0;
137140
if (!$user->save()) $this->throwExp(StatusCode::ERR_EXCEPTION, '添加用户失败');
138141

@@ -203,6 +206,7 @@ public function profileEdit($id)
203206
$user->desc = $postData['desc'] ?? '';
204207
$user->mobile = $postData['mobile'] ?? '';
205208
$user->sex = $postData['sex'] ?? '';
209+
$user->address = $postData['address'] ?? '';
206210
if (!$user->save()) $this->throwExp(StatusCode::ERR_EXCEPTION, '修改用户信息失败');
207211

208212
//正确返回信息
@@ -312,6 +316,9 @@ public function update(int $id)
312316
$user->desc = $postData['desc'] ?? '';
313317
$user->mobile = $postData['mobile'] ?? '';
314318
$user->sex = $postData['sex'] ?? '';
319+
$user->address = $postData['address'] ?? '';
320+
$user->email = $postData['email'] ?? '';
321+
$user->status = $postData['status'] ?? '';
315322
if (!$user->save()) $this->throwExp(StatusCode::ERR_EXCEPTION, '修改用户信息失败');
316323

317324
//将所有角色移除并重新赋予角色
@@ -349,44 +356,44 @@ public function destroy(int $id)
349356
/**
350357
* @Explanation(content="修改用户密码")
351358
* @RequestMapping(path="reset_password", methods="post")
352-
* @Middleware(RequestMiddleware::class)
359+
* @Middlewares({
360+
* @Middleware(RequestMiddleware::class),
361+
* @Middleware(PermissionMiddleware::class)
362+
* })
353363
* @return \Psr\Http\Message\ResponseInterface
354364
*/
355365
public function resetPassword()
356366
{
357-
$postData = $this->request->all() ?? [];
367+
$postData = $this->request->all()['postData'] ?? [];
358368
$params = [
359-
'id' => $postData['id'],
360-
'old_password' => $postData['old_password'] ?? '',
369+
'id' => $postData['uid'],
361370
'new_password' => $postData['new_password'] ?? '',
362371
'confirm_password' => $postData['confirm_password'] ?? '',
363372
];
364373
//配置验证
365374
$rules = [
366375
'id' => 'required',
367-
'old_password' => 'required',
368-
'new_password' => 'required',
376+
'new_password' => 'required|min:6|max:18',
369377
'confirm_password' => 'required',
370378
];
371379
$message = [
372380
'id.required' => '[id]缺失',
373-
'old_password.required' => '[old_password]缺失',
374381
'new_password.required' => '[new_password]缺失',
382+
'new_password.min' => '[new_password]最少6位',
383+
'new_password.max' => '[new_password]最多18位',
375384
'confirm_password.required' => '[confirm_password]缺失',
376385
];
377386

378387
$this->verifyParams($params, $rules, $message);
379388
$userInfo = User::getOneByUid($params['id']);
380389

381390
if (empty($userInfo)) $this->throwExp(400, '账号不存在');
382-
if (md5($params['old_password']) != $userInfo['password']) $this->throwExp(StatusCode::ERR_EXCEPTION, '输入密码与原先密码不一致');
383391
if (md5($params['new_password']) != md5($params['confirm_password'])) $this->throwExp(StatusCode::ERR_EXCEPTION, '两次密码输入不一致');
384392

385393
$userInfo->password = md5($params['new_password']);
386394
$updateRes = $userInfo->save();
387395

388396
if (!$updateRes) $this->throwExp(400, '修改密码失败');
389-
390397
return $this->success([], '修改密码成功');
391398
}
392399

app/Controller/Blog/AlbumController.php

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function index()
6161
* @RequestMapping(path="album_option", methods="get")
6262
* @Middlewares({
6363
* @Middleware(RequestMiddleware::class),
64-
* @Middleware(PermissionMiddleware::class)
6564
* })
6665
*/
6766
public function albumOptionList()

app/Controller/Setting/TimedTaskController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ public function store()
100100
$timedTaskQuery->execute_time = $params['execute_time'];
101101
$timedTaskQuery->status = $params['status'];
102102
$timedTaskQuery->desc = $params['desc'];
103+
$timedTaskQuery->times = 0;
103104

104-
$executeTime = $timedTaskInfo['execute_time'] ?? '';
105+
$executeTime = $params['execute_time'] ?? '';
105106
$nextExecuteTime = Cron::init($executeTime)->getNextRunDate()->format('Y-m-d H:i');
106107
$timedTaskQuery->next_execute_time = $nextExecuteTime;
107108

app/Controller/System/DictTypeController.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,13 @@ public function update(int $id)
143143
];
144144
$rules = [
145145
'dict_name' => 'required|min:4|max:18|',
146-
'dict_type' => 'required|unique:dict_type',
146+
'dict_type' => 'required',
147147
];
148148
$message = [
149149
'dict_name.required' => '[dict_name]缺失',
150150
'dict_name.min' => '[dict_name]最少4位',
151151
'dict_name.max' => '[dict_name]最多18位',
152152
'dict_type.required' => '[dict_type]缺失',
153-
'dict_type.unique' => '[dict_type]已经存在',
154153
];
155154
$this->verifyParams($params, $rules, $message);
156155

app/Controller/System/NoticeController.php

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function store()
101101
$noticeQuery->content = $params['content'];
102102
$noticeQuery->public_time = strtotime($params['public_time']);
103103
$noticeQuery->user_id = conGet('user_info')['id'];
104+
$noticeQuery->username = conGet('user_info')['desc'];
104105

105106
if (!$noticeQuery->save()) $this->throwExp(StatusCode::ERR_EXCEPTION, '添加系统通知错误');
106107

app/Model/Laboratory/Group.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class Group extends Model
1111
{
12-
use SoftDeletes;
13-
1412
/**
1513
* The table associated with the model.
1614
*

app/Model/Laboratory/GroupChatHistory.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
class GroupChatHistory extends Model
1818
{
19-
use SoftDeletes;
20-
2119
/**
2220
* The table associated with the model.
2321
*

app/Model/Laboratory/GroupRelation.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
class GroupRelation extends Model
1818
{
19-
use SoftDeletes;
20-
2119
/**
2220
* The table associated with the model.
2321
*

0 commit comments

Comments
 (0)