Commit 363446af authored by 赵建伟's avatar 赵建伟

update codes

parent eaff3d18
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="18c38e3b-9b7f-4a3f-b141-edcb320b1d24" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/sbin/start_service.sh" beforeDir="false" afterPath="$PROJECT_DIR$/sbin/start_service.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sbin/stop_service.sh" beforeDir="false" afterPath="$PROJECT_DIR$/sbin/stop_service.sh" afterDir="false" />
</list>
<list default="true" id="18c38e3b-9b7f-4a3f-b141-edcb320b1d24" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -121,7 +118,7 @@
<workItem from="1587982524517" duration="5052000" />
<workItem from="1588152481879" duration="139000" />
<workItem from="1588154352798" duration="195000" />
<workItem from="1588220085338" duration="4354000" />
<workItem from="1588220085338" duration="4971000" />
</task>
<task id="LOCAL-00001" summary="add init codes.">
<created>1587723565207</created>
......
......@@ -214,7 +214,7 @@
<workItem from="1584945647680" duration="4469000" />
<workItem from="1588148891822" duration="2318000" />
<workItem from="1588152718016" duration="1463000" />
<workItem from="1588154601852" duration="16438000" />
<workItem from="1588154601852" duration="17055000" />
</task>
<servers />
</component>
......
package com.gmei.data.gateway.server.endpoint;
import com.gmei.data.gateway.server.dto.ExcelGenDto;
import com.gmei.data.gateway.server.service.ExcelService;
import com.gmei.data.gateway.server.service.EmailService;
import com.gmei.data.gateway.server.service.SparksqlService;
import com.gmei.data.gateway.server.service.BiReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -15,24 +12,17 @@ import org.springframework.web.bind.annotation.RestController;
public class BiReportEndpoint {
@Autowired
public EmailService emailService;
@Autowired
public ExcelService excelService;
@Autowired
public SparksqlService sparksqlService;
public BiReportService biReportService;
@ResponseBody
@RequestMapping(value = "/genExcel")
public int genExcel(@RequestParam String hql){
ExcelGenDto resultDto = sparksqlService.getResultDto(hql);
return 0;
public int genExcel(@RequestParam String name){
return biReportService.genExcel(name);
}
@ResponseBody
@RequestMapping(value = "/sendEmail")
public int sendEmail(@RequestParam String hql){
return 0;
public int sendEmail(@RequestParam String name,@RequestParam String subject){
return biReportService.sendEmail(name,subject);
}
}
package com.gmei.data.gateway.server.service;
public interface BiReportService {
int genExcel(String name);
int sendEmail(String name,String subject);
}
package com.gmei.data.gateway.server.service;
public interface EmailService {
void sendAttachmentsMail(String to,String cc,String subject);
int sendAttachmentsMail(String to,String cc,String subject);
}
package com.gmei.data.gateway.server.service.impl;
import com.gmei.data.gateway.server.dto.ExcelGenDto;
import com.gmei.data.gateway.server.service.BiReportService;
import com.gmei.data.gateway.server.service.ExcelService;
import com.gmei.data.gateway.server.service.EmailService;
import com.gmei.data.gateway.server.service.ExcelService;
import com.gmei.data.gateway.server.service.SparksqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @ClassName BiReportServiceImpl
......@@ -11,20 +14,30 @@ import org.springframework.beans.factory.annotation.Autowired;
* @Date 2020/4/30
* @Version V1.0
**/
@Service
public class BiReportServiceImpl implements BiReportService {
@Autowired
private ExcelService excelService;
public EmailService emailService;
@Autowired
private EmailService emailService;
public int genExcel(){
public ExcelService excelService;
@Autowired
public SparksqlService sparksqlService;
return 0;
@Override
public int genExcel(String name){
ExcelGenDto resultDto = sparksqlService.getResultDto(name);
return excelService.genExcel(resultDto, "测试示例");
}
public int sendEmail(){
return 0;
@Override
public int sendEmail(String name,String subject){
int rs = 0;
ExcelGenDto resultDto = sparksqlService.getResultDto(name);
int genExcelRs = excelService.genExcel(resultDto, subject);
if(0 == genExcelRs){
rs = emailService.sendAttachmentsMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","测试示例");
}
return rs;
}
}
......@@ -31,7 +31,8 @@ public class EmailServiceImpl implements EmailService {
private static final Logger logger = LoggerFactory.getLogger(EmailServiceImpl.class);
@Override
public void sendAttachmentsMail(String to,String cc,String subject){
public int sendAttachmentsMail(String to,String cc,String subject){
int rs = 0;
MimeMessage message = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(message, true);
......@@ -53,6 +54,8 @@ public class EmailServiceImpl implements EmailService {
logger.info("带附件的邮件已经发送。");
} catch (MessagingException e) {
logger.error("发送带附件的邮件时发生异常!", e);
rs = -1;
}
return rs;
}
}
package com.gmei.data.gateway.server.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -17,10 +16,6 @@ import org.springframework.test.context.junit4.SpringRunner;
public class BiReportServiceTest {
@Autowired
private EmailService emailService;
private BiReportService biReportService;
@Test
public void testSendAttachmentsMail() {
emailService.sendAttachmentsMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","敏感稽查元数据库账户");
}
}
package com.gmei.data.gateway.server.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @ClassName EmailServiceTest
* @Author apple
* @Date 2020/4/30
* @Version V1.0
**/
@SpringBootTest
@RunWith(SpringRunner.class)
public class EmailServiceTest {
@Autowired
private EmailService emailService;
@Test
public void testSendAttachmentsMail() {
emailService.sendAttachmentsMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","敏感稽查元数据库账户");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment