| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package base
- import (
- "context"
- "dashoo.cn/common_definition/comm_def"
- "dashoo.cn/opms_libary/myerrors"
- "github.com/gogf/gf/errors/gerror"
- "github.com/gogf/gf/util/gvalid"
- projModel "dashoo.cn/micro/app/model/proj"
- projSrv "dashoo.cn/micro/app/service/proj"
- )
- type BusinessContactHandler struct{}
- func (p *BusinessContactHandler) GetList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
- if req.BusId == 0 {
- return gerror.New("参数为空,操作失败")
- }
- contactService, err := projSrv.NewBusinessContactService(ctx)
- if err != nil {
- return err
- }
- list, err := contactService.GetList(req)
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Data = list
- return nil
- }
- func (p *BusinessContactHandler) Create(ctx context.Context, req *projModel.BusinessContactReq, rsp *comm_def.CommonMsg) error {
- // 参数校验
- if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
- return err
- }
- contactService, err := projSrv.NewBusinessContactService(ctx)
- if err != nil {
- return err
- }
- err = contactService.Create(req)
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
- if err != nil {
- return err
- }
- return nil
- }
- func (p *BusinessContactHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq, rsp *comm_def.CommonMsg) error {
- // 参数校验
- if len(req.Ids) == 0 {
- return gerror.New("参数为空,操作失败")
- }
- contactService, err := projSrv.NewBusinessContactService(ctx)
- if err != nil {
- return gerror.New("系统异常,请重新尝试")
- }
- err = contactService.DeleteByIds(req.Ids)
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
- return err
- }
|