123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\admin\logic;
- use app\model\CommonModel;
- use app\model\VersionModel;
- use think\facade\Db;
- use think\response\Json;
- class VersionLogic extends BaseLogic
- {
- public static function lastVersion(): Json
- {
- //最新版本信息
- $version = VersionModel::order("addtime desc")
- ->findOrEmpty()
- ->toArray();
- return json_show(CommonModel::$success, '获取成功', $version);
- }
- //获取版本列表
- public static function getList(array $data = []): Json
- {
- $where = [];
- if ($data['keyword'] != '') $where[] = ['title', 'like', '%' . $data['keyword'] . '%'];
- $count = Db::name("version")
- ->where($where)
- ->count('id');
- $list = VersionModel::where($where)
- ->page($data['page'], $data['size'])
- ->order(['addtime' => 'desc'])
- ->select()
- ->toArray();
- return json_show(CommonModel::$success, '获取成功', ['list' => $list, 'count' => $count]);
- }
- //新增版本
- public static function create(array $data = []): Json
- {
- $data = [
- "title" => $data['title'],
- "content" => $data['content'],
- "version" => $data['version'],
- "addtime" => date("Y-m-d H:i:s")
- ];
- $inert = VersionModel::create($data)->save();
- //write_log("版本{$version}新建成功", $this->userinfo, "version", "add");
- return $inert ? json_show(CommonModel::$success, '版本信息新建成功') : json_show(CommonModel::$error_param, '版本信息新建失败');
- }
- }
|