package top.continew.admin.controller.business;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.apache.poi.ss.formula.functions.Na;
import org.springframework.web.bind.annotation.*;
import top.continew.admin.business.model.entity.CoinSpeedUpgradesRules;
import top.continew.admin.business.model.query.CoinSpeedUpgradesRulesQuery;
import top.continew.admin.business.model.query.TaskInfoQuery;
import top.continew.admin.business.model.req.CoinSpeedUpgradesRulesReq;
import top.continew.admin.business.service.ICoinSpeedUpgradesRulesService;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.model.resp.BasePageResp;

import java.util.List;

@RestController
@RequestMapping("/coin/speed/upgrades")
@AllArgsConstructor
@Tag(name = "推进器API")
public class CoinSpeedUpgradesRulesController {
    private final ICoinSpeedUpgradesRulesService rulesService;

    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    BasePageResp<CoinSpeedUpgradesRules> page(CoinSpeedUpgradesRulesQuery query) {
        return rulesService.getCoinSpeedUpgradesRulesPage(query);
    }


    @Operation(summary = "查询详情", description = "查询详情")
    @GetMapping("/{ids}")
    @Parameter(
            name = "ids",
            description = "ids",
            example = "1,2,3,4",
            in = ParameterIn.PATH
    )
    List<CoinSpeedUpgradesRules> getCoinSpeedUpgradesRulesByIds(@PathVariable("ids") List<Long> ids) {
        return rulesService.listByIds(ids);
    }


    @Operation(summary = "修改数据", description = "修改数据")
    @Parameter(
            name = "id",
            description = "ID",
            example = "1",
            in = ParameterIn.PATH
    )
    @PutMapping({"/{id}"})
    //@Validated({CrudValidationGroup.Update.class})
    public void update(@RequestBody CoinSpeedUpgradesRulesReq req, @PathVariable("id") Long id) {
        this.rulesService.updateCoinSpeedUpgradesRules(id, req);
    }

    @Operation(summary = "删除数据", description = "删除数据")
    @DeleteMapping({"/{ids}"})
    public void delete(@PathVariable("ids") List<Long> ids) {
        this.rulesService.removeByIds(ids);
    }


    @Operation(summary = "新增数据", description = "新增数据")
    @PostMapping
    public BaseIdResp<Long> add(@RequestBody CoinSpeedUpgradesRulesReq req) {
        return new BaseIdResp<>(rulesService.addCoinSpeedUpgradesRules(req));
    }
}
