// Package asArtshowV2 ----------------------------- // @file : pushDto.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2024/6/20 上午11:29 // ------------------------------------------- package asArtshow import ( "encoding/json" "fmt" "github.com/fonchain_enterprise/fonchain-main/api/artist" "github.com/fonchain_enterprise/fonchain-main/api/artistinfoArtshow" ) type HonorType struct { Title []HonorTitleType `json:"title"` School []HonorSchoolType `json:"-"` Award []HonorAwardType `json:"award"` ComeOut []HonorComeOutType `json:"-"` Exhibition []HonorExhibitionType `json:"exhibition"` Published []HonorPublishedType `json:"published"` Commentator []HonorCommentatorType `json:"-"` } func (h *HonorType) Parse(artistSupplement *artistinfoArtshow.ArtistSupplementV2Data) { h.Title = make([]HonorTitleType, 0) h.School = make([]HonorSchoolType, 0) h.Award = make([]HonorAwardType, 0) h.ComeOut = make([]HonorComeOutType, 0) h.Exhibition = make([]HonorExhibitionType, 0) h.Published = make([]HonorPublishedType, 0) h.Commentator = make([]HonorCommentatorType, 0) _ = json.Unmarshal([]byte(artistSupplement.Award), &h.Award) _ = json.Unmarshal([]byte(artistSupplement.Exhibition), &h.Exhibition) _ = json.Unmarshal([]byte(artistSupplement.Published), &h.Published) _ = json.Unmarshal([]byte(artistSupplement.Title), &h.Title) } func ParseHonorToArtistInfoType(honorList []*artist.HonorRequest) (data HonorType, err error) { data = HonorType{ Title: make([]HonorTitleType, 0), School: make([]HonorSchoolType, 0), Award: make([]HonorAwardType, 0), ComeOut: make([]HonorComeOutType, 0), Exhibition: make([]HonorExhibitionType, 0), Published: make([]HonorPublishedType, 0), Commentator: make([]HonorCommentatorType, 0), } for _, honorInfo := range honorList { var vBytes = []byte(honorInfo.HonorDetail) switch honorInfo.HonorType { case 1: var tmp HonorSchoolType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.School = append(data.School, tmp) case 2: var tmp HonorAwardType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.Award = append(data.Award, tmp) case 3: var tmp HonorTitleType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.Title = append(data.Title, tmp) case 4: var tmp HonorComeOutType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.ComeOut = append(data.ComeOut, tmp) case 5: fmt.Printf("exhibition: %+v\n", string(vBytes)) var tmp HonorExhibitionType err = json.Unmarshal(vBytes, &tmp) if err != nil { return } tmp.Id = honorInfo.Id data.Exhibition = append(data.Exhibition, tmp) case 6: fmt.Printf("Published: %+v\n", string(vBytes)) var tmp HonorPublishedType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.Published = append(data.Published, tmp) case 7: var tmp HonorCommentatorType _ = json.Unmarshal(vBytes, &tmp) tmp.Id = honorInfo.Id data.Commentator = append(data.Commentator, tmp) } } return } type PushArtistSupplementDataV2 struct { ArtistUid string `json:"artistUid"` ArtistProfile string `json:"artistProfile"` //ArtistCertPic string `json:"artistCertPic"` BankNum string `json:"bankNum"` BankName string `json:"bankName"` ArtistHonor HonorType } // 头衔 type HonorTitleType struct { Id int32 `json:"id"` Date string `json:"date"` Title string `json:"title"` Grade string `json:"grade"` Details string `json:"details"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` VoucherImg string `json:"voucherImg"` } func (h *HonorTitleType) ParseToArtistHonorRequest(artistUid string) *artist.HonorRequest { return &artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorTitleType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 游学地址/学校 type HonorSchoolType struct { Id int32 `json:"id"` Date string `json:"date"` StudyAddress string `json:"studyAddress"` Details string `json:"details"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorSchoolType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorSchoolType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 获奖称号 type HonorAwardType struct { Id int32 `json:"id"` Date string `json:"date"` Award string `json:"award"` EventName string `json:"eventName"` Picture string `json:"picture"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorAwardType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorAwardType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 出版内容 type HonorComeOutType struct { Id int32 `json:"id"` Date string `json:"date"` Content string `json:"content"` State string `json:"state"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorComeOutType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorComeOutType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 展览名称 type HonorExhibitionType struct { Id int32 `json:"id"` Date string `json:"date"` ExhibitionName string `json:"exhibitionName"` PaintingName string `json:"paintingName"` Picture string `json:"picture"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorExhibitionType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorExhibitionType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 发表内容 type HonorPublishedType struct { Id int32 `json:"id"` Date string `json:"date"` ContentName string `json:"contentName"` Articles string `json:"articles"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorPublishedType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorPublishedType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } // 评论方 type HonorCommentatorType struct { Id int32 `json:"id"` Date string `json:"date"` Person string `json:"person"` Comments string `json:"comments"` Photo string `json:"photo"` Picture string `json:"picture"` Video []HonorVideoType `json:"video"` Remark string `json:"remark"` Editable bool `json:"editable"` BtnDis bool `json:"btnDis"` } func (h *HonorCommentatorType) ParseToArtistHonorRequest(artistUid string) artist.HonorRequest { return artist.HonorRequest{ Uid: artistUid, HonorType: 1, HonorDetail: h.String(), } } func (h *HonorCommentatorType) String() string { bytes, _ := json.Marshal(h) return string(bytes) } type HonorVideoType struct { CoverUrl string `json:"CoverUrl"` OriUrl string `json:"OriUrl"` } type BankInfoType struct { BankNum string `json:"bankNum"` BankName string `json:"bankName"` }