1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package maintainance
- import (
- "context"
- "encoding/json"
- "fmt"
- "adm-vehicle-style/errors"
- "adm-vehicle-style/model"
- v1 "adm-vehicle-style/pb/v1"
- "git.getensh.com/common/gopkgsv2/database"
- "git.getensh.com/common/gopkgsv2/logger"
- "go.uber.org/zap"
- "google.golang.org/grpc/status"
- )
- func Delete(ctx context.Context, req *v1.DeleteMaintainaceRequest) (reply *v1.EmptyReply, err error) {
- reply = &v1.EmptyReply{}
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &status.Status{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- logger.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- if req.Id == 0 {
- return reply, errors.ParamsError
- }
- if err := model.NewMaintainDetailModel().Delete(database.DB().Where("id = ?", req.Id)); err != nil {
- return reply, errors.SystemError
- }
- return reply, nil
- }
|