初始化代码
This commit is contained in:
77
application/version/controller/Apip.php
Normal file
77
application/version/controller/Apip.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\captcha\Captcha;
|
||||
use think\DB;
|
||||
|
||||
class Apip extends Controller
|
||||
{
|
||||
public function initialize()
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
add_operation(3, 0); //用户行为日志
|
||||
}
|
||||
public function login()
|
||||
{
|
||||
|
||||
$captcha = input('captcha');
|
||||
$username = input('username');
|
||||
$password = input('password');
|
||||
if (empty($captcha)) {
|
||||
return ajaxReturn(201, '验证码不能为空');
|
||||
}
|
||||
// if (!captcha_check($captcha)) {
|
||||
// // 验证失败
|
||||
// return ajaxReturn(201, '验证码错误');
|
||||
// }
|
||||
if (empty($username)) {
|
||||
return ajaxReturn(201, '用户名不能为空');
|
||||
}
|
||||
if (empty($password)) {
|
||||
return ajaxReturn(201, '密码不能为空');
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['user_name', '=', $username];
|
||||
// $map[] = ['password', '=', md5($password)];
|
||||
$info = db::name('user')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ajaxReturn(201, '用户名不存在');
|
||||
} else {
|
||||
|
||||
if (md5($password) != $info['password']) {
|
||||
return ajaxReturn(201, '密码错误');
|
||||
}
|
||||
if ($info['is_login_version'] != 1) {
|
||||
return ajaxReturn(201, '普通用户无法登录');
|
||||
}
|
||||
$login_token = generateRandom(32);
|
||||
$login_token = $info['login_token']; //防止用户APP掉线 此处不更新登录token
|
||||
$data = [];
|
||||
$data['uid'] = $info['uid'];
|
||||
$data['login_token'] = $login_token;
|
||||
$data['update_time'] = time();
|
||||
$reslut = db::name('user')->update($data);
|
||||
if (!$reslut) {
|
||||
return ajaxReturn(201, '登录失败', '');
|
||||
} else {
|
||||
return ajaxReturn(200, '登录成功', $login_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function verify()
|
||||
{
|
||||
$config = [
|
||||
'codeSet' => '0123456789',
|
||||
// 验证码字体大小
|
||||
'fontSize' => 30,
|
||||
// 验证码位数
|
||||
'length' => 4,
|
||||
// 关闭验证码杂点
|
||||
'useNoise' => false,
|
||||
];
|
||||
$captcha = new Captcha($config);
|
||||
return $captcha->entry();
|
||||
}
|
||||
}
|
||||
51
application/version/controller/Capital.php
Normal file
51
application/version/controller/Capital.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
use think\DB;
|
||||
|
||||
class Capital extends Common
|
||||
{
|
||||
|
||||
|
||||
//获取房间流水 列表
|
||||
public function room_money_log()
|
||||
{
|
||||
$rid = -1;
|
||||
$room_info = Db::name("room")->where(array("room_owner_uid" => $this->uid))->find();
|
||||
if (!empty($room_info)) {
|
||||
$rid = $room_info['rid'];
|
||||
}
|
||||
$room_number = 0;
|
||||
$room_name = '';
|
||||
$time1 = input('time1', '');
|
||||
$time2 = input('time2', 0);
|
||||
|
||||
$order = input('order', 'a.sid');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('admin/Capital')->room_money_log($rid, $room_number, $room_name, $time1, $time2, $order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
$data['totalRow'] = $reslut['data']['totalRow'];
|
||||
return json($data);
|
||||
}
|
||||
//获取资金改变类型
|
||||
public function get_change_type()
|
||||
{
|
||||
$data = model('admin/UserMoneyLog')->ChangeTypeLable();
|
||||
return ajaxReturn(200, '', $data);
|
||||
}
|
||||
//获取资金类型
|
||||
public function get_money_type()
|
||||
{
|
||||
$data = model('admin/UserMoneyLog')->MoneyTypeLable();
|
||||
return ajaxReturn(200, '', $data);
|
||||
}
|
||||
}
|
||||
37
application/version/controller/Common.php
Normal file
37
application/version/controller/Common.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
|
||||
class Common extends Controller
|
||||
{
|
||||
public $uid;
|
||||
public function initialize()
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
// ajaxReturn(301, '系统维护');
|
||||
$login_token = input('login_token', 0);
|
||||
$reslut = model('User')->check_login_token($login_token);
|
||||
if ($reslut['code'] == 201) {
|
||||
return ajaxReturn(301, $reslut['msg'], $reslut['data']);
|
||||
} else {
|
||||
$this->uid = $reslut['data'];
|
||||
}
|
||||
add_operation(3, $this->uid); //用户行为日志
|
||||
}
|
||||
public function check_login_status()
|
||||
{
|
||||
$user_name = Db::name("user")->where(array("uid" => $this->uid))->value("user_name");
|
||||
$data['data'] = $user_name;
|
||||
ajaxReturn(1, '登录成功', $data);
|
||||
}
|
||||
public function get_menu_list()
|
||||
{
|
||||
$data = model('SystemMenu')->getSystemInit($this->uid);
|
||||
return json($data);
|
||||
}
|
||||
}
|
||||
17
application/version/controller/Upload.php
Normal file
17
application/version/controller/Upload.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
|
||||
class Upload extends Common
|
||||
{
|
||||
public function file_upload()
|
||||
{
|
||||
$file = request()->file('file');
|
||||
$file_category_name = input('file_category', 'all');
|
||||
$reslut = model('Upload')->single_file_upload($file, $file_category_name);
|
||||
return ajaxReturn($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
72
application/version/controller/Version.php
Normal file
72
application/version/controller/Version.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
use think\DB;
|
||||
|
||||
class Version extends Common
|
||||
{
|
||||
|
||||
//获取版本列表
|
||||
public function get_version_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Version')->get_version_list($page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return json($data);
|
||||
}
|
||||
|
||||
//获取 版本 详情
|
||||
public function get_version_info()
|
||||
{
|
||||
$vid = input('vid', 0);
|
||||
$data = model('Version')->get_version_info($vid);
|
||||
if ($data['code'] == 0) {
|
||||
return ajaxReturn(201, $data['msg'], $data['data']);
|
||||
} else {
|
||||
return ajaxReturn(200, $data['msg'], $data['data']);
|
||||
}
|
||||
}
|
||||
//编辑 版本
|
||||
public function edit_version()
|
||||
{
|
||||
$data = input('post.');
|
||||
$data = model('Version')->edit_version($data);
|
||||
if ($data['code'] == 0) {
|
||||
return ajaxReturn(201, $data['msg'], $data['data']);
|
||||
} else {
|
||||
return ajaxReturn(200, $data['msg'], $data['data']);
|
||||
}
|
||||
}
|
||||
|
||||
//添加 版本
|
||||
public function add_version()
|
||||
{
|
||||
$data = input('post.');
|
||||
$data = model('Version')->add_version($data);
|
||||
if ($data['code'] == 0) {
|
||||
return ajaxReturn(201, $data['msg'], $data['data']);
|
||||
} else {
|
||||
return ajaxReturn(200, $data['msg'], $data['data']);
|
||||
}
|
||||
}
|
||||
|
||||
//删除 版本
|
||||
public function del_version()
|
||||
{
|
||||
$vid = input('vid', 0);
|
||||
$data = model('Version')->del_version($vid);
|
||||
if ($data['code'] == 0) {
|
||||
return ajaxReturn(201, $data['msg'], $data['data']);
|
||||
} else {
|
||||
return ajaxReturn(200, $data['msg'], $data['data']);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
application/version/model/Capital.php
Normal file
10
application/version/model/Capital.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Capital extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
63
application/version/model/SystemMenu.php
Normal file
63
application/version/model/SystemMenu.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class SystemMenu extends Model
|
||||
{
|
||||
|
||||
// 获取初始化数据
|
||||
public function getSystemInit($aid = 0)
|
||||
{
|
||||
$homeInfo = [
|
||||
'title' => '首页',
|
||||
'href' => '',
|
||||
];
|
||||
$logoInfo = [
|
||||
'title' => '系统 管理',
|
||||
'image' => 'images/logo.png',
|
||||
];
|
||||
$menuInfo = $this->getMenuList($aid);
|
||||
$systemInit = [
|
||||
'homeInfo' => $homeInfo,
|
||||
'logoInfo' => $logoInfo,
|
||||
'menuInfo' => $menuInfo,
|
||||
];
|
||||
return $systemInit;
|
||||
}
|
||||
|
||||
// 获取菜单列表
|
||||
private function getMenuList($aid)
|
||||
{
|
||||
$menuList = Db::name('system_menu_version')
|
||||
->field('id,pid,title,icon,href,target')
|
||||
->where('status', 1)
|
||||
->where('type', 'in', [1, 2])
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
|
||||
$menuList = $this->buildMenuChild(0, $menuList);
|
||||
return $menuList;
|
||||
}
|
||||
|
||||
//递归获取子菜单
|
||||
private function buildMenuChild($pid, $menuList)
|
||||
{
|
||||
$treeList = [];
|
||||
foreach ($menuList as &$v) {
|
||||
|
||||
if ($pid == $v['pid']) {
|
||||
$node = $v;
|
||||
$child = $this->buildMenuChild($v['id'], $menuList);
|
||||
if (!empty($child)) {
|
||||
$node['child'] = $child;
|
||||
}
|
||||
// todo 后续此处加上用户的权限判断
|
||||
$treeList[] = $node;
|
||||
}
|
||||
}
|
||||
return $treeList;
|
||||
}
|
||||
}
|
||||
214
application/version/model/Upload.php
Normal file
214
application/version/model/Upload.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\version\model;
|
||||
|
||||
use think\Model;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
use Qiniu\Auth;
|
||||
use think\facade\Env;
|
||||
use Qcloud\Cos\Client;
|
||||
|
||||
class Upload extends Model
|
||||
{
|
||||
//单文件上传
|
||||
public function single_file_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
//判断上传方式
|
||||
$config = get_system_config();
|
||||
$reslut = ['code' => 201, 'msg' => '非法上传存储类型', 'data' => null];
|
||||
if ($config['file_upload_type'] == 1) {
|
||||
$reslut = $this->local_upload($file, $file_category_name);
|
||||
} elseif ($config['file_upload_type'] == 2) {
|
||||
$reslut = $this->qiniu_upload($file, $file_category_name);
|
||||
}elseif ($config['file_upload_type'] == 3) {
|
||||
$reslut = $this->tencent_upload($file, $file_category_name);
|
||||
}
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
public function server_local_upload($filePath){
|
||||
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
// 构建鉴权对象
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
// 生成上传 Token
|
||||
$token = $auth->uploadToken($bucket);
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$uploadMgr = new UploadManager();
|
||||
// 调用 UploadManager 的 putFile 方法进行文件的上传。
|
||||
$local_filePath= Env::get('root_path')."/public/".$filePath;
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $filePath, $local_filePath);
|
||||
if ($err !== null) {
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
} else {
|
||||
$data = [];
|
||||
$data['image_path'] = $ret['key'];
|
||||
$data['size'] = 0;
|
||||
$data['http_image_path'] = localpath_to_netpath($ret['key']);
|
||||
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function local_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
// // 获取表单上传文件 例如上传了001.jpg
|
||||
|
||||
// 移动到框架应用根目录/uploads/ 目录下
|
||||
$root_path = 'public/uploads/' . $file_category_name;
|
||||
mkdirs($root_path); //创建文件
|
||||
$info = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga'])->move('./uploads/' . $file_category_name);
|
||||
if ($info) {
|
||||
$file_info = $info->getInfo();
|
||||
// 成功上传后 获取上传信息
|
||||
// 输出 jpg
|
||||
// echo $info->getExtension();
|
||||
// // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getSaveName();
|
||||
// // 输出 42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getFilename();
|
||||
$image_path = '/uploads/' . $file_category_name . '/' . $info->getSaveName(); //返回的地址
|
||||
$image_path = str_replace("\\", "/", $image_path);
|
||||
$img['image_path'] = $image_path;
|
||||
$img['size'] = $file_info['size'];
|
||||
$img['http_image_path'] = localpath_to_netpath($image_path);
|
||||
return ['code' => 200, 'msg' => '上传成功', 'data' => $img];
|
||||
} else {
|
||||
|
||||
return ['code' => 201, 'msg' => '上传失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
public function qiniu_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '1024M');
|
||||
ini_set('upload_max_filesize', '200M');
|
||||
ini_set('post_max_size', '200M');
|
||||
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
|
||||
if (empty($file)) {
|
||||
return ['code' => 201, 'msg' => '请上传文件', 'data' => null];
|
||||
}
|
||||
$validate_reslut = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga,apk'])->check();
|
||||
if (!$validate_reslut) {
|
||||
return ['code' => 201, 'msg' => '非法上传存储类型', 'data' => null];
|
||||
}
|
||||
$extension = strtolower(pathinfo($file->getInfo('name'), PATHINFO_EXTENSION));
|
||||
$file_info = $file->getInfo();
|
||||
|
||||
|
||||
// 构建鉴权对象
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
// 生成上传 Token
|
||||
$token = $auth->uploadToken($bucket);
|
||||
// 要上传文件的本地路径
|
||||
$filePath = $file_info['tmp_name'];
|
||||
// 上传到存储后保存的文件名
|
||||
$savename = date('Ymd') . '/' . md5(microtime(true)) . ".$extension";
|
||||
$key = $file_category_name . '/' . $savename;
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$uploadMgr = new UploadManager();
|
||||
// 调用 UploadManager 的 putFile 方法进行文件的上传。
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
|
||||
if ($err !== null) {
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
} else {
|
||||
$data = [];
|
||||
$data['image_path'] = $ret['key'];
|
||||
$data['size'] = $file_info['size'];
|
||||
$data['http_image_path'] = localpath_to_netpath($ret['key']);
|
||||
$data['suffix'] = $extension;
|
||||
// $data_json = json_encode($data);
|
||||
// error_log($data_json, 3, 'upload.txt');
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_qiniu_upload_token()
|
||||
{
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$token = $auth->uploadToken($bucket);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => ['token' => $token]];
|
||||
}
|
||||
|
||||
public function tencent_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
$config = get_system_config();
|
||||
$secretId = $config['tencent_secret_id'];
|
||||
// $secretId = 111111;
|
||||
$secretKey = $config['tencent_secret_key'];
|
||||
$region = $config['tencent_territory'];
|
||||
$bucket = $config['tencent_bucket_name'];
|
||||
|
||||
if (empty($file)) {
|
||||
return ['code' => 201, 'msg' => '请上传文件', 'data' => null];
|
||||
}
|
||||
// dump($file);exit;
|
||||
|
||||
$validate_reslut = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga,apk'])->check();
|
||||
// dump($file);exit;
|
||||
if (!$validate_reslut) {
|
||||
return ['code' => 201, 'msg' => '非法上传存储类型', 'data' => null];
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($file->getInfo('name'), PATHINFO_EXTENSION));
|
||||
$file_info = $file->getInfo();
|
||||
|
||||
|
||||
// 构建鉴权对象
|
||||
$cosClient = new Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// 要上传文件的本地路径
|
||||
$filePath = $file_info['tmp_name'];
|
||||
// 上传到存储后保存的文件名
|
||||
$savename = date('Ymd') . '/' . md5(microtime(true)) . ".$extension";
|
||||
$key = $file_category_name . '/' . $savename;
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$file = fopen($filePath, "rb");
|
||||
|
||||
if ($file) {
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => $bucket,
|
||||
'Key' => $key,
|
||||
'Body' => $file)
|
||||
);
|
||||
|
||||
$data = [];
|
||||
$data['image_path'] = $result['Key'];
|
||||
$data['size'] = $file_info['size'];
|
||||
$data['http_image_path'] = localpath_to_netpath($result['Key']);
|
||||
$data['mp4_task_id'] = '';
|
||||
|
||||
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
24
application/version/model/User.php
Normal file
24
application/version/model/User.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\model;
|
||||
|
||||
use think\Model;
|
||||
use think\DB;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
public function check_login_token($login_token)
|
||||
{
|
||||
if (empty($login_token)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['login_token', '=', $login_token];
|
||||
$user_info = db::name('user')->where($map)->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '登录成功', 'data' => $user_info['uid']];
|
||||
}
|
||||
}
|
||||
}
|
||||
93
application/version/model/Version.php
Normal file
93
application/version/model/Version.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\version\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Version extends Model
|
||||
{
|
||||
public function get_version_list($page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['type', 'in', [1,2]];
|
||||
$list = db::name('version')->where($map)->order('vid desc')->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('version')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_version($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$version_info = db::name('version')->find($data['vid']);
|
||||
if (empty($version_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['type'] = $data['type'];
|
||||
$update_data['version'] = $data['version'];
|
||||
$update_data['down_url'] = $data['down_url'];
|
||||
$update_data['note'] = $data['note'];
|
||||
$update_data['is_force_update'] = $data['is_force_update'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('version')->where(['vid' => $data['vid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加
|
||||
public function add_version($data)
|
||||
{
|
||||
|
||||
$add_data = [];
|
||||
$add_data['type'] = $data['type'];
|
||||
$add_data['version'] = $data['version'];
|
||||
$add_data['down_url'] = $data['down_url'];
|
||||
$add_data['note'] = $data['note'];
|
||||
$add_data['is_force_update'] = $data['is_force_update'];
|
||||
$add_data['add_time'] = time();
|
||||
$reslut = db::name('version')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_version_info($vid)
|
||||
{
|
||||
if (empty($vid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$version_info = db::name('version')->where(['vid' => $vid])->find();
|
||||
$version_info['http_base_image'] = localpath_to_netpath($version_info['down_url']);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $version_info];
|
||||
}
|
||||
|
||||
//删除
|
||||
public function del_version($vid)
|
||||
{
|
||||
if (empty($vid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('version')->where(['vid' => $vid])->delete();
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user