💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Niushop开源商城后台功能 --- 后台功能开发基础功能可以查看thinkphp5手册:[https://ihavenolimitations.xyz/manual/thinkphp5/118003](https://ihavenolimitations.xyz/manual/thinkphp5/118003) 下面说一下关于niushop标准化的书写方法: ### 1. **数据获取** niushop获取数据统一采用request\\(\\)->get\\(\\),或者request->post\\(\\)方法,具体的使用方法可以参看thinkphp,例如: ```php $brand_name = request()->post('brand_name', ''); $brand_initial = request()->post('brand_initial', ''); $describe = request()->post('describe', ''); $brand_pic = request()->post('brand_pic', ''); $brand_recommend = request()->post('brand_recommend', ''); $category_name = request()->post('category_name', ''); $category_id_1 = request()->post('category_id_1', 0); $category_id_2 = request()->post('category_id_2', 0); $category_id_3 = request()->post('category_id_3', 0); $brand_ads = request()->post('brand_ads', ''); ``` ### 2. **数据返回:** niushop针对数据返回统一数据结构,统一采用ajaxReturn方法,例如: ```php /** * 添加商品品牌 */ public function addGoodsBrand() { if (request()->isAjax()) { $goodsbrand = new GoodsBrand(); $brand_name = request()->post('brand_name', ''); $brand_initial = request()->post('brand_initial', ''); $describe = request()->post('describe', ''); $brand_pic = request()->post('brand_pic', ''); $brand_recommend = request()->post('brand_recommend', ''); $category_name = request()->post('category_name', ''); $category_id_1 = request()->post('category_id_1', 0); $category_id_2 = request()->post('category_id_2', 0); $category_id_3 = request()->post('category_id_3', 0); $brand_ads = request()->post('brand_ads', ''); $sort = 0; $params = [ "shop_id" => $this->instance_id, "brand_name" => $brand_name, "brand_initial" => $brand_initial, "describe" => $describe, "brand_pic" => $brand_pic, "brand_recommend" => $brand_recommend, "category_name" => $category_name, "category_id_1" => $category_id_1, "category_id_2" => $category_id_2, "category_id_3" => $category_id_3, "sort" => $sort, "brand_ads" => $brand_ads, ]; $res = $goodsbrand->editGoodsBrand($params); return AjaxReturn($res); } else { $goodscategory = new GoodsCategory(); $list = $goodscategory->getGoodsCategoryListByParentId(0); $this->assign('goods_category_list', $list); return view($this->style . "Goods/addGoodsBrand"); } } ``` ### 3. 业务逻辑 niushop针对业务逻辑的处理是在service层中,service路径:data/service