优化
This commit is contained in:
@@ -17,8 +17,14 @@ func (s *DictionaryService) ImportDictionaryJSON(ctx context.Context, raw string
|
||||
Description string `json:"desc"`
|
||||
Details []dto.DictionaryDetailRequest `json:"sysDictionaryDetails"`
|
||||
}
|
||||
if json.Unmarshal([]byte(raw), &payload) != nil || payload.Name == "" || payload.Type == "" {
|
||||
return errors.New("JSON 格式错误")
|
||||
if err := json.Unmarshal([]byte(raw), &payload); err != nil {
|
||||
return errors.New("JSON 格式错误: " + err.Error())
|
||||
}
|
||||
if payload.Name == "" {
|
||||
return errors.New("字典名称不能为空")
|
||||
}
|
||||
if payload.Type == "" {
|
||||
return errors.New("字典类型不能为空")
|
||||
}
|
||||
dictionary := dictionaryDomain(&dto.DictionaryRequest{Name: payload.Name, Type: payload.Type, Status: payload.Status, Description: payload.Description})
|
||||
details := make([]*biz.DictionaryDetail, 0, len(payload.Details))
|
||||
|
||||
Reference in New Issue
Block a user