package com.fdkankan.manage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fdkankan.manage.common.ResultCode;
import com.fdkankan.manage.exception.BusinessException;
import com.fdkankan.manage.common.PageInfo;
import com.fdkankan.manage.entity.IntercomMessage;
import com.fdkankan.manage.mapper.IIntercomMessageMapper;
import com.fdkankan.manage.service.IIntercomMessageService;
import com.fdkankan.manage.vo.request.IntercomMessageParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
*
* 咨询留言表 服务实现类
*
*
* @author
* @since 2022-06-30
*/
@Service
public class IntercomMessageServiceImpl extends ServiceImpl implements IIntercomMessageService {
@Override
public PageInfo pageList(IntercomMessageParam param) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
if(StringUtils.isNotBlank(param.getContent())){
wrapper.like(IntercomMessage::getContent,param.getContent());
}
if(StringUtils.isNotBlank(param.getStartTime())){
wrapper.ge(IntercomMessage::getCreateTime,param.getStartTime());
}
if(StringUtils.isNotBlank(param.getEndTime())){
wrapper.le(IntercomMessage::getCreateTime,param.getEndTime());
}
wrapper.eq(IntercomMessage::getState,param.getState());
wrapper.orderByDesc(IntercomMessage::getCreateTime);
return PageInfo.PageInfo(this.page(new Page<>(param.getPageNum(),param.getPageSize()),wrapper));
}
@Override
public void handle(IntercomMessageParam param) {
if(param.getId() == null){
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
}
LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>();
wrapper.set(IntercomMessage::getState,0);
if(StringUtils.isNotBlank(param.getNoteContent())){
wrapper.set(IntercomMessage::getNoteContent,param.getNoteContent());
}
wrapper.eq(IntercomMessage::getId,param.getId());
this.update(wrapper);
}
}