From 6ddd63990fa1f568db14fee7ec385af001f3e13f Mon Sep 17 00:00:00 2001 From: zhouzhibo Date: Fri, 9 Apr 2021 10:19:01 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ac79190..be79d08 100644 --- a/build.sh +++ b/build.sh @@ -148,7 +148,7 @@ function init(){ if [ -f "${BASE_DIR}/build/config/settings.yml" ];then CONFIG_FILE=${BASE_DIR}/build/config/settings.yml else - echo_red "配置文件不存在,请检查配置文件是否存在。" + echo_red "配置文件 ${BASE_DIR}/build/config/settings.yml 不存在,请检查。" exit 1 fi echo_done From fde3f596d7ca95ac51f4ad4ca99aa9b87fe00228 Mon Sep 17 00:00:00 2001 From: zhouzhibo Date: Mon, 12 Apr 2021 21:31:33 +0800 Subject: [PATCH 2/7] =?UTF-8?q?head:=20fix:=20=E4=BC=98=E5=8C=96=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 137 ++++++++++++++++++++++++++------------------ config/settings.yml | 2 +- 2 files changed, 81 insertions(+), 58 deletions(-) diff --git a/build.sh b/build.sh index be79d08..a0b33e9 100644 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ # # id : AL1009 # -# Last modified: 2021-04-07 21:45 +# Last modified: 2021-04-12 21:18 # # Filename: build.sh # @@ -35,7 +35,6 @@ function echo_done() { } function get_db_config() { - cwd=$(pwd) key=$1 value=$(sed -n '/database/,/domain/p' "${CONFIG_FILE}" |awk -F : /^[[:space:]]*${key}/'{print $2}') @@ -81,7 +80,7 @@ EOF function check_soft { local _soft_name=$1 command -v ${_soft_name} > /dev/null || { - echo_red "请安装 ${_soft_name} 后再执行本脚本安装ferry。" + echo_red "请安装 ${_soft_name} 后再执行本脚本安装ferry。" exit 1 } } @@ -123,14 +122,20 @@ function mk_ferry_dir { } function test_mysql_connect() { - host=$1 - port=$2 - user=$3 - password=$4 - db=$5 - command="CREATE TABLE IF NOT EXISTS test(id INT); DROP TABLE test;" - echo_green "\n>>> $(gettext '拉取mysql docker 镜像如果是首次需要耗时,请稍等...')" - docker run -it --rm mysql:5 mysql -h${host} -P${port} -u${user} -p${password} ${db} -e "${command}" 2>/dev/null + host=$1 + port=$2 + user=$3 + password=$4 + db=$5 + sql_command="CREATE TABLE IF NOT EXISTS test(id INT); DROP TABLE test;" + command -v mysql > /dev/null + if [ "$?" -eq 0 ];then + mysql -h${host} -P${port} -u${user} -p${password} ${db} -e "${sql_command}" 2>/dev/null + else + [ "${host}" == "127.0.0.1" ] && return 0 + echo_green "\n>>> $(gettext '拉取mysql docker 镜像如果是首次需要耗时,请稍等...')" + docker run -it --rm mysql:5 mysql -h${host} -P${port} -u${user} -p${password} ${db} -e "${sql_command}" 2>/dev/null + fi } function init(){ @@ -148,41 +153,53 @@ function init(){ if [ -f "${BASE_DIR}/build/config/settings.yml" ];then CONFIG_FILE=${BASE_DIR}/build/config/settings.yml else - echo_red "配置文件 ${BASE_DIR}/build/config/settings.yml 不存在,请检查。" + echo_red "配置文件: ${BASE_DIR}/build/config/settings.yml 不存在,请检查。" exit 1 fi - echo_done +} +function set_external_redis() { + redis_host=$(awk --re-interval '/url: redis/{match($0,/([0-9]{1,3}\.){3}[0-9]{1,3}/,a); print a[0]}' ${CONFIG_FILE}) + read_from_input redis_host "$(gettext 'Please enter Redis server IP')" "" "${redis_host}" + + redis_port=$(awk -F : '/url: redis/{print $NF}' ${CONFIG_FILE}) + read_from_input redis_port "$(gettext 'Please enter Redis server port')" "" "${redis_port}" + + redis_pass=$(awk -F '/' '/url: redis/{if($0~"@")print $3}' ${CONFIG_FILE} |cut -f 1 -d '@') + read_from_input mysql_pass "$(gettext 'Please enter Redis password, 密码里面不能带@ /, 密码为空请务必修改配置文件!!')" "" "${redis_pass}" + + # 设置redis账号密码到配置文件 + sed -i "s/url: redis:\/\/.*/url: redis:\/\/${redis_pass}@${redis_host}:${redis_port}/g" ${CONFIG_FILE} } function set_external_mysql() { - mysql_host=$(get_db_config host) - read_from_input mysql_host "$(gettext 'Please enter MySQL server IP')" "" "${mysql_host}" + mysql_host=$(get_db_config host) + read_from_input mysql_host "$(gettext 'Please enter MySQL server IP')" "" "${mysql_host}" - mysql_port=$(get_db_config port) - read_from_input mysql_port "$(gettext 'Please enter MySQL server port')" "" "${mysql_port}" + mysql_port=$(get_db_config port) + read_from_input mysql_port "$(gettext 'Please enter MySQL server port')" "" "${mysql_port}" - mysql_db=$(get_db_config name) - read_from_input mysql_db "$(gettext 'Please enter MySQL database name')" "" "${mysql_db}" + mysql_db=$(get_db_config name) + read_from_input mysql_db "$(gettext 'Please enter MySQL database name')" "" "${mysql_db}" - mysql_user=$(get_db_config username) - read_from_input mysql_user "$(gettext 'Please enter MySQL username')" "" "${mysql_user}" + mysql_user=$(get_db_config username) + read_from_input mysql_user "$(gettext 'Please enter MySQL username')" "" "${mysql_user}" - mysql_pass=$(get_db_config password) - read_from_input mysql_pass "$(gettext 'Please enter MySQL password')" "" "${mysql_pass}" + mysql_pass=$(get_db_config password) + read_from_input mysql_pass "$(gettext 'Please enter MySQL password')" "" "${mysql_pass}" - test_mysql_connect ${mysql_host} ${mysql_port} ${mysql_user} ${mysql_pass} ${mysql_db} - if [[ "$?" != "0" ]]; then - echo_red "测试连接数据库失败, 请重新设置" - echo - set_external_mysql - fi + test_mysql_connect ${mysql_host} ${mysql_port} ${mysql_user} ${mysql_pass} ${mysql_db} + if [[ "$?" != "0" ]]; then + echo_red "测试连接数据库失败, 请重新设置" + echo + set_external_mysql + fi - set_db_config "host" ${mysql_host} - set_db_config "port" ${mysql_port} - set_db_config "username" ${mysql_user} - set_db_config "password" ${mysql_pass} - set_db_config "name" ${mysql_db} + set_db_config "host" ${mysql_host} + set_db_config "port" ${mysql_port} + set_db_config "username" ${mysql_user} + set_db_config "password" ${mysql_pass} + set_db_config "name" ${mysql_db} } function config_mysql { @@ -197,8 +214,20 @@ function config_mysql { fi } +function config_redis { + echo_green "\n>>> $(gettext '回车前请确保你已经安装了Redis,且启动服务')" + read_from_input confirm "$(gettext 'Do you have been installed Redis')?" "y/n" "y" + + if [[ "${confirm}" == "y" ]]; then + set_external_redis + else + echo_red "未安装Redis结束此次编译" + exit 1 + fi +} + function get_variables { - read_from_input front_url "$(gettext '请输入您的程序访问地址: ')" "" "https://fdevops.com:8001" + read_from_input front_url "$(gettext '请输入您的程序访问地址: ')" "" "https://127.0.0.1:8002" read_from_input front_clone_from "$(gettext '请选择从哪里拉取前端代码,默认是gitee: 1:gitee, 2: github, 3:自定义地址')" "" "1" if [ $front_clone_from == 1 ]; then @@ -210,15 +239,23 @@ function get_variables { fi config_mysql - read_from_input confirm "$(gettext '请确认是否创建配置文件中的redis库')?" "y/n[y]" "y" - if [[ "${confirm}" != "y" ]]; then - echo_red "结束此次编译" - exit 1 - fi + config_redis echo_done } +function config_front { + echo_green "\n>>> $(gettext '替换程序访问地址...')" + cat > ${BASE_DIR}/ferry_web/.env.production << EOF +# just a flag +ENV = 'production' + +# base api +VUE_APP_BASE_API = '$front_url' +EOF + +} + function install_front { echo_green "\n>>> $(gettext '开始拉取前端程序...')" read_from_input confirm "$(gettext '此处会执行 rm -rf ./ferry_web 的命令,若此命令不会造成当前环境的损伤则请继续')?" "y/n[y]" "y" @@ -238,7 +275,7 @@ function install_front { echo_red "克隆代码失败,请检查git地址: ${ui_address}或者网络质量" exit 1 fi - + config_front echo_green "\n>>> $(gettext '开始安装前端依赖...')" cnpm_base_dir=$(dirname $(dirname $(which npm))) npm install -g cnpm --registry=https://registry.npm.taobao.org --prefix ${cnpm_base_dir} @@ -246,19 +283,6 @@ function install_front { } -function config_front { - echo_green "\n>>> $(gettext '替换程序访问地址...')" - cat > ${BASE_DIR}/ferry_web/.env.production << EOF -# just a flag -ENV = 'production' - -# base api -VUE_APP_BASE_API = '$front_url' -EOF - -} - - function install_backend { echo_green "\n>>> $(gettext '开始编译后端程序...')" @@ -282,7 +306,7 @@ function install_backend { fi cp -r ${BASE_DIR}/ferry ${BASE_DIR}/build/ cd ${BASE_DIR}/build - ${BASE_DIR}/ferry init -c=config/settings.yml + ${BASE_DIR}/build/ferry init -c=config/settings.yml cd - &>/dev/null } @@ -291,13 +315,12 @@ function install_app() { init get_variables install_front - config_front install_backend } function start_backend { cd ${BASE_DIR}/build - ${BASE_DIR}/ferry server -c=config/settings.yml + ./ferry server -c=config/settings.yml } function main { diff --git a/config/settings.yml b/config/settings.yml index 0d9fe38..f9df756 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -53,7 +53,7 @@ settings: maxsize: 10240 path: ./logs/ferry.log redis: - url: redis://ferry123456@127.0.0.1:6379 + url: redis://127.0.0.1:6379 ssl: key: keystring pem: temp/pem.pem From 545140d7b07f7d36d94d2cd3979e9e4bbfa546d5 Mon Sep 17 00:00:00 2001 From: zhouzhibo Date: Tue, 13 Apr 2021 09:08:20 +0800 Subject: [PATCH 3/7] =?UTF-8?q?head:=20fix:=20=E4=BF=AE=E6=94=B9=E9=9D=99?= =?UTF-8?q?=E6=80=81=E6=96=87=E4=BB=B6=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/router.go b/router/router.go index dfd4e0a..2ac5c61 100644 --- a/router/router.go +++ b/router/router.go @@ -35,7 +35,7 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) *gin } func sysStaticFileRouter(r *gin.RouterGroup, g *gin.Engine) { - r.Static("/static", "./static") + r.Static("/static", "./template/web/static") g.LoadHTMLGlob("template/web/index.html") } From 1c46f04c7e80974006876ce166f65f471c646d5c Mon Sep 17 00:00:00 2001 From: zhouzhibo Date: Tue, 13 Apr 2021 09:26:16 +0800 Subject: [PATCH 4/7] =?UTF-8?q?head:=20fix:=20=E4=BF=AE=E6=94=B9Redis?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index a0b33e9..0ddfbd2 100644 --- a/build.sh +++ b/build.sh @@ -166,10 +166,14 @@ function set_external_redis() { read_from_input redis_port "$(gettext 'Please enter Redis server port')" "" "${redis_port}" redis_pass=$(awk -F '/' '/url: redis/{if($0~"@")print $3}' ${CONFIG_FILE} |cut -f 1 -d '@') - read_from_input mysql_pass "$(gettext 'Please enter Redis password, 密码里面不能带@ /, 密码为空请务必修改配置文件!!')" "" "${redis_pass}" + read_from_input redis_pass "$(gettext 'Please enter Redis password, 密码里面不能带@ /, 密码为空请务必修改配置文件!!')" "" "${redis_pass}" # 设置redis账号密码到配置文件 - sed -i "s/url: redis:\/\/.*/url: redis:\/\/${redis_pass}@${redis_host}:${redis_port}/g" ${CONFIG_FILE} + if [ "${redis_pass}" == "" ];then + sed -i "s/url: redis:\/\/.*/url: redis:\/\/${redis_host}:${redis_port}/g" ${CONFIG_FILE} + else + sed -i "s/url: redis:\/\/.*/url: redis:\/\/${redis_pass}@${redis_host}:${redis_port}/g" ${CONFIG_FILE} + fi } function set_external_mysql() { From 0684d701dcb6dd33c0c1a484a4bd530b1ef3df7a Mon Sep 17 00:00:00 2001 From: java <943927833@qq.com> Date: Tue, 13 Apr 2021 15:17:05 +0800 Subject: [PATCH 5/7] Update build.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改默认的访问地址 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 0ddfbd2..77f0b0e 100644 --- a/build.sh +++ b/build.sh @@ -231,7 +231,7 @@ function config_redis { } function get_variables { - read_from_input front_url "$(gettext '请输入您的程序访问地址: ')" "" "https://127.0.0.1:8002" + read_from_input front_url "$(gettext '请输入您的程序访问地址: ')" "" "https://fdevops.com:8002" read_from_input front_clone_from "$(gettext '请选择从哪里拉取前端代码,默认是gitee: 1:gitee, 2: github, 3:自定义地址')" "" "1" if [ $front_clone_from == 1 ]; then From 6595acb5d4bd62190b60f8fb3291edd507b21504 Mon Sep 17 00:00:00 2001 From: YuleiLan Date: Thu, 15 Apr 2021 18:13:07 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/router.go b/router/router.go index 2ac5c61..dfd4e0a 100644 --- a/router/router.go +++ b/router/router.go @@ -35,7 +35,7 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) *gin } func sysStaticFileRouter(r *gin.RouterGroup, g *gin.Engine) { - r.Static("/static", "./template/web/static") + r.Static("/static", "./static") g.LoadHTMLGlob("template/web/index.html") } From 0ca5490e818089c9cbf36256257a309e615c17bf Mon Sep 17 00:00:00 2001 From: YuleiLan Date: Mon, 19 Apr 2021 16:05:54 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=9B=A0=E6=B5=81=E7=A8=8B=E5=88=A0=E9=99=A4=E8=80=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=98=BE=E7=A4=BA=E7=9A=84bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/process.go | 78 +++++++++++++++++++----------------- pkg/service/userAuthority.go | 15 ++++--- 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/pkg/service/process.go b/pkg/service/process.go index c69f4e5..d8e42c7 100644 --- a/pkg/service/process.go +++ b/pkg/service/process.go @@ -34,38 +34,40 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma ) err = orm.Eloquent.Model(&processValue).Where("id = ?", processId).Find(&processValue).Error - if err != nil { - err = fmt.Errorf("查询流程失败,%v", err.Error()) - return - } + //if err != nil { + // err = fmt.Errorf("查询流程失败,%v", err.Error()) + // return + //} - err = json.Unmarshal([]byte(processValue.Structure), &processStructureDetails) - if err != nil { - err = fmt.Errorf("json转map失败,%v", err.Error()) - return - } + if processValue.Structure != nil && len(processValue.Structure) > 0 { + err = json.Unmarshal([]byte(processValue.Structure), &processStructureDetails) + if err != nil { + err = fmt.Errorf("json转map失败,%v", err.Error()) + return + } - // 排序,使用冒泡 - p := processStructureDetails["nodes"].([]interface{}) - if len(p) > 1 { - for i := 0; i < len(p); i++ { - for j := 1; j < len(p)-i; j++ { - if p[j].(map[string]interface{})["sort"] == nil || p[j-1].(map[string]interface{})["sort"] == nil { - return nil, errors.New("流程未定义顺序属性,请确认") - } - leftInt, _ := strconv.Atoi(p[j].(map[string]interface{})["sort"].(string)) - rightInt, _ := strconv.Atoi(p[j-1].(map[string]interface{})["sort"].(string)) - if leftInt < rightInt { - //交换 - p[j], p[j-1] = p[j-1], p[j] + // 排序,使用冒泡 + p := processStructureDetails["nodes"].([]interface{}) + if len(p) > 1 { + for i := 0; i < len(p); i++ { + for j := 1; j < len(p)-i; j++ { + if p[j].(map[string]interface{})["sort"] == nil || p[j-1].(map[string]interface{})["sort"] == nil { + return nil, errors.New("流程未定义顺序属性,请确认") + } + leftInt, _ := strconv.Atoi(p[j].(map[string]interface{})["sort"].(string)) + rightInt, _ := strconv.Atoi(p[j-1].(map[string]interface{})["sort"].(string)) + if leftInt < rightInt { + //交换 + p[j], p[j-1] = p[j-1], p[j] + } } } + for _, node := range processStructureDetails["nodes"].([]interface{}) { + processNode = append(processNode, node.(map[string]interface{})) + } + } else { + processNode = processStructureDetails["nodes"].([]map[string]interface{}) } - for _, node := range processStructureDetails["nodes"].([]interface{}) { - processNode = append(processNode, node.(map[string]interface{})) - } - } else { - processNode = processStructureDetails["nodes"].([]map[string]interface{}) } processValue.Structure = nil @@ -141,18 +143,20 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma if len(stateList) > 0 { breakStateTag: for _, stateValue := range stateList { - for _, processNodeValue := range processStructureDetails["nodes"].([]interface{}) { - if stateValue["id"].(string) == processNodeValue.(map[string]interface{})["id"] { - if _, ok := stateValue["processor"]; ok { - for _, userId := range stateValue["processor"].([]interface{}) { - if int(userId.(float64)) == tools.GetUserId(c) { - workOrderInfo.CurrentState = stateValue["id"].(string) - break breakStateTag + if processStructureDetails["nodes"] != nil { + for _, processNodeValue := range processStructureDetails["nodes"].([]interface{}) { + if stateValue["id"].(string) == processNodeValue.(map[string]interface{})["id"] { + if _, ok := stateValue["processor"]; ok { + for _, userId := range stateValue["processor"].([]interface{}) { + if int(userId.(float64)) == tools.GetUserId(c) { + workOrderInfo.CurrentState = stateValue["id"].(string) + break breakStateTag + } } + } else { + err = errors.New("未查询到对应的处理人字段,请确认。") + return } - } else { - err = errors.New("未查询到对应的处理人字段,请确认。") - return } } } diff --git a/pkg/service/userAuthority.go b/pkg/service/userAuthority.go index 26c7334..576a8e7 100644 --- a/pkg/service/userAuthority.go +++ b/pkg/service/userAuthority.go @@ -44,12 +44,15 @@ func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (s // 获取流程信息 err = orm.Eloquent.Model(&process.Info{}).Where("id = ?", workOrderInfo.Process).Find(&processInfo).Error - if err != nil { - return - } - err = json.Unmarshal(processInfo.Structure, &processState.Structure) - if err != nil { - return + //if err != nil { + // return + //} + + if processInfo.Structure != nil && len(processInfo.Structure) > 0 { + err = json.Unmarshal(processInfo.Structure, &processState.Structure) + if err != nil { + return + } } stateValue, err = processState.GetNode(currentState)