|
|
@ -7,24 +7,55 @@ use app\validate\ResourceValidate; |
|
|
use think\facade\Db; |
|
|
use think\facade\Db; |
|
|
use think\facade\Lang; |
|
|
use think\facade\Lang; |
|
|
use think\exception\ValidateException; |
|
|
use think\exception\ValidateException; |
|
|
|
|
|
use think\Request; |
|
|
|
|
|
|
|
|
class ResourceController |
|
|
class ResourceController |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 全部资源 列表 |
|
|
* 全部资源 列表 |
|
|
*/ |
|
|
*/ |
|
|
public function index() |
|
|
|
|
|
|
|
|
public function index(Request $request) |
|
|
{ |
|
|
{ |
|
|
$resource_list = Resource::where('type', 1)->select(); |
|
|
|
|
|
|
|
|
$param = $request->param(); |
|
|
|
|
|
$resource_list = Resource::field('id, name,user_id, resource_type, audit_status, del_audit_status, copyright_type, copyright_status, effective_start_time, effective_end_time,create_time') |
|
|
|
|
|
->when(isset($param['resource_type']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('resource_type', $param['resource_type']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['copyright_type']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('copyright_type', $param['copyright_type']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['copyright_status']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('copyright_status', $param['copyright_status']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['create_time']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('create_time', '>', $param['create_time']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['audit_status']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('audit_status', $param['audit_status']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['del_audit_status']), function ($query) use ($param) { |
|
|
|
|
|
$query->where('del_audit_status', $param['del_audit_status']); |
|
|
|
|
|
}) |
|
|
|
|
|
->when(isset($param['order_field']) && isset($param['order_sort']), function ($query) use ($param) { |
|
|
|
|
|
$query->order($param['order_field'], $param['order_sort']); |
|
|
|
|
|
}) |
|
|
|
|
|
->with('user') |
|
|
|
|
|
->where('type', 1) |
|
|
|
|
|
->select(); |
|
|
|
|
|
|
|
|
// $userService = app('userService');
|
|
|
// $userService = app('userService');
|
|
|
// return $userService->doSomething();
|
|
|
// return $userService->doSomething();
|
|
|
return jsonReturn(0, Lang::get('成功'), $resource_list); |
|
|
return jsonReturn(0, Lang::get('成功'), $resource_list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function save(Resource $resource) |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 全部资源 新增 |
|
|
|
|
|
*/ |
|
|
|
|
|
public function save(Resource $resource, Request $request) |
|
|
{ |
|
|
{ |
|
|
$param = input('post.'); |
|
|
|
|
|
|
|
|
$param = $request->param(); |
|
|
// 数据验证
|
|
|
// 数据验证
|
|
|
try { |
|
|
try { |
|
|
switch ($param['copyright_type']) { |
|
|
switch ($param['copyright_type']) { |
|
|
@ -52,4 +83,15 @@ class ResourceController |
|
|
} |
|
|
} |
|
|
return json($res); |
|
|
return json($res); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 资源 详情 |
|
|
|
|
|
*/ |
|
|
|
|
|
public function detail(Resource $resource, $id) |
|
|
|
|
|
{ |
|
|
|
|
|
$resource_detail = $resource::with('user') |
|
|
|
|
|
->with('files') |
|
|
|
|
|
->find($id); |
|
|
|
|
|
return jsonReturn(0, Lang::get('成功'), $resource_detail); |
|
|
|
|
|
} |
|
|
} |
|
|
} |