AreaServiceImpl.java 1.65 KB
/*
 * Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
 * GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package com.glsx.usercenter.service.impl;


import com.glsx.usercenter.mapper.SysAreaMapper;
import com.glsx.usercenter.pojo.user.SysArea;
import com.glsx.usercenter.pojo.user.SysAreaExample;
import com.glsx.usercenter.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**  
* @ClassName: AreaServiceImpl  
* @Description: TODO(这里用一句话描述这个类的作用)  
* @author Zheng Xiajun  
* @date 2019年1月23日 
*  
*/
@Service
public class AreaServiceImpl implements IAreaService {

	
	@Autowired
	private SysAreaMapper sysAreaMapper;
		@Override
	public List<SysArea> selectByExample(SysAreaExample example) {
		
		return sysAreaMapper.selectByExample(example);
	}

	
	@Override
	public SysArea  getAllChargeItems(Integer id) {
		SysAreaExample example=new SysAreaExample ();
		example.createCriteria().andIdEqualTo(id);
		List<SysArea> child = sysAreaMapper.selectByExample(example);
		example.clear();
		example.createCriteria().andIdEqualTo(child.get(0).getParentId());
		List<SysArea> parent= sysAreaMapper.selectByExample(example);
		example.clear();
		example.createCriteria().andIdEqualTo(parent.get(0).getParentId());
		SysArea prandPa= sysAreaMapper.selectByExample(example).get(0);
		parent.get(0).setChildren(child);
		prandPa.setChildren(parent);
		return prandPa;
	}

}