feat(search): search模块基本搭建
This commit is contained in:
parent
e7eb08ca3b
commit
0f06295fc5
|
@ -44,5 +44,18 @@
|
||||||
</jdbc-additional-properties>
|
</jdbc-additional-properties>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="0@47.120.65.66" uuid="80c74a8a-8467-45dc-ad24-8422085124e9">
|
||||||
|
<driver-ref>redis</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<jdbc-driver>jdbc.RedisDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:redis://47.120.65.66:6379/0</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,4 @@
|
||||||
package com.atguigu.ssyx;
|
package com.atguigu.ssyx.common;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
|
@ -14,12 +14,6 @@ bunny:
|
||||||
discovery:
|
discovery:
|
||||||
namespace: ssyx
|
namespace: ssyx
|
||||||
|
|
||||||
redis:
|
|
||||||
host: 47.120.65.66
|
|
||||||
port: 6379
|
|
||||||
database: 2
|
|
||||||
password: "02120212"
|
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpointUrl: "http://129.211.31.58:9000"
|
endpointUrl: "http://129.211.31.58:9000"
|
||||||
bucket-name: ssyx
|
bucket-name: ssyx
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.product.service.FileUploadService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@Api(tags = "文件上传接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("admin/product")
|
||||||
|
public class FileUploadController {
|
||||||
|
@Autowired
|
||||||
|
private FileUploadService fileUploadService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "文件上传")
|
||||||
|
@PostMapping("fileUpload")
|
||||||
|
public Result<String> fileUpload(@RequestBody MultipartFile file) {
|
||||||
|
String filename = fileUploadService.uploadFile(file);
|
||||||
|
return Result.success(filename);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.atguigu.ssyx.product.service;
|
||||||
|
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
public interface FileUploadService {
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*
|
||||||
|
* @param file 上传的文件
|
||||||
|
* @return 文件路径
|
||||||
|
*/
|
||||||
|
String uploadFile(MultipartFile file);
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.atguigu.ssyx.product.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.atguigu.ssyx.common.properties.MinioProperties;
|
||||||
|
import com.atguigu.ssyx.product.service.FileUploadService;
|
||||||
|
import io.minio.BucketExistsArgs;
|
||||||
|
import io.minio.MakeBucketArgs;
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import io.minio.PutObjectArgs;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class FileUploadServiceImpl implements FileUploadService {
|
||||||
|
@Autowired
|
||||||
|
private MinioProperties properties;
|
||||||
|
@Autowired
|
||||||
|
private MinioClient minioClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*
|
||||||
|
* @param file 上传的文件
|
||||||
|
* @return 文件路径
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String uploadFile(MultipartFile file) {
|
||||||
|
String bucketName = properties.getBucketName();
|
||||||
|
String dir = DateUtil.format(new Date(), "yyyy-MM-dd");
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
String filename = dir + "/" + uuid + "-" + file.getOriginalFilename();
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean bucketExists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
|
||||||
|
if (!bucketExists) {
|
||||||
|
log.warn("minio桶不存在:{}", bucketName);
|
||||||
|
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存入图片
|
||||||
|
minioClient.putObject(PutObjectArgs.builder()
|
||||||
|
.bucket(bucketName)
|
||||||
|
.object(filename)
|
||||||
|
.stream(file.getInputStream(), file.getSize(), -1).build());
|
||||||
|
|
||||||
|
return properties.getEndpointUrl() + "/" + properties.getBucketName() + "/" + filename;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,12 +14,6 @@ bunny:
|
||||||
discovery:
|
discovery:
|
||||||
namespace: ssyx
|
namespace: ssyx
|
||||||
|
|
||||||
redis:
|
|
||||||
host: 47.120.65.66
|
|
||||||
port: 6379
|
|
||||||
database: 2
|
|
||||||
password: "02120212"
|
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpointUrl: "http://129.211.31.58:9000"
|
endpointUrl: "http://129.211.31.58:9000"
|
||||||
bucket-name: ssyx
|
bucket-name: ssyx
|
||||||
|
|
|
@ -22,7 +22,11 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- redis的起步依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>com.atguigu</groupId> -->
|
<!-- <groupId>com.atguigu</groupId> -->
|
||||||
<!-- <artifactId>service-product-client</artifactId> -->
|
<!-- <artifactId>service-product-client</artifactId> -->
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.atguigu.ssyx.search;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||||
|
@ComponentScan(basePackages = {"com.atguigu.ssyx"})
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@EnableFeignClients
|
||||||
|
public class ServiceSearchApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ServiceSearchApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.atguigu.ssyx.search.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/search/sku")
|
||||||
|
public class SkuApiController {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.atguigu.ssyx.search.repository;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.search.SkuEs;
|
||||||
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
|
|
||||||
|
public interface SkuRepository extends ElasticsearchRepository<SkuEs,Long> {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.atguigu.ssyx.search.service;
|
||||||
|
|
||||||
|
public interface SkuService {
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.atguigu.ssyx.search.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.search.service.SkuService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SkuServiceImpl implements SkuService {
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
server:
|
server:
|
||||||
port: 8203
|
port: 8208
|
||||||
|
|
||||||
bunny:
|
bunny:
|
||||||
datasource:
|
rabbitmq:
|
||||||
host: 106.15.251.123
|
host: 116.196.101.14
|
||||||
port: 3305
|
port: 5672
|
||||||
sqlData: shequ-product
|
username: bunny
|
||||||
username: root
|
|
||||||
password: "02120212"
|
password: "02120212"
|
||||||
|
|
||||||
|
elasticsearch:
|
||||||
|
uris: http://192.168.1.4:9200
|
||||||
|
|
||||||
nacos:
|
nacos:
|
||||||
server-addr: z-bunny.cn:8848
|
server-addr: z-bunny.cn:8848
|
||||||
discovery:
|
discovery:
|
||||||
|
@ -17,7 +19,7 @@ bunny:
|
||||||
redis:
|
redis:
|
||||||
host: 47.120.65.66
|
host: 47.120.65.66
|
||||||
port: 6379
|
port: 6379
|
||||||
database: 2
|
database: 3
|
||||||
password: "02120212"
|
password: "02120212"
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
|
|
|
@ -1,17 +1,39 @@
|
||||||
server:
|
server:
|
||||||
port: 8203
|
port: 8208
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: service-product
|
name: service-search
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
|
|
||||||
datasource:
|
redis:
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
host: ${bunny.redis.host}
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
port: ${bunny.redis.port}
|
||||||
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
database: ${bunny.redis.database}
|
||||||
username: ${bunny.datasource.username}
|
password: ${bunny.redis.password}
|
||||||
password: ${bunny.datasource.password}
|
lettuce:
|
||||||
|
pool:
|
||||||
|
max-active: 20 #最大连接数
|
||||||
|
max-wait: -1 #最大阻塞等待时间(负数表示没限制)
|
||||||
|
max-idle: 5 #最大空闲
|
||||||
|
min-idle: 0 #最小空闲
|
||||||
|
|
||||||
|
elasticsearch:
|
||||||
|
rest:
|
||||||
|
uris: ${bunny.elasticsearch.uris}
|
||||||
|
|
||||||
|
rabbitmq:
|
||||||
|
host: ${bunny.rabbitmq.host}
|
||||||
|
port: ${bunny.rabbitmq.port}
|
||||||
|
username: ${bunny.rabbitmq.username}
|
||||||
|
password: ${bunny.rabbitmq.password}
|
||||||
|
publisher-confirm-type: CORRELATED
|
||||||
|
publisher-returns: true
|
||||||
|
listener:
|
||||||
|
simple:
|
||||||
|
prefetch: 1
|
||||||
|
concurrency: 3
|
||||||
|
acknowledge-mode: manual
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
sentinel:
|
sentinel:
|
||||||
|
@ -26,23 +48,21 @@ spring:
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
|
|
||||||
|
bunny:
|
||||||
|
minio:
|
||||||
|
endpointUrl: ${bunny.minio.endpointUrl}
|
||||||
|
accessKey: ${bunny.minio.accessKey}
|
||||||
|
secretKey: ${bunny.minio.secretKey}
|
||||||
|
bucket-name: ${bunny.minio.bucket-name}
|
||||||
|
|
||||||
mybatis-plus:
|
feign:
|
||||||
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
sentinel:
|
||||||
mapper-locations: classpath:mapper/*.xml
|
enabled: true
|
||||||
configuration:
|
client:
|
||||||
map-underscore-to-camel-case: true
|
config:
|
||||||
auto-mapping-behavior: full
|
default: #配置全局的feign的调用超时时间 如果 有指定的服务配置 默认的配置不会生效
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
connectTimeout: 30000 # 指定的是 消费者 连接服务提供者的连接超时时间 是否能连接 单位是毫秒
|
||||||
global-config:
|
readTimeout: 50000 # 指定的是调用服务提供者的 服务 的超时时间() 单位是毫秒
|
||||||
db-config:
|
|
||||||
# 设置表名前缀,不用在每个tableName添加前缀
|
|
||||||
# table-prefix: t_
|
|
||||||
# 全局配置主键值方式
|
|
||||||
id-type: assign_id
|
|
||||||
logic-not-delete-value: 0 # 未删除默认为0
|
|
||||||
logic-delete-value: 1 # 删除
|
|
||||||
logic-delete-field: deleted # 全局配置逻辑删除
|
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
@ -53,10 +73,3 @@ logging:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
path: "logs/${spring.application.name}"
|
path: "logs/${spring.application.name}"
|
||||||
|
|
||||||
bunny:
|
|
||||||
minio:
|
|
||||||
endpointUrl: ${bunny.minio.endpointUrl}
|
|
||||||
accessKey: ${bunny.minio.accessKey}
|
|
||||||
secretKey: ${bunny.minio.secretKey}
|
|
||||||
bucket-name: ${bunny.minio.bucket-name}
|
|
|
@ -14,12 +14,6 @@ bunny:
|
||||||
discovery:
|
discovery:
|
||||||
namespace: ssyx
|
namespace: ssyx
|
||||||
|
|
||||||
redis:
|
|
||||||
host: 47.120.65.66
|
|
||||||
port: 6379
|
|
||||||
database: 2
|
|
||||||
password: "02120212"
|
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpointUrl: "http://129.211.31.58:9000"
|
endpointUrl: "http://129.211.31.58:9000"
|
||||||
bucket-name: ssyx
|
bucket-name: ssyx
|
||||||
|
|
Loading…
Reference in New Issue