HAP_邮件批量发送

HAP_邮件批量发送_第1张图片
image.png

页面传递参数:

   /**
         * 邮箱发送事件
         */
        sendEmail:function () {
            
            var grid= $("#grid").data("kendoGrid");
            var checked = grid.selectedDataItems();
            var data = JSON.stringify(checked);
            console.log(data)
            $.ajax({
                    //url: '${base.contextPath}/ora/20796/hap/demo/send/email',
                    url: '${base.contextPath}/wht/ora/20796/student/send/email',
                    type: 'POST',
                    dataType: "json",
                    data:data,
                    contentType: "application/json",
                    success: function (result) {
                        if (result.success) {
                            kendo.ui.showInfoDialog({
                                title: $l('hap.tip.info'),
                                message: $l("hap.success")
                            });
                            viewModel.query();
                        } else {
                            kendo.ui.showErrorDialog({
                                title: $l('hap.error'),
                                message: result.message
                            });
                        }
                    }
                });

        },

后台接收参数:

  • 接口:
package wht.ora20796.service;

import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hap.system.service.IBaseService;
import wht.ora20796.dto.Ora20796Student;

import java.io.InputStream;
import java.util.List;

public interface IOra20796StudentService extends IBaseService, ProxySelf{
    /**
     * 邮箱发送
     */
    ResponseData sendEmail(IRequest iRequest, List dto)throws Exception;
    ResponseData importExcel(InputStream is, String fileName) throws Exception;
}
  • 实现类
/**
     * 邮箱发送
     *
     * @param iRequest
     * @return
     * @throws Exception
     */
    @Override
    public ResponseData sendEmail(IRequest request,List dto) throws Exception {
        ResponseData responseData = new ResponseData();
        HashMap templateData = new HashMap();

        /*templateData.put("StudentName", "This is a test email from Demo page");
        templateData.put("UserName", request.getUserName());
        //收件人,可以有多人
        ArrayList receivers = new ArrayList<>();
        MessageReceiver messageReceiver = new MessageReceiver();
        messageReceiver.setMessageAddress("[email protected]");
        //messageReceiver.setMessageAddress("[email protected]");
        messageReceiver.setMessageType(ReceiverTypeEnum.NORMAL.getCode());
        receivers.add(messageReceiver);
        //messageService.sendMessage(request, "ACT_EMAIL_NOTIFIER", templateData, receivers, (List) null);
        //messageService.sendMessage(request, "ORA_20796_DEMO3", templateData, receivers, (List) null);
        messageService.sendMessage(request, "ORA_20796_HOMEWORK", templateData, receivers, (List) null);
       */
        for(Ora20796Student student:dto){
            ArrayList receivers = new ArrayList<>();
            templateData.put("StudentName",student.getStudentName());
            templateData.put("UserName",request.getUserName());
            MessageReceiver messageReceiver = new MessageReceiver();
            messageReceiver.setMessageAddress(student.getEmail());
            messageReceiver.setMessageType(ReceiverTypeEnum.NORMAL.getCode());
            receivers.add(messageReceiver);
            messageService.sendMessage(request,"ORA_20796_HOMEWORK",templateData,receivers,(List) null );
        }

        return responseData;
    }

你可能感兴趣的:(HAP_邮件批量发送)