diff --git a/cmd/app.go b/cmd/app.go index 665b39d..4183fa3 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -21,7 +21,7 @@ func main() { config.SetProviderService(&controller.ArtistInfoArtworkProvider{}) config.SetProviderService(&controller.ArtistInfoArtshowProvider{}) config.SetProviderService(&controller.ArtistInfoContractProvider{}) - config.SetConsumerService(&controller.StatementServerProvider{}) + // config.SetConsumerService(&controller.StatementServerProvider{}) db.Init(m.SERVER_CONFIG) cache.InitRedis(m.SERVER_CONFIG) if err := config.Load(); err != nil { diff --git a/cmd/internal/controller/artistinfo_statement.go b/cmd/internal/controller/artistinfo_statement.go index 933a924..495832c 100644 --- a/cmd/internal/controller/artistinfo_statement.go +++ b/cmd/internal/controller/artistinfo_statement.go @@ -1,44 +1,44 @@ package controller -import ( - "context" +// import ( +// "context" - "github.com/fonchain/fonchain-artistinfo/cmd/internal/logic" - "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) +// "github.com/fonchain/fonchain-artistinfo/cmd/internal/logic" +// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" +// emptypb "google.golang.org/protobuf/types/known/emptypb" +// ) -//go:generate mockgen -destination .\artistinfoStatement_triple.pb.go -package controller -source ..\..\..\pb\artistinfoStatement\artistinfoStatement_triple.pb.go StatementServer +// //go:generate mockgen -destination .\artistinfoStatement_triple.pb.go -package controller -source ..\..\..\pb\artistinfoStatement\artistinfoStatement_triple.pb.go StatementServer -type StatementServerProvider struct { - artistinfoStatement.UnimplementedStatementServer - logic logic.StatementServerLogic -} +// type StatementServerProvider struct { +// artistinfoStatement.UnimplementedStatementServer +// logic logic.StatementServerLogic +// } -func (s *StatementServerProvider) CreateStatementBatch(ctx context.Context, in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) { - return s.logic.CreateStatementBatch(in) -} +// func (s *StatementServerProvider) CreateStatementBatch(ctx context.Context, in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) { +// return s.logic.CreateStatementBatch(in) +// } -func (s *StatementServerProvider) BatchCreateStatementBatch(ctx context.Context, in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) { - return s.logic.BatchCreateStatementBatch(in) -} +// func (s *StatementServerProvider) BatchCreateStatementBatch(ctx context.Context, in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) { +// return s.logic.BatchCreateStatementBatch(in) +// } -func (s *StatementServerProvider) GetStatementBatchList(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchListResponse, error) { - return s.logic.GetStatementBatchList(in) -} +// func (s *StatementServerProvider) GetStatementBatchList(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchListResponse, error) { +// return s.logic.GetStatementBatchList(in) +// } -func (s *StatementServerProvider) CreateStatementDetail(ctx context.Context, in *artistinfoStatement.StatementDetailRequest) (*artistinfoStatement.CreateStatementDetailResponse, error) { - return s.logic.CreateStatementDetail(in) -} +// func (s *StatementServerProvider) CreateStatementDetail(ctx context.Context, in *artistinfoStatement.StatementDetailRequest) (*artistinfoStatement.CreateStatementDetailResponse, error) { +// return s.logic.CreateStatementDetail(in) +// } -func (s *StatementServerProvider) BatchCreateStatementDetail(ctx context.Context, in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) { - return s.logic.BatchCreateStatementDetail(in) -} +// func (s *StatementServerProvider) BatchCreateStatementDetail(ctx context.Context, in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) { +// return s.logic.BatchCreateStatementDetail(in) +// } -func (s *StatementServerProvider) GetStatementDetailList(ctx context.Context, in *artistinfoStatement.GetStatementDetailListRequest) (*artistinfoStatement.GetStatementDetailListResponse, error) { - return s.logic.GetStatementDetailList(in) -} +// func (s *StatementServerProvider) GetStatementDetailList(ctx context.Context, in *artistinfoStatement.GetStatementDetailListRequest) (*artistinfoStatement.GetStatementDetailListResponse, error) { +// return s.logic.GetStatementDetailList(in) +// } -func (s *StatementServerProvider) GetStatementBatchTimeMenus(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchTimeMenusResponse, error) { - return s.logic.GetStatementBatchTimeMenus(in) -} +// func (s *StatementServerProvider) GetStatementBatchTimeMenus(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchTimeMenusResponse, error) { +// return s.logic.GetStatementBatchTimeMenus(in) +// } diff --git a/cmd/internal/dao/artistinfo_statement.go b/cmd/internal/dao/artistinfo_statement.go index 6b544cf..29a5de2 100644 --- a/cmd/internal/dao/artistinfo_statement.go +++ b/cmd/internal/dao/artistinfo_statement.go @@ -1,162 +1,162 @@ package dao -import ( - "github.com/fonchain/fonchain-artistinfo/cmd/model" - "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" - db "github.com/fonchain/fonchain-artistinfo/pkg/db" - "gorm.io/gorm/clause" -) - -// ===================================== +// import ( +// "github.com/fonchain/fonchain-artistinfo/cmd/model" +// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" +// db "github.com/fonchain/fonchain-artistinfo/pkg/db" +// "gorm.io/gorm/clause" +// ) // -// 对账单批次 -func CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res model.StatementBatch, err error) { - res = model.StatementBatch{ - StType: in.StType, - ArtistUid: in.ArtistUid, - ArtistRealName: in.ArtistRealName, - FlowStatus: in.FlowStatus, - BatchTime: in.BatchTime, - MinPrice: in.MinPrice, - GuaranteePrice: in.GuaranteePrice, - FileUrl: in.FileUrl, - } - err = db.DB.Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}}, - UpdateAll: true, - }).Create(&res).Error - return -} +// // ===================================== +// // +// // 对账单批次 +// func CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res model.StatementBatch, err error) { +// res = model.StatementBatch{ +// StType: in.StType, +// ArtistUid: in.ArtistUid, +// ArtistRealName: in.ArtistRealName, +// FlowStatus: in.FlowStatus, +// BatchTime: in.BatchTime, +// MinPrice: in.MinPrice, +// GuaranteePrice: in.GuaranteePrice, +// FileUrl: in.FileUrl, +// } +// err = db.DB.Clauses(clause.OnConflict{ +// Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}}, +// UpdateAll: true, +// }).Create(&res).Error +// return +// } -func BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) error { - var datas = []model.StatementBatch{} - for _, in := range in.Data { - datas = append(datas, model.StatementBatch{ - StType: in.StType, - ArtistUid: in.ArtistUid, - ArtistRealName: in.ArtistRealName, - FlowStatus: in.FlowStatus, - BatchTime: in.BatchTime, - MinPrice: in.MinPrice, - GuaranteePrice: in.GuaranteePrice, - FileUrl: in.FileUrl, - }) - } - err := db.DB.Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}}, - UpdateAll: true, - }).Create(&datas).Error - return err -} +// func BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) error { +// var datas = []model.StatementBatch{} +// for _, in := range in.Data { +// datas = append(datas, model.StatementBatch{ +// StType: in.StType, +// ArtistUid: in.ArtistUid, +// ArtistRealName: in.ArtistRealName, +// FlowStatus: in.FlowStatus, +// BatchTime: in.BatchTime, +// MinPrice: in.MinPrice, +// GuaranteePrice: in.GuaranteePrice, +// FileUrl: in.FileUrl, +// }) +// } +// err := db.DB.Clauses(clause.OnConflict{ +// Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}}, +// UpdateAll: true, +// }).Create(&datas).Error +// return err +// } -func GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res []model.StatementBatch, total int64, err error) { - res = []model.StatementBatch{} - var orm = db.DB.Model(model.StatementBatch{}).Order("created_at desc").Preload("ArtworkList") - if in.Condition.StType != 0 { - orm = orm.Where("st_type = ?", in.Condition.StType) - } - if in.Condition.ArtistUid != "" { - orm = orm.Where("artist_uid = ?", in.Condition.ArtistUid) - } - if in.Condition.ArtistRealName != "" { - orm = orm.Where("artist_real_name = ?", in.Condition.ArtistRealName) - } - if in.Condition.FlowStatus != 0 { - orm = orm.Where("flow_status = ?", in.Condition.FlowStatus) - } - if in.Condition.BatchTime != "" { - orm = orm.Where("batch_time = ?", in.Condition.BatchTime) - } - if in.Condition.MinPrice != 0 { - orm = orm.Where("min_price = ?", in.Condition.MinPrice) - } - if in.Condition.GuaranteePrice != 0 { - orm = orm.Where("guarantee_price = ?", in.Condition.GuaranteePrice) - } - if in.Condition.Id != 0 { - orm = orm.Where("id = ?", in.Condition.Id) - } - if in.Condition.FileUrl != "" { - orm = orm.Where("file_url = ?", in.Condition.FileUrl) - } - if len(in.Ids) > 0 { - orm = orm.Where("id in ?", in.Ids) - } - if len(in.BatchTimeList) > 0 { - orm = orm.Where("batch_time in ?", in.BatchTimeList) - } - err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error - return -} +// func GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res []model.StatementBatch, total int64, err error) { +// res = []model.StatementBatch{} +// var orm = db.DB.Model(model.StatementBatch{}).Order("created_at desc").Preload("ArtworkList") +// if in.Condition.StType != 0 { +// orm = orm.Where("st_type = ?", in.Condition.StType) +// } +// if in.Condition.ArtistUid != "" { +// orm = orm.Where("artist_uid = ?", in.Condition.ArtistUid) +// } +// if in.Condition.ArtistRealName != "" { +// orm = orm.Where("artist_real_name = ?", in.Condition.ArtistRealName) +// } +// if in.Condition.FlowStatus != 0 { +// orm = orm.Where("flow_status = ?", in.Condition.FlowStatus) +// } +// if in.Condition.BatchTime != "" { +// orm = orm.Where("batch_time = ?", in.Condition.BatchTime) +// } +// if in.Condition.MinPrice != 0 { +// orm = orm.Where("min_price = ?", in.Condition.MinPrice) +// } +// if in.Condition.GuaranteePrice != 0 { +// orm = orm.Where("guarantee_price = ?", in.Condition.GuaranteePrice) +// } +// if in.Condition.Id != 0 { +// orm = orm.Where("id = ?", in.Condition.Id) +// } +// if in.Condition.FileUrl != "" { +// orm = orm.Where("file_url = ?", in.Condition.FileUrl) +// } +// if len(in.Ids) > 0 { +// orm = orm.Where("id in ?", in.Ids) +// } +// if len(in.BatchTimeList) > 0 { +// orm = orm.Where("batch_time in ?", in.BatchTimeList) +// } +// err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error +// return +// } -func GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res []string, err error) { - res = []string{} - err = db.DB.Model(model.StatementBatch{}).Pluck("batch_time", &res).Error - return -} +// func GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res []string, err error) { +// res = []string{} +// err = db.DB.Model(model.StatementBatch{}).Pluck("batch_time", &res).Error +// return +// } -//===================================== -// 对账单详情 +// //===================================== +// // 对账单详情 -func CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res model.StatementDetail, err error) { - res = model.StatementDetail{ - BatchId: in.BatchId, - TfNum: in.TfNum, - ArtworkName: in.ArtworkName, - Ruler: in.Ruler, - SaleNo: in.SaleNo, - CompleteDate: in.CompleteDate, - } - err = db.DB.Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}}, - UpdateAll: true, - }).Create(&res).Error - return -} +// func CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res model.StatementDetail, err error) { +// res = model.StatementDetail{ +// BatchId: in.BatchId, +// TfNum: in.TfNum, +// ArtworkName: in.ArtworkName, +// Ruler: in.Ruler, +// SaleNo: in.SaleNo, +// CompleteDate: in.CompleteDate, +// } +// err = db.DB.Clauses(clause.OnConflict{ +// Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}}, +// UpdateAll: true, +// }).Create(&res).Error +// return +// } -func BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) error { - var datas = []model.StatementDetail{} - for _, in := range in.Data { - datas = append(datas, model.StatementDetail{ - BatchId: in.BatchId, - TfNum: in.TfNum, - ArtworkName: in.ArtworkName, - Ruler: in.Ruler, - SaleNo: in.SaleNo, - CompleteDate: in.CompleteDate, - }) - } - err := db.DB.Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}}, - UpdateAll: true, - }).Create(&datas).Error - return err -} +// func BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) error { +// var datas = []model.StatementDetail{} +// for _, in := range in.Data { +// datas = append(datas, model.StatementDetail{ +// BatchId: in.BatchId, +// TfNum: in.TfNum, +// ArtworkName: in.ArtworkName, +// Ruler: in.Ruler, +// SaleNo: in.SaleNo, +// CompleteDate: in.CompleteDate, +// }) +// } +// err := db.DB.Clauses(clause.OnConflict{ +// Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}}, +// UpdateAll: true, +// }).Create(&datas).Error +// return err +// } -func GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res []model.StatementDetail, total int64, err error) { - res = []model.StatementDetail{} - var orm = db.DB.Model(model.StatementDetail{}).Order("created_at desc") - if in.Condition.BatchId != 0 { - orm = orm.Where("batch_id = ?", in.Condition.BatchId) - } - if in.Condition.TfNum != "" { - orm = orm.Where("tf_num = ?", in.Condition.TfNum) - } - if in.Condition.ArtworkName != "" { - orm = orm.Where("artwork_name like = ?", "%"+in.Condition.ArtworkName+"%") - } - if in.Condition.Ruler != "" { - orm = orm.Where("ruler = ?", in.Condition.Ruler) - } - if in.Condition.SaleNo != "" { - orm = orm.Where("sale_no = ?", in.Condition.SaleNo) - } - if in.Condition.CompleteDate != "" { - orm = orm.Where("complete_date = ?", in.Condition.CompleteDate) - } - if in.Condition.Id != 0 { - orm = orm.Where("id = ?", in.Condition.Id) - } - err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error - return -} +// func GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res []model.StatementDetail, total int64, err error) { +// res = []model.StatementDetail{} +// var orm = db.DB.Model(model.StatementDetail{}).Order("created_at desc") +// if in.Condition.BatchId != 0 { +// orm = orm.Where("batch_id = ?", in.Condition.BatchId) +// } +// if in.Condition.TfNum != "" { +// orm = orm.Where("tf_num = ?", in.Condition.TfNum) +// } +// if in.Condition.ArtworkName != "" { +// orm = orm.Where("artwork_name like = ?", "%"+in.Condition.ArtworkName+"%") +// } +// if in.Condition.Ruler != "" { +// orm = orm.Where("ruler = ?", in.Condition.Ruler) +// } +// if in.Condition.SaleNo != "" { +// orm = orm.Where("sale_no = ?", in.Condition.SaleNo) +// } +// if in.Condition.CompleteDate != "" { +// orm = orm.Where("complete_date = ?", in.Condition.CompleteDate) +// } +// if in.Condition.Id != 0 { +// orm = orm.Where("id = ?", in.Condition.Id) +// } +// err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error +// return +// } diff --git a/cmd/internal/logic/artistinfo_statement.go b/cmd/internal/logic/artistinfo_statement.go index 224fd75..9725855 100644 --- a/cmd/internal/logic/artistinfo_statement.go +++ b/cmd/internal/logic/artistinfo_statement.go @@ -1,95 +1,95 @@ package logic -import ( - "github.com/fonchain/fonchain-artistinfo/cmd/internal/dao" - "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" - "github.com/fonchain/fonchain-artistinfo/pkg/util/stime" - "google.golang.org/protobuf/types/known/emptypb" -) +// import ( +// "github.com/fonchain/fonchain-artistinfo/cmd/internal/dao" +// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" +// "github.com/fonchain/fonchain-artistinfo/pkg/util/stime" +// "google.golang.org/protobuf/types/known/emptypb" +// ) -type StatementServerLogic struct{} +// type StatementServerLogic struct{} -func (s *StatementServerLogic) CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) { - res = &artistinfoStatement.CreateStatementBatchResponse{} - data, err := dao.CreateStatementBatch(in) - res.Id = data.ID - return -} +// func (s *StatementServerLogic) CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) { +// res = &artistinfoStatement.CreateStatementBatchResponse{} +// data, err := dao.CreateStatementBatch(in) +// res.Id = data.ID +// return +// } -func (s *StatementServerLogic) BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) { - return nil, dao.BatchCreateStatementBatch(in) -} +// func (s *StatementServerLogic) BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) { +// return nil, dao.BatchCreateStatementBatch(in) +// } -func (s *StatementServerLogic) GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchListResponse, err error) { - datas, total, err := dao.GetStatementBatchList(in) +// func (s *StatementServerLogic) GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchListResponse, err error) { +// datas, total, err := dao.GetStatementBatchList(in) - res = &artistinfoStatement.GetStatementBatchListResponse{ - Page: &artistinfoStatement.StatementPageInfo{ - Page: in.Page, - PageSize: in.PageSize, - Total: total, - }, - Data: []*artistinfoStatement.StatementBatchRequest{}, - } - for _, v := range datas { - res.Data = append(res.Data, &artistinfoStatement.StatementBatchRequest{ - StType: v.StType, - ArtistUid: v.ArtistUid, - ArtistRealName: v.ArtistRealName, - FlowStatus: v.FlowStatus, - BatchTime: v.BatchTime, - MinPrice: v.MinPrice, - GuaranteePrice: v.GuaranteePrice, - Id: v.ID, - CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms), - UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms), - DeletedAt: int64(v.DeletedAt), - FileUrl: v.FileUrl, - }) - } - return -} +// res = &artistinfoStatement.GetStatementBatchListResponse{ +// Page: &artistinfoStatement.StatementPageInfo{ +// Page: in.Page, +// PageSize: in.PageSize, +// Total: total, +// }, +// Data: []*artistinfoStatement.StatementBatchRequest{}, +// } +// for _, v := range datas { +// res.Data = append(res.Data, &artistinfoStatement.StatementBatchRequest{ +// StType: v.StType, +// ArtistUid: v.ArtistUid, +// ArtistRealName: v.ArtistRealName, +// FlowStatus: v.FlowStatus, +// BatchTime: v.BatchTime, +// MinPrice: v.MinPrice, +// GuaranteePrice: v.GuaranteePrice, +// Id: v.ID, +// CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms), +// UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms), +// DeletedAt: int64(v.DeletedAt), +// FileUrl: v.FileUrl, +// }) +// } +// return +// } -func (s *StatementServerLogic) CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res *artistinfoStatement.CreateStatementDetailResponse, err error) { - res = &artistinfoStatement.CreateStatementDetailResponse{} - data, err := dao.CreateStatementDetail(in) - res.Id = data.ID - return -} +// func (s *StatementServerLogic) CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res *artistinfoStatement.CreateStatementDetailResponse, err error) { +// res = &artistinfoStatement.CreateStatementDetailResponse{} +// data, err := dao.CreateStatementDetail(in) +// res.Id = data.ID +// return +// } -func (s *StatementServerLogic) BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) { - return nil, dao.BatchCreateStatementDetail(in) -} +// func (s *StatementServerLogic) BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) { +// return nil, dao.BatchCreateStatementDetail(in) +// } -func (s *StatementServerLogic) GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res *artistinfoStatement.GetStatementDetailListResponse, err error) { - datas, total, err := dao.GetStatementDetailList(in) - res = &artistinfoStatement.GetStatementDetailListResponse{ - Data: []*artistinfoStatement.StatementDetailRequest{}, - Page: &artistinfoStatement.StatementPageInfo{ - Page: in.Page, - PageSize: in.PageSize, - Total: total, - }, - } - for _, v := range datas { - res.Data = append(res.Data, &artistinfoStatement.StatementDetailRequest{ - BatchId: v.BatchId, - TfNum: v.TfNum, - ArtworkName: v.ArtworkName, - Ruler: v.Ruler, - SaleNo: v.SaleNo, - CompleteDate: v.CompleteDate, - Id: v.ID, - CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms), - UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms), - DeletedAt: int64(v.DeletedAt), - }) - } - return -} +// func (s *StatementServerLogic) GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res *artistinfoStatement.GetStatementDetailListResponse, err error) { +// datas, total, err := dao.GetStatementDetailList(in) +// res = &artistinfoStatement.GetStatementDetailListResponse{ +// Data: []*artistinfoStatement.StatementDetailRequest{}, +// Page: &artistinfoStatement.StatementPageInfo{ +// Page: in.Page, +// PageSize: in.PageSize, +// Total: total, +// }, +// } +// for _, v := range datas { +// res.Data = append(res.Data, &artistinfoStatement.StatementDetailRequest{ +// BatchId: v.BatchId, +// TfNum: v.TfNum, +// ArtworkName: v.ArtworkName, +// Ruler: v.Ruler, +// SaleNo: v.SaleNo, +// CompleteDate: v.CompleteDate, +// Id: v.ID, +// CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms), +// UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms), +// DeletedAt: int64(v.DeletedAt), +// }) +// } +// return +// } -func (s *StatementServerLogic) GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchTimeMenusResponse, err error) { - res = &artistinfoStatement.GetStatementBatchTimeMenusResponse{} - res.Data, err = dao.GetStatementBatchTimeMenus(in) - return -} +// func (s *StatementServerLogic) GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchTimeMenusResponse, err error) { +// res = &artistinfoStatement.GetStatementBatchTimeMenusResponse{} +// res.Data, err = dao.GetStatementBatchTimeMenus(in) +// return +// } diff --git a/pkg/common/filter/domain.go b/pkg/common/filter/domain.go new file mode 100644 index 0000000..61d9ef2 --- /dev/null +++ b/pkg/common/filter/domain.go @@ -0,0 +1,38 @@ +package filter + +import ( + "context" + + "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/filter" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +func init() { + extension.SetFilter("fonDomainFilter", NewDomainFonFilter) +} + +func NewDomainFonFilter() filter.Filter { + return &DomainFonFilter{} +} + +type DomainFonFilter struct { +} + +func (f *DomainFonFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + // if len(invocation.Arguments()) > 0 { + // req := invocation.Arguments()[0] + // pp := reflect.ValueOf(req) + // field := pp.Elem().FieldByName("Domain") + + // if field.IsValid() && field.String() == "" { + // field.SetString(config.Domain) + // } + // } + + return invoker.Invoke(ctx, invocation) +} + +func (f *DomainFonFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, protocol protocol.Invocation) protocol.Result { + return result +} diff --git a/pkg/common/filter/validate.go b/pkg/common/filter/validate.go new file mode 100644 index 0000000..9b203b3 --- /dev/null +++ b/pkg/common/filter/validate.go @@ -0,0 +1,51 @@ +package filter + +import ( + "context" + "regexp" + "strconv" + + "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/filter" + "dubbo.apache.org/dubbo-go/v3/protocol" + perrors "github.com/pkg/errors" +) + +type validator interface { + Validate() error +} + +func init() { + extension.SetFilter("fonValidateFilter", NewClientFonValidateFilter) +} + +func NewClientFonValidateFilter() filter.Filter { + return &ClientFonValidateFilter{} +} + +type ClientFonValidateFilter struct { +} + +func (f *ClientFonValidateFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + + if len(invocation.Arguments()) > 0 { + if v, ok := invocation.Arguments()[0].(validator); ok { + if err := v.Validate(); err != nil { + errMsg := err.Error() + re3, _ := regexp.Compile(`^invalid(.*): `) + rep := re3.ReplaceAllString(errMsg, "") + if errCode, err := strconv.ParseInt(rep, 10, 64); err == nil { + return &protocol.RPCResult{Err: perrors.Errorf("%v", int(errCode))} + } + + return &protocol.RPCResult{Err: perrors.Errorf("%v", rep)} + } + } + } + + return invoker.Invoke(ctx, invocation) +} + +func (f *ClientFonValidateFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, protocol protocol.Invocation) protocol.Result { + return result +} diff --git a/pkg/db/init.go b/pkg/db/init.go index 544bb30..1e4dac8 100644 --- a/pkg/db/init.go +++ b/pkg/db/init.go @@ -124,7 +124,8 @@ func migration() { &model.ArtshowArtistSupplement{}, //画展-画家补充信息 &model.Contract{}, //合同 &model.StatementBatch{}, //对账单批次 - &model.StatementDetail{}, //对账单详情 + &model.ArtworkEntrustDetail{}, // + &model.ArtworkSalesDetail{}, // ) if err != nil { fmt.Println("register table fail") diff --git a/pkg/service/init.go b/pkg/service/init.go index 1cae9b1..f2ef451 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -9,6 +9,7 @@ import ( "github.com/fonchain/fonchain-artistinfo/pb/account" "github.com/fonchain/fonchain-artistinfo/pb/artist" contractMicroservice "github.com/fonchain/fonchain-artistinfo/pb/contract_microservice" + _ "github.com/fonchain/fonchain-artistinfo/pkg/common/filter" ) var (