TbAreaBlockDaoImpl.java 3.37 KB
package com.zteits.sys.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import org.apache.commons.collections4.CollectionUtils;
import com.zteits.clouds.api.apibase.constants.AreaTypeEnum;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.sys.param.CheckBlockNameUniqueRequest;
import com.zteits.sys.dao.TbAreaBlockDao;
import com.zteits.sys.domain.TbAreaBlock;
import com.zteits.sys.mapper.TbAreaBlockMapper;
import com.zteits.sys.mapper.smapper.TbAreaBlockSmapper;

/**
 * Copyright: Copyright (c) 2017  zteits
 *
 * @ClassName: com.zteits.sys.dao.impl
 * @Description:
 * @version: v1.0.0
 * @author: atao
 * @date: 2017/8/29   下午3:43
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2017/8/29      atao          v1.0.0          创建
 */
@Component
public class TbAreaBlockDaoImpl implements TbAreaBlockDao {

    @Autowired
    private TbAreaBlockSmapper tbAreaBlockSmapper;

    @Autowired
    private TbAreaBlockMapper tbAreaBlockMapper;

    @Override
    public List<TbAreaBlock> queryAreaBlockByAreaType(List<Integer> areaTypes,Long orgId) {
        if(CollectionUtils.isEmpty(areaTypes)){
            throw new BizException(ErrorType.PARAMM_NULL,"区块类型");
        }
        if(null == orgId){
            throw new BizException(ErrorType.PARAMM_NULL,"组织ID");
        }
        return tbAreaBlockSmapper.queryAreaBlockByAreaType(areaTypes,orgId);
    }

    @Override
    public List<TbAreaBlock> queryTbAreaBlock(TbAreaBlock tbAreaBlock) {
        return tbAreaBlockSmapper.queryTbAreaBlock(tbAreaBlock);
    }

    @Override
    public int saveTbAreaBlock(TbAreaBlock tbAreaBlock) {

        return tbAreaBlockMapper.insert(tbAreaBlock);
    }

    @Override
    public int updateTbAreaBlock(TbAreaBlock tbAreaBlock) {
        return tbAreaBlockMapper.updateByPrimaryKeySelective(tbAreaBlock);
    }

    @Override
    public int deleteTbAreaBlock(Long id) {
        return tbAreaBlockMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<TbAreaBlock> queryAreaBlockByParentIdAndOrgId(Long parentId, Long orgId) {
        return tbAreaBlockSmapper.queryAreaBlockByParentIdAndOrgId(parentId,orgId);
    }

	@Override
	public List<TbAreaBlock> queryAreaBlockByBlockId(List<Long> plBlockIds) {
		return tbAreaBlockSmapper.queryAreaBlockByBlockId(plBlockIds);
	}

  /**
    * 通过操作员ID+组织id查询块信息.<b>
    * @param opId
    * @param orgId
    * @return
    * 2017年12月27日  wangfs.<br/>
    */
	@Override
	public List<TbAreaBlock> queryAreaBlockByOpIdAndOrgId(Long opId, Long orgId) {
		return tbAreaBlockSmapper.queryAreaBlockByOpIdAndOrgId(AreaTypeEnum.BLOCK.code(), opId, orgId);
	}

	/**
	 * 检查块名称是否唯一.<br/>
	 * @param request
	 * @return
	 * 2018年1月2日  wangfs.<br/>
	 */
	@Override
	public Boolean checkBlockNameUnique(CheckBlockNameUniqueRequest request) {
		int selectCounts = 0 ;
		selectCounts = tbAreaBlockSmapper.checkBlockNameUnique(request);
		return selectCounts >0 ? true : false;
	}

    @Override
    public List<TbAreaBlock> queryNextLowerLeverByIdForArea(Long id) {
        return tbAreaBlockSmapper.queryNextLowerLeverByIdForArea(id);
    }
}