Version.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\VersionLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. class Version extends BaseController
  9. {
  10. //最新版本信息
  11. public function lastVersion()
  12. {
  13. return VersionLogic::lastVersion();
  14. }
  15. //获取版本列表
  16. public function getList()
  17. {
  18. $param = $this->request->only(['page' => 1, 'size' => 10, 'keyword' => ''], 'post');
  19. $val = Validate::rule(Config::get('validate_rules.common'));
  20. if (!$val->check($param)) throw new ValidateException($val->getError());
  21. return VersionLogic::getList($param);
  22. }
  23. //创建版本
  24. public function create()
  25. {
  26. $param = $this->request->only(['title', 'content', 'version'], 'post');
  27. $val = Validate::rule(Config::get('validate_rules.createVersion'));
  28. if (!$val->check($param)) throw new ValidateException($val->getError());
  29. return VersionLogic::create($param);
  30. }
  31. }