Skip to content

Commit

Permalink
Merge pull request #4 from easywecom/dev
Browse files Browse the repository at this point in the history
V1.18.0版本更新
  • Loading branch information
lianluoyi authored Aug 10, 2022
2 parents aa05754 + f7371fb commit a0fea88
Show file tree
Hide file tree
Showing 3,055 changed files with 123,675 additions and 681 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 8 additions & 7 deletions easywecom-admin/pom.xml → easyink-admin/pom.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>easywecom</artifactId>
<groupId>com.easywecom</groupId>
<artifactId>easyink</artifactId>
<groupId>com.easyink</groupId>
<version>3.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>easywecom-admin</artifactId>
<artifactId>easyink-admin</artifactId>

<description>
web服务入口
Expand Down Expand Up @@ -56,17 +56,18 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>com.easywecom</groupId>
<artifactId>easywecom-quartz</artifactId>
<groupId>com.easyink</groupId>
<artifactId>easyink-quartz</artifactId>
</dependency>

<!-- 企业微信模块-->
<dependency>
<groupId>com.easywecom</groupId>
<artifactId>easywecom-wecom</artifactId>
<groupId>com.easyink</groupId>
<artifactId>easyink-wecom</artifactId>
</dependency>
<!--腾讯云-->
<dependency>
Expand Down
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions easyink-admin/src/main/java/com/easyink/EasyWeComApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.easyink;

import com.dtflys.forest.springboot.annotation.ForestScan;
import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
* 类名:启动程序
* @author: 1*+
* @date: 2021-08-17 14:18
*/
@Slf4j
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class})
@MapperScan("com.easyink.*.mapper")
@ForestScan(basePackages = {"com.easyink.wecom.client", "com.easyink.wecom.wxclient"})
@EnableAsync
public class EasyWeComApplication {
public static void main(String[] args) {
SpringApplication.run(EasyWeComApplication.class, args);
log.info("\n" +
" ,----, ,----, \n" +
" ,/ .`| ,/ .`| \n" +
" .--.--. ,` .' : ,---, ,-.----. ,` .' : .--.--. ,----.. ,----.. ,---,. .--.--. .--.--. \n" +
" / / '. ; ; / ' .' \\ \\ / \\ ; ; / / / '. ,--, / / \\ / / \\ ,' .' | / / '. / / '. \n" +
"| : /`. / .'___,/ ,' / ; '. ; : \\ .'___,/ ,' | : /`. / ,'_ /| | : : | : : ,---.' | | : /`. / | : /`. / \n" +
"; | |--` | : | : : \\ | | .\\ : | : | ; | |--` .--. | | : . | ;. / . | ;. / | | .' ; | |--` ; | |--` \n" +
"| : ;_ ; |.'; ; : | /\\ \\ . : |: | ; |.'; ; | : ;_ ,'_ /| : . | . ; /--` . ; /--` : : |-, | : ;_ | : ;_ \n" +
" \\ \\ `. `----' | | | : ' ;. : | | \\ : `----' | | \\ \\ `. | ' | | . . ; | ; ; | ; : | ;/| \\ \\ `. \\ \\ `. \n" +
" `----. \\ ' : ; | | ;/ \\ \\ | : . / ' : ; `----. \\ | | ' | | | | : | | : | | : .' `----. \\ `----. \\ \n" +
" __ \\ \\ | | | ' ' : | \\ \\ ,' ; | | \\ | | ' __ \\ \\ | : | | : ' ; . | '___ . | '___ | | |-, __ \\ \\ | __ \\ \\ | \n" +
" / /`--' / ' : | | | ' '--' | | ;\\ \\ ' : | / /`--' / | ; ' | | ' ' ; : .'| ' ; : .'| ' : ;/| / /`--' / / /`--' / \n" +
"'--'. / ; |.' | : : : ' | \\.' ; |.' '--'. / : | : ; ; | ' | '/ : ' | '/ : | | \\ '--'. / '--'. / \n" +
" `--'---' '---' | | ,' : : :-' '---' `--'---' ' : `--' \\ | : / | : / | : .' `--'---' `--'---' \n" +
" `--'' | |.' : , .-./ \\ \\ .' \\ \\ .' | | ,' \n" +
" `---' `--`----' `---` `---` `----' \n" +
" \n");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.easyink;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
* web容器中进行部署
*
* @author admin
*/
public class EasyWeComServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(EasyWeComApplication.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.easyink.web.controller.common;

import com.easyink.common.constant.Constants;
import com.easyink.common.core.domain.AjaxResult;
import com.easyink.common.core.redis.RedisCache;
import com.easyink.common.utils.sign.Base64;
import com.easyink.common.utils.uuid.IdUtils;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.google.code.kaptcha.Producer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
* 类名: CaptchaController
*
* @author: 1*+
* @date: 2021-08-27 15:52
*/
@Api(value = "CaptchaController", tags = "验证码接口")
@ApiSupport(order = 1, author = "1*+")
@RestController
public class CaptchaController {
@Resource(name = "captchaProducer")
private Producer captchaProducer;

@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;

@Autowired
private RedisCache redisCache;

// 验证码类型
@Value("${ruoyi.captchaType}")
private String captchaType;

private static final String MATH = "math";

/**
* 生成验证码
*/
@ApiOperation("生成验证码")
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) {
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;

String capStr;
String code;
BufferedImage image;

// 生成验证码
if (MATH.equals(captchaType)) {
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
image = captchaProducerMath.createImage(capStr);
} else {
capStr = code = captchaProducer.createText();
image = captchaProducer.createImage(capStr);
}

redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
try {
ImageIO.write(image, "jpg", os);
} catch (IOException e) {
return AjaxResult.error(e.getMessage());
}

AjaxResult ajax = AjaxResult.success();
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package com.easyink.web.controller.common;

import com.easyink.common.config.RuoYiConfig;
import com.easyink.common.config.ServerConfig;
import com.easyink.common.constant.Constants;
import com.easyink.common.core.domain.AjaxResult;
import com.easyink.common.core.domain.FileVo;
import com.easyink.common.utils.StringUtils;
import com.easyink.common.utils.file.FileUploadUtils;
import com.easyink.common.utils.file.FileUtils;
import com.easyink.framework.web.domain.server.SysFile;
import com.easyink.framework.web.service.FileService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* 类名: CommonController
*
* @author: 1*+
* @date: 2021-08-27 16:09
*/
@Slf4j
@RestController
@ApiSupport(order = 2, author = "1*+")
@Api(value = "CommonController", tags = "通用接口")
public class CommonController {

@Autowired
private ServerConfig serverConfig;

@Autowired
private FileService fileService;

/**
* 通用下载请求
*
* @param fileName 文件名称
* @param delete 是否删除
*/
@ApiOperation(value = "通用下载")
@GetMapping("common/download")
public void fileDownload(@ApiParam("文件名") String fileName, @ApiParam("是否删除本地文件") Boolean delete, HttpServletResponse response, HttpServletRequest request) {
try {
if (!FileUtils.isValidFilename(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = RuoYiConfig.getDownloadPath() + fileName;

response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
FileUtils.writeBytes(filePath, response.getOutputStream());
if (Boolean.TRUE.equals(delete)) {
FileUtils.deleteFile(filePath);
}
} catch (Exception e) {
log.error("下载文件失败", e);
}
}

/**
* 通用上传请求
*/
@ApiOperation(value = "通用上传")
@PostMapping(value = "/common/upload", headers = "content-type=multipart/form-data")
public AjaxResult uploadFile(@ApiParam(value = "上传文件", required = true) MultipartFile file) {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}

/**
* 通用上传请求
*/
@ApiOperation(value = "上传域名校验证书")
@PostMapping("/common/uploadCert")
public AjaxResult uploadCert(@ApiParam("上传域名文件") MultipartFile file) {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.uploadCert(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}


/**
* 本地资源通用下载
*/
@ApiOperation(value = "本地资源下载")
@GetMapping("/common/download/resource")
public void resourceDownload(@ApiParam("资源名") String name, HttpServletRequest request, HttpServletResponse response) throws IOException {
// 本地资源路径
String localPath = RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}


/**
* 网络资源通用下载
*/
@ApiOperation(value = "网络资源通用下载")
@GetMapping("/common/download/url")
public void webResourceDownload(@ApiParam("资源链接") String url, HttpServletRequest request, HttpServletResponse response) throws IOException {
FileUtils.downloadFile(url, response.getOutputStream());
}


/**
* 通用上传请求
*/
@ApiOperation(value = "上传到云存储")
@PostMapping("/common/uploadFile2Cos")
public AjaxResult uploadFile2Cos(@ApiParam("资源文件") MultipartFile file,String fileName) {
try {
SysFile sysFile;
if (StringUtils.isNotBlank(fileName)) {
sysFile = fileService.upload2Cos(file, fileName);
} else {
sysFile = fileService.upload(file);
}
return AjaxResult.success(
FileVo.builder()
.fileName(sysFile.getFileName())
.url(sysFile.getImgUrlPrefix() + sysFile.getFileName())
.build()
);
} catch (Exception e) {
return AjaxResult.error("不支持当前文件上传或文件过大建议传20MB以内的文件");
}
}


/**
* 获取图片
*/
@ApiOperation("获取图片")
@GetMapping("/common/findImage")
public void findImage(HttpServletResponse response, @ApiParam("文件名") String fileName) {
fileService.findImage(fileName, response);
}





}
Loading

0 comments on commit a0fea88

Please sign in to comment.