代码初始化
This commit is contained in:
75
application/api/controller/Usermode.php
Normal file
75
application/api/controller/Usermode.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Usermode extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//开启/关闭青少年模式
|
||||
public function open_teen_mode(){
|
||||
$uid = UID;
|
||||
$key_name = "api:user:open_teen_mode:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 1);
|
||||
$password = input('password', '');
|
||||
$again_password = input('again_password', '');
|
||||
$reslut = model('UserMode')->open_teen_mode($uid, $type, $password, $again_password);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关闭青少年模式、确认青少年模式密码
|
||||
public function close_teen_mode(){
|
||||
$uid = $this->uid;
|
||||
$key_name = "api:user:close_teen_mode:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 1);
|
||||
$password = input('password', '');
|
||||
$reslut = model('UserMode')->close_teen_mode($uid, $type, $password);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//青少年模式类型列表
|
||||
public function getUnderageTypeList(){
|
||||
$list = Db::name('vs_underage_mode_type')->where('is_delete', 1)->order(['sort'=>'asc', 'id' => 'desc'])->select();
|
||||
return V(1, "操作成功", $list);
|
||||
}
|
||||
//获取青少年模式列表 带分页
|
||||
public function getUnderageModeList(){
|
||||
$type = $this->request->get('type');
|
||||
$page = $this->request->get('page', 1);
|
||||
$page_limit = $this->request->get('page_limit', 10);
|
||||
if(!$type){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$list = Db::name('vs_underage_mode_content')
|
||||
->where('type_id', $type)
|
||||
->where('is_delete', 1)
|
||||
->order(['sort'=>'asc', 'id' => 'desc'])
|
||||
->paginate($page_limit, false, ['page' => $page]);
|
||||
return V(1, "操作成功", $list);
|
||||
}
|
||||
//获取青少年模式内容
|
||||
public function getUnderageModeContent(){
|
||||
$id = $this->request->get('id');
|
||||
if(!$id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = Db::name('vs_underage_mode_content')
|
||||
->where('is_delete', 1)
|
||||
->where('id', $id)
|
||||
->find();
|
||||
return V(1, "操作成功", $data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user