package com.sy.coinage.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sy.coinage.core.annotation.ActiveFastJsonProfile;
import com.sy.coinage.core.annotation.CurrentUser;
import com.sy.coinage.core.aop.annotation.Operation;
import com.sy.coinage.core.aop.annotation.Permission;
import com.sy.coinage.core.constants.Constants;
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.IdReq;
import com.sy.coinage.core.vo.CacheUserVO;
import com.sy.coinage.core.vo.OptVO;
import com.sy.coinage.workshop.model.Product;
import com.sy.coinage.workshop.req.ProductListReq;
import com.sy.coinage.workshop.req.ProductReq;
import com.sy.coinage.workshop.service.IProductService;
import com.sy.coinage.workshop.vo.ProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * -产品表Controller
 */
@Api(value = "产品表接口", tags = {"产品表接口"})
@RestController
@RequestMapping(value = "/app/product")
public class AppProductController extends BaseController {

    @Autowired
    private IProductService productService;

    @ApiOperation(value = "8.1 app根据品名ID获取产品相关信息")
    @GetMapping("/get/{id}")
    @ActiveFastJsonProfile(groups = "get", clazz = Product.class)
    public ProductVO get(@PathVariable Integer id) {
        ProductVO data = null;
        Product model = this.productService.getById(id);
        data = new ProductVO();
        BeanUtils.copyProperties(model, data);
        return data;
    }

}
