|
|
|
@ -0,0 +1,53 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* https://www.mall4j.com/
|
|
|
|
|
*
|
|
|
|
|
* 未经允许,不可做商业用途!
|
|
|
|
|
*
|
|
|
|
|
* 版权所有,侵权必究!
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package com.yami.shop.api.controller; // 定义类所在的包
|
|
|
|
|
|
|
|
|
|
import java.util.List; // 引入Java的List接口
|
|
|
|
|
|
|
|
|
|
import com.yami.shop.service.AreaService; // 引入区域服务类
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; // 引入Spring的@Autowired注解
|
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity; // 引入服务器响应实体类
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; // 引入Spring的@GetMapping注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; // 引入Spring的@RequestMapping注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; // 引入Spring的@RestController注解
|
|
|
|
|
|
|
|
|
|
import com.yami.shop.bean.model.Area; // 引入区域模型
|
|
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; // 引入Swagger的Tag注解
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter; // 引入Swagger的Parameter注解
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation; // 引入Swagger的Operation注解
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* AreaController类,负责处理省市区信息的获取请求。
|
|
|
|
|
* 该类包含一个根据父级ID获取省市区信息的方法。
|
|
|
|
|
* @作者 lgh on 2018/10/26.
|
|
|
|
|
*/
|
|
|
|
|
@RestController // 标注这是一个控制器类,并且其返回结果直接写入HTTP响应体中,而不是视图名称
|
|
|
|
|
@RequestMapping("/p/area") // 定义请求路径的根地址为/p/area
|
|
|
|
|
@Tag(name = "省市区接口") // 给API文档添加标签,描述这个控制器的功能
|
|
|
|
|
public class AreaController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AreaService areaService; // 自动注入区域服务类
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据省市区的父级ID获取地址信息
|
|
|
|
|
* @param pid 省市区的父级ID(pid为0获取所有省份)
|
|
|
|
|
* @return 服务器响应实体,包含查询到的省市区信息
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/listByPid")
|
|
|
|
|
@Operation(summary = "获取省市区信息" , description = "根据省市区的pid获取地址信息")
|
|
|
|
|
@Parameter(name = "pid", description = "省市区的pid(pid为0获取所有省份)" , required = true)
|
|
|
|
|
public ServerResponseEntity<List<Area>> listByPid(Long pid) {
|
|
|
|
|
List<Area> list = areaService.listByPid(pid);
|
|
|
|
|
return ServerResponseEntity.success(list);
|
|
|
|
|
}
|
|
|
|
|
}
|