2d7e16ccec1ae9d0ef96d534458704289fc679ab.svn-base 2.97 KB
/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.service.base;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseChxx11Dao;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseZbinfo11Dao;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseChxx11;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZbinfo11;

/**
 * 测绘信息Service
 * @author jiangdb
 * @version 2015-11-23
 */
@Service
@Transactional(readOnly = true)
public class RegBaseChxx11Service extends CrudService<RegBaseChxx11Dao, RegBaseChxx11> {
	
	@Autowired
	private RegBaseZbinfo11Dao regBaseZbinfoDao;
	

	public RegBaseChxx11 get(String id) {
		//return super.get(id);
		RegBaseChxx11 regBaseChxx = super.get(id);
		regBaseChxx.setRegBaseZbinfoList(regBaseZbinfoDao.findList(new RegBaseZbinfo11(regBaseChxx)));
		return regBaseChxx;
	}
	
	public List<RegBaseChxx11> findList(RegBaseChxx11 regBaseChxx) {
		return super.findList(regBaseChxx);
	}
	
	public Page<RegBaseChxx11> findPage(Page<RegBaseChxx11> page, RegBaseChxx11 regBaseChxx) {
		return super.findPage(page, regBaseChxx);
	}
	
	@Transactional(readOnly = false)
	public void save(RegBaseChxx11 regBaseChxx) {
		super.save(regBaseChxx);
		for (RegBaseZbinfo11 regBaseZbinfo : regBaseChxx.getRegBaseZbinfoList()){
			if (regBaseZbinfo.getId() == null){
				continue;
			}
			System.out.println(RegBaseZbinfo11.DEL_FLAG_NORMAL);
			if (RegBaseZbinfo11.DEL_FLAG_NORMAL.equals(regBaseZbinfo.getDelFlag())){
				if (StringUtils.isBlank(regBaseZbinfo.getId())){
					regBaseZbinfo.setMainId(regBaseChxx);
					regBaseZbinfo.preInsert();
					regBaseZbinfoDao.insert(regBaseZbinfo);
				}else{
					regBaseZbinfo.preUpdate();
					regBaseZbinfoDao.update(regBaseZbinfo);
				}
			}else{
				regBaseZbinfoDao.delete(regBaseZbinfo);
			}
		}
	}
	
	@Transactional(readOnly = false)
	public void drsave(RegBaseChxx11 regBaseChxx) {
		super.save(regBaseChxx);
		for (RegBaseZbinfo11 regBaseZbinfo : regBaseChxx.getRegBaseZbinfoList()){
			System.out.println(RegBaseZbinfo11.DEL_FLAG_NORMAL);
			if (RegBaseZbinfo11.DEL_FLAG_NORMAL.equals(regBaseZbinfo.getDelFlag())){
				if (StringUtils.isBlank(regBaseZbinfo.getId())){
					regBaseZbinfo.setMainId(regBaseChxx);
					regBaseZbinfo.preInsert();
					regBaseZbinfoDao.insert(regBaseZbinfo);
				}else{
					regBaseZbinfo.preUpdate();
					regBaseZbinfoDao.update(regBaseZbinfo);
				}
			}else{
				regBaseZbinfoDao.delete(regBaseZbinfo);
			}
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(RegBaseChxx11 regBaseChxx) {
		super.delete(regBaseChxx);
	}
	
}