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/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/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/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', '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', '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);
|
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
|
return err
|
||||||
}
|
}
|
||||||
sqlList := strings.Split(sql, ";")
|
sqlList := strings.Split(sql, ";")
|
||||||
for i := 0; i < len(sqlList)-1; i++ {
|
for _, sql := range sqlList {
|
||||||
if strings.Contains(sqlList[i], "--") {
|
if strings.Contains(sql, "--") {
|
||||||
fmt.Println(sqlList[i])
|
fmt.Println(sql)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sql := strings.Replace(sqlList[i]+";", "\n", "", 0)
|
sqlValue := strings.Replace(sql+";", "\n", "", 1)
|
||||||
if err = orm.Eloquent.Exec(sql).Error; err != nil {
|
if err = orm.Eloquent.Exec(sqlValue).Error; err != nil {
|
||||||
if !strings.Contains(err.Error(), "Query was empty") {
|
if !strings.Contains(err.Error(), "Query was empty") {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -43,7 +43,6 @@ func Ioutil(name string) (string, error) {
|
|||||||
if contents, err := ioutil.ReadFile(name); err == nil {
|
if contents, err := ioutil.ReadFile(name); err == nil {
|
||||||
//因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符
|
//因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符
|
||||||
result := strings.Replace(string(contents), "\n", "", 1)
|
result := strings.Replace(string(contents), "\n", "", 1)
|
||||||
fmt.Println("Use ioutil.ReadFile to read a file:", result)
|
|
||||||
return result, nil
|
return result, nil
|
||||||
} else {
|
} else {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user