PtCpController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace pt\controllers;
  3. use biz\cp\classes\PtCpClass;
  4. use common\components\stringUtil;
  5. use common\components\util;
  6. use Yii;
  7. class PtCpController extends BaseController
  8. {
  9. public function actionList()
  10. {
  11. $get = Yii::$app->request->get();
  12. $classId = $get['classId'] ?? 0;
  13. $search = $get['search'] ?? '';
  14. $classStyle = $get['classStyle'] ?? -1;
  15. $where = [];
  16. if ($classStyle == 0) {
  17. $where['classId'] = 0;
  18. } else {
  19. if (!empty($classId) && is_numeric($classId)) {
  20. $where['classId'] = $classId;
  21. }
  22. }
  23. if (!empty($search)) {
  24. if (stringUtil::isLetter($search)) {
  25. $where['py'] = ['like', $search];
  26. } else {
  27. $where['name'] = ['like', $search];
  28. }
  29. }
  30. $respond = PtCpClass::getCpList($where);
  31. util::success($respond);
  32. }
  33. //添加产品 ssh 20240119
  34. public function actionAddCp()
  35. {
  36. $post = Yii::$app->request->post();
  37. PtCpClass::addCp($post);
  38. util::complete('添加成功');
  39. }
  40. //修改产品 ssh 20240119
  41. public function actionUpdateCp()
  42. {
  43. $post = Yii::$app->request->post();
  44. PtCpClass::updateCp($post);
  45. util::complete('修改成功');
  46. }
  47. }