⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bussinesstypeserviceimpl.java

📁 一个关于tlms的一个小程序 看看能否帮助到别人
💻 JAVA
字号:
package com.szmx.tlms.admin.service.impl;

import com.szmx.framework.base.service.impl.BaseServiceImpl;
import com.szmx.framework.base.model.Pagination;
import com.szmx.tlms.admin.service.BussinessTypeService;
import com.szmx.tlms.admin.service.LogService;
import com.szmx.tlms.admin.model.BussinessType;
import com.szmx.tlms.admin.dao.BussinessTypeDAO;
import com.szmx.tlms.TlmsServiceException;
import com.szmx.tlms.TlmsServiceErrorCodes;
import com.szmx.tlms.GlobalConstants;

import java.util.Map;
import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2006-7-26
 * Time: 11:02:26
 * To change this template use File | Settings | File Templates.
 */
public class BussinessTypeServiceImpl extends BaseServiceImpl implements BussinessTypeService {
    /**
     * 通过Spring注入 BussinessTypeDAO实现类:BussinessTypeDAOImpl
     */
    private BussinessTypeDAO bussinessTypeDao;

    public void setBussinessTypeDao(BussinessTypeDAO bussinessTypeDao) {
        this.bussinessTypeDao = bussinessTypeDao;
    }

    /**
     * 通过Spring注入 LogService的实现类:LogServiceImpl
     */
    private LogService logService;

    public void setLogService(LogService logService) {
        this.logService = logService;
    }

//relationInfo service methods Begin--------------------------------------

    /**
     * This method is for admin to search BussinessType based on
     * search criteria with pagination and sort.
     *
     * @param pagination    (the pagination object)
     * @param bussinessType (Map)  [should contains properties]
     *                      bussinessID : Long
     *                      busSpecies : String
     *                      prefixContract : String
     *                      busInstroction : String
     * @return BussinessType list for search result
     * @throws com.szmx.tlms.TlmsServiceException
     *
     */
    public Pagination searchBussinessTypes(final Pagination pagination,
                                           final BussinessType bussinessType) throws TlmsServiceException {
        //构造用于sql-map的参数
        Map paraMap = new HashMap();

        //参数设置开始:
        //参数1。bussinessID
        paraMap.put("bussinessID", bussinessType.getBussinessID());
        //参数2。busSpecies
        paraMap.put("busSpecies", bussinessType.getBusSpecies());
        //参数3。prefixContract
        paraMap.put("prefixContract", bussinessType.getPrefixContract());
        //参数4。busInstroction
        paraMap.put("busInstroction", bussinessType.getBusInstroction());
        //参数设置结束。

        //调用Dao层BussinessTypeDao类的searchBussinessTypes方法,得到满足条件的记录集合,
        //并绑定到pagination表格控件上,返回之
        return bussinessTypeDao.searchBussinessTypes(pagination, paraMap);
    }

    /**
     * This method is for admin to get the BussinessType based on special Long id.
     *
     * @param id (the physic id of the BussinessType : Long)
     * @return BussinessType object for search result
     * @throws TlmsServiceException
     */
    public BussinessType getBussinessType(Long id) throws TlmsServiceException {
        //调用Dao层BussinessTypeDao类的getBussinessType方法,得到BussinessType,并返回
        return bussinessTypeDao.getBussinessType(id);
    }

    /**
     * This method is for admin to save the BussinessType based on special BussinessType object.
     *
     * @param bussinessType (contains context to save, need not id, created & updated info)
     * @throws TlmsServiceException
     */
    public void saveBussinessType(BussinessType bussinessType) throws TlmsServiceException {
        //验证记录是否存在
        if (validateConflictBussinessTypeId(bussinessType.getId())) {
            //已经存在
            throw new TlmsServiceException(TlmsServiceErrorCodes.SERVICE_ERROR_AD008);
        }
        //保存记录
        bussinessTypeDao.saveBussinessType(bussinessType);

        //系统日志:
        //Log log = new Log();
        //log.setEmpId(String.valueOf(relationInfo.getID()));
        // log.setActionCode(GlobalConstants.LOG_ACTION_TYPE_CREATE_USER);
        //log.populateCreateBean(relationInfo.getCreatedId());
        // logService.saveLog(log);
    }

    /**
     * This method is for admin to update the BussinessType based on special BussinessType object.
     *
     * @param bussinessType (contains context to save, need not updated info)
     * @throws TlmsServiceException
     */
    public void updateBussinessType(BussinessType bussinessType) throws TlmsServiceException {
        //更新记录
        bussinessTypeDao.saveBussinessType(bussinessType);
    }

    /**
     * This method is for admin to remove the BussinessTypes based on checked BussinessType.
     *
     * @param ids    (the array of selected BussinessType physic id, string value.)
     * @param userId (logined user physic id, Long value)
     * @throws TlmsServiceException
     */
    public void removeBussinessTypes(String[] ids, Long userId) throws TlmsServiceException {
        //遍历选中将要删除的记录的IS
        for (int i = 0; i < ids.length; i++) {
            //得到要删除的记录对应的对象
            BussinessType bussinessType = (BussinessType) bussinessTypeDao.getObject(BussinessType.class, new Long(ids[i]));

            //bussinessType对象不存在
            if (bussinessType == null) {
                throw new TlmsServiceException(TlmsServiceErrorCodes.SERVICE_ERROR_AD009);
            }
            //删除
            bussinessTypeDao.removeBussinessType(bussinessType.getId());

            //系统日志:
            //Log log = new Log();
            //log.setEmpId(String.valueOf(relationInfo.getID()));
            //log.setActionCode(GlobalConstants.LOG_ACTION_TYPE_CREATE_USER);
            //log.populateCreateBean(relationInfo.getCreatedId());
            //logService.saveLog(log);
        }
    }
//relationInfo service methods End--------------------------------------

//private method Begin----------------------------------------------------

    /**
     * This method is to validate if the BussinessType with the specific BussinessTypeId has existed
     *
     * @param Id
     * @return boolean
     * @throws TlmsServiceException
     */
    private boolean validateConflictBussinessTypeId(Long Id) throws TlmsServiceException {
        if (Id == null) {
            return false;
        } else {
            return this.getBussinessType(Id) != null;
        }

    }

//private method End-------------------------------------------------------

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -