发布权限
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class UserStaff extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'user_staff';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'name', 'sn'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -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']);
|
||||
|
||||
@@ -180,7 +180,7 @@ class UserService
|
||||
{
|
||||
// 对密码进行哈希处理
|
||||
$user = User::find($uid);
|
||||
$keysToKeep = ['name', 'nickname', 'avatar'];
|
||||
$keysToKeep = ['name', 'nickname', 'avatar', 'sn'];
|
||||
|
||||
$data = array_intersect_key($data, array_flip($keysToKeep));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user