测试
This commit is contained in:
parent
9cb5726372
commit
f376a1f0f7
Binary file not shown.
Binary file not shown.
@ -13,7 +13,8 @@ type ArtShowProvider struct {
|
|||||||
artShow.UnimplementedArtShowServer
|
artShow.UnimplementedArtShowServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) CreateShow(ctx context.Context, req *artShow.SaveShowReq) (res *artShow.SaveShowRes, err error) {
|
func (p *ArtShowProvider) CreateShow(_ context.Context, req *artShow.SaveShowReq) (res *artShow.SaveShowRes, err error) {
|
||||||
|
//fmt.Println("artShow create info ======== ", req.ShowSeq)
|
||||||
if req.ShowName == "" {
|
if req.ShowName == "" {
|
||||||
err = errors.New(m.ERROR_SHOW_NAME)
|
err = errors.New(m.ERROR_SHOW_NAME)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -22,11 +23,16 @@ func (p *ArtShowProvider) CreateShow(ctx context.Context, req *artShow.SaveShowR
|
|||||||
err = errors.New(m.ERROR_TIME)
|
err = errors.New(m.ERROR_TIME)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if req.ShowSeq == "" {
|
||||||
|
err = errors.New(m.ERROR_NOT_ARTIST_SEQ)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
res = new(artShow.SaveShowRes)
|
res = new(artShow.SaveShowRes)
|
||||||
err, showUID := service.CreateArtShowWithArtworkPrice(req)
|
err, showUID := service.CreateArtShowWithArtworkPrice(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Msg = err.Error()
|
res.Msg = err.Error()
|
||||||
err = errors.New(m.ERROR_CREATE)
|
err = errors.New(err.Error())
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.Msg = m.CREATE_SUCCESS
|
res.Msg = m.CREATE_SUCCESS
|
||||||
@ -34,7 +40,7 @@ func (p *ArtShowProvider) CreateShow(ctx context.Context, req *artShow.SaveShowR
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) UpdateShow(ctx context.Context, req *artShow.SaveShowReq) (res *artShow.SaveShowRes, err error) {
|
func (p *ArtShowProvider) UpdateShow(_ context.Context, req *artShow.SaveShowReq) (res *artShow.SaveShowRes, err error) {
|
||||||
if req.ShowUID == "" {
|
if req.ShowUID == "" {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
@ -63,9 +69,9 @@ func (p *ArtShowProvider) UpdateShow(ctx context.Context, req *artShow.SaveShowR
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) DelShow(ctx context.Context, req *artShow.DelShowReq) (res *artShow.CommonRes, err error) {
|
func (p *ArtShowProvider) DelShow(_ context.Context, req *artShow.DelShowReq) (res *artShow.CommonRes, err error) {
|
||||||
res = new(artShow.CommonRes)
|
res = new(artShow.CommonRes)
|
||||||
if len(req.ShowUID) < 1 {
|
if len(req.ShowUID) == 0 {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -79,7 +85,7 @@ func (p *ArtShowProvider) DelShow(ctx context.Context, req *artShow.DelShowReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowList(ctx context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
func (p *ArtShowProvider) ShowList(_ context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
||||||
if req.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.Page = 1
|
req.Page = 1
|
||||||
}
|
}
|
||||||
@ -96,7 +102,7 @@ func (p *ArtShowProvider) ShowList(ctx context.Context, req *artShow.ShowListReq
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowListWithRel(ctx context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
func (p *ArtShowProvider) ShowListWithRel(_ context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
||||||
if req.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.Page = 1
|
req.Page = 1
|
||||||
}
|
}
|
||||||
@ -113,7 +119,7 @@ func (p *ArtShowProvider) ShowListWithRel(ctx context.Context, req *artShow.Show
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowArtworkInfo(ctx context.Context, req *artShow.ArtworkDetailReq) (res *artShow.ShowArtworkDetailRes, err error) {
|
func (p *ArtShowProvider) ShowArtworkInfo(_ context.Context, req *artShow.ArtworkDetailReq) (res *artShow.ShowArtworkDetailRes, err error) {
|
||||||
err, res = service.ShowArtworkInfo(req)
|
err, res = service.ShowArtworkInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Msg = err.Error()
|
res.Msg = err.Error()
|
||||||
@ -123,7 +129,7 @@ func (p *ArtShowProvider) ShowArtworkInfo(ctx context.Context, req *artShow.Artw
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowDetail(ctx context.Context, req *artShow.ShowDetailReq) (res *artShow.ShowDetailRes, err error) {
|
func (p *ArtShowProvider) ShowDetail(_ context.Context, req *artShow.ShowDetailReq) (res *artShow.ShowDetailRes, err error) {
|
||||||
res = new(artShow.ShowDetailRes)
|
res = new(artShow.ShowDetailRes)
|
||||||
err, res = service.ShowDetail(req)
|
err, res = service.ShowDetail(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -134,7 +140,7 @@ func (p *ArtShowProvider) ShowDetail(ctx context.Context, req *artShow.ShowDetai
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowStatisticalInfo(ctx context.Context, req *artShow.ShowStatisticalInfoReq) (res *artShow.ShowStatisticalInfoRes, err error) {
|
func (p *ArtShowProvider) ShowStatisticalInfo(_ context.Context, req *artShow.ShowStatisticalInfoReq) (res *artShow.ShowStatisticalInfoRes, err error) {
|
||||||
res = new(artShow.ShowStatisticalInfoRes)
|
res = new(artShow.ShowStatisticalInfoRes)
|
||||||
err, num := service.ShowStatisticalInfo(req)
|
err, num := service.ShowStatisticalInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -146,7 +152,7 @@ func (p *ArtShowProvider) ShowStatisticalInfo(ctx context.Context, req *artShow.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ArtworkPrice(ctx context.Context, req *artShow.ArtworkPriceReq) (res *artShow.ArtworkPriceRes, err error) {
|
func (p *ArtShowProvider) ArtworkPrice(_ context.Context, req *artShow.ArtworkPriceReq) (res *artShow.ArtworkPriceRes, err error) {
|
||||||
if req.ArtworkUID == "" {
|
if req.ArtworkUID == "" {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
@ -161,15 +167,15 @@ func (p *ArtShowProvider) ArtworkPrice(ctx context.Context, req *artShow.Artwork
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowListWithApply(ctx context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
func (p *ArtShowProvider) ShowListWithApply(_ context.Context, req *artShow.ShowListReq) (res *artShow.ShowListRes, err error) {
|
||||||
if req.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.Page = 1
|
req.Page = 1
|
||||||
}
|
}
|
||||||
if req.PageSize == 0 {
|
if req.PageSize == 0 {
|
||||||
req.Page = 10
|
req.Page = 10
|
||||||
}
|
}
|
||||||
if req.IsShow == 0 {
|
if len(req.IsShow) == 0 {
|
||||||
req.IsShow = 2
|
req.IsShow = append(req.IsShow, 2)
|
||||||
}
|
}
|
||||||
res = new(artShow.ShowListRes)
|
res = new(artShow.ShowListRes)
|
||||||
err, res = service.ArtShowListWithApply(req)
|
err, res = service.ArtShowListWithApply(req)
|
||||||
@ -181,7 +187,7 @@ func (p *ArtShowProvider) ShowListWithApply(ctx context.Context, req *artShow.Sh
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ShowListForArtwork(ctx context.Context, req *artShow.ShowListForArtworkReq) (res *artShow.ShowListForArtworkRes, err error) {
|
func (p *ArtShowProvider) ShowListForArtwork(_ context.Context, req *artShow.ShowListForArtworkReq) (res *artShow.ShowListForArtworkRes, err error) {
|
||||||
if req.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.Page = 1
|
req.Page = 1
|
||||||
}
|
}
|
||||||
@ -198,7 +204,7 @@ func (p *ArtShowProvider) ShowListForArtwork(ctx context.Context, req *artShow.S
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ArtworkPriceList(ctx context.Context, req *artShow.ShowDetailReq) (res *artShow.ArtworkPriceListRes, err error) {
|
func (p *ArtShowProvider) ArtworkPriceList(_ context.Context, req *artShow.ShowDetailReq) (res *artShow.ArtworkPriceListRes, err error) {
|
||||||
if len(req.ShowUID) != 1 && req.ShowUID[len(req.ShowUID)-1] == "" {
|
if len(req.ShowUID) != 1 && req.ShowUID[len(req.ShowUID)-1] == "" {
|
||||||
res.Msg = err.Error()
|
res.Msg = err.Error()
|
||||||
err = errors.New(m.ERROR_QUERY)
|
err = errors.New(m.ERROR_QUERY)
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"fonchain-artshow/pkg/m"
|
"fonchain-artshow/pkg/m"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *ArtShowProvider) CreateApply(ctx context.Context, req *artShow.SaveApplyReq) (res *artShow.SaveApplyRes, err error) {
|
func (p *ArtShowProvider) CreateApply(_ context.Context, req *artShow.SaveApplyReq) (res *artShow.SaveApplyRes, err error) {
|
||||||
if req.Applicant == "" {
|
if req.Applicant == "" {
|
||||||
err = errors.New(m.ERROR_APPLICANT)
|
err = errors.New(m.ERROR_APPLICANT)
|
||||||
return
|
return
|
||||||
@ -29,7 +29,7 @@ func (p *ArtShowProvider) CreateApply(ctx context.Context, req *artShow.SaveAppl
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) UpdateApply(ctx context.Context, req *artShow.SaveApplyReq) (res *artShow.SaveApplyRes, err error) {
|
func (p *ArtShowProvider) UpdateApply(_ context.Context, req *artShow.SaveApplyReq) (res *artShow.SaveApplyRes, err error) {
|
||||||
if req.ApplyUID == "" {
|
if req.ApplyUID == "" {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
@ -46,7 +46,7 @@ func (p *ArtShowProvider) UpdateApply(ctx context.Context, req *artShow.SaveAppl
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ApplyList(ctx context.Context, req *artShow.ApplyListReq) (res *artShow.ApplyListRes, err error) {
|
func (p *ArtShowProvider) ApplyList(_ context.Context, req *artShow.ApplyListReq) (res *artShow.ApplyListRes, err error) {
|
||||||
res = new(artShow.ApplyListRes)
|
res = new(artShow.ApplyListRes)
|
||||||
if req.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.Page = 1
|
req.Page = 1
|
||||||
@ -63,7 +63,7 @@ func (p *ArtShowProvider) ApplyList(ctx context.Context, req *artShow.ApplyListR
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) ApplyDetail(ctx context.Context, req *artShow.ApplyShowReq) (res *artShow.ApplyShowRes, err error) {
|
func (p *ArtShowProvider) ApplyDetail(_ context.Context, req *artShow.ApplyShowReq) (res *artShow.ApplyShowRes, err error) {
|
||||||
if req.ApplyUID == "" {
|
if req.ApplyUID == "" {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
@ -78,7 +78,7 @@ func (p *ArtShowProvider) ApplyDetail(ctx context.Context, req *artShow.ApplySho
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) DelApply(ctx context.Context, req *artShow.DelApplyReq) (res *artShow.CommonRes, err error) {
|
func (p *ArtShowProvider) DelApply(_ context.Context, req *artShow.DelApplyReq) (res *artShow.CommonRes, err error) {
|
||||||
if len(req.ApplyUID) < 1 {
|
if len(req.ApplyUID) < 1 {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
@ -94,7 +94,7 @@ func (p *ArtShowProvider) DelApply(ctx context.Context, req *artShow.DelApplyReq
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArtShowProvider) UpdateApplyStatus(ctx context.Context, req *artShow.UpdateApplyStatusReq) (res *artShow.CommonRes, err error) {
|
func (p *ArtShowProvider) UpdateApplyStatus(_ context.Context, req *artShow.UpdateApplyStatusReq) (res *artShow.CommonRes, err error) {
|
||||||
if req.ApplyUID == "" {
|
if req.ApplyUID == "" {
|
||||||
err = errors.New(m.ERROR_INVALID_ID)
|
err = errors.New(m.ERROR_INVALID_ID)
|
||||||
return
|
return
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
uuid "github.com/satori/go.uuid"
|
uuid "github.com/satori/go.uuid"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -18,7 +19,15 @@ func SaveArtShow(tx *gorm.DB, artShow *model.ArtShow) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
artShow.ShowUID = uid.String()
|
artShow.ShowUID = uid.String()
|
||||||
artShow.ShowSeq = strings.Join([]string{m.ARTSHOW_PREFIX, time.Now().Format("20060102150405")}, "")
|
artShow.ShowSeq = strings.Replace(artShow.ShowSeq, "T", m.ARTSHOW_PREFIX, -1)
|
||||||
|
num := countArtistNumInShowCurrentYear(artShow.ArtistUID)
|
||||||
|
if num < 10 {
|
||||||
|
artShow.ShowSeq = strings.Join([]string{artShow.ShowSeq, time.Now().Format("06"), "00" + strconv.FormatInt(num, 10)}, "")
|
||||||
|
} else if num >= 10 && num < 100 {
|
||||||
|
artShow.ShowSeq = strings.Join([]string{artShow.ShowSeq, time.Now().Format("06"), "0" + strconv.FormatInt(num, 10)}, "")
|
||||||
|
} else if num >= 100 {
|
||||||
|
artShow.ShowSeq = strings.Join([]string{artShow.ShowSeq, time.Now().Format("06"), strconv.FormatInt(num, 10)}, "")
|
||||||
|
}
|
||||||
err = tx.Model(&model.ArtShow{}).Create(&artShow).Error
|
err = tx.Model(&model.ArtShow{}).Create(&artShow).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("ArtShow err", zap.Error(err))
|
zap.L().Error("ArtShow err", zap.Error(err))
|
||||||
@ -58,13 +67,9 @@ func ArtShowListWithRel(in *artShow.ShowListReq) (err error, total int64, out []
|
|||||||
queryDB.Where(" a.show_seq like ? ", "%"+in.ShowSeq+"%")
|
queryDB.Where(" a.show_seq like ? ", "%"+in.ShowSeq+"%")
|
||||||
countDB.Where(" a.show_seq like ? ", "%"+in.ShowSeq+"%")
|
countDB.Where(" a.show_seq like ? ", "%"+in.ShowSeq+"%")
|
||||||
}
|
}
|
||||||
if in.IsShow != 0 {
|
if in.StartShowTime != "" && in.EndShowTime != "" {
|
||||||
queryDB.Where(" a.is_show = ?", in.IsShow)
|
queryDB.Where("c.show_time between ? and ?", in.StartShowTime, in.EndShowTime)
|
||||||
countDB.Where(" a.is_show = ?", in.IsShow)
|
countDB.Where("c.show_time between ? and ?", in.StartShowTime, in.EndShowTime)
|
||||||
}
|
|
||||||
if in.StartTime != "" && in.EndTime != "" {
|
|
||||||
queryDB.Where("convert(a.create_time, date) between ? and ?", in.StartTime, in.EndTime)
|
|
||||||
countDB.Where("convert(a.create_time, date) between ? and ?", in.StartTime, in.EndTime)
|
|
||||||
}
|
}
|
||||||
if in.EndPrice != 0 {
|
if in.EndPrice != 0 {
|
||||||
queryDB.Where(" a.price between ? and ?", in.StartPrice, in.EndPrice)
|
queryDB.Where(" a.price between ? and ?", in.StartPrice, in.EndPrice)
|
||||||
@ -74,7 +79,14 @@ func ArtShowListWithRel(in *artShow.ShowListReq) (err error, total int64, out []
|
|||||||
queryDB.Where(" a.reward between ? and ?", in.StartReward, in.EndReward)
|
queryDB.Where(" a.reward between ? and ?", in.StartReward, in.EndReward)
|
||||||
countDB.Where(" a.reward between ? and ?", in.StartReward, in.EndReward)
|
countDB.Where(" a.reward between ? and ?", in.StartReward, in.EndReward)
|
||||||
}
|
}
|
||||||
|
if in.Address != "" {
|
||||||
|
queryDB.Where(" c.address like ?", "%"+in.Address+"%")
|
||||||
|
countDB.Where(" c.address like ?", "%"+in.Address+"%")
|
||||||
|
}
|
||||||
|
if len(in.IsShow) > 0 {
|
||||||
|
queryDB.Where(" a.is_show in ?", in.IsShow)
|
||||||
|
countDB.Where(" a.is_show in ?", in.IsShow)
|
||||||
|
}
|
||||||
//selectDb := queryDB
|
//selectDb := queryDB
|
||||||
//countDb := queryDB
|
//countDb := queryDB
|
||||||
|
|
||||||
@ -99,12 +111,12 @@ func ArtShowList(in *artShow.ShowListReq) (err error, total int64, out []*model.
|
|||||||
queryDB := db.DbArtShow.Model(&model.ArtShow{}).
|
queryDB := db.DbArtShow.Model(&model.ArtShow{}).
|
||||||
Select("show_uid, show_seq, show_name, artist_name, artist_uid, artwork_num, ruler, price, create_time, operator, is_show")
|
Select("show_uid, show_seq, show_name, artist_name, artist_uid, artwork_num, ruler, price, create_time, operator, is_show")
|
||||||
|
|
||||||
if in.IsShow != 0 {
|
if len(in.IsShow) > 0 {
|
||||||
queryDB.Where(" is_show = ?", in.IsShow)
|
queryDB.Where(" is_show in ?", in.IsShow)
|
||||||
}
|
|
||||||
if in.StartTime != "" && in.EndTime != "" {
|
|
||||||
queryDB.Where("convert(a.create_time, date) between ? and ?", in.StartTime, in.EndTime)
|
|
||||||
}
|
}
|
||||||
|
//if in.StartTime != "" && in.EndTime != "" {
|
||||||
|
// queryDB.Where("convert(a.create_time, date) between ? and ?", in.StartTime, in.EndTime)
|
||||||
|
//}
|
||||||
|
|
||||||
out = make([]*model.ArtShowRes, 0)
|
out = make([]*model.ArtShowRes, 0)
|
||||||
err = queryDB.Offset(int((in.Page - 1) * in.PageSize)).
|
err = queryDB.Offset(int((in.Page - 1) * in.PageSize)).
|
||||||
@ -134,7 +146,7 @@ func ArtShowList_apply(applyUID string) (err error, out []*model.ArtShowRes) {
|
|||||||
|
|
||||||
func ArtShowListByApplyStatus(in *artShow.ShowListReq) (err error, total int64, out []*model.ArtShowRes) {
|
func ArtShowListByApplyStatus(in *artShow.ShowListReq) (err error, total int64, out []*model.ArtShowRes) {
|
||||||
out = make([]*model.ArtShowRes, 0)
|
out = make([]*model.ArtShowRes, 0)
|
||||||
queryDB := db.DbArtShow.Table("art_show as a").Select("a.show_uid, a.show_seq, a.show_name, a.artist_name, a.artist_uid, a.artwork_num, a.ruler, a.price, a.create_time, a.is_show, b.address ,b.show_time").Joins(" left join show_rel as b on b.show_uid = a.show_uid").Where("a.is_show = ?", in.IsShow)
|
queryDB := db.DbArtShow.Table("art_show as a").Select("a.show_uid, a.show_seq, a.show_name, a.artist_name, a.artist_uid, a.artwork_num, a.ruler, a.price, a.create_time, a.is_show, b.address ,b.show_time").Joins(" left join show_rel as b on b.show_uid = a.show_uid").Where("a.is_show = ?", in.IsShow[len(in.IsShow)-1])
|
||||||
err = queryDB.Count(&total).Error
|
err = queryDB.Count(&total).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("ArtShowListByApplyStatus Count err", zap.Error(err))
|
zap.L().Error("ArtShowListByApplyStatus Count err", zap.Error(err))
|
||||||
@ -150,8 +162,8 @@ func ArtShowListByApplyStatus(in *artShow.ShowListReq) (err error, total int64,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func DelArtShow(tx *gorm.DB, show_uid string) (err error) {
|
func DelArtShow(tx *gorm.DB, showUid string) (err error) {
|
||||||
err = tx.Where("show_uid = ?", show_uid).Delete(&model.ArtShow{}).Error
|
err = tx.Where("show_uid = ?", showUid).Delete(&model.ArtShow{}).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("ArtShow delete err", zap.Error(err))
|
zap.L().Error("ArtShow delete err", zap.Error(err))
|
||||||
return
|
return
|
||||||
@ -159,9 +171,19 @@ func DelArtShow(tx *gorm.DB, show_uid string) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueryArtShow(show_uid []string) (err error, out []*model.ArtShowRes) {
|
func UniqueShowName(showName string) (out *model.ArtShowRes, err error) {
|
||||||
|
out = new(model.ArtShowRes)
|
||||||
|
err = db.DbArtShow.Table("art_show as a ").Select("a.show_uid").Joins("left join show_rel as b on a.show_uid = b.show_uid").Where("a.show_name = ?", showName).Find(&out).Error
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("ArtShow Find err", zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func QueryArtShow(showUids []string) (err error, out []*model.ArtShowRes) {
|
||||||
out = make([]*model.ArtShowRes, 0)
|
out = make([]*model.ArtShowRes, 0)
|
||||||
err = db.DbArtShow.Table("art_show as a ").Select("a.show_uid, a.show_seq, a.show_name, a.artist_name, a.artist_uid, a.artwork_num, a.ruler, a.price, a.create_time, a.operator,a.is_show, b.address ,b.show_time").Joins("left join show_rel as b on a.show_uid = b.show_uid").Where("a.show_uid in ?", show_uid).Find(&out).Error
|
err = db.DbArtShow.Table("art_show as a ").Select("a.show_uid, a.show_seq, a.show_name, a.artist_name, a.artist_uid, a.artwork_num, a.ruler, a.price, a.create_time, a.operator,a.is_show, b.address ,b.show_time").Joins("left join show_rel as b on a.show_uid = b.show_uid").Where("a.show_uid in ?", showUids).Find(&out).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("ArtShow Find err", zap.Error(err))
|
zap.L().Error("ArtShow Find err", zap.Error(err))
|
||||||
return
|
return
|
||||||
@ -226,3 +248,12 @@ func QueryArtShowForArtwork(in *artShow.ShowListForArtworkReq) (err error, total
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func countArtistNumInShowCurrentYear(artistUid string) (num int64) {
|
||||||
|
err := db.DbArtShow.Table("art_show").Where("artist_uid = ? and date_format(created_at,\"%Y\") = ? ", artistUid, time.Now().Format("2006")).Count(&num).Error
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
num = num + 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"fonchain-artshow/cmd/dao"
|
"fonchain-artshow/cmd/dao"
|
||||||
"fonchain-artshow/cmd/model"
|
"fonchain-artshow/cmd/model"
|
||||||
"fonchain-artshow/pb/artShow"
|
"fonchain-artshow/pb/artShow"
|
||||||
@ -15,6 +14,15 @@ import (
|
|||||||
func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showUID string) {
|
func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showUID string) {
|
||||||
artShowM := serializer.BuildArtShowM(in)
|
artShowM := serializer.BuildArtShowM(in)
|
||||||
|
|
||||||
|
out, err := dao.UniqueShowName(in.ShowName)
|
||||||
|
if err != nil {
|
||||||
|
return err, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if out.ShowUID != "" {
|
||||||
|
return errors.New(m.ERROR_SHOW_EXIST), ""
|
||||||
|
}
|
||||||
|
|
||||||
tx := db.DbArtShow.Begin()
|
tx := db.DbArtShow.Begin()
|
||||||
|
|
||||||
err = dao.SaveArtShow(tx, artShowM)
|
err = dao.SaveArtShow(tx, artShowM)
|
||||||
@ -32,7 +40,7 @@ func CreateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showUID
|
|||||||
err = dao.SaveArtworkPrice(tx, artworks[i])
|
err = dao.SaveArtworkPrice(tx, artworks[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return
|
return errors.New(m.ERROR_ARTWORK_CREATE), ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +57,7 @@ func UpdateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showUID
|
|||||||
artworks := make([]*model.ArtworkPrice, 0)
|
artworks := make([]*model.ArtworkPrice, 0)
|
||||||
|
|
||||||
// 查询是否已有画作存在
|
// 查询是否已有画作存在
|
||||||
err, artworkPrices := dao.ArtworkPriceList(in.ShowUID)
|
/*err, artworkPrices := dao.ArtworkPriceList(in.ShowUID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -57,12 +65,24 @@ func UpdateArtShowWithArtworkPrice(in *artShow.SaveShowReq) (err error, showUID
|
|||||||
|
|
||||||
if len(artworkPrices) > 0 {
|
if len(artworkPrices) > 0 {
|
||||||
artworks = append(artworks, artworkPrices...)
|
artworks = append(artworks, artworkPrices...)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// 判断是否有新增画作
|
// 判断是否有新增画作
|
||||||
if len(in.Artwork) > 0 {
|
if len(in.Artwork) > 0 {
|
||||||
showArtwork := serializer.BuildShowArtworkM(in.Artwork, in.ShowUID)
|
for i := 0; i < len(in.Artwork); i++ {
|
||||||
artworks = append(artworks, showArtwork...)
|
if in.Artwork[i].ArtworkPriceUID != "" {
|
||||||
|
queryErr, oldArtwork := dao.QueryArtworkPrice_uid(in.Artwork[i].ArtworkPriceUID)
|
||||||
|
if queryErr != nil {
|
||||||
|
return queryErr, ""
|
||||||
|
}
|
||||||
|
artworks = append(artworks, oldArtwork)
|
||||||
|
//fmt.Println("artworkPrices ==== ", oldArtwork)
|
||||||
|
} else {
|
||||||
|
newArtwork := serializer.BuildShowArtwork(in.Artwork[i], in.ShowUID)
|
||||||
|
artworks = append(artworks, newArtwork)
|
||||||
|
//fmt.Println("artworkPrices ==== ", newArtwork)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 画作
|
// 更新 画作
|
||||||
|
@ -11,14 +11,23 @@ mode = prod #正式prod #测试dev
|
|||||||
;DbPassWord = 123456
|
;DbPassWord = 123456
|
||||||
;DbName = art_show
|
;DbName = art_show
|
||||||
|
|
||||||
;正式服
|
;正式服 192.168.12.3
|
||||||
[mysql]
|
;[mysql]
|
||||||
Db = mysql
|
;Db = mysql
|
||||||
DbHost = mysql
|
;DbHost = mysql
|
||||||
DbPort = 3306
|
;DbPort = 3306
|
||||||
DbUser = root
|
;DbUser = root
|
||||||
DbPassWord = sLl0b7stlbwvZ883TV
|
;DbPassWord = sLl0b7stlbwvZ883TV
|
||||||
DbName = art_show
|
;DbName = art_show
|
||||||
|
|
||||||
|
;正式服 172.16.100.30
|
||||||
|
;[mysql]
|
||||||
|
;Db = mysql
|
||||||
|
;DbHost = 172.16.100.30
|
||||||
|
;DbPort = 3306
|
||||||
|
;DbUser = root
|
||||||
|
;DbPassWord = IhQmhg8HZjDmU=Ove5PnA^D
|
||||||
|
;DbName = art_show
|
||||||
|
|
||||||
;188
|
;188
|
||||||
;[mysql]
|
;[mysql]
|
||||||
@ -30,13 +39,14 @@ DbName = art_show
|
|||||||
;DbName = art_show
|
;DbName = art_show
|
||||||
|
|
||||||
;214
|
;214
|
||||||
;[mysql]
|
[mysql]
|
||||||
;Db = mysql
|
Db = mysql
|
||||||
;DbHost = 172.16.100.99 #214
|
;DbHost = 172.16.100.99 #214
|
||||||
;DbPort = 9007
|
DbHost = 172.16.39.93 #214
|
||||||
;DbUser = artuser
|
DbPort = 9007
|
||||||
;DbPassWord = "C250PflXIWv2SQm8"
|
DbUser = artuser
|
||||||
;DbName = art_show
|
DbPassWord = "C250PflXIWv2SQm8"
|
||||||
|
DbName = art_show
|
||||||
|
|
||||||
;[mysql]
|
;[mysql]
|
||||||
;Db = mysql
|
;Db = mysql
|
||||||
|
@ -3,8 +3,8 @@ dubbo:
|
|||||||
demoZK:
|
demoZK:
|
||||||
protocol: zookeeper
|
protocol: zookeeper
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
address: zookeeper:2181 # 正式服务
|
# address: zookeeper:2181 # 正式服务
|
||||||
# address: 127.0.0.1:2181 # 测试服务
|
address: 127.0.0.1:2181 # 测试服务
|
||||||
protocols:
|
protocols:
|
||||||
triple: #triple
|
triple: #triple
|
||||||
name: tri
|
name: tri
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,11 +37,12 @@ message SaveShowReq {
|
|||||||
int32 IsShow = 8 [json_name = "is_show"];
|
int32 IsShow = 8 [json_name = "is_show"];
|
||||||
string CreateTime = 9 [json_name = "create_time"];
|
string CreateTime = 9 [json_name = "create_time"];
|
||||||
string Operator = 10 [json_name = "operator"];
|
string Operator = 10 [json_name = "operator"];
|
||||||
|
string ShowSeq = 11 [json_name = "show_seq"];
|
||||||
|
|
||||||
string ShowUID = 11 [json_name = "id"];
|
string ShowUID = 12 [json_name = "id"];
|
||||||
|
|
||||||
repeated ArtworkDetail Artwork = 12 [json_name = "show_artwork"];
|
repeated ArtworkDetail Artwork = 13 [json_name = "show_artwork"];
|
||||||
repeated DelArtworkDetail DelArtwork = 13 [json_name = "del_show_artwork"];
|
repeated DelArtworkDetail DelArtwork = 14 [json_name = "del_show_artwork"];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +97,8 @@ message ShowListReq {
|
|||||||
int32 Page = 1 [json_name = "page"];
|
int32 Page = 1 [json_name = "page"];
|
||||||
int32 PageSize = 2 [json_name = "page_size"];
|
int32 PageSize = 2 [json_name = "page_size"];
|
||||||
|
|
||||||
string StartTime = 3 [json_name = "start_time"];
|
string StartShowTime = 3 [json_name = "start_show_time"];
|
||||||
string EndTime = 4 [json_name = "end_time"];
|
string EndShowTime = 4 [json_name = "end_show_time"];
|
||||||
string ShowSeq = 5 [json_name = "show_seq"];
|
string ShowSeq = 5 [json_name = "show_seq"];
|
||||||
string ShowName = 6 [json_name = "show_name"];
|
string ShowName = 6 [json_name = "show_name"];
|
||||||
string ArtistName = 7 [json_name = "artist_name"];
|
string ArtistName = 7 [json_name = "artist_name"];
|
||||||
@ -105,7 +106,8 @@ message ShowListReq {
|
|||||||
int64 EndPrice = 9 [json_name = "end_price"];
|
int64 EndPrice = 9 [json_name = "end_price"];
|
||||||
int64 StartReward = 10 [json_name = "start_reward"];
|
int64 StartReward = 10 [json_name = "start_reward"];
|
||||||
int64 EndReward = 11 [json_name = "end_reward"];
|
int64 EndReward = 11 [json_name = "end_reward"];
|
||||||
int32 IsShow = 12 [json_name = "is_show"];
|
string Address = 12 [json_name = "address"];
|
||||||
|
repeated int32 IsShow = 13 [json_name = "is_show"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message ShowListForArtworkReq {
|
message ShowListForArtworkReq {
|
||||||
|
@ -40,7 +40,7 @@ func Init(confPath string) {
|
|||||||
path := strings.Join([]string{DbUser, ":", DbPassWord, "@tcp(", DbHost, ":", DbPort, ")/", DbName, "?charset=utf8&parseTime=true"}, "")
|
path := strings.Join([]string{DbUser, ":", DbPassWord, "@tcp(", DbHost, ":", DbPort, ")/", DbName, "?charset=utf8&parseTime=true"}, "")
|
||||||
//连接数据库
|
//连接数据库
|
||||||
Database(path)
|
Database(path)
|
||||||
migration() //迁移表 按需打开
|
//migration() //迁移表 按需打开
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadMysqlData(file *ini.File) {
|
func LoadMysqlData(file *ini.File) {
|
||||||
|
@ -66,8 +66,10 @@ const (
|
|||||||
ERROR_CREATE = "创建失败"
|
ERROR_CREATE = "创建失败"
|
||||||
|
|
||||||
// 画展包创建错误
|
// 画展包创建错误
|
||||||
ERROR_SHOW_NAME = "画展包名缺失"
|
ERROR_SHOW_NAME = "画展包名缺失"
|
||||||
ERROR_TIME = "生成时间缺失"
|
ERROR_SHOW_EXIST = "画展包名已存在"
|
||||||
|
ERROR_ARTWORK_CREATE = "画展包画作创建失败"
|
||||||
|
ERROR_TIME = "生成时间缺失"
|
||||||
|
|
||||||
ERROR_INVALID_ID = "无效的记录ID"
|
ERROR_INVALID_ID = "无效的记录ID"
|
||||||
|
|
||||||
@ -78,4 +80,5 @@ const (
|
|||||||
ERROR_NUM = "数量错误"
|
ERROR_NUM = "数量错误"
|
||||||
|
|
||||||
ERROR_NOT_UPDATE_ISSHOW = "画展包已被使用"
|
ERROR_NOT_UPDATE_ISSHOW = "画展包已被使用"
|
||||||
|
ERROR_NOT_ARTIST_SEQ = "无效的画家编号"
|
||||||
)
|
)
|
||||||
|
@ -13,6 +13,7 @@ func BuildArtShowM(in *artShow.SaveShowReq) (out *model.ArtShow) {
|
|||||||
out.ShowName = in.ShowName
|
out.ShowName = in.ShowName
|
||||||
out.ArtistName = in.ArtistName
|
out.ArtistName = in.ArtistName
|
||||||
out.ArtistUID = in.ArtistUID
|
out.ArtistUID = in.ArtistUID
|
||||||
|
out.ShowSeq = in.ShowSeq
|
||||||
out.ArtworkNum = in.ArtworkNum
|
out.ArtworkNum = in.ArtworkNum
|
||||||
out.Price = in.Price
|
out.Price = in.Price
|
||||||
out.Ruler = in.Ruler
|
out.Ruler = in.Ruler
|
||||||
|
@ -27,6 +27,24 @@ func BuildShowArtworkM(in []*artShow.ArtworkDetail, showUID string) (out []*mode
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BuildShowArtwork(in *artShow.ArtworkDetail, showUID string) (out *model.ArtworkPrice) {
|
||||||
|
out = new(model.ArtworkPrice)
|
||||||
|
out.ArtworkUID = in.ArtworkUID
|
||||||
|
out.ArtworkName = in.ArtworkName
|
||||||
|
out.ArtistName = in.ArtistName
|
||||||
|
out.SmallPic = in.SmallPic
|
||||||
|
out.Ruler = in.Ruler
|
||||||
|
out.Length = in.Length
|
||||||
|
out.Width = in.Width
|
||||||
|
out.ArtworkPriceUID = in.ArtworkPriceUID
|
||||||
|
if showUID != "" {
|
||||||
|
out.ShowUID = showUID
|
||||||
|
} else {
|
||||||
|
out.ShowUID = in.ShowUID
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func BuildShowArtworkRpc(in []*model.ArtworkPrice) (out []*artShow.ArtworkDetail) {
|
func BuildShowArtworkRpc(in []*model.ArtworkPrice) (out []*artShow.ArtworkDetail) {
|
||||||
out = make([]*artShow.ArtworkDetail, len(in))
|
out = make([]*artShow.ArtworkDetail, len(in))
|
||||||
for i := 0; i < len(in); i++ {
|
for i := 0; i < len(in); i++ {
|
||||||
|
@ -39,7 +39,7 @@ func CalcPrice(total_price int64, total_ruler int32, artworksPrices []*model.Art
|
|||||||
|
|
||||||
maxId, dirId := findArtworkToAdd(artworksPrices, int64(price))
|
maxId, dirId := findArtworkToAdd(artworksPrices, int64(price))
|
||||||
|
|
||||||
if dirId >= 0 {
|
if dirId > -1 {
|
||||||
artworksPrices[dirId].Price = artworksPrices[dirId].Price + loss_total_price
|
artworksPrices[dirId].Price = artworksPrices[dirId].Price + loss_total_price
|
||||||
} else {
|
} else {
|
||||||
artworksPrices[maxId].Price = artworksPrices[maxId].Price + loss_total_price
|
artworksPrices[maxId].Price = artworksPrices[maxId].Price + loss_total_price
|
||||||
@ -60,7 +60,7 @@ func CalcPrice(total_price int64, total_ruler int32, artworksPrices []*model.Art
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dirId >= 0 {
|
if dirId > -1 {
|
||||||
artworksPrices[dirId].ArtworkPrice = artworksPrices[dirId].ArtworkPrice + loss_artwork_price
|
artworksPrices[dirId].ArtworkPrice = artworksPrices[dirId].ArtworkPrice + loss_artwork_price
|
||||||
} else {
|
} else {
|
||||||
artworksPrices[maxId].ArtworkPrice = artworksPrices[maxId].ArtworkPrice + loss_artwork_price
|
artworksPrices[maxId].ArtworkPrice = artworksPrices[maxId].ArtworkPrice + loss_artwork_price
|
||||||
@ -77,7 +77,7 @@ func CalcPrice(total_price int64, total_ruler int32, artworksPrices []*model.Art
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dirId >= 0 {
|
if dirId > -1 {
|
||||||
artworksPrices[dirId].CopyrightPrice = artworksPrices[dirId].CopyrightPrice + loss_copyright_price
|
artworksPrices[dirId].CopyrightPrice = artworksPrices[dirId].CopyrightPrice + loss_copyright_price
|
||||||
} else {
|
} else {
|
||||||
artworksPrices[maxId].CopyrightPrice = artworksPrices[maxId].CopyrightPrice + loss_copyright_price
|
artworksPrices[maxId].CopyrightPrice = artworksPrices[maxId].CopyrightPrice + loss_copyright_price
|
||||||
@ -141,6 +141,8 @@ func calcTotalPrice(artworks []*model.ArtworkPrice, add_balance, price int64) in
|
|||||||
artworks[i].Price = int64(add_balance_single)
|
artworks[i].Price = int64(add_balance_single)
|
||||||
artworks[i].Price += int64(artworks[i].Ruler) * price
|
artworks[i].Price += int64(artworks[i].Ruler) * price
|
||||||
|
|
||||||
|
artworks[i].RulerPrice = price
|
||||||
|
|
||||||
current_total_price += artworks[i].Price
|
current_total_price += artworks[i].Price
|
||||||
}
|
}
|
||||||
return current_total_price
|
return current_total_price
|
||||||
|
Loading…
Reference in New Issue
Block a user