|
|
@@ -2,14 +2,11 @@ package base
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
-
|
|
|
- "github.com/gogf/gf/errors/gerror"
|
|
|
+ "dashoo.cn/opms_libary/myerrors"
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
"github.com/gogf/gf/util/gvalid"
|
|
|
|
|
|
"dashoo.cn/common_definition/comm_def"
|
|
|
- "dashoo.cn/opms_libary/myerrors"
|
|
|
-
|
|
|
projModel "dashoo.cn/micro/app/model/proj"
|
|
|
projSrv "dashoo.cn/micro/app/service/proj"
|
|
|
)
|
|
|
@@ -21,9 +18,7 @@ func (p *BusinessHandler) GetList(ctx context.Context, req *projModel.ProjBusine
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- g.Log().Info("搜索值", req)
|
|
|
total, list, err := businessService.GetList(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -34,16 +29,15 @@ func (p *BusinessHandler) GetList(ctx context.Context, req *projModel.ProjBusine
|
|
|
func (p *BusinessHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if req.Id == 0 {
|
|
|
- return gerror.New("参数有误!")
|
|
|
+ return myerrors.ValidError("id参数有误!")
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
rsp.Data, err = businessService.GetEntityById(req.Id)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.QueryError(err, "项目")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
@@ -51,14 +45,13 @@ func (p *BusinessHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq
|
|
|
func (p *BusinessHandler) GetBusinessProduct(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if req.Id == 0 {
|
|
|
- return gerror.New("参数有误!")
|
|
|
+ return myerrors.ValidError("项目参数有误!")
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
productList, err := businessService.GetBusinessProduct(req.Id)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -68,14 +61,13 @@ func (p *BusinessHandler) GetBusinessProduct(ctx context.Context, req *comm_def.
|
|
|
|
|
|
func (p *BusinessHandler) GetBusinessDynamics(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
|
|
|
if req.BusId == 0 {
|
|
|
- return gerror.New("参数为空,操作失败")
|
|
|
+ return myerrors.ValidError("项目参数有误!")
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
total, list, err := businessService.GetBusinessDynamics(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -85,14 +77,13 @@ func (p *BusinessHandler) GetBusinessDynamics(ctx context.Context, req *projMode
|
|
|
|
|
|
func (p *BusinessHandler) GetBusinessDynamicsList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
|
|
|
if req.BusId == 0 {
|
|
|
- return gerror.New("参数为空,操作失败")
|
|
|
+ return myerrors.ValidError("项目参数有误!")
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
total, list, err := businessService.GetBusinessDynamicsList(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -103,12 +94,12 @@ func (p *BusinessHandler) GetBusinessDynamicsList(ctx context.Context, req *proj
|
|
|
func (p *BusinessHandler) Create(ctx context.Context, req *projModel.AddProjBusinessReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
}
|
|
|
// 校验产品数据
|
|
|
for _, v := range req.Products {
|
|
|
if err := gvalid.CheckStruct(ctx, v, nil); err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
}
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
@@ -116,22 +107,24 @@ func (p *BusinessHandler) Create(ctx context.Context, req *projModel.AddProjBusi
|
|
|
return err
|
|
|
}
|
|
|
err = businessService.Create(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.CreateError(err, "项目")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (p *BusinessHandler) UpdateById(ctx context.Context, req *projModel.UpdateProjBusinessReq, rsp *comm_def.CommonMsg) error {
|
|
|
+ // 参数校验
|
|
|
+ if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
+ }
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
err = businessService.UpdateById(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.UpdateError(err, "项目")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
@@ -139,16 +132,15 @@ func (p *BusinessHandler) UpdateById(ctx context.Context, req *projModel.UpdateP
|
|
|
func (p *BusinessHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if len(req.Ids) == 0 {
|
|
|
- return gerror.New("参数为空,操作失败")
|
|
|
+ return myerrors.ValidError("id参数有误!")
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
err = businessService.DeleteByIds(req.Ids)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.DeleteError(err, "项目")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
@@ -157,14 +149,13 @@ func (p *BusinessHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq,
|
|
|
func (p *BusinessHandler) BusinessGradation(ctx context.Context, req *projModel.BusinessGradationReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
err = businessService.BusinessGradation(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -175,14 +166,13 @@ func (p *BusinessHandler) BusinessGradation(ctx context.Context, req *projModel.
|
|
|
func (p *BusinessHandler) BusinessTransfer(ctx context.Context, req *projModel.BusinessTransferReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
err = businessService.BusinessTransfer(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -193,14 +183,13 @@ func (p *BusinessHandler) BusinessTransfer(ctx context.Context, req *projModel.B
|
|
|
func (p *BusinessHandler) SetPrimacyContact(ctx context.Context, req *projModel.BusinessPrimacyContactReq, rsp *comm_def.CommonMsg) error {
|
|
|
// 参数校验
|
|
|
if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
|
|
|
- return err
|
|
|
+ return myerrors.ValidError(err.Error())
|
|
|
}
|
|
|
businessService, err := projSrv.NewBusinessService(ctx)
|
|
|
if err != nil {
|
|
|
- return gerror.New("系统异常,请重新尝试")
|
|
|
+ return err
|
|
|
}
|
|
|
err = businessService.SetPrimacyContact(req)
|
|
|
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|