// Package backend ----------------------------- // @file : artworkSupplement.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2023/3/1 15:59 // ------------------------------------------- package backend import ( "github.com/fonchain_enterprise/fonchain-main/api/artistInfoArtwork" "github.com/fonchain_enterprise/fonchain-main/api/artistInfoUser" "github.com/fonchain_enterprise/fonchain-main/pkg/e" "github.com/fonchain_enterprise/fonchain-main/pkg/service" "github.com/gin-gonic/gin" "github.com/jinzhu/copier" gubrak "github.com/novalagung/gubrak/v2" ) // GetArtistListUnfinishedArtworkBase 获取未完成画作补充审批的艺术家列表 func GetArtistListUnfinishedArtworkBase(c *gin.Context) { var request = GetArtistListRequest{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } datas, err := service.GrpcArtistInfoArtworkImpl.GetArtworkLockRecords(c, &artistInfoArtwork.GetArtworkLockRecordsRequest{ QueryType: artistInfoArtwork.ArtworkQueryMode_NowAuditFlowOfBase, }) if err != nil { service.Error(c, e.Failed, err, err.Error()) } var artistUids = []string{} for _, v := range datas.Data { artistUids = append(artistUids, v.ArtistUid) } artistUids = gubrak.From(artistUids).Uniq().Result().([]string) userListResponse, err := service.GrpcArtistInfoUserImpl.FindUsersUserView(c, &artistInfoUser.FindUsersRequest{ MgmtArtistUids: artistUids, IsArtist: 1, Page: request.Page, PageSize: request.PageSize, ArtistRealName: request.ArtistName, Keyword: request.Keyword, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtistListUnfinishedArtworkBase: GrpcArtistInfoUserImpl.FindUsers Error", "查询失败") } var returnData []artistInfoUser.UserView err = copier.Copy(&returnData, &userListResponse.Data) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtistProfileList: copier.Copy Error", "数据转换失败") } service.ResponseList(c, returnData, service.OptionPage(userListResponse.Page.Page, userListResponse.Page.PageSize, userListResponse.Page.Total)) } // GetArtistListOfUnfinishedArtworkSupplement 获取未完成画作补充数据审批的艺术家列表 func GetArtistListOfUnfinishedArtworkSupplement(c *gin.Context) { var request = GetArtistListRequest{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } datas, err := service.GrpcArtistInfoArtworkImpl.GetArtworkLockRecords(c, &artistInfoArtwork.GetArtworkLockRecordsRequest{ QueryType: artistInfoArtwork.ArtworkQueryMode_NowAuditFlowOfSupplementing, }) if err != nil { service.Error(c, e.Failed, err, err.Error()) } var artistUids = []string{} for _, v := range datas.Data { artistUids = append(artistUids, v.ArtistUid) } artistUids = gubrak.From(artistUids).Uniq().Result().([]string) userListResponse, err := service.GrpcArtistInfoUserImpl.FindUsersUserView(c, &artistInfoUser.FindUsersRequest{ MgmtArtistUids: artistUids, IsArtist: 1, Page: request.Page, PageSize: request.PageSize, ArtistRealName: request.ArtistName, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtistProfileList: GrpcArtistInfoUserImpl.FindUsers Error", "查询失败") } var returnData []artistInfoUser.UserView err = copier.Copy(&returnData, &userListResponse.Data) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtistProfileList: copier.Copy Error", "数据转换失败") } service.ResponseList(c, returnData, service.OptionPage(userListResponse.Page.Page, userListResponse.Page.PageSize, userListResponse.Page.Total), service.OptionAddField_ArtshowCount("artistUid"), ) }