package com.qunzhixinxi.hnqz.admin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qunzhixinxi.hnqz.admin.entity.WmContract;
import com.qunzhixinxi.hnqz.admin.mapper.WmContractMapper;
import com.qunzhixinxi.hnqz.admin.service.WmContractService;
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class WmContractServiceImpl extends ServiceImpl<WmContractMapper, WmContract> implements WmContractService {

	private final WmContractMapper wmContractMapper;

	@Override
	public IPage<WmContract> selectContractList(Page page, WmContract wmContract) {

		OrderItem orderItem=new OrderItem();
		orderItem.setColumn("create_time");
		orderItem.setAsc(false);
		page.addOrder(orderItem);

		QueryWrapper queryWrapper=Wrappers.query();
		if(null!=wmContract.getId())
		{
			queryWrapper.like("id",wmContract.getId());
		}
		if(null!=wmContract.getContractName())
		{
			queryWrapper.like("contract_name",wmContract.getContractName());
		}
		if(null!=wmContract.getSignJia())
		{
			queryWrapper.like("sign_jia",wmContract.getSignJia());
		}
		wmContract.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
		return wmContractMapper.selectContractList(page,wmContract);
	}

}
