修复token验证和左侧表单问题

This commit is contained in:
2025-08-19 17:48:53 +08:00
parent 1ceaeb9214
commit 2d44b8764d
39 changed files with 1461 additions and 554 deletions
+227 -14
View File
@@ -2,8 +2,8 @@
namespace app\api\controller;
use app\api\controller\BaseController;
use app\admin\model\AdminUser;
use app\index\model\AdminUserGroup;
use app\api\model\AdminUser;
use app\api\model\AdminSysMenu;
use think\facade\Log;
use think\facade\Cache;
@@ -12,9 +12,9 @@ use think\Response;
class AdminController extends BaseController
{
/**
* 生成用户token
* 生成管理员token
*
* @param int $userId 用户ID
* @param int $userId 管理员ID
* @return string
*/
private function generateToken($userId)
@@ -31,7 +31,27 @@ class AdminController extends BaseController
}
/**
* 用户登录接口
* 从token中获取管理员ID
*
* @param string $token
* @return int|null
*/
private function getUserIdFromToken($token)
{
try {
$data = json_decode(base64_decode($token), true);
if ($data && isset($data['user_id'])) {
return $data['user_id'];
}
} catch (\Exception $e) {
return null;
}
return null;
}
/**
* 管理员登录接口
*
* @return \think\Response
*/
@@ -58,10 +78,10 @@ class AdminController extends BaseController
return json(['code' => 1, 'msg' => $validate->getError()]);
}
// 查询用户
// 查询管理员
$user = AdminUser::where('account', $data['account'])->find();
if (!$user) {
return json(['code' => 1, 'msg' => '用户不存在']);
return json(['code' => 1, 'msg' => '管理员不存在']);
}
// 验证密码
@@ -69,23 +89,23 @@ class AdminController extends BaseController
return json(['code' => 1, 'msg' => '密码错误']);
}
// 生成JWT token(这里使用简单的token,实际项目中建议使用JWT)
$token = $this->generateToken($user->id);
// 生成token
$token = $this->generateToken($user->uid);
// 将token存储到缓存中,设置过期时间
Cache::set('user_token_' . $user->id, $token, 7 * 24 * 3600);
Cache::set('admin_token_' . $user->uid, $token, 7 * 24 * 3600);
// 记录登录日志
Log::record('用户登录成功:' . $user->account, 'info');
Log::record('管理员登录成功:' . $user->account, 'info');
// 返回用户信息和token
// 返回管理员信息和token
return json([
'code' => 0,
'msg' => '登录成功',
'data' => [
'token' => $token,
'user_info' => [
'id' => $user->id,
'id' => $user->uid,
'account' => $user->account,
'name' => $user->name,
'avatar' => $user->avatar ?? '/static/images/avatar.png',
@@ -99,8 +119,201 @@ class AdminController extends BaseController
]);
} catch (\Exception $e) {
Log::record('登录失败:' . $e->getMessage(), 'error');
Log::record('管理员登录失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '登录失败:' . $e->getMessage()]);
}
}
/**
* 退出登录接口
*
* @return \think\Response
*/
public function logout()
{
try {
$token = $this->request->header('Authorization');
if ($token) {
// 去掉Bearer前缀
if (strpos($token, 'Bearer ') === 0) {
$token = substr($token, 7);
}
// 从token中获取管理员ID
$userId = $this->getUserIdFromToken($token);
if ($userId) {
// 清除token缓存
Cache::delete('admin_token_' . $userId);
}
}
Log::record('管理员退出登录', 'info');
// 增加前端刷新指示
return json([
'code' => 0,
'msg' => '退出成功',
'refresh' => true // 前端可根据此字段判断是否需要刷新
]);
} catch (\Exception $e) {
Log::record('退出登录失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '退出失败:' . $e->getMessage()]);
}
}
/**
* 获取管理员信息接口
*
* @return \think\Response
*/
public function info()
{
try {
$token = $this->request->header('Authorization');
if (!$token) {
return json(['code' => 1, 'msg' => '请先登录']);
}
// 去掉Bearer前缀
if (strpos($token, 'Bearer ') === 0) {
$token = substr($token, 7);
}
$userId = $this->getUserIdFromToken($token);
if (!$userId) {
return json(['code' => 1, 'msg' => 'token无效']);
}
// 验证token是否在缓存中
$cachedToken = Cache::get('admin_token_' . $userId);
if (!$cachedToken || $cachedToken !== $token) {
return json(['code' => 1, 'msg' => 'token已过期']);
}
// 获取管理员信息
$user = AdminUser::where('uid', $userId)->find();
if (!$user) {
return json(['code' => 1, 'msg' => '管理员不存在']);
}
return json([
'code' => 0,
'msg' => '获取成功',
'data' => [
'id' => $user->uid,
'account' => $user->account,
'name' => $user->name,
'avatar' => $user->avatar ?? '/static/images/avatar.png',
'phone' => $user->phone ?? '',
'sex' => $user->sex ?? 0,
'qq' => $user->qq ?? '',
'wechat' => $user->wechat ?? '',
'create_time' => $user->create_time
]
]);
} catch (\Exception $e) {
Log::record('获取管理员信息失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '获取管理员信息失败:' . $e->getMessage()]);
}
}
/**
* 修改密码接口
*
* @return \think\Response
*/
public function changePassword()
{
if (!$this->request->isPost()) {
return json(['code' => 1, 'msg' => '请求方法错误']);
}
try {
$token = $this->request->header('Authorization');
if (!$token) {
return json(['code' => 1, 'msg' => '请先登录']);
}
// 去掉Bearer前缀
if (strpos($token, 'Bearer ') === 0) {
$token = substr($token, 7);
}
$userId = $this->getUserIdFromToken($token);
if (!$userId) {
return json(['code' => 1, 'msg' => 'token无效']);
}
// 验证token是否在缓存中
$cachedToken = Cache::get('admin_token_' . $userId);
if (!$cachedToken || $cachedToken !== $token) {
return json(['code' => 1, 'msg' => 'token已过期']);
}
$data = $this->request->post();
// 验证数据
$validate = validate([
'oldPassword' => 'require',
'newPassword' => 'require|min:6'
], [
'oldPassword.require' => '原密码不能为空',
'newPassword.require' => '新密码不能为空',
'newPassword.min' => '新密码长度不能少于6位'
]);
if (!$validate->check($data)) {
return json(['code' => 1, 'msg' => $validate->getError()]);
}
// 获取管理员信息
$user = AdminUser::where('uid', $userId)->find();
if (!$user) {
return json(['code' => 1, 'msg' => '管理员不存在']);
}
// 验证原密码
if ($user->password !== md5($data['oldPassword'])) {
return json(['code' => 1, 'msg' => '原密码错误']);
}
// 更新密码
$user->password = md5($data['newPassword']);
$user->save();
Log::record('管理员修改密码成功:' . $user->account, 'info');
return json(['code' => 0, 'msg' => '密码修改成功']);
} catch (\Exception $e) {
Log::record('修改密码失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '修改密码失败:' . $e->getMessage()]);
}
}
/**
* 获取管理员菜单接口
*
* @return \think\Response
*/
public function menus()
{
try {
// 取消token验证,直接获取菜单数据
$menus = AdminSysMenu::getMenuTree();
return json([
'code' => 0,
'msg' => '获取成功',
'data' => $menus
]);
} catch (\Exception $e) {
Log::record('获取菜单失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '获取菜单失败:' . $e->getMessage()]);
}
}
}
-402
View File
@@ -1,402 +0,0 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\controller;
use app\api\controller\BaseController;
use app\index\model\User\Users as Users;
use app\index\model\User\UsersGroup as UsersGroup;
use think\facade\Log;
use think\facade\Cache;
use think\Response;
class UserController extends BaseController
{
/**
* 用户登录接口
*
* @return \think\Response
*/
public function login()
{
if (!$this->request->isPost()) {
return json(['code' => 1, 'msg' => '请求方法错误']);
}
$data = $this->request->post();
try {
// 验证数据
$validate = validate([
'account' => 'require|email',
'password' => 'require'
], [
'account.require' => '账户不能为空',
'account.email' => '邮箱格式不正确',
'password.require' => '密码不能为空'
]);
if (!$validate->check($data)) {
return json(['code' => 1, 'msg' => $validate->getError()]);
}
// 查询用户
$user = Users::where('account', $data['account'])->find();
if (!$user) {
return json(['code' => 1, 'msg' => '用户不存在']);
}
// 验证密码
if ($user->password !== md5($data['password'])) {
return json(['code' => 1, 'msg' => '密码错误']);
}
// 生成JWT token(这里使用简单的token,实际项目中建议使用JWT)
$token = $this->generateToken($user->id);
// 将token存储到缓存中,设置过期时间
Cache::set('user_token_' . $user->id, $token, 7 * 24 * 3600);
// 记录登录日志
Log::record('用户登录成功:' . $user->account, 'info');
// 返回用户信息和token
return json([
'code' => 0,
'msg' => '登录成功',
'data' => [
'token' => $token,
'user_info' => [
'id' => $user->id,
'account' => $user->account,
'name' => $user->name,
'avatar' => $user->avatar ?? '/static/images/avatar.png',
'phone' => $user->phone ?? '',
'sex' => $user->sex ?? 0,
'qq' => $user->qq ?? '',
'wechat' => $user->wechat ?? '',
'create_time' => $user->create_time
]
]
]);
} catch (\Exception $e) {
Log::record('登录失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '登录失败:' . $e->getMessage()]);
}
}
/**
* 用户注册接口
*
* @return \think\Response
*/
public function register()
{
if (!$this->request->isPost()) {
return json(['code' => 1, 'msg' => '请求方法错误']);
}
$data = $this->request->post();
try {
// 验证数据
$validate = validate([
'account' => 'require|email|unique:users',
'code' => 'require|number|length:6',
'password' => 'require|min:6|max:20',
'repassword' => 'require|confirm:password'
], [
'account.require' => '账户不能为空',
'account.email' => '邮箱格式不正确',
'account.unique' => '该邮箱已注册',
'code.require' => '验证码不能为空',
'code.number' => '验证码必须为数字',
'code.length' => '验证码长度必须为6位',
'password.require' => '密码不能为空',
'password.min' => '密码长度不能小于6个字符',
'password.max' => '密码长度不能超过20个字符',
'repassword.require' => '确认密码不能为空',
'repassword.confirm' => '两次输入的密码不一致'
]);
if (!$validate->check($data)) {
return json(['code' => 1, 'msg' => $validate->getError()]);
}
// 验证邮箱验证码
$emailCode = Cache::get('email_code_' . $data['account']);
if (!$emailCode || $emailCode != $data['code']) {
return json(['code' => 1, 'msg' => '验证码错误或已过期']);
}
// 创建用户
$user = new Users;
$user->account = $data['account'];
$user->password = md5($data['password']);
$user->name = $this->generateRandomName();
$user->create_time = time();
$user->save();
// 清除验证码缓存
Cache::delete('email_code_' . $data['account']);
return json(['code' => 0, 'msg' => '注册成功']);
} catch (\Exception $e) {
return json(['code' => 1, 'msg' => '注册失败:' . $e->getMessage()]);
}
}
/**
* 退出登录接口
*
* @return \think\Response
*/
public function logout()
{
try {
$token = $this->request->header('Authorization');
if ($token) {
// 从token中获取用户ID
$userId = $this->getUserIdFromToken($token);
if ($userId) {
// 清除token缓存
Cache::delete('user_token_' . $userId);
}
}
Log::record('用户退出登录', 'info');
return json(['code' => 0, 'msg' => '退出成功']);
} catch (\Exception $e) {
Log::record('退出登录失败:' . $e->getMessage(), 'error');
return json(['code' => 1, 'msg' => '退出失败:' . $e->getMessage()]);
}
}
/**
* 获取用户信息接口
*
* @return \think\Response
*/
public function getUserInfo()
{
try {
$token = $this->request->header('Authorization');
if (!$token) {
return json(['code' => 1, 'msg' => '请先登录']);
}
$userId = $this->getUserIdFromToken($token);
if (!$userId) {
return json(['code' => 1, 'msg' => 'token无效']);
}
// 验证token是否在缓存中
$cachedToken = Cache::get('user_token_' . $userId);
if (!$cachedToken || $cachedToken !== $token) {
return json(['code' => 1, 'msg' => 'token已过期']);
}
// 获取用户信息
$user = Users::find($userId);
if (!$user) {
return json(['code' => 1, 'msg' => '用户不存在']);
}
return json([
'code' => 0,
'msg' => '获取成功',
'data' => [
'id' => $user->id,
'account' => $user->account,
'name' => $user->name,
'avatar' => $user->avatar ?? '/static/images/avatar.png',
'phone' => $user->phone ?? '',
'sex' => $user->sex ?? 0,
'qq' => $user->qq ?? '',
'wechat' => $user->wechat ?? '',
'create_time' => $user->create_time
]
]);
} catch (\Exception $e) {
return json(['code' => 1, 'msg' => '获取用户信息失败:' . $e->getMessage()]);
}
}
/**
* 发送邮箱验证码接口
*
* @return \think\Response
*/
public function sendEmailCode()
{
if (!$this->request->isPost()) {
return json(['code' => 1, 'msg' => '请求方法错误']);
}
$email = $this->request->post('account');
if (empty($email)) {
return json(['code' => 1, 'msg' => '邮箱不能为空']);
}
// 验证邮箱格式
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
return json(['code' => 1, 'msg' => '邮箱格式不正确']);
}
// 检查邮箱是否已注册
$exists = Users::where('account', $email)->find();
if ($exists) {
return json(['code' => 1, 'msg' => '该邮箱已注册']);
}
// 生成6位随机验证码
$code = mt_rand(100000, 999999);
// 这里应该调用邮件发送服务
// 为了演示,我们直接返回成功
// 实际项目中需要实现邮件发送逻辑
// 将验证码存入缓存,有效期5分钟
Cache::set('email_code_' . $email, $code, 300);
return json(['code' => 0, 'msg' => '验证码已发送']);
}
/**
* 修改密码接口
*
* @return \think\Response
*/
public function updatePassword()
{
if (!$this->request->isPost()) {
return json(['code' => 1, 'msg' => '请求方法错误']);
}
try {
$token = $this->request->header('Authorization');
if (!$token) {
return json(['code' => 1, 'msg' => '请先登录']);
}
$userId = $this->getUserIdFromToken($token);
if (!$userId) {
return json(['code' => 1, 'msg' => 'token无效']);
}
$data = $this->request->post();
// 验证数据
$validate = validate([
'old_password' => 'require',
'new_password' => 'require|min:6|max:20',
'confirm_password' => 'require|confirm:new_password'
], [
'old_password.require' => '旧密码不能为空',
'new_password.require' => '新密码不能为空',
'new_password.min' => '新密码长度不能小于6个字符',
'new_password.max' => '新密码长度不能超过20个字符',
'confirm_password.require' => '确认密码不能为空',
'confirm_password.confirm' => '两次输入的密码不一致'
]);
if (!$validate->check($data)) {
return json(['code' => 1, 'msg' => $validate->getError()]);
}
// 获取用户信息
$user = Users::find($userId);
if (!$user) {
return json(['code' => 1, 'msg' => '用户不存在']);
}
// 验证旧密码
if ($user->password !== md5($data['old_password'])) {
return json(['code' => 1, 'msg' => '旧密码错误']);
}
// 更新密码
$user->password = md5($data['new_password']);
$user->update_time = time();
if ($user->save()) {
// 清除token,要求重新登录
Cache::delete('user_token_' . $userId);
return json(['code' => 0, 'msg' => '密码修改成功,请重新登录']);
} else {
return json(['code' => 1, 'msg' => '密码修改失败']);
}
} catch (\Exception $e) {
return json(['code' => 1, 'msg' => '密码修改失败:' . $e->getMessage()]);
}
}
/**
* 生成简单的token
*
* @param int $userId
* @return string
*/
private function generateToken($userId)
{
$data = [
'user_id' => $userId,
'timestamp' => time(),
'random' => mt_rand(100000, 999999)
];
return base64_encode(json_encode($data));
}
/**
* 从token中获取用户ID
*
* @param string $token
* @return int|null
*/
private function getUserIdFromToken($token)
{
try {
$data = json_decode(base64_decode($token), true);
if ($data && isset($data['user_id'])) {
return $data['user_id'];
}
} catch (\Exception $e) {
return null;
}
return null;
}
/**
* 生成随机用户名
*
* @return string
*/
private function generateRandomName()
{
return '云朵_' . mt_rand(100000, 999999);
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class AdminConfig extends Model
{
}
+92
View File
@@ -0,0 +1,92 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class AdminSysMenu extends Model
{
// 设置表名
protected $name = 'admin_sys_menu';
// 设置主键
protected $pk = 'smid';
// 自动时间戳
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
// 字段类型转换
protected $type = [
'smid' => 'integer',
'parent_id' => 'integer',
'type' => 'integer',
'sort' => 'integer',
'status' => 'integer',
'create_time' => 'integer',
'update_time' => 'integer'
];
// 允许写入的字段
protected $allowField = [
'parent_id', 'type', 'label', 'icon_class', 'sort', 'src', 'status'
];
/**
* 获取菜单树形结构
* @return array
*/
public static function getMenuTree()
{
// 获取所有启用的菜单
$menus = self::where('status', 1)
->order('sort', 'desc')
->order('smid', 'asc')
->select()
->toArray();
return self::buildTree($menus);
}
/**
* 构建树形结构
* @param array $menus 菜单数组
* @param int $parent_id 父级ID
* @return array
*/
public static function buildTree($menus, $parent_id = 0)
{
$tree = [];
foreach ($menus as $menu) {
if ($menu['parent_id'] == $parent_id) {
$children = self::buildTree($menus, $menu['smid']);
if ($children) {
$menu['children'] = $children;
} else {
$menu['children'] = [];
}
$tree[] = $menu;
}
}
return $tree;
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class AdminUser extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class AdminUserGroup extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class ApiKey extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Article;
use think\Model;
class Articles extends Model
{
}
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Article;
use think\Model;
class ArticlesCategory extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class Banner extends Model
{
}
+54
View File
@@ -0,0 +1,54 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
/**
* 后台管理系统
*/
namespace app\api\model;
use think\Model;
use think\facade\App;
class Base extends Model{
public function logs($data=null,$fileName=''){
if(is_null($data) || is_null($fileName)){
return false;
}
//获取Runtime路径
$path = App::getRuntimePath() . 'logs' . DIRECTORY_SEPARATOR;
if(!is_dir($path)){
$mkdir_re = mkdir($path,0777,TRUE);
if(!$mkdir_re){
$this -> logs($data,$fileName);
}
}
$info = ['data'=>$data];
$content = json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
if(empty($fileName)){
$filePath = $path . "/" . date("Ymd",time()).'.info.log';
}else{
$filePath = $path . "/" . $fileName . '.info.log';
}
$time = "[".date("Y-m-d H:i:s",time())."]";
$re = file_put_contents($filePath, $time." ".$content , FILE_APPEND);
if(!$re){
$this -> logs($data,$fileName);
}else{
return true;
}
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\ContentPush;
use think\Model;
class ContentPush extends Model
{
protected $name = 'content_push';
// 自动写入时间戳
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
}
@@ -0,0 +1,34 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\ContentPush;
use think\Model;
class ContentPushSetting extends Model
{
protected $name = 'content_push_setting';
// 自动写入时间戳
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class DailyStats extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Log;
use think\Model;
class LogsLogin extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Log;
use think\Model;
class LogsOperation extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class MailConfig extends Model
{
}
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Resource;
use think\Model;
class Resource extends Model
{
// 设置当前模型对应的数据表名称(不含前缀)
protected $name = 'resources';
// 设置主键
protected $pk = 'id';
}
@@ -0,0 +1,30 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\Resource;
use think\Model;
class ResourceCategory extends Model
{
// 设置当前模型对应的数据表名称(不含前缀)
protected $name = 'resources_category';
// 设置主键
protected $pk = 'id';
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\User;
use think\Model;
class Users extends Model
{
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model\User;
use think\Model;
class UsersGroup extends Model
{
}
+68
View File
@@ -0,0 +1,68 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
/**
* 配置表
*/
namespace app\api\model;
use think\Model;
class YzAdminConfig extends Model
{
// 设置当前模型对应的数据表名称(不含前缀)
protected $name = 'admin_config';
// 设置主键
protected $pk = 'config_id';
/**
* 列出全部配置,key对应value
*/
public function getAll(){
$aList = static::where('config_status',1)->order('config_sort DESC')->select()->toArray();
if(empty($aList)){
return [];
}else{
$return = [];
foreach($aList as $k=>$v){
$return[$v['config_name']] = $v['config_value'];
}
}
return $return;
}
/**
* 多条数据更新
*/
public function updateAll($data){
$lists = static::order('config_sort DESC,config_id')->select()->toArray();
if(empty($lists)){
return false;
}else{
foreach($lists as &$lists_v){
$lists_v['config_value'] = $data[$lists_v['config_name']];
}
$save = static::saveAll($lists);
if(empty($save)){
return false;
}
}
return true;
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* 商业使用授权协议
*
* Copyright (c) 2025 [云泽网]. 保留所有权利.
*
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
*
* 授权购买请联系: 357099073@qq.com
* 官方网站: https://www.yunzer.cn
*
* 评估用户须知:
* 1. 禁止移除版权声明
* 2. 禁止用于生产环境
* 3. 禁止转售或分发
*/
namespace app\api\model;
use think\Model;
class ZIconfont extends Model
{
}