package com.jeeplus.test.garbageClearance.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeeplus.sys.service.dto.UserDTO;
import com.jeeplus.test.garbageClearance.domain.LookOver;
import com.jeeplus.test.garbageClearance.mapper.LookOverMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 王强
 * @version 1.0
 * @date 2024-08-29 10:51
 */
@Service
@Transactional
public class LookOverService extends ServiceImpl<LookOverMapper, LookOver> {


    public String getMaxNo() {
        // 创建查询条件构造器
        QueryWrapper<LookOver> queryWrapper = new QueryWrapper<>();

        // 按no字段降序排列
        queryWrapper.select("MAX(no) as no");

        // 只获取第一条记录
        LookOver lookOver = baseMapper.selectOne(queryWrapper);

        // 返回最大的no值
        return lookOver != null ? lookOver.getNo() : null;
    }

    public UserDTO getUserInfoByOffId(String officeId) {
        return baseMapper.getUserInfoByOffId(officeId);
    }
}
