package com.sy.coinage.workshop.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import javax.validation.Valid;

import org.springframework.beans.BeanUtils;
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 com.sy.coinage.core.annotation.ActiveFastJsonProfile;
import com.sy.coinage.core.annotation.CurrentUser;
import com.sy.coinage.core.aop.annotation.Permission;
import com.sy.coinage.core.aop.annotation.Operation;
import com.sy.coinage.core.controller.BaseController;
import com.sy.coinage.core.interceptor.Create;
import com.sy.coinage.core.interceptor.Update;
import com.sy.coinage.core.req.*;
import com.sy.coinage.core.vo.*;

import com.sy.coinage.workshop.model.*;
import com.sy.coinage.workshop.service.IDeliveryDetailService;
import com.sy.coinage.workshop.vo.*;
import com.sy.coinage.workshop.req.*;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * -Controller
 */
@Api(value = "接口", tags = {"接口"})
@RestController
@RequestMapping(value = "/deliveryDetail")
public class DeliveryDetailController extends BaseController {

    @Autowired
    private IDeliveryDetailService deliveryDetailService;

    /**
     * 分页列表
     */
    @ApiOperation(value = "列表")
    @PostMapping("/list")
    @ActiveFastJsonProfile(groups = "list", clazz = DeliveryDetail.class)
    public List<DeliveryDetail> list(@RequestBody DeliveryDetailListReq req, @CurrentUser CacheUserVO user) {
        QueryWrapper<DeliveryDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delivery_id", req.getDeliveryId());
        List<DeliveryDetail> data = this.deliveryDetailService.queryList(queryWrapper);
        return data;
    }

    @ApiOperation(value = "-通过ID查询单条数据")
    @PostMapping("/get")
    @ActiveFastJsonProfile(groups = "get", clazz = DeliveryDetail.class)
    public DeliveryDetailVO get(@RequestBody @ApiParam(value = "主键请求bean") @Valid IdReq req) {
        DeliveryDetailVO data = null;
        DeliveryDetail model = this.deliveryDetailService.getById(req.getId());
        data = new DeliveryDetailVO();
        BeanUtils.copyProperties(model, data);
        return data;
    }

}
