This commit is contained in:
xiangwb
2018-04-10 14:39:00 +08:00
parent 80802269ac
commit 84598d7603
46 changed files with 0 additions and 4030 deletions
@@ -1,26 +0,0 @@
package com.xwbing.configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
/**
* 说明: 定时任务定时类
* 项目名称: boot-module-demo
* 创建时间: 2017/5/10 16:36
* 作者: xiangwb
*/
@Configuration
@EnableScheduling // 启用定时任务
public class SchedulingConfig {
private static final Logger logger = LoggerFactory.getLogger(SchedulingConfig.class);
@Scheduled(cron = "0 */30 * * * ?") // 每半小时执行一次
public void scheduler() {
logger.info("scheduled ==================");
//TODO
}
}
@@ -23,7 +23,6 @@ public class SwaggerConfig {
@Bean
public Docket sysDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("system")
.apiInfo(sysApiInf())
.select()
.apis(RequestHandlerSelectors.basePackage("com.xwbing.controller.sys"))
@@ -40,25 +39,4 @@ public class SwaggerConfig {
.version("1.0.0")
.build();
}
@Bean
public Docket otherDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("other")
.apiInfo(otherApiInf())
.select()
.apis(RequestHandlerSelectors.basePackage("com.xwbing.controller.other"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo otherApiInf() {
return new ApiInfoBuilder()
.title("RESTful API Document")
.description("other接口文档")
.termsOfServiceUrl("http://localhost:8080/swagger-ui.html")
.contact(new Contact("项伟兵", "https://github.com/xiangwbs/boot-module-pro.git", "xiangwbs@163.com"))
.version("1.0.0")
.build();
}
}
@@ -1,69 +0,0 @@
package com.xwbing.controller.other;
import com.alibaba.fastjson.JSONObject;
import com.xwbing.annotation.LogInfo;
import com.xwbing.service.other.MailService;
import com.xwbing.util.JsonResult;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 项目名称: sb-boot-module-demo
* 创建时间: 2017/9/18 13:42
* 作者: xiangwb
* 说明:邮件测试控制层
*/
@Api(tags = "mailApi", description = "邮件测试相关接口")
@RestController
@RequestMapping("/mail/")
public class MailTestControl {
@Resource
private MailService mailService;
@LogInfo("发送纯文本邮件")
@GetMapping("sendSimpleMail")
@ApiOperation(value = "发送纯文本邮件")
public JSONObject sendSimpleMail() {
RestMessage restMessage = mailService.sendSimpleMail("786461501@qq.com", "测试邮件", "收到一个纯文本邮件");
return JsonResult.toJSONObj(restMessage);
}
@LogInfo("发送html格式邮件")
@GetMapping("sendHtmlMail")
@ApiOperation(value = "发送html格式邮件")
public JSONObject sendHtmlMail() {
String content = "<html>" +
"<body>" +
"<h3>hello world ! 这是一封Html邮件!</h3>" +
"</body>" +
"</html>";
RestMessage restMessage = mailService.sendHtmlMail("786461501@qq.com", "html测试邮件", content);
return JsonResult.toJSONObj(restMessage);
}
@LogInfo("发送带附件邮件")
@GetMapping("sendAttachmentsMail")
@ApiOperation(value = "发送带附件邮件")
public JSONObject sendAttachmentsMail() {
String path = "C:\\Users\\admin\\Desktop\\qq.txt";
RestMessage restMessage = mailService.sendAttachmentsMail("786461501@qq.com", "附件测试邮件", "收到一个带附件邮件", path);
return JsonResult.toJSONObj(restMessage);
}
@LogInfo("发送文本内嵌图片邮件")
@GetMapping("sendInlineResourceMail")
@ApiOperation(value = "发送文本内嵌图片邮件")
public JSONObject sendInlineResourceMail() {
String rscId = "file";
String content = "<html><body>这是有图片的邮件:<img src=\'cid:" + rscId + "\'></body></html>";
String imgPath = "C:\\Users\\admin\\Desktop\\0000001.png";
RestMessage restMessage = mailService.sendInlineResourceMail("786461501@qq.com", "内嵌图片测试邮件", content, imgPath, rscId);
return JsonResult.toJSONObj(restMessage);
}
}
@@ -1,169 +0,0 @@
package com.xwbing.controller.other;
import com.alibaba.fastjson.JSONObject;
import com.xwbing.annotation.LogInfo;
import com.xwbing.domain.entity.ExpressInfo;
import com.xwbing.domain.entity.vo.ExpressInfoVo;
import com.xwbing.redis.RedisService;
import com.xwbing.service.other.CookieSessionService;
import com.xwbing.service.other.ExpressDeliveryService;
import com.xwbing.service.other.QRCodeZipService;
import com.xwbing.util.HttpUtil;
import com.xwbing.util.JsonResult;
import com.xwbing.util.RSAUtil;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 说明: 测试控制层
* 项目名称: boot-module-demo
* 创建时间: 2017/5/5 9:21
* 作者: xiangwb
*/
@Api(tags = "testApi", description = "测试相关接口")
@RestController
@RequestMapping("/test/")
public class TestControl {
@Resource
private RedisService redisService;
@Resource
private ExpressDeliveryService expressDeliveryService;
@Resource
private QRCodeZipService qrCodeZipService;
@Resource
private CookieSessionService cookieSessionService;
private final Logger logger = LoggerFactory.getLogger(TestControl.class);
@LogInfo("redis功能测试")
@GetMapping("redis")
public void redis() {
redisService.set("redis", "xwbing");
String s = redisService.get("redis");
logger.info("redis获取的数据为:" + s);
}
@LogInfo("log功能测试")
@GetMapping("log")
public void log() {
logger.info("info test");
logger.error("error test");
}
@LogInfo("获取快递列表")
@GetMapping("listShipperCode")
public JSONObject listShipperCode() {
List<JSONObject> list = expressDeliveryService.listShipperCode();
return JsonResult.toJSONObj(list, "");
}
@LogInfo("快递查询")
@PostMapping("expressInfo")
public JSONObject getExpressInfo(@RequestBody ExpressInfo info) {
if (StringUtils.isEmpty(info.getLogisticCode()) || StringUtils.isEmpty(info.getShipperCode())) {
return JsonResult.toJSONObj("快递公司或物流单号不能为空");
}
ExpressInfoVo infoVo = expressDeliveryService.queryOrderTraces(info);
return JsonResult.toJSONObj(infoVo, "查询快递信息成功");
}
@LogInfo("生成二维码")
@PostMapping("createQRCode")
public JSONObject createQRCode(@RequestParam String name, @RequestParam String text) {
RestMessage qrCode = qrCodeZipService.createQRCode(name, text);
return JsonResult.toJSONObj(qrCode);
}
@LogInfo("解析二维码")
@GetMapping("decode")
public JSONObject decode(@RequestParam String path) {
if (StringUtils.isEmpty(path)) {
return JsonResult.toJSONObj("二维码图片路径不能为空");
}
File file = new File(path);
RestMessage decode = qrCodeZipService.decode(file);
return JsonResult.toJSONObj(decode);
}
@LogInfo("导出zip")
@GetMapping("batchGetImage")
public JSONObject batchGetImage(HttpServletResponse response, @RequestParam String[] names, @RequestParam String fileName) {
if (StringUtils.isEmpty(fileName)) {
return JsonResult.toJSONObj("zip名称不能为空");
}
RestMessage restMessage = qrCodeZipService.batchGetImage(response, names, fileName);
return JsonResult.toJSONObj(restMessage);
}
@LogInfo("rsa")
@GetMapping("rsa")
public void rsa() {
String en = RSAUtil.encrypt("123456");
String de = RSAUtil.decrypt(en);
System.out.println(de);
}
@LogInfo("httpUtil")
@PostMapping("httpUtil")
public JSONObject httpUtil(@RequestBody JSONObject param) {
// String url = "http://localhost:8080/user/listAll";
// return HttpClientUtil.get(url);
String url = "http://localhost:8080/user/save";
return HttpUtil.postByJson(url, param);
}
@LogInfo("session")
@GetMapping("session")
public JSONObject session(HttpServletRequest request) {
return JsonResult.toJSONObj(cookieSessionService.session(request));
}
@LogInfo("cookie")
@GetMapping("cookie")
public JSONObject cookie(HttpServletRequest request, HttpServletResponse response) {
return JsonResult.toJSONObj(cookieSessionService.cookie(response, request));
}
@LogInfo("completableFuture")
@GetMapping("completableFuture")
public JSONObject completableFuture() {
return JsonResult.toJSONObj(thenCombine(), "");
}
private JSONObject thenCombine() {
return CompletableFuture.supplyAsync(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "hello";
}).thenCombine(CompletableFuture.supplyAsync(() -> {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//出现异常,异常会被限制在执行任务的线程范围内
if (1 == 1) {
throw new RuntimeException("545456");
}
return "world";
}), (s1, s2) -> {
JSONObject object = new JSONObject();
object.put("s1", s1);
object.put("s2", s2);
return object;
}).join();
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B