优化
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))
|
||||
|
||||
@@ -8,7 +8,7 @@ type DepartmentRequest struct {
|
||||
ParentID uint `json:"parentId"`
|
||||
Sort int `json:"sort"`
|
||||
LeaderID uint `json:"leaderId"`
|
||||
Status bool `json:"status"`
|
||||
Status *bool `json:"status"`
|
||||
}
|
||||
|
||||
type DepartmentListRequest struct {
|
||||
@@ -38,7 +38,7 @@ type DepartmentResponse struct {
|
||||
Sort int `json:"sort"`
|
||||
LeaderID uint `json:"leaderId"`
|
||||
Leader any `json:"leader"`
|
||||
Status bool `json:"status"`
|
||||
Status *bool `json:"status"`
|
||||
Children []*DepartmentResponse `json:"children"`
|
||||
NamePath string `json:"namePath"`
|
||||
}
|
||||
@@ -48,7 +48,7 @@ type PositionRequest struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Sort int `json:"sort"`
|
||||
Status bool `json:"status"`
|
||||
Status *bool `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -79,6 +79,6 @@ type PositionResponse struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Sort int `json:"sort"`
|
||||
Status bool `json:"status"`
|
||||
Status *bool `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user