46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package smithy
|
|
|
|
import (
|
|
"errors"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SmithyRefuseReq) (errdata *pb.ErrorData) {
|
|
if req.CustomerId == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SmithyRefuseReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.RefuseCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
cus, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
|
|
if err != nil {
|
|
var errCustom = new(comm.CustomError)
|
|
if errors.As(err, &errCustom) {
|
|
this.module.Debug(errCustom.Code.String())
|
|
} else {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
resp := &pb.SmithyRefuseResp{
|
|
Customers: cus.Customers,
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "refuse", resp)
|
|
return
|
|
}
|