Skip to content

Commit ab1b24c

Browse files
committed
维护好友列表脚本
1 parent 275c5f5 commit ab1b24c

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

app/Controller/IndexController.php

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace App\Controller;
66

77
use App\Foundation\Utils\GroupAvatar;
8+
use App\Model\Auth\User;
9+
use App\Model\Laboratory\FriendRelation;
810
use Hyperf\HttpServer\Annotation\Controller;
911
use Hyperf\HttpServer\Annotation\RequestMapping;
1012

@@ -21,24 +23,37 @@ class IndexController extends AbstractController
2123
*/
2224
public function index()
2325
{
24-
$picList = [
25-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face1.png',
26-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face2.png',
27-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face3.png',
28-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face4.png',
29-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face5.png',
30-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face6.png',
31-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face7.png',
32-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face8.png',
33-
'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face9.png',
34-
];
3526

36-
GroupAvatar::init($picList, false, '121312');
37-
$res = GroupAvatar::build();
38-
39-
40-
return $this->success([
41-
'list' => $res
42-
]);
27+
$user = User::query()->get()->toArray();
28+
foreach ($user as $item) {
29+
foreach ($user as $key) {
30+
if ($key['id'] == $item['id']) continue;
31+
FriendRelation::query()->insert([
32+
'uid' => $item['id'],
33+
'friend_id' => $key['id'],
34+
'created_at' => date('Y-m-d H:i:s'),
35+
'updated_at' => date('Y-m-d H:i:s'),
36+
]);
37+
}
38+
}
39+
// $picList = [
40+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face1.png',
41+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face2.png',
42+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face3.png',
43+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face4.png',
44+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face5.png',
45+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face6.png',
46+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face7.png',
47+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face8.png',
48+
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face9.png',
49+
// ];
50+
//
51+
// GroupAvatar::init($picList, false, '121312');
52+
// $res = GroupAvatar::build();
53+
//
54+
//
55+
// return $this->success([
56+
// 'list' => $res
57+
// ]);
4358
}
4459
}

0 commit comments

Comments
 (0)