Update IndexImgController.java

cyj
pbvfus8to 8 months ago
parent ce684669e0
commit 9f4ca94cbb

@ -24,23 +24,36 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
*
*
* @author lanhai
*/
@RestController
// 使用 @Tag 注解为该控制器类添加标签说明,用于在 API 文档(如 Swagger 生成的文档)中对该类下的接口进行分类展示,这里表明是“首页轮播图接口”相关的一组接口。
@Tag(name = "首页轮播图接口")
public class IndexImgController {
// 注入IndexImgService用于与首页轮播图相关的业务逻辑处理例如从数据库中查询轮播图列表等操作。
@Autowired
private IndexImgService indexImgService;
/**
*
*
* @GetMapping HTTP GET /indexImgs访
* @Operation API summarydescription便使
*
* @return ServerResponseEntityIndexImgDto
*/
@GetMapping("/indexImgs")
@Operation(summary = "首页轮播图" , description = "获取首页轮播图列表信息")
@Operation(summary = "首页轮播图", description = "获取首页轮播图列表信息")
public ServerResponseEntity<List<IndexImgDto>> indexImgs() {
// 调用IndexImgService的listIndexImg方法从数据库或其他数据源获取首页轮播图的原始数据列表以IndexImg对象列表形式返回
List<IndexImg> indexImgList = indexImgService.listIndexImg();
// 使用hutool的BeanUtil工具类将IndexImg对象列表转换为IndexImgDto对象列表IndexImgDto可能是用于对外展示的、经过筛选或格式调整后的视图对象
// 这样可以避免直接将内部的业务实体对象暴露给客户端,更好地控制数据的展示格式和安全性。
List<IndexImgDto> indexImgDtos = BeanUtil.copyToList(indexImgList, IndexImgDto.class);
// 将转换后的IndexImgDto列表封装在表示成功的ServerResponseEntity对象中返回给客户端遵循统一的接口响应格式规范。
return ServerResponseEntity.success(indexImgDtos);
}
}
}
Loading…
Cancel
Save