fix bug.
This commit is contained in:
parent
0bdb8bdac6
commit
4626e07fbf
@ -87,7 +87,7 @@ INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/deptTree', 'GET', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/logout', 'POST', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/avatar', 'POST', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/pwd', 'PUT', NULL, NULL, NULL;
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/pwd', 'PUT', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/dashboard', 'GET', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'POST', NULL, NULL, NULL);
|
||||
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'GET', NULL, NULL, NULL);
|
||||
|
@ -24,13 +24,13 @@ func InitDb() error {
|
||||
return err
|
||||
}
|
||||
sqlList := strings.Split(sql, ";")
|
||||
for i := 0; i < len(sqlList)-1; i++ {
|
||||
if strings.Contains(sqlList[i], "--") {
|
||||
fmt.Println(sqlList[i])
|
||||
for _, sql := range sqlList {
|
||||
if strings.Contains(sql, "--") {
|
||||
fmt.Println(sql)
|
||||
continue
|
||||
}
|
||||
sql := strings.Replace(sqlList[i]+";", "\n", "", 0)
|
||||
if err = orm.Eloquent.Exec(sql).Error; err != nil {
|
||||
sqlValue := strings.Replace(sql+";", "\n", "", 1)
|
||||
if err = orm.Eloquent.Exec(sqlValue).Error; err != nil {
|
||||
if !strings.Contains(err.Error(), "Query was empty") {
|
||||
return err
|
||||
}
|
||||
@ -43,7 +43,6 @@ func Ioutil(name string) (string, error) {
|
||||
if contents, err := ioutil.ReadFile(name); err == nil {
|
||||
//因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符
|
||||
result := strings.Replace(string(contents), "\n", "", 1)
|
||||
fmt.Println("Use ioutil.ReadFile to read a file:", result)
|
||||
return result, nil
|
||||
} else {
|
||||
return "", err
|
||||
|
Loading…
x
Reference in New Issue
Block a user