• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / app / 13100242664

02 Feb 2025 03:42PM UTC coverage: 22.581%. Remained the same
13100242664

push

github

semantic-release-bot
chore(release): publish

See CHANGELOG.md for more details.

42 of 186 relevant lines covered (22.58%)

3.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Service/LoginLogModel.php
1
<?php
2

3
namespace Miaoxing\App\Service;
4

5
use Miaoxing\Plugin\BaseModel;
6
use Miaoxing\Plugin\Model\HasAppIdTrait;
7
use Miaoxing\Plugin\Model\IpTrait;
8
use Miaoxing\Plugin\Model\ModelTrait;
9
use Miaoxing\Plugin\Model\ReqQueryTrait;
10
use Miaoxing\Plugin\Service\User;
11

12
/**
13
 * @mixin \StrPropMixin
14
 * @property string|null $id
15
 * @property string $appId 应用编号
16
 * @property string $userId
17
 * @property string $username 用户名
18
 * @property int $type 操作类型
19
 * @property int $code 返回代码
20
 * @property string $message 返回消息
21
 * @property int $platform 平台,默认为浏览器
22
 * @property string $userAgent 用户代理
23
 * @property string|null $createdAt 创建时间
24
 * @property string $createdBy 创建用户编号
25
 * @property string $createdIp 创建用户 IP
26
 * @property string $createdIpAddress 创建用户地址
27
 */
28
class LoginLogModel extends BaseModel
29
{
30
    use HasAppIdTrait;
31
    use IpTrait;
32
    use ModelTrait;
33
    use ReqQueryTrait;
34

35
    public const TYPE_LOGIN = 1;
36

37
    public const TYPE_LOGIN_FAILED = 2;
38

39
    public const TYPE_LOGOUT = 3;
40

41
    /**
42
     * 记录登录日志
43
     *
44
     * @param array $data
45
     * @svc
46
     */
47
    protected function log(array $data)
48
    {
49
        $user = User::cur();
×
50
        $this->saveAttributes(array_merge([
×
51
            'userId' => $user->id ?? 0,
×
52
            'username' => $user->username ?? '',
×
53
            'userAgent' => $this->str->cut($this->req->getHeader('USER_AGENT'), 255),
×
54
        ], $data));
×
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc