niucloud-admin/niucloud/app/service/admin/applet/AppletVersionService.php
2023-07-01 16:20:54 +08:00

124 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\applet;
use app\dict\applet\AppletlDict;
use app\dict\sys\FileDict;
use app\model\applet\AppletVersion;
use app\model\article\Article;
use app\service\core\applet\CoreAppletVersionService;
use app\service\core\upload\CoreUploadService;
use core\base\BaseAdminService;
/**
* 文章服务层
* Class ArticleService
* @package app\service\admin\article
*/
class AppletVersionService extends BaseAdminService
{
protected $core_applet_version_service;
public function __construct()
{
parent::__construct();
$this->model = new AppletVersion();
$this->core_applet_version_service = new CoreAppletVersionService;
}
/**
* 获取列表
* @param array $where
* @param string $order
*/
public function getPage(array $where = [])
{
return $this->core_applet_version_service->getPage($where);
}
/**
* 获取信息
* @param int $id
*/
public function getInfo(int $id)
{
return $this->core_applet_version_service->getInfo($id);
}
/**
* 添加
* @param array $data
* @return true
*/
public function add(array $data)
{
$data['version_num'] = version_to_int($data['version']);//版本号数字
$data['uid'] = $this->uid;//发布者
$data['status'] = AppletlDict::OFF;
$this->model->create($data);
return true;
}
/**
* 上传小程序包
* @param $file
* @return true
* @throws \Exception
*/
public function upload($file){
$core_upload_service = new CoreUploadService();
$type = FileDict::APPLET;
$dir = '/applet/'.$type.'/version/';
return $core_upload_service->document($file, $this->site_id, $type, $dir, FileDict::LOCAL);
}
/**
* 设置版本状态
* @param $id
* @param $status
* @return true
*/
public function setStatus(int $id, $status){
$data = array(
'status' => $status
);
$where = array(
['id', '=', $id]
);
$this->model->where($where)->update($data);
return true;
}
/**
* 编辑
* @param int $id
* @param array $data
*/
public function edit(int $id, array $data)
{
$data['version_num'] = version_to_int($data['version']);//版本号数字
$data['status'] = AppletlDict::OFF;
$data['update_time'] = time();
$this->model->where([['id', '=', $id]])->create($data);
return true;
}
/**
* 删除
* @param int $id
* @return true
*/
public function del(int $id){
$this->model->where([['id', '=', $id]])->delete();
return true;
}
}