Compare commits

...

2 Commits

@ -19,64 +19,64 @@ import java.util.List;
* Controller
* Created by macro on 2019/1/28.
*/
@Controller
@Api(tags = "HomeController")
@Tag(name = "HomeController", description = "首页内容管理")
@RequestMapping("/home")
public class HomeController {
@Controller// 声明HomeController类用于处理与首页相关的HTTP请求
@Api(tags = "HomeController")// 使用Swagger注解为API分组便于文档生成
@Tag(name = "HomeController", description = "首页内容管理") // Swagger的标签注解用于描述这个控制器的功能
@RequestMapping("/home")// 定义类级别的请求映射所有方法的URL都会以/home开头
public class HomeController {// 自动注入HomeService用于业务逻辑处理
@Autowired
private HomeService homeService;
@ApiOperation("首页内容信息展示")
@RequestMapping(value = "/content", method = RequestMethod.GET)
@ResponseBody
// 获取首页内容信息的API
@ApiOperation("首页内容信息展示")// Swagger注解描述方法的功能
@RequestMapping(value = "/content", method = RequestMethod.GET)// 定义GET请求的映射
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<HomeContentResult> content() {
HomeContentResult contentResult = homeService.content();
return CommonResult.success(contentResult);
HomeContentResult contentResult = homeService.content(); // 调用homeService的content方法获取首页内容结果
return CommonResult.success(contentResult);// 返回成功的响应结果,包含首页内容
}
@ApiOperation("分页获取推荐商品")
@RequestMapping(value = "/recommendProductList", method = RequestMethod.GET)
@ResponseBody
// 分页获取推荐商品的API
@ApiOperation("分页获取推荐商品")// Swagger注解描述方法的功能
@RequestMapping(value = "/recommendProductList", method = RequestMethod.GET)// 定义GET请求的映射
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<List<PmsProduct>> recommendProductList(@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<PmsProduct> productList = homeService.recommendProductList(pageSize, pageNum);
return CommonResult.success(productList);
List<PmsProduct> productList = homeService.recommendProductList(pageSize, pageNum);// 调用homeService的recommendProductList方法根据分页参数获取推荐商品列表
return CommonResult.success(productList);// 返回成功的响应结果,包含推荐商品列表
}
@ApiOperation("获取首页商品分类")
@RequestMapping(value = "/productCateList/{parentId}", method = RequestMethod.GET)
@ResponseBody
// 获取首页商品分类的API
@ApiOperation("获取首页商品分类")// 注解,描述方法的功能
@RequestMapping(value = "/productCateList/{parentId}", method = RequestMethod.GET)// 定义GET请求的映射包含一个路径变量parentId
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<List<PmsProductCategory>> getProductCateList(@PathVariable Long parentId) {
List<PmsProductCategory> productCategoryList = homeService.getProductCateList(parentId);
return CommonResult.success(productCategoryList);
List<PmsProductCategory> productCategoryList = homeService.getProductCateList(parentId);// 调用homeService的getProductCateList方法根据parentId获取商品分类列表
return CommonResult.success(productCategoryList);// 返回成功的响应结果,包含商品分类列表
}
@ApiOperation("根据分类分页获取专题")
@RequestMapping(value = "/subjectList", method = RequestMethod.GET)
@ResponseBody
// 根据分类分页获取专题的API
@ApiOperation("根据分类分页获取专题")// 注解,描述方法的功能
@RequestMapping(value = "/subjectList", method = RequestMethod.GET)// 定义GET请求的映射
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<List<CmsSubject>> getSubjectList(@RequestParam(required = false) Long cateId,
@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<CmsSubject> subjectList = homeService.getSubjectList(cateId,pageSize,pageNum);
return CommonResult.success(subjectList);
List<CmsSubject> subjectList = homeService.getSubjectList(cateId,pageSize,pageNum);// 调用homeService的getSubjectList方法根据分类ID和分页参数获取专题列表
return CommonResult.success(subjectList);// 返回成功的响应结果,包含专题列表
}
@ApiOperation("分页获取人气推荐商品")
// 分页获取人气推荐商品的API
@ApiOperation("分页获取人气推荐商品")// Swagger注解描述方法的功能
@RequestMapping(value = "/hotProductList", method = RequestMethod.GET)
@ResponseBody
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<List<PmsProduct>> hotProductList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {
List<PmsProduct> productList = homeService.hotProductList(pageNum,pageSize);
return CommonResult.success(productList);
List<PmsProduct> productList = homeService.hotProductList(pageNum,pageSize); // 调用homeService的hotProductList方法根据分页参数获取人气推荐商品列表
return CommonResult.success(productList);// 返回成功的响应结果,包含人气推荐商品列表
}
@ApiOperation("分页获取新品推荐商品")
@RequestMapping(value = "/newProductList", method = RequestMethod.GET)
@ResponseBody
// 分页获取新品推荐商品的API
@ApiOperation("分页获取新品推荐商品")//注解,描述方法的功能
@RequestMapping(value = "/newProductList", method = RequestMethod.GET)// 定义GET请求的映射
@ResponseBody// 返回的数据直接作为响应体返回
public CommonResult<List<PmsProduct>> newProductList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize) {
List<PmsProduct> productList = homeService.newProductList(pageNum,pageSize);
return CommonResult.success(productList);
List<PmsProduct> productList = homeService.newProductList(pageNum,pageSize);// 调用homeService的newProductList方法根据分页参数获取新品推荐商品列表
return CommonResult.success(productList);// 返回成功的响应结果,包含新品推荐商品列表
}
}

Loading…
Cancel
Save