package com.jeesharp.business.setting.controller;

import com.jeesharp.business.modules.setting.application.HomeBannerApplicationService;
import com.jeesharp.business.modules.setting.vo.MiniHomeBannerItemVO;
import com.jeesharp.framework.pojo.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 小程序轮播图接口：按展示位置返回启用中的 {@code cms_home_banner} 列表（免登录）。
 *
 * @author jeesharp
 * @since 2026-05-13
 */
@RestController
@RequestMapping("${jeesharp.web.mobilePath:/mobile}/setting/homeBanner")
@Tag(name = "小程序-轮播图")
@AllArgsConstructor
public class HomeBannerMobileController {

    private final HomeBannerApplicationService homeBannerApplicationService;

    @Operation(summary = "按位置查询轮播列表", description = "position：HOME-首页，MALL-商城，FOOD-美食餐饮；缺省为 HOME")
    @GetMapping("/list")
    public AjaxResult<List<MiniHomeBannerItemVO>> listByPosition(
        @Parameter(description = "展示位置：HOME / MALL / FOOD，缺省首页")
        @RequestParam(value = "position", required = false) String position) {
        return AjaxResult.okData(homeBannerApplicationService.listMiniBannersByPosition(position));
    }
}
