Merge branch 'template' into develop
# Conflicts: # nflg-wms-admin/pom.xml
This commit is contained in:
commit
1804a9f122
|
|
@ -34,33 +34,6 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-ldap</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>logback-adapter</artifactId>-->
|
||||
<!-- <groupId>com.alibaba.nacos</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-bootstrap</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.projectlombok</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
|
|
@ -100,6 +73,16 @@
|
|||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tech.powerjob</groupId>
|
||||
<artifactId>powerjob-worker-spring-boot-starter</artifactId>
|
||||
<version>5.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tech.powerjob</groupId>
|
||||
<artifactId>powerjob-client</artifactId>
|
||||
<version>5.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -18,16 +18,8 @@ public class AdminApplication {
|
|||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
log.info("【管理端】已启动");
|
||||
// log.info("当前日志实现类:" + LoggerFactory.getILoggerFactory().getClass().getName());
|
||||
log.info("---------------------- Sa-Token SSO 模式二 Client 端启动成功 ----------------------");
|
||||
log.info("配置信息:" + SaSsoManager.getClientConfig());
|
||||
|
||||
// LdapService ldapService = new LdapService();
|
||||
// ldapService.init("192.168.0.2", 389, "commpub@nflg", "Nflg2019#", "OU=福建南方路面机械有限公司,DC=nflg");
|
||||
// LdapDepartmentDTO department = ldapService.getDepartmentTree("OU=产品事业部");
|
||||
// System.out.println(JSONUtil.toJsonStr(department));
|
||||
// List<LdapUserDTO> users = ldapService.getUsers();
|
||||
// System.out.println(JSONUtil.toJsonStr(users));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.nflg.wms.admin.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import tech.powerjob.client.PowerJobClient;
|
||||
|
||||
@Configuration
|
||||
public class PowerJobClientConfig {
|
||||
|
||||
@Value("${powerjob.worker.server-address}")
|
||||
private String serverAddress;
|
||||
|
||||
@Value("${powerjob.worker.app-name}")
|
||||
private String appName;
|
||||
|
||||
@Value("${powerjob.client.password}")
|
||||
private String password;
|
||||
|
||||
@Bean
|
||||
public PowerJobClient initPowerJobClient() {
|
||||
return new PowerJobClient(serverAddress, appName, password);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,10 +32,27 @@
|
|||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="POWERJOB_WORKER_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${logDir}/powerjob-worker.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${logDir}/powerjob-worker.%d{yyyy-MM-dd}.log</FileNamePattern>
|
||||
<MaxHistory>7</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<append>true</append>
|
||||
</appender>
|
||||
|
||||
<logger name="com.alibaba.nacos" level="warn" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="tech.powerjob" level="INFO" additivity="false">
|
||||
<appender-ref ref="POWERJOB_WORKER_APPENDER" />
|
||||
</logger>
|
||||
|
||||
<!-- 默认配置 -->
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
|
|
|
|||
|
|
@ -119,6 +119,11 @@
|
|||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.5.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package com.nflg.wms.starter.config;
|
||||
|
||||
import io.minio.BucketExistsArgs;
|
||||
import io.minio.MakeBucketArgs;
|
||||
import io.minio.MinioClient;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@ConditionalOnProperty(name = "file.upload.type", havingValue = "minio")
|
||||
public class MinIOConfig {
|
||||
|
||||
@Value("${minio.endpoint}")
|
||||
private String endpoint;
|
||||
|
||||
@Value("${minio.access-key}")
|
||||
private String accessKey;
|
||||
|
||||
@Value("${minio.secret-key}")
|
||||
private String secretKey;
|
||||
|
||||
@Value("${minio.bucket-name}")
|
||||
private String bucketName;
|
||||
|
||||
private MinioClient client;
|
||||
|
||||
@Bean
|
||||
public MinioClient initMinioClient() throws Exception{
|
||||
client= MinioClient.builder()
|
||||
.endpoint(endpoint)
|
||||
.credentials(accessKey, secretKey)
|
||||
.build();
|
||||
// 自动创建 bucket(如果不存在)
|
||||
if (!client.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) {
|
||||
client.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
try {
|
||||
client.close();
|
||||
} catch (Exception e) {
|
||||
log.error("MinIO 销毁出错", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ public interface FileUploadService {
|
|||
* @return 可访问的url
|
||||
* @throws IOException
|
||||
*/
|
||||
String upload(String filePath, MultipartFile file) throws IOException;
|
||||
String upload(String filePath, MultipartFile file) throws Exception;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
|
|
@ -25,6 +25,6 @@ public interface FileUploadService {
|
|||
* @return 可访问的url
|
||||
* @throws IOException
|
||||
*/
|
||||
String upload(String filePath, InputStream stream) throws IOException;
|
||||
String upload(String filePath, InputStream stream) throws Exception;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.nflg.wms.starter.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.wms.starter.service.FileUploadService;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "file.upload.type", havingValue = "minio")
|
||||
public class MinIOServiceImpl implements FileUploadService {
|
||||
|
||||
@Value("${minio.bucket-name}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${minio.endpoint}")
|
||||
private String domain;
|
||||
|
||||
@Resource
|
||||
private MinioClient minioClient;
|
||||
|
||||
@Override
|
||||
public String upload(String filePath, MultipartFile file) throws Exception {
|
||||
return upload(filePath, file.getInputStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(String filePath, InputStream stream) throws Exception {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(filePath)
|
||||
.stream(stream, stream.available(), -1)
|
||||
.build());
|
||||
return StrUtil.format("{}/{}", domain, filePath);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ import java.io.InputStream;
|
|||
@Service
|
||||
@ConditionalOnProperty(name = "file.upload.type", havingValue = "oss")
|
||||
@Slf4j
|
||||
public class OSSFileUploadService implements FileUploadService {
|
||||
public class OSSFileUploadServiceImpl implements FileUploadService {
|
||||
|
||||
@Resource
|
||||
private OSS ossClient;
|
||||
Loading…
Reference in New Issue