package com.ruoyi.iot.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.iot.domain.TChargeRecord;
import com.ruoyi.iot.domain.TDevicePlan;
import com.ruoyi.iot.domain.vo.TChargeRecordVO;
import com.ruoyi.iot.service.ITChargeRecordService;
import com.ruoyi.iot.service.impl.TChargeRecordServiceImpl;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzh
 * @since 2023-06-25
 */
@RestController
@RequestMapping("/chargeRecord")
@Slf4j
public class TChargeRecordController extends BaseController {

    @Autowired
    private ITChargeRecordService tChargeRecordService;


    @PostMapping("/list")
    @ApiOperation("查询充电记录")
    public AjaxResult list() {
        startPage();
        LambdaQueryWrapper<TChargeRecord> objectLambdaQueryWrapper = Wrappers.lambdaQuery();
        objectLambdaQueryWrapper.orderByDesc(TChargeRecord::getCreateTime);
        LoginUser loginUser = getLoginUser();
        Long userId = loginUser.getUserId();
        objectLambdaQueryWrapper.eq(TChargeRecord::getUserId,userId);
        List<TChargeRecord> list = tChargeRecordService.list(objectLambdaQueryWrapper);
        return AjaxResult.success(list);
    }
}

