package com.xiaoniu.system.platformsettings.storetype.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.common.core.vo.LabelAndValueVO;
import com.xiaoniu.system.platformsettings.storetype.dto.AddStoreTypeDTO;
import com.xiaoniu.system.platformsettings.storetype.dto.EditStoreTypeDTO;
import com.xiaoniu.system.platformsettings.storetype.dto.StoreTypeListQueryDTO;
import com.xiaoniu.system.platformsettings.storetype.service.ITbStoreTypeService;
import com.xiaoniu.system.platformsettings.storetype.vo.StoreTypeDetailsVO;
import com.xiaoniu.system.platformsettings.storetype.vo.StoreTypeListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 门店类型信息表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-10-11 02:13:07
 */
@Tag(name = "门店类型信息管理")
@RestController
@RequestMapping("/storeType")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbStoreTypeController {

    private final ITbStoreTypeService tbStoreTypeService;

    @Operation(summary = "门店类型信息列表")
    @PostMapping("/list")
    public Result<List<StoreTypeListVO>> list(@RequestBody StoreTypeListQueryDTO dto) {
        return Result.success("查询成功", tbStoreTypeService.storeTypeList(dto));
    }

    @Operation(summary = "新增门店类型信息")
    @PostMapping("/add")
    public Result<String> add(@RequestBody @Validated AddStoreTypeDTO dto) {
        tbStoreTypeService.addStoreType(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "修改门店类型信息")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody @Validated EditStoreTypeDTO dto) {
        tbStoreTypeService.editStoreType(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "门店类型信息详情")
    @GetMapping("/details")
    public Result<StoreTypeDetailsVO> details(@RequestParam Long id) {
        return Result.success("查询成功", tbStoreTypeService.details(id));
    }

    @Operation(summary = "删除门店类型信息")
    @GetMapping("/del")
    public Result<String> delStoreType(@RequestParam Long id) {
        tbStoreTypeService.delStoreType(id);
        return Result.success("操作成功");
    }

    @Operation(summary = "获取商品类型(下拉选)")
    @GetMapping("/getStoreType")
    public Result<List<LabelAndValueVO>> getStoreType(@RequestParam(required = false) Long id) {
        return Result.success("操作成功", tbStoreTypeService.getStoreTyp(id));
    }

    @Operation(summary = "获取二级商品类型(下拉选)")
    @GetMapping("/getStoreType2")
    public Result<List<LabelAndValueVO>> getStoreType2(@RequestParam(required = false) Long id) {
        return Result.success("操作成功", tbStoreTypeService.getStoreType2(id));
    }
}
