123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace api\controllers;
- use app\common\controllers\AController;
- use app\modules\admin\models\Attachment;
- use app\modules\admin\models\AttachmentTrash;
- use app\modules\doc\models\Doc;
- use app\modules\doc\models\DocData;
- use app\modules\doc\models\DocPackfile;
- use app\modules\doc\models\DocReal;
- use app\modules\doc\models\DocRealData;
- use Yii;
- class WriterController extends AController
- {
- public function init()
- {
- parent::init();
- }
- //删除文档草稿箱
- public function actionDeldraftdoc()
- {
- $ids = Yii::$app->request->get('ids');
- $ids = !empty($ids)?explode(",",$ids):[$this->get['id']];
- if(!empty($ids)){
- foreach($ids as $id){
- $model = Doc::findOne($id);
- $modelData = DocData::findOne($id);
- if($model&&$modelData)
- {
- //判断有无操作权限
- $checkResult = $this->checkRights($this->user_id,$model);
- if($checkResult['error']==1)continue;
- $imgcode = string2array($modelData->imgcode);
- $h5code = string2array($modelData->h5code);
- $file = $modelData->file;
- $path = getFileWorkPath($file);
- if($model->delete()&&$modelData->delete())
- {
- Attachment::releaseAttachmentByTable($id,$model->shortTableName(),'thumb');
- Attachment::releaseAttachmentByTable($id,$modelData->shortTableName(),'file');
- $trash = new AttachmentTrash();
- $trash->file_path = $path;
- $trash->is_oss = Yii::$app->params['oss']['OPEN_OSS'];
- $trash->create_time = TIMESTAMP;
- $trash->save();
- if(is_array($imgcode))foreach($imgcode as $img)
- {
- $trash = new AttachmentTrash();
- $trash->file_path = $img;
- $trash->is_oss = Yii::$app->params['oss']['OPEN_OSS'];
- $trash->create_time = TIMESTAMP;
- $trash->save();
- }
- if(is_array($h5code))foreach($h5code as $h5)
- {
- $trash = new AttachmentTrash();
- $trash->file_path = $h5;
- $trash->is_oss = Yii::$app->params['oss']['OPEN_OSS'];
- $trash->create_time = TIMESTAMP;
- $trash->save();
- }
- $packFileList = DocPackfile::find()->where("doc_id=$id")->all();
- if(is_array($packFileList))foreach($packFileList as $packFile)
- {
- $trash = new AttachmentTrash();
- $trash->file_path = $packFile->path;
- $trash->is_oss = Yii::$app->params['oss']['OPEN_OSS'];
- $trash->create_time = TIMESTAMP;
- $trash->save();
- }
- }
- }
- }
- return [
- 'error' => 0,
- 'msg' => '操作成功',
- 'data' => [],
- 'code'=>200
- ];
- }
- else
- {
- return [
- 'error' => 1,
- 'msg' => '操作失败',
- 'data' => [],
- 'code'=>200
- ];
- }
- }
- //删除文档
- public function actionDeldoc()
- {
- $ids = Yii::$app->request->get('ids');
- $ids = !empty($ids)?explode(",",$ids):[$this->get['id']];
- if(!empty($ids)){
- foreach($ids as $id){
- $model = DocReal::findOne($id);
- $modelData = DocRealData::findOne($id);
- if($model&&$modelData)
- {
- //判断有无操作权限
- $checkResult = $this->checkRights($this->user_id,$model);
- if($checkResult['error']==1)continue;
- $model->is_delete = 1;
- $model->save();
- }
- }
- return [
- 'error' => 0,
- 'msg' => '操作成功',
- 'data' => [],
- 'code'=>200
- ];
- }
- else
- {
- return [
- 'error' => 1,
- 'msg' => '操作失败',
- 'data' => [],
- 'code'=>200
- ];
- }
- }
- }
|