Files
dafuweng-saiadmin6.x/server/app/dice/logic/player/DicePlayerLogic.php
zhenhui dd264b1e97 1.将部门修改为渠道,并且所有dice_表关联渠道表
2.将所有配置表,记录表设置关联渠道
3.优化后台页面设置
2026-05-19 09:49:02 +08:00

62 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\dice\logic\player;
use app\dice\basic\DiceBaseLogic;
use plugin\saiadmin\exception\ApiException;
use plugin\saiadmin\utils\Helper;
use app\dice\model\player\DicePlayer;
/**
* 大富翁-玩家逻辑层
*/
class DicePlayerLogic extends DiceBaseLogic
{
/** 密码加密盐(可与 config 统一) */
private const PASSWORD_SALT = 'dice_player_salt_2024';
/**
* 构造函数
*/
public function __construct()
{
$this->model = new DicePlayer();
}
/**
* 添加数据(密码 md5+salt 加密)
*/
public function add(array $data): mixed
{
if (!empty($data['password'])) {
$data['password'] = $this->hashPassword($data['password']);
}
return parent::add($data);
}
/**
* 修改数据(仅当传入 password 时用 md5+salt 加密后更新)
*/
public function edit($id, array $data): mixed
{
if (isset($data['password']) && $data['password'] !== '') {
$data['password'] = $this->hashPassword($data['password']);
} else {
unset($data['password']);
}
return parent::edit($id, $data);
}
/**
* 密码加密md5(salt . password)
*/
private function hashPassword(string $password): string
{
return md5(self::PASSWORD_SALT . $password);
}
}