PtItemController.php 2.4 KB

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