From dd38aba9aae63411b4c1944d2c49115c2333d6cc Mon Sep 17 00:00:00 2001 From: Zhu Zhonghua <zhonghua@qq.com> Date: 星期一, 07 四月 2025 23:02:41 +0800 Subject: [PATCH] 新建 --- aps-modules/aps-upload/pom.xml | 82 +++++++++++++ aps-modules/aps-upload/src/main/java/com/aps/upload/service/impl/CoreServiceImpl.java | 21 +++ aps-modules/aps-upload/src/main/resources/banner.txt | 10 + aps-modules/aps-upload/src/main/resources/bootstrap.yml | 25 ++++ aps-modules/aps-upload/src/main/resources/mapper/upload/CoreMapper.xml | 10 + aps-modules/aps-upload/src/main/java/com/aps/upload/APSUploadApplication.java | 29 ++++ aps-modules/aps-upload/src/main/resources/logback.xml | 74 ++++++++++++ aps-modules/pom.xml | 1 aps-modules/aps-upload/src/main/java/com/aps/upload/controller/CoreController.java | 48 ++++++++ aps-modules/aps-upload/src/main/java/com/aps/upload/mapper/CoreMapper.java | 7 + aps-modules/aps-upload/src/main/java/com/aps/upload/service/ICoreService.java | 20 +++ 11 files changed, 327 insertions(+), 0 deletions(-) diff --git a/aps-modules/aps-upload/pom.xml b/aps-modules/aps-upload/pom.xml new file mode 100644 index 0000000..46d694d --- /dev/null +++ b/aps-modules/aps-upload/pom.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>com.aps</groupId> + <artifactId>aps-modules</artifactId> + <version>3.6.5</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>aps-modules-upload</artifactId> + + <description> + aps涓婁紶涓氬姟妯″潡 + </description> + + <dependencies> + + <!-- SpringCloud Alibaba Nacos --> + <dependency> + <groupId>com.alibaba.cloud</groupId> + <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> + </dependency> + + <!-- SpringCloud Alibaba Nacos Config --> + <dependency> + <groupId>com.alibaba.cloud</groupId> + <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> + </dependency> + + <!-- SpringCloud Alibaba Sentinel --> + <dependency> + <groupId>com.alibaba.cloud</groupId> + <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> + </dependency> + + <!-- SpringBoot Actuator --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + + <!-- SpringBoot Web --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <!-- Minio --> + <dependency> + <groupId>io.minio</groupId> + <artifactId>minio</artifactId> + <version>${minio.version}</version> + </dependency> + + <!-- RuoYi Api System --> + <dependency> + <groupId>com.aps</groupId> + <artifactId>aps-api-system</artifactId> + </dependency> + + </dependencies> + + <build> + <finalName>${project.artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/aps-modules/aps-upload/src/main/java/com/aps/upload/APSUploadApplication.java b/aps-modules/aps-upload/src/main/java/com/aps/upload/APSUploadApplication.java new file mode 100644 index 0000000..9fe98a4 --- /dev/null +++ b/aps-modules/aps-upload/src/main/java/com/aps/upload/APSUploadApplication.java @@ -0,0 +1,29 @@ +package com.aps.upload; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * 鏂囦欢鏈嶅姟 + * + * @author ruoyi + */ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) +public class APSUploadApplication +{ + public static void main(String[] args) + { + SpringApplication.run(APSUploadApplication.class, args); + System.out.println("(鈾モ棤鈥库棤)锞夛緸 鏂囦欢鏈嶅姟妯″潡鍚姩鎴愬姛 醿�(麓凇`醿�)锞� \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/aps-modules/aps-upload/src/main/java/com/aps/upload/controller/CoreController.java b/aps-modules/aps-upload/src/main/java/com/aps/upload/controller/CoreController.java new file mode 100644 index 0000000..823aaf5 --- /dev/null +++ b/aps-modules/aps-upload/src/main/java/com/aps/upload/controller/CoreController.java @@ -0,0 +1,48 @@ +package com.aps.upload.controller; + +import com.aps.core.service.ICoreService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import com.aps.common.core.domain.R; +import com.aps.common.core.utils.file.FileUtils; +import com.aps.system.api.domain.SysFile; + +/** + * 鏂囦欢璇锋眰澶勭悊 + * + * @author ruoyi + */ +@RestController +public class CoreController +{ + private static final Logger log = LoggerFactory.getLogger(CoreController.class); + + @Autowired + private ICoreService coreService; + + /** + * 鏂囦欢涓婁紶璇锋眰 + */ + @PostMapping("upload") + public R<SysFile> upload(MultipartFile file) + { + try + { + // 涓婁紶骞惰繑鍥炶闂湴鍧� + String url = coreService.uploadFile(file); + SysFile sysFile = new SysFile(); + sysFile.setName(FileUtils.getName(url)); + sysFile.setUrl(url); + return R.ok(sysFile); + } + catch (Exception e) + { + log.error("涓婁紶鏂囦欢澶辫触", e); + return R.fail(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/aps-modules/aps-upload/src/main/java/com/aps/upload/mapper/CoreMapper.java b/aps-modules/aps-upload/src/main/java/com/aps/upload/mapper/CoreMapper.java new file mode 100644 index 0000000..639903c --- /dev/null +++ b/aps-modules/aps-upload/src/main/java/com/aps/upload/mapper/CoreMapper.java @@ -0,0 +1,7 @@ +package com.aps.upload.mapper; + +public interface CoreMapper +{ + + public void cleanJobLog(); +} diff --git a/aps-modules/aps-upload/src/main/java/com/aps/upload/service/ICoreService.java b/aps-modules/aps-upload/src/main/java/com/aps/upload/service/ICoreService.java new file mode 100644 index 0000000..cf1e521 --- /dev/null +++ b/aps-modules/aps-upload/src/main/java/com/aps/upload/service/ICoreService.java @@ -0,0 +1,20 @@ +package com.aps.upload.service; + +import org.springframework.web.multipart.MultipartFile; + +/** + * 鏂囦欢涓婁紶鎺ュ彛 + * + * @author ruoyi + */ +public interface ICoreService +{ + /** + * 鏂囦欢涓婁紶鎺ュ彛 + * + * @param file 涓婁紶鐨勬枃浠� + * @return 璁块棶鍦板潃 + * @throws Exception + */ + public String uploadFile(MultipartFile file) throws Exception; +} diff --git a/aps-modules/aps-upload/src/main/java/com/aps/upload/service/impl/CoreServiceImpl.java b/aps-modules/aps-upload/src/main/java/com/aps/upload/service/impl/CoreServiceImpl.java new file mode 100644 index 0000000..53dda10 --- /dev/null +++ b/aps-modules/aps-upload/src/main/java/com/aps/upload/service/impl/CoreServiceImpl.java @@ -0,0 +1,21 @@ +package com.aps.upload.service.impl; + +import com.aps.core.service.ICoreService; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +/** + * 鏈湴鏂囦欢瀛樺偍 + * + */ +@Primary +@Service +public class CoreServiceImpl implements ICoreService +{ + @Override + public String uploadFile(MultipartFile file) throws Exception + { + return null; + } +} diff --git a/aps-modules/aps-upload/src/main/resources/banner.txt b/aps-modules/aps-upload/src/main/resources/banner.txt new file mode 100644 index 0000000..27cacb9 --- /dev/null +++ b/aps-modules/aps-upload/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ __ _ _ + (_) / _|(_)| | + _ __ _ _ ___ _ _ _ ______ | |_ _ | | ___ +| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \ +| | | |_| || (_) || |_| || | | | | || || __/ +|_| \__,_| \___/ \__, ||_| |_| |_||_| \___| + __/ | + |___/ \ No newline at end of file diff --git a/aps-modules/aps-upload/src/main/resources/bootstrap.yml b/aps-modules/aps-upload/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..94dd926 --- /dev/null +++ b/aps-modules/aps-upload/src/main/resources/bootstrap.yml @@ -0,0 +1,25 @@ +# Tomcat +server: + port: 9206 + +# Spring +spring: + application: + # 搴旂敤鍚嶇О + name: aps-upload + profiles: + # 鐜閰嶇疆 + active: dev + cloud: + nacos: + discovery: + # 鏈嶅姟娉ㄥ唽鍦板潃 + server-addr: 192.168.50.160:8848 + config: + # 閰嶇疆涓績鍦板潃 + server-addr: 192.168.50.160:8848 + # 閰嶇疆鏂囦欢鏍煎紡 + file-extension: yml + # 鍏变韩閰嶇疆 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/aps-modules/aps-upload/src/main/resources/logback.xml b/aps-modules/aps-upload/src/main/resources/logback.xml new file mode 100644 index 0000000..fd27c64 --- /dev/null +++ b/aps-modules/aps-upload/src/main/resources/logback.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration scan="true" scanPeriod="60 seconds" debug="false"> + <!-- 鏃ュ織瀛樻斁璺緞 --> + <property name="log.path" value="logs/aps-file" /> + <!-- 鏃ュ織杈撳嚭鏍煎紡 --> + <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> + + <!-- 鎺у埗鍙拌緭鍑� --> + <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + </appender> + + <!-- 绯荤粺鏃ュ織杈撳嚭 --> + <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.path}/info.log</file> + <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� --> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- 鏃ュ織鏂囦欢鍚嶆牸寮� --> + <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern> + <!-- 鏃ュ織鏈�澶х殑鍘嗗彶 60澶� --> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- 杩囨护鐨勭骇鍒� --> + <level>INFO</level> + <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� --> + <onMatch>ACCEPT</onMatch> + <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� --> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + + <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.path}/error.log</file> + <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� --> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- 鏃ュ織鏂囦欢鍚嶆牸寮� --> + <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern> + <!-- 鏃ュ織鏈�澶х殑鍘嗗彶 60澶� --> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- 杩囨护鐨勭骇鍒� --> + <level>ERROR</level> + <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� --> + <onMatch>ACCEPT</onMatch> + <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� --> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + + <!-- 绯荤粺妯″潡鏃ュ織绾у埆鎺у埗 --> + <logger name="com.aps" level="info" /> + <!-- Spring鏃ュ織绾у埆鎺у埗 --> + <logger name="org.springframework" level="warn" /> + + <root level="info"> + <appender-ref ref="console" /> + </root> + + <!--绯荤粺鎿嶄綔鏃ュ織--> + <root level="info"> + <appender-ref ref="file_info" /> + <appender-ref ref="file_error" /> + </root> +</configuration> \ No newline at end of file diff --git a/aps-modules/aps-upload/src/main/resources/mapper/upload/CoreMapper.xml b/aps-modules/aps-upload/src/main/resources/mapper/upload/CoreMapper.xml new file mode 100644 index 0000000..a0015c5 --- /dev/null +++ b/aps-modules/aps-upload/src/main/resources/mapper/upload/CoreMapper.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.aps.upload.mapper.CoreMapper"> + + <update id="cleanJobLog"> + truncate table sys_job_log + </update> +</mapper> \ No newline at end of file diff --git a/aps-modules/pom.xml b/aps-modules/pom.xml index 26dd932..87ffe3d 100644 --- a/aps-modules/pom.xml +++ b/aps-modules/pom.xml @@ -14,6 +14,7 @@ <module>aps-job</module> <module>aps-file</module> <module>aps-core</module> + <module>aps-upload</module> </modules> <artifactId>aps-modules</artifactId> -- Gitblit v1.9.3