diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/GitServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/GitServiceImpl.java index 81ca724..db32159 100644 --- a/src/main/java/net/geedge/asw/module/app/service/impl/GitServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/app/service/impl/GitServiceImpl.java @@ -1,6 +1,7 @@ package net.geedge.asw.module.app.service.impl; import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.json.JSONObject; import cn.hutool.log.Log; import net.geedge.asw.common.util.ASWException; import net.geedge.asw.common.util.RCode; @@ -42,6 +43,12 @@ public class GitServiceImpl implements IGitService { @Value("${file.extensions.text:txt,csv,md,html,xml,json,log,bat,py,sh,ini,conf,yaml,yml,properties,toml,java,c,cpp,js,php,ts,go,rb,rtf,tex,rss,xhtml,sql}") private String textExtensions; + @Value("${asw.application.template.basic.json}") + private String basicJsonTemplate; + + @Value("${asw.application.template.signature.json}") + private String signatureJsonTemplate; + /** * 本地分支引用前缀 */ @@ -300,7 +307,19 @@ public class GitServiceImpl implements IGitService { for (String str : T.ListUtil.of("README.md", "basic.json", "signature.json", "icon.png")) { String savePath = T.StrUtil.concat(true, "applications/", applicationName, "/", str); - ObjectId objectId = this.insertBlobFileToDatabase(repository, T.StrUtil.EMPTY.getBytes()); + String fileContent = T.StrUtil.EMPTY; + if ("basic.json".equals(str)) { + JSONObject jsonObject = T.JSONUtil.parseObj(this.basicJsonTemplate); + jsonObject.set("id", T.StrUtil.uuid()); + jsonObject.set("name", applicationName); + jsonObject.set("longName", applicationName); + fileContent = T.JSONUtil.toJsonPrettyStr(jsonObject); + } + if ("signature.json".equals(str)) { + fileContent = this.signatureJsonTemplate; + } + + ObjectId objectId = this.insertBlobFileToDatabase(repository, fileContent.getBytes()); filePathAndBlobIdMap.put(savePath, objectId); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5348fef..1788d85 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -73,4 +73,34 @@ mybatis-plus: banner: false logging: - config: ./config/logback-spring.xml \ No newline at end of file + config: ./config/logback-spring.xml + + + +asw: + application: + template: + basic.json: |- #配置JSON格式 + { + "id": "{uuid}", + "name": "{application name}", + "longName": "{application name}", + "developer": "", + "website": "", + "packageName": { + "android": "", + "ios": "" + }, + "properties": { + "category": "", + "subcategory": "", + "content": "unknown", + "parentApp": "", + "risk": 1 + } + } + signature.json: |- + { + "surrogates": [] + } +