1831 lines
58 KiB
Go
1831 lines
58 KiB
Go
|
package service
|
|||
|
|
|||
|
import (
|
|||
|
"bytes"
|
|||
|
"context"
|
|||
|
"dubbo.apache.org/dubbo-go/v3/common/constant"
|
|||
|
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
|||
|
"encoding/base64"
|
|||
|
"encoding/json"
|
|||
|
"errors"
|
|||
|
"fmt"
|
|||
|
_ "github.com/Workiva/go-datastructures/threadsafe/err"
|
|||
|
service "github.com/fonchain_enterprise/fonchain-main/api"
|
|||
|
artShow "github.com/fonchain_enterprise/fonchain-main/api/artShow"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artist"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artistinfoArtshow"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artwork"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artwork_query"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/paybill"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/cache"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/common"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/config"
|
|||
|
projectConf "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/logic/ocr"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/model"
|
|||
|
pkgResponse "github.com/fonchain_enterprise/fonchain-main/pkg/model/response"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/serializer"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/utils"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/utils/stime"
|
|||
|
baiduUtils "github.com/fonchain_enterprise/utils/baidu"
|
|||
|
"github.com/gin-gonic/gin"
|
|||
|
"github.com/jinzhu/copier"
|
|||
|
"go.uber.org/zap"
|
|||
|
"io/ioutil"
|
|||
|
"reflect"
|
|||
|
"sort"
|
|||
|
"strings"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
func CreateProfile(c *gin.Context) {
|
|||
|
// 1. 获取参数及参数的校验
|
|||
|
var profileRequest artist.ProfileRequest
|
|||
|
if err := c.ShouldBind(&profileRequest); err != nil {
|
|||
|
logger.Errorf("CreateProfileHandler ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
if err := profileRequest.Validate(); err != nil {
|
|||
|
err = common.SubstrError(err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.CreateProfile(context.Background(), &profileRequest)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
Data: resp.DataInfo,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
func UpdateProfile(c *gin.Context) {
|
|||
|
// 1. 获取参数及参数的校验
|
|||
|
var profileRequest artist.ProfileRequest
|
|||
|
if err := c.ShouldBind(&profileRequest); err != nil {
|
|||
|
logger.Errorf("UpdateProfile ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
var logicArtist logic.ArtistInfo
|
|||
|
profileRequest.Name = logicArtist.RecheckArtistName(profileRequest.Name)
|
|||
|
if err := profileRequest.Validate(); err != nil {
|
|||
|
err = common.SubstrError(err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
atta := make(map[string]interface{}, 2)
|
|||
|
userInfoAny, ok := c.Get("mLoginInfo")
|
|||
|
loginInfo := model.LoginInfo{}
|
|||
|
if ok {
|
|||
|
loginInfo = userInfoAny.(model.LoginInfo)
|
|||
|
loginInfoByte, _ := json.Marshal(loginInfo)
|
|||
|
atta["userinfo"] = string(loginInfoByte)
|
|||
|
}
|
|||
|
if projectConf.Env == "dev" {
|
|||
|
loginInfo.ID = 1
|
|||
|
loginInfo.NickName = "admin"
|
|||
|
}
|
|||
|
limitInfo, _err := CheckEditLimit(c, profileRequest.TagName, profileRequest.Uid)
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), limitInfo)
|
|||
|
return
|
|||
|
}
|
|||
|
reqContext := context.WithValue(context.Background(), constant.DubboCtxKey("attachment"), atta)
|
|||
|
resp, err := GrpcArtistImpl.UpdateProfile(reqContext, &profileRequest)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if resp.BankInfoChange {
|
|||
|
req1 := paybill.RecordReq{
|
|||
|
ArtistUid: profileRequest.Uid,
|
|||
|
OldArtist: &paybill.Artist{
|
|||
|
BankNum: resp.OldBank.BankNum,
|
|||
|
BankCode: resp.OldBank.BankCode,
|
|||
|
BankName: resp.OldBank.BankName,
|
|||
|
},
|
|||
|
NewArtist: &paybill.Artist{
|
|||
|
BankNum: profileRequest.BankNum,
|
|||
|
BankCode: profileRequest.BankCode,
|
|||
|
BankName: profileRequest.BankName,
|
|||
|
},
|
|||
|
OperatorId: uint32(loginInfo.ID),
|
|||
|
OperatorName: loginInfo.NickName,
|
|||
|
}
|
|||
|
// 账单列表
|
|||
|
_, err = GrpcPayBillImpl.Record(context.Background(), &req1)
|
|||
|
if err != nil {
|
|||
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
RemoveEditLimit(profileRequest.TagName, profileRequest.Uid)
|
|||
|
SyncArtistInfo(profileRequest.Uid, profileRequest.Name)
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.SUCCESS), resp.DataInfo)
|
|||
|
}
|
|||
|
|
|||
|
func SyncArtistInfo(artistUid string, artistName string) {
|
|||
|
var profileRequest artwork.UpArtistInfoRequest
|
|||
|
var infoReq artwork.UpArtistInfoRequest_ArtistInfo
|
|||
|
infoReq.ArtistName = artistName
|
|||
|
infoReq.ArtistUuid = artistUid
|
|||
|
profileRequest.Data = append(profileRequest.Data, &infoReq)
|
|||
|
resp, err := GrpcArtworkImpl.UpdateArtistInfo(context.Background(), &profileRequest)
|
|||
|
logger.Info("updateArtworkInfo", resp)
|
|||
|
if err != nil {
|
|||
|
logger.Errorf("updateArtworkInfo err", err)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
func Detail(c *gin.Context) {
|
|||
|
// 1. 获取参数及参数的校验
|
|||
|
//var id = c.Param("id")
|
|||
|
var detailRequest artist.DetailRequest
|
|||
|
//detailRequest.Uid = id
|
|||
|
if err := c.ShouldBind(&detailRequest); err != nil {
|
|||
|
logger.Errorf("GetDetailHandler ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ArtistDetail(context.Background(), &detailRequest)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
if len(resp.HonorInfo) == 0 {
|
|||
|
resp.HonorInfo = []*artist.HonorRequest{}
|
|||
|
}
|
|||
|
resp.ProfileInfo.Resume = DownloadIfHttpLongText(resp.ProfileInfo.Resume)
|
|||
|
//从最近一次的画展包核验数据中获取个人简介2
|
|||
|
recordRes, err := GrpcArtistImpl.GetArtistOneQueryCheckRecordList(c, &artist.GetArtistOneQueryCheckRecordListRequest{
|
|||
|
Query: &artist.ArtistOneQueryCheckRecordData{ArtistUID: resp.ProfileInfo.Uid},
|
|||
|
Page: 1,
|
|||
|
PageSize: -1,
|
|||
|
Order: "created_at desc",
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
zap.L().Error("获取画展阿波核验数据失败", zap.Error(err))
|
|||
|
}
|
|||
|
if recordRes.Total > 0 {
|
|||
|
for _, v := range recordRes.List {
|
|||
|
if v.Resume2 != "" {
|
|||
|
resp.ProfileInfo.Resume2 = v.Resume2
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//查询画展次数
|
|||
|
if resp.ProfileInfo != nil {
|
|||
|
resp.ProfileInfo.ArtistShowCount = fmt.Sprintf("%s(0)", resp.ProfileInfo.Name)
|
|||
|
artshowResp, _err := GrpcArtShowImpl.ArtistExhibitionCount(context.Background(), &artShow.ArtistExhibitionCountReq{ArtistUid: []string{resp.ProfileInfo.Uid}})
|
|||
|
if _err == nil && len(artshowResp.ArtistShowCount) > 0 {
|
|||
|
resp.ProfileInfo.ArtistShowCount = fmt.Sprintf("%s(%d)", resp.ProfileInfo.Name, artshowResp.ArtistShowCount[0].ShowCount)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
Data: resp,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
func List(c *gin.Context) {
|
|||
|
// 1. 获取参数及参数的校验
|
|||
|
var listReq artist.ArtistListRequest
|
|||
|
var paramMap map[string]interface{}
|
|||
|
bodyByte, _ := ioutil.ReadAll(c.Request.Body)
|
|||
|
if err := json.Unmarshal(bodyByte, ¶mMap); err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.JsonUnmarshal), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyByte))
|
|||
|
|
|||
|
if err := c.ShouldBind(&listReq); err != nil {
|
|||
|
logger.Errorf("ListHandler ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
_, ok := paramMap["Gender"]
|
|||
|
if !ok {
|
|||
|
listReq.Gender = -1
|
|||
|
}
|
|||
|
/*if listReq.MasterType == model.MasterTypeEmpty { //默认是查询普通
|
|||
|
listReq.MasterType = model.MasterTypeNo
|
|||
|
}*/
|
|||
|
resp, err := GrpcArtistImpl.ArtistList(context.Background(), &listReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if len(resp.Data) == 0 {
|
|||
|
resp.Data = []*artist.ProfileRequest{}
|
|||
|
}
|
|||
|
var artistUids []string = make([]string, 0, len(resp.Data))
|
|||
|
for k, v := range resp.Data {
|
|||
|
artistUids = append(artistUids, v.Uid)
|
|||
|
resp.Data[k].ArtistShowCount = fmt.Sprintf("%s(0)", v.Name)
|
|||
|
if v.BlackListStatus == 2 {
|
|||
|
listTimes, _ := stime.DatetimeToTimes(v.BlackListTime, stime.Format_Normal_YMDhms)
|
|||
|
if listTimes > 0 && (int64(listTimes)+86400*365) < time.Now().Unix() {
|
|||
|
v.BlackListStatus = 100
|
|||
|
}
|
|||
|
resp.Data[k].Name = fmt.Sprintf("#%s", v.Name)
|
|||
|
}
|
|||
|
}
|
|||
|
// 查询画展次数
|
|||
|
if len(resp.Data) > 0 && listReq.PageSize <= 50 {
|
|||
|
artshowResp, _err := GrpcArtShowImpl.ArtistExhibitionCount(c, &artShow.ArtistExhibitionCountReq{ArtistUid: artistUids})
|
|||
|
if _err != nil {
|
|||
|
zap.L().Error("artist ArtistExhibitionCount err", zap.Error(_err))
|
|||
|
}
|
|||
|
fmt.Println("artistUids", artistUids)
|
|||
|
fmt.Println("artshowResp", artshowResp)
|
|||
|
zap.L().Info("artist-list", zap.Any("artistUids", artistUids))
|
|||
|
zap.L().Info("artist-list", zap.Any("artshowResp", artshowResp))
|
|||
|
if artshowResp != nil && len(artshowResp.ArtistShowCount) > 0 {
|
|||
|
for k, v := range resp.Data {
|
|||
|
for _, v1 := range artshowResp.ArtistShowCount {
|
|||
|
if v.Uid == v1.ArtistUid {
|
|||
|
resp.Data[k].ArtistShowCount = fmt.Sprintf("%s(%d)", v.Name, v1.ShowCount)
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
// ListExport 导出画家
|
|||
|
func ListExport(c *gin.Context) {
|
|||
|
var listReq artist.ExportArtistRequest
|
|||
|
|
|||
|
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
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ExportArtist(context.Background(), &listReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
//组装数据
|
|||
|
if len(resp.Data) == 0 {
|
|||
|
resp.Data = []*artist.ExportArtistResponse_Info{}
|
|||
|
}
|
|||
|
columns := strings.Split(resp.ColumnDesc, ",") // excel 字段
|
|||
|
columnStruct := strings.Split(resp.StructName, ",") // struct 字段
|
|||
|
data, _ := logic.RegroupArtistExcelData(resp.Data, columnStruct)
|
|||
|
content, _ := utils.ToExcelByType(columns, data, "slice", "")
|
|||
|
utils.ResponseXls(c, content, model.ArtistExcelName)
|
|||
|
}
|
|||
|
|
|||
|
// ExportArtistField 导出字段列表
|
|||
|
func ExportArtistField(c *gin.Context) {
|
|||
|
var req artist.ExportFieldListRequest
|
|||
|
var err error
|
|||
|
if err = c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("ExportArtistField 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.MasterType == model.MasterTypeEmpty {
|
|||
|
req.MasterType = model.MasterTypeNo
|
|||
|
}
|
|||
|
var resp *artist.ExportFieldListResponse
|
|||
|
if resp, err = GrpcArtistImpl.ExportFieldList(context.Background(), &req); err != nil {
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp.Data)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func Media(c *gin.Context) {
|
|||
|
var (
|
|||
|
mediaReq artist.MediaRequest
|
|||
|
artistDetail *artist.DetailResponse
|
|||
|
err error
|
|||
|
)
|
|||
|
if err = c.ShouldBind(&mediaReq); err != nil {
|
|||
|
logger.Errorf("MediaHandler ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
limitInfo, _err := CheckEditLimit(c, mediaReq.TagName, mediaReq.Uid)
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), limitInfo)
|
|||
|
return
|
|||
|
}
|
|||
|
// 查询详情
|
|||
|
if artistDetail, err = GrpcArtistImpl.ArtistDetail(c, &artist.DetailRequest{Uid: mediaReq.Uid}); err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
var cardInfo *baiduUtils.OrcRes
|
|||
|
var logicOcr = new(ocr.Card)
|
|||
|
mediaReq.CardIdInfo = &artist.CardIdInfo{}
|
|||
|
if mediaReq.CardFace != "" && artistDetail.MediaInfo.CardFace != mediaReq.CardFace {
|
|||
|
cardInfo, _err = logicOcr.CardInfo(mediaReq.CardFace, "front")
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), limitInfo)
|
|||
|
return
|
|||
|
}
|
|||
|
if cardInfo.IdCard == "" {
|
|||
|
ResponseQuickMsg(c, e.Failed, e.ERROR_CARDID_OCR, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
_ = copier.CopyWithOption(&mediaReq.CardIdInfo, cardInfo, copier.Option{IgnoreEmpty: true})
|
|||
|
mediaReq.CardIdInfo.CardId = cardInfo.IdCard
|
|||
|
mediaReq.CardIdInfo.Address = cardInfo.Path
|
|||
|
}
|
|||
|
if mediaReq.CardNational != "" && artistDetail.MediaInfo.CardNational != mediaReq.CardNational {
|
|||
|
cardInfo, _err = logicOcr.CardInfo(mediaReq.CardNational, "back")
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if cardInfo.ExpireStartTime == "" {
|
|||
|
ResponseQuickMsg(c, e.Failed, e.ERROR_CARDID_OCR, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
_ = copier.CopyWithOption(&mediaReq.CardIdInfo, cardInfo, copier.Option{IgnoreEmpty: true})
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.UpdateMedia(context.Background(), &mediaReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
RemoveEditLimit(mediaReq.TagName, mediaReq.Uid)
|
|||
|
// 解析最后一个访谈视频发送至画家宝
|
|||
|
if len(mediaReq.InterviewVideos) > 0 {
|
|||
|
if resp.DataInfo.Send {
|
|||
|
var newVideoUrl string = mediaReq.InterviewVideos[len(mediaReq.InterviewVideos)-1].OriUrl
|
|||
|
var newVideoCover string = mediaReq.InterviewVideos[len(mediaReq.InterviewVideos)-1].CoverUrl
|
|||
|
_, err = GrpcArtistInfoArtshowImpl.UpdateLockedArtshowVideo(context.Background(), &artistinfoArtshow.UpdateLockedArtshowVideoRequest{
|
|||
|
ArtistUid: mediaReq.Uid,
|
|||
|
VideoUrl: newVideoUrl,
|
|||
|
VideoCover: newVideoCover,
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
logger.Errorf("UpdateLockedArtshowVideo err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorUpdateVideo), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp.DataInfo)
|
|||
|
}
|
|||
|
|
|||
|
// Indexs 更新指数
|
|||
|
func Indexs(c *gin.Context) {
|
|||
|
var indexReq artist.IndexRequest
|
|||
|
if err := c.ShouldBind(&indexReq); err != nil {
|
|||
|
logger.Errorf("Indexs ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
indexReq.InSource = artist.InSource_InSourceManager
|
|||
|
/*resp, err := GrpcArtistImpl.UpdateIndex(context.Background(), &indexReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}*/
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: e.GetMsg(e.Success),
|
|||
|
Status: e.Ok,
|
|||
|
Data: map[string]interface{}{
|
|||
|
"Uid": indexReq.Uid,
|
|||
|
},
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// Honor 更新荣誉
|
|||
|
func Honor(c *gin.Context) {
|
|||
|
var honorReq artist.HonorRequest
|
|||
|
if err := c.ShouldBind(&honorReq); err != nil {
|
|||
|
logger.Errorf("Honor ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.UpdateHonor(context.Background(), &honorReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
Data: resp.DataInfo,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// HonorDel 删除荣誉
|
|||
|
func HonorDel(c *gin.Context) {
|
|||
|
var honorReq artist.HonorDelRequest
|
|||
|
if err := c.ShouldBind(&honorReq); err != nil {
|
|||
|
logger.Errorf("Honor HonorDel err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.HonorDel(context.Background(), &honorReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
})
|
|||
|
}
|
|||
|
func ContractAdd(c *gin.Context) {
|
|||
|
var contractReq artist.ContractAddRequest
|
|||
|
if err := c.ShouldBind(&contractReq); err != nil {
|
|||
|
logger.Errorf("Contract ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ContractAdd(context.Background(), &contractReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
func ContractEdit(c *gin.Context) {
|
|||
|
var contractReq artist.ContractAddRequest
|
|||
|
if err := c.ShouldBind(&contractReq); err != nil {
|
|||
|
logger.Errorf("Contract ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ContractUpdate(context.Background(), &contractReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
func ContractList(c *gin.Context) {
|
|||
|
var contractReq artist.ContractListRequest
|
|||
|
if err := c.ShouldBind(&contractReq); err != nil {
|
|||
|
logger.Errorf("ContractList ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ContractList(context.Background(), &contractReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
}
|
|||
|
|
|||
|
func DelArtist(c *gin.Context) {
|
|||
|
var delReq artist.DelRequest
|
|||
|
if err := c.ShouldBind(&delReq); err != nil {
|
|||
|
logger.Errorf("DelArtist ShouldBind err", err)
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Data: nil,
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.DelArtist(context.Background(), &delReq)
|
|||
|
if err != nil {
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: err.Error(),
|
|||
|
Status: e.Failed,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseMsg(c, e.SUCCESS, serializer.Response{
|
|||
|
Msg: resp.Msg,
|
|||
|
Status: e.Ok,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
func IdName(c *gin.Context) {
|
|||
|
var idNameReq artist.ArtIdNameRequest
|
|||
|
if err := c.ShouldBind(&idNameReq); err != nil {
|
|||
|
logger.Errorf("idNameReq ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ArtistIdName(context.Background(), &idNameReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
for _, v := range resp.Items {
|
|||
|
if v.BlackListStatus == 2 {
|
|||
|
v.Name = fmt.Sprintf("#%s", v.Name)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp.Items)
|
|||
|
}
|
|||
|
|
|||
|
func InvitationAdd(c *gin.Context) {
|
|||
|
var req artist.InvitationAddRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationAdd ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
//确认个人简介信息是否已经核验
|
|||
|
//res, err := GrpcArtistImpl.GetArtistOneQueryCheckRecordList(c, &artist.GetArtistOneQueryCheckRecordListRequest{
|
|||
|
// Query: &artist.ArtistOneQueryCheckRecordData{ShowUid: req.ShowUid},
|
|||
|
// Page: 1,
|
|||
|
// PageSize: 1,
|
|||
|
//})
|
|||
|
//if err != nil {
|
|||
|
// ErrorWithMark(c, e.Failed, err, "", "查询核验状态失败!")
|
|||
|
// return
|
|||
|
//}
|
|||
|
//if res.Total == 0 {
|
|||
|
// ErrorWithMark(c, e.Failed, nil, "", "请先完成画家核验后再发送邀请函!")
|
|||
|
// return
|
|||
|
//}
|
|||
|
//发送邀请函
|
|||
|
//req.Address = "苏州" //默认为苏州
|
|||
|
//fmt.Println("req.ShowUid", req.ShowUid)
|
|||
|
//resp, err := GrpcArtistImpl.InvitationAdd(context.Background(), &req)
|
|||
|
//if err != nil {
|
|||
|
// ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
// return
|
|||
|
//}
|
|||
|
//go func() {
|
|||
|
// var theseArtists, err = GrpcArtistInfoUserImpl.FindUsers(c, &artistInfoUser.FindUsersRequest{MgmtArtistUids: req.ArtistUuids})
|
|||
|
// if err != nil {
|
|||
|
// fmt.Printf("app通知发送失败。获取画家信息失败:%s\n", err.Error())
|
|||
|
// return
|
|||
|
// }
|
|||
|
// //设置别名
|
|||
|
// var alias []string
|
|||
|
// for _, v := range theseArtists.Data {
|
|||
|
// alias = append(alias, fmt.Sprintf("user_%d_%s", v.Id, v.TelNum))
|
|||
|
// }
|
|||
|
// //发送通知
|
|||
|
// if len(alias) > 0 {
|
|||
|
// appPusher := push.DefaultArtistinfoPusher()
|
|||
|
// appPusher.Audience.SetAlias(alias)
|
|||
|
// appPusher.Notice.Title = "恭喜您收到了一张画展邀请函!"
|
|||
|
// appPusher.Notice.Alert = "请进入画家宝点击邀请函以查看详情。"
|
|||
|
// appPusher.SetAndroidIntentPage("action=com.jiyi.jy_jpush_third.JYThirdActivity;component=uni.UNID335ADB/com.jiyi.jy_jpush_third.JYThirdActivity")
|
|||
|
// if config.Env == "test" {
|
|||
|
// //测试环境
|
|||
|
// appPusher.SetExtrasKeyVale("pageLink", "http://artisttest.szjixun.cn/pages/invite/index")
|
|||
|
// } else {
|
|||
|
// //生成环境
|
|||
|
// appPusher.SetExtrasKeyVale("pageLink", "/pages/invite/index")
|
|||
|
// }
|
|||
|
// //appPusher.SetIosPageLink("/pages/invite/index")
|
|||
|
// err = appPusher.PushNotify()
|
|||
|
// if err != nil {
|
|||
|
// fmt.Println("app通知发送失败:" + err.Error())
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}()
|
|||
|
//徐嘉鸿新增逻辑,查询画展包的画展时间如果小于今天则不发送邀请 updated by xjj 2024-05-21
|
|||
|
showListRes, err := GrpcArtShowImpl.ShowDetail(c, &artShow.ShowDetailReq{
|
|||
|
ShowUID: []string{req.ShowUid},
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
ErrorWithMark(c, e.Failed, err, "", "查询画展包信息失败!")
|
|||
|
return
|
|||
|
}
|
|||
|
if len(showListRes.Data) > 0 {
|
|||
|
var packageShowTime string
|
|||
|
if showListRes.Data[0].ShowTime != "" {
|
|||
|
packageShowTime = showListRes.Data[0].ShowTime
|
|||
|
} else if showListRes.Data[0].PreTime != "" {
|
|||
|
packageShowTime = showListRes.Data[0].PreTime
|
|||
|
}
|
|||
|
var now = time.Now().Format(stime.Format_Normal_YMD)
|
|||
|
if packageShowTime < now {
|
|||
|
ResponseQuickMsg(c, e.Failed, "画展时间已过,无法发送邀请函!", nil)
|
|||
|
return
|
|||
|
}
|
|||
|
} else {
|
|||
|
ResponseQuickMsg(c, e.Failed, "画展包信息不存在!,无法发送邀请函", nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := SendInvitationLetter(&req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func InvitationList(c *gin.Context) {
|
|||
|
var req artist.InvitationListRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationList ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
res, err := GrpcArtistImpl.InvitationList(context.Background(), &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
var resp []InvitationData
|
|||
|
if len(res.Data) > 0 {
|
|||
|
for _, v := range res.Data {
|
|||
|
v := v
|
|||
|
inviteStatus := 0
|
|||
|
switch {
|
|||
|
case v.IsCome == 0:
|
|||
|
inviteStatus = 2
|
|||
|
case v.IsCome == 1:
|
|||
|
inviteStatus = 3
|
|||
|
case v.IsCome == 2:
|
|||
|
inviteStatus = 4
|
|||
|
}
|
|||
|
resp = append(resp, InvitationData{
|
|||
|
InviteStatus: inviteStatus,
|
|||
|
InvitationUpdateRequest: v,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
ResponseQuickMsg(c, e.Ok, res.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func InvitationUpdate(c *gin.Context) {
|
|||
|
var req artist.InvitationUpdateRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationUpdate ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.InvitationUpdate(c, &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func InvitationDel(c *gin.Context) {
|
|||
|
var req artist.InvitationDelRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationDel ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.InvitationDel(context.Background(), &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func InvitationInfo(c *gin.Context) {
|
|||
|
var req artist.InvitationInfoRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationInfo ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.InvitationInfo(context.Background(), &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp.Info)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func DownloadArtist(c *gin.Context) {
|
|||
|
var listReq artist.ExportArtistRequest
|
|||
|
if err := c.ShouldBind(&listReq); err != nil {
|
|||
|
logger.Errorf("ListExport ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ExportArtist(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.RegroupArtistDownloadData(resp.Data, columnStruct, columnDesc, adminId)
|
|||
|
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/%s", httpType, c.Request.Host, zipPath)
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]string{
|
|||
|
"ExportUrl": exportUrl,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func GetCardIdWithImg(c *gin.Context) {
|
|||
|
var listReq artist.GetCardIdWithImgReq
|
|||
|
if err := c.ShouldBind(&listReq); err != nil {
|
|||
|
logger.Errorf("GetCardIdWithImg ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if err := listReq.Validate(); err != nil {
|
|||
|
err = common.SubstrError(err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.GetCardIdWithImg(context.Background(), &listReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func DelContract(c *gin.Context) {
|
|||
|
var req artist.DelContractReq
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("DelContract 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
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.DelContract(context.Background(), &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, nil)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func ArtistOneQueryList(c *gin.Context) {
|
|||
|
var req artist.OneQueryReq
|
|||
|
var reqModel model.OneQueryReq
|
|||
|
var err error
|
|||
|
if err = c.ShouldBind(&reqModel); err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("ArtistOneQueryList --1")
|
|||
|
//查询黑名单中的画家
|
|||
|
var blackArtistUids []string
|
|||
|
blackListRes, err := GrpcArtistImpl.BlackList(context.Background(), &artist.BlackListReq{Page: 1, PageSize: -1, Gender: -1, BlackListStatus: 2})
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("ArtistOneQueryList --2")
|
|||
|
for i, _ := range blackListRes.Data {
|
|||
|
blackArtistUids = append(blackArtistUids, blackListRes.Data[i].ArtistUuid)
|
|||
|
}
|
|||
|
fmt.Println("blackArtistUids", blackArtistUids)
|
|||
|
if reqModel.Permission == model.PermissionFinance && reqModel.AllArtist == 1 {
|
|||
|
var count int32
|
|||
|
var respALl []*AristOneQueryRespData
|
|||
|
respALl, count, err = AllArtist(reqModel)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Failed), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
respALl = AristOneQueryRespDataCount(respALl, blackArtistUids...)
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), map[string]interface{}{
|
|||
|
"Data": respALl,
|
|||
|
"Count": count,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
//临时使用旧版本逻辑
|
|||
|
//ArtistOneQueryListOldLogic(c, reqModel)
|
|||
|
//return
|
|||
|
fmt.Printf("request:%+v\n", reqModel)
|
|||
|
// 查询指定月的画展包
|
|||
|
if reqModel.ShowTime != "" {
|
|||
|
//qst := strings.Split(reqModel.ShowTime, "-")
|
|||
|
//month, _ := strconv.Atoi(qst[1])
|
|||
|
//queryShowTime := fmt.Sprintf("%s.%d", qst[0], month)
|
|||
|
showList, errs := GrpcArtShowImpl.GetShowUidWithShowTime(c, &artShow.GetShowUidWithShowTimeReq{ShowTimes: []string{reqModel.ShowTime}})
|
|||
|
if errs != nil {
|
|||
|
ErrorWithMark(c, e.Failed, errs, "GetShowUidWithShowTime Err:"+errs.Error(), "查询失败")
|
|||
|
return
|
|||
|
}
|
|||
|
if len(showList.ShowUids) == 0 {
|
|||
|
var resp = &artist.OneQueryResp{Data: []*artist.OneQueryResp_Info{}, Page: req.Page, PageSize: req.PageSize}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
req.ShowUids = showList.ShowUids
|
|||
|
}
|
|||
|
fmt.Println("showUids", req.ShowUids)
|
|||
|
_ = copier.Copy(&req, reqModel)
|
|||
|
//fmt.Println("111111111111111111111")
|
|||
|
//var artistResp *artShow.ArtistWithShowTimeResp
|
|||
|
//if artistResp, err = GrpcArtShowImpl.ArtistWithShowTime(context.Background(), &artShow.ArtistWithShowTimeReq{ShowTime: reqModel.ShowTime}); err != nil {
|
|||
|
// fmt.Println("ArtistWithShowTime err", err)
|
|||
|
// ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
// return
|
|||
|
//}
|
|||
|
//fmt.Println("2222222222222")
|
|||
|
//fmt.Printf("ShowTimeArtistUuids:%+v\n", artistResp.ArtistUids)
|
|||
|
//if len(artistResp.ArtistUids) > 0 {
|
|||
|
// req.ShowTimeArtistUuids = artistResp.ArtistUids
|
|||
|
//} else {
|
|||
|
// fmt.Println("OUT1")
|
|||
|
// var resp = &artist.OneQueryResp{Data: []*artist.OneQueryResp_Info{}, Page: req.Page, PageSize: req.PageSize}
|
|||
|
// ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
// return
|
|||
|
//}
|
|||
|
fmt.Println("3333333333333333")
|
|||
|
|
|||
|
if req.Permission == model.PermissionTraining {
|
|||
|
passResp, errS := GrpcArtworkQueryImpl.GetPassArtist(context.Background(), &artwork_query.GetPassArtistReq{})
|
|||
|
if errS != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, errS.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Printf("PassArtistUuids:%+v\n", passResp.ArtistUuids)
|
|||
|
if len(passResp.ArtistUuids) > 0 {
|
|||
|
req.PassArtistUuids = passResp.ArtistUuids
|
|||
|
} else {
|
|||
|
fmt.Println("OUT2")
|
|||
|
var resp = &artist.OneQueryResp{Data: []*artist.OneQueryResp_Info{}, Page: req.Page, PageSize: req.PageSize}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
fmt.Println("4444444444444444444")
|
|||
|
// 如果出库时间不为空 查询满足出库时间的画家
|
|||
|
if req.StockOutTime != "" {
|
|||
|
stockResp, _err := GrpcArtworkQueryImpl.StockOutArtist(context.Background(), &artwork_query.StockOutArtistReq{StockOutTime: req.StockOutTime})
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Printf("StockOutArtistUuids:%+v\n", stockResp.ArtistUuids)
|
|||
|
if len(stockResp.ArtistUuids) > 0 {
|
|||
|
req.StockOutArtistUuids = stockResp.ArtistUuids
|
|||
|
} else {
|
|||
|
fmt.Println("OUT3")
|
|||
|
var resp = &artist.OneQueryResp{Data: []*artist.OneQueryResp_Info{}, Page: req.Page, PageSize: req.PageSize}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
fmt.Println("5555555555555")
|
|||
|
//查询拥有暂存数据的画家
|
|||
|
if req.CheckStatus == 10 {
|
|||
|
req.CheckStatus = 2
|
|||
|
//获取暂存数据的画家列表
|
|||
|
var artistList, errs = GetArtistUidListFromOneQueryDataCache()
|
|||
|
if errs != nil {
|
|||
|
zap.L().Error("ArtistOneQueryList-GetArtistUidListFromOneQueryDataCached err", zap.Error(errs))
|
|||
|
Error(c, e.Failed, errs, "缓存读取失败")
|
|||
|
return
|
|||
|
}
|
|||
|
if len(artistList) > 0 {
|
|||
|
// artistList和ShowTimeArtistUuids取交集
|
|||
|
if len(req.ShowTimeArtistUuids) > 0 {
|
|||
|
req.ShowTimeArtistUuids = utils.Intersection(artistList, req.ShowTimeArtistUuids)
|
|||
|
}
|
|||
|
//artistList和PassArtistUuids取交集
|
|||
|
if len(req.PassArtistUuids) > 0 {
|
|||
|
req.PassArtistUuids = utils.Intersection(artistList, req.PassArtistUuids)
|
|||
|
}
|
|||
|
//artistList和StockOutArtistUuids取交集
|
|||
|
if len(req.StockOutArtistUuids) > 0 {
|
|||
|
req.StockOutArtistUuids = utils.Intersection(artistList, req.StockOutArtistUuids)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if req.CheckStatus != 1 {
|
|||
|
//查询核验数据
|
|||
|
fmt.Println("GrpcArtistImpl.OneQuery START")
|
|||
|
fmt.Printf("OneQuery request params:%+v\n\n", &req)
|
|||
|
resp, errs := GrpcArtistImpl.OneQuery(c, &req)
|
|||
|
if errs != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, errs.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Printf("OneQuery result:%+v \n\n", resp)
|
|||
|
if resp.Count == 0 {
|
|||
|
ResponseList(c, []struct{}{}, OptionPage(req.Page, req.PageSize, resp.Count))
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseCache start")
|
|||
|
//查询缓存中的暂存数据
|
|||
|
resp2, err := UpdateArtistOneQueryDataUseCache(resp.Data, req.Permission, reqModel.ShowTime)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, errs.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseCache end")
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseInvitationLetter start")
|
|||
|
//查询邀请函中的数据
|
|||
|
err = UpdateArtistOneQueryDataUseInvitationLetter(resp2)
|
|||
|
if err != nil {
|
|||
|
ErrorWithMark(c, e.Failed, err, "", "获取画家邀请函信息失败")
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseInvitationLetter end")
|
|||
|
//查询画展时间
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseArtShow start")
|
|||
|
err = UpdateArtistOneQueryDataUseArtShow(resp2)
|
|||
|
if err != nil {
|
|||
|
ErrorWithMark(c, e.Failed, err, "", "获取画展包邀请时间失败")
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("UpdateArtistOneQueryDataUseArtShow end")
|
|||
|
resp2 = AristOneQueryRespInfoCount(resp2, blackArtistUids...)
|
|||
|
//下载在线存储的长文本个人简介
|
|||
|
for i, _ := range resp2 {
|
|||
|
if strings.HasPrefix(resp2[i].Resume, "http") {
|
|||
|
resp2[i].Resume = DownloadIfHttpLongText(resp2[i].Resume)
|
|||
|
}
|
|||
|
if strings.HasPrefix(resp2[i].Resume2, "http") {
|
|||
|
resp2[i].Resume2 = DownloadIfHttpLongText(resp2[i].Resume2)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]any{"Data": resp2, "Page": resp.Page, "PageSize": resp.PageSize, "Count": resp.Count})
|
|||
|
return
|
|||
|
} else {
|
|||
|
//查询未发起核验的画家
|
|||
|
var (
|
|||
|
startShowTime = ""
|
|||
|
endShowTime = ""
|
|||
|
)
|
|||
|
if reqModel.ShowTime != "" {
|
|||
|
startShowTime = reqModel.ShowTime + "-01 00:00:00"
|
|||
|
reqTime, _ := stime.StringToTimeWithFormat(reqModel.ShowTime, "2006-01")
|
|||
|
endTime := time.Date(reqTime.Year(), reqTime.Month(), 1, 0, 0, 0, 0, stime.Loc.Shanghai())
|
|||
|
endShowTime = stime.TimeToString(endTime, stime.Format_Normal_YMDhms)
|
|||
|
}
|
|||
|
fmt.Println("startShowTime", startShowTime)
|
|||
|
fmt.Println("endShowTime", endShowTime)
|
|||
|
//从画展包获取未发起核验的画家数据
|
|||
|
showList, errs := GrpcArtShowImpl.ShowList(c, &artShow.ShowListReq{
|
|||
|
Page: 1,
|
|||
|
PageSize: -1,
|
|||
|
StartShowTime: startShowTime,
|
|||
|
EndShowTime: endShowTime,
|
|||
|
IsSend: 1,
|
|||
|
})
|
|||
|
fmt.Println("showList.total", showList.Total)
|
|||
|
if errs != nil {
|
|||
|
ErrorWithMark(c, e.Failed, errs, "GrpcArtShowImpl.ShowList Err", "查询失败")
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("6666666666666666666666")
|
|||
|
if showList.Total == 0 {
|
|||
|
var resp = &artist.OneQueryResp{Data: []*artist.OneQueryResp_Info{}, Page: req.Page, PageSize: req.PageSize}
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
|||
|
return
|
|||
|
}
|
|||
|
//非教培仅展示画家列表,不展示画展包信息,所以要去重
|
|||
|
if reqModel.Permission != model.PermissionTraining {
|
|||
|
uniqueData := make(map[string]*artShow.ShowDetail)
|
|||
|
for _, v := range showList.Data {
|
|||
|
v := v
|
|||
|
if _, ok := uniqueData[v.ArtistUID]; !ok {
|
|||
|
uniqueData[v.ArtistUID] = v
|
|||
|
}
|
|||
|
}
|
|||
|
showList.Data = make([]*artShow.ShowDetail, 0)
|
|||
|
showList.Total = int64(len(uniqueData))
|
|||
|
for _, v := range uniqueData {
|
|||
|
showList.Data = append(showList.Data, v)
|
|||
|
}
|
|||
|
}
|
|||
|
// 重新排序确保画家位置不变
|
|||
|
sort.Slice(showList.Data, func(i, j int) bool {
|
|||
|
if showList.Data[i].CreateTime == showList.Data[j].CreateTime {
|
|||
|
return showList.Data[i].Tnum > showList.Data[j].Tnum
|
|||
|
} else {
|
|||
|
return showList.Data[i].CreateTime > showList.Data[j].CreateTime
|
|||
|
}
|
|||
|
})
|
|||
|
var artistUids []string
|
|||
|
for k, v := range showList.Data {
|
|||
|
if int32(k) >= reqModel.PageSize*(reqModel.Page-1) && int32(k) < reqModel.PageSize*reqModel.Page {
|
|||
|
artistUids = append(artistUids, v.ArtistUID)
|
|||
|
}
|
|||
|
}
|
|||
|
fmt.Println("artistUids", artistUids)
|
|||
|
var artistsRes = &artist.ArtistListResponse{}
|
|||
|
if len(artistUids) > 0 {
|
|||
|
var artistListRequest = &artist.ArtistListRequest{Uids: artistUids, Page: 1, PageSize: int32(len(artistUids)), Gender: -1}
|
|||
|
fmt.Println("artistListRequest.Gender", artistListRequest.Gender)
|
|||
|
artistsRes, err = GrpcArtistImpl.ArtistList(c, artistListRequest)
|
|||
|
if err != nil {
|
|||
|
ErrorWithMark(c, e.Failed, err, "ArtistList Err", "查询失败")
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
fmt.Println("artistsRes.Count", len(artistsRes.Data))
|
|||
|
var resp2 = []*AristOneQueryRespData{}
|
|||
|
for k, v := range showList.Data {
|
|||
|
if int32(k) >= reqModel.PageSize*(reqModel.Page-1) && int32(k) < reqModel.PageSize*reqModel.Page {
|
|||
|
fmt.Println("k", k)
|
|||
|
var currentArtist *artist.ProfileRequest
|
|||
|
foundArtist := false
|
|||
|
for i, a := range artistsRes.Data {
|
|||
|
fmt.Println("a.Uid", a.Uid)
|
|||
|
if a.Uid == v.ArtistUID {
|
|||
|
foundArtist = true
|
|||
|
currentArtist = artistsRes.Data[i]
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
if !foundArtist {
|
|||
|
fmt.Println("找不到画家:", v.ArtistUID)
|
|||
|
continue
|
|||
|
}
|
|||
|
resp2 = append(resp2, &AristOneQueryRespData{
|
|||
|
OneQueryResp_Info: artist.OneQueryResp_Info{
|
|||
|
CardId: currentArtist.CardId,
|
|||
|
Tnum: v.Tnum,
|
|||
|
StyleFaction: currentArtist.StyleFaction,
|
|||
|
Resume: currentArtist.Resume,
|
|||
|
Age: currentArtist.Age,
|
|||
|
CaaCertNum: currentArtist.CaaCertNum,
|
|||
|
PenName: currentArtist.PenName,
|
|||
|
CoopPlatform: currentArtist.CoopPlatform,
|
|||
|
Gender: currentArtist.Gender,
|
|||
|
Student: currentArtist.Student,
|
|||
|
Teacher: currentArtist.Teacher,
|
|||
|
NativePlace: currentArtist.NativePlace,
|
|||
|
Name: currentArtist.Name,
|
|||
|
School: currentArtist.School,
|
|||
|
Position: currentArtist.Position,
|
|||
|
StageName: currentArtist.StageName,
|
|||
|
CaaJoinTime: currentArtist.CaaJoinTime,
|
|||
|
ArtistUuid: currentArtist.Uid,
|
|||
|
JoinShow: currentArtist.JoinShow,
|
|||
|
Phone: currentArtist.Phone,
|
|||
|
Resume2: currentArtist.Resume2,
|
|||
|
CheckStatus: 1,
|
|||
|
ShowUid: v.ShowUID,
|
|||
|
},
|
|||
|
QueryShowTime: reqModel.ShowTime,
|
|||
|
ShowUid: v.ShowUID,
|
|||
|
ShowName: v.ShowName,
|
|||
|
ShowTime: v.ShowTime,
|
|||
|
PreTime: v.PreTime,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
resp2 = AristOneQueryRespInfoCount(resp2, blackArtistUids...)
|
|||
|
//下载在线存储的长文本个人简介
|
|||
|
for i, _ := range resp2 {
|
|||
|
if strings.HasPrefix(resp2[i].Resume, "http") {
|
|||
|
resp2[i].Resume = DownloadIfHttpLongText(resp2[i].Resume)
|
|||
|
}
|
|||
|
if strings.HasPrefix(resp2[i].Resume2, "http") {
|
|||
|
resp2[i].Resume2 = DownloadIfHttpLongText(resp2[i].Resume2)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, "查询成功", map[string]any{"Data": resp2, "Page": reqModel.Page, "PageSize": reqModel.PageSize, "Count": len(showList.Data)})
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func AllArtist(reqModel model.OneQueryReq) (respALl []*AristOneQueryRespData, count int32, err error) {
|
|||
|
artistResp, _err := GrpcArtistImpl.OneQueryAllArtist(context.Background(), &artist.OneQueryAllArtistReq{
|
|||
|
Page: reqModel.Page,
|
|||
|
PageSize: reqModel.PageSize,
|
|||
|
Keyword: reqModel.Keyword,
|
|||
|
PkUuid: reqModel.PkUuid,
|
|||
|
ArtistUuids: reqModel.SearchArtistUuids,
|
|||
|
})
|
|||
|
if _err != nil {
|
|||
|
err = _err
|
|||
|
return
|
|||
|
}
|
|||
|
count = artistResp.Count
|
|||
|
var artistUuids string
|
|||
|
for _, currentArtist := range artistResp.Data {
|
|||
|
if strings.Contains(artistUuids, currentArtist.ArtistUuid) {
|
|||
|
continue
|
|||
|
}
|
|||
|
artistUuids = fmt.Sprintf("%s,%s", artistUuids, currentArtist.ArtistUuid)
|
|||
|
oneQueryRespInfo := artist.OneQueryResp_Info{}
|
|||
|
_ = copier.Copy(&oneQueryRespInfo, currentArtist)
|
|||
|
respALl = append(respALl, &AristOneQueryRespData{
|
|||
|
OneQueryResp_Info: oneQueryRespInfo,
|
|||
|
//QueryShowTime: reqModel.ShowTime,
|
|||
|
//ShowUid: v.ShowUID,
|
|||
|
//ShowName: v.ShowName,
|
|||
|
//ShowTime: v.ShowTime,
|
|||
|
//PreTime: v.PreTime,
|
|||
|
})
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func ArtistOneQueryExport(c *gin.Context) {
|
|||
|
/*type Person struct {
|
|||
|
Name string
|
|||
|
Age int
|
|||
|
}
|
|||
|
people := []Person{
|
|||
|
{"Alice", 30},
|
|||
|
{"Bob", 25},
|
|||
|
{"Charlie", 35},
|
|||
|
}
|
|||
|
|
|||
|
// 遍历切片中的每个结构体
|
|||
|
for _, p := range people {
|
|||
|
// 使用反射获取结构体的类型信息
|
|||
|
t := reflect.TypeOf(p)
|
|||
|
v := reflect.ValueOf(p)
|
|||
|
|
|||
|
// 遍历结构体的字段并输出字段名和值
|
|||
|
for i := 0; i < t.NumField(); i++ {
|
|||
|
fieldName := t.Field(i).Name
|
|||
|
fieldValue := v.Field(i).Interface()
|
|||
|
fmt.Printf("%s: %v\n", fieldName, fieldValue)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Failed, "", nil)
|
|||
|
return*/
|
|||
|
var resp *artist.OneQueryResp = &artist.OneQueryResp{}
|
|||
|
var req artist.OneQueryReq
|
|||
|
var err error
|
|||
|
var reqModel model.OneQueryReq
|
|||
|
if err = c.ShouldBind(&reqModel); err != nil {
|
|||
|
logger.Errorf("ArtistOneQueryExport ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if reqModel.ExportAll == 1 {
|
|||
|
reqModel.AllArtist = 1
|
|||
|
reqModel.ColumnsFields = model.ExportOneQueryArtistFields
|
|||
|
}
|
|||
|
_ = copier.Copy(&req, reqModel)
|
|||
|
if reqModel.Permission == model.PermissionFinance && reqModel.AllArtist == 1 {
|
|||
|
var respALl []*AristOneQueryRespData
|
|||
|
respALl, _, err = AllArtist(reqModel)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Failed), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
_ = copier.Copy(&resp.Data, respALl)
|
|||
|
} else {
|
|||
|
// 如果没有时间默认当月
|
|||
|
if reqModel.ShowTime == "" {
|
|||
|
reqModel.ShowTime = time.Now().Format("2006-01")
|
|||
|
}
|
|||
|
var artistResp *artShow.ArtistWithShowTimeResp
|
|||
|
if artistResp, err = GrpcArtShowImpl.ArtistWithShowTime(context.Background(), &artShow.ArtistWithShowTimeReq{ShowTime: reqModel.ShowTime}); err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if len(artistResp.ArtistUids) > 0 {
|
|||
|
req.ShowTimeArtistUuids = artistResp.ArtistUids
|
|||
|
}
|
|||
|
if req.Permission == model.PermissionTraining {
|
|||
|
passResp, errS := GrpcArtworkQueryImpl.GetPassArtist(context.Background(), &artwork_query.GetPassArtistReq{})
|
|||
|
if errS != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, errS.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
req.PassArtistUuids = passResp.ArtistUuids
|
|||
|
}
|
|||
|
// 如果出库时间不为空 查询满足出库时间的画家
|
|||
|
if req.StockOutTime != "" {
|
|||
|
stockResp, _err := GrpcArtworkQueryImpl.StockOutArtist(context.Background(), &artwork_query.StockOutArtistReq{StockOutTime: req.StockOutTime})
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
req.StockOutArtistUuids = stockResp.ArtistUuids
|
|||
|
if len(req.StockOutArtistUuids) == 0 {
|
|||
|
req.StockOutArtistUuids = []string{"-1"}
|
|||
|
}
|
|||
|
}
|
|||
|
resp, err = GrpcArtistImpl.OneQuery(context.Background(), &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var adminId uint64
|
|||
|
var fileName string
|
|||
|
if mLoginInfoAny, exists := c.Get("mLoginInfo"); exists {
|
|||
|
userInfo := mLoginInfoAny.(model.LoginInfo)
|
|||
|
adminId = userInfo.ID
|
|||
|
}
|
|||
|
var genderMap = make(map[string]string, 3)
|
|||
|
genderMap = map[string]string{"0": "女", "1": "男", "3": "未知"}
|
|||
|
if len(resp.Data) > 0 {
|
|||
|
var dataSliceKv []map[string]interface{} = make([]map[string]interface{}, 0, len(resp.Data))
|
|||
|
var artistUuids string
|
|||
|
for _, vv := range resp.Data {
|
|||
|
if strings.Contains(artistUuids, vv.ArtistUuid) {
|
|||
|
continue
|
|||
|
}
|
|||
|
artistUuids = fmt.Sprintf("%s,%s", artistUuids, vv.ArtistUuid)
|
|||
|
var info model.OneQueryArtistRespInfo
|
|||
|
_ = copier.Copy(&info, vv)
|
|||
|
t := reflect.TypeOf(info)
|
|||
|
v := reflect.ValueOf(info)
|
|||
|
var tmp map[string]interface{} = make(map[string]interface{})
|
|||
|
for i := 0; i < t.NumField(); i++ {
|
|||
|
fieldName := t.Field(i).Name
|
|||
|
fieldValue := v.Field(i).Interface()
|
|||
|
tmp[fieldName] = fieldValue
|
|||
|
}
|
|||
|
dataSliceKv = append(dataSliceKv, tmp)
|
|||
|
}
|
|||
|
var columns []string
|
|||
|
for _, column := range req.ColumnsFields {
|
|||
|
if _, ok := model.OneQueryArtistColumn[column]; ok {
|
|||
|
columns = append(columns, model.OneQueryArtistColumn[column])
|
|||
|
}
|
|||
|
}
|
|||
|
var data []interface{}
|
|||
|
for _, v := range dataSliceKv {
|
|||
|
var temp []string
|
|||
|
for _, column := range req.ColumnsFields {
|
|||
|
var columnVal string
|
|||
|
if v[column] == nil {
|
|||
|
continue
|
|||
|
}
|
|||
|
columnVal = fmt.Sprintf("%v", v[column])
|
|||
|
if column == "Gender" {
|
|||
|
columnVal = genderMap[columnVal]
|
|||
|
}
|
|||
|
temp = append(temp, columnVal)
|
|||
|
}
|
|||
|
data = append(data, &temp)
|
|||
|
}
|
|||
|
fileName = fmt.Sprintf("画家数据%d.xlsx", adminId)
|
|||
|
_, err = utils.ToExcelByType(columns, data, "slice", "./runtime/"+fileName)
|
|||
|
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, fileName)
|
|||
|
ResponseQuickMsg(c, e.Ok, resp.Msg, map[string]string{
|
|||
|
"url": exportUrl,
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func SendIndexes(c *gin.Context) {
|
|||
|
var req model.ArtistInfo
|
|||
|
var err error
|
|||
|
if err = c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("SendIndexes ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.InvalidParams), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, _err := GrpcArtistImpl.ArtistDetail(context.Background(), &artist.DetailRequest{Uid: req.ArtistUuid})
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if resp.ProfileInfo.CardId == "" {
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorArtistCardId), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
var indexexInfo model.IndexesInfo
|
|||
|
if err = json.Unmarshal([]byte(resp.ProfileInfo.Indexs), &indexexInfo); err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.ErrorIndexes), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
timeNow := time.Now().Unix()
|
|||
|
param := fmt.Sprintf("Browse_point=%v&Card_id=%v&Coll_point=%v&Edu_point=%v&Exhibition_point=%v&Skill_point=%v&Timestamp=%d",
|
|||
|
indexexInfo.Influence, resp.ProfileInfo.CardId, indexexInfo.Collectible, indexexInfo.Education, indexexInfo.Exhibition, indexexInfo.Professionalism, timeNow)
|
|||
|
sign := utils.Md5Str(param)
|
|||
|
postData := model.SendIndexesReq{
|
|||
|
CardID: resp.ProfileInfo.CardId,
|
|||
|
ExhibitionPoint: indexexInfo.Exhibition,
|
|||
|
SkillPoint: indexexInfo.Professionalism,
|
|||
|
BrowsePoint: indexexInfo.Influence,
|
|||
|
CollPoint: indexexInfo.Collectible,
|
|||
|
EduPoint: indexexInfo.Education,
|
|||
|
Timestamp: int(timeNow),
|
|||
|
Sign: sign,
|
|||
|
}
|
|||
|
_, respSend, err := utils.PostBody(config.SendIndexesUrl, postData)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), respSend)
|
|||
|
return
|
|||
|
}
|
|||
|
var sendResp model.RespSendIndexes
|
|||
|
_ = json.Unmarshal([]byte(respSend), &sendResp)
|
|||
|
if sendResp.Code == 0 {
|
|||
|
ResponseQuickMsg(c, e.Failed, sendResp.Msg, respSend)
|
|||
|
return
|
|||
|
}
|
|||
|
var reqLog artist.AddIndexesLogReq
|
|||
|
_ = copier.Copy(&reqLog, indexexInfo)
|
|||
|
reqLog.ArtistUuid = req.ArtistUuid
|
|||
|
_, err = GrpcArtistImpl.AddIndexesLog(context.Background(), &reqLog)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func IndexesLog(c *gin.Context) {
|
|||
|
var req artist.IndexesLogReq
|
|||
|
var err error
|
|||
|
if err = c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("IndexesLog ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, e.GetMsg(e.InvalidParams), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, _err := GrpcArtistImpl.IndexesLog(context.Background(), &artist.IndexesLogReq{ArtistUuid: req.ArtistUuid})
|
|||
|
if _err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, _err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func BatchUpdLowArtist(c *gin.Context) {
|
|||
|
var batchUpdLowArtistReq artist.BatchUpdLowArtistReq
|
|||
|
//if err := c.ShouldBind(&batchUpdLowArtistReq); err != nil {
|
|||
|
// logger.Errorf("BatchUpdLowArtist ShouldBind err", err)
|
|||
|
// ResponseQuickMsg(c, e.Ok, e.GetMsg(e.InvalidParams), nil)
|
|||
|
// return
|
|||
|
//}
|
|||
|
resp, err := GrpcArtistImpl.BatchUpdLowArtist(context.Background(), &batchUpdLowArtistReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), resp)
|
|||
|
return
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
func SaveLowArtist(c *gin.Context) {
|
|||
|
var lowArtist artist.LowArtist
|
|||
|
if err := c.ShouldBind(&lowArtist); err != nil {
|
|||
|
logger.Errorf("SaveLowArtist ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.InvalidParams), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.SaveLowArtist(context.Background(), &lowArtist)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), resp)
|
|||
|
return
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
func LowArtistList(c *gin.Context) {
|
|||
|
var lowArtistListReq artist.LowArtistListReq
|
|||
|
if err := c.ShouldBind(&lowArtistListReq); err != nil {
|
|||
|
logger.Errorf("LowArtistList ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.InvalidParams), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.LowArtistList(context.Background(), &lowArtistListReq)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, e.GetMsg(e.Success), resp)
|
|||
|
return
|
|||
|
|
|||
|
}
|
|||
|
func SyncLowArtist() {
|
|||
|
var lowArtistListReq artist.LowArtistListReq
|
|||
|
lowArtistListReq.Sync = 1
|
|||
|
_, err := GrpcArtistImpl.LowArtistList(context.Background(), &lowArtistListReq)
|
|||
|
if err != nil {
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
func InvitationDetail(c *gin.Context) {
|
|||
|
var req artist.InvitationInfoRequest
|
|||
|
if err := c.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("InvitationInfo ShouldBind err", err)
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.GetInvitationLetterDetail(c, &artist.GetInvitationLetterDetailReq{LetterUid: req.Uuid})
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
//从画家招待获取出行信息
|
|||
|
fmt.Println("InvitationDetail------------1")
|
|||
|
entertainmentRes, err := GrpcArtShowImpl.GetArtistEntertainmentList(c, &artShow.GetArtistEntertainmentListRequest{
|
|||
|
Query: &artShow.ArtistEntertainment{ShowUID: resp.ShowUid},
|
|||
|
Page: 1,
|
|||
|
PageSize: 1,
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
Error(c, e.Failed, err, "从画家招待获取出行信息失败")
|
|||
|
return
|
|||
|
}
|
|||
|
fmt.Println("InvitationDetail--------------------2")
|
|||
|
if entertainmentRes.Total > 0 {
|
|||
|
fmt.Println("InvitationDetail-----------------3")
|
|||
|
var TravelWay int32 //画家招待的出行方式和邀请函中的定义是反过来的
|
|||
|
if entertainmentRes.List[0].TravelWay == 1 {
|
|||
|
TravelWay = 2
|
|||
|
} else if entertainmentRes.List[0].TravelWay == 2 {
|
|||
|
TravelWay = 1
|
|||
|
}
|
|||
|
//resp.Address = entertainmentRes.List[0].Address
|
|||
|
//resp.ShowTime = entertainmentRes.List[0].ShowTime
|
|||
|
resp.ArrivalDate = entertainmentRes.List[0].ArrivalDate
|
|||
|
resp.ArrivalTime = entertainmentRes.List[0].ArrivalTime
|
|||
|
resp.TrainNumber = entertainmentRes.List[0].TrainNum
|
|||
|
resp.ArrivalPlace = entertainmentRes.List[0].ArrivalAddress
|
|||
|
resp.TravelMethod = TravelWay
|
|||
|
resp.TravelCert = entertainmentRes.List[0].Transportation
|
|||
|
}
|
|||
|
//如果画展包已经完成审批,则使用审批完成后的画展时间和地址
|
|||
|
showRelRes, err := GrpcArtShowImpl.GetShowRelDetail(context.Background(), &artShow.GetShowRelByIdRequest{ShowUid: resp.ShowUid})
|
|||
|
if err == nil && showRelRes.Address != "" && showRelRes.ShowTime != "" {
|
|||
|
resp.Address = showRelRes.Address
|
|||
|
resp.ShowTime = showRelRes.ShowTime
|
|||
|
}
|
|||
|
fmt.Printf("InvitationDetail resp:%+v\n", resp)
|
|||
|
//增加artistShowCount字段
|
|||
|
invitationLetter, _ := GrpcArtistImpl.GetInvitationLetterList(c, &artist.GetInvitationLetterListRequest{Query: &artist.InvitationLetterData{Uuid: resp.LetterUid}, Page: 1, PageSize: 1})
|
|||
|
var mapData = make(map[string]interface{})
|
|||
|
jsonBytes, _ := json.Marshal(resp)
|
|||
|
_ = json.Unmarshal(jsonBytes, &mapData)
|
|||
|
countList, _ := GrpcArtShowImpl.ArtistExhibitionCount(context.Background(), &artShow.ArtistExhibitionCountReq{ArtistUid: []string{invitationLetter.List[0].ArtistUuid}})
|
|||
|
if countList != nil && len(countList.ArtistShowCount) > 0 {
|
|||
|
mapData["artistShowCount"] = fmt.Sprintf("%s(%d)", invitationLetter.List[0].ArtistName, countList.ArtistShowCount[0].ShowCount)
|
|||
|
} else {
|
|||
|
mapData["artistShowCount"] = fmt.Sprintf("%s(0)", resp.ArtistName)
|
|||
|
}
|
|||
|
ResponseQuickMsg(c, e.Ok, "查询成功", mapData)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func AristOneQueryRespDataCount(data []*AristOneQueryRespData, blackArtistUidList ...string) (newData []*AristOneQueryRespData) {
|
|||
|
newData = data
|
|||
|
if len(newData) == 0 {
|
|||
|
return
|
|||
|
}
|
|||
|
var artistUids []string = make([]string, 0, len(newData))
|
|||
|
for k, v := range newData {
|
|||
|
artistUids = append(artistUids, v.ArtistUuid)
|
|||
|
newData[k].ArtistShowCount = fmt.Sprintf("%s(0)", v.Name)
|
|||
|
}
|
|||
|
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 newData {
|
|||
|
if len(blackArtistUidList) > 0 {
|
|||
|
for _, blackUid := range blackArtistUidList {
|
|||
|
if blackUid == v.ArtistUuid {
|
|||
|
newData[k].Name = "#" + newData[k].Name
|
|||
|
continue
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
for _, v1 := range artshowResp.ArtistShowCount {
|
|||
|
if v.ArtistUuid == v1.ArtistUid {
|
|||
|
newData[k].ArtistShowCount = fmt.Sprintf("%s(%d)", v.Name, v1.ShowCount)
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func AristOneQueryRespInfoCount(data []*AristOneQueryRespData, blackListUidList ...string) (newData []*AristOneQueryRespData) {
|
|||
|
newData = data
|
|||
|
if len(newData) == 0 {
|
|||
|
return
|
|||
|
}
|
|||
|
var artistUids []string = make([]string, 0, len(newData))
|
|||
|
for k, v := range newData {
|
|||
|
artistUids = append(artistUids, v.ArtistUuid)
|
|||
|
newData[k].ArtistShowCount = fmt.Sprintf("%s(0)", v.Name)
|
|||
|
}
|
|||
|
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 newData {
|
|||
|
if len(blackListUidList) > 0 {
|
|||
|
for _, blackUid := range blackListUidList {
|
|||
|
if blackUid == v.ArtistUuid {
|
|||
|
newData[k].Name = "#" + newData[k].Name
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
for _, v1 := range artshowResp.ArtistShowCount {
|
|||
|
if v.ArtistUuid == v1.ArtistUid {
|
|||
|
newData[k].ArtistShowCount = fmt.Sprintf("%s(%d)", v.Name, v1.ShowCount)
|
|||
|
break
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func ArtistBaseInfo(ctx *gin.Context) {
|
|||
|
req := artist.ArtistBaseInfoReq{}
|
|||
|
if err := ctx.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("ListHandler ShouldBind err", err)
|
|||
|
ResponseQuickMsg(ctx, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ArtistBaseInfo(ctx, &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(ctx, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp.ArtistShowCount = fmt.Sprintf("%s(0)", resp.Name)
|
|||
|
artshowResp, _err := GrpcArtShowImpl.ArtistExhibitionCount(context.Background(), &artShow.ArtistExhibitionCountReq{ArtistUid: []string{resp.ArtistUuid}})
|
|||
|
if _err != nil {
|
|||
|
zap.L().Error("artist ArtistExhibitionCount err", zap.Error(_err))
|
|||
|
}
|
|||
|
if artshowResp != nil && len(artshowResp.ArtistShowCount) > 0 {
|
|||
|
resp.ArtistShowCount = fmt.Sprintf("%s(%d)", resp.Name, artshowResp.ArtistShowCount[0].ShowCount)
|
|||
|
resp.ShowCount = artshowResp.ArtistShowCount[0].ShowCount
|
|||
|
if resp.BlackListStatus == 2 {
|
|||
|
resp.Name = fmt.Sprintf("#%s", resp.Name)
|
|||
|
}
|
|||
|
}
|
|||
|
ResponseQuickMsg(ctx, e.Ok, "", resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func ArtistBaseList(ctx *gin.Context) {
|
|||
|
req := artist.ArtistBaseListReq{}
|
|||
|
if err := ctx.ShouldBind(&req); err != nil {
|
|||
|
logger.Errorf("ArtistBaseList ShouldBind err", err)
|
|||
|
ResponseQuickMsg(ctx, e.Failed, "", nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ArtistBaseList(ctx, &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(ctx, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
if resp == nil || resp.Data == nil {
|
|||
|
ResponseQuickMsg(ctx, e.Ok, e.GetMsg(e.Ok), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
var artistUuids []string
|
|||
|
if resp.Data != nil {
|
|||
|
for k, v := range resp.Data {
|
|||
|
v.ArtistShowCount = fmt.Sprintf("%s(0)", v.Name)
|
|||
|
artistUuids = append(artistUuids, v.Uid)
|
|||
|
if v.BlackListStatus == 2 {
|
|||
|
resp.Data[k].Name = fmt.Sprintf("#%s", v.Name)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// 如果有过滤操作就再去查询画作那边的画家
|
|||
|
if req.FilterType == "HAS_ARTWORK" {
|
|||
|
artistResp, _err := GrpcArtworkQueryImpl.ArtworkArtistList(ctx, &artwork_query.ArtworkArtistListReq{})
|
|||
|
if _err == nil && len(artistResp.Data) > 0 {
|
|||
|
tempData := resp.Data
|
|||
|
resp.Data = nil
|
|||
|
for _, v := range tempData {
|
|||
|
for _, vv := range artistResp.Data {
|
|||
|
if v.Uid == vv.ArtistUuid {
|
|||
|
v.ArtistShowCount = fmt.Sprintf("%s(%d)", v.Name, vv.ArtworkNum)
|
|||
|
v.ShowCount = vv.ArtworkNum
|
|||
|
resp.Data = append(resp.Data, v)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
resp.Count = int32(len(resp.Data))
|
|||
|
if len(resp.Data) <= 50 && req.PageSize <= 50 {
|
|||
|
artShowResp, _err := GrpcArtShowImpl.ArtistExhibitionCount(context.Background(), &artShow.ArtistExhibitionCountReq{ArtistUid: artistUuids})
|
|||
|
if _err == nil && len(artShowResp.ArtistShowCount) > 0 {
|
|||
|
for _, v := range resp.Data {
|
|||
|
for _, vv := range artShowResp.ArtistShowCount {
|
|||
|
if v.Uid == vv.ArtistUid {
|
|||
|
v.ArtistShowCount = fmt.Sprintf("%s(%d)", v.Name, vv.ShowCount)
|
|||
|
v.ShowCount = vv.ShowCount
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// 如果有过滤标志,就要去画作那边查询
|
|||
|
ResponseQuickMsg(ctx, e.Ok, e.GetMsg(e.Ok), resp)
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func SearchList(ctx *gin.Context) {
|
|||
|
req := artist.ArtistSearchReq{}
|
|||
|
if err := ctx.ShouldBind(&req); err != nil {
|
|||
|
zap.L().Error("SearchList ShouldBind err", zap.Error(err))
|
|||
|
ResponseQuickMsg(ctx, e.Failed, "", nil)
|
|||
|
return
|
|||
|
}
|
|||
|
resp, err := GrpcArtistImpl.ArtistSearch(ctx, &req)
|
|||
|
if err != nil {
|
|||
|
ResponseQuickMsg(ctx, e.Failed, err.Error(), nil)
|
|||
|
return
|
|||
|
}
|
|||
|
for _, v := range resp.Data {
|
|||
|
if v.BlackListStatus == 2 {
|
|||
|
listTimes, _ := stime.DatetimeToTimes(v.BlackListTime, stime.Format_Normal_YMDhms)
|
|||
|
if listTimes > 0 && (int64(listTimes)+86400*365) < time.Now().Unix() {
|
|||
|
v.BlackListStatus = 100
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
service.ResponseQuickMsg(ctx, e.Ok, e.GetMsg(e.Success), resp)
|
|||
|
return
|
|||
|
}
|
|||
|
func CheckEditLimit(ctx *gin.Context, tagName string, artistUuid string) (limitInfo pkgResponse.EditLimitInfo, err error) {
|
|||
|
userInfoAny, ok := ctx.Get("mLoginInfo")
|
|||
|
loginInfo := model.LoginInfo{}
|
|||
|
if ok {
|
|||
|
loginInfo = userInfoAny.(model.LoginInfo)
|
|||
|
}
|
|||
|
if projectConf.Env == "dev" {
|
|||
|
loginInfo.ID = 1
|
|||
|
loginInfo.NickName = "admin"
|
|||
|
}
|
|||
|
cacheLimitKey := fmt.Sprintf("editLimit_%s_%s", tagName, artistUuid)
|
|||
|
limitVal := cache.RedisClient.Get(cacheLimitKey)
|
|||
|
|
|||
|
if limitVal.Val() != "" {
|
|||
|
_ = json.Unmarshal([]byte(limitVal.Val()), &limitInfo)
|
|||
|
if limitInfo.AdminID != loginInfo.ID {
|
|||
|
err = errors.New(e.ERROR_EDIT_LIMIT)
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
func RemoveEditLimit(tagName string, artistUuid string) {
|
|||
|
cacheLimitKey := fmt.Sprintf("editLimit_%s_%s", tagName, artistUuid)
|
|||
|
cache.RedisClient.Del(cacheLimitKey)
|
|||
|
}
|