dggzichahu/application/admin/logic/ScreenSizeLogic.php

112 lines
3.0 KiB
PHP
Executable File

<?php
// +----------------------------------------------------------------------
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | Author: HcyShop-kiki
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\admin\model\ScreenSize;
use think\Db;
class ScreenSizeLogic
{
public static function lists($get)
{
$where = [];
$where[] = ['del', '=', '0'];
$screen_size = new ScreenSize();
$count = $screen_size->where($where)->count();
$list = $screen_size->where($where)->page($get['page'], $get['limit'])->select();
foreach ($list as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
if ($item['is_show'] == 1) {
$item['is_show_text'] = '启用';
} else {
$item['is_show_text'] = '停用';
}
}
return ['count' => $count, 'lists' => $list];
}
/**
* Desc: 添加筛选尺寸
* @param $post array
* @return boolean
*/
public static function addScreenSize($post)
{
$screen_size = new ScreenSize();
$data = [
'name' => $post['name'],
'is_show' => $post['is_show'],
'create_time' => time(),
];
return $screen_size->save($data);
}
/**
* Desc: 编辑筛选尺寸
* @param $post array
* @return boolean
*/
public static function editScreenSize($post)
{
$screen_size = new ScreenSize();
$data = [
'name' => $post['name'],
'is_show' => $post['is_show'],
'update_time' => time(),
];
return $screen_size->save($data, ['id' => $post['id'], 'del' => 0]);
}
/**
* Desc: 删除筛选尺寸
* @param $id int
* @return boolean
*/
public static function delScreenSize($id)
{
$screen_size = new ScreenSize();
$data = [
'update_time' => time(),
'del' => 1,
];
return $screen_size->save($data, ['id' => $id, 'del' => 0]);
}
/**
* Desc: 获取单条筛选尺寸
* @param $id int
* @return boolean
*/
public static function getScreenSize($id = 0)
{
$where[] = ['del', '=', 0];
if ($id) {
$where[] = ['id', '=', $id];
}
$screen_size = new ScreenSize();
return $screen_size->where($where)->column('*', 'id');
}
public static function switchStatus($post)
{
$data = [
'is_show' => $post['is_show'],
'update_time' => time(),
];
return Db::name('screen_size')->where(['del' => 0, 'id' => $post['id']])->update($data);
}
//获取尺寸列表
public static function getScreenSizeList(){
return Db::name('screen_size')->where(['del'=>0])->field('id,name')->select();
}
}