Post.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Db;
  7. class Post extends Base
  8. {
  9. public function __construct(App $app = null) {
  10. parent::__construct($app);
  11. $this->model = new \app\common\model\Post();
  12. }
  13. public function add(){
  14. $ret=$this->model->addSave($this->userId,$this->orgId);
  15. if($ret){
  16. HelpHander::success([],'发布成功');
  17. }else{
  18. HelpHander::error($this->model->getError());
  19. }
  20. }
  21. public function lists(){
  22. $page=input('page',1);
  23. $size=input('size',10);
  24. $ret=$this->model->lists($page,$size,$this->orgId,$this->userId);
  25. if($ret){
  26. HelpHander::success($ret);
  27. }else{
  28. HelpHander::error('暂无信息');
  29. }
  30. }
  31. public function del(){
  32. $id=input('id');
  33. $ret=$this->model->del($id);
  34. if($ret){
  35. HelpHander::success([],'删除成功');
  36. }else{
  37. HelpHander::error('删除失败');
  38. }
  39. }
  40. }