| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <?php
- /**
- * User: Qinii
- * Date: 2020-10-12
- * Time: 09:41
- */
- namespace app\controller\api\information;
- use think\App;
- use app\common\repositories\information\InformationRepository as repository;
- //use app\common\repositories\article\ArticleRepository as repository;
- //use app\validate\api\InformationValidate as validate;
- use crmeb\basic\BaseController;
- class Information extends BaseController
- {
- /**
- * @var repository
- */
- protected $repository;
- /**
- * StoreBrand constructor.
- * @param App $app
- * @param repository $repository
- */
- public function __construct(App $app, repository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- /**
- *发布资讯
- *@title 标题
- *@content 内容
- *@images 图片
- *@uid 用户id
- */
- public function postinfo()
- {
- $data = $this->request->params(['title', 'content','images']);
- $data['uid'] = $this->request->uid();
- $cid = 24 ;
- $res=$this->repository->postinfo($data,$cid);
- if ($res) {
- return app('json')->success('发布成功');
- }else{
- return app('json')->fail('发布失败');
- }
-
- }
- /**
- *我发布的资讯
- *@title 搜索标题
- *@uid 用户id
- *@pid 父id
- *@id id
- */
- public function userlist()
- {
- [$page, $limit] = $this->getPage();
- $title = $this->request->params(['title']);
- $where['status'] = ['in','0,1,2,3'];
- if(input('status')){
- $where['status'] =input('status');
- }
- $where['uid'] = $this->request->uid();
- $where["pid"]=0;
- $res=$this->repository->getlist($where,$page,$limit,$title['title']);
- return app('json')->success($res);
- }
- /**
- *编辑我发布的资讯
- *@title 标题
- *@content 内容
- *@images 图片
- *@id id
- *@uid 用户id
- */
- public function editinfo(){
- $data = $this->request->params(['title', 'content','images','id']);
- $where['uid'] = $this->request->uid();
- $where["pid"]=0;
- $res=$this->repository->editinfo($data,$where);
- if ($res) {
- return app('json')->success('编辑成功');
- }else{
- return app('json')->fail('保存失败');
- }
- }
- /**
- *删除我发布的资讯
- *@id id
- *@uid 用户id
- */
- public function delinfo(){
- $where = $this->request->params(['id']);
- if(empty($where["id"])) return app('json')->fail('请上传id');
- $wheres['uid'] = $this->request->uid();
- $wheres['article_id']= $where["id"];
- $res=$this->repository->delinfo($wheres);
- if ($res) {
- return app('json')->success('编辑成功');
- }else{
- return app('json')->fail('保存失败');
- }
- }
- /**
- * 资讯列表
- * @id id
- * page
- * limit
- * uid
- * pid
- * order 排序
- */
- public function list()
- {
- [$page, $limit] = $this->getPage();
- $title = input('title/s',"");
- if ($title){
- $where["title"]=["like","%".$title."%"];
- }
- $where["pid"]=0;
- $where["status"]=1;
- $where["cid"]=23;
- $order="is_top desc,id desc";
- $res=$this->repository->getlist($where,$page,$limit,$order);
- if ($res) {
- return app('json')->success($res);
- }else{
- return app('json')->fail('暂无数据');
- }
-
- }
- /**
- * 发布评论
- * content评论内容
- * pid 评论对象id
- */
- public function postcomment()
- {
- $data = $this->request->params(['content','pid']);
- $data['uid'] = $this->request->uid();
- $res=$this->repository->postcomment($data);
- if ($res) {
- return app('json')->success('发布成功');
- }else{
- return app('json')->fail('发布失败');
- }
-
- }
- /**
- * 评论列表
- * id 评论对象id
- */
- public function getcomment()
- {
- [$page, $limit] = $this->getPage();
- $id = input('id/d');
- $uid= $this->request->uid();
- if(empty($id)) return app('json')->fail('请上传id');
- $where["pid"]=$id;
- $res=$this->repository->getcommentlist($where,$page,$limit,$uid);
- if ($res) {
- return app('json')->success($res);
- }else{
- return app('json')->fail('暂无评论');
- }
-
- }
- /**
- * 赞 取消赞
- * pid 赞的对象id
- */
- public function fabulous()
- {
- $data = $this->request->params(['pid']);
- $data['uid'] = $this->request->uid();
- $data['type']=0;
- if(empty($data["pid"])) return app('json')->fail('请上传pid');
- $res=$this->repository->fabulous($data);
- if ($res) {
- return app('json')->success($res);
- }else{
- return app('json')->fail('失败');
- }
-
- }
- /**
- * 举报
- * pid 举报的对象id
- * cotent 举报内容
- */
- public function report()
- {
- $data = $this->request->params(['pid',"cotent"]);
- $data['uid'] = $this->request->uid();
- $data['type']=1;
- if(empty($data["pid"])) return app('json')->fail('请上传pid');
- $res=$this->repository->report($data);
- if ($res) {
- return app('json')->success($res);
- }else{
- return app('json')->fail('失败');
- }
-
- }
- /**
- * 评论管理
- * $uid 用户id
- */
- public function get_comment_list(){
- $uid = $this->request->uid();
- $res=$this->repository->comment_list($uid);
- if ($res) {
- return app('json')->success($res);
- }else{
- return app('json')->fail('暂无数据');
- }
- }
- }
|