发布权限

This commit is contained in:
2025-12-24 16:57:35 +08:00
parent e12f2f8d05
commit 35daeffdf0
3 changed files with 61 additions and 5 deletions
+11 -4
View File
@@ -6,6 +6,7 @@ use app\common\model\PostCategory;
use app\common\model\PostMedia;
use app\common\model\Sku;
use app\common\model\User;
use app\common\model\UserStaff;
use app\common\validate\PostValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\Post;
@@ -109,10 +110,16 @@ class PostService
public function beforeServiceStore($data, Request $request)
{
$data['user_id'] = $request->user->uid;;
// $user = User::where('id', $data['user_id'])->first();
// if($user->is_release == 0){
// throw new BusinessException('无发布权限');
// }
$user = User::where('id', $data['user_id'])->first();
if($user->is_release == 0){
$staff = UserStaff::where('name',$user->name)->where('sn',$user->sn)->first();
if(!empty($staff)){
$user->is_release = 1;
$user->save();
}else{
throw new BusinessException('无发布权限');
}
}
$media = serialize($data['media']);
redis::set('PostMedia_'.$data['user_id'],$media,30);
unset($data['media']);