-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'd7d8ee481e720624225511e102773d1f2fc68e41' into pro
- Loading branch information
Showing
65 changed files
with
1,806 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use Request; | ||
use App\Models\User; | ||
use App\Module\Base; | ||
use App\Models\Complaint; | ||
use App\Models\WebSocketDialog; | ||
|
||
/** | ||
* @apiDefine dialog | ||
* | ||
* 投诉 | ||
*/ | ||
class ComplaintController extends AbstractController | ||
{ | ||
/** | ||
* @api {get} api/complaint/lists 01. 获取举报投诉列表 | ||
* | ||
* @apiDescription 需要token身份 | ||
* @apiVersion 1.0.0 | ||
* @apiGroup dialog | ||
* @apiName lists | ||
* | ||
* @apiParam {Number} [type] 类型 | ||
* @apiParam {Number} [status] 状态 | ||
* | ||
* @apiParam {Number} [page] 当前页,默认:1 | ||
* @apiParam {Number} [pagesize] 每页显示数量,默认:50,最大:100 | ||
* | ||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误) | ||
* @apiSuccess {String} msg 返回信息(错误描述) | ||
* @apiSuccess {Object} data 返回数据 | ||
*/ | ||
public function lists() | ||
{ | ||
$user = User::auth(); | ||
$user->identity('admin'); | ||
// | ||
$type = intval(Request::input('type')); | ||
$status = Request::input('status'); | ||
// | ||
$complaints = Complaint::query() | ||
->when($type, function($q) use($type) { | ||
$q->where('type', $type); | ||
}) | ||
->when($status != "", function($q) use($status) { | ||
$q->where('status', $status); | ||
}) | ||
->orderByDesc('id') | ||
->paginate(Base::getPaginate(100, 50)); | ||
// | ||
return Base::retSuccess('success', $complaints); | ||
} | ||
|
||
/** | ||
* @api {get} api/complaint/submit 02. 举报投诉 | ||
* | ||
* @apiDescription 需要token身份 | ||
* @apiVersion 1.0.0 | ||
* @apiGroup dialog | ||
* @apiName submit | ||
* | ||
* @apiParam {Number} dialog_id 对话ID | ||
* @apiParam {Number} type 类型 | ||
* @apiParam {String} reason 原因 | ||
* @apiParam {String} imgs 图片 | ||
* | ||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误) | ||
* @apiSuccess {String} msg 返回信息(错误描述) | ||
* @apiSuccess {Object} data 返回数据 | ||
*/ | ||
public function submit() | ||
{ | ||
$user = User::auth(); | ||
// | ||
$dialog_id = intval(Request::input('dialog_id')); | ||
$type = intval(Request::input('type')); | ||
$reason = trim(Request::input('reason')); | ||
$imgs = Request::input('imgs'); | ||
// | ||
WebSocketDialog::checkDialog($dialog_id); | ||
// | ||
if (!$type) { | ||
return Base::retError('请选择举报类型'); | ||
} | ||
if (!$reason) { | ||
return Base::retError('请填写举报原因'); | ||
} | ||
// | ||
$report_imgs = []; | ||
if (!empty($imgs) && is_array($imgs)) { | ||
foreach ($imgs as $img) { | ||
$report_imgs[] = Base::unFillUrl($img['path']); | ||
} | ||
} | ||
// | ||
Complaint::createInstance([ | ||
'dialog_id' => $dialog_id, | ||
'userid' => $user->userid, | ||
'type' => $type, | ||
'reason' => $reason, | ||
'imgs' => $report_imgs, | ||
])->save(); | ||
// | ||
return Base::retSuccess('success'); | ||
} | ||
|
||
/** | ||
* @api {get} api/complaint/action 03. 举报投诉 - 操作 | ||
* | ||
* @apiDescription 需要token身份 | ||
* @apiVersion 1.0.0 | ||
* @apiGroup dialog | ||
* @apiName action | ||
* | ||
* @apiParam {Number} id ID | ||
* @apiParam {Number} type 类型 | ||
* | ||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误) | ||
* @apiSuccess {String} msg 返回信息(错误描述) | ||
* @apiSuccess {Object} data 返回数据 | ||
*/ | ||
public function action() | ||
{ | ||
$user = User::auth(); | ||
$user->identity('admin'); | ||
// | ||
$id = intval(Request::input('id')); | ||
$type = trim(Request::input('type')); | ||
// | ||
if ($type == 'handle') { | ||
Complaint::whereId($id)->update([ | ||
"status" => 1 | ||
]); | ||
} | ||
if ($type == 'delete') { | ||
Complaint::whereId($id)->delete(); | ||
} | ||
// | ||
return Base::retSuccess('success'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
|
||
/** | ||
* App\Models\Complaint | ||
* | ||
* @property int $id | ||
* @property int|null $dialog_id 对话ID | ||
* @property int|null $userid 举报人id | ||
* @property int|null $type 举报类型 | ||
* @property string|null $reason 举报原因 | ||
* @property string|null $imgs 举报图片 | ||
* @property int|null $status 状态 0待处理、1已处理、2已删除 | ||
* @property \Illuminate\Support\Carbon|null $created_at | ||
* @property \Illuminate\Support\Carbon|null $updated_at | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelAppend() | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelHidden() | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel change($array) | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel getKeyValue() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint newModelQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint newQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint query() | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel remove() | ||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel saveOrIgnore() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereCreatedAt($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereDialogId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereImgs($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereReason($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereStatus($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereType($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereUpdatedAt($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Complaint whereUserid($value) | ||
* @mixin \Eloquent | ||
*/ | ||
class Complaint extends AbstractModel | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
database/migrations/2024_04_24_145504_create_complaints_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateComplaintsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('complaints', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->bigInteger('dialog_id')->nullable()->default(0)->comment('对话ID'); | ||
$table->bigInteger('userid')->nullable()->default(0)->comment('举报人id'); | ||
$table->bigInteger('type')->nullable()->default(0)->comment('举报类型'); | ||
$table->string('reason', 500)->nullable()->default('')->comment('举报原因'); | ||
$table->text('imgs')->nullable()->comment('举报图片'); | ||
$table->bigInteger('status')->nullable()->default(0)->comment('状态 0待处理、1已处理、2已删除'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('complaints'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,3 +494,6 @@ Api接口文档 | |
|
||
注册失败 | ||
会议已结束 | ||
|
||
请选择举报类型 | ||
请填写举报原因 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.