package com.lz.modules.third.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.Query;
import com.lz.modules.third.dao.ThirdMsgSendRecordMapper;
import com.lz.modules.third.entity.ThirdMsgSendRecord;
import com.lz.modules.third.service.ThirdMsgSendRecordService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* <p>
* 第三方消息发送记录 服务类
* </p>
*
* @author quyixiao
* @since 2020-08-19
*/

@Service
public class ThirdMsgSendRecordServiceImpl extends ServiceImpl<ThirdMsgSendRecordMapper, ThirdMsgSendRecord> implements ThirdMsgSendRecordService {


    @Resource
	private ThirdMsgSendRecordMapper thirdMsgSendRecordMapper;



	@Override
	public ThirdMsgSendRecord selectThirdMsgSendRecordById(Long id){
		return thirdMsgSendRecordMapper.selectThirdMsgSendRecordById(id);
	}



	@Override
	public Long insertThirdMsgSendRecord(ThirdMsgSendRecord thirdMsgSendRecord){
		return thirdMsgSendRecordMapper.insertThirdMsgSendRecord(thirdMsgSendRecord);
	}



	@Override
	public int updateThirdMsgSendRecordById(ThirdMsgSendRecord thirdMsgSendRecord){
		return thirdMsgSendRecordMapper.updateThirdMsgSendRecordById(thirdMsgSendRecord);
	}



	@Override
	public int updateCoverThirdMsgSendRecordById(ThirdMsgSendRecord thirdMsgSendRecord){
		return thirdMsgSendRecordMapper.updateCoverThirdMsgSendRecordById(thirdMsgSendRecord);
	}



	@Override
	public int deleteThirdMsgSendRecordById(Long id){
		return thirdMsgSendRecordMapper.deleteThirdMsgSendRecordById(id);
	}

	@Override
	public PageUtils queryPage(Map<String, Object> params){
		String roleName = (String)params.get("app_name");
		Long createUserId = (Long)params.get("app_key");

		IPage<ThirdMsgSendRecord> page = this.page(
				new Query<ThirdMsgSendRecord>().getPage(params),
				new QueryWrapper<ThirdMsgSendRecord>()
						.like(StringUtils.isNotBlank(roleName),"app_name", roleName)
						.eq(createUserId != null,"app_key", createUserId)
		);

		return new PageUtils(page);
	}

	@Override
	public void insert(ThirdMsgSendRecord thirdMsgSendRecord){
		thirdMsgSendRecordMapper.insert(thirdMsgSendRecord);
	}

	@Override
	public ThirdMsgSendRecord selectThirdMsgSendRecordByWorkIdAndStaffIdAndTypeAndStatus(Long workId,
																						 Long staffId,
																						 int workType,
																						 int status){
		return thirdMsgSendRecordMapper.selectThirdMsgSendRecordByWorkIdAndStaffIdAndTypeAndStatus(workId,
				staffId,
				workType,
				status);
	}

	@Override
	public List<ThirdMsgSendRecord> selectThirdMsgSendRecordsByRecordIds(List<Long> recordIds, int type, int status){
		return thirdMsgSendRecordMapper.selectThirdMsgSendRecordsByRecordIds(recordIds, type, status);
	}

}
