File tree Expand file tree Collapse file tree
src/main/java/io/github/talelin/latticy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import io .github .talelin .latticy .common .factory .YamlPropertySourceFactory ;
44import org .springframework .boot .context .properties .ConfigurationProperties ;
55import org .springframework .context .annotation .PropertySource ;
6- import org .springframework .core .annotation .Order ;
76import org .springframework .stereotype .Component ;
87
98/**
109 * @author pedro@TaleLin
1110 */
1211@ Component
13- @ ConfigurationProperties (prefix = "lin.file" )
12+ @ ConfigurationProperties ("lin.file" )
1413@ PropertySource (
1514 value = "classpath:io/github/talelin/latticy/extension/file/config.yml" ,
16- encoding = "UTF-8" ,factory = YamlPropertySourceFactory .class )
15+ encoding = "UTF-8" , factory = YamlPropertySourceFactory .class )
1716public class FileProperties {
1817
1918 private static final String [] DEFAULT_EMPTY_ARRAY = new String [0 ];
@@ -30,6 +29,19 @@ public class FileProperties {
3029
3130 private String [] include = DEFAULT_EMPTY_ARRAY ;
3231
32+ /**
33+ * 文件存储路径
34+ */
35+ private String servePath = "assets/**" ;
36+
37+ public String getServePath () {
38+ return servePath ;
39+ }
40+
41+ public void setServePath (String servePath ) {
42+ this .servePath = servePath ;
43+ }
44+
3345 public String getStoreDir () {
3446 return storeDir ;
3547 }
Original file line number Diff line number Diff line change 33import cn .hutool .core .bean .BeanUtil ;
44import io .github .talelin .latticy .bo .FileBO ;
55import io .github .talelin .latticy .module .file .FileConstant ;
6+ import io .github .talelin .latticy .module .file .FileProperties ;
67import io .github .talelin .latticy .module .file .Uploader ;
78import io .github .talelin .latticy .mapper .FileMapper ;
89import io .github .talelin .latticy .model .FileDO ;
1920
2021/**
2122 * @author pedro@TaleLin
23+ * @author Juzi@TaleLin
2224 */
2325@ Service
2426public class FileServiceImpl extends ServiceImpl <FileMapper , FileDO > implements FileService {
2527
2628 @ Autowired
2729 private Uploader uploader ;
2830
29- @ Value ( "${lin.file.domain}" )
30- private String domain ;
31-
32- @ Value ( "${lin.file.serve-path:assets/**}" )
33- private String servePath ;
31+ /**
32+ * 文件上传配置信息
33+ */
34+ @ Autowired
35+ private FileProperties fileProperties ;
3436
3537 /**
3638 * 为什么不做批量插入
@@ -67,8 +69,8 @@ private FileBO transformDoToBo(FileDO file, String key) {
6769 FileBO bo = new FileBO ();
6870 BeanUtil .copyProperties (file , bo );
6971 if (file .getType ().equals (FileConstant .LOCAL )) {
70- String s = servePath .split ("/" )[0 ];
71- bo .setUrl (domain + s + "/" + file .getPath ());
72+ String s = fileProperties . getServePath () .split ("/" )[0 ];
73+ bo .setUrl (fileProperties . getDomain () + s + "/" + file .getPath ());
7274 } else {
7375 bo .setUrl (file .getPath ());
7476 }
You can’t perform that action at this time.
0 commit comments