task_list.go 873 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package task
  4. import (
  5. "adm-task/errors"
  6. "context"
  7. "fmt"
  8. "gorm.io/gorm"
  9. "git.getensh.com/common/gopkgsv2/database"
  10. pb_v1 "adm-task/pb/v1"
  11. )
  12. func GetTaskBySourceCode(ctx context.Context, req *pb_v1.GetTaskBySourceCodeRequest) (reply *pb_v1.GetTaskBySourceCodeReply, err error) {
  13. reply = &pb_v1.GetTaskBySourceCodeReply{}
  14. if req.SourceCode == "" {
  15. fmt.Println("参数错误,source code 为空")
  16. return reply, nil
  17. }
  18. reply = &pb_v1.GetTaskBySourceCodeReply{}
  19. err = database.DB().Raw("select task_id from t_adm_task_data_relation where is_on=1 and source_code=?", req.SourceCode).Find(&reply.TaskList).Error
  20. if err != nil {
  21. if err == gorm.ErrRecordNotFound {
  22. return reply, nil
  23. }
  24. return reply, errors.ServiceError
  25. }
  26. return reply, nil
  27. }