diff --git a/.gitignore b/.gitignore index 44eac50f7f44c2602eb7f01b57c707257d6c6185..b69cb13a9066a33ca3e66895fd9529340b2abe8c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/database.config .idea **/appsettings.json +/variable_医疗01.yaml +/variable_190.yaml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/README.md b/README.md index d9d2a2f9764e142bd49cf7bdc5eeca972ac9a22e..0267ff74677d492fe305edad230ea27065d184b8 100644 --- a/README.md +++ b/README.md @@ -7,24 +7,205 @@ go build ``` ## 使用方式 +1. 克隆本项目,或下载本项目完整压缩包 + ```shell + git clone https://gitee.com/newtouch_code/oh-container-deploy.git + ``` -1. 编辑 [variable.yaml](variable.yaml) -2. 执行 [openhis-config-temp.exe](openhis-config-temp.exe) -3. 在生成的[config](config)目录下,找到对应的模块配置文件,复制到对应的ISS模块的配置文件夹中 +2. 编辑 [variable.yaml](variable.yaml) +3. 在`Windows PowerShell`执行 [openhis-config.exe](openhis-config-temp.exe) + ```shell + PS C:\Users\mohaijiang\GolandProjects\openhis-config-temp> .\openhis-config.exe + 开始生成配置文件 + 61.172.179.6,30288 + Directory: ./config + Directory: config\ApiManage + File temp: config\ApiManage\appsettings.json.tmpl + Template rendered and output file created. + Directory: config\AuthCenterAPI + File temp: config\AuthCenterAPI\appsettings.json.tmpl + Template rendered and output file created. + Directory: config\BaeAPI + Directory: config\BaeAPI\Configs + File temp: config\BaeAPI\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\BaeAPI\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\Base + Directory: config\Base\Configs + File temp: config\Base\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\Base\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\CIS + Directory: config\CIS\Configs + File temp: config\CIS\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\CIS\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\CISAPI + Directory: config\CISAPI\Configs + File temp: config\CISAPI\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\CISAPI\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\EMR + Directory: config\EMR\Configs + File temp: config\EMR\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\EMR\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\Herp + Directory: config\Herp\Configs + File temp: config\Herp\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\Herp\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\JobService + File temp: config\JobService\appsettings.json.tmpl + Template rendered and output file created. + Directory: config\MRMS + Directory: config\MRMS\Configs + File temp: config\MRMS\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\MRMS\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\MRQC + Directory: config\MRQC\Configs + File temp: config\MRQC\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\MRQC\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\OR + Directory: config\OR\Configs + File temp: config\OR\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\OR\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\PDS + Directory: config\PDS\Configs + File temp: config\PDS\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\PDS\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\PDSAPI + Directory: config\PDSAPI\Configs + File temp: config\PDSAPI\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\PDSAPI\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\Report + File temp: config\Report\appsettings.json.tmpl + Template rendered and output file created. + Directory: config\Sett + Directory: config\Sett\Configs + File temp: config\Sett\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\Sett\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\SettAPI + Directory: config\SettAPI\Configs + File temp: config\SettAPI\Configs\database.config.tmpl + Template rendered and output file created. + File temp: config\SettAPI\Configs\system.config.tmpl + Template rendered and output file created. + Directory: config\Union + File temp: config\Union\appsettings.json.tmpl + Template rendered and output file created. + Directory: config\his.baseapi + File temp: config\his.baseapi\appsettings.json.tmpl + Template rendered and output file created. + ``` +4. 在生成的[config](config)目录下,找到对应的模块配置文件,复制到对应的ISS模块的配置文件夹中 ## [variable.yaml](variable.yaml) 配置文件说明 ```yaml ## 数据库连接地址 -DatabaseHost: 61.172.179.6,30557 +DatabaseHost: 61.172.179.6,30288 ## 数据库用户名 DatabaseUser: sa ## 数据库密码 -DatabasePassword: 1qazxsw2# +DatabasePassword: Abcd1234 ## redis 连接地址 RedisHost: 61.172.179.6:32079 ## redis 密码 RedisPassword: newtouch -## 服务暴露IP: +## 服务暴露IP(公网IP,如不需要公网映射,直接填写内网IP即可): PublicIP: 127.0.0.1 +## 内网(局域网)IP +LanIP: 127.0.0.1 + +Services: + ## 公网服务端口 + PublicWebPort: + ## 静态资源公网端口 + Static: 8014 + ## 报表服务公网端口 + Report: 8000 + ## 后台管理公网端口 + Base: 8001 + ## 结算管理公网端口 + Sett: 8002 + ## 医护协同公网端口 + Cis: 8003 + ## 药房药库公网端口 + Pds: 8004 + ## 电子病例公网端口 + Emr: 8005 + ## 手术管理公网端口 + Or: 8006 + ## 医疗资源管理公网端口 + Herp: 8007 + ## 病案管理公网端口 + Mrms: 8008 + ## 病例质控管理公网端口 + Mrqc: 8009 + ## 认证接口公网端口 + AuthCenter: 8015 + ## 统一api公网端口 + WebAPIManage: 8016 + ## 基础api公网端口 + HisBaseAPI: 8017 + ## 联合工作站公网端口 + Union: 8018 + ## 内网服务端口 + LanWebPort: + ## 静态资源内网端口 + Static: 8014 + ## 报表服务内网端口 + Report: 8000 + ## 后台管理内网端口 + Base: 8001 + ## 结算管理内网端口 + Sett: 8002 + ## 医护协同内网端口 + Cis: 8003 + ## 药房药库内网端口 + Pds: 8004 + ## 电子病例内网端口 + Emr: 8005 + ## 手术管理内网端口 + Or: 8006 + ## 医疗资源管理内网端口 + Herp: 8007 + ## 病案管理内网端口 + Mrms: 8008 + ## 病例质控管理内网端口 + Mrqc: 8009 + ## 联合工作站内网端口 + Union: 8018 + LanAPIPort: + ## 后台管理API 内网端口 + Base: 7001 + ## 结算管理API 内网端口 + Sett: 7002 + ## 医护协同API 内网端口 + Cis: 7003 + ## 认证中心API 内网端口 + AuthCenter: 8015 + ## 统一API 内网端口 + WebAPIManage: 8016 + ## 基础API 内网端口 + HisBaseAPI: 8017 ``` \ No newline at end of file diff --git a/cmd/replace.go b/cmd/replace.go new file mode 100644 index 0000000000000000000000000000000000000000..b10a1d0bf8ebac3b41df067e8a623f2ab2d0c848 --- /dev/null +++ b/cmd/replace.go @@ -0,0 +1,37 @@ +/* +Copyright © 2024 NAME HERE +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// replaceCmd represents the replace command +var replaceCmd = &cobra.Command{ + Use: "replace", + Short: "替換部署包配置文件", + Long: `根据config目录,替换openhis 部署包的配置文件: +示例: + + openhis-config.exe replace -d ./openhis`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("replace called") + }, +} + +func init() { + rootCmd.AddCommand(replaceCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // replaceCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + replaceCmd.Flags().StringP("toggle", "t", "./openhis", "Help message for toggle") +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000000000000000000000000000000000000..a91b2bd889b53516c8991697dcec8da124a690e0 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,130 @@ +/* +Copyright © 2024 NAME HERE +*/ +package cmd + +import ( + "fmt" + "gopkg.in/yaml.v3" + "log" + "os" + "path/filepath" + "strings" + "text/template" + + "github.com/spf13/cobra" +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "openhis-config", + Short: "生成配置文件", + Long: `根据variable.yaml 和模板目录config 生成 院版HIS 部署配置文件. + +For example: + + ./openhis-config.exe +`, + // Uncomment the following line if your bare application + // has an action associated with it: + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("开始生成配置文件") + genConfig() + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + err := rootCmd.Execute() + if err != nil { + os.Exit(1) + } +} + +func init() { + // Here you will define your flags and configuration settings. + // Cobra supports persistent flags, which, if defined here, + // will be global for your application. + + // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.openhis-config.yaml)") + + // Cobra also supports local flags, which will only run + // when this action is called directly. + //rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + +func genConfig() { + var variable Variable + + data, err := os.ReadFile("./variable.yaml") + if err != nil { + log.Fatalf("error: %v", err) + } + // 解析 YAML 到结构体 + err = yaml.Unmarshal(data, &variable) + if err != nil { + log.Fatalf("error: %v", err) + } + + fmt.Println(variable.DatabaseHost) + + // 要遍历的目录路径 + dirPath := "./config" + + // 回调函数,处理每个文件或目录 + err = filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { + if err != nil { + fmt.Println(err) // 打印错误信息 + return err // 返回错误,可以决定是否继续遍历 + } + if info.IsDir() { + fmt.Printf("Directory: %s\n", path) + } else if filepath.Ext(info.Name()) == ".tmpl" { + fmt.Printf("File temp: %s\n", path) + err := RenderTemplate(variable, path) + if err != nil { + fmt.Println("filepath.Walk() RenderTemplate returned:", err) + return err + } + + } + return nil // 继续遍历 + }) + + if err != nil { + fmt.Println("filepath.Walk() returned:", err) + } +} + +func RenderTemplate(variable Variable, templatePath string) error { + // 输出文件路径 + outputPath := strings.Replace(templatePath, ".tmpl", "", 1) + + // 读取模板文件 + tmplBytes, err := os.ReadFile(templatePath) + if err != nil { + panic(err) + } + + // 解析模板 + t, err := template.New("template").Parse(string(tmplBytes)) + if err != nil { + panic(err) + } + // 创建输出文件 + outputFile, err := os.Create(outputPath) + if err != nil { + panic(err) + } + defer outputFile.Close() + + // 渲染模板到输出文件 + err = t.Execute(outputFile, variable) + if err != nil { + panic(err) + } + + fmt.Println("Template rendered and output file created.") + return nil +} diff --git a/variable.go b/cmd/variable.go similarity index 99% rename from variable.go rename to cmd/variable.go index 2622ab8dc5d57b630151da933a321ce66e7a3a78..83da20f7e628452deb7309c2f6f0312436139d92 100644 --- a/variable.go +++ b/cmd/variable.go @@ -1,4 +1,4 @@ -package main +package cmd type Variable struct { DatabaseHost string `yaml:"DatabaseHost"` diff --git a/config/webapimanage/appsettings.json.tmpl b/config/ApiManage/appsettings.json.tmpl similarity index 100% rename from config/webapimanage/appsettings.json.tmpl rename to config/ApiManage/appsettings.json.tmpl diff --git a/config/authenticationcenter/appsettings.json.tmpl b/config/AuthCenterAPI/appsettings.json.tmpl similarity index 100% rename from config/authenticationcenter/appsettings.json.tmpl rename to config/AuthCenterAPI/appsettings.json.tmpl diff --git a/config/base/api/database.config.tmpl b/config/BaeAPI/Configs/database.config.tmpl similarity index 100% rename from config/base/api/database.config.tmpl rename to config/BaeAPI/Configs/database.config.tmpl diff --git a/config/base/api/log4net.config b/config/BaeAPI/Configs/log4net.config similarity index 100% rename from config/base/api/log4net.config rename to config/BaeAPI/Configs/log4net.config diff --git a/config/base/api/system.config.tmpl b/config/BaeAPI/Configs/system.config.tmpl similarity index 100% rename from config/base/api/system.config.tmpl rename to config/BaeAPI/Configs/system.config.tmpl diff --git a/config/base/web/database.config.tmpl b/config/Base/Configs/database.config.tmpl similarity index 100% rename from config/base/web/database.config.tmpl rename to config/Base/Configs/database.config.tmpl diff --git a/config/base/web/log4net.config b/config/Base/Configs/log4net.config similarity index 100% rename from config/base/web/log4net.config rename to config/Base/Configs/log4net.config diff --git a/config/base/web/system.config.tmpl b/config/Base/Configs/system.config.tmpl similarity index 92% rename from config/base/web/system.config.tmpl rename to config/Base/Configs/system.config.tmpl index 9cc09487e875baaeaf52ed393dc4a182932ef9eb..46f1112286d13421cf946e0a9a80faa56c5efa17 100644 --- a/config/base/web/system.config.tmpl +++ b/config/Base/Configs/system.config.tmpl @@ -26,7 +26,8 @@ - + + diff --git a/config/cis/web/database.config.tmpl b/config/CIS/Configs/database.config.tmpl similarity index 100% rename from config/cis/web/database.config.tmpl rename to config/CIS/Configs/database.config.tmpl diff --git a/config/cis/web/system.config.tmpl b/config/CIS/Configs/system.config.tmpl similarity index 90% rename from config/cis/web/system.config.tmpl rename to config/CIS/Configs/system.config.tmpl index 468fcb6ad2e8f61a1aef6ce3da5f594e908d5770..a849fe8cafb8251a210e9b53e823e2a3b8756708 100644 --- a/config/cis/web/system.config.tmpl +++ b/config/CIS/Configs/system.config.tmpl @@ -2,7 +2,7 @@ - + @@ -32,6 +32,8 @@ + + @@ -45,6 +47,7 @@ + @@ -60,11 +63,16 @@ - + + + + + + @@ -89,12 +97,13 @@ + - + diff --git a/config/cis/api/database.config.tmpl b/config/CISAPI/Configs/database.config.tmpl similarity index 100% rename from config/cis/api/database.config.tmpl rename to config/CISAPI/Configs/database.config.tmpl diff --git a/config/cis/api/log4net.config b/config/CISAPI/Configs/log4net.config similarity index 100% rename from config/cis/api/log4net.config rename to config/CISAPI/Configs/log4net.config diff --git a/config/cis/api/system.config.tmpl b/config/CISAPI/Configs/system.config.tmpl similarity index 100% rename from config/cis/api/system.config.tmpl rename to config/CISAPI/Configs/system.config.tmpl diff --git a/config/emr/web/database.config.tmpl b/config/EMR/Configs/database.config.tmpl similarity index 100% rename from config/emr/web/database.config.tmpl rename to config/EMR/Configs/database.config.tmpl diff --git a/config/emr/web/system.config.tmpl b/config/EMR/Configs/system.config.tmpl similarity index 100% rename from config/emr/web/system.config.tmpl rename to config/EMR/Configs/system.config.tmpl diff --git a/config/herp/web/database.config.tmpl b/config/Herp/Configs/database.config.tmpl similarity index 100% rename from config/herp/web/database.config.tmpl rename to config/Herp/Configs/database.config.tmpl diff --git a/config/herp/web/system.config.tmpl b/config/Herp/Configs/system.config.tmpl similarity index 100% rename from config/herp/web/system.config.tmpl rename to config/Herp/Configs/system.config.tmpl diff --git a/config/JobService/appsettings.json.tmpl b/config/JobService/appsettings.json.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..2af9080876837600613f0efe0539264c6f1dc5bb --- /dev/null +++ b/config/JobService/appsettings.json.tmpl @@ -0,0 +1,78 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Hangfire": "Information" + } + }, + "Kestrel": { + "Endpoints": { + //"Https": { "Url": "https://*:9001" }, + "Http": { "Url": "http://localhost:9000" } + } + }, + "AllowedHosts": "*", + "AppId": "His.Job", + "Hangfire": { + "HangfireSettings": { + "ServerName": "SqlserverHangfire", + "StartUpPath": "/job", + "ReadOnlyPath": "", + "JobQueues": [ "default", "apis", "recurring", "Immediately" ], + "WorkerCount": 50, + "DisplayStorageConnectionString": false, + "HttpAuthInfo": { + "SslRedirect": false, + "RequireSsl": false, + "LoginCaseSensitive": true, + "IsOpenLogin": true, + "Users": [ + { + "Login": "admin", + "PasswordClear": "test" + } + ] + }, + "SqlConnectionString": "Data Source={{ .DatabaseHost }};Initial Catalog=NewtouchHis_Job;User ID={{ .DatabaseUser }};Password={{ .DatabasePassword }};" + + }, + "HttpJobOptions": { + "Lang": "zh", + "DefaultTimeZone": "", + "CurrentDomain": "//", + "EnableDingTalk": true, + "DefaultRecurringQueueName": "recurring", + "GlobalSettingJsonFilePath": "", + "Proxy": "", + "JobExpirationTimeoutDay": 7, + "GlobalHttpTimeOut": 5000, + "MailOption": { + "Server": "", + "Port": 0, + "User": "", + "Password": "", + "UseSsl": false, + "AlertMailList": [] + }, + "DingTalkOption": { + "Token": "", + "AtPhones": "", + "IsAtAll": false + } + } + + }, + "BusinessConfig": { + //顶级机构编码 + "Top_OrganizeId": "d8ee85f8-d8d1-4b5c-bd9e-1761f44242d8", + "AppId": "API.Manage", + "AppAPIHost": { + "ScheduleJobHost": "http://localhost:9000", + //接口中心 + "SiteApiManageHost": "http://localhost:5212", + //消息中心接口 + "SiteNoticeCenterHost": "http://localhost:7001" + } + } +} diff --git a/config/mrms/web/database.config.tmpl b/config/MRMS/Configs/database.config.tmpl similarity index 100% rename from config/mrms/web/database.config.tmpl rename to config/MRMS/Configs/database.config.tmpl diff --git a/config/mrms/web/system.config.tmpl b/config/MRMS/Configs/system.config.tmpl similarity index 100% rename from config/mrms/web/system.config.tmpl rename to config/MRMS/Configs/system.config.tmpl diff --git a/config/mrqc/web/database.config.tmpl b/config/MRQC/Configs/database.config.tmpl similarity index 100% rename from config/mrqc/web/database.config.tmpl rename to config/MRQC/Configs/database.config.tmpl diff --git a/config/mrqc/web/system.config.tmpl b/config/MRQC/Configs/system.config.tmpl similarity index 99% rename from config/mrqc/web/system.config.tmpl rename to config/MRQC/Configs/system.config.tmpl index f376c828f4c9f5f53c29696e3ebfdfa65533a227..e20f075e1175985e70159741a9de9fa5e1342435 100644 --- a/config/mrqc/web/system.config.tmpl +++ b/config/MRQC/Configs/system.config.tmpl @@ -63,7 +63,7 @@ - + diff --git a/config/or/web/database.config.tmpl b/config/OR/Configs/database.config.tmpl similarity index 100% rename from config/or/web/database.config.tmpl rename to config/OR/Configs/database.config.tmpl diff --git a/config/or/web/system.config.tmpl b/config/OR/Configs/system.config.tmpl similarity index 100% rename from config/or/web/system.config.tmpl rename to config/OR/Configs/system.config.tmpl diff --git a/config/pds/web/database.config.tmpl b/config/PDS/Configs/database.config.tmpl similarity index 100% rename from config/pds/web/database.config.tmpl rename to config/PDS/Configs/database.config.tmpl diff --git a/config/pds/web/log4net.config b/config/PDS/Configs/log4net.config similarity index 100% rename from config/pds/web/log4net.config rename to config/PDS/Configs/log4net.config diff --git a/config/pds/web/system.config.tmpl b/config/PDS/Configs/system.config.tmpl similarity index 100% rename from config/pds/web/system.config.tmpl rename to config/PDS/Configs/system.config.tmpl diff --git a/config/pds/api/database.config.tmpl b/config/PDSAPI/Configs/database.config.tmpl similarity index 100% rename from config/pds/api/database.config.tmpl rename to config/PDSAPI/Configs/database.config.tmpl diff --git a/config/pds/api/system.config.tmpl b/config/PDSAPI/Configs/system.config.tmpl similarity index 100% rename from config/pds/api/system.config.tmpl rename to config/PDSAPI/Configs/system.config.tmpl diff --git a/config/Report/appsettings.json.tmpl b/config/Report/appsettings.json.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..10bdbf76614c54dd79e3eb72ca7833da4fb3f68c --- /dev/null +++ b/config/Report/appsettings.json.tmpl @@ -0,0 +1,9 @@ +{ + "ConnectionStrings": { + + "KyTemplateConnection": "Data Source={{ .DatabaseHost }};Initial Catalog=NewtouchHIS_Base;User ID={{ .DatabaseUser }};Password={{ .DatabasePassword }};MultipleActiveResultSets=true;" + } +} + + + diff --git a/config/sett/web/database.config.tmpl b/config/Sett/Configs/database.config.tmpl similarity index 100% rename from config/sett/web/database.config.tmpl rename to config/Sett/Configs/database.config.tmpl diff --git a/config/sett/web/log4net.config b/config/Sett/Configs/log4net.config similarity index 100% rename from config/sett/web/log4net.config rename to config/Sett/Configs/log4net.config diff --git a/config/sett/web/system.config.tmpl b/config/Sett/Configs/system.config.tmpl similarity index 99% rename from config/sett/web/system.config.tmpl rename to config/Sett/Configs/system.config.tmpl index b722e4e41e832b4a55ac6a454bdc4f090e65d892..1d1ba568b58bb207052a96122f39ab3dff3579f8 100644 --- a/config/sett/web/system.config.tmpl +++ b/config/Sett/Configs/system.config.tmpl @@ -63,7 +63,7 @@ - + diff --git a/config/sett/api/database.config.tmpl b/config/SettAPI/Configs/database.config.tmpl similarity index 100% rename from config/sett/api/database.config.tmpl rename to config/SettAPI/Configs/database.config.tmpl diff --git a/config/sett/api/log4net.config b/config/SettAPI/Configs/log4net.config similarity index 100% rename from config/sett/api/log4net.config rename to config/SettAPI/Configs/log4net.config diff --git a/config/sett/api/system.config.tmpl b/config/SettAPI/Configs/system.config.tmpl similarity index 91% rename from config/sett/api/system.config.tmpl rename to config/SettAPI/Configs/system.config.tmpl index 55344dcfe1fc7584576bde390c36e9dececf5885..046bff0916152dec38374cb5bf34f1d496f1c95f 100644 --- a/config/sett/api/system.config.tmpl +++ b/config/SettAPI/Configs/system.config.tmpl @@ -5,14 +5,12 @@ - - - + @@ -36,6 +34,7 @@ + diff --git a/config/union/appsettings.json.tmpl b/config/Union/appsettings.json.tmpl similarity index 100% rename from config/union/appsettings.json.tmpl rename to config/Union/appsettings.json.tmpl diff --git a/config/emr/api/database.config.tmpl b/config/emr/api/database.config.tmpl deleted file mode 100644 index 3049216c4c629e4f0dc7d363ec7c4b3881df66cc..0000000000000000000000000000000000000000 --- a/config/emr/api/database.config.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/config/emr/api/system.config.tmpl b/config/emr/api/system.config.tmpl deleted file mode 100644 index de5371abfc36798425846d33c58136c64d69d2ac..0000000000000000000000000000000000000000 --- a/config/emr/api/system.config.tmpl +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/herp/api/database.config.tmpl b/config/herp/api/database.config.tmpl deleted file mode 100644 index e0158df9aa5e1ff78ffbaa3eefb10bcd9e20bb2d..0000000000000000000000000000000000000000 --- a/config/herp/api/database.config.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/config/herp/api/system.config.tmpl b/config/herp/api/system.config.tmpl deleted file mode 100644 index 6f3c29c0dbb53485331acba1009a85c2a80b864b..0000000000000000000000000000000000000000 --- a/config/herp/api/system.config.tmpl +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/HIS_BaseAPI/appsettings.json.tmpl b/config/his.baseapi/appsettings.json.tmpl similarity index 100% rename from config/HIS_BaseAPI/appsettings.json.tmpl rename to config/his.baseapi/appsettings.json.tmpl diff --git a/config/mrms/api/database.config.tmpl b/config/mrms/api/database.config.tmpl deleted file mode 100644 index f2271ef11c3fbf6759508fc726b41548e6992899..0000000000000000000000000000000000000000 --- a/config/mrms/api/database.config.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/config/mrms/api/system.config.tmpl b/config/mrms/api/system.config.tmpl deleted file mode 100644 index de5371abfc36798425846d33c58136c64d69d2ac..0000000000000000000000000000000000000000 --- a/config/mrms/api/system.config.tmpl +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/mrqc/api/database.config.tmpl b/config/mrqc/api/database.config.tmpl deleted file mode 100644 index 3d4ac9bd80d4293aa3e348a28ff4f54fba9f2f83..0000000000000000000000000000000000000000 --- a/config/mrqc/api/database.config.tmpl +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/config/mrqc/api/system.config.tmpl b/config/mrqc/api/system.config.tmpl deleted file mode 100644 index f2244f3a6f557c7fd108e90c65f92fb9e82647dc..0000000000000000000000000000000000000000 --- a/config/mrqc/api/system.config.tmpl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/or/api/database.config.tmpl b/config/or/api/database.config.tmpl deleted file mode 100644 index 3d43a1bcb3bb2776d991aa5d72cbc2090ad9dc05..0000000000000000000000000000000000000000 --- a/config/or/api/database.config.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/config/or/api/system.config.tmpl b/config/or/api/system.config.tmpl deleted file mode 100644 index de5371abfc36798425846d33c58136c64d69d2ac..0000000000000000000000000000000000000000 --- a/config/or/api/system.config.tmpl +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/go.mod b/go.mod index 9ce711f17e94b043a7f9b23c04bc93baf82721ed..8b3ca259ca82a0ceeeb48b0d27f0fe01e2fd450b 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,13 @@ -module openhis-config-temp +module openhis-config go 1.21 -require gopkg.in/yaml.v2 v2.4.0 // indirect +require ( + github.com/spf13/cobra v1.8.1 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/go.sum b/go.sum index 75346616b19bda7882ecbba954fe5bc1e5577468..a01295bb5e263b63437e9cb67eaa794937d62251 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,12 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 1a2a2576ab44a472f6e20ea1d4f46345ce3dbb11..b75f404abc52104dfa8473ad3c49df2383d8b816 100644 --- a/main.go +++ b/main.go @@ -1,86 +1,10 @@ +/* +Copyright © 2024 NAME HERE haijiang.mo@newtouch.com +*/ package main -import ( - "fmt" - "gopkg.in/yaml.v2" - "log" - "os" - "path/filepath" - "strings" - "text/template" -) +import "openhis-config/cmd" func main() { - var variable Variable - - data, err := os.ReadFile("./variable.yaml") - if err != nil { - log.Fatalf("error: %v", err) - } - // 解析 YAML 到结构体 - err = yaml.Unmarshal(data, &variable) - if err != nil { - log.Fatalf("error: %v", err) - } - - fmt.Println(variable.DatabaseHost) - - // 要遍历的目录路径 - dirPath := "./config" - - // 回调函数,处理每个文件或目录 - err = filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { - if err != nil { - fmt.Println(err) // 打印错误信息 - return err // 返回错误,可以决定是否继续遍历 - } - if info.IsDir() { - fmt.Printf("Directory: %s\n", path) - } else if filepath.Ext(info.Name()) == ".tmpl" { - fmt.Printf("File temp: %s\n", path) - err := RenderTemplate(variable, path) - if err != nil { - fmt.Println("filepath.Walk() RenderTemplate returned:", err) - return err - } - - } - return nil // 继续遍历 - }) - - if err != nil { - fmt.Println("filepath.Walk() returned:", err) - } -} - -func RenderTemplate(variable Variable, templatePath string) error { - // 输出文件路径 - outputPath := strings.Replace(templatePath, ".tmpl", "", 1) - - // 读取模板文件 - tmplBytes, err := os.ReadFile(templatePath) - if err != nil { - panic(err) - } - - // 解析模板 - t, err := template.New("template").Parse(string(tmplBytes)) - if err != nil { - panic(err) - } - // 创建输出文件 - outputFile, err := os.Create(outputPath) - if err != nil { - panic(err) - } - defer outputFile.Close() - - // 渲染模板到输出文件 - err = t.Execute(outputFile, variable) - if err != nil { - panic(err) - } - - fmt.Println("Template rendered and output file created.") - return nil + cmd.Execute() } diff --git a/openhis-config-temp.exe b/openhis-config.exe similarity index 41% rename from openhis-config-temp.exe rename to openhis-config.exe index 5176d1c28128eaf77eadcaa1259be4fb87373ac2..8d6a42eb4eabe5abce737643a1ab6185bee38126 100644 Binary files a/openhis-config-temp.exe and b/openhis-config.exe differ diff --git a/variable.yaml b/variable.yaml index 188df12c7df05ed39386de1176b06cb6c184739b..6e43b91a2334dfc73ad8b1cc5b37da313abe16a1 100644 --- a/variable.yaml +++ b/variable.yaml @@ -1,60 +1,87 @@ ## 数据库连接地址 -DatabaseHost: 61.172.179.6,30557 +DatabaseHost: 61.172.179.6,30288 ## 数据库用户名 DatabaseUser: sa ## 数据库密码 -DatabasePassword: 1qazxsw2# +DatabasePassword: Abcd1234 ## redis 连接地址 RedisHost: 61.172.179.6:32079 ## redis 密码 RedisPassword: newtouch -## 服务暴露IP: -PublicIP: 192.168.9.190 +## 服务暴露IP(公网IP,如不需要公网映射,直接填写内网IP即可): +PublicIP: 127.0.0.1 ## 内网(局域网)IP -LanIP: 192.168.9.190 +LanIP: 127.0.0.1 Services: ## 公网服务端口 PublicWebPort: + ## 静态资源公网端口 Static: 8014 + ## 报表服务公网端口 Report: 8000 + ## 后台管理公网端口 Base: 8001 + ## 结算管理公网端口 Sett: 8002 + ## 医护协同公网端口 Cis: 8003 + ## 药房药库公网端口 Pds: 8004 + ## 电子病例公网端口 Emr: 8005 + ## 手术管理公网端口 Or: 8006 + ## 医疗资源管理公网端口 Herp: 8007 + ## 病案管理公网端口 Mrms: 8008 + ## 病例质控管理公网端口 Mrqc: 8009 + ## 认证接口公网端口 AuthCenter: 8015 + ## 统一api公网端口 WebAPIManage: 8016 + ## 基础api公网端口 HisBaseAPI: 8017 + ## 联合工作站公网端口 Union: 8018 ## 内网服务端口 LanWebPort: + ## 静态资源内网端口 Static: 8014 + ## 报表服务内网端口 Report: 8000 + ## 后台管理内网端口 Base: 8001 + ## 结算管理内网端口 Sett: 8002 + ## 医护协同内网端口 Cis: 8003 + ## 药房药库内网端口 Pds: 8004 + ## 电子病例内网端口 Emr: 8005 + ## 手术管理内网端口 Or: 8006 + ## 医疗资源管理内网端口 Herp: 8007 + ## 病案管理内网端口 Mrms: 8008 + ## 病例质控管理内网端口 Mrqc: 8009 + ## 联合工作站内网端口 Union: 8018 LanAPIPort: + ## 后台管理API 内网端口 Base: 7001 + ## 结算管理API 内网端口 Sett: 7002 + ## 医护协同API 内网端口 Cis: 7003 - Pds: 7004 - Emr: 7005 - Or: 7006 - Herp: 7007 - Mrms: 7008 - Mrqc: 7009 + ## 认证中心API 内网端口 AuthCenter: 8015 + ## 统一API 内网端口 WebAPIManage: 8016 + ## 基础API 内网端口 HisBaseAPI: 8017 \ No newline at end of file