Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
6 个修改的文件
包含
112 行增加
和
3 行删除
| @@ -2,7 +2,55 @@ | @@ -2,7 +2,55 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Logic\Bside\MailLogic; | ||
| 7 | +use App\Models\Mail as MailModel; | ||
| 8 | +use App\Models\MailUser as MailUserModel; | ||
| 9 | +use Illuminate\Http\Request; | ||
| 10 | + | ||
| 5 | class MailController extends BaseController | 11 | class MailController extends BaseController |
| 6 | { | 12 | { |
| 13 | + const STATUS_ZERO = 0; //状态为未读状态 | ||
| 14 | + const STATUS_ONE = 1; //状态为已读状态 | ||
| 15 | + /** | ||
| 16 | + * @name :当前用户站内信列表 | ||
| 17 | + * @return void | ||
| 18 | + * @author :liyuhang | ||
| 19 | + * @method | ||
| 20 | + */ | ||
| 21 | + public function lists(){ | ||
| 22 | + $mailModel = new MailModel(); | ||
| 23 | + //获取当前用户下的所有站内信 | ||
| 24 | + $this->map['user_list'] = ['like','%,'.$this->uid.',%']; | ||
| 25 | + $this->map['status'] = $this::STATUS_ZERO; | ||
| 26 | + $lists = $mailModel->lists($this->map,$this->page,$this->row); | ||
| 27 | + if(!empty($lists)){ | ||
| 28 | + foreach ($lists as $k => $v){ | ||
| 29 | + //获取用户已读还是未读 | ||
| 30 | + $info = MailUserModel::read(['mail_id'=>$v['id'],'user_id'=>$this->uid]); | ||
| 31 | + if($info !== false){ | ||
| 32 | + $v['read_status'] = $this::STATUS_ONE;// | ||
| 33 | + } | ||
| 34 | + $lists[$k] = $v; | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @name :获取站内信详情 | ||
| 42 | + * @return void | ||
| 43 | + * @author :liyuhang | ||
| 44 | + * @method | ||
| 45 | + */ | ||
| 46 | + public function info(Request $request,MailLogic $mailLogic){ | ||
| 47 | + $request->validate([ | ||
| 48 | + 'id'=>['required'] | ||
| 49 | + ],[ | ||
| 50 | + 'id.required' => 'ID不能为空' | ||
| 51 | + ]); | ||
| 52 | + $info = $mailLogic->mail_info(); | ||
| 53 | + $this->response('success',Code::SUCCESS,$info); | ||
| 54 | + } | ||
| 7 | 55 | ||
| 8 | } | 56 | } |
app/Http/Logic/Bside/MailLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Models\Mail as MailModel; | ||
| 7 | +use App\Models\MailUser as MailUserModel; | ||
| 8 | + | ||
| 9 | +class MailLogic extends BaseLogic | ||
| 10 | +{ | ||
| 11 | + | ||
| 12 | + public function __construct() | ||
| 13 | + { | ||
| 14 | + parent::__construct(); | ||
| 15 | + $this->model = new MailModel(); | ||
| 16 | + $this->param = $this->requestAll; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @name :详情 | ||
| 21 | + * @author :liyuhang | ||
| 22 | + */ | ||
| 23 | + public function mail_info(){ | ||
| 24 | + $info = $this->model->read($this->param); | ||
| 25 | + if($info === false){ | ||
| 26 | + $this->fail('当前数据不存在',Code::USER_ERROR); | ||
| 27 | + } | ||
| 28 | + //生成一条阅读记录 | ||
| 29 | + $mailUserModel = new MailUserModel(); | ||
| 30 | + $data = [ | ||
| 31 | + 'user_id'=>$info['id'], | ||
| 32 | + 'mail_id'=>$this->user['id'], | ||
| 33 | + ]; | ||
| 34 | + $rs = $mailUserModel->add($data); | ||
| 35 | + if($rs === false){ | ||
| 36 | + $this->fail('error',Code::USER_ERROR); | ||
| 37 | + } | ||
| 38 | + $this->success($info); | ||
| 39 | + } | ||
| 40 | +} |
| @@ -55,6 +55,11 @@ class UserLogic extends BaseLogic | @@ -55,6 +55,11 @@ class UserLogic extends BaseLogic | ||
| 55 | if($info !== false){ | 55 | if($info !== false){ |
| 56 | $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE); | 56 | $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE); |
| 57 | } | 57 | } |
| 58 | + //上传头像 | ||
| 59 | + if(isset($this->param['image'])){ | ||
| 60 | + $data = $this->upload(); | ||
| 61 | + $this->param['image'] = $data['path']; | ||
| 62 | + } | ||
| 58 | $this->param['operator_id'] = $this->user['id']; | 63 | $this->param['operator_id'] = $this->user['id']; |
| 59 | $rs = $this->model->edits($this->param); | 64 | $rs = $this->model->edits($this->param); |
| 60 | if($rs === false){ | 65 | if($rs === false){ |
| @@ -98,7 +103,7 @@ class UserLogic extends BaseLogic | @@ -98,7 +103,7 @@ class UserLogic extends BaseLogic | ||
| 98 | */ | 103 | */ |
| 99 | public function user_del(){ | 104 | public function user_del(){ |
| 100 | $this->param['operator_id'] = $this->user['id']; | 105 | $this->param['operator_id'] = $this->user['id']; |
| 101 | - $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]); | 106 | + $rs = $this->model->edit(['status'=>2],['id'=>['in',$this->param['id']]]); |
| 102 | if($rs === false){ | 107 | if($rs === false){ |
| 103 | $this->fail('error',Code::USER_ERROR); | 108 | $this->fail('error',Code::USER_ERROR); |
| 104 | } | 109 | } |
| @@ -36,7 +36,7 @@ class Base extends Model | @@ -36,7 +36,7 @@ class Base extends Model | ||
| 36 | $query = $this->formatQuery($map); | 36 | $query = $this->formatQuery($map); |
| 37 | $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $page); | 37 | $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $page); |
| 38 | if (empty($lists)) { | 38 | if (empty($lists)) { |
| 39 | - return false; | 39 | + return []; |
| 40 | } | 40 | } |
| 41 | $lists = $lists->toArray(); | 41 | $lists = $lists->toArray(); |
| 42 | return $lists; | 42 | return $lists; |
| @@ -54,7 +54,7 @@ class Base extends Model | @@ -54,7 +54,7 @@ class Base extends Model | ||
| 54 | $query = $this->formatQuery($map); | 54 | $query = $this->formatQuery($map); |
| 55 | $lists = $query->select($fields)->orderBy($order)->get(); | 55 | $lists = $query->select($fields)->orderBy($order)->get(); |
| 56 | if (empty($lists)) { | 56 | if (empty($lists)) { |
| 57 | - return false; | 57 | + return []; |
| 58 | } | 58 | } |
| 59 | $lists = $lists->toArray(); | 59 | $lists = $lists->toArray(); |
| 60 | return $lists; | 60 | return $lists; |
app/Models/MailUser.php
0 → 100644
| @@ -26,6 +26,12 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -26,6 +26,12 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 26 | Route::any('/del', [\App\Http\Controllers\Bside\UserController::class, 'del'])->name('user_del'); | 26 | Route::any('/del', [\App\Http\Controllers\Bside\UserController::class, 'del'])->name('user_del'); |
| 27 | }); | 27 | }); |
| 28 | 28 | ||
| 29 | + //站内信 | ||
| 30 | + Route::prefix('mail')->group(function () { | ||
| 31 | + Route::any('/', [\App\Http\Controllers\Bside\MailController::class, 'lists'])->name('mail_lists'); | ||
| 32 | + Route::any('/info', [\App\Http\Controllers\Bside\MailController::class, 'info'])->name('mail_info'); | ||
| 33 | + }); | ||
| 34 | + | ||
| 29 | //用户角色相关路由 | 35 | //用户角色相关路由 |
| 30 | Route::prefix('role')->group(function () { | 36 | Route::prefix('role')->group(function () { |
| 31 | Route::any('/', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'lists'])->name('project_role_lists'); | 37 | Route::any('/', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'lists'])->name('project_role_lists'); |
-
请 注册 或 登录 后发表评论