| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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/frame/g"
- "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
- }
- total, list, err := contactService.GetList(req)
- _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Data = g.Map{"list": list, "total": total}
- 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
- }
|