首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

注脚驱动,事务切面

2013-03-29 
注解驱动,事务切面package com.cpic.a2.backend.sales.business.channel.serviceimport java.text.Simple

注解驱动,事务切面

package com.cpic.a2.backend.sales.business.channel.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

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

import com.cpic.a2.backend.sales.dao.channel.ChannelBranchRelaDao;
import com.cpic.a2.backend.sales.dao.channel.ChannelDao;
import com.cpic.a2.backend.sales.dao.channel.ChannelSoluRelaDao;
import com.cpic.a2.sales.vo.channel.ChannelBranchRelaVO;
import com.cpic.a2.sales.vo.channel.ChannelSoluRelaVO;
import com.cpic.a2.sales.vo.channel.ChannelVO;
import com.cpic.a2.util.exception.PersistentException;
import com.cpic.common.base.service.BaseService;
@Service("channelService")
@Transactional(value="hibernateTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = {PersistentException.class,RuntimeException.class })
public class ChannelService extends BaseService implements IChannelService {

??? @Autowired???
??? private ChannelDao channelDao;
???
??? @Autowired???
??? private ChannelBranchRelaDao channelBranchRelaDao;
???
??? @Autowired???
??? private ChannelSoluRelaDao channelSoluRelaDao;
???
??? public String generateChannelCode() {??? ???
??? ???
??? ??? Date newDate = new Date();
??? ??? int i = (int)(Math.random()*(9999-1000))+1000;
??? ??? SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
??? ??? return "CH"+dateFormat.format(newDate).concat(""+i);
??? ???
??? }

??? public void createChannel(ChannelVO channelVO,List<ChannelBranchRelaVO> channelBranchRelaVOs) throws PersistentException {
??? ??? channelVO.setChannelStatus("1");
??? ??? //如果用户没有选择企业团购类型,系统自动设置为01(网购)
??? ??? if (channelVO.getCooperationType()==null) {
??? ??? ??? channelVO.setCooperationType("01");
??? ??? }
??? ??? channelVO.setCreationDtime(new Date());
??? ??? channelDao.saveOrUpdate(channelVO);
??? ??? for (int i=0;i<channelBranchRelaVOs.size();i++) {
??? ??? ??? channelBranchRelaVOs.get(i).setChannelId(channelVO.getChannelId());
??? ??? ??? channelBranchRelaDao.saveOrUpdate(channelBranchRelaVOs.get(i));
??? ??? }
??? ???
??? }
???
??? public void updateChannel(ChannelVO channelVO,
??? ??? ??? List<ChannelBranchRelaVO> channelBranchRelaVOs) throws PersistentException {
??? ??? ???
??? ??? ??? if (channelVO.getChannelStatus()==null) {
??? ??? ??? ??? channelVO.setChannelStatus("1");
??? ??? ??? }???
??? ??? ???
??? ??? ??? //如果用户没有选择企业团购类型,系统自动设置为01(网购)
??? ??? ??? if (channelVO.getCooperationType()==null) {
??? ??? ??? ??? channelVO.setCooperationType("01");
??? ??? ??? }
??? ??? ??? channelDao.saveOrUpdate(channelVO);
??? ??? ??? if (channelBranchRelaVOs!=null) {
??? ??? ??? ??? ChannelBranchRelaVO queryParametersVO = new ChannelBranchRelaVO();
??? ??? ??? ??? queryParametersVO.setChannelId(channelVO.getChannelId());
??? ??? ??? ???
??? ??? ??? ??? //delete channel branch rela vo first
??? ??? ??? ??? List<ChannelBranchRelaVO> relaList = channelBranchRelaDao.queryChannelBranchRela(queryParametersVO);
??? ??? ??? ??? if (relaList!=null) {
??? ??? ??? ??? ??? for (int i=0;i<relaList.size();i++) {
??? ??? ??? ??? ??? ??? ChannelBranchRelaVO relaVO = relaList.get(i);
??? ??? ??? ??? ??? ??? channelBranchRelaDao.delete(ChannelBranchRelaVO.class,relaVO.getListId());
??? ??? ??? ??? ??? }
??? ??? ??? ??? }
??? ??? ??? ??? for (int i=0;i<channelBranchRelaVOs.size();i++) {
??? ??? ??? ??? ??? channelBranchRelaVOs.get(i).setChannelId(channelVO.getChannelId());
??? ??? ??? ??? ??? channelBranchRelaDao.saveOrUpdate(channelBranchRelaVOs.get(i));
??? ??? ??? ??? }
??? ??? ??? }??? ???
??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ???
??? }
???
??? public List<ChannelVO> queryChannelList(ChannelVO queryParametersVO,
??? ??? ??? Integer currentPage, Integer pageSize) throws PersistentException {
??? ??? this.log("normal message", "INFO", queryParametersVO.toString(), "queryChannelList", null);
??? ??? if (currentPage ==null && pageSize==null) {
??? ??? ??? return null;
??? ??? } else {
??? ??? ??? return channelDao.queryChannelList(queryParametersVO, currentPage.intValue(), pageSize.intValue());
??? ??? }
??? ???
??? }

??? public Long queryChannelListCount(ChannelVO queryParametersVO) throws PersistentException {??? ???
??? ??? return channelDao.queryChannelListCount(queryParametersVO);
??? }

??? public ChannelVO getChannel(Long channelId) throws PersistentException {??? ???
??? ??? return (ChannelVO) channelDao.get(ChannelVO.class,channelId);
??? }

??? public List<ChannelBranchRelaVO> queryChannelBranchRelaVO(Long channelId) throws PersistentException {
??? ???
??? ??? return channelDao.queryChannelBranchRelaVO(channelId);
??? }

??? public void removeAllChannelSoluRela(Long channelId) throws PersistentException {
??? ??? List<ChannelSoluRelaVO> relaList = channelSoluRelaDao.queryByChannelId(channelId);
??? ??? if (relaList!=null) {
??? ??? ??? for (int i=0;i<relaList.size();i++) {
??? ??? ??? ??? channelSoluRelaDao.delete(ChannelSoluRelaVO.class,((ChannelSoluRelaVO)relaList.get(i)).getListId());
??? ??? ??? }
??? ??? }
??? ???
??? }

??? public void createChannelSoluRela(ChannelSoluRelaVO relaVO) throws PersistentException {??? ???
??? ??? channelSoluRelaDao.saveOrUpdate(relaVO);
??? }
???
???
??? public List<ChannelSoluRelaVO> queryChannelSoluRelaVOByChannelId(Long channelId) throws PersistentException {??? ???
??? ??? return channelSoluRelaDao.queryByChannelId(channelId);??? ???
??? }

??? //更新渠道方案经办人关联信息 2012-11-22
??? public boolean updateChanSolu(String[] updArr) {
??? ??? return channelSoluRelaDao.updateChanSolu(updArr);
??? }

???
}

热点排行