初始化代码
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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user