package com.fjhx.victoriatourist.service.abnormal.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.victoriatourist.entity.abnormal.po.AbnormalInfo;
import com.fjhx.victoriatourist.mapper.abnormal.AbnormalInfoMapper;
import com.fjhx.victoriatourist.service.abnormal.AbnormalInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.utils.UserUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.victoriatourist.entity.abnormal.vo.AbnormalInfoVo;
import com.fjhx.victoriatourist.entity.abnormal.dto.AbnormalInfoSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;


/**
 * <p>
 * 异常记录 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-11
 */
@DS(SourceConstant.VICTORIATOURIST)
@Service
public class AbnormalInfoServiceImpl extends ServiceImpl<AbnormalInfoMapper, AbnormalInfo> implements AbnormalInfoService {

    @Override
    public Page<AbnormalInfoVo> getPage(AbnormalInfoSelectDto dto) {
        IWrapper<AbnormalInfo> wrapper = getWrapper();
        wrapper.eq(AbnormalInfo::getType, dto.getType())
                .eq(AbnormalInfo::getStatus, dto.getStatus())
                .like(AbnormalInfo::getTitle, dto.getKeyword());

        wrapper.orderByDesc("ai", AbnormalInfo::getId);
        Page<AbnormalInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        //赋值最近操作人
        UserUtil.assignmentNickName(page.getRecords(), AbnormalInfo::getUpdateUser, AbnormalInfoVo::setHandleUserName);
        return page;
    }

}
