添加app更新
This commit is contained in:
parent
aafe54420b
commit
7f305fb6d2
108
app/adminapi/controller/AppUpdateController.php
Normal file
108
app/adminapi/controller/AppUpdateController.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\controller\BaseAdminController;
|
||||||
|
use app\adminapi\lists\AppUpdateLists;
|
||||||
|
use app\adminapi\logic\AppUpdateLogic;
|
||||||
|
use app\adminapi\validate\AppUpdateValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app更新控制器
|
||||||
|
* Class AppUpdateController
|
||||||
|
* @package app\adminapi\controller
|
||||||
|
*/
|
||||||
|
class AppUpdateController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取app更新列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new AppUpdateLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加app更新
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new AppUpdateValidate())->post()->goCheck('add');
|
||||||
|
$result = AppUpdateLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(AppUpdateLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑app更新
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new AppUpdateValidate())->post()->goCheck('edit');
|
||||||
|
$result = AppUpdateLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(AppUpdateLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除app更新
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new AppUpdateValidate())->post()->goCheck('delete');
|
||||||
|
AppUpdateLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取app更新详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new AppUpdateValidate())->goCheck('detail');
|
||||||
|
$result = AppUpdateLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
77
app/adminapi/lists/AppUpdateLists.php
Normal file
77
app/adminapi/lists/AppUpdateLists.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\adminapi\lists;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\AppUpdate;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app更新列表
|
||||||
|
* Class AppUpdateLists
|
||||||
|
* @package app\adminapi\lists
|
||||||
|
*/
|
||||||
|
class AppUpdateLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取app更新列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return AppUpdate::where($this->searchWhere)
|
||||||
|
->field(['id', 'title', 'content', 'type', 'version', 'dow_url', 'force', 'quiet'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取app更新数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return AppUpdate::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
118
app/adminapi/logic/AppUpdateLogic.php
Normal file
118
app/adminapi/logic/AppUpdateLogic.php
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\adminapi\logic;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\AppUpdate;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app更新逻辑
|
||||||
|
* Class AppUpdateLogic
|
||||||
|
* @package app\adminapi\logic
|
||||||
|
*/
|
||||||
|
class AppUpdateLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加app更新
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
AppUpdate::create([
|
||||||
|
'title' => $params['title'],
|
||||||
|
'content' => $params['content'],
|
||||||
|
'type' => $params['type'],
|
||||||
|
'version' => $params['version'],
|
||||||
|
'dow_url' => $params['dow_url'],
|
||||||
|
'force' => $params['force'],
|
||||||
|
'quiet' => $params['quiet']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑app更新
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
AppUpdate::where('id', $params['id'])->update([
|
||||||
|
'title' => $params['title'],
|
||||||
|
'content' => $params['content'],
|
||||||
|
'type' => $params['type'],
|
||||||
|
'version' => $params['version'],
|
||||||
|
'dow_url' => $params['dow_url'],
|
||||||
|
'force' => $params['force'],
|
||||||
|
'quiet' => $params['quiet']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除app更新
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return AppUpdate::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取app更新详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return AppUpdate::findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
104
app/adminapi/validate/AppUpdateValidate.php
Normal file
104
app/adminapi/validate/AppUpdateValidate.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\adminapi\validate;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app更新验证器
|
||||||
|
* Class AppUpdateValidate
|
||||||
|
* @package app\adminapi\validate
|
||||||
|
*/
|
||||||
|
class AppUpdateValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'title' => 'require',
|
||||||
|
'content' => 'require',
|
||||||
|
'type' => 'require',
|
||||||
|
'version' => 'require',
|
||||||
|
'dow_url' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'title' => '标题',
|
||||||
|
'content' => '内容',
|
||||||
|
'type' => '1ios 2安卓',
|
||||||
|
'version' => '版本',
|
||||||
|
'dow_url' => 'app链接',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return AppUpdateValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['title','content','type','version','dow_url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return AppUpdateValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','title','content','type','version','dow_url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return AppUpdateValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return AppUpdateValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/08/31 11:08
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -115,8 +115,9 @@ class AccountLogLists extends BaseApiDataLists
|
|||||||
$endTime = $date + 86399; // 获取该日期24小时后的时间戳
|
$endTime = $date + 86399; // 获取该日期24小时后的时间戳
|
||||||
$where[] = ['create_time', 'between', [$startTime, $endTime]];
|
$where[] = ['create_time', 'between', [$startTime, $endTime]];
|
||||||
}else{
|
}else{
|
||||||
$where[] = ['create_time', 'between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d'))+86366]];
|
// $where[] = ['create_time', 'between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d'))+86366]];
|
||||||
}
|
}
|
||||||
|
|
||||||
$lists = UserAccountLog::field($field)
|
$lists = UserAccountLog::field($field)
|
||||||
->where($where)
|
->where($where)
|
||||||
->with(['userInfo'])
|
->with(['userInfo'])
|
||||||
|
@ -154,9 +154,7 @@ class IndexLogic extends BaseLogic
|
|||||||
'shop_name' => ConfigService::get('website', 'shop_name'),
|
'shop_name' => ConfigService::get('website', 'shop_name'),
|
||||||
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
|
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
|
||||||
];
|
];
|
||||||
// H5配置
|
$versionInfo=[];
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'domain' => FileService::getFileUrl(),
|
'domain' => FileService::getFileUrl(),
|
||||||
'style' => $style,
|
'style' => $style,
|
||||||
@ -164,8 +162,19 @@ class IndexLogic extends BaseLogic
|
|||||||
'menu' => $menu,
|
'menu' => $menu,
|
||||||
'login' => $loginConfig,
|
'login' => $loginConfig,
|
||||||
'website' => $website,
|
'website' => $website,
|
||||||
'version'=> config('project.version')
|
'version'=> config('project.version'),
|
||||||
|
'version_info'=>$versionInfo,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAndroid() {
|
||||||
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
return strpos($userAgent, 'Android') !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isIOS() {
|
||||||
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
return strpos($userAgent, 'iPhone') !== false || strpos($userAgent, 'iPad') !== false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -78,13 +78,16 @@ class UserTokenService
|
|||||||
public static function overtimeToken($token)
|
public static function overtimeToken($token)
|
||||||
{
|
{
|
||||||
$time = time();
|
$time = time();
|
||||||
$adminSession = UserSession::where('token', '=', $token)->find();
|
$userSession = UserSession::where('token', '=', $token)->find();
|
||||||
|
if ($userSession->isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//延长token过期时间
|
//延长token过期时间
|
||||||
$adminSession->expire_time = $time + Config::get('project.user_token.expire_duration');
|
$userSession->expire_time = $time + Config::get('project.user_token.expire_duration');
|
||||||
$adminSession->update_time = $time;
|
$userSession->update_time = $time;
|
||||||
$adminSession->save();
|
$userSession->save();
|
||||||
|
|
||||||
return (new UserTokenCache())->setUserInfo($adminSession->token);
|
return (new UserTokenCache())->setUserInfo($userSession->token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
34
app/common/model/AppUpdate.php
Normal file
34
app/common/model/AppUpdate.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app更新模型
|
||||||
|
* Class AppUpdate
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class AppUpdate extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'app_update';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user