package org.dromara.web.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.work.domain.bo.TpOrderBo;
import org.dromara.work.domain.vo.TpOrderVo;
import org.dromara.work.service.ITpOrderService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 集材社调用接口
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/home")
@Tag(name = "集材社调用接口")
public class HomeController {

    private final ITpOrderService tpOrderService;

    /**
     * 获取订单详细信息
     *
     * @param id 主键
     */
    @GetMapping("order/{id}")
    public R<TpOrderVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
        return R.ok(tpOrderService.queryById(id));
    }

    /**
     * 更新订单信息
     */
    @PostMapping("/updateOrder")
    @RepeatSubmit()
    public R<Boolean> edit(@RequestBody TpOrderBo bo) {
        return R.ok(tpOrderService.updateInfoByBo(bo));
    }


}
