package com.ruoyi.api.controller.info;

import com.ruoyi.api.controller.common.AbstractApiController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.FilePathSplicingType;
import com.ruoyi.common.filepathsplicing.FilePathSplicing;
import com.ruoyi.info.service.domain.bo.ServiceProductBo;
import com.ruoyi.info.service.domain.vo.ServiceProductVo;
import com.ruoyi.info.service.enums.ServiceUnit;
import com.ruoyi.info.service.service.IServiceProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 服务Controller
 *
 * @author ruoyi
 * @date 2025-09-20
 */
@Validated
@Api(value = "服务控制器", tags = {"服务管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/service/serviceProduct")
public class ApiServiceProductController extends AbstractApiController {

    private final IServiceProductService iServiceProductService;

    /**
     * 查询服务列表
     */
    @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
    @ApiOperation("查询服务列表")
    @GetMapping("/list")
    public R<List<ServiceProductVo>> list(@Validated(QueryGroup.class) ServiceProductBo bo) {
        bo.setStatus(true);
        return R.ok(iServiceProductService.queryList(bo));
    }

    @ApiOperation("枚举")
    @GetMapping("/enum")
    public R<Map<String,  Object>> getEnum() {
        Map<String, Object> map = new HashMap<>();
        map.put("serviceUnit", ServiceUnit.toJsonArray());
        return R.ok(map);
    }
}
