是否允许发布帖子权限
This commit is contained in:
@@ -104,7 +104,7 @@ class UserService
|
|||||||
$config['where']['corp_id'] = $p['corp_id'];
|
$config['where']['corp_id'] = $p['corp_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['fields'] = ['id','sn', 'name', 'email', 'mobile', 'avatar', 'nickname', 'is_admin', 'status', 'created_at'];
|
$config['fields'] = ['id','sn', 'name', 'email', 'mobile', 'avatar', 'nickname', 'is_release', 'status', 'created_at'];
|
||||||
|
|
||||||
$config['with']['roles'][] = 'id';
|
$config['with']['roles'][] = 'id';
|
||||||
$config['with']['roles'][] = 'name';
|
$config['with']['roles'][] = 'name';
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class User extends Model
|
|||||||
/**
|
/**
|
||||||
* 允许自动填充模型字段
|
* 允许自动填充模型字段
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['id', 'password', 'name', 'email', 'mobile', 'avatar', 'sn', 'status', 'is_admin', 'nickname', 'openid', 'unionid', 'created_at', 'updated_at'];
|
protected $fillable = ['id', 'password', 'name', 'email', 'mobile', 'avatar', 'sn', 'status', 'is_release', 'nickname', 'openid', 'unionid', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不允许自动填充模型字段
|
* 不允许自动填充模型字段
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
namespace app\common\service;
|
namespace app\common\service;
|
||||||
|
|
||||||
use app\common\model\PostMedia;
|
use app\common\model\PostMedia;
|
||||||
|
use app\common\model\User;
|
||||||
use app\common\validate\PostValidate;
|
use app\common\validate\PostValidate;
|
||||||
use app\common\traits\crud\CrudServiceTrait;
|
use app\common\traits\crud\CrudServiceTrait;
|
||||||
use app\common\model\Post;
|
use app\common\model\Post;
|
||||||
|
use support\exception\BusinessException;
|
||||||
use support\Redis;
|
use support\Redis;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
|
||||||
@@ -92,6 +94,10 @@ class PostService
|
|||||||
public function beforeServiceStore($data, Request $request)
|
public function beforeServiceStore($data, Request $request)
|
||||||
{
|
{
|
||||||
$data['user_id'] = $request->user->uid;;
|
$data['user_id'] = $request->user->uid;;
|
||||||
|
$user = User::where('id', $data['user_id'])->first();
|
||||||
|
if($user->is_release == 0){
|
||||||
|
throw new BusinessException('无发布权限');
|
||||||
|
}
|
||||||
$media = serialize($data['media']);
|
$media = serialize($data['media']);
|
||||||
redis::set('PostMedia_'.$data['user_id'],$media,30);
|
redis::set('PostMedia_'.$data['user_id'],$media,30);
|
||||||
unset($data['media']);
|
unset($data['media']);
|
||||||
|
|||||||
Reference in New Issue
Block a user