Merge pull request 'fix dict bugs' (#106) from devad/pcm-coordinator:hot_fix into master
Former-commit-id: 4a51cebc7940f078c2f1515eed518ae66e1d1292
This commit is contained in:
commit
84576a9b7d
|
@ -817,7 +817,6 @@ type (
|
|||
ItemValue string `json:"itemValue,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
SortOrder string `json:"sortOrder,omitempty"`
|
||||
Type string `json:"type,omitempty" db:"type"`
|
||||
ParentId string `json:"parentId,omitempty"`
|
||||
Status string `json:"status,omitempty" db:"status"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
|
@ -843,7 +842,6 @@ type (
|
|||
ItemValue string `json:"itemValue,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
SortOrder string `json:"sortOrder,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
}
|
||||
|
@ -855,7 +853,6 @@ type (
|
|||
ItemValue string `json:"itemValue,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
SortOrder string `json:"sortOrder,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
ParentId string `json:"parentId,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
|
|
|
@ -39,11 +39,10 @@ func (l *AddDictItemLogic) AddDictItem(req *types.DictItemEditReq) (resp *types.
|
|||
dictItem.ItemValue = req.ItemValue
|
||||
dictItem.Description = req.Description
|
||||
dictItem.SortOrder = req.SortOrder
|
||||
dictItem.Type = req.Type
|
||||
dictItem.ParentId = "0"
|
||||
if req.ParentId != "" {
|
||||
dictItem.ParentId = req.ParentId
|
||||
}
|
||||
dictItem.ParentId = "0"
|
||||
dictItem.Status = req.Status
|
||||
dictItem.Id = utils.GenSnowflakeIDStr()
|
||||
dictItem.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
||||
|
|
|
@ -30,7 +30,7 @@ func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *type
|
|||
dictItem := &types.DictItemInfo{}
|
||||
result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id)
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
logx.Errorf("Dictionary data editing failure. errors: %s", err.Error())
|
||||
logx.Errorf("Dictionary data editing failure. errors: %s", result.Error)
|
||||
return nil, errors.New("DictItem does not exist")
|
||||
}
|
||||
utils.Convert(req, &dictItem)
|
||||
|
|
|
@ -31,7 +31,7 @@ func (l *EditDictLogic) EditDict(req *types.DictEditReq) (resp *types.DictResp,
|
|||
dict := &types.DictInfo{}
|
||||
result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id)
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
logx.Errorf("Dictionary editing failure. errors: %s", err.Error())
|
||||
logx.Errorf("Dictionary editing failure. errors: %s", result.Error)
|
||||
return nil, errors.New("Dict does not exist")
|
||||
}
|
||||
utils.Convert(req, &dict)
|
||||
|
|
|
@ -2,6 +2,7 @@ package dictionary
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
@ -29,12 +30,13 @@ func (l *ListDictItemByCodeLogic) ListDictItemByCode(req *types.DictCodeReq) (re
|
|||
db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict")
|
||||
|
||||
// 左连接查询
|
||||
db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id").
|
||||
err = db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id").
|
||||
Where("t_dict.dict_code = ?", req.DictCode).
|
||||
Where("t_dict_item.status", 1).
|
||||
Order("t_dict_item.sort_order").Scan(&dictList)
|
||||
Order("t_dict_item.sort_order").Scan(&dictList).Error
|
||||
if err != nil {
|
||||
return resp, err
|
||||
logx.Errorf("ListDictItemByCode()=> failed %s", err.Error())
|
||||
return nil, errors.New("description Failed to query dictionary entry data")
|
||||
}
|
||||
resp.List = dictList
|
||||
return resp, nil
|
||||
|
|
|
@ -791,7 +791,6 @@ type DictItemInfo struct {
|
|||
ItemValue string `json:"itemValue,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
SortOrder string `json:"sortOrder,omitempty"`
|
||||
Type string `json:"type,omitempty" db:"type"`
|
||||
ParentId string `json:"parentId,omitempty"`
|
||||
Status string `json:"status,omitempty" db:"status"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
|
@ -817,7 +816,6 @@ type DictItemEditReq struct {
|
|||
ItemValue string `json:"itemValue,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
SortOrder string `json:"sortOrder,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
ParentId string `json:"parentId,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
}
|
||||
|
@ -829,7 +827,6 @@ type DictItemResp struct {
|
|||
ItemValue string `json:"itemValue,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
SortOrder string `json:"sortOrder,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
ParentId string `json:"parentId,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
|
|
Loading…
Reference in New Issue