package com.blueland.service.impl;


import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.blueland.service.IPubOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blueland.bo.Org;
import com.blueland.bo.PubOrgEntity;
import com.blueland.dao.PubOrgDao;

@Service
public class PubOrgServiceImpl extends ServiceImpl<PubOrgDao, PubOrgEntity> implements IPubOrgService {
	@Autowired
	//TpubOrg对应的DAO类,主要用于数据库的增删改查等操作
	private PubOrgDao pubOrgDao;

	@Override
	public PubOrgEntity findOrgById(String id) {
		return pubOrgDao.selectById(id);
	}

	@Override
	public List<Org> getListNoPage(Org org) {
		// TODO Auto-generated method stub
		return pubOrgDao.getListNoPage(org);
	}

	@Override
	public PubOrgEntity get(PubOrgEntity bo) {
		return this.baseMapper.selectOne(buildQueryWrapper(bo));
	}

	@Override
	public Page<PubOrgEntity> findPage(PubOrgEntity bo) {
		Page<PubOrgEntity> page = new Page(bo.getPageNum(), bo.getPageSize());
		return this.baseMapper.findPage(page, bo);
	}

	@Override
	public List<PubOrgEntity> findList(PubOrgEntity bo) {
		return this.baseMapper.findList(bo);
	}

	private LambdaQueryWrapper<PubOrgEntity> buildQueryWrapper(PubOrgEntity bo) {
		LambdaQueryWrapper<PubOrgEntity> lqw = Wrappers.lambdaQuery();
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgId()), PubOrgEntity::getOrgId, bo.getOrgId());
		lqw.like(ObjectUtil.isNotEmpty(bo.getOrgName()), PubOrgEntity::getOrgName, bo.getOrgName());
		lqw.like(ObjectUtil.isNotEmpty(bo.getOrgFullName()), PubOrgEntity::getOrgFullName, bo.getOrgFullName());
		lqw.like(ObjectUtil.isNotEmpty(bo.getOrgFullPathName()), PubOrgEntity::getOrgFullPathName, bo.getOrgFullPathName());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgFullPathId()), PubOrgEntity::getOrgFullPathId, bo.getOrgFullPathId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgParentId()), PubOrgEntity::getOrgParentId, bo.getOrgParentId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgType()), PubOrgEntity::getOrgType, bo.getOrgType());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgLevel()), PubOrgEntity::getOrgLevel, bo.getOrgLevel());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgAreaType()), PubOrgEntity::getOrgAreaType, bo.getOrgAreaType());
		lqw.like(ObjectUtil.isNotEmpty(bo.getOrgWorkAddress()), PubOrgEntity::getOrgWorkAddress, bo.getOrgWorkAddress());
		lqw.like(ObjectUtil.isNotEmpty(bo.getOrgWorkPhone()), PubOrgEntity::getOrgWorkPhone, bo.getOrgWorkPhone());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgPrincipal()), PubOrgEntity::getOrgPrincipal, bo.getOrgPrincipal());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgStatus()), PubOrgEntity::getOrgStatus, bo.getOrgStatus());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getFundCode()), PubOrgEntity::getFundCode, bo.getFundCode());
		lqw.like(ObjectUtil.isNotEmpty(bo.getFundName()), PubOrgEntity::getFundName, bo.getFundName());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getCompanyId()), PubOrgEntity::getCompanyId, bo.getCompanyId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getOrgBranchLeader()), PubOrgEntity::getOrgBranchLeader, bo.getOrgBranchLeader());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getDeptId()), PubOrgEntity::getDeptId, bo.getDeptId());
		lqw.like(ObjectUtil.isNotEmpty(bo.getRemark()), PubOrgEntity::getRemark, bo.getRemark());
		lqw.like(ObjectUtil.isNotEmpty(bo.getDeptName()), PubOrgEntity::getDeptName, bo.getDeptName());
		lqw.like(ObjectUtil.isNotEmpty(bo.getCompanyName()), PubOrgEntity::getCompanyName, bo.getCompanyName());
		return lqw;
	}

}
