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.IWorkshopEntryDetailService;
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 = "/workshopEntryDetail")
public class WorkshopEntryDetailController extends BaseController {

    @Autowired
    private IWorkshopEntryDetailService workshopEntryDetailService;

    @ApiOperation(value = "分页列表")
    @PostMapping("/list")
    @ActiveFastJsonProfile(groups = "list", clazz = WorkshopEntryDetail.class)
    public List<WorkshopEntryDetail> list(@RequestBody WorkshopEntryDetailListReq req, @CurrentUser CacheUserVO user) {
        LambdaQueryWrapper<WorkshopEntryDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WorkshopEntryDetail::getEntryId, req.getEntryId());
        List<WorkshopEntryDetail> data = this.workshopEntryDetailService.list(queryWrapper);
        return data;
    }

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

}
