作者 lyh

gx

... ... @@ -22,28 +22,11 @@ class ServiceController extends BaseController
* @time :2023/6/25 14:31
*/
public function lists(ServiceLogic $serviceLogic){
$lists = $serviceLogic->serviceLists($this->map,$this->page,$this->row,$this->order);
$lists = $serviceLogic->serviceLists($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :企业服务通知详情
* @name :read
* @author :lyh
* @method :post
* @time :2023/6/25 11:50
*/
public function read(ServiceLogic $serviceLogic){
$this->request->validate([
'id' => 'required',
],[
'id.required' => '主键不能为空',
]);
$info = $serviceLogic->serviceRead();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :新增或编辑
* @name :save
* @author :lyh
... ... @@ -51,53 +34,11 @@ class ServiceController extends BaseController
* @time :2023/6/25 11:51
*/
public function save(ServiceLogic $serviceLogic){
if(isset($this->param['id'])){
$this->request->validate([
'id' => 'required',
],[
'id.required' => '主键不能为空',
]);
}
//参数验证
$this->verifyParam();
$serviceLogic->serviceSave();
$this->response('success');
}
/**
* @remark :编辑指定状态
* @name :status
* @author :lyh
* @method :post
* @time :2023/6/25 14:15
*/
public function status(ServiceLogic $serviceLogic){
$this->request->validate([
'id' => 'required',
],[
'id.required' => '主键不能为空',
]);
$serviceLogic->serviceStatus();
$this->response('success');
}
/**
* @param ServiceLogic $serviceLogic
* @remark :删除信息
* @name :del
* @author :lyh
* @method :post
* @time :2023/6/25 14:26
*/
public function del(ServiceLogic $serviceLogic){
$this->request->validate([
'id' => 'required|array',
],[
'id.required' => '主键不能为空',
]);
$serviceLogic->serviceDel();
$this->response('success');
}
/**
* @remark :参数验证
... ...
... ... @@ -22,49 +22,29 @@ class ServiceLogic extends BaseLogic
* @method :post
* @time :2023/6/25 14:32
*/
public function serviceLists($map,$page,$row,$order = 'id',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
public function serviceLists($map){
$map['type'] = 1;
$lists = $this->model->list($map);
foreach ($lists as $k => $v){
if(!empty($v['images'])){
$arr = explode(',',$v['images']);
switch ($v['key']){
case 'images':
$arr = explode(',',$v['values']);
foreach ($arr as $k1 => $v1){
$v['images_link'][$k1] = url('a/image/'.$v1);
}
}
if(!empty($v['android'])){
$v['android_link'] = url('a/image/'.$v['android']);
}
if(!empty($v['ios'])){
$v['ios_link'] = url('a/image/'.$v['ios']);
break;
case 'android':
$v['android_link'] = url('a/image/'.$v['values']);
break;
case 'ios':
$v['ios_link'] = url('a/image/'.$v['values']);
break;
}
$lists[$k] = $v;
}
return $this->success($lists);
}
/**
* @remark :获取详情
* @name :serviceRead
* @author :lyh
* @method :post
* @time :2023/6/25 13:44
*/
public function serviceRead(){
$info = $this->model->read(['id'=>$this->param['id']]);
if(!empty($info['images'])){
$arr = explode(',',$info['images']);
foreach ($arr as $k => $v){
$info['images_link'][$k] = url('a/image/'.$v);
}
}
if(!empty($info['android'])){
$info['android_link'] = url('a/image/'.$info['android']);
}
if(!empty($info['ios'])){
$info['ios_link'] = url('a/image/'.$info['ios']);
}
return $this->success($info);
}
/**
* @remark :新增或编辑
... ... @@ -74,49 +54,12 @@ class ServiceLogic extends BaseLogic
* @time :2023/6/25 13:45
*/
public function serviceSave(){
if(isset($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
$rs = $this->model->insert($this->param['data']);
if($rs === false){
$this->fail('error');
$this->fail('批量插入失败');
}
return $this->success();
}
/**
* @remark :指定状态始终为一条数据
* @name :serviceStatus
* @author :lyh
* @method :post
* @time :2023/6/25 14:09
*/
public function serviceStatus(){
DB::beginTransaction();
try {
$this->model->edit(['status'=>1],['id'=>['!=',$this->param['id']]]);
$this->model->edit(['status'=>0],['id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
return $this->success();
}
/**
* @remark :删除企业服务信息
* @name :serviceDel
* @author :lyh
* @method :post
* @time :2023/6/25 14:22
*/
public function serviceDel(){
$rs = $this->model->del(['id'=>['in',$this->param['id']]]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -3,12 +3,12 @@
namespace App\Models;
/**
* @remark :企业服务中心
* @remark :企业服务中心设置
* @name :Service
* @author :lyh
* @time :2023/6/25 11:53
*/
class Service extends Base
{
protected $table = 'gl_enterprise_service';
protected $table = 'gl_service_setting';
}
... ...
... ... @@ -117,10 +117,7 @@ Route::middleware(['aloginauth'])->group(function () {
//企业服务配置信息
Route::prefix('service')->group(function () {
Route::any('/', [Aside\ServiceController::class, 'lists'])->name('admin.service_lists');
Route::any('/read', [Aside\ServiceController::class, 'read'])->name('admin.service_read');
Route::any('/save', [Aside\ServiceController::class, 'save'])->name('admin.service_save');
Route::any('/status', [Aside\ServiceController::class, 'status'])->name('admin.service_status');
Route::any('/del', [Aside\ServiceController::class, 'del'])->name('admin.service_del');
});
//项目管理
... ...