68 lines
2.0 KiB
PHP
Raw Normal View History

2021-07-28 10:04:47 +08:00
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
2021-11-24 17:17:29 +08:00
* @license https://opensource.org/licenses/Apache-2.0
2021-07-28 10:04:47 +08:00
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\api\controller;
use app\api\BaseController;
2021-07-28 15:16:29 +08:00
use app\api\middleware\Auth;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
2021-07-28 10:04:47 +08:00
use think\facade\Db;
use think\facade\Request;
class Index extends BaseController
{
/**
* 控制器中间件 [登录、注册 不需要鉴权]
* @var array
*/
protected $middleware = [
Auth::class => ['except' => ['index','reg','login'] ]
2021-07-28 10:04:47 +08:00
];
2023-01-18 17:10:33 +08:00
/**
* 文章投诉接口.
*/
public function complaint(){
$param = get_params();
$id = $param['id']; //文章id
$content = $param['content']; //投诉内容
$type = $param['type']??1; //标识1文章/2朋友圈
2023-03-14 14:50:53 +08:00
$user_id = $this->request->uid;//用户的id
2023-01-18 17:10:33 +08:00
$where['article_id'] = $id;
$where['user_id'] = $user_id;
$where['type'] = $type;
$is_complaint = Db::table('fa_article_complaint')->where($where)->find();
if($is_complaint){
$this->apiError('您已投诉!');
}else{
2023-03-14 14:50:53 +08:00
$useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->where('status', 1)->find();
2023-01-18 17:10:33 +08:00
$data = [];
if ($useraddress) {
$data['county'] = $useraddress['area_id'];
$data['township'] = $useraddress['street_id'];
$data['village'] = $useraddress['village_id'];
}
$data['article_id'] = $id;
$data['user_id'] = $user_id;
$data['type'] = $type;
$data['content'] = $content;
$data['createtime'] = time();
$res = Db::table('fa_article_complaint')->strict(false)->insert($data);
if($res){
$this->apiSuccess('投诉成功');
}else{
$this->apiError('投诉失败');
}
}
}
2021-07-28 10:04:47 +08:00
}