|
|
|
@ -0,0 +1,91 @@
|
|
|
|
|
// 定义包名,用于组织代码结构
|
|
|
|
|
package com.macro.mall.portal.controller;
|
|
|
|
|
|
|
|
|
|
// 导入通用分页类,用于封装分页数据
|
|
|
|
|
import com.macro.mall.common.api.CommonPage;
|
|
|
|
|
// 导入通用结果类,用于统一返回操作结果
|
|
|
|
|
import com.macro.mall.common.api.CommonResult;
|
|
|
|
|
// 导入品牌实体类,用于封装品牌数据
|
|
|
|
|
import com.macro.mall.model.PmsBrand;
|
|
|
|
|
// 导入产品实体类,用于封装产品数据
|
|
|
|
|
import com.macro.mall.model.PmsProduct;
|
|
|
|
|
// 导入品牌服务接口,用于访问品牌数据
|
|
|
|
|
import com.macro.mall.portal.service.PmsPortalBrandService;
|
|
|
|
|
// 导入Swagger注解,用于生成API文档
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
// 导入Spring框架的注解,用于声明组件和自动注入
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
// 导入Java的List接口,用于操作列表数据
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 首页品牌推荐管理Controller
|
|
|
|
|
* 该类负责处理首页品牌推荐相关的操作
|
|
|
|
|
* Created by macro on 2020/5/15.
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@Api(tags = "PmsPortalBrandController")
|
|
|
|
|
@Tag(name = "PmsPortalBrandController", description = "前台品牌管理")
|
|
|
|
|
@RequestMapping("/brand")
|
|
|
|
|
public class PmsPortalBrandController {
|
|
|
|
|
|
|
|
|
|
// 使用@Autowired注解自动注入PmsPortalBrandService实例
|
|
|
|
|
@Autowired
|
|
|
|
|
private PmsPortalBrandService portalBrandService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页获取推荐品牌
|
|
|
|
|
* @param pageSize 每页显示的品牌数量,默认为6
|
|
|
|
|
* @param pageNum 当前页码,默认为1
|
|
|
|
|
* @return 通用结果对象,包含推荐品牌列表数据
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("分页获取推荐品牌")
|
|
|
|
|
@RequestMapping(value = "/recommendList", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult<List<PmsBrand>> recommendList(@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize,
|
|
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
|
|
|
|
// 调用portalBrandService的recommendList方法分页获取推荐品牌
|
|
|
|
|
List<PmsBrand> brandList = portalBrandService.recommendList(pageNum, pageSize);
|
|
|
|
|
// 返回包含推荐品牌列表的通用结果对象
|
|
|
|
|
return CommonResult.success(brandList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取品牌详情
|
|
|
|
|
* @param brandId 品牌ID
|
|
|
|
|
* @return 通用结果对象,包含品牌详情数据
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("获取品牌详情")
|
|
|
|
|
@RequestMapping(value = "/detail/{brandId}", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult<PmsBrand> detail(@PathVariable Long brandId) {
|
|
|
|
|
// 调用portalBrandService的detail方法获取品牌详情
|
|
|
|
|
PmsBrand brand = portalBrandService.detail(brandId);
|
|
|
|
|
// 返回包含品牌详情的通用结果对象
|
|
|
|
|
return CommonResult.success(brand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页获取品牌相关商品
|
|
|
|
|
* @param brandId 品牌ID
|
|
|
|
|
* @param pageNum 当前页码,默认为1
|
|
|
|
|
* @param pageSize 每页显示的商品数量,默认为6
|
|
|
|
|
* @return 通用结果对象,包含品牌相关商品的分页数据
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("分页获取品牌相关商品")
|
|
|
|
|
@RequestMapping(value = "/productList", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult<CommonPage<PmsProduct>> productList(@RequestParam Long brandId,
|
|
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
|
|
@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {
|
|
|
|
|
// 调用portalBrandService的productList方法分页获取品牌相关商品
|
|
|
|
|
CommonPage<PmsProduct> result = portalBrandService.productList(brandId, pageNum, pageSize);
|
|
|
|
|
// 返回包含品牌相关商品分页数据的通用结果对象
|
|
|
|
|
return CommonResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
}
|