Package com.jeecms.cms.manager.main.impl

Source Code of com.jeecms.cms.manager.main.impl.ContentTxtMngImpl

package com.jeecms.cms.manager.main.impl;

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

import com.jeecms.cms.dao.main.ContentTxtDao;
import com.jeecms.cms.entity.main.Content;
import com.jeecms.cms.entity.main.ContentTxt;
import com.jeecms.cms.manager.main.ContentTxtMng;
import com.jeecms.common.hibernate3.Updater;

@Service
@Transactional
public class ContentTxtMngImpl implements ContentTxtMng {
  public ContentTxt save(ContentTxt txt, Content content) {
    if (txt.isAllBlank()) {
      return null;
    } else {
      txt.setContent(content);
      txt.init();
      dao.save(txt);
      content.setContentTxt(txt);
      return txt;
    }
  }

  public ContentTxt update(ContentTxt txt, Content content) {
    ContentTxt entity = dao.findById(content.getId());
    if (entity == null) {
      entity = save(txt, content);
      content.getContentTxtSet().add(entity);
      return entity;
    } else {
      if (txt.isAllBlank()) {
        content.getContentTxtSet().clear();
        return null;
      } else {
        Updater<ContentTxt> updater = new Updater<ContentTxt>(txt);
        entity = dao.updateByUpdater(updater);
        entity.blankToNull();
        return entity;
      }
    }
  }

  private ContentTxtDao dao;

  @Autowired
  public void setDao(ContentTxtDao dao) {
    this.dao = dao;
  }
}
TOP

Related Classes of com.jeecms.cms.manager.main.impl.ContentTxtMngImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.