fonchain-fiee/pkg/service/artistInfo/asArtwork/supplementDto.go

370 lines
14 KiB
Go
Raw Normal View History

2025-02-19 06:24:15 +00:00
// Package dto -----------------------------
// @file : artworkSupplement.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2023/2/28 16:47
// -------------------------------------------
package asArtwork
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
"github.com/fonchain_enterprise/fonchain-main/api/artistInfoArtwork"
"github.com/fonchain_enterprise/fonchain-main/api/artistInfoUser"
"github.com/fonchain_enterprise/fonchain-main/api/artwork"
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
"github.com/fonchain_enterprise/fonchain-main/pkg/utils"
"github.com/fonchain_enterprise/fonchain-main/pkg/utils/stime"
)
// 画作补充信息
type ArtworkSupplementInfo struct {
// 画作首选项
//Id int `json:"id"`
ArtworkUuid string `json:"artworkUid"`
ArtistName string `json:"artistName"`
ArtistUid string `json:"artistUid"`
ArtworkName string `json:"artworkName"`
Length int32 `json:"length"`
Width int32 `json:"width"`
Ruler int32 `json:"ruler"`
InscribeDate string `json:"inscribeDate"` //落款时间
Abstract string `json:"abstract"` //简介
HdPic string `json:"hdPic"` //高清图
ArtistPhoto string `json:"artistPhoto"` //画家画作合照
CreatedDate string `json:"createdDate"` //初始创作时间
CreatedAddress string `json:"createdAddress"` //创作地址
PriceRun float32 `json:"priceRun"`
CreatedAt string `json:"createdAt"` //todo 这几个字段没画作服务没返回,待处理
UpdatedAt string `json:"updatedAt"` //todo 这几个字段没画作服务没返回,待处理
DeletedAt string `json:"deletedAt"` //todo 这几个字段没画作服务没返回,待处理
//首次发表
FirstPublish string `gorm:"column:first_publish" json:"firstPublish"` //type:string comment:首次发发表作品url
//FirstPublishImg string `gorm:"column:first_publish_img" json:"FirstPublishImg"` //type:string comment:首次发表作品url
//FirstName string `gorm:"column:first_name" json:"FirstName"` //type:string comment:首次命名
//FirstNameImg string `gorm:"column:first_name_img" json:"FirstNameImg"` //type:string comment:首次命名截图
// 画作荣誉
ArtistMarketDetail string `json:"artistMarketDetail"` //画作微服务ArtworkMarketData表 - Type: int32 =0 详情
ArtistMarketUrl1 string `json:"artistMarketUrl1"` //画作微服务ArtworkMarketData表 - Type: int32 =1 获奖
ArtistMarketUrl2 string `json:"artistMarketUrl2"` //画作微服务ArtworkMarketData表 - Type: int32 =1 拍卖
ArtistMarketId1 int32 `json:"artistMarketId1"` //对应上面三个字段的id
ArtistMarketId2 int32 `json:"artistMarketId2"`
ArtistMarketId3 int32 `json:"artistMarketId3"`
// 审核状态
SupplementAuditStatus int32 `json:"supplementAuditStatus"`
SupplementAuditMark string `json:"supplementAuditMark"`
SupplementAuditMark2 string `json:"supplementAuditMark2"`
//动态字段
Editable bool `json:"editable"` //该条数据是否可编辑
IsFirstPublish bool `json:"isFirstPublish"` //是否首次发表
//锁定状态
Status int64 `json:"lockStatus"` //锁定状态 2锁定 3解锁
Tfnum string `json:"tfnum"` //画作编号
}
func (a *ArtworkSupplementInfo) ConvertResponse(lockInfo *artistInfoArtwork.ArtworkLockInfo, profile *artwork.CreArtProRequest, marketInfo []*artwork.UpdateMInfoRequest, extDataInfo *artwork.UpdateExtDataRequest) error {
//查询该条数据是否可编辑
lockStatus, err := service.GrpcArtistInfoArtworkImpl.CheckArtworkSupplementInfoEditable(context.Background(), &artistInfoArtwork.ArtworkUidRequest{ArtworkUid: profile.ArtworkUuid})
if err != nil {
return err
}
a.Editable = lockStatus.Editable
a.Status = lockInfo.Status
//数据拼接
if lockInfo != nil {
a.ArtworkUuid = lockInfo.ArtworkUid
a.ArtistUid = lockInfo.ArtistUid
a.SupplementAuditStatus = lockInfo.SupplementAuditStatus
a.SupplementAuditMark = lockInfo.SupplementAuditMark
a.SupplementAuditMark2 = lockInfo.SupplementAuditMark2
a.CreatedAt = stime.TimeToString(time.Unix(lockInfo.CreatedAt, 0), stime.Format_Normal_YMDhms)
a.UpdatedAt = stime.TimeToString(time.Unix(lockInfo.UpdatedAt, 0), stime.Format_Normal_YMDhms)
}
if profile != nil {
a.ArtworkUuid = profile.ArtworkUuid
a.ArtistName = profile.ArtistName
a.ArtworkName = profile.ArtworkName
a.Length = profile.Length
a.Width = profile.Width
a.Ruler = profile.Ruler
a.InscribeDate = profile.InscribeDate
a.HdPic = profile.HdPic
a.ArtistPhoto = profile.ArtistPhoto
a.PriceRun = profile.PriceRun
a.Abstract = profile.Abstract
a.CreatedDate = profile.CreatedDate
a.CreatedAddress = profile.CreatedAddress
}
if a.ArtistName == "" || a.ArtistName == " " {
artistInfo, _ := service.GrpcArtistInfoUserImpl.FindUser(context.Background(), &artistInfoUser.FindUserRequest{
MgmtArtistUid: lockInfo.ArtistUid,
IsArtist: true,
})
if artistInfo != nil && artistInfo.RealName != nil {
a.ArtistName = artistInfo.RealName.Name
}
}
if marketInfo != nil && len(marketInfo) > 0 {
for _, v := range marketInfo {
switch v.Type {
case 0:
a.ArtistMarketDetail = v.Detail
a.ArtistMarketId1 = v.MarketId
case 2:
if a.ArtistMarketUrl1 == "" {
a.ArtistMarketUrl1 = v.Detail
a.ArtistMarketId2 = v.MarketId
} else if a.ArtistMarketUrl2 == "" {
a.ArtistMarketUrl2 = v.Detail
a.ArtistMarketId3 = v.MarketId
break
}
}
}
}
if extDataInfo != nil {
a.FirstPublish = extDataInfo.FirstPublish
a.IsFirstPublish = utils.If(extDataInfo.FirstPublish == "", false, true).(bool)
}
return nil
}
func (a *ArtworkSupplementInfo) ConvertGrpcRequest() (profile *artwork.CreArtProRequest, marketInfo []*artwork.UpdateMInfoRequest, extDataInfo *artwork.UpdateExtDataRequest) {
profile = &artwork.CreArtProRequest{
ArtworkUuid: a.ArtworkUuid,
ArtistName: a.ArtistName,
ArtworkName: a.ArtworkName,
Length: a.Length,
Width: a.Width,
Ruler: a.Ruler,
InscribeDate: a.InscribeDate,
HdPic: a.HdPic,
ArtistPhoto: a.ArtistPhoto,
PriceRun: a.PriceRun,
CreatedDate: a.CreatedDate,
}
marketInfo = []*artwork.UpdateMInfoRequest{
{
ArtworkUuid: a.ArtworkUuid,
Type: 0,
Detail: a.ArtistMarketDetail,
MarketId: a.ArtistMarketId1,
},
{
ArtworkUuid: a.ArtworkUuid,
Type: 2,
Detail: a.ArtistMarketUrl1,
MarketId: a.ArtistMarketId2,
},
{
ArtworkUuid: a.ArtworkUuid,
Type: 2,
Detail: a.ArtistMarketUrl2,
MarketId: a.ArtistMarketId3,
},
}
extDataInfo = &artwork.UpdateExtDataRequest{
ArtworkUuid: a.ArtworkUuid,
FirstPublish: a.FirstPublish,
}
return
}
type GetAuditSupplementDataListRequest struct {
ArtistUid string `json:"artistUid"` //可选 艺术家id
ArtworkName string `json:"artworkName"` //可选 画作名称
AuditStatus int64 `json:"auditStatus"` //可选 审批状态
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
}
type AuditSupplement struct {
ArtworkUid string `json:"artworkUid"`
ArtworkUids []string `json:"artworkUids"`
AuditStatus int64 `json:"auditStatus"` // 画作补充信息审核状态 1:待审核/暂存 2审核通过 3审核不通过 6驳回
AuditMark string `json:"auditMark" gorm:"column:audit_mark;comment:审核备注"`
AuditMark2 string `json:"auditMark2" gorm:"column:audit_mark2;comment:审核备注2"`
FlowIndex int64 `json:"flowIndex"` //需要修改的审批流程位置
}
func (a AuditSupplement) ConvertGrpcRequest(userAccId uint64, userNickName string) *artistInfoArtwork.UpdateArtworkAuditStatusRequest {
return &artistInfoArtwork.UpdateArtworkAuditStatusRequest{
ArtworkUid: a.ArtworkUid,
AuditStatus: a.AuditStatus,
AuditMark: a.AuditMark,
AuditMark2: a.AuditMark2,
FlowIndex: a.FlowIndex,
ArtworkUids: a.ArtworkUids,
ApproverAccid: int32(userAccId),
Approver: userNickName,
}
}
// 获取用户端补充信息预览列表请求
type GetSupplementDataListAtUserSideRequest struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
type GetSupplementDataListAtBackendSideRequest struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
ArtistUid string `json:"artistUid"`
History bool `json:"history"`
SupplementAuditStatus int32 `json:"supplementAuditStatus"` //画作补充信息审核状态 1:暂存 2:待审核 3审核不通过 4审核通过
ArtworkName string `json:"artworkName"`
SortOrder string `json:"sortOrder"`
SortField string `json:"sortField"`
}
type GenerateSupplementInfoRequest struct {
ArtworkUids []string `json:"artworkUids"`
}
// ArtworkSupplementInfoList 画作补充信息列表
type ArtworkSupplementInfoList []ArtworkSupplementInfo
type ArtworkAward struct {
AwardTime string `json:"award_time"` //获奖时间(画家宝不需要)
AwardContent string `json:"award_content"` //获奖奖项或正文内容
AwardCert string `json:"award_cert"` //获奖图片
AwardLink string `json:"award_link"` //链接地址
}
type tmpArtworkAwardResponse struct {
ArtistMarketId1 int32
ArtistMarketId2 int32
ArtistMarketId3 int32
ArtistMarketDetail string
ArtistMarketUrl1 string
ArtistMarketUrl2 string
}
func ConvertMarketDataToResponse(ArtworkMarkets []*artistInfoArtwork.ArtworkMarketData) (tmp tmpArtworkAwardResponse) {
for _, v := range ArtworkMarkets {
if v.Detail != "" {
if strings.Contains(v.Detail, "{") {
var detail ArtworkAward
if err := json.Unmarshal([]byte(v.Detail), &detail); err != nil {
fmt.Println(err.Error())
continue
}
if tmp.ArtistMarketId1 == 0 {
tmp.ArtistMarketDetail = detail.AwardContent
tmp.ArtistMarketUrl1 = detail.AwardCert
tmp.ArtistMarketId1 = int32(v.ID)
} else if tmp.ArtistMarketId2 == 0 {
tmp.ArtistMarketUrl2 = detail.AwardCert
tmp.ArtistMarketId2 = int32(v.ID)
}
} else {
//旧版数据处理优化
switch v.Type {
case 0:
tmp.ArtistMarketDetail = v.Detail
tmp.ArtistMarketId1 = int32(v.ID)
case 2:
if tmp.ArtistMarketUrl1 == "" {
tmp.ArtistMarketUrl1 = v.Detail
tmp.ArtistMarketId2 = int32(v.ID)
} else if tmp.ArtistMarketUrl2 == "" {
tmp.ArtistMarketUrl2 = v.Detail
tmp.ArtistMarketId3 = int32(v.ID)
}
}
}
}
}
return
}
type GetViewReviewArtworkListRequest struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
artistInfoArtwork.ViewReviewArtworkData
SelectColumns []int64
ArtworkUids []string
ReviewUpdatedFrom string `json:"reviewUpdatedFrom"`
ReviewUpdatedTo string `json:"reviewUpdatedTo"`
History bool `json:"history"`
}
type ExportArtworkReviewListRequest struct {
artistInfoArtwork.ViewReviewArtworkData
ColumnIds []int64 `json:"columnIds"`
//ArtworkUids []string `json:"artworkUids"`
ReviewUpdatedFrom string `json:"reviewUpdatedFrom"`
ReviewUpdatedTo string `json:"reviewUpdatedTo"`
}
type ViewReviewArtworkExportData struct {
ID int64 `json:"ID"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
DeletedAt int64 `json:"deletedAt"`
ReviewStatus string `json:"reviewStatus"`
ReviewMark string `json:"reviewMark"` //复审备注
InSource string `json:"inSource"` //导入状态
ArtworkName string `json:"artworkName"` //
ArtworkUid string `json:"artworkUid"` //
Tfnum string `json:"tfnum"` //画作名
ArtistName string `json:"artistName"` //
ArtistUid string `json:"artistUid"` //
Tnum string `json:"tnum"` //画家编号
ArtworkType string `json:"artworkType"` //
Width int32 `json:"width"` //
Length int32 `json:"length"` //
Ruler int32 `json:"ruler"` //
HdPic string `json:"hdPic"` //
ArtistPhoto string `json:"artistPhoto"` //
SealPic string `json:"sealPic"` //人名章图
NationalExhibition string `json:"nationalExhibition"` //
LockStatus int32 `json:"lockStatus"` //
LockTime string `json:"lockTime"` //
ReviewMark2 string `json:"reviewMark2"` //复审备注
ReviewUpdatedAt string `json:"reviewUpdatedAt"` //复审操作时间
}
type GetViewReviewArtistStaticListRequest struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
artistInfoArtwork.ViewReviewArtistStaticData
Mode int `json:"mode"`
}
type GetArtworkBaseAuditHistoryListRequest struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
artistInfoArtwork.ArtworkBaseAuditHistoryData
}
type GetViewArtworkSupplementDetailListRequest struct {
artistInfoArtwork.ViewArtworkSupplementDetailData
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
History int32 `json:"history"`
SupplementAuditStatus int32 `json:"supplementAuditStatus"` //画作补充信息审核状态 1:暂存 2:待审核 3审核不通过 4审核通过
SortOrder string `json:"sortOrder"`
SortField string `json:"sortField"`
}
type GetReviewAuditMessageListRequest struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
artistInfoArtwork.ReviewAuditMessageData
ArtworkName string `json:"artworkName"`
ArtistName string `json:"artistName"`
Tfnum string `json:"tfnum"`
Tnum string `json:"tnum"`
ArtistUid string `json:"artistUid"`
ArtworkUid string `json:"artworkUid"`
}