class QuCheckboxManagerImpl extends BaseServiceImpl<QuCheckbox, String> implements QuCheckboxManager {

	@Autowired
	private QuCheckboxDao quCheckboxDao;

	@Override
	public void setBaseDao() {
		this.baseDao=quCheckboxDao;
	}

	public List<QuCheckbox> findByQuId(String quId){

		/*
		Page<QuCheckbox> page=new Page<QuCheckbox>();
		page.setOrderBy("orderById");
		page.setOrderDir("asc");
		List<PropertyFilter> filters=new ArrayList<PropertyFilter>();
		filters.add(new PropertyFilter("EQS_quId", quId));
		filters.add(new PropertyFilter("EQI_visibility", "1"));
		return findAll(page, filters);
		*/

		CriteriaBuilder criteriaBuilder=quCheckboxDao.getSession().getCriteriaBuilder();
		CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(QuCheckbox.class);
		Root root = criteriaQuery.from(QuCheckbox.class);
		criteriaQuery.select(root);
		Predicate eqQuId = criteriaBuilder.equal(root.get("quId"),quId);
		Predicate eqVisibility = criteriaBuilder.equal(root.get("visibility"),1);
		criteriaQuery.where(eqQuId,eqVisibility);
		criteriaQuery.orderBy(criteriaBuilder.asc(root.get("orderById")));
		return quCheckboxDao.findAll(criteriaQuery);

	}


	public int getOrderById(String quId){
		Criterion criterion=Restrictions.eq("quId", quId);
		QuCheckbox quCheckbox=quCheckboxDao.findFirst("orderById", false, criterion);
		if(quCheckbox!=null){
			return quCheckbox.getOrderById();
		}
		return 0;
	}

	/*******************************************************************8
	 * 更新操作
	 */

	@Override
	@Transactional
	public QuCheckbox upOptionName(String quId,String quItemId, String optionName) {
		if(quItemId!=null && !"".equals(quItemId)){
			QuCheckbox quCheckbox=quCheckboxDao.get(quItemId);
			quCheckbox.setOptionName(optionName);
			quCheckboxDao.save(quCheckbox);
			return quCheckbox;
		}else{
			//取orderById
			int orderById=getOrderById(quId);
			//新加选项
			QuCheckbox quCheckbox=new QuCheckbox();
			quCheckbox.setQuId(quId);
			quCheckbox.setOptionName(optionName);
			//title
			quCheckbox.setOrderById(++orderById);
			quCheckbox.setOptionTitle(orderById+"");
			quCheckboxDao.save(quCheckbox);
			return quCheckbox;
		}
	}

	@Override
	@Transactional
	public List<QuCheckbox> saveManyOptions(String quId,List<QuCheckbox> quCheckboxs) {<FILL_FUNCTION_BODY>}

	@Override
	@Transactional
	public void ajaxDelete(String quItemId) {
		QuCheckbox quCheckbox=get(quItemId);
		quCheckbox.setVisibility(0);
		quCheckboxDao.save(quCheckbox);
	}

	@Override
	@Transactional
	public void saveAttr(String quItemId, String isNote) {
		QuCheckbox quCheckbox=get(quItemId);
		if(isNote!=null && "1".equals(isNote)){
			quCheckbox.setIsNote(1);
		}else{
			quCheckbox.setIsNote(0);
		}
		quCheckboxDao.save(quCheckbox);
	}

}

		//取orderById
		int orderById=getOrderById(quId);
		for (QuCheckbox quCheckbox : quCheckboxs) {
			//新加选项
			quCheckbox.setOrderById(++orderById);
			quCheckbox.setOptionTitle(orderById+"");
			quCheckboxDao.save(quCheckbox);
		}
		return quCheckboxs;
	
<methods>public non-sealed void <init>() ,public void delete(net.diaowen.dwsurvey.entity.QuCheckbox) ,public void delete(java.lang.String) ,public net.diaowen.dwsurvey.entity.QuCheckbox findById(java.lang.String) ,public transient List<net.diaowen.dwsurvey.entity.QuCheckbox> findList(org.hibernate.criterion.Criterion[]) ,public transient Page<net.diaowen.dwsurvey.entity.QuCheckbox> findPage(Page<net.diaowen.dwsurvey.entity.QuCheckbox>, org.hibernate.criterion.Criterion[]) ,public Page<net.diaowen.dwsurvey.entity.QuCheckbox> findPageByCri(Page<net.diaowen.dwsurvey.entity.QuCheckbox>, List<org.hibernate.criterion.Criterion>) ,public net.diaowen.dwsurvey.entity.QuCheckbox get(java.lang.String) ,public net.diaowen.dwsurvey.entity.QuCheckbox getModel(java.lang.String) ,public void save(net.diaowen.dwsurvey.entity.QuCheckbox) <variables>protected BaseDao<net.diaowen.dwsurvey.entity.QuCheckbox,java.lang.String> baseDao