【category 添加时BUG修复】
This commit is contained in:
parent
a0e69d02af
commit
d7593e5e2d
@ -2795,6 +2795,7 @@ type CalculateLink struct {
|
||||
BRelatedRef *RelatedRef `protobuf:"bytes,5,opt,name=bRelatedRef,proto3" json:"bRelatedRef,omitempty"` // B端(最大端)关联的端点
|
||||
DevicePositions []*CalculateLink_DevicePosition `protobuf:"bytes,6,rep,name=devicePositions,proto3" json:"devicePositions,omitempty"` //设备在link上的位置
|
||||
Index int32 `protobuf:"varint,7,opt,name=index,proto3" json:"index,omitempty"` //link唯一标识
|
||||
Ab bool `protobuf:"varint,8,opt,name=ab,proto3" json:"ab,omitempty"` // 是否是从A->B, 道岔直连为false
|
||||
}
|
||||
|
||||
func (x *CalculateLink) Reset() {
|
||||
@ -2878,6 +2879,13 @@ func (x *CalculateLink) GetIndex() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CalculateLink) GetAb() bool {
|
||||
if x != nil {
|
||||
return x.Ab
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type CalculateLink_DevicePosition struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -3404,7 +3412,7 @@ var file_stationLayoutGraphics_proto_rawDesc = []byte{
|
||||
0x01, 0x28, 0x11, 0x52, 0x0f, 0x63, 0x75, 0x72, 0x76, 0x61, 0x74, 0x75, 0x72, 0x65, 0x4e, 0x75,
|
||||
0x6d, 0x62, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x66, 0x44, 0x65, 0x76, 0x69, 0x63,
|
||||
0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x66, 0x44, 0x65,
|
||||
0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0xcb, 0x03, 0x0a, 0x0d, 0x43, 0x61, 0x6c, 0x63, 0x75,
|
||||
0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0xdb, 0x03, 0x0a, 0x0d, 0x43, 0x61, 0x6c, 0x63, 0x75,
|
||||
0x6c, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d,
|
||||
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68,
|
||||
0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x49, 0x6e, 0x66,
|
||||
@ -3426,7 +3434,8 @@ var file_stationLayoutGraphics_proto_rawDesc = []byte{
|
||||
0x6c, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50,
|
||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50,
|
||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65,
|
||||
0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x1a, 0x64,
|
||||
0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x61, 0x62, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x61, 0x62, 0x1a, 0x64,
|
||||
0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x76, 0x69,
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 269cba242ab05d5c664386075386eb6a624bc861
|
||||
Subproject commit b301710b88a46b232bdeae5cd480f002342b01a5
|
@ -16,7 +16,7 @@ func PageCategoryQuery(query *dto.PageCategoryReqDto) (*dto.PageDto, error) {
|
||||
if query.Name != "" {
|
||||
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
|
||||
}
|
||||
records, total, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size)
|
||||
records, total, err := dq.Debug().Select(d.ID, d.Code, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -39,7 +39,7 @@ func ListCategoryQuery(query *dto.PageCategoryReqDto) ([]*model.Category, error)
|
||||
|
||||
// 创建草稿
|
||||
func CreateCategory(dto *dto.CategoryDto) (*model.Category, error) {
|
||||
if err := checkCategoryInfo(dto.Name); err != nil {
|
||||
if err := checkCategoryInfo(dto.Name, dto.Code, 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
d := model.Category{
|
||||
@ -65,11 +65,17 @@ func QueryCategory(id int32) *model.Category {
|
||||
}
|
||||
|
||||
func UpdateCategory(id int32, dto *dto.CategoryDto) bool {
|
||||
if err := checkCategoryInfo(dto.Name, dto.Code, id); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
findOldQuery := dbquery.Category
|
||||
oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First()
|
||||
if oldD == nil || err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if dto.Code != "" {
|
||||
oldD.Code = dto.Code
|
||||
}
|
||||
if dto.Config != "" {
|
||||
oldD.Config = dto.Config
|
||||
}
|
||||
@ -88,14 +94,29 @@ func DeleteCategoryById(id int) {
|
||||
_, _ = dbquery.Category.Debug().Where(dbquery.Category.ID.Eq(int32(id))).Delete()
|
||||
}
|
||||
|
||||
func checkCategoryInfo(name string) error {
|
||||
func checkCategoryInfo(name string, code string, id int32) error {
|
||||
findNameQuery := dbquery.Category
|
||||
count, err := findNameQuery.Where(findNameQuery.Name.Eq(name)).Debug().Count()
|
||||
w := findNameQuery.Where()
|
||||
if id != 0 {
|
||||
w = w.Where(findNameQuery.ID.Eq(id))
|
||||
}
|
||||
if name != "" {
|
||||
count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if count > 0 {
|
||||
panic("名称已存在")
|
||||
}
|
||||
return err
|
||||
}
|
||||
if code != "" {
|
||||
count, err := w.Where(findNameQuery.Code.Eq(code)).Debug().Count()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if count > 0 {
|
||||
panic("编码已存在")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user