Skip to content

Commit eae333d

Browse files
author
xxx
committed
新增:后台学员实名信息删除接口
1 parent 729ebc4 commit eae333d

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

app/Http/Controllers/Backend/Api/V1/MemberController.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,13 @@ public function sendMessageMulti(Request $request)
496496
$userIds = $request->input('user_ids');
497497

498498
if (!is_array($userIds) || !$userIds) {
499-
return $this->error('请选择需要发送消息的用户');
499+
return $this->error(__('请选择需要发送消息的用户'));
500500
}
501501
if (!$message) {
502-
return $this->error('请输入需要发送的消息');
502+
return $this->error(__('请输入需要发送的消息'));
503503
}
504504
if (count($userIds) > 100) {
505-
return $this->error('单次发送消息不能超过100人');
505+
return $this->error(__('单次发送消息不能超过100人'));
506506
}
507507

508508
AdministratorLog::storeLog(
@@ -728,7 +728,7 @@ public function updateFieldMulti(Request $request)
728728
{
729729
$userIds = $request->input('user_ids');
730730
if (!$userIds || !is_array($userIds)) {
731-
return $this->error('请选择需要修改的用户');
731+
return $this->error(__('请选择需要修改的用户'));
732732
}
733733

734734
// 要更改的字段
@@ -745,12 +745,12 @@ public function updateFieldMulti(Request $request)
745745
'is_lock', 'is_active', 'role_id', 'role_expired_at', 'is_password_set', 'is_set_nickname', 'tag',
746746
];
747747
if (!$field || !in_array($field, $fieldsWhitelist)) {
748-
return $this->error('待修改字段不合法');
748+
return $this->error(__('待修改字段不合法'));
749749
}
750750

751751
// 如果选择了有效的roleId的话,那么role_expired_at则必须是有效的时间
752752
if ($field === 'role_id' && (int)$value && !$roleExpiredAt) {
753-
return $this->error('请选择VIP过期时间');
753+
return $this->error(__('请选择VIP过期时间'));
754754
}
755755

756756
AdministratorLog::storeLog(
@@ -782,4 +782,16 @@ public function updateFieldMulti(Request $request)
782782

783783
return $this->success();
784784
}
785+
786+
public function deleteUserProfile($userId)
787+
{
788+
$userProfile = UserProfile::query()->where('user_id', $userId)->first();
789+
if (!$userProfile) {
790+
return $this->error(__('当前学员未完成实名认证'));
791+
}
792+
793+
$userProfile->forceDelete();
794+
795+
return $this->success();
796+
}
785797
}

database/seeders/AdministratorPermissionSeeder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ public function run()
382382
'method' => 'DELETE',
383383
'url' => 'member/\d+',
384384
],
385+
[
386+
'display_name' => '学员-实名信息-删除',
387+
'slug' => 'member.profile.destroy',
388+
'method' => 'DELETE',
389+
'url' => 'member/\d+/profile',
390+
],
385391

386392
// 学员标签
387393
[

routes/backend-v1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
Route::get('/{id}', 'MemberController@edit');
204204
Route::post('/', 'MemberController@store');
205205
Route::put('/{id}', 'MemberController@update');
206+
Route::delete('/{id}/profile', 'MemberController@deleteUserProfile');
206207
Route::put('/field/multi', 'MemberController@updateFieldMulti');
207208

208209
// 更新用户标签

0 commit comments

Comments
 (0)