Skip to content

Commit

Permalink
Merge branch 'develop' of ssh://git.gezi.vip:6006/gx/dootask
Browse files Browse the repository at this point in the history
# Conflicts:
#	public/css/app.css
#	public/js/app.js
#	public/js/build/208.js
#	public/js/build/389.js
#	public/js/build/406.js
#	public/js/build/406.js.LICENSE.txt
#	public/js/build/423.js
#	public/js/build/459.js
#	public/js/build/459.js.LICENSE.txt
#	public/js/build/688.js
#	public/js/build/688.js.LICENSE.txt
#	public/js/build/726.js
#	public/js/build/755.js
#	public/js/build/93.js
#	public/js/build/954.js
  • Loading branch information
kuaifan committed Feb 19, 2022
2 parents 970b811 + 09b1d89 commit f4f351c
Show file tree
Hide file tree
Showing 7,013 changed files with 2,558,474 additions and 75 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
35 changes: 34 additions & 1 deletion app/Http/Controllers/Api/DialogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\WebSocketDialog;
use App\Models\WebSocketDialogMsg;
use App\Models\WebSocketDialogMsgRead;
use App\Models\WebSocketDialogUser;
use App\Module\Base;
use Carbon\Carbon;
use Request;
Expand Down Expand Up @@ -39,9 +40,10 @@ public function lists()
{
$user = User::auth();
//
$list = WebSocketDialog::select(['web_socket_dialogs.*'])
$list = WebSocketDialog::select(['web_socket_dialogs.*','u.top','u.top_at'])
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
->where('u.userid', $user->userid)
->orderByDesc('u.top')
->orderByDesc('web_socket_dialogs.last_at')
->paginate(Base::getPaginate(200, 100));
$list->transform(function (WebSocketDialog $item) use ($user) {
Expand Down Expand Up @@ -475,4 +477,35 @@ public function msg__withdraw()
$msg->deleteMsg();
return Base::retSuccess("success");
}

/**
* @api {get} api/dialog/top 12. 会话置顶
*
* @apiDescription 消息撤回限制24小时内,需要token身份
* @apiVersion 1.0.0
* @apiGroup dialog
* @apiName top
*
* @apiParam {Number} dialog_id 会话ID
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function top()
{
$user = User::auth();
$dialogId = intval(Request::input('dialog_id'));
$dialogUser = WebSocketDialogUser::whereUserid($user->userid)->whereDialogId($dialogId)->first();
if (!$dialogUser) {
return Base::retError("会话不存在");
}
$top = $dialogUser->top === 1 ? 0 : 1;
$topAt = $dialogUser->top === 1 ? null : Carbon::now();
$dialogUser->top = $top;
$dialogUser->top_at = $topAt;
$dialogUser->save();
return Base::retSuccess("success", $dialogId);
}

}
20 changes: 20 additions & 0 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,24 @@ public function login()
$type = trim(Request::input('type'));
$email = trim(Request::input('email'));
$password = trim(Request::input('password'));
if(!$email){
return Base::retError('请输入邮箱地址');
}
if ($type == 'reg') {
$password2 = trim(Request::input('password2'));
//邮箱
if (!Base::isMail($email)) {
return Base::retError('请输入正确的邮箱地址');
}
if (User::email2userid($email) > 0) {
return Base::retError('邮箱地址已存在');
}
if (empty($password)) {
return Base::retError('请输入密码');
}
if ($password != $password2) {
return Base::retError('确认密码输入不一致');
}
$setting = Base::setting('system');
if ($setting['reg'] == 'close') {
return Base::retError('未开放注册');
Expand All @@ -64,6 +81,9 @@ public function login()
return Base::retError('请输入正确的验证码', ['code' => 'need']);
}
}
if (empty($password)) {
return Base::retError('请输入密码');
}
//
$retError = function ($msg) use ($email) {
Cache::forever("code::" . $email, "need");
Expand Down
7 changes: 0 additions & 7 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,6 @@ public function checkSystem($onlyUserid = null)
*/
public static function reg($email, $password, $other = [])
{
//邮箱
if (!Base::isMail($email)) {
throw new ApiException('请输入正确的邮箱地址');
}
if (User::email2userid($email) > 0) {
throw new ApiException('邮箱地址已存在');
}
//密码
self::passwordPolicy($password);
//开始注册
Expand Down
2 changes: 2 additions & 0 deletions app/Models/WebSocketDialogUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @property int $id
* @property int|null $dialog_id 对话ID
* @property int|null $userid 会员ID
* @property int|null $top 是否置顶:0否,1是
* @property \Illuminate\Support\Carbon|null $top_at 置顶时间
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogUser newModelQuery()
Expand Down
55 changes: 55 additions & 0 deletions app/Tasks/BatchRemoveFileTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Tasks;

use App\Exceptions\ApiException;
use App\Models\File;
use App\Models\Tmp;
use App\Models\User;
use App\Models\WebSocketTmpMsg;
use Carbon\Carbon;
use Log;
use Throwable;

/**
* 删除过期临时数据任务
* Class DeleteTmpTask
* @package App\Tasks
*/
class BatchRemoveFileTask extends AbstractTask
{
protected array $_ids = [];

protected int $_userid;

public function __construct(array $ids, $userid)
{
$this->_ids = $ids;
$this->_userid = $userid;
}

public function start()
{
foreach ($this->_ids as $id) {
Log::info("---------- $id ----------");
Log::info("尝试删除Id为[$id]的文件");
$file = File::find($id);
if (empty($file)) {
Log::warning("Id为[$id]的文件不存在或已被删除");
continue;
}
Log::info("获取到文件名为[" . $file->name . "],类型为[" . ( $file->type ?: $file->ext ) . "]");
$permission = $file->getPermission($this->_userid);
if ($permission < 1000) {
Log::warning("文件[$id][" . $file->name . "]仅限所有者或创建者操作");
continue;
}
try {
$file->deleteFile();
Log::info("删除Id为[$id]的文件成功");
} catch (Throwable $throwable) {
Log::error("删除Id为[$id]的文件失败,原因是:" . $throwable->getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class WebSocketDialogUsersAddTop extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
if (!Schema::hasColumn('web_socket_dialog_users', 'top')) {
$table->tinyInteger('top')->nullable()->default(0)->after('userid')->comment('是否置顶:0否,1是');
}
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
$table->dropColumn("top");
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class WebSocketDialogUsersAddTopAt extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
if (!Schema::hasColumn('web_socket_dialog_users', 'top_at')) {
$table->timestamp('top_at')->nullable()->after('top')->comment('置顶时间');
}
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
$table->dropColumn("top_at");
});
}
}
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/iview.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/js/build/113.js

This file was deleted.

2 changes: 1 addition & 1 deletion public/js/build/208.js

Large diffs are not rendered by default.

Loading

0 comments on commit f4f351c

Please sign in to comment.