main
jhc 2 years ago
parent f3af2a2804
commit 28381abfee

@ -42,7 +42,7 @@ func (p *ArtShowProvider) UpdateShow(ctx context.Context, req *artShow.SaveShowR
res = new(artShow.SaveShowRes)
if req.IsShow == m.ARTSHOW_INSIDE {
showRel := new(model.ShowRel)
err, showRel = service.QueryShowRel(uint(req.ID))
err, showRel = service.QueryShowRel_showId(req.ID)
if err != nil {
return res, err
}
@ -64,6 +64,7 @@ func (p *ArtShowProvider) UpdateShow(ctx context.Context, req *artShow.SaveShowR
}
func (p *ArtShowProvider) DelShow(ctx context.Context, req *artShow.DelShowReq) (res *artShow.CommonRes, err error) {
res = new(artShow.CommonRes)
if len(req.ShowID) < 1 {
err = errors.New(m.ERROR_INVALID_ID)
return
@ -95,8 +96,18 @@ func (p *ArtShowProvider) ShowList(ctx context.Context, req *artShow.ShowListReq
return
}
func (p *ArtShowProvider) ShowInfo(ctx context.Context, req *artShow.ShowDetailReq) (res *artShow.ShowArtworkDetailRes, err error) {
err, res = service.ShowInfo(req)
func (p *ArtShowProvider) ShowArtworkInfo(ctx context.Context, req *artShow.ShowDetailReq) (res *artShow.ShowArtworkDetailRes, err error) {
err, res = service.ShowArtworkInfo(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) ShowDetail(ctx context.Context, req *artShow.ShowDetailReq) (res *artShow.ShowDetailRes, err error) {
err, res = service.ShowDetail(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)

@ -6,14 +6,15 @@ import (
"fonchain-artshow/pkg/db"
"go.uber.org/zap"
"gorm.io/gorm"
"log"
)
func SaveArtShow(tx *gorm.DB, artShow *model.ArtShow) (err error) {
if artShow.ID != uint(0) {
err = tx.Model(&model.ArtShow{}).Omit("id").Where("id = ?", artShow.ID).Updates(&artShow).Error
err = tx.Model(&model.ArtShow{}).Omit("id").Where("id = ?", artShow.ID).Updates(artShow).Error
} else {
err = tx.Model(&model.ArtShow{}).Create(artShow).Error
err = tx.Model(&model.ArtShow{}).Create(&artShow).Error
}
if err != nil {
zap.L().Error("ArtShow err", zap.Error(err))
@ -82,8 +83,8 @@ func ArtShowListByApplyStatus(in *artShow.ShowListReq) (err error, total int64,
return
}
func DelArtShow(in *artShow.DelShowReq) (err error) {
err = db.DbArtShow.Where("id = ?", in.ShowID).Delete(&model.ArtShow{}).Error
func DelArtShow(tx *gorm.DB, show_id int64) (err error) {
err = tx.Where("id = ?", show_id).Delete(&model.ArtShow{}).Error
if err != nil {
zap.L().Error("ArtShow delete err", zap.Error(err))
return
@ -97,21 +98,45 @@ func QueryArtShow(id uint) (err error, out *model.ArtShow) {
zap.L().Error("ArtShow Find err", zap.Error(err))
return
}
log.Println(out)
return
}
func ShowStatistical(isShow int32) (err error, artistNum int64, packageNum int64) {
func ShowStatistical(isShow int32) (err error, artistNum, packageNum, totalNum, NotShowNum, ShowHisNum int64) {
artistNum = 0
err = db.DbArtShow.Model(&model.ArtShow{}).Distinct("artist_name").Where("is_show = ?", isShow).Count(&artistNum).Error
if err != nil {
zap.L().Error("ShowStatistical artistNum count err", zap.Error(err))
return
}
packageNum = 0
err = db.DbArtShow.Model(&model.ArtShow{}).Where("is_show = ?", isShow).Count(&packageNum).Error
if err != nil {
zap.L().Error("ShowStatistical packageNum count err", zap.Error(err))
return
}
totalNum = 0
err = db.DbArtShow.Model(&model.ArtShow{}).Count(&totalNum).Error
if err != nil {
zap.L().Error("ShowStatistical totalNum count err", zap.Error(err))
return
}
NotShowNum = 0
err = db.DbArtShow.Table("art_show as a").Distinct("b.artist_name").Joins(" join artwork_price as b on b.show_id = a.id").Where("a.is_show in (1,2)").Count(&NotShowNum).Error
if err != nil {
zap.L().Error("ShowStatistical totalNum count err", zap.Error(err))
return
}
ShowHisNum = 0
err = db.DbArtShow.Table("art_show as a").Distinct("b.artist_name").Joins(" join artwork_price as b on b.show_id = a.id").Where("a.is_show = 3 ").Count(&ShowHisNum).Error
if err != nil {
zap.L().Error("ShowStatistical totalNum count err", zap.Error(err))
return
}
return
}

@ -14,7 +14,13 @@ func SaveArtworkPrice(tx *gorm.DB, artworks []*model.ArtworkPrice) (err error, i
if artworks[i].ID != 0 {
err = tx.Model(&model.ArtworkPrice{}).Omit("id").Where("id = ?", artworks[i].ID).Updates(artworks[i]).Error
} else {
artworkPrice := new(model.ArtworkPrice)
results := tx.Model(&model.ArtworkPrice{}).Where("show_id = ? and artwork_id = ?", artworks[i].ShowID, artworks[i].ArtworkID).First(&artworkPrice)
if results.Error == nil || artworkPrice.ID == 0 {
err = tx.Model(&model.ArtworkPrice{}).Create(&artworks[i]).Error
} else {
err = tx.Model(&model.ArtworkPrice{}).Where("show_id = ? and artwork_id = ?", artworks[i].ShowID, artworks[i].ArtworkID).Updates(artworks[i]).Error
}
}
if err != nil {
zap.L().Error("Artwork price save err", zap.Error(err))
@ -55,8 +61,17 @@ func QueryArtworkPrice_id(id uint) (err error, out *model.ArtworkPrice) {
return
}
func DelArtworkPrice(tx *gorm.DB, ids []uint) (err error) {
err = tx.Where("id in (?)", ids).Delete(&model.ArtworkPrice{}, ids).Error
func DelArtworkPrice(tx *gorm.DB, ids []int64) (err error) {
err = tx.Where("id in (?)", ids).Delete(&model.ArtworkPrice{}).Error
if err != nil {
zap.L().Error("Artwork delete err", zap.Error(err))
return
}
return
}
func DelArtworkPrice_showId(tx *gorm.DB, id int64) (err error) {
err = tx.Where("show_id = ? ", id).Delete(&model.ArtworkPrice{}).Error
if err != nil {
zap.L().Error("Artwork delete err", zap.Error(err))
return

@ -15,7 +15,7 @@ func SaveShowApply(showApply *model.ShowApply) (tx *gorm.DB, err error) {
if showApply.ID != uint(0) {
err = tx.Model(&model.ShowApply{}).Omit("id").Where("id = ?", showApply.ID).Updates(showApply).Error
} else {
err = tx.Model(&model.ShowApply{}).Create(showApply).Error
err = tx.Model(&model.ShowApply{}).Create(&showApply).Error
}
if err != nil {
zap.L().Error("ShowApply err", zap.Error(err))
@ -60,6 +60,7 @@ func ShowApplyDetail(applyID uint) (err error, out *model.ShowApply) {
}
return
}
func DelShowApply(in *artShow.DelApplyReq) (tx *gorm.DB, err error) {
tx = db.DbArtShow.Begin()
err = tx.Delete(&model.ShowApply{}, in.ApplyID).Error

@ -13,7 +13,13 @@ func SaveShowRels(tx *gorm.DB, showRels []*model.ShowRel) (err error, out []uint
if showRels[i].ID != 0 {
err = tx.Model(&model.ShowRel{}).Omit("id").Where("id = ?", showRels[i].ID).Updates(showRels[i]).Error
} else {
err = tx.Model(&model.ShowRel{}).Create(&showRels[i]).Error
showRel := new(model.ShowRel)
results := tx.Model(&model.ArtworkPrice{}).Where("show_id = ? and apply_id = ?", showRels[i].ShowID, showRels[i].ApplyID).First(&showRel)
if results.Error == nil || showRel.ID == 0 {
err = tx.Model(&model.ArtworkPrice{}).Create(&showRels[i]).Error
} else {
err = tx.Model(&model.ArtworkPrice{}).Where("show_id = ? and apply_id = ?", showRels[i].ShowID, showRels[i].ApplyID).Updates(showRels[i]).Error
}
}
if err != nil {
zap.L().Error("ShowRels err", zap.Error(err))
@ -33,7 +39,7 @@ func SaveShowRel(tx *gorm.DB, showRel *model.ShowRel) (err error) {
return
}
func DelShowRel(tx *gorm.DB, ids []uint) (err error) {
func DelShowRel(tx *gorm.DB, ids []int64) (err error) {
err = tx.Where("id in (?)", ids).Delete(&model.ShowRel{}).Error
if err != nil {
zap.L().Error("ShowRel delete err", zap.Error(err))
@ -51,11 +57,11 @@ func DelShowRelByApplyID(tx *gorm.DB, applyID uint) (err error) {
return
}
func QueryShowRel(showID uint) (err error, out *model.ShowRel) {
func QueryShowRel_showId(showID int64) (err error, out *model.ShowRel) {
out = new(model.ShowRel)
findDB := db.DbArtShow.Model(&model.ShowRel{})
if showID != 0 {
findDB = findDB.Where("id = ? ", showID)
findDB = findDB.Where("show_id = ? ", showID)
}
err = findDB.Find(&out).Error
if err != nil {

@ -2,12 +2,12 @@ package main
import (
"fmt"
"fonchain-artshow/pb/artShow"
"google.golang.org/grpc"
grpc2 "fonchain-artshow/pb/grpc"
//grpc_go "github.com/dubbogo/grpc-go"
"net"
"google.golang.org/grpc"
"fonchain-artshow/cmd/controller"
"fonchain-artshow/pkg/db"
"fonchain-artshow/pkg/logger"
@ -15,7 +15,7 @@ import (
)
type server struct {
artShow.UnimplementedArtShowServer
grpc2.UnimplementedArtShowServer
}
func main() {
@ -26,7 +26,7 @@ func main() {
}
s := grpc.NewServer() // 创建gRPC服务器
artShow.RegisterArtShowServer(s, &controller.ArtShowProvider{}) // 在gRPC服务端注册服务
grpc2.RegisterArtShowServer(s, &controller.ArtShowProvider{}) // 在gRPC服务端注册服务
db.Init(m.SERVER_CONFIG)
//初始化zap

@ -12,6 +12,8 @@ type ArtworkPrice struct {
SmallPic string `json:"small_pic" gorm:"small_pic"` // 画作小图
Price int64 `json:"price" gorm:"price"` // 总价
RulerPrice int64 `json:"ruler_price" gorm:"ruler_price"` // 平尺价
Length int32 `json:"length" gorm:"length"` // 画作长度
Width int32 `json:"width" gorm:"width"` // 画作宽度
Ruler int32 `json:"ruler" gorm:"ruler"` // 画作平尺
ArtworkPrice int64 `json:"artwork_price" gorm:"artwork_price"` // 画作价格
MarketPrice int64 `json:"market_price" gorm:"market_price"` // 市场价

@ -1,13 +1,14 @@
package service
import (
"errors"
"fmt"
"fonchain-artshow/cmd/dao"
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/artShow"
"fonchain-artshow/pkg/db"
"fonchain-artshow/pkg/m"
"fonchain-artshow/pkg/serializer"
"fonchain-artshow/pkg/utils"
)
func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID uint) {
@ -21,12 +22,11 @@ func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID u
return
}
if len(in.ShowArtwork) > 0 {
artworks := serializer.BuildShowArtworkM(in.ShowArtwork, artShowM.ID)
err, artworks = serializer.CalcPrice(artworks, artShowM.Ruler, artShowM.Price)
if err != nil {
return
}
artworks = serializer.CalcPrice(artShowM.Price, artShowM.Ruler, artworks)
err, artworks = serializer.CalcReward(artworks, artShowM.Reward)
if err != nil {
return
@ -37,6 +37,7 @@ func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID u
tx.Rollback()
return
}
}
err = tx.Commit().Error
@ -57,23 +58,11 @@ func UpdateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID u
artworks = artworkPrices
} else {
artworks = serializer.BuildShowArtworkM(in.ShowArtwork, uint(in.ID))
for i := 0; i < len(artworks); i++ { // 查找 已存在 artwork_price 获取 ruler 信息
if artworks[i].Ruler == 0 {
err, artwork := dao.QueryArtworkPrice_id(artworks[i].ID)
if err != nil {
return err, 0
}
artworks[i].Ruler = artwork.Ruler
}
}
}
if len(artworks) > 0 {
if in.Price != 0 {
err, artworks = serializer.CalcPrice(artworks, artShowM.Ruler, artShowM.Price)
if err != nil {
return
}
artworks = serializer.CalcPrice(artShowM.Price, artShowM.Ruler, artworks)
}
if in.Reward != 0 {
err, artworks = serializer.CalcReward(artworks, artShowM.Reward)
@ -82,14 +71,18 @@ func UpdateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID u
}
}
// 更新画作价格
err, newIDs := dao.SaveArtworkPrice(tx, artworks)
err, _ := dao.SaveArtworkPrice(tx, artworks)
if err != nil {
tx.Rollback()
return err, 0
}
// 删除旧画作
_, del, _ := utils.BeUniqueSlice_uint(serializer.BuildArtworkPriceIDs(artworkPrices), newIDs)
if len(del) > 0 {
//_, del, _ := utils.BeUniqueSlice_uint(serializer.BuildArtworkPriceIDs(artworkPrices), newIDs)
if len(in.DelShowArtwork) > 0 {
del := make([]int64, 0)
for i := 0; i < len(in.DelShowArtwork); i++ {
del = append(del, in.DelShowArtwork[i].ID)
}
err = dao.DelArtworkPrice(tx, del)
if err != nil {
tx.Rollback()
@ -110,11 +103,27 @@ func UpdateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showID u
}
func DelArtShow(in *artShow.DelShowReq) (err error) {
err = dao.DelArtShow(in)
tx := db.DbArtShow.Begin()
for i := 0; i < len(in.ShowID); i++ {
queryShowRelErr, show_rel := dao.QueryShowRel_showId(in.ShowID[i])
if queryShowRelErr == nil && show_rel.ID == 0 {
delArtShowErr := dao.DelArtShow(tx, in.ShowID[i])
if err != nil {
return
tx.Rollback()
return delArtShowErr
}
delArtworkPriceErr := dao.DelArtworkPrice_showId(tx, in.ShowID[i])
if err != nil {
tx.Rollback()
return delArtworkPriceErr
}
} else if show_rel.ShowID != 0 {
tx.Rollback()
return errors.New("存在画展包被使用,无法删除")
}
}
// 暂不处理 画展包里的 画作
err = tx.Commit().Error
return
}
@ -125,7 +134,7 @@ func ArtShowList(in *artShow.ShowListReq) (err error, out *artShow.ShowListRes)
if err != nil {
return
}
err, out.TotalArtistNum, out.TotalPackageNum = dao.ShowStatistical(m.ARTSHOW_PASS)
err, out.TotalArtistNum, out.TotalPackageNum, _, _, _ = dao.ShowStatistical(m.ARTSHOW_PASS)
if err != nil {
return
}
@ -133,7 +142,7 @@ func ArtShowList(in *artShow.ShowListReq) (err error, out *artShow.ShowListRes)
return
}
func ShowInfo(in *artShow.ShowDetailReq) (err error, out *artShow.ShowArtworkDetailRes) {
func ShowArtworkInfo(in *artShow.ShowDetailReq) (err error, out *artShow.ShowArtworkDetailRes) {
out = new(artShow.ShowArtworkDetailRes)
artworkPriceS := make([]*model.ArtworkPrice, 0)
err, artworkPriceS = dao.ArtworkPriceList(uint(in.ShowID))
@ -144,11 +153,23 @@ func ShowInfo(in *artShow.ShowDetailReq) (err error, out *artShow.ShowArtworkDet
return
}
func ShowDetail(in *artShow.ShowDetailReq) (err error, out *artShow.ShowDetailRes) {
out = new(artShow.ShowDetailRes)
show := new(model.ArtShow)
err, show = dao.QueryArtShow(uint(in.ShowID))
if err != nil {
return
}
out.Data = serializer.BuildArtShowRpc(show)
fmt.Println(out.Data)
return
}
func ArtShowListWithApply(in *artShow.ShowListReq) (err error, out *artShow.ShowListRes) {
out = new(artShow.ShowListRes)
artShows := make([]*model.ArtShow, 0)
err, out.Total, artShows = dao.ArtShowListByApplyStatus(in)
err, out.TotalArtistNum, out.TotalPackageNum = dao.ShowStatistical(m.ARTSHOW_PASS)
err, out.TotalArtistNum, out.TotalPackageNum, _, _, _ = dao.ShowStatistical(m.ARTSHOW_PASS)
if err != nil {
return
}
@ -158,7 +179,7 @@ func ArtShowListWithApply(in *artShow.ShowListReq) (err error, out *artShow.Show
func ShowStatisticalInfo(in *artShow.ShowStatisticalInfoReq) (err error, out *artShow.ShowStatisticalInfoRes_Num) {
out = new(artShow.ShowStatisticalInfoRes_Num)
err, out.ArtistNum, out.PackageNum = dao.ShowStatistical(in.IsShow)
err, out.ArtistNum, out.PackageNum, out.TotalNum, out.NotShowNum, out.ShowHisNum = dao.ShowStatistical(in.IsShow)
if err != nil {
return
}

@ -4,8 +4,8 @@ import (
"fonchain-artshow/cmd/dao"
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/artShow"
"fonchain-artshow/pkg/m"
"fonchain-artshow/pkg/serializer"
"fonchain-artshow/pkg/utils"
"gorm.io/gorm"
)
@ -42,24 +42,39 @@ func UpdateShowApplyWithShowRel(in *artShow.SaveApplyReq) (err error, applyID ui
// 更新画展包申请关系
if len(in.Rel) > 0 {
err, oldShowRelS := dao.QueryShowRelList(showApply.ID) // 查找 旧 show_rel
// 保存 新 show_rel
newShowRelS := serializer.BuildShowRelM(in.Rel, showApply.ID)
err, _ := dao.SaveShowRels(tx, newShowRelS)
for i := 0; i < len(newShowRelS); i++ {
// 更新 画展包状态 为 已展
show := serializer.BuildArtShowIsShowM(newShowRelS[i].ShowID, m.ARTSHOW_SHOWING)
err := dao.SaveArtShow(tx, show)
if err != nil {
tx.Rollback()
return err, showApply.ID
}
}
newShowRelS := serializer.BuildShowRelM(in.Rel, showApply.ID)
err, newIds := dao.SaveShowRels(tx, newShowRelS) // 保存 新 show_rel
if len(in.DelRel) > 0 { // 如果 旧 show_rel 有数据 则 删除 旧记录(去除 保留下来的)
del := make([]int64, 0)
for i := 0; i < len(in.DelRel); i++ {
del = append(del, in.DelRel[i].ID)
if len(oldShowRelS) > 0 { // 如果 旧 show_rel 有数据 则 删除 旧记录(去除 保留下来的)
_, del, _ := utils.BeUniqueSlice_uint(serializer.BuildShowRelIDs(oldShowRelS), newIds)
if len(del) > 0 {
err = dao.DelShowRel(tx, del)
// 更新 画展包状态 为 可展
show := serializer.BuildArtShowIsShowM(newShowRelS[i].ShowID, m.ARTSHOW_PASS)
err := dao.SaveArtShow(tx, show)
if err != nil {
tx.Rollback()
return err, showApply.ID
}
}
err = dao.DelShowRel(tx, del)
if err != nil {
tx.Rollback()
return err, showApply.ID
}
}
}
err = tx.Commit().Error
@ -133,9 +148,9 @@ func DelApplyByApplyID(in *artShow.DelApplyReq) (err error) {
return
}
func QueryShowRel(showID uint) (err error, out *model.ShowRel) {
func QueryShowRel_showId(showID int64) (err error, out *model.ShowRel) {
out = new(model.ShowRel)
err, out = dao.QueryShowRel(showID)
err, out = dao.QueryShowRel_showId(showID)
if err != nil {
return err, nil
}

@ -1,14 +1,51 @@
[system]
mode = prod #正式prod #测试dev
;mode = prod #正式prod #测试dev
mode = dev #正式prod #测试dev
;本地测试
;[mysql]
;Db = mysql
;DbHost = 127.0.0.1
;DbPort = 3306
;DbUser = root
;DbPassWord = 123456
;DbName = art_show
;正式服
;[mysql]
;Db = mysql
;DbHost = mysql
;DbPort = 3306
;DbUser = root
;DbPassWord = sLl0b7stlbwvZ883TV
;DbName = art_show
;188
;[mysql]
;Db = mysql
;DbHost = 172.16.100.22
;DbPort = 9005
;DbUser = root
;DbPassWord = sLl0b7stlbwvZ883TV
;DbName = art_show
;214
[mysql]
Db = mysql
DbHost = 172.16.100.22
DbPort = 9005
DbUser = root
DbPassWord = sLl0b7stlbwvZ883TV
DbHost = 172.16.100.99 #214
DbPort = 9007
DbUser = artuser
DbPassWord = "C250PflXIWv2SQm8"
DbName = art_show
;[mysql]
;Db = mysql
;DbHost = 121.229.45.214 #214
;DbPort = 9007
;DbUser = artuser
;DbPassWord = "C250PflXIWv2SQm8"
;DbName = art_show
[redis]
RedisDB =
RedisAddr = 127.0.0.1:6379

@ -3,7 +3,8 @@ dubbo:
demoZK:
protocol: zookeeper
timeout: 3s
address: 172.16.100.22:2181
# address: zookeeper:2181
address: 127.0.0.1:2181
protocols:
triple: #triple
name: tri

File diff suppressed because it is too large Load Diff

@ -23,6 +23,13 @@ func (this *SaveShowReq) Validate() error {
}
}
}
for _, item := range this.DelShowArtwork {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("DelShowArtwork", err)
}
}
}
return nil
}
func (this *SaveShowRes) Validate() error {
@ -37,6 +44,14 @@ func (this *ShowDetailReq) Validate() error {
func (this *ShowDetail) Validate() error {
return nil
}
func (this *ShowDetailRes) Validate() error {
if this.Data != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
return nil
}
func (this *ShowArtworkDetailRes) Validate() error {
for _, item := range this.Data {
if item != nil {
@ -66,6 +81,9 @@ func (this *DelShowReq) Validate() error {
func (this *ShowArtworkDetail) Validate() error {
return nil
}
func (this *DelArtworkDetail) Validate() error {
return nil
}
func (this *ShowStatisticalInfoReq) Validate() error {
return nil
}
@ -97,6 +115,9 @@ func (this *ArtworkPriceRes_PriceInfo) Validate() error {
func (this *ShowRel) Validate() error {
return nil
}
func (this *DelShowRel) Validate() error {
return nil
}
func (this *SaveApplyReq) Validate() error {
for _, item := range this.Rel {
if item != nil {
@ -105,6 +126,13 @@ func (this *SaveApplyReq) Validate() error {
}
}
}
for _, item := range this.DelRel {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("DelRel", err)
}
}
}
return nil
}
func (this *SaveApplyRes) Validate() error {

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v3.21.4
// - protoc v3.10.1
// source: pb/artshow.proto
package artShow
@ -32,7 +32,8 @@ type ArtShowClient interface {
UpdateShow(ctx context.Context, in *SaveShowReq, opts ...grpc_go.CallOption) (*SaveShowRes, common.ErrorWithAttachment)
DelShow(ctx context.Context, in *DelShowReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment)
ShowList(ctx context.Context, in *ShowListReq, opts ...grpc_go.CallOption) (*ShowListRes, common.ErrorWithAttachment)
ShowInfo(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowArtworkDetailRes, common.ErrorWithAttachment)
ShowArtworkInfo(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowArtworkDetailRes, common.ErrorWithAttachment)
ShowDetail(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowDetailRes, common.ErrorWithAttachment)
ShowStatisticalInfo(ctx context.Context, in *ShowStatisticalInfoReq, opts ...grpc_go.CallOption) (*ShowStatisticalInfoRes, common.ErrorWithAttachment)
ArtworkPrice(ctx context.Context, in *ArtworkPriceReq, opts ...grpc_go.CallOption) (*ArtworkPriceRes, common.ErrorWithAttachment)
CreateApply(ctx context.Context, in *SaveApplyReq, opts ...grpc_go.CallOption) (*SaveApplyRes, common.ErrorWithAttachment)
@ -53,7 +54,8 @@ type ArtShowClientImpl struct {
UpdateShow func(ctx context.Context, in *SaveShowReq) (*SaveShowRes, error)
DelShow func(ctx context.Context, in *DelShowReq) (*CommonRes, error)
ShowList func(ctx context.Context, in *ShowListReq) (*ShowListRes, error)
ShowInfo func(ctx context.Context, in *ShowDetailReq) (*ShowArtworkDetailRes, error)
ShowArtworkInfo func(ctx context.Context, in *ShowDetailReq) (*ShowArtworkDetailRes, error)
ShowDetail func(ctx context.Context, in *ShowDetailReq) (*ShowDetailRes, error)
ShowStatisticalInfo func(ctx context.Context, in *ShowStatisticalInfoReq) (*ShowStatisticalInfoRes, error)
ArtworkPrice func(ctx context.Context, in *ArtworkPriceReq) (*ArtworkPriceRes, error)
CreateApply func(ctx context.Context, in *SaveApplyReq) (*SaveApplyRes, error)
@ -101,10 +103,16 @@ func (c *artShowClient) ShowList(ctx context.Context, in *ShowListReq, opts ...g
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowList", in, out)
}
func (c *artShowClient) ShowInfo(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowArtworkDetailRes, common.ErrorWithAttachment) {
func (c *artShowClient) ShowArtworkInfo(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowArtworkDetailRes, common.ErrorWithAttachment) {
out := new(ShowArtworkDetailRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowInfo", in, out)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowArtworkInfo", in, out)
}
func (c *artShowClient) ShowDetail(ctx context.Context, in *ShowDetailReq, opts ...grpc_go.CallOption) (*ShowDetailRes, common.ErrorWithAttachment) {
out := new(ShowDetailRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowDetail", in, out)
}
func (c *artShowClient) ShowStatisticalInfo(ctx context.Context, in *ShowStatisticalInfoReq, opts ...grpc_go.CallOption) (*ShowStatisticalInfoRes, common.ErrorWithAttachment) {
@ -169,7 +177,8 @@ type ArtShowServer interface {
UpdateShow(context.Context, *SaveShowReq) (*SaveShowRes, error)
DelShow(context.Context, *DelShowReq) (*CommonRes, error)
ShowList(context.Context, *ShowListReq) (*ShowListRes, error)
ShowInfo(context.Context, *ShowDetailReq) (*ShowArtworkDetailRes, error)
ShowArtworkInfo(context.Context, *ShowDetailReq) (*ShowArtworkDetailRes, error)
ShowDetail(context.Context, *ShowDetailReq) (*ShowDetailRes, error)
ShowStatisticalInfo(context.Context, *ShowStatisticalInfoReq) (*ShowStatisticalInfoRes, error)
ArtworkPrice(context.Context, *ArtworkPriceReq) (*ArtworkPriceRes, error)
CreateApply(context.Context, *SaveApplyReq) (*SaveApplyRes, error)
@ -199,8 +208,11 @@ func (UnimplementedArtShowServer) DelShow(context.Context, *DelShowReq) (*Common
func (UnimplementedArtShowServer) ShowList(context.Context, *ShowListReq) (*ShowListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowList not implemented")
}
func (UnimplementedArtShowServer) ShowInfo(context.Context, *ShowDetailReq) (*ShowArtworkDetailRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowInfo not implemented")
func (UnimplementedArtShowServer) ShowArtworkInfo(context.Context, *ShowDetailReq) (*ShowArtworkDetailRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowArtworkInfo not implemented")
}
func (UnimplementedArtShowServer) ShowDetail(context.Context, *ShowDetailReq) (*ShowDetailRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowDetail not implemented")
}
func (UnimplementedArtShowServer) ShowStatisticalInfo(context.Context, *ShowStatisticalInfoReq) (*ShowStatisticalInfoRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowStatisticalInfo not implemented")
@ -373,7 +385,7 @@ func _ArtShow_ShowList_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
func _ArtShow_ShowArtworkInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ShowDetailReq)
if err := dec(in); err != nil {
return nil, err
@ -386,7 +398,36 @@ func _ArtShow_ShowInfo_Handler(srv interface{}, ctx context.Context, dec func(in
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("ShowInfo", args, invAttachment)
invo := invocation.NewRPCInvocation("ShowArtworkInfo", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ShowDetailReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("ShowDetail", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
@ -687,8 +728,12 @@ var ArtShow_ServiceDesc = grpc_go.ServiceDesc{
Handler: _ArtShow_ShowList_Handler,
},
{
MethodName: "ShowInfo",
Handler: _ArtShow_ShowInfo_Handler,
MethodName: "ShowArtworkInfo",
Handler: _ArtShow_ShowArtworkInfo_Handler,
},
{
MethodName: "ShowDetail",
Handler: _ArtShow_ShowDetail_Handler,
},
{
MethodName: "ShowStatisticalInfo",

@ -8,7 +8,8 @@ service ArtShow {
rpc UpdateShow (SaveShowReq) returns (SaveShowRes) {} //
rpc DelShow (DelShowReq) returns (CommonRes) {} //
rpc ShowList (ShowListReq) returns (ShowListRes) {} //
rpc ShowInfo (ShowDetailReq) returns (ShowArtworkDetailRes) {} //
rpc ShowArtworkInfo (ShowDetailReq) returns (ShowArtworkDetailRes) {} //
rpc ShowDetail (ShowDetailReq) returns (ShowDetailRes) {} //
rpc ShowStatisticalInfo (ShowStatisticalInfoReq) returns (ShowStatisticalInfoRes) {} // ()
rpc ArtworkPrice (ArtworkPriceReq) returns (ArtworkPriceRes) {} //
rpc CreateApply (SaveApplyReq) returns (SaveApplyRes) {} //
@ -33,8 +34,9 @@ message SaveShowReq {
string ShowTime = 9 [json_name = "show_time"];
repeated ShowArtworkDetail ShowArtwork = 10 [json_name = "show_artwork"];
repeated DelArtworkDetail DelShowArtwork = 11 [json_name = "del_show_artwork"];
int64 ID = 11 [json_name = "id"];
int64 ID = 12 [json_name = "id"];
}
message SaveShowRes {
@ -65,6 +67,11 @@ message ShowDetail {
int32 IsShow = 11 [json_name = "is_show"];
}
message ShowDetailRes {
ShowDetail Data = 1 [json_name = "data"];
string Msg = 2 [json_name = "msg"];
}
message ShowArtworkDetailRes {
repeated ShowArtworkDetail data = 1 [json_name = "data"];
string Msg = 2 [json_name = "msg"];
@ -102,8 +109,16 @@ message ShowArtworkDetail {
int64 ArtworkID = 3 [json_name = "artwork_id"];
string ArtworkName = 4 [json_name = "artwork_name"];
string ArtistName = 5 [json_name = "artist_name"];
int32 Ruler = 6 [json_name = "ruler"];
string SmallPic = 7 [json_name = "small_pic"];
int32 Length = 6 [json_name = "length"];
int32 Width = 7 [json_name = "width"];
int32 Ruler = 8 [json_name = "ruler"];
string SmallPic = 9 [json_name = "small_pic"];
}
//
message DelArtworkDetail {
int64 ID = 1 [json_name = "id"];
int64 ArtworkID = 2 [json_name = "artwork_id"];
}
//
@ -115,6 +130,9 @@ message ShowStatisticalInfoRes {
message Num {
int64 ArtistNum = 1 [json_name = "artist_num"];
int64 PackageNum = 2 [json_name = "package_num"];
int64 TotalNum = 3 [json_name = "total_num"];
int64 NotShowNum = 4 [json_name = "not_show_num"];
int64 ShowHisNum = 5 [json_name = "show_his_num"];
}
Num Data = 1 [json_name = "data"];
@ -146,6 +164,11 @@ message ShowRel {
string Address = 5 [json_name = "address"];
}
message DelShowRel {
int64 ID = 1 [json_name = "id"];
int64 ShowID = 2 [json_name = "show_id"];
}
message SaveApplyReq {
string Applicant = 1 [json_name = "applicant"];
@ -157,6 +180,7 @@ message SaveApplyReq {
string Remark = 7 [json_name = "remark"];
repeated ShowRel Rel = 8 [json_name = "rel"];
repeated DelShowRel DelRel = 9 [json_name = "del_rel"];
}
message SaveApplyRes {

@ -0,0 +1,610 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.10.1
// source: pb/artshow.proto
package grpc
import (
context "context"
"fonchain-artshow/pb/artShow"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// ArtShowClient is the client API for ArtShow service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ArtShowClient interface {
CreateShow(ctx context.Context, in *artShow.SaveShowReq, opts ...grpc.CallOption) (*artShow.SaveShowRes, error)
UpdateShow(ctx context.Context, in *artShow.SaveShowReq, opts ...grpc.CallOption) (*artShow.SaveShowRes, error)
DelShow(ctx context.Context, in *artShow.DelShowReq, opts ...grpc.CallOption) (*artShow.CommonRes, error)
ShowList(ctx context.Context, in *artShow.ShowListReq, opts ...grpc.CallOption) (*artShow.ShowListRes, error)
ShowArtworkInfo(ctx context.Context, in *artShow.ShowDetailReq, opts ...grpc.CallOption) (*artShow.ShowArtworkDetailRes, error)
ShowDetail(ctx context.Context, in *artShow.ShowDetailReq, opts ...grpc.CallOption) (*artShow.ShowDetailRes, error)
ShowStatisticalInfo(ctx context.Context, in *artShow.ShowStatisticalInfoReq, opts ...grpc.CallOption) (*artShow.ShowStatisticalInfoRes, error)
ArtworkPrice(ctx context.Context, in *artShow.ArtworkPriceReq, opts ...grpc.CallOption) (*artShow.ArtworkPriceRes, error)
CreateApply(ctx context.Context, in *artShow.SaveApplyReq, opts ...grpc.CallOption) (*artShow.SaveApplyRes, error)
UpdateApply(ctx context.Context, in *artShow.SaveApplyReq, opts ...grpc.CallOption) (*artShow.SaveApplyRes, error)
DelApply(ctx context.Context, in *artShow.DelApplyReq, opts ...grpc.CallOption) (*artShow.CommonRes, error)
ShowListWithApply(ctx context.Context, in *artShow.ShowListReq, opts ...grpc.CallOption) (*artShow.ShowListRes, error)
UpdateApplyStatus(ctx context.Context, in *artShow.UpdateApplyStatusReq, opts ...grpc.CallOption) (*artShow.CommonRes, error)
ApplyList(ctx context.Context, in *artShow.ApplyListReq, opts ...grpc.CallOption) (*artShow.ApplyListRes, error)
ApplyDetail(ctx context.Context, in *artShow.ApplyShowReq, opts ...grpc.CallOption) (*artShow.ApplyShowRes, error)
}
type artShowClient struct {
cc grpc.ClientConnInterface
}
func NewArtShowClient(cc grpc.ClientConnInterface) ArtShowClient {
return &artShowClient{cc}
}
func (c *artShowClient) CreateShow(ctx context.Context, in *artShow.SaveShowReq, opts ...grpc.CallOption) (*artShow.SaveShowRes, error) {
out := new(artShow.SaveShowRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/CreateShow", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) UpdateShow(ctx context.Context, in *artShow.SaveShowReq, opts ...grpc.CallOption) (*artShow.SaveShowRes, error) {
out := new(artShow.SaveShowRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/UpdateShow", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) DelShow(ctx context.Context, in *artShow.DelShowReq, opts ...grpc.CallOption) (*artShow.CommonRes, error) {
out := new(artShow.CommonRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/DelShow", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ShowList(ctx context.Context, in *artShow.ShowListReq, opts ...grpc.CallOption) (*artShow.ShowListRes, error) {
out := new(artShow.ShowListRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ShowList", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ShowArtworkInfo(ctx context.Context, in *artShow.ShowDetailReq, opts ...grpc.CallOption) (*artShow.ShowArtworkDetailRes, error) {
out := new(artShow.ShowArtworkDetailRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ShowArtworkInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ShowDetail(ctx context.Context, in *artShow.ShowDetailReq, opts ...grpc.CallOption) (*artShow.ShowDetailRes, error) {
out := new(artShow.ShowDetailRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ShowDetail", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ShowStatisticalInfo(ctx context.Context, in *artShow.ShowStatisticalInfoReq, opts ...grpc.CallOption) (*artShow.ShowStatisticalInfoRes, error) {
out := new(artShow.ShowStatisticalInfoRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ShowStatisticalInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ArtworkPrice(ctx context.Context, in *artShow.ArtworkPriceReq, opts ...grpc.CallOption) (*artShow.ArtworkPriceRes, error) {
out := new(artShow.ArtworkPriceRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ArtworkPrice", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) CreateApply(ctx context.Context, in *artShow.SaveApplyReq, opts ...grpc.CallOption) (*artShow.SaveApplyRes, error) {
out := new(artShow.SaveApplyRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/CreateApply", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) UpdateApply(ctx context.Context, in *artShow.SaveApplyReq, opts ...grpc.CallOption) (*artShow.SaveApplyRes, error) {
out := new(artShow.SaveApplyRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/UpdateApply", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) DelApply(ctx context.Context, in *artShow.DelApplyReq, opts ...grpc.CallOption) (*artShow.CommonRes, error) {
out := new(artShow.CommonRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/DelApply", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ShowListWithApply(ctx context.Context, in *artShow.ShowListReq, opts ...grpc.CallOption) (*artShow.ShowListRes, error) {
out := new(artShow.ShowListRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ShowListWithApply", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) UpdateApplyStatus(ctx context.Context, in *artShow.UpdateApplyStatusReq, opts ...grpc.CallOption) (*artShow.CommonRes, error) {
out := new(artShow.CommonRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/UpdateApplyStatus", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ApplyList(ctx context.Context, in *artShow.ApplyListReq, opts ...grpc.CallOption) (*artShow.ApplyListRes, error) {
out := new(artShow.ApplyListRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ApplyList", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *artShowClient) ApplyDetail(ctx context.Context, in *artShow.ApplyShowReq, opts ...grpc.CallOption) (*artShow.ApplyShowRes, error) {
out := new(artShow.ApplyShowRes)
err := c.cc.Invoke(ctx, "/ArtShow.ArtShow/ApplyDetail", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ArtShowServer is the server API for ArtShow service.
// All implementations must embed UnimplementedArtShowServer
// for forward compatibility
type ArtShowServer interface {
CreateShow(context.Context, *artShow.SaveShowReq) (*artShow.SaveShowRes, error)
UpdateShow(context.Context, *artShow.SaveShowReq) (*artShow.SaveShowRes, error)
DelShow(context.Context, *artShow.DelShowReq) (*artShow.CommonRes, error)
ShowList(context.Context, *artShow.ShowListReq) (*artShow.ShowListRes, error)
ShowArtworkInfo(context.Context, *artShow.ShowDetailReq) (*artShow.ShowArtworkDetailRes, error)
ShowDetail(context.Context, *artShow.ShowDetailReq) (*artShow.ShowDetailRes, error)
ShowStatisticalInfo(context.Context, *artShow.ShowStatisticalInfoReq) (*artShow.ShowStatisticalInfoRes, error)
ArtworkPrice(context.Context, *artShow.ArtworkPriceReq) (*artShow.ArtworkPriceRes, error)
CreateApply(context.Context, *artShow.SaveApplyReq) (*artShow.SaveApplyRes, error)
UpdateApply(context.Context, *artShow.SaveApplyReq) (*artShow.SaveApplyRes, error)
DelApply(context.Context, *artShow.DelApplyReq) (*artShow.CommonRes, error)
ShowListWithApply(context.Context, *artShow.ShowListReq) (*artShow.ShowListRes, error)
UpdateApplyStatus(context.Context, *artShow.UpdateApplyStatusReq) (*artShow.CommonRes, error)
ApplyList(context.Context, *artShow.ApplyListReq) (*artShow.ApplyListRes, error)
ApplyDetail(context.Context, *artShow.ApplyShowReq) (*artShow.ApplyShowRes, error)
mustEmbedUnimplementedArtShowServer()
}
// UnimplementedArtShowServer must be embedded to have forward compatible implementations.
type UnimplementedArtShowServer struct {
}
func (UnimplementedArtShowServer) CreateShow(context.Context, *artShow.SaveShowReq) (*artShow.SaveShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateShow not implemented")
}
func (UnimplementedArtShowServer) UpdateShow(context.Context, *artShow.SaveShowReq) (*artShow.SaveShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateShow not implemented")
}
func (UnimplementedArtShowServer) DelShow(context.Context, *artShow.DelShowReq) (*artShow.CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method DelShow not implemented")
}
func (UnimplementedArtShowServer) ShowList(context.Context, *artShow.ShowListReq) (*artShow.ShowListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowList not implemented")
}
func (UnimplementedArtShowServer) ShowArtworkInfo(context.Context, *artShow.ShowDetailReq) (*artShow.ShowArtworkDetailRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowArtworkInfo not implemented")
}
func (UnimplementedArtShowServer) ShowDetail(context.Context, *artShow.ShowDetailReq) (*artShow.ShowDetailRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowDetail not implemented")
}
func (UnimplementedArtShowServer) ShowStatisticalInfo(context.Context, *artShow.ShowStatisticalInfoReq) (*artShow.ShowStatisticalInfoRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowStatisticalInfo not implemented")
}
func (UnimplementedArtShowServer) ArtworkPrice(context.Context, *artShow.ArtworkPriceReq) (*artShow.ArtworkPriceRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ArtworkPrice not implemented")
}
func (UnimplementedArtShowServer) CreateApply(context.Context, *artShow.SaveApplyReq) (*artShow.SaveApplyRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateApply not implemented")
}
func (UnimplementedArtShowServer) UpdateApply(context.Context, *artShow.SaveApplyReq) (*artShow.SaveApplyRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateApply not implemented")
}
func (UnimplementedArtShowServer) DelApply(context.Context, *artShow.DelApplyReq) (*artShow.CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method DelApply not implemented")
}
func (UnimplementedArtShowServer) ShowListWithApply(context.Context, *artShow.ShowListReq) (*artShow.ShowListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowListWithApply not implemented")
}
func (UnimplementedArtShowServer) UpdateApplyStatus(context.Context, *artShow.UpdateApplyStatusReq) (*artShow.CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateApplyStatus not implemented")
}
func (UnimplementedArtShowServer) ApplyList(context.Context, *artShow.ApplyListReq) (*artShow.ApplyListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ApplyList not implemented")
}
func (UnimplementedArtShowServer) ApplyDetail(context.Context, *artShow.ApplyShowReq) (*artShow.ApplyShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ApplyDetail not implemented")
}
func (UnimplementedArtShowServer) mustEmbedUnimplementedArtShowServer() {}
// UnsafeArtShowServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ArtShowServer will
// result in compilation errors.
type UnsafeArtShowServer interface {
mustEmbedUnimplementedArtShowServer()
}
func RegisterArtShowServer(s grpc.ServiceRegistrar, srv ArtShowServer) {
s.RegisterService(&ArtShow_ServiceDesc, srv)
}
func _ArtShow_CreateShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.SaveShowReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).CreateShow(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/CreateShow",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).CreateShow(ctx, req.(*artShow.SaveShowReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_UpdateShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.SaveShowReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).UpdateShow(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/UpdateShow",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).UpdateShow(ctx, req.(*artShow.SaveShowReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_DelShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.DelShowReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).DelShow(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/DelShow",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).DelShow(ctx, req.(*artShow.DelShowReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ShowListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ShowList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ShowList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ShowList(ctx, req.(*artShow.ShowListReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowArtworkInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ShowDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ShowArtworkInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ShowArtworkInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ShowArtworkInfo(ctx, req.(*artShow.ShowDetailReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ShowDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ShowDetail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ShowDetail",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ShowDetail(ctx, req.(*artShow.ShowDetailReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowStatisticalInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ShowStatisticalInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ShowStatisticalInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ShowStatisticalInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ShowStatisticalInfo(ctx, req.(*artShow.ShowStatisticalInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ArtworkPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ArtworkPriceReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ArtworkPrice(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ArtworkPrice",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ArtworkPrice(ctx, req.(*artShow.ArtworkPriceReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_CreateApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.SaveApplyReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).CreateApply(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/CreateApply",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).CreateApply(ctx, req.(*artShow.SaveApplyReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_UpdateApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.SaveApplyReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).UpdateApply(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/UpdateApply",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).UpdateApply(ctx, req.(*artShow.SaveApplyReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_DelApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.DelApplyReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).DelApply(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/DelApply",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).DelApply(ctx, req.(*artShow.DelApplyReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ShowListWithApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ShowListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ShowListWithApply(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ShowListWithApply",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ShowListWithApply(ctx, req.(*artShow.ShowListReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_UpdateApplyStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.UpdateApplyStatusReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).UpdateApplyStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/UpdateApplyStatus",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).UpdateApplyStatus(ctx, req.(*artShow.UpdateApplyStatusReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ApplyList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ApplyListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ApplyList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ApplyList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ApplyList(ctx, req.(*artShow.ApplyListReq))
}
return interceptor(ctx, in, info, handler)
}
func _ArtShow_ApplyDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(artShow.ApplyShowReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArtShowServer).ApplyDetail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ArtShow.ArtShow/ApplyDetail",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArtShowServer).ApplyDetail(ctx, req.(*artShow.ApplyShowReq))
}
return interceptor(ctx, in, info, handler)
}
// ArtShow_ServiceDesc is the grpc.ServiceDesc for ArtShow service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ArtShow_ServiceDesc = grpc.ServiceDesc{
ServiceName: "ArtShow.ArtShow",
HandlerType: (*ArtShowServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateShow",
Handler: _ArtShow_CreateShow_Handler,
},
{
MethodName: "UpdateShow",
Handler: _ArtShow_UpdateShow_Handler,
},
{
MethodName: "DelShow",
Handler: _ArtShow_DelShow_Handler,
},
{
MethodName: "ShowList",
Handler: _ArtShow_ShowList_Handler,
},
{
MethodName: "ShowArtworkInfo",
Handler: _ArtShow_ShowArtworkInfo_Handler,
},
{
MethodName: "ShowDetail",
Handler: _ArtShow_ShowDetail_Handler,
},
{
MethodName: "ShowStatisticalInfo",
Handler: _ArtShow_ShowStatisticalInfo_Handler,
},
{
MethodName: "ArtworkPrice",
Handler: _ArtShow_ArtworkPrice_Handler,
},
{
MethodName: "CreateApply",
Handler: _ArtShow_CreateApply_Handler,
},
{
MethodName: "UpdateApply",
Handler: _ArtShow_UpdateApply_Handler,
},
{
MethodName: "DelApply",
Handler: _ArtShow_DelApply_Handler,
},
{
MethodName: "ShowListWithApply",
Handler: _ArtShow_ShowListWithApply_Handler,
},
{
MethodName: "UpdateApplyStatus",
Handler: _ArtShow_UpdateApplyStatus_Handler,
},
{
MethodName: "ApplyList",
Handler: _ArtShow_ApplyList_Handler,
},
{
MethodName: "ApplyDetail",
Handler: _ArtShow_ApplyDetail_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pb/artshow.proto",
}

@ -47,6 +47,7 @@ func BuildArtShowRpc(artShowM *model.ArtShow) (out *artShow.ShowDetail) {
out.ShowSeq = artShowM.ShowSeq
out.ShowName = artShowM.ShowName
out.ArtistName = artShowM.ArtistName
out.ArtistID = artShowM.ArtistID
out.ArtworkNum = artShowM.ArtworkNum
out.Ruler = artShowM.Ruler
out.Price = artShowM.Price
@ -55,3 +56,10 @@ func BuildArtShowRpc(artShowM *model.ArtShow) (out *artShow.ShowDetail) {
out.IsShow = int32(artShowM.IsShow)
return
}
func BuildArtShowIsShowM(artShowIds uint, isShow int8) (out *model.ArtShow) {
out = new(model.ArtShow)
out.ID = artShowIds
out.IsShow = isShow
return
}

@ -14,6 +14,8 @@ func BuildShowArtworkM(in []*artShow.ShowArtworkDetail, showID uint) (out []*mod
artworkPrice.ArtistName = in[i].ArtistName
artworkPrice.SmallPic = in[i].SmallPic
artworkPrice.Ruler = in[i].Ruler
artworkPrice.Length = in[i].Length
artworkPrice.Width = in[i].Width
if in[i].ID != 0 {
artworkPrice.ID = uint(in[i].ID)
}
@ -31,12 +33,15 @@ func BuildShowArtworkRpc(in []*model.ArtworkPrice) (out []*artShow.ShowArtworkDe
out = make([]*artShow.ShowArtworkDetail, len(in))
for i := 0; i < len(in); i++ {
artworkPrice := new(artShow.ShowArtworkDetail)
artworkPrice.ID = int64(in[i].ID)
artworkPrice.ShowID = int64(in[i].ShowID)
artworkPrice.ArtworkID = in[i].ArtworkID
artworkPrice.ArtworkName = in[i].ArtworkName
artworkPrice.ArtistName = in[i].ArtistName
artworkPrice.SmallPic = in[i].SmallPic
artworkPrice.Ruler = in[i].Ruler
artworkPrice.Length = in[i].Length
artworkPrice.Width = in[i].Width
out[i] = artworkPrice
}
@ -61,3 +66,11 @@ func BuildArtworkPriceIDs(in []*model.ArtworkPrice) (out []uint) {
}
return
}
func BuildArtworkIDs(in []*model.ArtworkPrice) (out []int64) {
out = make([]int64, len(in))
for i := 0; i < len(in); i++ {
out[i] = in[i].ArtworkID
}
return
}

@ -2,69 +2,173 @@ package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pkg/utils"
"math"
)
func CalcPrice(artworks []*model.ArtworkPrice, ruler int32, totalPrice int64) (err error, save []*model.ArtworkPrice) {
if totalPrice == 0 || ruler == 0 {
return nil, artworks
func CalcPrice(total_price int64, total_ruler int32, artworksPrices []*model.ArtworkPrice) []*model.ArtworkPrice {
price := math.Floor(float64(total_price) / float64(total_ruler))
_, f := math.Modf(float64(total_price) / float64(total_ruler))
if f >= 0.5 {
price += 1
}
var (
current_total_price int64
current_artwork_price int64
current_copyright_price int64
add_total_balance int64
add_artwork_balance int64
add_copyright_balance int64
loss_total_price int64
loss_artwork_price int64
loss_copyright_price int64
)
for total_price-current_total_price != 0 {
current_total_price = calcTotalPrice(artworksPrices, add_total_balance, int64(price))
if current_total_price != 0 {
add_total_balance = total_price - current_total_price
}
if int(math.Abs(float64(add_total_balance))) < len(artworksPrices) {
loss_total_price = add_total_balance
break
}
}
maxId, dirId := findArtworkToAdd(artworksPrices, int64(price))
if dirId > 0 {
artworksPrices[dirId].Price = artworksPrices[dirId].Price + loss_total_price
} else {
artworksPrices[maxId].Price = artworksPrices[maxId].Price + loss_total_price
}
for int64(float64(total_price)*0.95)-current_artwork_price != 0 {
current_artwork_price = calcArtworkPrice(artworksPrices, add_artwork_balance)
if current_artwork_price != 0 {
add_artwork_balance = int64(float64(total_price)*0.95) - current_artwork_price
}
if int(math.Abs(float64(add_artwork_balance))) < len(artworksPrices) {
_, f := math.Modf(float64(total_price) * 0.95)
if f >= 0.5 {
add_artwork_balance += 1
}
loss_artwork_price = add_artwork_balance
break
}
}
if dirId > 0 {
artworksPrices[dirId].ArtworkPrice = artworksPrices[dirId].ArtworkPrice + loss_artwork_price
} else {
artworksPrices[maxId].ArtworkPrice = artworksPrices[maxId].ArtworkPrice + loss_artwork_price
}
for int64(float64(total_price)*0.05)-current_copyright_price != 0 {
current_copyright_price = calcCopyrightPrice(artworksPrices, add_copyright_balance)
if current_copyright_price != 0 {
add_copyright_balance = int64(float64(total_price)*0.05) - current_copyright_price
}
if int(math.Abs(float64(add_copyright_balance))) < len(artworksPrices) {
loss_copyright_price = add_copyright_balance
break
}
}
if dirId > 0 {
artworksPrices[dirId].CopyrightPrice = artworksPrices[dirId].CopyrightPrice + loss_copyright_price
} else {
artworksPrices[maxId].CopyrightPrice = artworksPrices[maxId].CopyrightPrice + loss_copyright_price
}
save = make([]*model.ArtworkPrice, 0)
return artworksPrices
}
func calcArtworkPrice(artworks []*model.ArtworkPrice, add_balance int64) int64 {
var (
needAddPriceArtworkIndex int
currentArtworkRuler int
currentTotalPrice int64
maxRulerIndex int
totalDiv float64
current_artwork_price int64
add_balance_single float64
)
if math.Abs(float64(add_balance)) > 0 {
add_balance_single = math.Floor(math.Abs(float64(add_balance)) / float64(len(artworks)))
if add_balance < 0 {
add_balance_single = 0 - add_balance_single
}
}
for i := 0; i < len(artworks); i++ {
artworks[i].ArtworkPrice = int64(math.Floor(float64(artworks[i].Price) * 0.95))
artworks[i].ArtworkPrice += int64(add_balance_single)
price := utils.FormatFloat(float64(totalPrice)/float64(ruler)/10, 2) * 10 // 用于计算的单价
//ruler_price := math.Floor(float64(total_price)/float64(ruler)/10) * 10 // 保存的单价
current_artwork_price += artworks[i].ArtworkPrice
}
return current_artwork_price
}
func calcCopyrightPrice(artworks []*model.ArtworkPrice, add_balance int64) int64 {
var (
current_copyright_price int64
add_balance_single float64
)
if math.Abs(float64(add_balance)) > 0 {
add_balance_single = math.Floor(math.Abs(float64(add_balance)) / float64(len(artworks)))
if add_balance < 0 {
add_balance_single = 0 - add_balance_single
}
}
for i := 0; i < len(artworks); i++ {
if currentArtworkRuler < int(artworks[i].Ruler) {
currentArtworkRuler = int(artworks[i].Ruler)
needAddPriceArtworkIndex = i
maxRulerIndex = i
} else if currentArtworkRuler == int(artworks[i].Ruler) {
currentArtworkRuler = 0
needAddPriceArtworkIndex = -1
artworks[i].CopyrightPrice = int64(math.Floor(float64(artworks[i].Price) * 0.05))
artworks[i].CopyrightPrice += int64(add_balance_single)
current_copyright_price += artworks[i].CopyrightPrice
}
return current_copyright_price
}
artworks[i].RulerPrice = int64(price)
artworks[i].Price = int64(price * float64(artworks[i].Ruler))
artworkPrice := float64(artworks[i].Price) * 0.95
artworkPrice, div1 := math.Modf(artworkPrice)
artworks[i].ArtworkPrice = int64(artworkPrice)
totalDiv += div1 // 小数点 省略掉的 0.5
copyrightPrice := artworks[i].Price - artworks[i].ArtworkPrice
artworks[i].CopyrightPrice = copyrightPrice
currentTotalPrice += artworks[i].Price
func calcTotalPrice(artworks []*model.ArtworkPrice, add_balance, price int64) int64 {
var (
current_total_price int64
add_balance_single float64
)
if math.Abs(float64(add_balance)) > 0 {
add_balance_single = math.Floor(math.Abs(float64(add_balance)) / float64(len(artworks)))
if add_balance < 0 {
add_balance_single = 0 - add_balance_single
}
}
for i := 0; i < len(artworks); i++ {
artworks[i].Price = int64(add_balance_single)
artworks[i].Price += int64(artworks[i].Ruler) * price
if needAddPriceArtworkIndex == -1 {
needAddPriceArtworkIndex = maxRulerIndex
current_total_price += artworks[i].Price
}
return current_total_price
}
artworks[needAddPriceArtworkIndex].RulerPrice = int64(price)
artworks[needAddPriceArtworkIndex].FloatPrice = totalPrice - currentTotalPrice - artworks[needAddPriceArtworkIndex].Price
artworks[needAddPriceArtworkIndex].Price = int64(float32(totalPrice) - float32(currentTotalPrice) + float32(artworks[needAddPriceArtworkIndex].Price))
artworks[needAddPriceArtworkIndex].ArtworkPrice = int64((float64(artworks[needAddPriceArtworkIndex].Price) * 0.95) + totalDiv)
artworks[needAddPriceArtworkIndex].CopyrightPrice = artworks[needAddPriceArtworkIndex].Price - artworks[needAddPriceArtworkIndex].ArtworkPrice
func findArtworkToAdd(artworks []*model.ArtworkPrice, ruler_price int64) (int, int) {
var (
current_ruler int
max_ruler int
maxIndex int
difIndex int
)
return nil, artworks
for i := 0; i < len(artworks); i++ {
if artworks[i].Ruler > int32(max_ruler) {
maxIndex = i
max_ruler = int(artworks[i].Ruler)
}
func CalcReward(artworks []*model.ArtworkPrice, reward int64) (err error, save []*model.ArtworkPrice) {
save = artworks
if reward == 0 {
return nil, artworks
if artworks[i].Ruler > int32(current_ruler) {
difIndex = i
current_ruler = int(artworks[i].Ruler)
} else if artworks[i].Ruler == int32(current_ruler) {
current_ruler = 0
difIndex = 0
}
for i := 0; i < len(artworks); i++ {
artworks[i].ArtistPrice = reward * int64(artworks[i].Ruler)
//artworks[i].ShowID = show_id
artworks[i].RulerPrice = ruler_price
}
return nil, save
return maxIndex, difIndex
}

@ -0,0 +1,70 @@
package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pkg/utils"
"math"
)
func _CalcPrice(artworks []*model.ArtworkPrice, ruler int32, totalPrice int64) (err error, save []*model.ArtworkPrice) {
if totalPrice == 0 || ruler == 0 {
return nil, artworks
}
save = make([]*model.ArtworkPrice, 0)
var (
needAddPriceArtworkIndex int
currentArtworkRuler int
currentTotalPrice int64
maxRulerIndex int
totalDiv float64
)
price := utils.FormatFloat(float64(totalPrice)/float64(ruler)/10, 2) * 10 // 用于计算的单价
//ruler_price := math.Floor(float64(total_price)/float64(ruler)/10) * 10 // 保存的单价
for i := 0; i < len(artworks); i++ {
if currentArtworkRuler < int(artworks[i].Ruler) {
currentArtworkRuler = int(artworks[i].Ruler)
needAddPriceArtworkIndex = i
maxRulerIndex = i
} else if currentArtworkRuler == int(artworks[i].Ruler) {
currentArtworkRuler = 0
needAddPriceArtworkIndex = -1
}
artworks[i].RulerPrice = int64(price)
artworks[i].Price = int64(price * float64(artworks[i].Ruler))
artworkPrice := float64(artworks[i].Price) * 0.95
artworkPrice, div1 := math.Modf(artworkPrice)
artworks[i].ArtworkPrice = int64(artworkPrice)
totalDiv += div1 // 小数点 省略掉的 0.5
copyrightPrice := artworks[i].Price - artworks[i].ArtworkPrice
artworks[i].CopyrightPrice = copyrightPrice
currentTotalPrice += artworks[i].Price
}
if needAddPriceArtworkIndex == -1 {
needAddPriceArtworkIndex = maxRulerIndex
}
artworks[needAddPriceArtworkIndex].RulerPrice = int64(price)
artworks[needAddPriceArtworkIndex].FloatPrice = totalPrice - currentTotalPrice - artworks[needAddPriceArtworkIndex].Price
artworks[needAddPriceArtworkIndex].Price = int64(float32(totalPrice) - float32(currentTotalPrice) + float32(artworks[needAddPriceArtworkIndex].Price))
artworks[needAddPriceArtworkIndex].ArtworkPrice = int64((float64(artworks[needAddPriceArtworkIndex].Price) * 0.95) + totalDiv)
artworks[needAddPriceArtworkIndex].CopyrightPrice = artworks[needAddPriceArtworkIndex].Price - artworks[needAddPriceArtworkIndex].ArtworkPrice
return nil, artworks
}
func CalcReward(artworks []*model.ArtworkPrice, reward int64) (err error, save []*model.ArtworkPrice) {
save = artworks
if reward == 0 {
return nil, artworks
}
for i := 0; i < len(artworks); i++ {
artworks[i].ArtistPrice = reward * int64(artworks[i].Ruler)
}
return nil, save
}
Loading…
Cancel
Save