Skip to content

Commit

Permalink
第一次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
paterleng committed Sep 9, 2023
1 parent 9aa937e commit f5f1986
Show file tree
Hide file tree
Showing 58 changed files with 5,190 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
# 屏蔽所有的.log文件
*.log
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/enjoy-research.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added .keep
Empty file.
1 change: 0 additions & 1 deletion 123

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM centos:7.9.2009
ENV MYPATH /enjoy-research
WORKDIR $MYPATH
RUN yum -y update \
&& yum -y install vim \
&& yum -y install git \
&& yum install -y gcc-c++ \
&& yum -y install wget \
&& wget -P /root/ https://studygolang.com/dl/golang/go1.17.11.linux-amd64.tar.gz \
&& tar -zxvf /root/go1.17.11.linux-amd64.tar.gz -C /usr/local \
&& echo export PATH=$PATH:/usr/local/go/bin >> /etc/profile \
&& source /etc/profile && go version \
&& echo "source /etc/profile" >> /root/.bashrc \
&& go env -w GOPROXY=https://goproxy.cn,direct \
&& go env -w GO111MODULE=on \
Binary file added a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project:
name: "项目名称"
mode: "dev"
port: 端口
start: "创建时间"
log:
level: "日志水平"
filename: "日志文件名"
max_size: 200
max_age: 30
max_backups: 7
mysql:
host: "IP"
port: 端口
user: "用户名"
password: "密码"
dbname: "数据库"
max_open_conns: 200
max_idle_conns: 50
redis:
db: redis仓库
host: IP:端口
password: "密码"
#阿里云oss配置
oss:
end_point: ""
access_key_id : ""
access_key_secret: ""
bucket_name: ""
base_path: ""
rabbitMQ:
username: 用户名
password: 密码
host: IP
post: 端口

149 changes: 149 additions & 0 deletions controller/address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package controller

import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"strconv"
"web_app/dao/mysql"
"web_app/model"
)

// 查找所有省
func SearchProvince(c *gin.Context) {
//直接去查数据库
province, err := mysql.SearchProvince()
if err != nil {
zap.L().Error("查询省出错了", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
//成功返回省的信息
ResponseSuccess(c, province)
}

// 查找所有市
func SearchCity(c *gin.Context) {
province, _ := strconv.Atoi(c.Query("provinceid"))
provinceid := uint(province)
citys, err := mysql.SearchCity(provinceid)
if err != nil {
zap.L().Error("查询市失败", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
ResponseSuccess(c, citys)

}

// 查找市下面的学校
func SearchSchool(c *gin.Context) {
city, _ := strconv.Atoi(c.Query("cityid"))
cityid := uint(city)
citys, err := mysql.SearchSchool(cityid)
if err != nil {
zap.L().Error("查询学校失败", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
ResponseSuccess(c, citys)
}

func SearchAcademies(c *gin.Context) {
school, _ := strconv.Atoi(c.Query("schoolid"))
schoolid := uint(school)
academies, err := mysql.SearchAcademies(schoolid)
if err != nil {
zap.L().Error("查询专业失败", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
ResponseSuccess(c, academies)
}

//查询所有的地址
func SelectAllAddress(c *gin.Context) {
err, address := mysql.SelectAllAddress()
if err != nil {
zap.L().Error("查询所有地址", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
ResponseSuccess(c, address)
}

//模糊查询学校
func SelectLikeSchool(c *gin.Context) {

}

//根据学校id查询该学校下面所有专业
func SelectMajorBySchool(c *gin.Context) {
id := c.Query("id")
ids, err := strconv.Atoi(id)
if err != nil {
zap.L().Error("查询学校下所有专业失败", zap.Error(err))
ResponseErrorWithMsg(c, CodeServerBusy, "参数错误")
return
}
var academies []model.Academy
var academiesid []uint
err = mysql.DB.Where("school_id", ids).Find(&academies).Error
if err != nil {
zap.L().Error("查询学校下所有专业失败", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
for _, academy := range academies {
academiesid = append(academiesid, academy.ID)
}
//去查学院下面的各个专业
var majors []model.Major
err = mysql.DB.Where("academy_id IN ?", academiesid).Find(&majors).Error
if err != nil {
zap.L().Error("查询学校下所有专业失败", zap.Error(err))
ResponseError(c, CodeServerBusy)
return
}
ResponseSuccess(c, majors)
}

//根据学院id查询学院下专业
func SelectMajorByAcademyId(c *gin.Context) {
id := c.Query("id")
academyid, err := strconv.Atoi(id)
if err != nil {
zap.L().Error("查询学院下所有专业失败", zap.Error(err))
ResponseErrorWithMsg(c, CodeServerBusy, "参数错误")
return
}
var p *[]model.Major
err = mysql.DB.Where("academy_id", academyid).Find(&p).Error
if err != nil {
zap.L().Error("查询专业下所有科目失败", zap.Error(err))
ResponseErrorWithMsg(c, CodeServerBusy, "查询失败")
return
}
ResponseSuccess(c, p)
}

//根据专业id查询考试科目
func SeleteSubjectByAcademiyid(c *gin.Context) {
id := c.Query("id")
marjorid, err := strconv.Atoi(id)
if err != nil {
zap.L().Error("查询专业下所有科目失败", zap.Error(err))
ResponseErrorWithMsg(c, CodeServerBusy, "参数错误")
return
}
var p model.Major
p.ID = uint(marjorid)
err = mysql.DB.Preload("Subjects").Find(&p).Error
if err != nil {
zap.L().Error("查询专业下所有科目失败", zap.Error(err))
ResponseErrorWithMsg(c, CodeServerBusy, "查询失败")
return
}
ResponseSuccess(c, p)
}

//根据学校及专业id查询考研科目
Loading

0 comments on commit f5f1986

Please sign in to comment.