修复自定义Marshal序列化的BUG

This commit is contained in:
2025-01-22 15:55:39 +08:00
parent c00354fe46
commit 10759d9c5e
8 changed files with 48 additions and 29 deletions

View File

@ -14,11 +14,11 @@ package consts
// Date : 14:10 2024/11/25
type DataType string
func (df DataType) String() string {
return string(df)
func (df *DataType) String() string {
return string(*df)
}
func (df DataType) MarshalJSON() ([]byte, error) {
func (df *DataType) MarshalJSON() ([]byte, error) {
return []byte(df.String()), nil
}
@ -27,9 +27,9 @@ func (df DataType) MarshalJSON() ([]byte, error) {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:45 2024/11/25
func (df DataType) IsValid() bool {
func (df *DataType) IsValid() bool {
for _, item := range DataTypeList {
if item.Value == df {
if item.Value == *df {
return true
}
}