package com.jd.lightapplication.controller;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jd.lightapplication.common.lang.R;
import com.jd.lightapplication.model.QrcodeShowConfig;
import com.jd.lightapplication.service.QrcodeShowConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;


@Slf4j
@RestController()
@RequestMapping("/api/qrcode/show/config")
@Api(tags = "二维码展示配置")
public class QrcodeShowConfigController {

    @Resource
    private QrcodeShowConfigService qrcodeShowConfigService;

    @GetMapping("/list")
    @ApiOperation(value = "1、分页查询")
    public R queryPageBean(Page page,String title) {
        return R.success(qrcodeShowConfigService.page(page,title));
    }

    @PostMapping("/addBean")
    @ApiOperation(value = "2、新增")
    public R addBean(@RequestBody QrcodeShowConfig qrcodeShowConfig) {
        qrcodeShowConfig.setCreateTime(DateUtil.now());
        qrcodeShowConfigService.save(qrcodeShowConfig);
        return R.success();
    }

    @PostMapping("/updateBean")
    @ApiOperation(value = "3、修改")
    public R updateBean(@RequestBody QrcodeShowConfig qrcodeShowConfig) {
        qrcodeShowConfig.setUpdateTime(DateUtil.now());
        qrcodeShowConfigService.updateById(qrcodeShowConfig);
        return R.success();
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "4、删除")
    public R deleteById(long id) {
        qrcodeShowConfigService.removeById(id);
        return R.success();
    }

    @GetMapping("/queryAll")
    @ApiOperation(value = "5、查询所有需要展示的二维码")
    public R queryAll() {
        return R.success(qrcodeShowConfigService.queryAll());
    }

}