package com.ssj.service.sys.role.service.impl;

import com.ssj.bean.sys.role.domain.AdminOrg;
import com.ssj.dao.sys.role.dao.AdminOrgDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.sys.role.service.AdminOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/** 
 * @author  ZhangCaibao 
 * @version 2018年2月11日 下午4:18:14 
 * 类说明 
 */
@Service
@Transactional
public class AdminOrgServiceImpl extends BaseServiceImpl<AdminOrg, String> implements AdminOrgService {
	@Autowired
	private AdminOrgDao adminOrgDao;
	@Override
	public PagingAndSortingRepository<AdminOrg, String> getDao() {
		return adminOrgDao;
	}
	@Override
	public List<AdminOrg> findByAdminId(String adminId) {
		return adminOrgDao.findByAdminId(adminId);
	}
	@Override
	public void deleteByAdminId(String adminId) {
		adminOrgDao.deleteByAdminId(adminId);
		
	}
	@Override
	public void saveAdminOrg(List<AdminOrg> list, String adminId) {
		this.deleteByAdminId(adminId);
		for (AdminOrg adminOrg : list) {
			adminOrg.setAdminId(adminId);
			adminOrg.setCreateTime(new Date());
		}
		this.save(list);
	}

}
