PtItemController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\item\classes\PtItemClass;
  4. use common\components\imgUtil;
  5. use common\components\stringUtil;
  6. use common\components\util;
  7. use Yii;
  8. class PtItemController extends BaseController
  9. {
  10. //官方认证修改 ssh 20231125
  11. public function actionChangeAuth()
  12. {
  13. $id = Yii::$app->request->get('id', 0);
  14. $item = PtItemClass::getById($id, true);
  15. if (empty($item)) {
  16. util::fail('没有找到花材');
  17. }
  18. if (getenv('YII_ENV') == 'production') {
  19. if ($this->adminId != 4) {
  20. util::fail('无法操作');
  21. }
  22. } else {
  23. if ($this->adminId != 919) {
  24. util::fail('无法操作');
  25. }
  26. }
  27. $newAuth = $item->auth == 0 ? 1 : 0;
  28. $item->auth = $newAuth;
  29. $item->save();
  30. util::complete('修改成功');
  31. }
  32. //获取平台里的花材列表
  33. public function actionList()
  34. {
  35. $name = Yii::$app->request->get('name', '');
  36. $search = Yii::$app->request->get('search', '');
  37. if (empty($name)) {
  38. $name = $search;
  39. }
  40. $where = [];
  41. if (!empty($name)) {
  42. if (stringUtil::isLetter($name)) {
  43. $where['py'] = ['like', $name];
  44. } else {
  45. $where['name'] = ['like', $name];
  46. }
  47. }
  48. $classId = Yii::$app->request->get('classId', 0);
  49. if (!empty($classId)) {
  50. $where['classId'] = $classId;
  51. }
  52. //没有删除的花材
  53. $where['delStatus'] = 0;
  54. $list = PtItemClass::getItemList($where, true, $this->mainId);
  55. util::success($list);
  56. }
  57. //获取平台花材详情 ssh 20210826
  58. public function actionDetail()
  59. {
  60. $id = Yii::$app->request->get('id', 0);
  61. $info = PtItemClass::getById($id);
  62. if (empty($info)) {
  63. util::fail('没有找到花材');
  64. }
  65. $shortCover = $info['cover'] ?? '';
  66. $info['shortCover'] = $shortCover;
  67. $info['cover'] = imgUtil::groupImg($shortCover);
  68. $info['bigCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  69. $info['smallCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  70. util::success($info);
  71. }
  72. }