where(['del'=>0])->column('name','id'); $result = $this->dataLists(new GoodsLists()); foreach($result['lists'] as $item){ $item['cat_name'] = self::getCateName($goods_category_list, $item); } return $result; } public static function getCateName($cates, $item) { if(isset($cates[$item['third_category_id']])) { return $cates[$item['third_category_id']]; } if(isset($cates[$item['second_category_id']])) { return $cates[$item['second_category_id']]; } if(isset($cates[$item['first_category_id']])) { return $cates[$item['first_category_id']]; } return ''; } /** * @notes 添加 * @return \think\response\Json * @author likeadmin * @date 2025/05/08 15:34 */ public function add() { $params = (new GoodsValidate())->post()->goCheck('add'); $result = GoodsLogic::add($params); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(GoodsLogic::getError()); } /** * @notes 编辑 * @return \think\response\Json * @author likeadmin * @date 2025/05/08 15:34 */ public function edit() { $params = (new GoodsValidate())->post()->goCheck('edit'); $result = GoodsLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(GoodsLogic::getError()); } /** * @notes 删除 * @return \think\response\Json * @author likeadmin * @date 2025/05/08 15:34 */ public function delete() { $params = (new GoodsValidate())->post()->goCheck('delete'); GoodsLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取详情 * @return \think\response\Json * @author likeadmin * @date 2025/05/08 15:34 */ public function detail() { $params = (new GoodsValidate())->goCheck('detail'); $result = GoodsLogic::detail($params); return $this->data($result); } }