package com.usky.agbox.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usky.agbox.domain.PatrolInspectionAgbox;
import com.usky.agbox.mapper.PatrolInspectionAgboxMapper;
import com.usky.agbox.service.PatrolInspectionAgboxService;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.mybatis.core.AbstractCrudService;
import com.usky.common.security.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author han
 * @since 2024-05-23
 */
@Service
public class PatrolInspectionAgboxServiceImpl extends AbstractCrudService<PatrolInspectionAgboxMapper, PatrolInspectionAgbox> implements PatrolInspectionAgboxService {
    @Override
    public void update(PatrolInspectionAgbox patrolInspectionAgbox) {
        patrolInspectionAgbox.setUpdateTime(LocalDateTime.now());
        patrolInspectionAgbox.setUpdateBy(SecurityUtils.getUsername());
        this.updateById(patrolInspectionAgbox);
    }

    @Override
    public CommonPage<PatrolInspectionAgbox> page(Integer pageNum,Integer pageSize) {
        IPage<PatrolInspectionAgbox> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<PatrolInspectionAgbox> lambdaQuery = Wrappers.lambdaQuery();
        page = this.page(page,lambdaQuery);
        return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
    }
}
