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

📄 operatorserviceimpl.java

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

import com.szmx.framework.base.model.Pagination;
import com.szmx.framework.base.service.impl.BaseServiceImpl;
import com.szmx.tlms.admin.model.Operator;
import com.szmx.tlms.admin.service.OperatorService;
import com.szmx.tlms.admin.service.LogService;
import com.szmx.tlms.admin.dao.OperatorDAO;
import com.szmx.tlms.TlmsServiceException;
import com.szmx.tlms.TlmsServiceErrorCodes;

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

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2006-7-31
 * Time: 11:06:41
 * To change this template use File | Settings | File Templates.
 */
public class OperatorServiceImpl extends BaseServiceImpl implements OperatorService {


    /**
     * 通过Spring注入 BussinessTypeDAO实现类:BussinessTypeDAOImpl
     */
    private OperatorDAO operatorDAO;

    public void setOperatorDAO(OperatorDAO operatorDAO) {
        this.operatorDAO = operatorDAO;
    }

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

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

    // Operator Service methods declare begin: ----------------------------------------

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

        //参数设置开始:
        //参数1。OperatorID
        paraMap.put("operatorID", operator.getOperatorID());
        //参数2。OperatorName
        paraMap.put("operatorName", operator.getOperatorName());
        //参数3。Sex
        paraMap.put("sex", operator.getSex());
        //参数4。OperatorType
        paraMap.put("operatorType", operator.getOperatorType());
        //参数5。LoginName
        paraMap.put("loginName", operator.getLoginName());
        //参数6。Birthday
        paraMap.put("birthday", operator.getBirthday());
        //参数7。EnterDate
        paraMap.put("enterDate", operator.getEnterDate());
        //参数8。Mobile
        paraMap.put("mobile", operator.getMobile());
        //参数9。Tel
        paraMap.put("tel", operator.getTel());
        //参数10。Other
        paraMap.put("other", operator.getOther());
        //参数11。Email
        paraMap.put("email", operator.getEmail());
        //参数12。Remark
        paraMap.put("remark", operator.getRemark());
        //参数设置结束。

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

    /**
     * This method is for admin to get the Operator based on special Long id.
     *
     * @param id (the physic id of the Operator : Long)
     * @return Operator object for search result
     * @throws TlmsServiceException
     */
    public Operator getOperator(Long id) throws TlmsServiceException {
        return operatorDAO.getOperator(id);
    }


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

    /**
     * This method is for admin to update the Operator based on special Operator object.
     *
     * @param operator (contains context to save, need not updated info)
     * @throws TlmsServiceException
     */
    public void updateOperator(Operator operator) throws TlmsServiceException {
        //更新记录
        operatorDAO.saveOperator(operator);
    }

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

            //bussinessType对象不存在
            if (operator == null) {
                throw new TlmsServiceException(TlmsServiceErrorCodes.SERVICE_ERROR_AD009);
            }
            //删除
            operatorDAO.removeOperator(operator.getId());
        }
    }
// Operator Service methods declare end: ----------------------------------------

// Department Managerment begin: ----------------------------------------

    /**
     * This method is for admin to get all departments
     *
     * @param pagination (the pagination object)
     * @param paraMap    (Map) [empty map to get all department]
     * @throws TlmsServiceException
     */
    public Pagination searchDepartment(Pagination pagination, Map paraMap) throws TlmsServiceException {
        return operatorDAO.searchDepartment(pagination, paraMap);
    }

    /**
     * This method is for admin to get all departments
     *
     * @throws TlmsServiceException
     */
    public List getDepartmentList() throws TlmsServiceException {
        return operatorDAO.getDepartmentList();
    }
// Department Managerment 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 validateConflictOperatorId(Long Id) throws TlmsServiceException {
        if (Id == null) {
            return false;
        } else {
            return this.getOperator(Id) != null;
        }

    }

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

}

⌨️ 快捷键说明

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