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.ICheckDetailService;
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 = "/checkDetail")
public class CheckDetailController extends BaseController {

    @Autowired
    private ICheckDetailService checkDetailService;


    @ApiOperation(value = "列表")
    @PostMapping("/list")
    @ActiveFastJsonProfile(groups = "list", clazz = CheckDetail.class)
    public List<CheckDetail> list(@RequestBody @Valid CheckDetailListReq req, @CurrentUser CacheUserVO user) {
        LambdaQueryWrapper<CheckDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CheckDetail::getCheckId, req.getCheckId());
        List<CheckDetail> data = this.checkDetailService.list(queryWrapper);
        return data;
    }

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

}
