package com.fjhx.victoriatourist.controller.group;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.victoriatourist.entity.group.dto.GetCombinableQuantityDto;
import com.fjhx.victoriatourist.entity.group.dto.GroupRecordDetailsSelectDto;
import com.fjhx.victoriatourist.entity.group.dto.GroupRecordDto;
import com.fjhx.victoriatourist.entity.group.vo.GetCombinableQuantityVo;
import com.fjhx.victoriatourist.entity.group.vo.GroupRecordDetailsVo;
import com.fjhx.victoriatourist.service.group.GroupRecordDetailsService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 * 组合记录明细 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-18
 */
@RestController
@RequestMapping("/groupRecordDetails")
public class GroupRecordDetailsController {

    @Autowired
    private GroupRecordDetailsService groupRecordDetailsService;

    /**
     * 组合记录明细分页
     */
    @PostMapping("/page")
    public Page<GroupRecordDetailsVo> page(@Validated @RequestBody GroupRecordDetailsSelectDto dto) {
        return groupRecordDetailsService.getPage(dto);
    }

    /**
     * 组合记录明细明细
     */
    @PostMapping("/detail")
    public List<GroupRecordDetailsVo> detail(@RequestBody BaseSelectDto dto) {
        return groupRecordDetailsService.detail(dto.getId());
    }

    /**
     * 获取可组合数量
     */
    @PostMapping("/getCombinableQuantity")
    public GetCombinableQuantityVo getCombinableQuantity(@Validated @RequestBody GetCombinableQuantityDto dto) {
        return groupRecordDetailsService.getCombinableQuantity(dto);
    }

    /**
     * 组合/拆分
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody GroupRecordDto dto) {
        groupRecordDetailsService.add(dto);
    }

}
