selection_service.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package selection
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/gogf/gf/frame/g"
  6. "github.com/gogf/gf/net/ghttp"
  7. "youngmini_server/app/dao"
  8. )
  9. var service = new(selectionService)
  10. type selectionService struct {
  11. }
  12. func (s *selectionService) List(r *ghttp.Request) (res ListSelectionRes, err error) {
  13. err = dao.YounggeeAssignmentInfo.Ctx(r.GetCtx()).Scan(&res.SelectionList)
  14. if err != nil {
  15. return
  16. }
  17. return
  18. }
  19. func GetDetailBySelectionId(ctx context.Context, selectionId string) (res ListSelectionSql, err error) {
  20. whereCondition := g.Map{
  21. dao.YounggeeSelectionInfo.Columns.SelectionId: selectionId,
  22. }
  23. err = dao.YounggeeSelectionInfo.Ctx(ctx).Where(whereCondition).Scan(&res)
  24. if err != nil {
  25. return
  26. }
  27. return
  28. }
  29. func GetDetailByTaskId(ctx context.Context, taskId string) (res ListSelectionSql, err error) {
  30. var selectionId interface{}
  31. whereCondition := g.Map{
  32. dao.YounggeeSecTaskInfo.Columns.TaskId: taskId,
  33. }
  34. selectionId, err = dao.YounggeeSecTaskInfo.Ctx(ctx).Fields(dao.YounggeeSecTaskInfo.Columns.SelectionId).Where(whereCondition).Value()
  35. if err != nil {
  36. return
  37. }
  38. whereCondition = g.Map{
  39. dao.YounggeeSelectionInfo.Columns.SelectionId: selectionId,
  40. }
  41. fmt.Println("selectionId: ", selectionId)
  42. err = dao.YounggeeSelectionInfo.Ctx(ctx).Where(whereCondition).Scan(&res)
  43. if err != nil {
  44. return
  45. }
  46. return
  47. }