作者 tangxuhui

数据结构更新

package command
import (
"fmt"
"strconv"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -12,13 +8,13 @@ type CreateDividendsOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//客户名称
CustomerName string `json:"customerName" valid:"Required"`
CustomerName string `json:"customerName"`
//分红订单原单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum" valid:"Required"`
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
//订单产生时间 时间戳 毫秒
OrderTime int64 `json:"orderTime" valid:"Required"`
OrderTime int64 `json:"orderTime"`
//备注
Remarks string `json:"remarks" valid:"Required"`
Remarks string `json:"remarks"`
//订单操作人uid
OperatorUid string `json:"operatorUid"`
//区域名称
... ... @@ -35,25 +31,25 @@ type CreateDividendsOrderCommand struct {
} `json:"orderGoods"`
}
func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) {
// 162 92522 89000
orderTimeStr := strconv.Itoa(int(createDividendsOrderCommand.OrderTime))
orderTimeStrRune := []rune(orderTimeStr)
if len(orderTimeStrRune) != 13 {
validation.AddError("订单产生时间", "格式错误")
}
}
// func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) {
// // 162 92522 89000
// orderTimeStr := strconv.Itoa(int(createDividendsOrderCommand.OrderTime))
// orderTimeStrRune := []rune(orderTimeStr)
// if len(orderTimeStrRune) != 13 {
// validation.AddError("订单产生时间", "格式错误")
// }
// }
func (createDividendsOrderCommand *CreateDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (createDividendsOrderCommand *CreateDividendsOrderCommand) ValidateCommand() error {
// valid := validation.Validation{}
// b, err := valid.Valid(createDividendsOrderCommand)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -11,23 +8,23 @@ type RemoveDividendsOrderCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单ID
DividendsOrderId []string `json:"dividendsOrderId" valid:"Required"`
DividendsOrderId []string `json:"dividendsOrderId"`
}
func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) Valid(validation *validation.Validation) {
// func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) Valid(validation *validation.Validation) {
}
// }
func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (removeDividendsOrderCommand *RemoveDividendsOrderCommand) ValidateCommand() error {
// valid := validation.Validation{}
// b, err := valid.Valid(removeDividendsOrderCommand)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
package command
import (
"fmt"
"strconv"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -14,15 +10,15 @@ type UpdateDividendsOrderCommand struct {
//分红订单
DividendsOrderID int `json:"dividendsOrderId"`
//客户名称
CustomerName string `json:"customerName" valid:"Required"`
CustomerName string `json:"customerName"`
//分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount" valid:"Required"`
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
//分红订单原单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum" valid:"Required"`
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
//订单产生时间 时间戳 毫秒
OrderTime int64 `json:"orderTime" valid:"Required"`
OrderTime int64 `json:"orderTime" `
//备注
Remarks string `json:"remarks" valid:"Required"`
Remarks string `json:"remarks"`
//区域名称
RegionName string `json:"regionName"`
//订单产品列表
... ... @@ -37,25 +33,25 @@ type UpdateDividendsOrderCommand struct {
} `json:"orderGoods"`
}
func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) {
// 162 92522 89000
orderTimeStr := strconv.Itoa(int(updateDividendsOrderCommand.OrderTime))
orderTimeStrRune := []rune(orderTimeStr)
if len(orderTimeStrRune) != 13 {
validation.AddError("订单产生时间", "格式错误")
}
}
// func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) {
// // 162 92522 89000
// orderTimeStr := strconv.Itoa(int(updateDividendsOrderCommand.OrderTime))
// orderTimeStrRune := []rune(orderTimeStr)
// if len(orderTimeStrRune) != 13 {
// validation.AddError("订单产生时间", "格式错误")
// }
// }
func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateDividendsOrderCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) ValidateCommand() error {
// valid := validation.Validation{}
// b, err := valid.Valid(updateDividendsOrderCommand)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -14,20 +11,20 @@ type GetDividendsOrderQuery struct {
DividendsOrderId int `json:"dividendsOrderId,string" valid:"Required"`
}
func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
// func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
}
// }
func (getDividendsOrderQuery *GetDividendsOrderQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getDividendsOrderQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (getDividendsOrderQuery *GetDividendsOrderQuery) ValidateQuery() error {
// valid := validation.Validation{}
// b, err := valid.Valid(getDividendsOrderQuery)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type ListDividendsOrdersQuery struct {
// 页码
PageNumber int `json:"pageNumber"`
... ... @@ -13,20 +7,20 @@ type ListDividendsOrdersQuery struct {
PageSize int `json:"pageSize"`
}
func (listDividendsOrdersQuery *ListDividendsOrdersQuery) Valid(validation *validation.Validation) {
// func (listDividendsOrdersQuery *ListDividendsOrdersQuery) Valid(validation *validation.Validation) {
}
// }
func (listDividendsOrdersQuery *ListDividendsOrdersQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listDividendsOrdersQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (listDividendsOrdersQuery *ListDividendsOrdersQuery) ValidateQuery() error {
// valid := validation.Validation{}
// b, err := valid.Valid(listDividendsOrdersQuery)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -20,20 +17,20 @@ type SearchDividendsOrderQuery struct {
PageSize int `json:"pageSize"`
}
func (searchDividendsOrderQuery *SearchDividendsOrderQuery) Valid(validation *validation.Validation) {
// func (searchDividendsOrderQuery *SearchDividendsOrderQuery) Valid(validation *validation.Validation) {
}
// }
func (searchDividendsOrderQuery *SearchDividendsOrderQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(searchDividendsOrderQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
// func (searchDividendsOrderQuery *SearchDividendsOrderQuery) ValidateQuery() error {
// valid := validation.Validation{}
// b, err := valid.Valid(searchDividendsOrderQuery)
// if err != nil {
// return err
// }
// if !b {
// for _, validErr := range valid.Errors {
// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
// }
// }
// return nil
// }
... ...
... ... @@ -16,9 +16,9 @@ type DividendsOrderService struct {
// 创建分红订单实体对象
func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createDividendsOrderCommand *command.CreateDividendsOrderCommand) (interface{}, error) {
if err := createDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
// if err := createDividendsOrderCommand.ValidateCommand(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
orderGoods := []allied_creation_cooperation.DividendsOrderGoodAdd{}
for _, v := range createDividendsOrderCommand.OrderGoods {
good := allied_creation_cooperation.DividendsOrderGoodAdd{
... ... @@ -53,9 +53,9 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
// 返回分红订单实体对象
func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividendsOrderQuery *query.GetDividendsOrderQuery) (interface{}, error) {
if err := getDividendsOrderQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
// if err := getDividendsOrderQuery.ValidateQuery(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getDividendsOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsOrderGet(allied_creation_cooperation.ReqDividendsOrderGet{
DividendsOrderId: getDividendsOrderQuery.DividendsOrderId,
... ... @@ -68,9 +68,9 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
// 移除分红订单实体对象
func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeDividendsOrderCommand *command.RemoveDividendsOrderCommand) (interface{}, error) {
if err := removeDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
// if err := removeDividendsOrderCommand.ValidateCommand(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsOrderCommand.Operator)
_, err := creationCooperationGateway.DividendsOrderBatchRemove(allied_creation_cooperation.ReqDividendsOrderBatchRemove{
... ... @@ -84,9 +84,9 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
// 查询分红订单方法
func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchDividendsOrderQuery *query.SearchDividendsOrderQuery) (int, interface{}, error) {
if err := searchDividendsOrderQuery.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
// if err := searchDividendsOrderQuery.ValidateQuery(); err != nil {
// return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(searchDividendsOrderQuery.Operator)
result, err := creationCooperationGateway.DividendsOrderSearch(allied_creation_cooperation.ReqDividendsOrderSearch{
PageNumber: searchDividendsOrderQuery.PageNumber,
... ... @@ -107,9 +107,9 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchD
// 更新分红订单实体对象
func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateDividendsOrderCommand *command.UpdateDividendsOrderCommand) (interface{}, error) {
if err := updateDividendsOrderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
// if err := updateDividendsOrderCommand.ValidateCommand(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
// }
orderGoods := []allied_creation_cooperation.DividendsOrderGoods{}
for _, v := range updateDividendsOrderCommand.OrderGoods {
good := allied_creation_cooperation.DividendsOrderGoods{
... ...