table)->where($where)->page($page, $page_limit)->select(); $count = db::name($this->table)->where($where)->count(); foreach ($list as &$value) { $value['begin_time'] = date('Y-m-d H:i:s',$value['begin_time']); $value['end_time'] = date('Y-m-d H:i:s',$value['end_time']); } $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', ''); $begin_time = input('begin_time', ''); $end_time = input('end_time', ''); $begin_time = !empty($begin_time) ? strtotime($begin_time) : 0; $end_time = !empty($end_time) ? strtotime($end_time) : 0; $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(), 'begin_time' => $begin_time, 'end_time' => $end_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', ''); $begin_time = input('begin_time', ''); $end_time = input('end_time', ''); $begin_time = !empty($begin_time) ? strtotime($begin_time) : 0; $end_time = !empty($end_time) ? strtotime($end_time) : 0; $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(), 'begin_time' => $begin_time, 'end_time' => $end_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,"应用失败"); } } }