Fix problems modifying personal information,Upgrade route configuration format

This commit is contained in:
zhangwenjian
2020-05-25 21:30:29 +08:00
parent e07cb22255
commit c0b8199c36
18 changed files with 355 additions and 244 deletions
+1
View File
@@ -4,6 +4,7 @@ var (
CreatedSuccess = "创建成功!"
UpdatedSuccess = "更新成功!"
DeletedSuccess = "删除成功!"
DeletedFail = "删除失败!"
GetSuccess = "查询成功!"
NotFound = "未找到相关内容或者数据为空!"
)
-6
View File
@@ -14,9 +14,6 @@ var cfgApplication *viper.Viper
var cfgJwt *viper.Viper
var cfgLog *viper.Viper
//func init() {
// InitConfig("settings.dev")
//}
//载入配置文件
func ConfigSetup(path string) {
@@ -58,9 +55,6 @@ func ConfigSetup(path string) {
LogConfig = InitLog(cfgLog)
}
func SetApplicationIsInit() {
SetConfig("./config", "settings.application.isInit", false)
}
func SetConfig(configPath string, key string, value interface{}) {
viper.AddConfigPath(configPath)
+13
View File
@@ -53,3 +53,16 @@ func JsonStrToMap(e string) (map[string]interface{}, error) {
return nil, err
}
}
func StructToMap(data interface{}) (map[string]interface{}, error) {
dataBytes, err := json.Marshal(data)
if err != nil {
return nil, err
}
mapData := make(map[string]interface{})
err = json.Unmarshal(dataBytes, &mapData)
if err != nil {
return nil, err
}
return mapData, nil
}
+1 -1
View File
@@ -14,7 +14,6 @@ func StrToInt(err error, index string) int {
return result
}
func CompareHashAndPassword(e string, p string) (bool, error) {
err := bcrypt.CompareHashAndPassword([]byte(e), []byte(p))
if err != nil {
@@ -50,6 +49,7 @@ func HasError(err error, msg string, code ...int) {
if msg == "" {
msg = err.Error()
}
log.Println(err)
panic("CustomError#" + strconv.Itoa(statusCode) + "#" + msg)
}
}