123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- declare (strict_types = 1);
- namespace app\model\system;
- use app\Request;
- use library\basic\BaseModel;
- use library\services\UtilService;
- use library\utils\Arr;
- use think\db\exception\DbException;
- use think\Model;
- class News extends BaseModel{
- private $_data;
- /**
- * 保存数据
- * @param type $post
- * @return boolean
- */
- public function newsSave($post){
- if(!empty($post['id'])) {
- $this->where('id',$post['id'])->save($post);
- return true;
- } else {
- unset($post['id']);
- $post["time"] = time();
- $bool = $this->insert($post);
- return $bool;
- }
- }
- /**
- * 删除数据
- * @param type $id
- * @return boolean
- */
- public function newsDel($id){
- $this->where("id",$id)->delete();
- return true;
- }
-
- /**
- * 设置显示状态
- * @param $id
- * @param $status
- */
- public function newsShowSet($id,$status) {
- self::beginTrans();
- try{
- $this->where('id', $id)->save(['is_show'=>$status]);
- self::commitTrans();
- return true;
- }catch (DbException $db) {
- self::rollbackTrans();
- return false;
- }
- }
- }
|