132 lines
3.5 KiB
PHP
132 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller;
|
|
|
|
use app\admin\model\AdminLog;
|
|
use app\common\controller\adminApi;
|
|
use think\Config;
|
|
use think\Db;
|
|
use think\Hook;
|
|
use think\Session;
|
|
use think\Validate;
|
|
|
|
/**
|
|
* 版本管理
|
|
* @internal
|
|
*/
|
|
class Theme extends adminApi
|
|
{
|
|
|
|
protected $noNeedLogin = [];
|
|
protected $noNeedRight = [];
|
|
|
|
protected $table = 'vs_theme';
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
}
|
|
/*
|
|
* 列表
|
|
*/
|
|
public function theme_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$id = input('id', '');
|
|
$theme_name = input('theme_name', '');
|
|
$where=[];
|
|
if($id != ''){
|
|
$where['id'] = $id;
|
|
}
|
|
if($theme_name != ''){
|
|
$where['theme_name'] = $theme_name;
|
|
}
|
|
$list = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
|
$count = db::name($this->table)->where($where)->count();
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $list
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
/*
|
|
* 添加
|
|
*/
|
|
public function theme_add(){
|
|
$admin_id = Session::get('admin_id');
|
|
$theme_name = input('theme_name', '');
|
|
$theme_color = input('theme_color', '');
|
|
$auxiliary_color = input('auxiliary_color', '');
|
|
$file_url = input('file_url', '');
|
|
$is_active = input('is_active', '');
|
|
$data = [
|
|
'theme_name' => $theme_name,
|
|
'theme_color' => $theme_color,
|
|
'auxiliary_color' => $auxiliary_color,
|
|
'file_url' => $file_url,
|
|
'is_active' => $is_active,
|
|
'admin_id' => $admin_id,
|
|
'createtime' => time()
|
|
];
|
|
$res = db::name($this->table)->insert($data);
|
|
if($res){
|
|
return V(1,"添加成功");
|
|
}else{
|
|
return V(0,"添加失败");
|
|
}
|
|
}
|
|
/*
|
|
* 修改
|
|
*/
|
|
public function theme_edit(){
|
|
$theme_name = input('theme_name', '');
|
|
$theme_color = input('theme_color', '');
|
|
$auxiliary_color = input('auxiliary_color', '');
|
|
$file_url = input('file_url', '');
|
|
$is_active = input('is_active', '');
|
|
$id = input('id', '');
|
|
$data = [
|
|
'theme_name' => $theme_name,
|
|
'theme_color' => $theme_color,
|
|
'auxiliary_color' => $auxiliary_color,
|
|
'file_url' => $file_url,
|
|
'is_active' => $is_active,
|
|
'updatetime' => time()
|
|
];
|
|
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
|
if($res){
|
|
return V(1,"修改成功");
|
|
}else{
|
|
return V(0,"修改失败");
|
|
}
|
|
}
|
|
/*
|
|
* 删除
|
|
*/
|
|
public function theme_del(){
|
|
$id = input('id', '');
|
|
$res = db::name($this->table)->where(['id'=>$id])->delete();
|
|
if($res){
|
|
return V(1,"删除成功");
|
|
}else{
|
|
return V(0,"删除失败");
|
|
}
|
|
}
|
|
/*
|
|
* 应用
|
|
*/
|
|
public function theme_apply(){
|
|
$id = input('id', '');
|
|
db::name($this->table)->where(['is_active'=>1])->update(['is_active'=>0]);
|
|
$res = db::name($this->table)->where(['id'=>$id])->update(['is_active'=>1]);
|
|
if($res){
|
|
return V(1,"应用成功");
|
|
}else{
|
|
return V(0,"应用失败");
|
|
}
|
|
}
|
|
|
|
} |