first commit

This commit is contained in:
jhc 2022-09-21 14:30:52 +08:00
commit 3fd07b60fc
42 changed files with 11003 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/misc.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SwUserDefinedSpecifications">
<option name="specTypeByUrl">
<map />
</option>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/fonchain-artshow.iml" filepath="$PROJECT_DIR$/.idea/fonchain-artshow.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

40
cmd/app.go Normal file
View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"fonchain-artshow/cmd/controller"
"fonchain-artshow/pkg/db"
"fonchain-artshow/pkg/m"
"os"
)
func main() {
//注册服务
config.SetProviderService(&controller.ArtShowProvider{})
db.Init(m.SERVER_CONFIG)
os.Setenv("DUBBO_GO_CONFIG_PATH", m.DUBBOGO_CONFIG)
if err := config.Load(); err != nil {
panic(err)
}
//logger.ZapInit(m.SERVER_CONFIG)
select {}
}

153
cmd/controller/art_show.go Normal file
View File

@ -0,0 +1,153 @@
package controller
import (
"context"
"errors"
"fonchain-artshow/cmd/model"
"fonchain-artshow/cmd/service"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/m"
)
type ArtShowProvider struct {
test.UnimplementedArtShowServer
}
func (p *ArtShowProvider) CreateShow(ctx context.Context, req *test.SaveShowReq) (res *test.SaveShowRes, err error) {
if req.ShowName == "" {
err = errors.New(m.ERROR_SHOW_NAME)
return nil, err
}
if req.ShowTime == "" {
err = errors.New(m.ERROR_TIME)
return nil, err
}
res = new(test.SaveShowRes)
err, showID := service.CreateArtShowWithArtworkPrice(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_CREATE)
return res, err
}
res.Msg = m.CREATE_SUCCESS
res.ShowID = int64(showID)
return res, nil
}
func (p *ArtShowProvider) UpdateShow(ctx context.Context, req *test.SaveShowReq) (res *test.SaveShowRes, err error) {
if req.ID == 0 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.SaveShowRes)
if req.IsShow == m.ARTSHOW_INSIDE {
showRel := new(model.ShowRel)
err, showRel = service.QueryShowRel(uint(req.ID))
if err != nil {
return res, err
}
if showRel.ID > 0 {
err = errors.New(m.ERROR_NOT_UPDATE_ISSHOW)
return
}
}
err, showID := service.UpdateArtShowWithArtworkPrice(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.UPDATE_FAILED)
return
}
res.Msg = m.UPDATE_SUCCESS
res.ShowID = int64(showID)
return
}
func (p *ArtShowProvider) DelShow(ctx context.Context, req *test.DelShowReq) (res *test.CommonRes, err error) {
if len(req.ShowID) < 1 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
err = service.DelArtShow(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_DELETE)
return
}
res.Msg = m.DELETE_SUCCESS
return
}
func (p *ArtShowProvider) ShowList(ctx context.Context, req *test.ShowListReq) (res *test.ShowListRes, err error) {
if req.Page == 0 {
req.Page = 1
}
if req.PageSize == 0 {
req.Page = 10
}
res = new(test.ShowListRes)
err, res = service.ArtShowList(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) ShowInfo(ctx context.Context, req *test.ShowDetailReq) (res *test.ShowArtworkDetailRes, err error) {
err, res = service.ShowInfo(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) ShowStatisticalInfo(ctx context.Context, req *test.ShowStatisticalInfoReq) (res *test.ShowStatisticalInfoRes, err error) {
res = new(test.ShowStatisticalInfoRes)
err, num := service.ShowStatisticalInfo(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_Statistical_NUM)
return
}
res.Data = num
return
}
func (p *ArtShowProvider) ArtworkPrice(ctx context.Context, req *test.ArtworkPriceReq) (res *test.ArtworkPriceRes, err error) {
if req.ArtworkID == 0 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.ArtworkPriceRes)
err, res = service.ArtworkPriceInfo(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) ShowListWithApply(ctx context.Context, req *test.ShowListReq) (res *test.ShowListRes, err error) {
if req.Page == 0 {
req.Page = 1
}
if req.PageSize == 0 {
req.Page = 10
}
if req.IsShow == 0 {
req.IsShow = 2
}
res = new(test.ShowListRes)
err, res = service.ArtShowListWithApply(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}

View File

@ -0,0 +1,111 @@
package controller
import (
"context"
"errors"
"fonchain-artshow/cmd/service"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/m"
)
func (p *ArtShowProvider) CreateApply(ctx context.Context, req *test.SaveApplyReq) (res *test.SaveApplyRes, err error) {
if req.Applicant == "" {
err = errors.New(m.ERROR_APPLICANT)
return
}
if req.ApplyTime == "" {
err = errors.New(m.ERROR_TIME)
return
}
res = new(test.SaveApplyRes)
err, applyID := service.CreateShowApply(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_CREATE)
return
}
res.Msg = m.CREATE_SUCCESS
res.ApplyID = int64(applyID)
return
}
func (p *ArtShowProvider) UpdateApply(ctx context.Context, req *test.SaveApplyReq) (res *test.SaveApplyRes, err error) {
if req.ID == 0 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.SaveApplyRes)
err, showID := service.UpdateShowApplyWithShowRel(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.UPDATE_FAILED)
return
}
res.Msg = m.UPDATE_SUCCESS
res.ApplyID = int64(showID)
return
}
func (p *ArtShowProvider) ApplyList(ctx context.Context, req *test.ApplyListReq) (res *test.ApplyListRes, err error) {
res = new(test.ApplyListRes)
if req.Page == 0 {
req.Page = 1
}
if req.PageSize == 0 {
req.Page = 10
}
err, res.Total, res.Data = service.ShowApplyList(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) ApplyDetail(ctx context.Context, req *test.ApplyShowReq) (res *test.ApplyShowRes, err error) {
if req.ApplyID == 0 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.ApplyShowRes)
err, res = service.ShowApplyDetail(uint(req.ApplyID))
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_QUERY)
return
}
return
}
func (p *ArtShowProvider) DelApply(ctx context.Context, req *test.DelApplyReq) (res *test.CommonRes, err error) {
if len(req.ApplyID) < 1 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.CommonRes)
err = service.DelApplyByApplyID(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.ERROR_DELETE)
return
}
res.Msg = m.DELETE_SUCCESS
return
}
func (p *ArtShowProvider) UpdateApplyStatus(ctx context.Context, req *test.UpdateApplyStatusReq) (res *test.CommonRes, err error) {
if req.ApplyID == 0 {
err = errors.New(m.ERROR_INVALID_ID)
return
}
res = new(test.CommonRes)
err = service.UpdateShowApplyStatus(req)
if err != nil {
res.Msg = err.Error()
err = errors.New(m.UPDATE_FAILED)
return
}
res.Msg = m.UPDATE_SUCCESS
return
}

117
cmd/dao/art_show.go Normal file
View File

@ -0,0 +1,117 @@
package dao
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/db"
"go.uber.org/zap"
"gorm.io/gorm"
)
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
} else {
err = tx.Model(&model.ArtShow{}).Create(artShow).Error
}
if err != nil {
zap.L().Error("ArtShow err", zap.Error(err))
return
}
return
}
func ArtShowList(in *test.ShowListReq) (err error, total int64, out []*model.ArtShow) {
queryDB := db.DbArtShow.Model(&model.ArtShow{})
if in.ArtistID != "" {
queryDB = queryDB.Where("artist_id = ? ", in.ArtistID)
}
if in.StartTime != "" && in.EndTime != "" {
queryDB = queryDB.Where("convert(show_time, date) between ? and ?", in.StartTime, in.EndTime)
}
if in.IsShow != 0 {
queryDB = queryDB.Where("is_show = ?", in.IsShow)
}
err = queryDB.Count(&total).Error
if err != nil {
zap.L().Error("ArtShowList Count err", zap.Error(err))
return
}
out = make([]*model.ArtShow, 0)
err = queryDB.Offset(int((in.Page - 1) * in.PageSize)).
Limit(int(in.PageSize)).Find(&out).Error
if err != nil {
zap.L().Error("ArtShowList Find err", zap.Error(err))
return
}
return
}
func ArtShowList_apply(applyID uint) (err error, out []*model.ArtShow) {
out = make([]*model.ArtShow, 0)
err = db.DbArtShow.Table("art_show as a ").Joins(" left join show_rel as b on a.id = b.show_id").Where("b.apply_id = ? ", applyID).Find(&out).Error
if err != nil {
zap.L().Error("ArtShowList_apply Find err", zap.Error(err))
return
}
return
}
func ArtShowListByApplyStatus(in *test.ShowListReq) (err error, total int64, out []*model.ArtShow) {
out = make([]*model.ArtShow, 0)
tx := db.DbArtShow.Table("art_show as a")
tx.Joins(" left join show_rel as b on b.show_id = a.id").Where("a.is_show = ?", in.IsShow)
err = tx.Count(&total).Error
if err != nil {
zap.L().Error("ArtShowListByApplyStatus Count err", zap.Error(err))
return
}
err = tx.Offset(int((in.Page - 1) * in.PageSize)).
Limit(int(in.PageSize)).Find(&out).Error
if err != nil {
zap.L().Error("ArtShowListByApplyStatus Find err", zap.Error(err))
return
}
return
}
func DelArtShow(in *test.DelShowReq) (err error) {
err = db.DbArtShow.Where("id = ?", in.ShowID).Delete(&model.ArtShow{}).Error
if err != nil {
zap.L().Error("ArtShow delete err", zap.Error(err))
return
}
return
}
func QueryArtShow(id uint) (err error, out *model.ArtShow) {
err = db.DbArtShow.Model(&model.ArtShow{}).Where("id = ?", id).Find(&out).Error
if err != nil {
zap.L().Error("ArtShow Find err", zap.Error(err))
return
}
return
}
func ShowStatistical(isShow int32) (err error, artistNum int64, packageNum int64) {
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
}
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
}
return
}

55
cmd/dao/artwork_price.go Normal file
View File

@ -0,0 +1,55 @@
package dao
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pkg/db"
"go.uber.org/zap"
"gorm.io/gorm"
)
func SaveArtworkPrice(tx *gorm.DB, artworks []*model.ArtworkPrice) (err error, ids []uint) {
ids = make([]uint, 0) // 用于记录 更新的记录ID
for i := 0; i < len(artworks); i++ {
if artworks[i].ID != 0 {
err = tx.Model(&model.ArtworkPrice{}).Omit("id").Where("id = ?", artworks[i].ID).Updates(artworks[i]).Error
} else {
err = tx.Model(&model.ArtworkPrice{}).Create(&artworks[i]).Error
}
if err != nil {
zap.L().Error("Artwork price save err", zap.Error(err))
return
}
ids = append(ids, artworks[i].ID)
}
return
}
func ArtworkPriceList(showID uint) (err error, out []*model.ArtworkPrice) {
out = make([]*model.ArtworkPrice, 0)
err = db.DbArtShow.Model(&model.ArtworkPrice{}).Where("show_id = ? ", showID).Find(&out).Error
if err != nil {
zap.L().Error("Artwork list err", zap.Error(err))
return
}
return
}
func QueryArtworkPrice(artworkID int64) (err error, out *model.ArtworkPrice) {
out = new(model.ArtworkPrice)
err = db.DbArtShow.Model(&model.ArtworkPrice{}).Where("artwork_id = ? ", artworkID).Find(&out).Error
if err != nil {
zap.L().Error("Artwork price query err", zap.Error(err))
return
}
return
}
func DelArtworkPrice(tx *gorm.DB, ids []uint) (err error) {
err = tx.Where("id in (?)", ids).Delete(&model.ArtworkPrice{}, ids).Error
if err != nil {
zap.L().Error("Artwork delete err", zap.Error(err))
return
}
return
}

66
cmd/dao/show_apply.go Normal file
View File

@ -0,0 +1,66 @@
package dao
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/db"
"go.uber.org/zap"
"gorm.io/gorm"
)
func SaveShowApply(showApply *model.ShowApply) (tx *gorm.DB, err error) {
tx = db.DbArtShow.Begin()
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
}
if err != nil {
zap.L().Error("ShowApply err", zap.Error(err))
return
}
return
}
func ShowApplyList(in *test.ApplyListReq) (err error, total int64, out []*model.ShowApply) {
out = make([]*model.ShowApply, 0)
queryDB := db.DbArtShow.Model(&model.ShowApply{})
err = queryDB.Count(&total).Error
if err != nil {
zap.L().Error("ShowApplyList count err", zap.Error(err))
return
}
if in.PageSize != 0 {
queryDB = queryDB.Offset(int((in.Page - 1) * in.PageSize)).
Limit(int(in.PageSize))
}
err = queryDB.Find(&out).Error
if err != nil {
zap.L().Error("ShowApplyList err", zap.Error(err))
return
}
return
}
func ShowApplyDetail(applyID uint) (err error, out *model.ShowApply) {
out = new(model.ShowApply)
err = db.DbArtShow.Model(&model.ShowApply{}).Where("id = ?", applyID).Find(&out).Error
if err != nil {
zap.L().Error("ShowApplyDetail err", zap.Error(err))
return
}
return
}
func DelShowApply(in *test.DelApplyReq) (tx *gorm.DB, err error) {
tx = db.DbArtShow.Begin()
err = tx.Delete(&model.ShowApply{}, in.ApplyID).Error
if err != nil {
zap.L().Error("ShowApply delete err", zap.Error(err))
return
}
return
}

80
cmd/dao/show_rel.go Normal file
View File

@ -0,0 +1,80 @@
package dao
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pkg/db"
"go.uber.org/zap"
"gorm.io/gorm"
)
func SaveShowRels(tx *gorm.DB, showRels []*model.ShowRel) (err error, out []uint) {
out = make([]uint, 0)
for i := 0; i < len(showRels); i++ {
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
}
if err != nil {
zap.L().Error("ShowRels err", zap.Error(err))
return err, nil
}
out = append(out, showRels[i].ID)
}
return
}
func SaveShowRel(tx *gorm.DB, showRel *model.ShowRel) (err error) {
err = tx.Model(&model.ShowRel{}).Where("show_id = ?", showRel.ShowID).Updates(showRel).Error
if err != nil {
zap.L().Error("ShowRel err", zap.Error(err))
return err
}
return
}
func DelShowRel(tx *gorm.DB, ids []uint) (err error) {
err = tx.Where("id in (?)", ids).Delete(&model.ShowRel{}).Error
if err != nil {
zap.L().Error("ShowRel delete err", zap.Error(err))
return
}
return
}
func DelShowRelByApplyID(tx *gorm.DB, applyID uint) (err error) {
err = tx.Where("apply_id = ? ", applyID).Delete(&model.ShowRel{}).Error
if err != nil {
zap.L().Error("ShowRel by applyID delete err", zap.Error(err))
return
}
return
}
func QueryShowRel(showID uint) (err error, out *model.ShowRel) {
out = new(model.ShowRel)
findDB := db.DbArtShow.Model(&model.ShowRel{})
if showID != 0 {
findDB = findDB.Where("id = ? ", showID)
}
err = findDB.Find(&out).Error
if err != nil {
zap.L().Error("QueryShowRel err", zap.Error(err))
return
}
return
}
func QueryShowRelList(applyID uint) (err error, out []*model.ShowRel) {
out = make([]*model.ShowRel, 0)
findDB := db.DbArtShow.Model(&model.ShowRel{})
if applyID != 0 {
findDB = findDB.Where("apply_id = ? ", applyID)
}
err = findDB.Find(&out).Error
if err != nil {
zap.L().Error("QueryShowRelList err", zap.Error(err))
return
}
return
}

44
cmd/main.go Normal file
View File

@ -0,0 +1,44 @@
package main
import (
"fmt"
"fonchain-artshow/pb/test"
"google.golang.org/grpc"
//grpc_go "github.com/dubbogo/grpc-go"
"net"
"fonchain-artshow/cmd/controller"
"fonchain-artshow/pkg/db"
"fonchain-artshow/pkg/logger"
"fonchain-artshow/pkg/m"
)
type server struct {
test.UnimplementedArtShowServer
}
func main() {
l, err := net.Listen("tcp", ":8883")
if err != nil {
fmt.Printf("failed to listen: %v", err)
return
}
s := grpc.NewServer() // 创建gRPC服务器
test.RegisterArtShowServer(s, &controller.ArtShowProvider{}) // 在gRPC服务端注册服务
db.Init(m.SERVER_CONFIG)
//初始化zap
logger.ZapInit(m.SERVER_CONFIG)
//demo.InitLogger()
//defer demo.SugarLogger.Sync()
// 启动服务
err = s.Serve(l)
if err != nil {
fmt.Printf("failed to serve: %v", err)
return
}
}

18
cmd/model/art_show.go Normal file
View File

@ -0,0 +1,18 @@
package model
import "gorm.io/gorm"
type ArtShow struct {
gorm.Model
ShowSeq string `json:"show_seq" gorm:"show_seq"` // 画展包序列
ShowName string `json:"show_name" gorm:"show_name"` // 画展包名称
ArtistName string `json:"artist_name" gorm:"artist_name"` // 画家
ArtistID string `json:"artist_id" gorm:"artist_id"` // 画家ID
ArtworkNum int32 `json:"artwork_num" gorm:"artwork_num"` // 画作数量
Ruler int32 `json:"ruler" gorm:"ruler"` // 画作总平尺
Price int64 `json:"price" gorm:"price"` // 画展包价格
Reward int64 `json:"reward" gorm:"reward"` // 润格
ShowTime string `json:"show_time" gorm:"show_time"` // 画展时间
IsShow int8 `json:"is_show" gorm:"is_show"` // 是否出展 1,内部(default) 2,可展 3,已展
}

View File

@ -0,0 +1,21 @@
package model
import "gorm.io/gorm"
type ArtworkPrice struct {
gorm.Model
ShowID uint `json:"show_id" gorm:"show_id"` // 画展ID
ArtworkID int64 `json:"artwork_id" gorm:"artwork_id"` // 画作ID
ArtworkName string `json:"artwork_name" gorm:"artwork_name"` // 画作名称
ArtistName string `json:"artist_name" gorm:"artist_name"` // 画家名称
SmallPic string `json:"small_pic" gorm:"small_pic"` // 画作小图
Price int64 `json:"price" gorm:"price"` // 总价
RulerPrice int64 `json:"ruler_price" gorm:"ruler_price"` // 平尺价
Ruler int32 `json:"ruler" gorm:"ruler"` // 画作平尺
ArtworkPrice int64 `json:"artwork_price" gorm:"artwork_price"` // 画作价格
MarketPrice int64 `json:"market_price" gorm:"market_price"` // 市场价
CopyrightPrice int64 `json:"copyright_price" gorm:"copyright_price"` // 版权价格
ArtistPrice int64 `json:"artist_price" gorm:"artist_price"` // 画家价格 (润格 * 平尺)
FloatPrice int64 `json:"float_price" gorm:"float_price"` // 浮动价格
}

17
cmd/model/show_apply.go Normal file
View File

@ -0,0 +1,17 @@
package model
import (
"gorm.io/gorm"
)
type ShowApply struct {
gorm.Model
ApplySeq string `json:"apply_seq" gorm:"apply_seq"` // 画展包申请序列号
Applicant string `json:"applicant" gorm:"applicant"` // 申请人
ApplicantID uint `json:"applicant_id" gorm:"applicant_id"` // 申请人
Num int32 `json:"num" gorm:"num"` // 申请画展包数量
ApplyTime string `json:"apply_time" gorm:"apply_time"` // 申请时间
Status int `json:"status" gorm:"status"` // 申请画展包状态 10,创建 11,数量审批 12,数量审批驳回 13,关联画展包 14,画展包关联审批 15,关联审批驳回 16,可展
Remark string `json:"remark" gorm:"remark"` // 备注
}

16
cmd/model/show_rel.go Normal file
View File

@ -0,0 +1,16 @@
package model
import "gorm.io/gorm"
type ShowRel struct {
gorm.Model
//ShowSeq string `json:"show_seq" gorm:"show_seq"` // 画展包序列
ShowID uint `json:"show_id" gorm:"show_id"` // 画展包ID
//ApplySeq string `json:"apply_seq" gorm:"apply_seq"` // 申请序列
ApplyID uint `json:"apply_id" gorm:"apply_id"` // 申请ID
Index int32 `json:"index" gorm:"index"` // 申请下标
Address string `json:"address" gorm:"address"` // 参展地址
//Status int32 `json:"status" gorm:"status"` // 参展状态 1、待展 2、驳回 3、可展
//Remark string `json:"remark" gorm:"remark"` // 备注
}

159
cmd/service/art_show.go Normal file
View File

@ -0,0 +1,159 @@
package service
import (
"fonchain-artshow/cmd/dao"
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/db"
"fonchain-artshow/pkg/m"
"fonchain-artshow/pkg/serializer"
"fonchain-artshow/pkg/utils"
)
func CreateArtShowWithArtworkPrice(in *test.SaveShowReq) (err error, showID uint) {
artShowM := serializer.BuildArtShowM(in)
tx := db.DbArtShow.Begin()
err = dao.SaveArtShow(tx, artShowM)
if err != nil {
tx.Rollback()
return
}
artworks := serializer.BuildShowArtworkM(in.ShowArtwork, artShowM.ID)
err, artworks = serializer.CalcPrice(artworks, artShowM.Ruler, artShowM.Price)
if err != nil {
return
}
err, artworks = serializer.CalcReward(artworks, artShowM.Reward)
if err != nil {
return
}
err, _ = dao.SaveArtworkPrice(tx, artworks)
if err != nil {
tx.Rollback()
return
}
err = tx.Commit().Error
return err, artShowM.ID
}
func UpdateArtShowWithArtworkPrice(in *test.SaveShowReq) (err error, showID uint) {
err, artShowExist := dao.QueryArtShow(uint(in.ID))
if err != nil {
return
}
err, artworkPrices := dao.ArtworkPriceList(artShowExist.ID)
if err != nil {
return
}
tx := db.DbArtShow.Begin()
artShowM := serializer.BuildArtShowM(in) // 构建画展包数据
artworks := make([]*model.ArtworkPrice, 0)
if len(in.ShowArtwork) < 1 && (in.Price != 0 || in.Reward != 0) {
artworks = artworkPrices
} else {
artworks = serializer.BuildShowArtworkM(in.ShowArtwork, uint(in.ID))
}
if len(artworks) > 0 {
if in.Price != 0 {
err, artworks = serializer.CalcPrice(artworks, artShowM.Ruler, artShowM.Price)
if err != nil {
return
}
}
if in.Reward != 0 {
err, artworks = serializer.CalcReward(artworks, artShowM.Reward)
if err != nil {
return
}
}
// 更新画作价格
err, newIDs := dao.SaveArtworkPrice(tx, artworks)
if err != nil {
tx.Rollback()
return err, 0
}
// 删除旧画作
_, del, _ := utils.BeUniqueSlice_uint(serializer.BuildArtworkPriceIDs(artworkPrices), newIDs)
if len(del) > 0 {
err = dao.DelArtworkPrice(tx, del)
if err != nil {
tx.Rollback()
return err, 0
}
}
}
// 更新画展包
err = dao.SaveArtShow(tx, artShowM)
if err != nil {
tx.Rollback()
return
}
err = tx.Commit().Error
return err, artShowM.ID
}
func DelArtShow(in *test.DelShowReq) (err error) {
err = dao.DelArtShow(in)
if err != nil {
return
}
// 暂不处理 画展包里的 画作
return
}
func ArtShowList(in *test.ShowListReq) (err error, out *test.ShowListRes) {
out = new(test.ShowListRes)
artShows := make([]*model.ArtShow, 0)
err, out.Total, artShows = dao.ArtShowList(in)
if err != nil {
return
}
err, out.TotalArtistNum, out.TotalPackageNum = dao.ShowStatistical(m.ARTSHOW_PASS)
if err != nil {
return
}
out.Data = serializer.BuildArtShowListRes(artShows)
return
}
func ShowInfo(in *test.ShowDetailReq) (err error, out *test.ShowArtworkDetailRes) {
out = new(test.ShowArtworkDetailRes)
artworkPriceS := make([]*model.ArtworkPrice, 0)
err, artworkPriceS = dao.ArtworkPriceList(uint(in.ShowID))
if err != nil {
return
}
out.Data = serializer.BuildShowArtworkRpc(artworkPriceS)
return
}
func ArtShowListWithApply(in *test.ShowListReq) (err error, out *test.ShowListRes) {
out = new(test.ShowListRes)
artShows := make([]*model.ArtShow, 0)
err, out.Total, artShows = dao.ArtShowListByApplyStatus(in)
err, out.TotalArtistNum, out.TotalPackageNum = dao.ShowStatistical(m.ARTSHOW_PASS)
if err != nil {
return
}
out.Data = serializer.BuildArtShowListRes(artShows)
return
}
func ShowStatisticalInfo(in *test.ShowStatisticalInfoReq) (err error, out *test.ShowStatisticalInfoRes_Num) {
out = new(test.ShowStatisticalInfoRes_Num)
err, out.ArtistNum, out.PackageNum = dao.ShowStatistical(in.IsShow)
if err != nil {
return
}
return
}

143
cmd/service/show_apply.go Normal file
View File

@ -0,0 +1,143 @@
package service
import (
"fonchain-artshow/cmd/dao"
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/serializer"
"fonchain-artshow/pkg/utils"
"gorm.io/gorm"
)
func CreateShowApply(in *test.SaveApplyReq) (err error, applyID uint) {
showApply := serializer.BuildShowApply(in)
tx, err := dao.SaveShowApply(showApply)
if err != nil {
tx.Rollback()
return
}
err = tx.Commit().Error
// 申请画展包时,暂时不携带画展包信息
/* showRels := serializer.BuildShowRel(in.Rel, showApply.ID)
err = dao.SaveShowRels(tx, showRels)
if err != nil {
tx.Rollback()
return
}
err = tx.Commit().Error*/
return err, showApply.ID
}
func UpdateShowApplyWithShowRel(in *test.SaveApplyReq) (err error, applyID uint) {
// 更新画展包申请
showApply := serializer.BuildShowApply(in)
tx, err := dao.SaveShowApply(showApply)
if err != nil {
tx.Rollback()
return
}
// 更新画展包申请关系
if len(in.Rel) > 0 {
err, oldShowRelS := dao.QueryShowRelList(showApply.ID) // 查找 旧 show_rel
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(oldShowRelS) > 0 { // 如果 旧 show_rel 有数据 则 删除 旧记录(去除 保留下来的)
_, del, _ := utils.BeUniqueSlice_uint(serializer.BuildShowRelIDs(oldShowRelS), newIds)
if len(del) > 0 {
err = dao.DelShowRel(tx, del)
if err != nil {
tx.Rollback()
return err, showApply.ID
}
}
}
}
err = tx.Commit().Error
return err, showApply.ID
}
func UpdateShowApplyStatus(in *test.UpdateApplyStatusReq) (err error) {
// 更新画展包申请 状态
showApply := &model.ShowApply{
Model: gorm.Model{ID: uint(in.ApplyID)},
Status: int(in.Status),
Remark: in.Remark,
}
tx, err := dao.SaveShowApply(showApply)
if err != nil {
tx.Rollback()
return
}
err = tx.Commit().Error
return
}
func ShowApplyList(in *test.ApplyListReq) (err error, total int64, out []*test.ApplyDetail) {
out = make([]*test.ApplyDetail, 0)
err, total, applyList := dao.ShowApplyList(in)
if err != nil {
return
}
if len(applyList) > 0 {
for i := 0; i < len(applyList); i++ {
showApply := serializer.BuildShowApplyRes(applyList[i])
out = append(out, showApply)
}
}
return
}
func ShowApplyDetail(applyID uint) (err error, out *test.ApplyShowRes) {
out = new(test.ApplyShowRes)
err, showApply := dao.ShowApplyDetail(applyID)
if err != nil {
return
}
out.Apply = serializer.BuildShowApplyRes(showApply)
err, artShow := dao.ArtShowList_apply(applyID)
if err != nil {
return
}
out.Show = serializer.BuildArtShowListRes(artShow)
return
}
func DelApplyByApplyID(in *test.DelApplyReq) (err error) {
tx, err := dao.DelShowApply(in)
if err != nil {
tx.Rollback()
return
}
for i := 0; i < len(in.ApplyID); i++ {
err = dao.DelShowRelByApplyID(tx, uint(in.ApplyID[i]))
if err != nil {
tx.Rollback()
return
}
}
err = tx.Commit().Error
return
}
func QueryShowRel(showID uint) (err error, out *model.ShowRel) {
out = new(model.ShowRel)
err, out = dao.QueryShowRel(showID)
if err != nil {
return err, nil
}
return
}

16
cmd/service/show_price.go Normal file
View File

@ -0,0 +1,16 @@
package service
import (
"fonchain-artshow/cmd/dao"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/serializer"
)
func ArtworkPriceInfo(in *test.ArtworkPriceReq) (err error, artworkPriceRes *test.ArtworkPriceRes) {
err, artworkPrice := dao.QueryArtworkPrice(in.ArtworkID)
if err != nil {
return
}
artworkPriceRes = serializer.BuildArtworkPriceRes(artworkPrice)
return
}

23
conf/conf.ini Normal file
View File

@ -0,0 +1,23 @@
[system]
mode = dev #正式prod #测试dev
[mysql]
Db = mysql
DbHost = 127.0.0.1
DbPort = 3306
DbUser = root
DbPassWord = 123456
DbName = art_show
[redis]
RedisDB =
RedisAddr = 127.0.0.1:6379
RedisPW =
RedisDBNAme =
[zap_log]
level: "info"
filename: "./runtime/log/artwork_server.log"
max_size: 200
max_age: 30
max_backups: 7

14
conf/dubbogo.yaml Normal file
View File

@ -0,0 +1,14 @@
dubbo:
registries:
demoZK:
protocol: zookeeper
timeout: 3s
address: 127.0.0.1:2181
protocols:
triple: #triple
name: tri
port: 20000
provider:
services:
ArtShowProvider:
interface: com.fontree.microservices.common.ArtShow

145
go.mod Normal file
View File

@ -0,0 +1,145 @@
module fonchain-artshow
go 1.18
replace github.com/fonchain_enterprise/utils/aes => ../utils/aes
require (
dubbo.apache.org/dubbo-go/v3 v3.0.2
github.com/dubbogo/grpc-go v1.42.10
github.com/dubbogo/triple v1.1.8
github.com/fonchain_enterprise/utils/aes v0.0.0-00010101000000-000000000000
github.com/gin-gonic/gin v1.8.1
github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/spf13/cast v1.3.0
go.uber.org/zap v1.21.0
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.1
gopkg.in/ini.v1 v1.51.0
gorm.io/driver/mysql v1.3.6
gorm.io/gorm v1.23.8
)
require (
cloud.google.com/go v0.65.0 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect
github.com/RoaringBitmap/roaring v1.1.0 // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/Workiva/go-datastructures v1.0.52 // indirect
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 // indirect
github.com/alibaba/sentinel-golang v1.0.4 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 // indirect
github.com/apache/dubbo-getty v1.4.8 // indirect
github.com/apache/dubbo-go-hessian2 v1.11.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/creasty/defaults v1.5.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 // indirect
github.com/dubbogo/gost v1.11.25 // indirect
github.com/emicklei/go-restful/v3 v3.7.4 // indirect
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-co-op/gocron v1.9.0 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-kit/log v0.1.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.5.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/sdk v0.3.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k0kubun/pp v3.0.1+incompatible // indirect
github.com/knadh/koanf v1.4.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/nacos-group/nacos-sdk-go v1.1.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/polarismesh/polaris-go v1.1.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/statsd_exporter v0.21.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.6 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/uber/jaeger-client-go v2.29.1+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/zouyx/agollo/v3 v3.4.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect
go.etcd.io/etcd/client/v3 v3.5.4 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20211104193956-4c6863e31247 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

1273
go.sum Normal file

File diff suppressed because it is too large Load Diff

2633
pb/artShow/artshow.pb.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,732 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v3.10.1
// source: pb/artshow.proto
package artShow
import (
context "context"
protocol "dubbo.apache.org/dubbo-go/v3/protocol"
dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
grpc_go "github.com/dubbogo/grpc-go"
codes "github.com/dubbogo/grpc-go/codes"
metadata "github.com/dubbogo/grpc-go/metadata"
status "github.com/dubbogo/grpc-go/status"
common "github.com/dubbogo/triple/pkg/common"
constant "github.com/dubbogo/triple/pkg/common/constant"
triple "github.com/dubbogo/triple/pkg/triple"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc_go.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 *SaveShowReq, opts ...grpc_go.CallOption) (*SaveShowRes, common.ErrorWithAttachment)
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)
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)
UpdateApply(ctx context.Context, in *SaveApplyReq, opts ...grpc_go.CallOption) (*SaveApplyRes, common.ErrorWithAttachment)
DelApply(ctx context.Context, in *DelApplyReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment)
ShowListWithApply(ctx context.Context, in *ShowListReq, opts ...grpc_go.CallOption) (*ShowListRes, common.ErrorWithAttachment)
UpdateApplyStatus(ctx context.Context, in *UpdateApplyStatusReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment)
ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc_go.CallOption) (*ApplyListRes, common.ErrorWithAttachment)
ApplyDetail(ctx context.Context, in *ApplyShowReq, opts ...grpc_go.CallOption) (*ApplyShowRes, common.ErrorWithAttachment)
}
type artShowClient struct {
cc *triple.TripleConn
}
type ArtShowClientImpl struct {
CreateShow func(ctx context.Context, in *SaveShowReq) (*SaveShowRes, error)
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)
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)
UpdateApply func(ctx context.Context, in *SaveApplyReq) (*SaveApplyRes, error)
DelApply func(ctx context.Context, in *DelApplyReq) (*CommonRes, error)
ShowListWithApply func(ctx context.Context, in *ShowListReq) (*ShowListRes, error)
UpdateApplyStatus func(ctx context.Context, in *UpdateApplyStatusReq) (*CommonRes, error)
ApplyList func(ctx context.Context, in *ApplyListReq) (*ApplyListRes, error)
ApplyDetail func(ctx context.Context, in *ApplyShowReq) (*ApplyShowRes, error)
}
func (c *ArtShowClientImpl) GetDubboStub(cc *triple.TripleConn) ArtShowClient {
return NewArtShowClient(cc)
}
func (c *ArtShowClientImpl) XXX_InterfaceName() string {
return "ArtShow.ArtShow"
}
func NewArtShowClient(cc *triple.TripleConn) ArtShowClient {
return &artShowClient{cc}
}
func (c *artShowClient) CreateShow(ctx context.Context, in *SaveShowReq, opts ...grpc_go.CallOption) (*SaveShowRes, common.ErrorWithAttachment) {
out := new(SaveShowRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateShow", in, out)
}
func (c *artShowClient) UpdateShow(ctx context.Context, in *SaveShowReq, opts ...grpc_go.CallOption) (*SaveShowRes, common.ErrorWithAttachment) {
out := new(SaveShowRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateShow", in, out)
}
func (c *artShowClient) DelShow(ctx context.Context, in *DelShowReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment) {
out := new(CommonRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DelShow", in, out)
}
func (c *artShowClient) ShowList(ctx context.Context, in *ShowListReq, opts ...grpc_go.CallOption) (*ShowListRes, common.ErrorWithAttachment) {
out := new(ShowListRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
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) {
out := new(ShowArtworkDetailRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowInfo", in, out)
}
func (c *artShowClient) ShowStatisticalInfo(ctx context.Context, in *ShowStatisticalInfoReq, opts ...grpc_go.CallOption) (*ShowStatisticalInfoRes, common.ErrorWithAttachment) {
out := new(ShowStatisticalInfoRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowStatisticalInfo", in, out)
}
func (c *artShowClient) ArtworkPrice(ctx context.Context, in *ArtworkPriceReq, opts ...grpc_go.CallOption) (*ArtworkPriceRes, common.ErrorWithAttachment) {
out := new(ArtworkPriceRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ArtworkPrice", in, out)
}
func (c *artShowClient) CreateApply(ctx context.Context, in *SaveApplyReq, opts ...grpc_go.CallOption) (*SaveApplyRes, common.ErrorWithAttachment) {
out := new(SaveApplyRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateApply", in, out)
}
func (c *artShowClient) UpdateApply(ctx context.Context, in *SaveApplyReq, opts ...grpc_go.CallOption) (*SaveApplyRes, common.ErrorWithAttachment) {
out := new(SaveApplyRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateApply", in, out)
}
func (c *artShowClient) DelApply(ctx context.Context, in *DelApplyReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment) {
out := new(CommonRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DelApply", in, out)
}
func (c *artShowClient) ShowListWithApply(ctx context.Context, in *ShowListReq, opts ...grpc_go.CallOption) (*ShowListRes, common.ErrorWithAttachment) {
out := new(ShowListRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ShowListWithApply", in, out)
}
func (c *artShowClient) UpdateApplyStatus(ctx context.Context, in *UpdateApplyStatusReq, opts ...grpc_go.CallOption) (*CommonRes, common.ErrorWithAttachment) {
out := new(CommonRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateApplyStatus", in, out)
}
func (c *artShowClient) ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc_go.CallOption) (*ApplyListRes, common.ErrorWithAttachment) {
out := new(ApplyListRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ApplyList", in, out)
}
func (c *artShowClient) ApplyDetail(ctx context.Context, in *ApplyShowReq, opts ...grpc_go.CallOption) (*ApplyShowRes, common.ErrorWithAttachment) {
out := new(ApplyShowRes)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ApplyDetail", in, out)
}
// ArtShowServer is the server API for ArtShow service.
// All implementations must embed UnimplementedArtShowServer
// for forward compatibility
type ArtShowServer interface {
CreateShow(context.Context, *SaveShowReq) (*SaveShowRes, error)
UpdateShow(context.Context, *SaveShowReq) (*SaveShowRes, error)
DelShow(context.Context, *DelShowReq) (*CommonRes, error)
ShowList(context.Context, *ShowListReq) (*ShowListRes, error)
ShowInfo(context.Context, *ShowDetailReq) (*ShowArtworkDetailRes, error)
ShowStatisticalInfo(context.Context, *ShowStatisticalInfoReq) (*ShowStatisticalInfoRes, error)
ArtworkPrice(context.Context, *ArtworkPriceReq) (*ArtworkPriceRes, error)
CreateApply(context.Context, *SaveApplyReq) (*SaveApplyRes, error)
UpdateApply(context.Context, *SaveApplyReq) (*SaveApplyRes, error)
DelApply(context.Context, *DelApplyReq) (*CommonRes, error)
ShowListWithApply(context.Context, *ShowListReq) (*ShowListRes, error)
UpdateApplyStatus(context.Context, *UpdateApplyStatusReq) (*CommonRes, error)
ApplyList(context.Context, *ApplyListReq) (*ApplyListRes, error)
ApplyDetail(context.Context, *ApplyShowReq) (*ApplyShowRes, error)
mustEmbedUnimplementedArtShowServer()
}
// UnimplementedArtShowServer must be embedded to have forward compatible implementations.
type UnimplementedArtShowServer struct {
proxyImpl protocol.Invoker
}
func (UnimplementedArtShowServer) CreateShow(context.Context, *SaveShowReq) (*SaveShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateShow not implemented")
}
func (UnimplementedArtShowServer) UpdateShow(context.Context, *SaveShowReq) (*SaveShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateShow not implemented")
}
func (UnimplementedArtShowServer) DelShow(context.Context, *DelShowReq) (*CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method DelShow not implemented")
}
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) ShowStatisticalInfo(context.Context, *ShowStatisticalInfoReq) (*ShowStatisticalInfoRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowStatisticalInfo not implemented")
}
func (UnimplementedArtShowServer) ArtworkPrice(context.Context, *ArtworkPriceReq) (*ArtworkPriceRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ArtworkPrice not implemented")
}
func (UnimplementedArtShowServer) CreateApply(context.Context, *SaveApplyReq) (*SaveApplyRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateApply not implemented")
}
func (UnimplementedArtShowServer) UpdateApply(context.Context, *SaveApplyReq) (*SaveApplyRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateApply not implemented")
}
func (UnimplementedArtShowServer) DelApply(context.Context, *DelApplyReq) (*CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method DelApply not implemented")
}
func (UnimplementedArtShowServer) ShowListWithApply(context.Context, *ShowListReq) (*ShowListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowListWithApply not implemented")
}
func (UnimplementedArtShowServer) UpdateApplyStatus(context.Context, *UpdateApplyStatusReq) (*CommonRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateApplyStatus not implemented")
}
func (UnimplementedArtShowServer) ApplyList(context.Context, *ApplyListReq) (*ApplyListRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ApplyList not implemented")
}
func (UnimplementedArtShowServer) ApplyDetail(context.Context, *ApplyShowReq) (*ApplyShowRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ApplyDetail not implemented")
}
func (s *UnimplementedArtShowServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
func (s *UnimplementedArtShowServer) XXX_GetProxyImpl() protocol.Invoker {
return s.proxyImpl
}
func (s *UnimplementedArtShowServer) XXX_ServiceDesc() *grpc_go.ServiceDesc {
return &ArtShow_ServiceDesc
}
func (s *UnimplementedArtShowServer) XXX_InterfaceName() string {
return "ArtShow.ArtShow"
}
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_go.ServiceRegistrar, srv ArtShowServer) {
s.RegisterService(&ArtShow_ServiceDesc, srv)
}
func _ArtShow_CreateShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SaveShowReq)
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("CreateShow", 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_UpdateShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SaveShowReq)
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("UpdateShow", 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_DelShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(DelShowReq)
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("DelShow", 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_ShowList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ShowListReq)
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("ShowList", 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_ShowInfo_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("ShowInfo", 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_ShowStatisticalInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ShowStatisticalInfoReq)
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("ShowStatisticalInfo", 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_ArtworkPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ArtworkPriceReq)
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("ArtworkPrice", 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_CreateApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SaveApplyReq)
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("CreateApply", 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_UpdateApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SaveApplyReq)
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("UpdateApply", 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_DelApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(DelApplyReq)
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("DelApply", 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_ShowListWithApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ShowListReq)
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("ShowListWithApply", 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_UpdateApplyStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateApplyStatusReq)
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("UpdateApplyStatus", 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_ApplyList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ApplyListReq)
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("ApplyList", 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_ApplyDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ApplyShowReq)
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("ApplyDetail", 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)
}
// ArtShow_ServiceDesc is the grpc_go.ServiceDesc for ArtShow service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
var ArtShow_ServiceDesc = grpc_go.ServiceDesc{
ServiceName: "ArtShow.ArtShow",
HandlerType: (*ArtShowServer)(nil),
Methods: []grpc_go.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: "ShowInfo",
Handler: _ArtShow_ShowInfo_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_go.StreamDesc{},
Metadata: "pb/artshow.proto",
}

216
pb/artshow.proto Normal file
View File

@ -0,0 +1,216 @@
syntax = "proto3";
package ArtShow;
option go_package = "./artShow;artShow";
service ArtShow {
rpc CreateShow (SaveShowReq) returns (SaveShowRes) {} //
rpc UpdateShow (SaveShowReq) returns (SaveShowRes) {} //
rpc DelShow (DelShowReq) returns (CommonRes) {} //
rpc ShowList (ShowListReq) returns (ShowListRes) {} //
rpc ShowInfo (ShowDetailReq) returns (ShowArtworkDetailRes) {} //
rpc ShowStatisticalInfo (ShowStatisticalInfoReq) returns (ShowStatisticalInfoRes) {} // ()
rpc ArtworkPrice (ArtworkPriceReq) returns (ArtworkPriceRes) {} //
rpc CreateApply (SaveApplyReq) returns (SaveApplyRes) {} //
rpc UpdateApply (SaveApplyReq) returns (SaveApplyRes) {} //
rpc DelApply (DelApplyReq) returns (CommonRes) {} //
rpc ShowListWithApply (ShowListReq) returns (ShowListRes) {} //
rpc UpdateApplyStatus (UpdateApplyStatusReq) returns (CommonRes) {} //
rpc ApplyList (ApplyListReq) returns (ApplyListRes) {} //
rpc ApplyDetail (ApplyShowReq) returns (ApplyShowRes) {} //
}
//
message SaveShowReq {
string ShowName = 1 [json_name = "show_name"];
string ArtistName = 2 [json_name = "artist_name"];
string ArtistID = 3 [json_name = "artist_id"];
int32 ArtworkNum = 4 [json_name = "artwork_num"];
int32 Ruler = 5 [json_name = "ruler"];
int64 Price = 6 [json_name = "price"];
int64 Reward = 7 [json_name = "reward"];
int32 IsShow = 8 [json_name = "is_show"];
string ShowTime = 9 [json_name = "show_time"];
repeated ShowArtworkDetail ShowArtwork = 10 [json_name = "show_artwork"];
int64 ID = 11 [json_name = "id"];
}
message SaveShowRes {
string Msg = 1 [json_name = "msg"];
int64 ShowID = 2 [json_name = "show_id"];
}
message CommonRes {
string Msg = 1 [json_name = "msg"];
}
//
message ShowDetailReq {
int64 ShowID = 1 [json_name = "show_id"];
}
message ShowDetail {
int64 ID = 1 [json_name = "id"];
string ShowSeq = 2 [json_name = "show_seq"];
string ShowName = 3 [json_name = "show_name"];
string ArtistName = 4 [json_name = "artist_name"];
string ArtistID = 5 [json_name = "artist_id"];
int32 ArtworkNum = 6 [json_name = "artwork_num"];
int32 Ruler = 7 [json_name = "ruler"];
int64 Price = 8 [json_name = "price"];
int64 Reward = 9 [json_name = "reward"];
string ShowTime = 10 [json_name = "show_time"];
int32 IsShow = 11 [json_name = "is_show"];
}
message ShowArtworkDetailRes {
repeated ShowArtworkDetail data = 1 [json_name = "data"];
string Msg = 2 [json_name = "msg"];
}
//
message ShowListReq {
int32 Page = 1 [json_name = "page"];
int32 PageSize = 2 [json_name = "page_size"];
string StartTime = 3 [json_name = "start_time"];
string EndTime = 4 [json_name = "end_time"];
string ArtistID = 5 [json_name = "artist_id"];
int32 IsShow = 6 [json_name = "is_show"];
}
message ShowListRes {
int64 Total = 1 [json_name = "total"];
int64 TotalPackageNum = 2 [json_name = "total_package_num"];
int64 TotalArtistNum = 3 [json_name = "total_artist_num"];
repeated ShowDetail Data = 4 [json_name = "data"];
string Msg = 5 [json_name = "msg"];
}
//
message DelShowReq {
repeated int64 ShowID = 1 [json_name = "show_id"];
}
//
message ShowArtworkDetail {
int64 ID = 1 [json_name = "id"];
int64 ShowID =2 [json_name = "show_id"];
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"];
}
//
message ShowStatisticalInfoReq {
int32 IsShow = 1 [json_name = "is_show"];
}
message ShowStatisticalInfoRes {
message Num {
int64 ArtistNum = 1 [json_name = "artist_num"];
int64 PackageNum = 2 [json_name = "package_num"];
}
Num Data = 1 [json_name = "data"];
string Msg = 2 [json_name = "msg"];
}
message ArtworkPriceReq {
int64 ArtworkID = 1 [json_name = "artwork_id"];
}
message ArtworkPriceRes {
message PriceInfo {
int64 Price = 1 [json_name = "price"];
int64 RulerPrice = 2 [json_name = "ruler_price"];
int64 ArtworkPrice = 3 [json_name = "artwork_price"];
int64 MarketPrice = 4 [json_name = "market_price"];
int64 CopyrightPrice = 5 [json_name = "copyright_price"];
}
PriceInfo Data = 1 [json_name = "data"];
string Msg = 2 [json_name = "msg"];
}
message ShowRel {
int64 ID = 1 [json_name = "id"];
int64 ApplyID = 2 [json_name = "apply_id"];
int64 ShowID = 3 [json_name = "show_id"];
int32 Index = 4 [json_name = "index"];
string Address = 5 [json_name = "address"];
}
message SaveApplyReq {
string Applicant = 1 [json_name = "applicant"];
int64 ApplicantID = 2 [json_name = "applicant_id"];
int32 Num = 3 [json_name = "num"];
string ApplyTime = 4 [json_name = "apply_time"];
int64 ID = 5 [json_name = "id"];
int32 Status = 6 [json_name = "status"];
string Remark = 7 [json_name = "remark"];
repeated ShowRel Rel = 8 [json_name = "rel"];
}
message SaveApplyRes {
string Msg = 1 [json_name = "msg"];
int64 ApplyID = 2 [json_name = "apply_id"];
}
message ApplyListReq {
int32 Page = 1 [json_name = "page"];
int32 PageSize = 2 [json_name = "page_size"];
}
message ApplyListRes {
int64 Total = 1 [json_name = "total"];
repeated ApplyDetail Data = 2 [json_name = "data"];
string Msg = 3 [json_name = "msg"];
}
message ApplyShowReq {
int64 ApplyID = 1 [json_name = "apply_id"];
}
message ApplyShowRes {
ApplyDetail Apply = 1 [json_name = "apply"];
repeated ShowDetail Show = 2 [json_name = "show"];
string Msg = 3 [json_name = "msg"];
}
message ApplyDetail {
int64 ID = 1 [json_name = "id"];
string ApplySeq = 2 [json_name = "apply_seq"];
string Applicant = 3 [json_name = "applicant"];
int64 ApplicantID = 4 [json_name = "applicant_id"];
int32 Num = 5 [json_name = "num"];
string ApplyTime = 6 [json_name = "apply_time"];
int32 Status = 7 [json_name = "status"];
string Remark = 8 [json_name = "remark"];
}
message ShowRelListReq {
int64 ApplyID = 1 [json_name = "apply_id"];
}
message ShowRelListRes {
string Msg = 1 [json_name = "msg"];
repeated ShowRel Data = 2 [json_name = "data"];
}
message UpdateApplyStatusReq {
int32 Status = 1 [json_name = "status"];
string Remark = 2 [json_name = "remark"];
int64 ApplyID = 3 [json_name = "apply_id"];
}
message DelApplyReq {
repeated int64 ApplyID = 1 [json_name = "apply_id"];
}

3185
pb/test/artshow.pb.go Normal file

File diff suppressed because it is too large Load Diff

862
pb/validate.proto Normal file
View File

@ -0,0 +1,862 @@
syntax = "proto2";
package validate;
option go_package = "github.com/envoyproxy/protoc-gen-validate/validate";
option java_package = "io.envoyproxy.pgv.validate";
import "google/protobuf/descriptor.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
// Validation rules applied at the message level
extend google.protobuf.MessageOptions {
// Disabled nullifies any validation rules for this message, including any
// message fields associated with it that do support validation.
optional bool disabled = 1071;
// Ignore skips generation of validation methods for this message.
optional bool ignored = 1072;
}
// Validation rules applied at the oneof level
extend google.protobuf.OneofOptions {
// Required ensures that exactly one the field options in a oneof is set;
// validation fails if no fields in the oneof are set.
optional bool required = 1071;
}
// Validation rules applied at the field level
extend google.protobuf.FieldOptions {
// Rules specify the validations to be performed on this field. By default,
// no validation is performed against a field.
optional FieldRules rules = 1071;
}
// FieldRules encapsulates the rules for each type of field. Depending on the
// field, the correct set should be used to ensure proper validations.
message FieldRules {
optional MessageRules message = 17;
oneof type {
// Scalar Field Types
FloatRules float = 1;
DoubleRules double = 2;
Int32Rules int32 = 3;
Int64Rules int64 = 4;
UInt32Rules uint32 = 5;
UInt64Rules uint64 = 6;
SInt32Rules sint32 = 7;
SInt64Rules sint64 = 8;
Fixed32Rules fixed32 = 9;
Fixed64Rules fixed64 = 10;
SFixed32Rules sfixed32 = 11;
SFixed64Rules sfixed64 = 12;
BoolRules bool = 13;
StringRules string = 14;
BytesRules bytes = 15;
// Complex Field Types
EnumRules enum = 16;
RepeatedRules repeated = 18;
MapRules map = 19;
// Well-Known Field Types
AnyRules any = 20;
DurationRules duration = 21;
TimestampRules timestamp = 22;
}
}
// FloatRules describes the constraints applied to `float` values
message FloatRules {
// Const specifies that this field must be exactly the specified value
optional float const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional float lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional float lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional float gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional float gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated float in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated float not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// DoubleRules describes the constraints applied to `double` values
message DoubleRules {
// Const specifies that this field must be exactly the specified value
optional double const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional double lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional double lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional double gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional double gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated double in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated double not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// Int32Rules describes the constraints applied to `int32` values
message Int32Rules {
// Const specifies that this field must be exactly the specified value
optional int32 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional int32 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional int32 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional int32 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional int32 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated int32 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated int32 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// Int64Rules describes the constraints applied to `int64` values
message Int64Rules {
// Const specifies that this field must be exactly the specified value
optional int64 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional int64 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional int64 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional int64 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional int64 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated int64 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated int64 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// UInt32Rules describes the constraints applied to `uint32` values
message UInt32Rules {
// Const specifies that this field must be exactly the specified value
optional uint32 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional uint32 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional uint32 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional uint32 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional uint32 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated uint32 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated uint32 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// UInt64Rules describes the constraints applied to `uint64` values
message UInt64Rules {
// Const specifies that this field must be exactly the specified value
optional uint64 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional uint64 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional uint64 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional uint64 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional uint64 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated uint64 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated uint64 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// SInt32Rules describes the constraints applied to `sint32` values
message SInt32Rules {
// Const specifies that this field must be exactly the specified value
optional sint32 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional sint32 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional sint32 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional sint32 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional sint32 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated sint32 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated sint32 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// SInt64Rules describes the constraints applied to `sint64` values
message SInt64Rules {
// Const specifies that this field must be exactly the specified value
optional sint64 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional sint64 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional sint64 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional sint64 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional sint64 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated sint64 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated sint64 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// Fixed32Rules describes the constraints applied to `fixed32` values
message Fixed32Rules {
// Const specifies that this field must be exactly the specified value
optional fixed32 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional fixed32 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional fixed32 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional fixed32 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional fixed32 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated fixed32 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated fixed32 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// Fixed64Rules describes the constraints applied to `fixed64` values
message Fixed64Rules {
// Const specifies that this field must be exactly the specified value
optional fixed64 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional fixed64 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional fixed64 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional fixed64 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional fixed64 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated fixed64 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated fixed64 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// SFixed32Rules describes the constraints applied to `sfixed32` values
message SFixed32Rules {
// Const specifies that this field must be exactly the specified value
optional sfixed32 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional sfixed32 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional sfixed32 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional sfixed32 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional sfixed32 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated sfixed32 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated sfixed32 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// SFixed64Rules describes the constraints applied to `sfixed64` values
message SFixed64Rules {
// Const specifies that this field must be exactly the specified value
optional sfixed64 const = 1;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional sfixed64 lt = 2;
// Lte specifies that this field must be less than or equal to the
// specified value, inclusive
optional sfixed64 lte = 3;
// Gt specifies that this field must be greater than the specified value,
// exclusive. If the value of Gt is larger than a specified Lt or Lte, the
// range is reversed.
optional sfixed64 gt = 4;
// Gte specifies that this field must be greater than or equal to the
// specified value, inclusive. If the value of Gte is larger than a
// specified Lt or Lte, the range is reversed.
optional sfixed64 gte = 5;
// In specifies that this field must be equal to one of the specified
// values
repeated sfixed64 in = 6;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated sfixed64 not_in = 7;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 8;
}
// BoolRules describes the constraints applied to `bool` values
message BoolRules {
// Const specifies that this field must be exactly the specified value
optional bool const = 1;
}
// StringRules describe the constraints applied to `string` values
message StringRules {
// Const specifies that this field must be exactly the specified value
optional string const = 1;
// Len specifies that this field must be the specified number of
// characters (Unicode code points). Note that the number of
// characters may differ from the number of bytes in the string.
optional uint64 len = 19;
// MinLen specifies that this field must be the specified number of
// characters (Unicode code points) at a minimum. Note that the number of
// characters may differ from the number of bytes in the string.
optional uint64 min_len = 2;
// MaxLen specifies that this field must be the specified number of
// characters (Unicode code points) at a maximum. Note that the number of
// characters may differ from the number of bytes in the string.
optional uint64 max_len = 3;
// LenBytes specifies that this field must be the specified number of bytes
optional uint64 len_bytes = 20;
// MinBytes specifies that this field must be the specified number of bytes
// at a minimum
optional uint64 min_bytes = 4;
// MaxBytes specifies that this field must be the specified number of bytes
// at a maximum
optional uint64 max_bytes = 5;
// Pattern specifes that this field must match against the specified
// regular expression (RE2 syntax). The included expression should elide
// any delimiters.
optional string pattern = 6;
// Prefix specifies that this field must have the specified substring at
// the beginning of the string.
optional string prefix = 7;
// Suffix specifies that this field must have the specified substring at
// the end of the string.
optional string suffix = 8;
// Contains specifies that this field must have the specified substring
// anywhere in the string.
optional string contains = 9;
// NotContains specifies that this field cannot have the specified substring
// anywhere in the string.
optional string not_contains = 23;
// In specifies that this field must be equal to one of the specified
// values
repeated string in = 10;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated string not_in = 11;
// WellKnown rules provide advanced constraints against common string
// patterns
oneof well_known {
// Email specifies that the field must be a valid email address as
// defined by RFC 5322
bool email = 12;
// Hostname specifies that the field must be a valid hostname as
// defined by RFC 1034. This constraint does not support
// internationalized domain names (IDNs).
bool hostname = 13;
// Ip specifies that the field must be a valid IP (v4 or v6) address.
// Valid IPv6 addresses should not include surrounding square brackets.
bool ip = 14;
// Ipv4 specifies that the field must be a valid IPv4 address.
bool ipv4 = 15;
// Ipv6 specifies that the field must be a valid IPv6 address. Valid
// IPv6 addresses should not include surrounding square brackets.
bool ipv6 = 16;
// Uri specifies that the field must be a valid, absolute URI as defined
// by RFC 3986
bool uri = 17;
// UriRef specifies that the field must be a valid URI as defined by RFC
// 3986 and may be relative or absolute.
bool uri_ref = 18;
// Address specifies that the field must be either a valid hostname as
// defined by RFC 1034 (which does not support internationalized domain
// names or IDNs), or it can be a valid IP (v4 or v6).
bool address = 21;
// Uuid specifies that the field must be a valid UUID as defined by
// RFC 4122
bool uuid = 22;
// WellKnownRegex specifies a common well known pattern defined as a regex.
KnownRegex well_known_regex = 24;
}
// This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable
// strict header validation.
// By default, this is true, and HTTP header validations are RFC-compliant.
// Setting to false will enable a looser validations that only disallows
// \r\n\0 characters, which can be used to bypass header matching rules.
optional bool strict = 25 [default = true];
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 26;
}
// WellKnownRegex contain some well-known patterns.
enum KnownRegex {
UNKNOWN = 0;
// HTTP header name as defined by RFC 7230.
HTTP_HEADER_NAME = 1;
// HTTP header value as defined by RFC 7230.
HTTP_HEADER_VALUE = 2;
}
// BytesRules describe the constraints applied to `bytes` values
message BytesRules {
// Const specifies that this field must be exactly the specified value
optional bytes const = 1;
// Len specifies that this field must be the specified number of bytes
optional uint64 len = 13;
// MinLen specifies that this field must be the specified number of bytes
// at a minimum
optional uint64 min_len = 2;
// MaxLen specifies that this field must be the specified number of bytes
// at a maximum
optional uint64 max_len = 3;
// Pattern specifes that this field must match against the specified
// regular expression (RE2 syntax). The included expression should elide
// any delimiters.
optional string pattern = 4;
// Prefix specifies that this field must have the specified bytes at the
// beginning of the string.
optional bytes prefix = 5;
// Suffix specifies that this field must have the specified bytes at the
// end of the string.
optional bytes suffix = 6;
// Contains specifies that this field must have the specified bytes
// anywhere in the string.
optional bytes contains = 7;
// In specifies that this field must be equal to one of the specified
// values
repeated bytes in = 8;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated bytes not_in = 9;
// WellKnown rules provide advanced constraints against common byte
// patterns
oneof well_known {
// Ip specifies that the field must be a valid IP (v4 or v6) address in
// byte format
bool ip = 10;
// Ipv4 specifies that the field must be a valid IPv4 address in byte
// format
bool ipv4 = 11;
// Ipv6 specifies that the field must be a valid IPv6 address in byte
// format
bool ipv6 = 12;
}
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 14;
}
// EnumRules describe the constraints applied to enum values
message EnumRules {
// Const specifies that this field must be exactly the specified value
optional int32 const = 1;
// DefinedOnly specifies that this field must be only one of the defined
// values for this enum, failing on any undefined value.
optional bool defined_only = 2;
// In specifies that this field must be equal to one of the specified
// values
repeated int32 in = 3;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated int32 not_in = 4;
}
// MessageRules describe the constraints applied to embedded message values.
// For message-type fields, validation is performed recursively.
message MessageRules {
// Skip specifies that the validation rules of this field should not be
// evaluated
optional bool skip = 1;
// Required specifies that this field must be set
optional bool required = 2;
}
// RepeatedRules describe the constraints applied to `repeated` values
message RepeatedRules {
// MinItems specifies that this field must have the specified number of
// items at a minimum
optional uint64 min_items = 1;
// MaxItems specifies that this field must have the specified number of
// items at a maximum
optional uint64 max_items = 2;
// Unique specifies that all elements in this field must be unique. This
// contraint is only applicable to scalar and enum types (messages are not
// supported).
optional bool unique = 3;
// Items specifies the contraints to be applied to each item in the field.
// Repeated message fields will still execute validation against each item
// unless skip is specified here.
optional FieldRules items = 4;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 5;
}
// MapRules describe the constraints applied to `map` values
message MapRules {
// MinPairs specifies that this field must have the specified number of
// KVs at a minimum
optional uint64 min_pairs = 1;
// MaxPairs specifies that this field must have the specified number of
// KVs at a maximum
optional uint64 max_pairs = 2;
// NoSparse specifies values in this field cannot be unset. This only
// applies to map's with message value types.
optional bool no_sparse = 3;
// Keys specifies the constraints to be applied to each key in the field.
optional FieldRules keys = 4;
// Values specifies the constraints to be applied to the value of each key
// in the field. Message values will still have their validations evaluated
// unless skip is specified here.
optional FieldRules values = 5;
// IgnoreEmpty specifies that the validation rules of this field should be
// evaluated only if the field is not empty
optional bool ignore_empty = 6;
}
// AnyRules describe constraints applied exclusively to the
// `google.protobuf.Any` well-known type
message AnyRules {
// Required specifies that this field must be set
optional bool required = 1;
// In specifies that this field's `type_url` must be equal to one of the
// specified values.
repeated string in = 2;
// NotIn specifies that this field's `type_url` must not be equal to any of
// the specified values.
repeated string not_in = 3;
}
// DurationRules describe the constraints applied exclusively to the
// `google.protobuf.Duration` well-known type
message DurationRules {
// Required specifies that this field must be set
optional bool required = 1;
// Const specifies that this field must be exactly the specified value
optional google.protobuf.Duration const = 2;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional google.protobuf.Duration lt = 3;
// Lt specifies that this field must be less than the specified value,
// inclusive
optional google.protobuf.Duration lte = 4;
// Gt specifies that this field must be greater than the specified value,
// exclusive
optional google.protobuf.Duration gt = 5;
// Gte specifies that this field must be greater than the specified value,
// inclusive
optional google.protobuf.Duration gte = 6;
// In specifies that this field must be equal to one of the specified
// values
repeated google.protobuf.Duration in = 7;
// NotIn specifies that this field cannot be equal to one of the specified
// values
repeated google.protobuf.Duration not_in = 8;
}
// TimestampRules describe the constraints applied exclusively to the
// `google.protobuf.Timestamp` well-known type
message TimestampRules {
// Required specifies that this field must be set
optional bool required = 1;
// Const specifies that this field must be exactly the specified value
optional google.protobuf.Timestamp const = 2;
// Lt specifies that this field must be less than the specified value,
// exclusive
optional google.protobuf.Timestamp lt = 3;
// Lte specifies that this field must be less than the specified value,
// inclusive
optional google.protobuf.Timestamp lte = 4;
// Gt specifies that this field must be greater than the specified value,
// exclusive
optional google.protobuf.Timestamp gt = 5;
// Gte specifies that this field must be greater than the specified value,
// inclusive
optional google.protobuf.Timestamp gte = 6;
// LtNow specifies that this must be less than the current time. LtNow
// can only be used with the Within rule.
optional bool lt_now = 7;
// GtNow specifies that this must be greater than the current time. GtNow
// can only be used with the Within rule.
optional bool gt_now = 8;
// Within specifies that this field must be within this duration of the
// current time. This constraint can be used alone or with the LtNow and
// GtNow rules.
optional google.protobuf.Duration within = 9;
}

80
pb/validator.proto Normal file
View File

@ -0,0 +1,80 @@
// Copyright 2016 Michal Witkowski. All Rights Reserved.
// See LICENSE for licensing terms.
// Protocol Buffers extensions for defining auto-generateable validators for messages.
// TODO(mwitkow): Add example.
syntax = "proto2";
package validator;
import "google/protobuf/descriptor.proto";
option go_package = "github.com/mwitkow/go-proto-validators;validator";
// TODO(mwitkow): Email protobuf-global-extension-registry@google.com to get an extension ID.
extend google.protobuf.FieldOptions {
optional FieldValidator field = 65020;
}
extend google.protobuf.OneofOptions {
optional OneofValidator oneof = 65021;
}
message FieldValidator {
// Uses a Golang RE2-syntax regex to match the field contents.
optional string regex = 1;
// Field value of integer strictly greater than this value.
optional int64 int_gt = 2;
// Field value of integer strictly smaller than this value.
optional int64 int_lt = 3;
// Used for nested message types, requires that the message type exists.
optional bool msg_exists = 4;
// Human error specifies a user-customizable error that is visible to the user.
optional string human_error = 5;
// Field value of double strictly greater than this value.
// Note that this value can only take on a valid floating point
// value. Use together with float_epsilon if you need something more specific.
optional double float_gt = 6;
// Field value of double strictly smaller than this value.
// Note that this value can only take on a valid floating point
// value. Use together with float_epsilon if you need something more specific.
optional double float_lt = 7;
// Field value of double describing the epsilon within which
// any comparison should be considered to be true. For example,
// when using float_gt = 0.35, using a float_epsilon of 0.05
// would mean that any value above 0.30 is acceptable. It can be
// thought of as a {float_value_condition} +- {float_epsilon}.
// If unset, no correction for floating point inaccuracies in
// comparisons will be attempted.
optional double float_epsilon = 8;
// Floating-point value compared to which the field content should be greater or equal.
optional double float_gte = 9;
// Floating-point value compared to which the field content should be smaller or equal.
optional double float_lte = 10;
// Used for string fields, requires the string to be not empty (i.e different from "").
optional bool string_not_empty = 11;
// Repeated field with at least this number of elements.
optional int64 repeated_count_min = 12;
// Repeated field with at most this number of elements.
optional int64 repeated_count_max = 13;
// Field value of length greater than this value.
optional int64 length_gt = 14;
// Field value of length smaller than this value.
optional int64 length_lt = 15;
// Field value of length strictly equal to this value.
optional int64 length_eq = 16;
// Requires that the value is in the enum.
optional bool is_in_enum = 17;
// Ensures that a string value is in UUID format.
// uuid_ver specifies the valid UUID versions. Valid values are: 0-5.
// If uuid_ver is 0 all UUID versions are accepted.
optional int32 uuid_ver = 18;
}
message OneofValidator {
// Require that one of the oneof fields is set.
optional bool required = 1;
}

95
pkg/db/init.go Normal file
View File

@ -0,0 +1,95 @@
package db
import (
"fmt"
"fonchain-artshow/cmd/model"
"fonchain-artshow/pkg/m"
"os"
"strings"
"time"
"github.com/gin-gonic/gin"
"gopkg.in/ini.v1"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
)
var DbArtShow *gorm.DB
var (
Db string
DbHost string
DbPort string
DbUser string
DbPassWord string
DbName string
)
func Init(confPath string) {
//从本地读取环境变量
file, err := ini.Load(confPath)
if err != nil {
fmt.Println(m.ERROR_SERVER, err)
}
//加载数据库配置
LoadMysqlData(file)
//MySQL数据库
path := strings.Join([]string{DbUser, ":", DbPassWord, "@tcp(", DbHost, ":", DbPort, ")/", DbName, "?charset=utf8&parseTime=true"}, "")
//连接数据库
Database(path)
migration() //迁移表 按需打开
}
func LoadMysqlData(file *ini.File) {
Db = file.Section("mysql").Key("Db").String()
DbHost = file.Section("mysql").Key("DbHost").String()
DbPort = file.Section("mysql").Key("DbPort").String()
DbUser = file.Section("mysql").Key("DbUser").String()
DbPassWord = file.Section("mysql").Key("DbPassWord").String()
DbName = file.Section("mysql").Key("DbName").String()
}
func Database(conn string) {
var ormLogger logger.Interface
if gin.Mode() == "debug" {
ormLogger = logger.Default.LogMode(logger.Info)
} else {
ormLogger = logger.Default
}
db, err := gorm.Open(mysql.New(mysql.Config{
DSN: conn, // DSN data source name
DefaultStringSize: 256, // string 类型字段的默认长度
DisableDatetimePrecision: true, // 禁用 datetime 精度MySQL 5.6 之前的数据库不支持
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
DontSupportRenameColumn: true, // 用 `change` 重命名列MySQL 8 之前的数据库和 MariaDB 不支持重命名列
SkipInitializeWithVersion: false, // 根据版本自动配置
}), &gorm.Config{
Logger: ormLogger,
NamingStrategy: schema.NamingStrategy{
SingularTable: true,
},
})
sqlDB, _ := db.DB()
sqlDB.SetMaxIdleConns(20) //设置连接池,空闲
sqlDB.SetMaxOpenConns(100) //打开
sqlDB.SetConnMaxLifetime(time.Second * 30)
DbArtShow = db
if err != nil {
panic(err)
}
}
//执行数据迁移
func migration() {
//自动迁移模式
err := DbArtShow.AutoMigrate(&model.ArtShow{},
&model.ShowApply{}, &model.ArtworkPrice{}, &model.ShowRel{})
if err != nil {
fmt.Println("register table fail")
os.Exit(0)
}
fmt.Println("register table success")
}

86
pkg/logger/zap_logger.go Normal file
View File

@ -0,0 +1,86 @@
package logger
import (
"os"
"gopkg.in/ini.v1"
"github.com/natefinch/lumberjack"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var lg *zap.Logger
var (
mode string
level string
filename string
maxSize int
maxAge int
maxBackups int
)
func LoadLogConfig(file *ini.File) {
logCfg := file.Section("zap_log")
mode = logCfg.Key("mode").String()
level = logCfg.Key("level").String()
filename = logCfg.Key("filename").String()
maxSize, _ = logCfg.Key("max_size").Int()
maxAge, _ = logCfg.Key("max_age").Int()
maxBackups, _ = logCfg.Key("max_backups").Int()
}
// ZapInit 初始化lg
func ZapInit(confPath string) {
//从本地读取环境变量
file, err := ini.Load(confPath)
if err != nil {
panic(err)
}
//加载数据库配置
LoadLogConfig(file)
writeSyncer := getLogWriter(filename, maxSize, maxBackups, maxAge)
encoder := getEncoder()
var l = new(zapcore.Level)
err = l.UnmarshalText([]byte(level))
if err != nil {
return
}
var core zapcore.Core
if mode == "dev" {
// 进入开发模式,日志输出到终端
consoleEncoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
core = zapcore.NewTee(
zapcore.NewCore(encoder, writeSyncer, l),
zapcore.NewCore(consoleEncoder, zapcore.Lock(os.Stdout), zapcore.DebugLevel),
)
} else {
core = zapcore.NewCore(encoder, writeSyncer, l)
}
lg = zap.New(core, zap.AddCaller())
zap.ReplaceGlobals(lg)
return
}
func getEncoder() zapcore.Encoder {
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
encoderConfig.TimeKey = "time"
encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
encoderConfig.EncodeDuration = zapcore.SecondsDurationEncoder
encoderConfig.EncodeCaller = zapcore.ShortCallerEncoder
return zapcore.NewJSONEncoder(encoderConfig)
}
func getLogWriter(filename string, maxSize, maxBackup, maxAge int) zapcore.WriteSyncer {
lumberJackLogger := &lumberjack.Logger{
Filename: filename,
MaxSize: maxSize,
MaxBackups: maxBackup,
MaxAge: maxAge,
}
return zapcore.AddSync(lumberJackLogger)
}

80
pkg/logger/zap_rotate.go Normal file
View File

@ -0,0 +1,80 @@
package logger
import (
"fmt"
"io"
"time"
rotatelogs "github.com/lestrrat/go-file-rotatelogs"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var SugarLogger *zap.SugaredLogger
func main() {
fmt.Println("begin main")
}
func InitLogger() {
encoder := getEncoder()
//两个interface,判断日志等级
//warnlevel以下归到info日志
infoLevel := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return lvl < zapcore.WarnLevel
})
//warnlevel及以上归到warn日志
warnLevel := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return lvl >= zapcore.WarnLevel
})
infoWriter := getLogWriter("/", 1, 1, 1)
warnWriter := getLogWriter("/", 1, 1, 1)
//创建zap.Core,for logger
core := zapcore.NewTee(
zapcore.NewCore(encoder, infoWriter, infoLevel),
zapcore.NewCore(encoder, warnWriter, warnLevel),
)
//生成Logger
logger := zap.New(core, zap.AddCaller())
SugarLogger = logger.Sugar()
}
func getEncoderTest() zapcore.Encoder {
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
return zapcore.NewConsoleEncoder(encoderConfig)
}
func getLogWriterTest(filePath string) zapcore.WriteSyncer {
warnIoWriter := getWriter(filePath)
return zapcore.AddSync(warnIoWriter)
}
//日志文件切割
func getWriter(filename string) io.Writer {
// 保存日志30天每24小时分割一次日志
/*
hook, err := rotatelogs.New(
filename+"_%Y%m%d.log",
rotatelogs.WithLinkName(filename),
rotatelogs.WithMaxAge(time.Hour*24*30),
rotatelogs.WithRotationTime(time.Hour*24),
)
*/
//保存日志30天每1分钟分割一次日志
hook, err := rotatelogs.New(
filename+"_%Y%m%d%H%M.log",
rotatelogs.WithLinkName(filename),
rotatelogs.WithMaxAge(time.Hour*24*30),
rotatelogs.WithRotationTime(time.Minute*1),
)
if err != nil {
panic(err)
}
return hook
}

77
pkg/m/msg.go Normal file
View File

@ -0,0 +1,77 @@
package m
import "github.com/fonchain_enterprise/utils/aes"
var Encryption aes.Encryption
var JWTSecret = []byte("asdfqwer1234")
const (
SERVER_CONFIG = "./conf/conf.ini"
DUBBOGO_CONFIG = "./conf/dubbogo.yaml"
)
const (
TokenTime = 12
EmptyNum = 0
)
const (
SUCCESS = "success"
FAILED = "failed"
)
const (
PRICE_PRECISION = 100
)
const (
ARTSHOW_PREFIX = "AS" // 画展包编号前缀
ARTSHOWAPPLY_PREFIX = "ASA" // 申请画展包前缀
)
// 画展包及画展包申请状态码定义
const (
ARTSHOW_INSIDE = iota + 1 // 内部
ARTSHOW_PASS // 可展
ARTSHOW_SHOWING // 已展
)
const (
SHOWAPPLY_ADD = iota + 10 // 待展
SHOWAPPLY_NUM // 数量审批
SHOWAPPLY_NUM_REJECT // 数量审批驳回
SHOWAPPLY_REL_SHOW // 关联画展包
SHOWAPPLY_SHOW // 画展包关联审批
SHOWAPPLY_SHOW_REJECT // 关联审批驳回
SHOWAPPLY_PASS // 可展
)
const (
ACCOUNT_EXIST = "账号已存在"
ERROR_NOT_FOUND = "不存在的记录"
ERROR_SERVER = "服务器错误"
CREATE_SUCCESS = "创建成功"
UPDATE_SUCCESS = "更新成功"
ERROR_DELETE = "删除错误"
DELETE_SUCCESS = "删除成功"
ERROR_QUERY = "查询失败"
UPDATE_FAILED = "更新失败"
ERROR_UID = "uid创建错误"
ERROR_INVALID_PARAM = "参数错误"
ERROR_CREATE = "创建失败"
// 画展包创建错误
ERROR_SHOW_NAME = "画展包名缺失"
ERROR_TIME = "生成时间缺失"
ERROR_INVALID_ID = "无效的记录ID"
ERROR_Statistical_NUM = "统计错误"
ERROR_APPLICANT = "申请人无效"
ERROR_NUM = "数量错误"
ERROR_NOT_UPDATE_ISSHOW = "画展包已被使用"
)

View File

@ -0,0 +1,53 @@
package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/m"
"strings"
"time"
)
func BuildArtShowM(in *test.SaveShowReq) (out *model.ArtShow) {
out = new(model.ArtShow)
if in.ID == 0 {
out.ShowSeq = strings.Join([]string{m.ARTSHOW_PREFIX, time.Now().Format("20060102150405")}, "")
} else {
out.ID = uint(in.ID)
}
out.ShowName = in.ShowName
out.ArtistName = in.ArtistName
out.ArtistID = in.ArtistID
out.ArtworkNum = in.ArtworkNum
out.Price = in.Price
out.Ruler = in.Ruler
out.Reward = in.Reward
out.ShowTime = in.ShowTime
out.IsShow = int8(in.IsShow)
return
}
func BuildArtShowListRes(artShows []*model.ArtShow) (out []*test.ShowDetail) {
out = make([]*test.ShowDetail, 0)
for i := 0; i < len(artShows); i++ {
artShowM := BuildArtShowRpc(artShows[i])
out = append(out, artShowM)
}
return
}
func BuildArtShowRpc(artShowM *model.ArtShow) (out *test.ShowDetail) {
out = new(test.ShowDetail)
out.ID = int64(artShowM.ID)
out.ShowSeq = artShowM.ShowSeq
out.ShowName = artShowM.ShowName
out.ArtistName = artShowM.ArtistName
out.ArtworkNum = artShowM.ArtworkNum
out.Ruler = artShowM.Ruler
out.Price = artShowM.Price
out.Reward = artShowM.Reward
out.ShowTime = artShowM.ShowTime
out.IsShow = int32(artShowM.IsShow)
return
}

View File

@ -0,0 +1,63 @@
package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
)
func BuildShowArtworkM(in []*test.ShowArtworkDetail, showID uint) (out []*model.ArtworkPrice) {
out = make([]*model.ArtworkPrice, len(in))
for i := 0; i < len(in); i++ {
artworkPrice := new(model.ArtworkPrice)
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
if in[i].ID != 0 {
artworkPrice.ID = uint(in[i].ID)
}
if in[i].ShowID == 0 {
artworkPrice.ShowID = showID
} else {
artworkPrice.ShowID = uint(in[i].ShowID)
}
out[i] = artworkPrice
}
return
}
func BuildShowArtworkRpc(in []*model.ArtworkPrice) (out []*test.ShowArtworkDetail) {
out = make([]*test.ShowArtworkDetail, len(in))
for i := 0; i < len(in); i++ {
artworkPrice := new(test.ShowArtworkDetail)
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
out[i] = artworkPrice
}
return
}
func BuildArtworkPriceRes(artworkPrice *model.ArtworkPrice) (out *test.ArtworkPriceRes) {
out = new(test.ArtworkPriceRes)
out.Data = new(test.ArtworkPriceRes_PriceInfo)
out.Data.Price = artworkPrice.Price
out.Data.RulerPrice = artworkPrice.RulerPrice
out.Data.ArtworkPrice = artworkPrice.ArtworkPrice
out.Data.MarketPrice = artworkPrice.MarketPrice
out.Data.CopyrightPrice = artworkPrice.CopyrightPrice
return
}
func BuildArtworkPriceIDs(in []*model.ArtworkPrice) (out []uint) {
out = make([]uint, len(in))
for i := 0; i < len(in); i++ {
out[i] = in[i].ID
}
return
}

View File

@ -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
}

View File

@ -0,0 +1,41 @@
package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
"fonchain-artshow/pkg/m"
"strings"
"time"
)
func BuildShowApply(in *test.SaveApplyReq) (out *model.ShowApply) {
out = new(model.ShowApply)
if in.ID == 0 {
out.ApplySeq = strings.Join([]string{m.ARTSHOWAPPLY_PREFIX, time.Now().Format("20060102150405")}, "")
out.Status = m.SHOWAPPLY_ADD
} else {
out.ID = uint(in.ID)
}
out.Applicant = in.Applicant
out.ApplicantID = uint(in.ApplicantID)
out.Num = in.Num
out.ApplyTime = in.ApplyTime
out.Remark = in.Remark
return
}
func BuildShowApplyRes(in *model.ShowApply) (out *test.ApplyDetail) {
out = new(test.ApplyDetail)
out.ID = int64(in.ID)
out.ApplySeq = in.ApplySeq
out.Applicant = in.Applicant
out.ApplicantID = int64(in.ApplicantID)
out.Num = in.Num
out.ApplyTime = in.ApplyTime
out.Status = int32(in.Status)
out.Remark = in.Remark
return
}

View File

@ -0,0 +1,44 @@
package serializer
import (
"fonchain-artshow/cmd/model"
"fonchain-artshow/pb/test"
)
func BuildShowRelM(in []*test.ShowRel, applyID uint) (out []*model.ShowRel) {
for i := 0; i < len(in); i++ {
showRel := &model.ShowRel{
ShowID: uint(in[i].ShowID),
ApplyID: applyID,
Index: in[i].Index,
Address: in[i].Address,
}
if in[i].ID != 0 {
showRel.ID = uint(in[i].ID)
}
out = append(out, showRel)
}
return
}
func BuildShowRelRes(in []*model.ShowRel) (out []*test.ShowRel) {
for i := 0; i < len(in); i++ {
showRel := &test.ShowRel{
ID: int64(in[i].ID),
ApplyID: int64(in[i].ApplyID),
ShowID: int64(in[i].ShowID),
Index: in[i].Index,
Address: in[i].Address,
}
out = append(out, showRel)
}
return
}
func BuildShowRelIDs(in []*model.ShowRel) (out []uint) {
out = make([]uint, len(in))
for i := 0; i < len(in); i++ {
out[i] = in[i].ID
}
return
}

14
pkg/utils/math.go Normal file
View File

@ -0,0 +1,14 @@
package utils
import (
"math"
"strconv"
"github.com/spf13/cast"
)
func FormatFloat(f float64, dig int) float64 {
result := cast.ToFloat64(strconv.FormatFloat(f, 'f', dig+1, 64))
pow := math.Pow(1, float64(dig))
return math.Round(result*pow) / pow
}

97
pkg/utils/silce.go Normal file
View File

@ -0,0 +1,97 @@
package utils
import "strconv"
func BeUniqueSlice_string(src, dest []string) (add []string, del []string, same []string) {
srcMap := make(map[string]byte) //按源数组建索引
allMap := make(map[string]byte) //所有元素建索引
//1.建立map
for _, v := range src {
srcMap[v] = 0
allMap[v] = 0
}
//2.将 dest 元素添加到 mall(msrc) 中,长度发生变化,即元素添加成功, 记录添加不成功的元素,便是重复元素
for _, v := range dest {
l := len(allMap)
allMap[v] = 0
if l != len(allMap) {
l = len(allMap)
} else {
same = append(same, v)
}
}
//3.找相同
for _, v := range same {
delete(allMap, v)
}
//4.找不同
for v, _ := range allMap {
_, exist := srcMap[v]
if exist {
del = append(del, v)
} else {
add = append(add, v)
}
}
return
}
func BeUniqueSlice_uint(src, dest []uint) (add []uint, del []uint, same []uint) {
srcMap := make(map[uint]byte) //按源数组建索引
allMap := make(map[uint]byte) //所有元素建索引
//1.建立map
for _, v := range src {
srcMap[v] = 0
allMap[v] = 0
}
//2.将 dest 元素添加到 mall(srcMap) 中,长度发生变化,即元素添加成功, 记录添加不成功的元素,便是重复元素
for _, v := range dest {
l := len(allMap)
allMap[v] = 0
if l != len(allMap) {
l = len(allMap)
} else {
same = append(same, v)
}
}
//3.找相同
for _, v := range same {
delete(allMap, v)
}
//4.找不同
for v, _ := range allMap {
_, exist := srcMap[v]
if exist {
del = append(del, v)
} else {
add = append(add, v)
}
}
return
}
func ConvertString2Uint(src []string) (dest []uint) {
for i := 0; i < len(src); i++ {
x, _ := strconv.ParseUint(src[i], 10, 64)
dest = append(dest, uint(x))
}
return
}
func ConvertUint2String(src []uint) (dest []string) {
for i := 0; i < len(src); i++ {
x := strconv.FormatUint(uint64(src[i]), 10)
dest = append(dest, x)
}
return
}

View File

@ -0,0 +1,25 @@
{"level":"ERROR","time":"2022-09-19T13:06:48.656+0800","caller":"dao/art_show.go:20","msg":"ArtShow err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T13:07:03.984+0800","caller":"dao/art_show.go:20","msg":"ArtShow err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T13:12:15.656+0800","caller":"dao/artwork_price.go:21","msg":"Artwork price save err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T14:21:22.396+0800","caller":"dao/show_apply.go:20","msg":"ShowApply err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T14:22:47.440+0800","caller":"dao/show_apply.go:20","msg":"ShowApply err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T14:25:31.761+0800","caller":"dao/art_show.go:61","msg":"ArtShowListByApplyStatus Count err","error":"Error 1054: Unknown column 'a.*' in 'field list'"}
{"level":"ERROR","time":"2022-09-19T16:12:06.010+0800","caller":"dao/show_apply.go:20","msg":"ShowApply err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T16:14:00.297+0800","caller":"dao/show_apply.go:20","msg":"ShowApply err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-19T16:25:58.540+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1054: Unknown column 'a.status' in 'where clause'"}
{"level":"ERROR","time":"2022-09-19T17:00:41.775+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:04:33.080+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:04:53.913+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:04:54.722+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:04:55.217+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:04:55.385+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:06:58.083+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel where status <> 2 AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:09:12.833+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel where status <> 2 AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:10:26.292+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel where status <> 2 AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:10:28.073+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel where status <> 2 AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:10:29.281+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from art_show.show_rel where status <> 2 AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:11:04.872+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:11:06.142+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select show_id from show_rel AND a.is_show = ?' at line 1"}
{"level":"ERROR","time":"2022-09-19T19:11:43.178+0800","caller":"dao/art_show.go:62","msg":"ArtShowListByApplyStatus Count err","error":"Error 1242: Subquery returns more than 1 row"}
{"level":"ERROR","time":"2022-09-20T16:24:46.138+0800","caller":"dao/artwork_price.go:51","msg":"Artwork delete err","error":"WHERE conditions required"}
{"level":"ERROR","time":"2022-09-20T17:02:59.796+0800","caller":"dao/show_rel.go:39","msg":"ShowRel delete err","error":"WHERE conditions required"}