schoolmeal

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 10 Imported by: 2

README

Schoolmeal

GoDoc Go Report Card

go get -u github.com/JedBeom/schoolmeal

교육청 API로 학교 급식과 학사 일정을 가져오는 Golang 패키지입니다.

Example

package main

import (
    "fmt"
    sm "github.com/JedBeom/schoolmeal"
    "time"
)

func main() {

    // 학교 정보를 가져온다
    school, err := sm.Find(sm.Seoul, "서울대학교사범대학부설고등학교")
    if err != nil {
        panic(err)
    }

    // 해당 학교의 일주일치 급식을 가져옴
    meals, err := school.GetWeekMeal(sm.Timestamp(time.Now()), sm.Lunch)
    if err != nil {
        panic(err)
    }

    // 수요일의 급식의 날짜와 급식 메뉴를 출력
    fmt.Println(meals[time.Wednesday].Date, meals[time.Wednesday].Content)
}

더 많은 정보는 godoc을 참고하세요.

Documentation

Overview

Package schoolmeal gets menu of Korean schools schoolmeal 패키지는 대한민국의 유치원, 초중고 학교의 급식을 크롤링한 결과를 리턴하는 함수를 제공합니다. 예제를 보고 싶으시면 이 패키지의 Github의 README.md를 봐 주세요.

Index

Constants

View Source
const (
	Breakfast = iota + 1 // 아침
	Lunch                // 점심
	Dinner               // 저녁
)

GetWeekMeal 함수의 mealType 인자에 사용하는 상수들입니다.

View Source
const (
	Kindergarten = iota + 1 // 유치원
	Elementary              // 초등학교
	Middle                  // 중학교
	High                    // 고등학교
)

School 구조체의 Code 필드에 사용할 수 있습니다.

View Source
const (
	Seoul     = "sen" // 서울특별시교육청
	Busan     = "pen" // 부산광역시교육청
	Daegu     = "dge" // 대구광역시교육청
	Incheon   = "ice" // 인천광역시교육청
	Gwangju   = "gen" // 광주광역시교육청
	Daejeon   = "dje" // 대전광역시교육청
	Ulsan     = "use" // 울산광역시교육청
	Sejong    = "sje" // 세종특별자치시교육청
	Gyeonggi  = "goe" // 경기도교육청
	Gangwon   = "gwe" // 강원도교육청
	Chungbuk  = "cbe" // 충청북도교육청
	Chungnam  = "cne" // 충남북도교육청
	Jeonbuk   = "jbe" // 전라북도교육청
	Jeonnam   = "jne" // 전라남도교육청
	Gyeongbuk = "kbe" // 경상북도교육청
	Geyongnam = "gne" // 경상남도교육청
	Jeju      = "jje" // 제주특별자치도교육청
)

School 구조체의 Zone 필드에 사용 가능합니다. 학교를 관할하는 교육청에 맞게 사용하면 됩니다.

Variables

This section is empty.

Functions

func Timestamp

func Timestamp(date time.Time) (stamp string)

Timestamp 함수는 GetWeekMeal 함수의 첫번째 인자로 쓰기 좋습니다. 인자로 받은 시간을 2018.11.18의 형태로 리턴합니다.

Types

type Meal

type Meal struct {
	DateString string    // 2018.11.30 형태의 타임스탬프
	Date       time.Time // parsed DateString

	Type    int    // 급식 종류
	People  int    // 몇 명이나 먹나요?
	Content string // 메뉴
}

Meal 구조체는 급식 정보를 저장합니다.

type Schedule added in v0.1.12

type Schedule struct {
	DateString string
	Date       time.Time
	Name       string
	Type       int // 0: 없음, 1: 공휴일, 2: 휴업일

	Grade1, Grade2, Grade3 bool
}

type School

type School struct {
	Name string // 학교 이름; GetWeekMeals()를 사용하기 위한 필수 필드는 아닙니다. Find() 사용 시 자동으로 채워집니다.
	Zone string // 학교를 관할하는 교육청
	Code string // 학교 코드
	Kind int    // 학교의 타입(유, 초, 중, 고)
	// contains filtered or unexported fields
}

School 구조체는 급식 정보를 얻어오기 위해 필요한 학교 정보들을 필드로 가집니다.

func Find

func Find(zone, schoolName string) (school School, err error)

Find 함수는 학교를 찾아 School을 리턴합니다. 여러 개의 학교가 찾아질 경우 첫번째 학교를 사용합니다.

func (School) GetDayMeal added in v0.1.5

func (s School) GetDayMeal(date string, mealType int) (m Meal, err error)

GetDayMeal 함수는 하루의 급식을 가져옵니다.

func (School) GetMonthMeal added in v0.1.9

func (s School) GetMonthMeal(year, month int) (monthMeals [][]Meal, err error)

GetMonthMeal 함수는 인자로 받은 연도와 달의 전체 급식을 리턴합니다. Meal[날짜-1][타입-1]

func (School) GetMonthSchedule added in v0.1.12

func (s School) GetMonthSchedule(year, month int) (schedules []Schedule, err error)

GetMonthSchedule 함수는 월별 일정을 가져옵니다.

func (School) GetWeekMeal

func (s School) GetWeekMeal(date string, mealType int) (meals []Meal, err error)

GetWeekMeal 함수는 인자로 받는 날짜가 포함된 주의 급식이 담긴 []Meal{}을 리턴합니다.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL