更新去重索引

This commit is contained in:
徐俊杰 2023-03-21 11:18:11 +08:00
parent 0876153953
commit c8696a969f
4 changed files with 69 additions and 41 deletions

View File

@ -1,32 +1,32 @@
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{}

View File

@ -4,14 +4,14 @@ package model
type StatementBatch struct {
Model
// StType int32 `gorm:"column:st_type;unqiueIndex:sttype_uid_batchtime_idx;comment:对账单类型 1=版权 2=物权;"`
ArtistUid string `gorm:"column:artist_uid;unqiueIndex:sttype_uid_batchtime_idx;comment:画家uid"`
// ArtistRealName string `gorm:"column:artist_real_name;comment:画家真实姓名;"`
ArtistUid string `gorm:"column:artist_uid;unqiueIndex:sttype_uid_batchtime_idx;comment:画家uid"`
ArtistName string `gorm:"column:artist_name;comment:画家姓名;"`
BatchTime string `gorm:"column:batch_time;unqiueIndex:sttype_uid_batchtime_idx;comment:批次时间;"`
FlowStatus int32 `gorm:"column:flow_status;default:1;comment:流程状态 1=未生成 2=已生成未签署 3=已签署"`
FileUrl string `gorm:"column:file_url,comment:对账单文件地址;"`
// FileUrl string `gorm:"column:file_url,comment:对账单文件地址;"`
EntrustList []ArtworkEntrustDetail `gorm:"foreignKey:BatchId"`
SalesList []ArtworkSalesDetail `gorm:"foreignKey:BatchId"`
EntrustList []ArtworkEntrustDetail `gorm:"foreignKey:BatchId"` //当前批次的委托单详情
SalesList []ArtworkSalesDetail `gorm:"foreignKey:BatchId"` //当前批次的销售单详情
}
func (StatementBatch) TableName() string {

View File

@ -3,9 +3,9 @@ package model
// User 用户模型
type User struct {
Model
MgmtAccId int64 `gorm:"column:mgmt_acc_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:账号id"`
MgmtArtistId int64 `gorm:"column:mgmt_artist_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:艺术家id"`
MgmtArtistUid string `gorm:"column:mgmt_artist_uid;type:varchar(256);comment:艺术家uid"`
MgmtAccId int64 `gorm:"column:mgmt_acc_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_uid;comment:账号id"`
MgmtArtistId int64 `gorm:"column:mgmt_artist_id;not null;comment:艺术家id"`
MgmtArtistUid string `gorm:"column:mgmt_artist_uid;type:varchar(256);uniqueIndex:mgmt_acc_mgmt_artist_uid;comment:艺术家uid"`
TelNum string `gorm:"column:tel_num;type:varchar(20);not null;电话号码"`
InviteCode string `gorm:"column:invited_code;type:varchar(16);default:'';comment:个人邀请码"`
InvitedBy *Invite `gorm:"foreignKey:InvitedId"` //邀请者的相关信息

View File

@ -8,7 +8,7 @@ import "google/protobuf/empty.proto"; //使用 google.protobuf.Empty
// protoc -I . -I ./pb --proto_path=. --go_out=./pb/artistinfoStatement --go-triple_out=./pb/artistinfoStatement --validate_out="lang=go:./pb/artistinfoStatement" ./pb/artistinfoStatement.proto
service Statement {
rpc CreateStatementBatch(StatementBatchRequest)returns(CreateStatementBatchResponse){}; //
rpc CreateOrUpdateStatementBatch(StatementBatchRequest)returns(CreateStatementBatchResponse){}; //
rpc BatchCreateStatementBatch(BatchCreateStatementBatchRequest)returns(google.protobuf.Empty){}; //
rpc GetStatementBatchList(GetStatementBatchListRequest)returns(GetStatementBatchListResponse){}; //
rpc GetStatementBatchTimeMenus(GetStatementBatchListRequest)returns(GetStatementBatchTimeMenusResponse){}; //
@ -24,19 +24,47 @@ message StatementPageInfo{
int64 total=3;
}
message StatementBatchRequest{
int32 stType=1; // cmd/model/artworkStatement.go
enum StatementCreateType{
saveEntrust=0;
saveSalse=1;
}
message StatementBatchRequest{ // cmd/model/artworkStatement.go
string artistUid=1;
string artistName=2;
string aatchTime=3;
int32 flowStatus=4;
StatementCreateType updateType=5;
repeated EntrustRequest entrustList=6;
repeated SalesRequest salesList=7;
}
message EntrustRequest{
string tfNum =1;
string artworkName =2;
string ruler =3;
string saleNo =4;
string completeDate =5;
float minPrice =6;
float guaranteePrice =7;
}
message SalesRequest {
string tfNum =1;
string artworkName =2;
string ruler =3;
string saleNo =4;
string completeDate =5;
}
message StatementBatchInfo{ // cmd/model/artworkStatement.go
// int32 stType=1;
string artistUid=2;
string artistRealName=3;
string artistName=3;
int32 flowStatus=4;
string batchTime=5;
float minPrice=6;
float guaranteePrice=7;
int64 id = 8;
string createdAt =9;
string updatedAt =10;
int64 deletedAt =11;
string fileUrl =12;
}
message CreateStatementBatchResponse{
int64 id =1;