初始化项目文件

This commit is contained in:
2025-07-11 16:54:11 +08:00
parent 6bffd582a0
commit 39fedaac16
213 changed files with 16944 additions and 0 deletions

34
api_iris/utils/sudoku.go Normal file
View File

@ -0,0 +1,34 @@
package utils
import (
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
"io"
"net/http"
"net/url"
)
func CheckSudoku(sudoku string) (error, ResSudoku) {
resp, err := http.Get(fmt.Sprintf("https://git-ylsa0.cn/api_ylsa/get_sudoku_check/?sudoku=%s", url.QueryEscape(sudoku)))
if err != nil {
logrus.Errorln("请求get_sudoku_check接口失败", err)
return err, ResSudoku{}
}
defer func(Body io.ReadCloser) {
err = Body.Close()
if err != nil {
logrus.Errorln(err.Error())
}
}(resp.Body)
body, _ := io.ReadAll(resp.Body)
var r ResSudoku
//解析json结构
err = json.Unmarshal(body, &r)
if err != nil {
logrus.Errorln("请求结果json解析失败", err)
return err, ResSudoku{}
}
logrus.Infoln("数独检查完成")
return nil, r
}