package com.fdkankan.manage.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fdkankan.manage.common.PageInfo; import com.fdkankan.manage.common.ResultCode; import com.fdkankan.manage.entity.AgentAudit; import com.fdkankan.manage.entity.RtkInfo; import com.fdkankan.manage.entity.SysUser; import com.fdkankan.manage.exception.BusinessException; import com.fdkankan.manage.mapper.IRtkInfoMapper; import com.fdkankan.manage.service.IRtkInfoService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fdkankan.manage.service.ISysUserService; import com.fdkankan.manage.vo.request.RtkInfoParam; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /** *

* 服务实现类 *

* * @author * @since 2024-04-26 */ @Service public class RtkInfoServiceImpl extends ServiceImpl implements IRtkInfoService { @Autowired ISysUserService sysUserService; @Override public RtkInfo getByRtkSnCode(String rtkSnCode) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(RtkInfo::getRtkSnCode,rtkSnCode); return this.getOne(wrapper); } @Override public Object pageList(RtkInfoParam param) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if(StringUtils.isNotBlank(param.getRtkSnCode())){ wrapper.like(RtkInfo::getRtkSnCode,param.getRtkSnCode()); } if(StringUtils.isNotBlank(param.getUserName())){ wrapper.like(RtkInfo::getUserName,param.getUserName()); } if(StringUtils.isNotBlank(param.getOperator())){ wrapper.like(RtkInfo::getOperator,param.getOperator()); } if(StringUtils.isNotBlank(param.getStartTime())&& StringUtils.isNotBlank(param.getEndTime()) ) { wrapper.between(RtkInfo::getCreateTime,param.getStartTime(),param.getEndTime()); } wrapper.orderByDesc(RtkInfo::getCreateTime); wrapper.orderByDesc(RtkInfo::getId); Page page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper); Set createUserIds = page.getRecords().stream().map(RtkInfo::getCreateUserId).collect(Collectors.toSet()); HashMap byIds = sysUserService.getByIds(createUserIds); for (RtkInfo record : page.getRecords()) { SysUser sysUser = byIds.get(record.getCreateUserId()); if(sysUser != null){ record.setCreateUserName(sysUser.getUserName()); record.setCreateNickName(sysUser.getNickName()); } } return PageInfo.PageInfo(page); } @Override public void saveOrEdit(RtkInfo rtkInfo) { this.saveOrUpdate(rtkInfo); } @Override public void del(RtkInfo rtkInfo) { if(rtkInfo.getId() == null){ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS); } RtkInfo rtkInfo1 = this.getById(rtkInfo.getId()); if(rtkInfo1 == null){ throw new BusinessException(ResultCode.RECOED_NO_EXITS); } this.removeById(rtkInfo.getId()); } }