Phone: 158 4018 8888 Email: 407593529@qq.com

命名规范

2026-02-06 15:59:17 3

命名规范

后台接口命名

查询分页:pages

/**
* 获取商品品牌分页列表
* @description 查看列表-分页
* @return \think\Response
*/
public function pages(){
    $data = $this->request->params([
         [ "brand_name","" ],
         [ 'order', '' ],
         [ 'sort', '' ]
    ]);
    return success((new BrandService())->getPage($data));
}

查询列表:lists

/**
 * 获取商品品牌列表
 * @description 查看商品列表-全部
 * @return \think\Response
 */
public function lists(){
    $data = $this->request->params([
        ["brand_name",""]
    ]);
    return success((new BrandService())->getList($data));
}

查询信息:info

/**
 * 商品品牌详情
 * @description 查看详情
 * @param int $id
 * @return \think\Response
 */
public function info(int $id){
    return success((new BrandService())->getInfo($id));
}

添加:add

/**
 * 添加商品品牌
 * @description 添加商品品牌
 * @return \think\Response
 */
public function add(){
    $data = $this->request->params([
         ["brand_name",""],
         ["logo",""],
         ["desc",""],
         ["sort",0],
         ["color_json",""],
    ]);
    $this->validate($data, 'addon\shop\app\validate\goods\Brand.add');
    $id = (new BrandService())->add($data);
    return success('ADD_SUCCESS', ['id' => $id]);
}

编辑:edit

/**
 * 商品品牌编辑
 * @description 编辑商品品牌
 * @param $id  商品品牌id
 * @return \think\Response
 */
public function edit($id){
    $data = $this->request->params([
         ["brand_name",""],
         ["logo",""],
         ["desc",""],
         ["sort",0],
         ["color_json",""],
    ]);
    $this->validate($data, 'addon\shop\app\validate\goods\Brand.edit');
    (new BrandService())->edit($id, $data);
    return success('EDIT_SUCCESS');
}

删除:del

/**
 * 商品品牌删除
 * @description 删除商品品牌
 * @param $id  商品品牌id
 * @return \think\Response
 */
public function del(int $id){
    (new BrandService())->del($id);
    return success('DELETE_SUCCESS');
}

修改某个字段:modify+字段名称

/**
 * 修改排序
 * @description 编辑品牌排序
 * @return \think\Response
 */
public function modifySort()
{
    $data = $this->request->params([
        [ 'brand_id', '' ],
        [ 'sort', '' ],
    ]);
    ( new BrandService() )->modifySort($data);
    return success('SUCCESS');
}

选择样式

选择布局
选择颜色
选择背景
选择背景