CaseManageController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace frontend\modules\api\controllers;
  3. use common\services\CaseService;
  4. use frontend\modules\api\components\BaseAdminController;
  5. use Yii;
  6. use yii\web\Response;
  7. class CaseManageController extends BaseAdminController
  8. {
  9. /**
  10. * 查询案例是否重名
  11. * @return Response
  12. */
  13. public function actionCheck()
  14. {
  15. $post = Yii::$app->request->post();
  16. if (isset($post['id'])) {
  17. $otherInfo = CaseService::getCaseQuery()
  18. ->andWhere(["and", ['title' => $post['title']], ['<>', 'id', $post['id']]])
  19. ->one();
  20. if ($otherInfo) {
  21. return $this->asJson([], 1, "案件名称已存在!"); //通知前端
  22. }
  23. return $this->asJson([]);
  24. }
  25. if ($post['category'] == 'title') {
  26. $info = CaseService::getCaseQuery()->andWhere(['title' => $post['title']])
  27. ->one();
  28. if ($info) {
  29. return $this->asJson([], 1, "案件名称已存在!"); //通知前端
  30. }
  31. }
  32. return $this->asJson([]);
  33. }
  34. }