4
0
Fork 0
dcat-admin-user/README.md

125 lines
4.1 KiB
Markdown

# Dcat Admin Extension
用户管理
## 安装
- 进入项目目录
- `mkdir packages && cd packages`
- `git clone https://gitea.peidikeji.cn/pdkj/dcat-admin-user.git`
- `composer config repositories.peidikeji/dcat-admin-user path ./packages/dcat-admin-user`
- `composer require peidikeji/dcat-admin-user`
- `php artisan migrate`
### 配置
- `config/auth.php`
```php
[
'guards' => [
'api' => [
'driver' => 'sanctum',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => Peidikeji\User\Models\User::class,
],
],
];
```
## 事件
- 用户注册成功: `Peidikeji\User\Events\UserRegister`
## 测试数据
- 复制文件: `database/factories/UserFactory`, `database/seeders/UserSeeder`
## 后台权限
```php
$permissions = [
'users' => ['name' => '用户管理', 'curd' => true, 'children' => ['balance' => '变更余额', 'password' => '重置密码']],
'user-balance' => ['name' => '余额流水', 'curd' => ['index', 'show']],
];
```
## 后台菜单
```php
$menus = [
['title' => '用户模块', 'icon' => 'feather icon-user', 'uri' => '/users', 'permission' => ['users', 'user_balance'], 'children' => [
['title' => '用户管理', 'icon' => '', 'uri' => '/users', 'permission' => 'users'],
['title' => '余额流水', 'icon' => '', 'uri' => '/user-balance', 'permission' => 'user_balance'],
]],
];
```
## 数据表
### 用户表: users
| column | type | nullable | default | comment |
| - | - | - | - | - |
| id | bigint | not null | - | 主键 |
| username | varchar(191) | null | - | 用户名 |
| phone | varchar(191) | null | - | 手机号 |
| name | varchar(191) | null | - | 昵称 |
| avatar | varchar(191) | null | - | 头像 |
| balance | decimal(12, 2) | not null | 0 | 余额 |
| invite_code | varchar(191) | not null | - | 邀请码 |
| inviter_id | bigint | null | - | 邀请人 |
| inviter_path | varchart(191) | not null | '-' | 所有的上级邀请人(-1-2-3-) |
| created_at | timestamp | null | - | 创建时间 |
| updated_at | timestamp | null | - | 更新时间 |
### 第三方登录信息: user_socialites
| column | type | nullable | default | comment |
| - | - | - | - | - |
| id | bigint | not null | - | 主键 |
| user_id | bigint | not null | - | 外键关联 users.id |
| type | varchar(191) | not null | - | 类型(SocialiteType) |
| openid | varchar(191) | not null | - | 第三方唯一凭证 |
| unionid | varchar(191) | null | - | 第三方唯一凭证 |
| data | json | null | - | 第三方数据 |
| created_at | timestamp | null | - | 创建时间 |
| updated_at | timestamp | null | - | 更新时间 |
### 用户余额变动记录: user_balance_logs
| column | type | nullable | default | comment |
| - | - | - | - | - |
| id | bigint | not null | - | 主键 |
| user_id | bigint | not null | - | 外键关联 users.id |
| cate | varchar(191) | not null | - | 类别 |
| description | varchar(191) | not null | - | 描述 |
| amount | decimal(12, 2) | not null | - | 变动数量(正数为增加, 负数为减少) |
| balance | decimal(12, 2) | not null | - | 变动后的余额 |
| remarks | varchart(191) | null | - | 备注 |
| source_type | varchart(191) | null | - | 来源(多态关联) |
| source_id | bigint | null | - | 来源(多态关联) |
| created_at | timestamp | null | - | 创建时间 |
| updated_at | timestamp | null | - | 更新时间 |
## 收货地址: user_address
| column | type | nullable | default | comment |
| - | - | - | - | - |
| id | bigint | not null | - | 主键 |
| user_id | bigint | not null | - | 外键关联 users.id |
| contact_name | varchar(191) | not null | - | 联系人 |
| phone | varchar(191) | not null | - | 电话 |
| address | varchar(191) | not null | - | 地址 |
| province_id | bigint | null | - | 所属地区 |
| city_id | bigint | null | - | 所属地区 |
| area_id | bigint | null | - | 所属地区 |
| is_default | int | not null | 0 | 默认地址 |
| created_at | timestamp | null | - | 创建时间 |
| updated_at | timestamp | null | - | 更新时间 |