package service import ( "context" "encoding/json" "fmt" "strings" "dubbo.apache.org/dubbo-go/v3/common/logger" dubboGoV3Config "dubbo.apache.org/dubbo-go/v3/config" "github.com/fonchain_enterprise/fonchain-main/api/account" artShow "github.com/fonchain_enterprise/fonchain-main/api/artShow" "github.com/fonchain_enterprise/fonchain-main/api/artist" "github.com/fonchain_enterprise/fonchain-main/api/artwork" "github.com/fonchain_enterprise/fonchain-main/api/artwork_query" "github.com/fonchain_enterprise/fonchain-main/api/artwork_third_party" "github.com/fonchain_enterprise/fonchain-main/api/note" api "github.com/fonchain_enterprise/fonchain-main/api/rule" "github.com/fonchain_enterprise/fonchain-main/api/task" "github.com/fonchain_enterprise/fonchain-main/pkg/common" "github.com/fonchain_enterprise/fonchain-main/pkg/config" "github.com/fonchain_enterprise/fonchain-main/pkg/e" "github.com/fonchain_enterprise/fonchain-main/pkg/logic" "github.com/fonchain_enterprise/fonchain-main/pkg/model" "github.com/fonchain_enterprise/fonchain-main/pkg/model/login" "github.com/fonchain_enterprise/fonchain-main/pkg/model/request" "github.com/fonchain_enterprise/fonchain-main/pkg/serializer" "github.com/fonchain_enterprise/fonchain-main/pkg/utils" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/jinzhu/copier" "go.uber.org/zap" "google.golang.org/protobuf/types/known/wrapperspb" ) // MyAwList 快速工作台 func MyAwList(c *gin.Context) { var req artwork_query.MyAwListReq if err := c.ShouldBind(&req); err != nil { logger.Errorf("MyAwList ShouldBind err", err) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: err.Error(), Status: e.Failed, }) return } // 获取权限信息 var rulesReq api.RulesRequest userInfoAny, _ := c.Get("jwtInfo") userInfo := userInfoAny.(login.Info) rulesReq.AccountID = userInfo.ID rulesResp, _ := RuleProvider.Rules(c, &rulesReq) if rulesResp != nil && rulesResp.MyRules != nil { for _, ruleInfo := range rulesResp.MyRules { req.RulesUrl = append(req.RulesUrl, ruleInfo.Url) } } req.AdminId = int32(userInfo.ID) resp, errS := GrpcArtworkQueryImpl.MyAwList(context.Background(), &req) if errS != nil { ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: errS.Error(), Status: e.Failed, }) return } if len(resp.Data) == 0 { resp.Data = []*artwork_query.MyAwListResp_Info{} } else { var artistUids []string = make([]string, 0, len(resp.Data)) for k, v := range resp.Data { artistUids = append(artistUids, v.ArtistUuid) v.ArtistShowCount = fmt.Sprintf("%s(0)", v.ArtistName) if v.BlackListStatus == 2 { resp.Data[k].ArtistName = fmt.Sprintf("#%s", v.ArtistName) } } artshowResp, _err := GrpcArtShowImpl.ArtistExhibitionCount(context.Background(), &artShow.ArtistExhibitionCountReq{ArtistUid: artistUids}) if _err != nil { zap.L().Error("artist ArtistExhibitionCount err", zap.Error(_err)) } if artshowResp != nil && len(artshowResp.ArtistShowCount) > 0 { for k, v := range resp.Data { for _, v1 := range artshowResp.ArtistShowCount { if v.ArtistUuid == v1.ArtistUid { resp.Data[k].ArtistShowCount = fmt.Sprintf("%s(%d)", v.ArtistName, v1.ShowCount) break } } } } } ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: resp.Msg, Status: e.Ok, Data: resp, }) return } func EditAwStatus(c *gin.Context) { var infoRequest artwork_query.UpdateAwStockStatusRequest var err error if err = c.ShouldBind(&infoRequest); err != nil { logger.Errorf("EditAwStatus ShouldBind err", err) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: e.GetMsg(e.BindError), Status: e.Failed, }) return } userInfoAny, _ := c.Get("jwtInfo") infoByte, _ := json.Marshal(userInfoAny) userInfo := model.LoginInfo{} if err = json.Unmarshal(infoByte, &userInfo); err != nil { logger.Errorf("EditAwStatus Unmarshal err", err) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: e.GetMsg(e.JsonUnmarshal), Status: e.Failed, }) return } // 判断 infoRequest.AdminId = int32(userInfo.ID) resp, err := GrpcArtworkQueryImpl.UpdateAwStockStatus(context.Background(), &infoRequest) if err != nil { ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: err.Error(), Status: e.Failed, }) return } SubmitTask(c, infoRequest.ActionType, infoRequest.ArtworkIds) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: resp.Msg, Status: e.Ok, }) } func AllotArtwork(c *gin.Context) { var req artwork_query.UpdateAwStockStatusRequest if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { logger.Errorf("AllotArtwork ShouldBind err", err) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: err.Error(), Status: e.Failed, }) return } userInfoAny, ok := c.Get("jwtInfo") userInfo := model.LoginInfo{} if ok { infoByte, _ := json.Marshal(userInfoAny) if err := json.Unmarshal(infoByte, &userInfo); err != nil { logger.Errorf("EditAwStatus Unmarshal err", err) ResponseQuickMsg(c, e.Failed, e.GetMsg(e.JsonUnmarshal), nil) return } } req.AdminId = int32(userInfo.ID) resp, errs := GrpcArtworkQueryImpl.UpdateAwStockStatus(context.Background(), &req) if errs != nil { ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: errs.Error(), Status: e.Failed, }) return } //发送到task任务中去 SendTask(c, userInfo, req) ResponseMsg(c, e.SUCCESS, serializer.Response{ Msg: resp.Msg, Status: e.Ok, }) } func SendTask(c *gin.Context, user model.LoginInfo, req artwork_query.UpdateAwStockStatusRequest) { var artworks []*task.Artwork taskReq := &task.TaskRequest{ Type: "art", StartAt: req.ReceiveDate, SubmitterID: user.ID, SubmitterName: user.NickName, } type ArtworkName struct { ArtworkName string ArtworkId uint64 } type ArtworkReq struct { ArtworkNames []ArtworkName } var artworkRes ArtworkReq if err := c.ShouldBindBodyWith(&artworkRes, binding.JSON); err == nil { for _, t := range artworkRes.ArtworkNames { artworks = append(artworks, &task.Artwork{ ArtworkID: t.ArtworkId, Name: t.ArtworkName, }) } taskReq.Artworks = artworks } users := UserByIds(c, req.AllotUids) taskReq.JoinUsers = users fmt.Println("通知task生成数据", taskReq) TaskProvider.Create(c, taskReq) return } func UserByIds(c *gin.Context, allowUids []int32) []*task.JoinUser { var joinUsers []*task.JoinUser var userIds []uint64 for _, t := range allowUids { userIds = append(userIds, uint64(t)) } IdsReq := account.ListByIDsRequest{ IDs: userIds, PageSize: 999999, Page: 1, } userRes, _ := AccountProvider.ListByIDs(c, &IdsReq) for _, t := range userRes.Data { joinUsers = append(joinUsers, &task.JoinUser{ UserID: t.ID, Name: t.NickName, }) } return joinUsers } func ShelfNoList(c *gin.Context) { var req artwork_query.ShelfListRequest resp, err := GrpcArtworkQueryImpl.ShelfList(context.Background(), &req) if err != nil { ResponseQuickMsg(c, e.Ok, err.Error(), nil) return } if len(resp.Data) == 0 { resp.Data = []*artwork_query.ShelfListResponse_ShelfInfo{} } ResponseQuickMsg(c, e.Ok, resp.Msg, resp.Data) } func UpdateCopyright(c *gin.Context) { var req artwork_query.UpdateCopyrightHashRequest var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("AllotArtwork ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } //检测路径生成hash req.CopyrightPath = model.CopyrightDir + "/" + req.CopyrightPath[strings.LastIndex(req.CopyrightPath, "/")+1:] exists, _ := utils.CheckDirPath(req.CopyrightPath, false) if !exists { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorFileNotExists), nil) return } req.CopyrightHash, err = utils.GenerateSHA256Hash(req.CopyrightPath) if err != nil { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.Error), nil) return } resp, err := GrpcArtworkQueryImpl.UpdateCopyrightHash(context.Background(), &req) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) } func ExportArtwork(c *gin.Context) { var listReq artwork_query.ExportArtworkRequest /*if c.Request.Method == "POST" { if err := c.ShouldBind(&listReq); err != nil { logger.Errorf("ListExport ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } dataStr, err := json.Marshal(&listReq) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var dataBase64 string = base64.StdEncoding.EncodeToString(dataStr) var httpType string if config.IsHttps { httpType = model.HttpsType } else { httpType = model.HttpType } var exportUrl string = fmt.Sprintf("%s%s%s?data=%s", httpType, c.Request.Host, c.Request.RequestURI, dataBase64) ResponseQuickMsg(c, e.Ok, "", map[string]interface{}{"ExportUrl": exportUrl}) return } if c.Request.Method != "GET" { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.Error), nil) return } dataAny, ok := c.GetQuery("data") if !ok { return } dataStr := fmt.Sprintf("%v", dataAny) dataJsonStr, err := base64.StdEncoding.DecodeString(dataStr) if err != nil { return } if err = json.Unmarshal(dataJsonStr, &listReq); err != nil { return }*/ if err := c.ShouldBind(&listReq); err != nil { logger.Errorf("ListExport ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } resp, err := GrpcArtworkQueryImpl.ExportArtwork(context.Background(), &listReq) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } //组装数据 if len(resp.Data) == 0 { resp.Data = []*artwork_query.ExportArtworkResponse_Info{} } var adminId uint64 if mLoginInfoAny, exists := c.Get("mLoginInfo"); exists { userInfo := mLoginInfoAny.(model.LoginInfo) adminId = userInfo.ID } var tagInfo map[int32]string tagInfo, err = GetTagIdList() columns := strings.Split(resp.ColumnDesc, ",") // excel 字段 columnStruct := strings.Split(resp.StructName, ",") // struct 字段 data, _ := logic.RegroupArtworkExcelData(resp.Data, columnStruct, tagInfo) exportFileName := fmt.Sprintf("画作信息%d.xlsx", adminId) filePath := fmt.Sprintf("./runtime/%s", exportFileName) _, _ = utils.ToExcelByType(columns, data, "slice", filePath) // 下载图片 自适应插入到Excel,线上一直没有开启就先关掉了 /*err = logic.DealAwListExcelImg(filePath) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return }*/ var httpType string if config.IsHttps { httpType = model.HttpsType } else { httpType = model.HttpType } var exportUrl string = fmt.Sprintf("%s%s/static/%s", httpType, c.Request.Host, exportFileName) ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]string{ "ExportUrl": exportUrl, }) return //utils.ResponseXls(c, content, model.ArtworkExcelName) } func GetTagIdList() (info map[int32]string, err error) { resp := &artwork_query.TagIdKvListResponse{} var req artwork_query.TagIdKvListRequest req.Pids = "44,4,5,39,40,42" if resp, err = GrpcArtworkQueryImpl.TagIdKvList(context.Background(), &req); err != nil { return } info = resp.Info return } // ExportArtworkField 导出字段列表 func ExportArtworkField(c *gin.Context) { var req artwork_query.ExportFieldListRequest var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("ExportFieldList ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork_query.ExportFieldListResponse if resp, err = GrpcArtworkQueryImpl.ExportFieldList(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, resp.Msg, nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, resp.Data) return } // UpdateCopyrightInfo 更新版权信息 func UpdateCopyrightInfo(c *gin.Context) { var req artwork.UpdateCopyrightInfoRequest var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("UpdateCopyrightInfo ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork.UpdateCopyrightInfoResponse if resp, err = GrpcArtworkImpl.UpdateCopyrightInfo(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func DownloadArtwork(c *gin.Context) { var listReq artwork_query.ExportArtworkRequest if err := c.ShouldBind(&listReq); err != nil { logger.Errorf("ListExport ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } resp, err := GrpcArtworkQueryImpl.ExportArtwork(context.Background(), &listReq) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } columnDesc := strings.Split(resp.ColumnDesc, ",") // excel 字段 columnStruct := strings.Split(resp.StructName, ",") // struct 字段 var adminId uint64 if config.Env != "dev" { if mLoginInfoAny, exists := c.Get("mLoginInfo"); exists { userInfo := mLoginInfoAny.(model.LoginInfo) adminId = userInfo.ID } } if resp.Data == nil { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } zipPath, err := logic.RegroupArtworkDownloadData(resp.Data, columnStruct, columnDesc, adminId, model.DownloadFile) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if zipPath == "" { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } var httpType string if config.IsHttps { httpType = model.HttpsType } else { httpType = model.HttpType } var exportUrl string = fmt.Sprintf("%s%s/%s", httpType, c.Request.Host, zipPath) ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]string{ "ExportUrl": exportUrl, }) return } func DownloadHash(c *gin.Context) { var listReq artwork_query.ExportArtworkRequest if err := c.ShouldBind(&listReq); err != nil { logger.Errorf("DownloadHash err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } fmt.Println("DownloadHash1111111111111111111") listReq.ColumnId = "63" resp, err := GrpcArtworkQueryImpl.ExportArtwork(context.Background(), &listReq) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } columnDesc := strings.Split(resp.ColumnDesc, ",") // excel 字段 columnStruct := strings.Split(resp.StructName, ",") // struct 字段 var adminId uint64 if config.Env != "dev" { if mLoginInfoAny, exists := c.Get("mLoginInfo"); exists { userInfo := mLoginInfoAny.(model.LoginInfo) adminId = userInfo.ID } } if resp.Data == nil { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } zipPath, _ := logic.RegroupArtworkDownloadData(resp.Data, columnStruct, columnDesc, adminId, model.DownloadHash) if zipPath == "" { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } var httpType string if config.IsHttps { httpType = model.HttpsType } else { httpType = model.HttpType } var exportUrl string = fmt.Sprintf("%s%s/%s", httpType, c.Request.Host, zipPath) ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]string{ "ExportUrl": exportUrl, }) return } func SubmitTask(c *gin.Context, status int32, ids []int32) { if status != 2 { return } for _, id := range ids { req := &task.PassArtWorkRequest{ ArtworkId: uint64(id), } _, _ = TaskProvider.PassArtWork(c, req) } return } func SyncAwSignDate(c *gin.Context) { var req artwork.SyncAwSignDataReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("SyncAwData ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork.SyncAwSignDataResp if resp, err = GrpcArtworkImpl.SyncAwSignData(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, resp.Msg, nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func SyncAwStorage(c *gin.Context) { var req artwork.SyncAwStorageReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("SyncAwData ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if req.StorageType == 0 { req.StorageType = 1 } var resp *artwork.SyncAwStorageResp if resp, err = GrpcArtworkImpl.SyncAwStorage(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, resp.Msg, nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func AuthImgBatch(c *gin.Context) { var req artwork.AuthImgBatchReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("AuthImgBatch ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork.AuthImgBatchResp if resp, err = GrpcArtworkImpl.AuthImgBatch(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func UpdateAwInfoWithKey(c *gin.Context) { var req artwork.UpdateAwInfoWithKeyReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("AuthImgBatch ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork.UpdateAwInfoWithKeyResp if resp, err = GrpcArtworkImpl.UpdateAwInfoWithKey(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func AddBrand(c *gin.Context) { var addBrandReq request.AddBrandReq var req artwork_third_party.UpdateAwStatusReq var err error if err = c.ShouldBind(&addBrandReq); err != nil { logger.Errorf("AddBrand ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if addBrandReq.ArtworkUuid == "" || addBrandReq.ArtShowId == "" { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ParamsError), nil) return } //画作在被点击上架时,需检测画作及画作归属的画家信息是否已被核验,没有则给 //出相关提示—“画家个人简介未核验!”/“画作评价未核验! res, err := GrpcArtworkImpl.ArtworkDetail(c, &artwork.ArtworkDetailRequest{ArtworkUuid: addBrandReq.ArtworkUuid, Type: "1,3"}) if err != nil { ErrorWithMark(c, e.Failed, err, "GrpcArtworkImpl.ArtworkDetail Err:"+err.Error(), "画作评价未核验!") return } if res.ExtDataInfo.CheckStatus != 3 { ErrorWithMark(c, e.Failed, nil, "CheckStatus != 3", "画作评价未核验!") return } artistExt, err := GrpcArtistImpl.RecordInfoByArtistUid(c, &artist.RecordInfoByArtistUidReq{ ArtshowUuid: addBrandReq.ArtShowId, ArtistUuid: res.ProfileInfo.ArtistUuid, }) if err != nil { zap.L().Error("AddBrand err RecordInfoByArtistUid", zap.Error(err)) ErrorWithMark(c, e.Failed, err, "GrpcArtistImpl.GetExtData Err:"+err.Error(), "画家个人简介异常!") return } fmt.Printf("artistExt.Data.CheckStatus:%v\n", artistExt.CheckStatus) if artistExt.Resume2 == "" { ErrorWithMark(c, e.Failed, nil, "artistExt.Resume2 == '' ", "画家个人简介未核验!") return } // 在上架的地方判断润格审批 if dubboGoV3Config.GetConsumerService("ArtShowClientImpl") != nil { var showReq artShow.ShowStatusReq showReq.ShowUID = []string{ addBrandReq.ArtShowId, } fmt.Println(111111) showResp, err := GrpcArtShowImpl.QueryShowStatus(context.Background(), &showReq) if err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } fmt.Println(2222222) if len(showResp.Status) == 0 { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorGetArtShow), nil) return } fmt.Println(33333333) for _, v := range showResp.Status { if v.IsShow != model.ArtShowStatus { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorPriceRunFailed), nil) return } } fmt.Println(444444444444) } else { fmt.Println("!!! dubboGoV3Config.GetConsumerService(\"ArtShowClientImpl\") == nil") ResponseQuickMsg(c, e.Failed, e.GetMsg(e.Error), nil) return } fmt.Println(555555555555) req.ArtworkUuid = addBrandReq.ArtworkUuid if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } fmt.Println(66666666666666) req.Action = model.SaleStatusConfirm // 查询画展包的画作信息 zap.L().Info("ArtworkPrice", zap.Any("ArtworkUuid", addBrandReq.ArtworkUuid)) artworkPriceResp, _err := GrpcArtShowImpl.ArtworkPrice(context.Background(), &artShow.ArtworkPriceReq{ ArtworkUID: addBrandReq.ArtworkUuid, }) if _err != nil { ResponseQuickMsg(c, e.Failed, _err.Error(), nil) return } zap.L().Info("ArtworkPrice", zap.Any("artshowPriceResp", artworkPriceResp)) if artworkPriceResp != nil && artworkPriceResp.Data != nil { req.CompanyName = artworkPriceResp.Data.TalentAgency } var resp *artwork_third_party.UpdateAwStatusResp if resp, err = GrpcArtworkThirdPartyImpl.UpdateAwStatus(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } fmt.Println(777777777777777) ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func UpdateAwBatch(c *gin.Context) { var reqModel model.UpdateAwBatchReq var err error if err = c.ShouldBind(&reqModel); err != nil { logger.Errorf("UpdateAwBatch ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var req artwork.UpdateAwBatchReq if err = copier.Copy(&req, &reqModel); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) } req.ArtShowStatus = wrapperspb.Int32(*reqModel.ArtShowStatus) if err = req.Validate(); err != nil { err = common.SubstrError(err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } if len(req.ArtworkUuids) == 0 { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ParamsError), nil) return } var resp *artwork.UpdateAwBatchResp if resp, err = GrpcArtworkImpl.UpdateAwBatch(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func VerifyList(c *gin.Context) { var req artwork_query.VerifyListReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("VerifyList ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var resp *artwork_query.VerifyListResp if resp, err = GrpcArtworkQueryImpl.VerifyList(context.Background(), &req); err != nil { ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } var bitRateAll []string = []string{"60", "200", "600", "2000"} var VerifyListData []model.BitInfo for i := 1; i <= 20; i++ { var temp model.BitInfo v := resp.Data[fmt.Sprintf("%d", i)] temp.BitMapIndex = int32(i) if v != nil { temp.BitmapImg = v.BitmapImg if len(v.BmImgs) > 0 { for bitRate, vv := range v.BmImgs { for _, vvv := range vv.Data { var tt model.BmImgsInfo tt.Uuid = vvv.Uuid tt.RateUrl = vvv.RateUrl tt.RateSimilar = vvv.RateSimilar //FIXME 先不展示相似度 vvv.RateSimilar //if config.Env == "prod" { // tt.RateSimilar = -1 //} tt.RateImgTime = vvv.RateImgTime if temp.BmImgs == nil { temp.BmImgs = map[string][]*model.BmImgsInfo{} } temp.BmImgs[bitRate] = append(temp.BmImgs[bitRate], &tt) } } } } if temp.BmImgs == nil { temp.BmImgs = map[string][]*model.BmImgsInfo{} for _, rate := range bitRateAll { temp.BmImgs[rate] = append(temp.BmImgs[rate], &model.BmImgsInfo{ RateUrl: "", RateSimilar: -1, RateImgTime: "", Uuid: "", }) } } VerifyListData = append(VerifyListData, temp) } ResponseQuickMsg(c, e.Ok, resp.Msg, VerifyListData) return } func SyncArtworkData(c *gin.Context) { var req artwork.SyncArtworkDataReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("SyncArtworkData ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } resp, errs := GrpcArtworkImpl.SyncArtworkData(context.Background(), &req) if errs != nil { ResponseQuickMsg(c, e.Failed, errs.Error(), nil) return } ResponseQuickMsg(c, e.Ok, resp.Msg, nil) return } func ArtworkFilterList(c *gin.Context) { var req artwork_query.FilterAwListReq var err error if err = c.ShouldBind(&req); err != nil { logger.Errorf("ArtworkFilterList ShouldBind err", err) ResponseQuickMsg(c, e.Failed, err.Error(), nil) return } resp, errs := GrpcArtworkQueryImpl.FilterAwList(context.Background(), &req) if errs != nil { ResponseQuickMsg(c, e.Failed, errs.Error(), nil) return } if len(resp.Data) == 0 { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } artistResp, erra := GrpcArtistImpl.ArtistData(context.Background(), &artist.ArtistDataRequest{Uids: []string{req.ArtistUuid}}) if len(artistResp.Data) == 0 { ResponseQuickMsg(c, e.Failed, e.GetMsg(e.NOTDATA), nil) return } if erra != nil { ResponseQuickMsg(c, e.Failed, erra.Error(), nil) return } var data []*model.FilterArtworkList var temp *model.FilterArtworkList for _, artworkInfo := range resp.Data { respNote, errA := GrpcNoteImpl.NoteListByAwId(context.Background(), ¬e.NoteListreq{ ArtworkUuid: artworkInfo.ArtworkUuid, }) if errA != nil { ResponseQuickMsg(c, e.Failed, errA.Error(), nil) return } if len(respNote.Data) > 0 { // 判断是否包含退 if strings.Contains(respNote.Data[0].Content, model.FilterAwKeyword) { continue } } temp = &model.FilterArtworkList{} _ = copier.Copy(&temp, artworkInfo) temp.Gender = artistResp.Data[0].ProfileInfo.Gender temp.Age = artistResp.Data[0].ProfileInfo.Age temp.Agent = artistResp.Data[0].ProfileInfo.Agent temp.ArtistName = artistResp.Data[0].ProfileInfo.Name data = append(data, temp) } ResponseQuickMsg(c, e.Ok, resp.Msg, data) return }