|
@@ -5,7 +5,9 @@ namespace app\admin\logic;
|
|
|
use app\model\AccountBatchLogModel;
|
|
|
use app\model\AccountModel;
|
|
|
use app\model\CommonModel;
|
|
|
+use app\model\VideoModel;
|
|
|
use think\Exception;
|
|
|
+use think\exception\ValidateException;
|
|
|
use think\facade\Config;
|
|
|
use think\facade\Db;
|
|
|
use think\response\Json;
|
|
@@ -81,8 +83,13 @@ class AccountLogic extends BaseLogic
|
|
|
{
|
|
|
$res = AccountModel::field(true)
|
|
|
->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
|
|
|
- ->withAttr('video_ids', function ($val) {
|
|
|
- return explode(',', $val);
|
|
|
+ ->append(['video_list'])
|
|
|
+ ->withAttr('video_list', function ($val, $data) {
|
|
|
+ return VideoModel::field('id,video_name')
|
|
|
+ ->whereIn('id', $data['video_ids'])
|
|
|
+ ->where('is_del', CommonModel::$del_normal)
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
})
|
|
|
->findOrEmpty()
|
|
|
->toArray();
|
|
@@ -158,4 +165,31 @@ class AccountLogic extends BaseLogic
|
|
|
return json_show(CommonModel::$success, '获取批量添加账户列表成功', ['count' => $count, 'list' => $list]);
|
|
|
}
|
|
|
|
|
|
+ //修改密码
|
|
|
+ public static function changePasswod(array $data = []): Json
|
|
|
+ {
|
|
|
+ $rs = AccountModel::where(['id' => $data['id'], 'is_del' => CommonModel::$del_normal])
|
|
|
+ ->field('id')
|
|
|
+ ->findOrEmpty()
|
|
|
+ ->isEmpty();
|
|
|
+
|
|
|
+ if ($rs) throw new ValidateException('该账户不存在');
|
|
|
+
|
|
|
+ $salt = randomkeys(6);
|
|
|
+ $password = getPassword($data['new_password'], $salt);
|
|
|
+
|
|
|
+ $da = [
|
|
|
+ 'pwd' => $data['new_password'],
|
|
|
+ 'salt' => $salt,
|
|
|
+ 'password' => $password,
|
|
|
+ 'updaterid' => self::$uid,
|
|
|
+ 'updater' => self::$uname,
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $rs = AccountModel::where(['id' => $data['id'], 'is_del' => CommonModel::$del_normal])
|
|
|
+ ->save($da);
|
|
|
+
|
|
|
+ return $rs ? json_show(CommonModel::$success, '更改密码成功') : json_show(CommonModel::$error_param, '更改密码失败');
|
|
|
+ }
|
|
|
}
|