yeshijie 4 роки тому
батько
коміт
fef3dd8ce1

+ 0 - 11
guns-base-support/guns-core/pom.xml

@ -27,17 +27,6 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <!-- aop -->

+ 1 - 1
guns-main/pom.xml

@ -19,7 +19,7 @@
    <artifactId>guns-main</artifactId>
    <packaging>war</packaging>
    <packaging>jar</packaging>
    <dependencies>

+ 27 - 0
guns-main/src/main/java/cn/stylefeng/guns/config/FastDFSConfig.java

@ -0,0 +1,27 @@
package cn.stylefeng.guns.config;
import cn.stylefeng.guns.zjxlUtil.FastDFSClientPool;
import cn.stylefeng.guns.zjxlUtil.FastDFSUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author Sand
 * @version 1.0
 * @created 2015.11.27 16:08
 */
@Configuration
public class FastDFSConfig {
    @Bean
    public FastDFSClientPool fastDFSClientPool(){
        FastDFSClientPool clientPool = FastDFSClientPool.getInstance();
        return clientPool;
    }
    @Bean
    public FastDFSUtil fastDFSUtil(){
        FastDFSUtil util = new FastDFSUtil();
        return util;
    }
}

+ 8 - 9
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlBannerCnotroller.java

@ -1,29 +1,28 @@
package cn.stylefeng.guns.zjxl.cnotroller;
import cn.stylefeng.guns.config.FastDFSConfig;
import cn.stylefeng.guns.zjxl.model.UploadModel;
import cn.stylefeng.guns.zjxl.model.ZjxlBanner;
import cn.stylefeng.guns.zjxl.model.ZjxlCompanyCase;
import cn.stylefeng.guns.zjxl.model.ret.BannerCompanyCaseRet;
import cn.stylefeng.guns.zjxl.model.ret.BaseResultModel;
import cn.stylefeng.guns.zjxl.model.ret.ResultOneModel;
import cn.stylefeng.guns.zjxl.service.ZjxlBannerService;
import cn.stylefeng.guns.zjxl.service.ZjxlCompanyCaseService;
import cn.stylefeng.guns.zjxlUtil.BaseController;
import cn.stylefeng.guns.zjxlUtil.FastDFSUtil;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.ini4j.spi.RegEscapeTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
/***
 * @ClassName: ZjxlBannerCnotroller
@ -39,8 +38,8 @@ public class ZjxlBannerCnotroller extends BaseController {
    @Autowired
    private ZjxlBannerService bannerService;
    @Autowired(required = false)
    FastDFSUtil fastDFSUtil;
    @Autowired
    FastDFSConfig fastDFSConfig;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
@ -143,7 +142,7 @@ public class ZjxlBannerCnotroller extends BaseController {
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream(), fileType, "");
        ObjectNode objectNode = fastDFSConfig.fastDFSUtil().upload(mf.getInputStream(), fileType, "");
        //解析返回的objectNode
        uploadModel.setFileName(fileName);
        uploadModel.setFileType(fileType);

+ 2 - 2
guns-main/src/main/java/cn/stylefeng/guns/zjxlUtil/FastDFSUtil.java

@ -76,7 +76,7 @@ public class FastDFSUtil {
     *
     * @throws Exception
     */
    public static ObjectNode upload(InputStream in, String fileExtension,
    public  ObjectNode upload(InputStream in, String fileExtension,
                                    String description) throws Exception {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
@ -162,7 +162,7 @@ public class FastDFSUtil {
     *
     * @throws Exception
     */
    public static ObjectNode upload(String fileName, String description) throws Exception {
    public ObjectNode upload(String fileName, String description) throws Exception {
        StorageClient client = FastDFSClientPool.getInstance().getStorageClient();
        try {
            NameValuePair[] meta_list;

+ 1 - 1
guns-main/src/main/resources/application-dev.yml

@ -10,4 +10,4 @@ spring:
    max-pool-prepared-statement-per-connection-size: 20
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.26.0.110:8888/

+ 4 - 1
guns-main/src/main/resources/application-local.yml

@ -7,4 +7,7 @@ spring:
    password: ssgg@jkzl2019
    # 连接池大小根据实际情况调整
    max-active: 20
    max-pool-prepared-statement-per-connection-size: 20
    max-pool-prepared-statement-per-connection-size: 20
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/

+ 3 - 1
guns-main/src/main/resources/application-prod.yml

@ -7,4 +7,6 @@ spring:
    password: 123456
    # 连接池大小根据实际情况调整
    max-active: 20
    max-pool-prepared-statement-per-connection-size: 20
    max-pool-prepared-statement-per-connection-size: 20
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/

+ 4 - 1
guns-main/src/main/resources/application-test.yml

@ -7,4 +7,7 @@ spring:
    password: ssgg@jkzl2019
    # 连接池大小根据实际情况调整
    max-active: 20
    max-pool-prepared-statement-per-connection-size: 20
    max-pool-prepared-statement-per-connection-size: 20
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/

+ 0 - 1
guns-main/src/main/resources/application.yml

@ -1,6 +1,5 @@
#服务配置
server:
  port: 82
  max-http-header-size: 10240
#spring相关配置

+ 1 - 1
guns-main/src/main/resources/config/fdfs_client.conf

@ -9,7 +9,7 @@ http.secret_key = FastDFS1234567890
#tracker_server = 172.19.103.54:22122
#-------------测试环境---------------#
tracker_server = 172.19.103.54:22122
tracker_server = 172.26.0.110:22122
#-------------正式环境---------------#
#tracker_server = 192.168.120.172:22122

+ 2 - 2
pom.xml

@ -186,9 +186,9 @@
    <profiles>
        <profile>
            <id>local</id>
            <id>test</id>
            <properties>
                <spring.active>local</spring.active>
                <spring.active>test</spring.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>