init web struct

This commit is contained in:
杨康 2022-08-16 21:10:41 +08:00
parent 94d06be2a1
commit 40156944c4
154 changed files with 5694 additions and 22926 deletions

View File

@ -1,3 +0,0 @@
.dockerignore
Dockerfile
docker-compose.yml

32
.gitignore vendored
View File

@ -1,32 +0,0 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.swp
# 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/
.idea/
*.iml
tmp/
tmpFiles/
*.tmp
logs/
files/
lastupdate.tmp
routers/commentsRouter*.go
### Config file
conf/app-dev.conf
conf/app-prod.conf

View File

@ -1,30 +0,0 @@
FROM golang:1.16-rc-buster
WORKDIR /openpbl
RUN go env -w CGO_ENABLED=0 GOPROXY=https://goproxy.io,direct GOOS=linux GOARCH=amd64 \
&& apt update && apt install sudo \
&& wget https://nodejs.org/dist/v12.22.0/node-v12.22.0-linux-x64.tar.gz \
&& sudo tar xf node-v12.22.0-linux-x64.tar.gz \
&& sudo apt install wait-for-it
ENV PATH=$PATH:/openpbl/node-v12.22.0-linux-x64/bin
RUN npm install -g yarn
COPY web/package.json /openpbl/web/package.json
RUN cd web && yarn install
COPY web /openpbl/web
RUN cd web && yarn build && rm -rf node_modules
COPY ./ /openpbl
RUN cd /openpbl && go build main.go
FROM alpine:3.7
COPY --from=0 /openpbl /
COPY --from=0 /usr/bin/wait-for-it /
RUN set -eux \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
&& apk update \
&& apk upgrade \
&& apk add bash
ENV RUNMODE=prod
CMD ./wait-for-it openpbl-db:3308 && ./main

201
LICENSE
View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,88 +0,0 @@
# OpenPBL
System of PBL.
### 前端 react
配置文件内容参考
`web/.env`
```dotenv
REACT_APP_CASDOOR_ENDPOINT=
REACT_APP_CLIENT_ID=
REACT_APP_APP_NAME=
REACT_APP_CASDOOR_ORGANIZATION='openct'
GENERATE_SOURCEMAP=false
SKIP_PREFLIGHT_CHECK=true
```
```bash
cd web
yarn install
yarn build
```
### 后端 beego
新建配置文件
`vim conf/app-dev.conf`
配置文件内容参考
`conf/app.conf`
```
appname = OpenPBL
httpaddr = 0.0.0.0
autorender = false
copyrequestbody = true
EnableDocs = true
SessionOn = true
copyrequestbody = true
httpport = 5000
driverName = mysql
dataSourceName = root:123@tcp(localhost:3306)/
dbName = openpbl
redisEndpoint =
jwtSecret = CasdoorSecret
casdoorEndpoint =
clientId =
clientSecret =
casdoorOrganization = "openct"
```
开发环境
```bash
bee run -runargs -RUNMODE=dev
```
```bash
go build main.go
./main -RUNMODE dev
```
生产环境
```bash
go build main.go
./main -RUNMODE prod
```
运行参数
```RUNMODE```
```
dev: 加载顺序 conf/app-dev.conf conf/app.conf
```
```
prod: 加载顺序 conf/app-prod.conf conf/app.conf
```
```
: 加载顺序 conf/app.conf
```

View File

@ -1,22 +0,0 @@
appname = OpenPBL
httpaddr = 0.0.0.0
autorender = false
copyrequestbody = true
EnableDocs = true
SessionOn = true
copyrequestbody = true
runmode=dev
httpport = 5000
driverName = mysql
dataSourceName = root:123@tcp(localhost:3306)/
dbName = openpbl
redisEndpoint =
jwtSecret = CasdoorSecret
casdoorEndpoint =
clientId =
clientSecret =
casdoorOrganization = "openct"

View File

@ -1,137 +0,0 @@
package controllers
import (
"OpenPBL/util"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor-go-sdk/auth"
)
type AuthController struct {
beego.Controller
}
func InitCasdoor() {
var CasdoorEndpoint = beego.AppConfig.String("casdoorEndpoint")
var ClientId = beego.AppConfig.String("clientId")
var ClientSecret = beego.AppConfig.String("clientSecret")
var JwtSecret = beego.AppConfig.String("jwtSecret")
var CasdoorOrganization = beego.AppConfig.String("casdoorOrganization")
auth.InitConfig(CasdoorEndpoint, ClientId, ClientSecret, JwtSecret, CasdoorOrganization)
}
func (c *AuthController) GetSessionUser() *auth.Claims {
s := c.GetSession("user")
if s == nil {
return nil
}
claims := &auth.Claims{}
err := util.JsonToStruct(s.(string), claims)
if err != nil {
panic(err)
}
return claims
}
func (c *AuthController) SetSessionUser(claims *auth.Claims) {
if claims == nil {
c.DelSession("user")
return
}
s := util.StructToJson(claims)
c.SetSession("user", s)
}
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
// Login
// @Title
// @Description
// @Param code body string true "code"
// @Param state body string true "state"
// @Success 200 {int} models.Teacher.Id
// @Failure 403 body is empty
// @router /login [post]
func (c *AuthController) Login() {
code := c.Input().Get("code")
state := c.Input().Get("state")
token, err := auth.GetOAuthToken(code, state)
if err != nil {
c.Data["json"] = Response{
Code: 403,
Msg: err.Error(),
}
c.ServeJSON()
return
}
claims, err := auth.ParseJwtToken(token.AccessToken)
if err != nil {
c.Data["json"] = Response{
Code: 403,
Msg: err.Error(),
}
c.ServeJSON()
return
}
claims.AccessToken = token.AccessToken
c.SetSessionUser(claims)
resp := &Response{
Code: 200,
Msg: "登录成功",
Data: claims,
}
c.Data["json"] = resp
c.ServeJSON()
}
// Logout
// @Title
// @Description
// @Success 200 {object} Response
// @router /logout [post]
func (c *AuthController) Logout() {
var resp Response
c.SetSessionUser(nil)
resp = Response{
Code: 200,
Msg: "",
}
c.Data["json"] = resp
c.ServeJSON()
}
// GetAccount
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 401 {object} Response
// @router /account [get]
func (c *AuthController) GetAccount() {
var resp Response
user := c.GetSessionUser()
if user == nil {
resp = Response{
Code: 404,
Msg: "账号不存在",
}
c.Data["json"] = resp
c.ServeJSON()
return
}
resp = Response{
Code: 200,
Msg: "",
Data: user,
}
c.Data["json"] = resp
c.ServeJSON()
}

View File

@ -1,181 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"strconv"
)
type ChaptersResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Chapters []models.Outline `json:"chapters"`
ShowMinute bool `json:"showMinute"`
}
// GetProjectChapters
// @Title
// @Description
// @Param pid path string true "project id"
// @Success 200 {object} []models.Outline
// @Failure 403 body is empty
// @router /:id/chapters [get]
func (p *ProjectController) GetProjectChapters() {
user := p.GetSessionUser()
uid := ""
show := false
if util.IsStudent(user) {
uid = user.Name
show = true
}
if util.IsTeacher(user) {
uid = p.GetString("studentId")
if uid != "" {
show = true
}
}
pid := p.GetString(":id")
outline, err := models.GetChaptersByPid(pid, uid)
if err != nil {
p.Data["json"] = ChaptersResponse{
Code: 400,
Msg: err.Error(),
Chapters: make([]models.Outline, 0),
}
} else {
p.Data["json"] = ChaptersResponse{
Code: 200,
Chapters: outline,
ShowMinute: show,
}
}
p.ServeJSON()
}
// CreateProjectChapter
// @Title
// @Description
// @Param body body models.Chapter true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:id/chapter [post]
func (p *ProjectController) CreateProjectChapter() {
pid, err := p.GetInt64(":id")
num, err := p.GetInt("chapterNumber")
chapter := &models.Chapter{
ProjectId: pid,
ChapterName: p.GetString("chapterName"),
ChapterNumber: num,
}
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
}
err = chapter.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "添加成功",
Data: strconv.FormatInt(chapter.Id, 10),
}
}
p.ServeJSON()
}
// UpdateProjectChapter
// @Title
// @Description
// @Param body body models.Chapter true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/chapter/:chapterId [post]
func (p *ProjectController) UpdateProjectChapter() {
cid, err := p.GetInt64(":chapterId")
pid, err := p.GetInt64(":projectId")
num, err := p.GetInt("chapterNumber")
chapter := &models.Chapter{
Id: cid,
ProjectId: pid,
ChapterName: p.GetString("chapterName"),
ChapterNumber: num,
}
err = chapter.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: "更新失败",
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
Data: true,
}
}
p.ServeJSON()
}
// DeleteProjectChapter
// @Title
// @Description
// @Param body body models.Chapter true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/chapter/:chapterId/delete [post]
func (p *ProjectController) DeleteProjectChapter() {
cid, err := p.GetInt64(":chapterId")
pid, err := p.GetInt64(":projectId")
num, err := p.GetInt("chapterNumber")
chapter := &models.Chapter{
Id: cid,
ProjectId: pid,
ChapterName: p.GetString("chapterName"),
ChapterNumber: num,
}
err = chapter.Delete()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
Data: true,
}
}
p.ServeJSON()
}
// ExchangeProjectChapter
// @Title
// @Description
// @Param cid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/chapters/exchange [post]
func (p *ProjectController) ExchangeProjectChapter() {
cid1 := p.GetString("chapterId1")
cid2 := p.GetString("chapterId2")
err := models.ExchangeChapters(cid1, cid2)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: true,
}
}
p.ServeJSON()
}

View File

@ -1,111 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"time"
)
type CommentResponse struct {
Code int `json:"code"`
Comments []models.Comment `json:"comments"`
Count int64 `json:"count"`
}
// GetProjectComments
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @router /:id/comments [get]
func (p *ProjectController) GetProjectComments() {
pid := p.GetString(":id")
from, err := p.GetInt("from")
if err != nil {
from = 0
}
size, err := p.GetInt("size")
if err != nil {
size = 10
}
isTeacher, err := p.GetBool("isTeacher")
if err != nil {
isTeacher = false
}
text := p.GetString("text")
comments, rows, err := models.GetProjectComments(pid, from, size, text, isTeacher)
if err != nil {
p.Data["json"] = CommentResponse{
Code: 400,
}
} else {
p.Data["json"] = CommentResponse{
Code: 200,
Comments: comments,
Count: rows,
}
}
p.ServeJSON()
}
// CreateProjectComment
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @Failure 403
// @router /:id/comment [post]
func (p *ProjectController) CreateProjectComment() {
pid, err := p.GetInt64(":id")
user := p.GetSessionUser()
uid := util.GetUserId(user)
comment := &models.Comment{
ProjectId: pid,
UserId: uid,
UserAvatar: user.Avatar,
UserName: user.DisplayName,
IsTeacher: util.IsTeacher(user),
Content: p.GetString("content"),
CreateAt: time.Time{},
}
err = comment.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "发布成功",
}
}
p.ServeJSON()
}
// DeleteProjectComment
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @router /:id/comment/:commentId/delete [post]
func (p *ProjectController) DeleteProjectComment() {
cid, err := p.GetInt64(":commentId")
err = (&models.Comment{Id: cid}).Delete()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
}
}
p.ServeJSON()
}

View File

@ -1,2 +0,0 @@
package controllers

View File

@ -1,43 +0,0 @@
package controllers
import (
"OpenPBL/models"
"github.com/astaxie/beego"
)
// HomeController
// Operations about Projects
type HomeController struct {
beego.Controller
}
type HomeProjectResponse struct {
Code int `json:"code"`
Projects []models.Project `json:"projects"`
}
// GetLatestProjects
// @Title
// @Description
// @Param num path int true ""
// @Success 200 {object} HomeProjectResponse
// @Failure 400
// @router /projects/latest [get]
func (h *HomeController) GetLatestProjects() {
num, err := h.GetInt("num")
if err != nil {
num = 3
}
projects, err := models.GetLatestProjects(num)
if err != nil {
h.Data["json"] = HomeProjectResponse{
Code: 400,
}
} else {
h.Data["json"] = HomeProjectResponse{
Code: 200,
Projects: projects,
}
}
h.ServeJSON()
}

View File

@ -1,155 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor-go-sdk/auth"
)
// MessageController
// Operations about Projects
type MessageController struct {
beego.Controller
}
func (m *MessageController) GetSessionUser() *auth.Claims {
s := m.GetSession("user")
if s == nil {
return nil
}
claims := &auth.Claims{}
err := util.JsonToStruct(s.(string), claims)
if err != nil {
panic(err)
}
return claims
}
type MessagesResponse struct {
Messages []models.Message `json:"messages"`
Count int64 `json:"count"`
Code int `json:"code"`
}
// GetUserMessages
// @Title
// @Description
// @Param readType params string true "read unread all"
// @Param messageType params string true "info warn error all"
// @Param from params int false ""
// @Param size params int false ""
// @Param orderType params string false "desc asc"
// @Success 200 {object} MessagesResponse
// @Failure 400
// @router / [get]
func (m *MessageController) GetUserMessages() {
user := m.GetSessionUser()
from, err := m.GetInt("from")
if err != nil {
from = 0
}
size, err := m.GetInt("size")
if err != nil {
size = 10
}
orderType := m.GetString("orderType")
r := m.GetString("readType")
t := m.GetString("messageType")
uid := util.GetUserId(user)
var messages []models.Message
var rows int64
messages, rows, err = models.GetMessages(uid, orderType, t, r, from, size)
if err != nil {
m.Data["json"] = MessagesResponse{
Code: 400,
}
} else {
m.Data["json"] = MessagesResponse{
Code: 200,
Messages: messages,
Count: rows,
}
}
m.ServeJSON()
}
// ReadUserMessage
// @Title
// @Description
// @Param messageId path string true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:messageId/read [post]
func (m *MessageController) ReadUserMessage() {
user := m.GetSessionUser()
uid := util.GetUserId(user)
mid, err := m.GetInt64(":messageId")
err = models.ReadMessage(mid, uid)
if err != nil {
m.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
m.Data["json"] = Response{
Code: 200,
}
}
m.ServeJSON()
}
// DeleteUserMessage
// @Title
// @Description
// @Param messageId path string true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:messageId/delete [post]
func (m *MessageController) DeleteUserMessage() {
user := m.GetSessionUser()
uid := util.GetUserId(user)
mid, err := m.GetInt64(":messageId")
msg := models.Message{
Id: mid,
ReceiverId: uid,
}
err = msg.Delete()
if err != nil {
m.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
m.Data["json"] = Response{
Code: 200,
}
}
m.ServeJSON()
}
// ReadAllUserMessage
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 400
// @router /read-all [post]
func (m *MessageController) ReadAllUserMessage() {
user := m.GetSessionUser()
uid := util.GetUserId(user)
err := models.ReadAllMessage(uid)
if err != nil {
m.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
m.Data["json"] = Response{
Code: 200,
}
}
m.ServeJSON()
}

View File

@ -1,599 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"encoding/json"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor-go-sdk/auth"
"strings"
"time"
)
// ProjectController
// Operations about Projects
type ProjectController struct {
beego.Controller
}
func (p *ProjectController) GetSessionUser() *auth.Claims {
s := p.GetSession("user")
if s == nil {
return nil
}
claims := &auth.Claims{}
err := util.JsonToStruct(s.(string), claims)
if err != nil {
panic(err)
}
return claims
}
type ProjectResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Project models.ProjectDetail `json:"project"`
}
// GetProjectDetail
// @Title
// @Description
// @Param id path string true "project id"
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:id [get]
func (p *ProjectController) GetProjectDetail() {
pid, err := p.GetInt64(":id")
user := p.GetSessionUser()
uid := util.GetUserId(user)
var project models.ProjectDetail
if util.IsStudent(user) {
project, err = models.GetProjectByPidForStudent(pid, uid)
} else if util.IsTeacher(user) {
project, err = models.GetProjectByPidForTeacher(pid, uid)
}
if err != nil {
p.Data["json"] = ProjectResponse{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = ProjectResponse{
Code: 200,
Project: project,
}
}
p.ServeJSON()
}
// CreateProject
// @Title
// @Description create project
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @Failure 403
// @router / [post]
func (p *ProjectController) CreateProject() {
user := p.GetSessionUser()
var resp Response
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法用户",
}
p.Data["json"] = resp
p.ServeJSON()
return
}
uid := util.GetUserId(user)
project := &models.Project{
TeacherId: uid,
LearnMinuteWeight: 100,
}
err := project.Create()
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
} else {
resp = Response{
Code: 200,
Msg: "创建成功",
Data: project.Id,
}
}
p.Data["json"] = resp
p.ServeJSON()
}
// UpdateProject
// @Title
// @Description create project
// @Param body body models.Project true ""
// @Success 200 {int} models.Project.Id
// @Failure 403 body is empty
// @router /:id [post]
func (p *ProjectController) UpdateProject() {
user := p.GetSessionUser()
var resp Response
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法用户",
}
p.Data["json"] = resp
p.ServeJSON()
return
}
uid := util.GetUserId(user)
pid, err := p.GetInt64(":id")
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
p.Data["json"] = resp
p.ServeJSON()
return
}
var timeLayoutStr = "2006-01-02 15:04:05 -0700 MST"
endTime, err := time.Parse(timeLayoutStr, p.GetString("endTime"))
b := true
if err != nil {
b = false
}
project := &models.Project{
Id: pid,
Image: p.GetString("image"),
ProjectTitle: p.GetString("projectTitle"),
ProjectIntroduce: p.GetString("projectIntroduce"),
ProjectGoal: p.GetString("projectGoal"),
TeacherId: uid,
Subjects: p.GetString("subjects"),
Skills: p.GetString("skills"),
EndTime: endTime,
TimedEnd: b,
}
projectSubjects, projectSkills, err := getProjectSubjectsAndSkills(pid, project.Subjects, project.Skills)
err = project.UpdateInfo(projectSubjects, projectSkills)
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
Data: true,
}
} else {
resp = Response{
Code: 200,
Msg: "更新成功",
}
}
p.Data["json"] = resp
p.ServeJSON()
}
// UpdateProjectWeight
// @Title
// @Description create project
// @Param body body models.Project true ""
// @Success 200 {int} models.Project.Id
// @Failure 403 body is empty
// @router /:id/weight [post]
func (p *ProjectController) UpdateProjectWeight() {
user := p.GetSessionUser()
var resp Response
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法用户",
}
p.Data["json"] = resp
p.ServeJSON()
return
}
pid, err := p.GetInt64(":id")
learnMinuteWeight, err := p.GetInt("learnMinuteWeight")
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
p.Data["json"] = resp
p.ServeJSON()
return
}
project := models.Project{
Id: pid,
LearnMinuteWeight: learnMinuteWeight,
}
tasks := make([]models.Task, 0)
err = json.Unmarshal([]byte(p.GetString("tasks")), &tasks)
err = models.UpdateWeight(project, tasks)
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
Data: true,
}
} else {
resp = Response{
Code: 200,
Msg: "更新成功",
}
}
p.Data["json"] = resp
p.ServeJSON()
}
// PublishProject
// @Title
// @Description
// @Param pid path int true ""
// @Success 200 {Response}
// @Failure 400
// @Failure 401
// @Failure 403
// @router /:id/publish [post]
func (u *ProjectController) PublishProject() {
pid, err := u.GetInt64(":id")
var resp Response
user := u.GetSessionUser()
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
p := models.Project{
Id: pid,
PublishedAt: time.Now(),
Published: true,
}
err = models.UpdatePublished(p)
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
} else {
resp = Response{
Code: 200,
Msg: "发布成功",
}
}
u.Data["json"] = resp
u.ServeJSON()
}
// CloseProject
// @Title
// @Description
// @Param pid path int true ""
// @Success 200 {object} Response
// @Failure 400
// @Failure 401
// @Failure 403
// @router /:id/close [post]
func (u *ProjectController) CloseProject() {
pid, err := u.GetInt64(":id")
var resp Response
user := u.GetSessionUser()
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
p := models.Project{
Id: pid,
ClosedAt: time.Now(),
Closed: true,
}
err = models.UpdateClosed(p)
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
} else {
resp = Response{
Code: 200,
Msg: "发布成功",
}
}
u.Data["json"] = resp
u.ServeJSON()
}
// DeleteProject
// @Title
// @Description
// @Param pid path int true ""
// @Success 200 {Response}
// @Failure 400
// @Failure 401
// @Failure 403
// @router /:id/delete [post]
func (u *ProjectController) DeleteProject() {
pid, err := u.GetInt64(":id")
var resp Response
user := u.GetSessionUser()
if !util.IsTeacher(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
p := models.Project{
Id: pid,
}
err = p.Delete()
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
} else {
resp = Response{
Code: 200,
Msg: "删除成功",
}
}
u.Data["json"] = resp
u.ServeJSON()
}
// RemoveStudent
// @Title
// @Description
// @Param pid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/remove/:studentId [post]
func (u *ProjectController) RemoveStudent() {
pid, err := u.GetInt64(":projectId")
sid := u.GetString(":studentId")
var resp Response
l := &models.LearnProject{
StudentId: sid,
ProjectId: pid,
}
err = l.Delete()
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
u.Data["json"] = resp
} else {
resp = Response{
Code: 200,
Msg: "移除成功",
}
}
u.Data["json"] = resp
u.ServeJSON()
}
func getProjectSubjectsAndSkills(pid int64, subjects string, skills string) (subjectList []*models.ProjectSubject, skillList []*models.ProjectSkill, err error) {
var (
subjectL []string
skillL []string
)
if subjects == "" {
subjectL = make([]string, 0)
} else {
subjectL = strings.Split(subjects, ",")
}
if skills == "" {
skillL = make([]string, 0)
} else {
skillL = strings.Split(skills, ",")
}
n1 := len(subjectL)
n2 := len(skillL)
subjectList = make([]*models.ProjectSubject, n1)
skillList = make([]*models.ProjectSkill, n2)
for i:=0; i<n1; i++ {
subjectList[i] = &models.ProjectSubject{
Subject: subjectL[i],
ProjectId: pid,
}
}
for i:=0; i<n2; i++ {
skillList[i] = &models.ProjectSkill{
Skill: skillL[i],
ProjectId: pid,
}
}
return
}
type StudentsResponse struct {
Code int `json:"code"`
Students []models.LearnProject `json:"students"`
Count int64 `json:"count"`
}
// GetProjectStudents
// @Title
// @Description
// @Param from query int true ""
// @Param size query int true ""
// @Success 200 {object} StudentsResponse
// @Failure 403
// @router /:projectId/students [get]
func (p *ProjectController) GetProjectStudents() {
pid := p.GetString(":projectId")
from, err := p.GetInt("from")
if err != nil {
from = 0
}
size, err := p.GetInt("size")
if err != nil {
size = 10
}
students, rows, err := models.GetProjectStudents(pid, from, size)
if err != nil {
p.Data["json"] = StudentsResponse{
Code: 400,
Students: nil,
}
} else {
p.Data["json"] = StudentsResponse{
Code: 200,
Students: students,
Count: rows,
}
}
p.ServeJSON()
}
// AddFavouriteProject
// @Title
// @Description
// @Param projectId path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/favourite/add [post]
func (p *ProjectController) AddFavouriteProject() {
pid, err := p.GetInt64(":projectId")
uid := util.GetUserId(p.GetSessionUser())
err = models.AddFavourite(uid, pid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "收藏成功",
}
}
p.ServeJSON()
}
// RemoveFavouriteProject
// @Title
// @Description
// @Param projectId path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/favourite/remove [post]
func (p *ProjectController) RemoveFavouriteProject() {
pid, err := p.GetInt64(":projectId")
uid := util.GetUserId(p.GetSessionUser())
err = models.RemoveFavourite(uid, pid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "移除成功",
}
}
p.ServeJSON()
}
type SubjectsAndSkillsResponse struct {
Code int `json:"code"`
Subjects []string `json:"subjects"`
Skills []string `json:"skills"`
}
// GetProjectSubjectsAndSkills
// @Title
// @Description
// @Param id path string true "project id"
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:id/subjects-skills [get]
func (p *ProjectController) GetProjectSubjectsAndSkills() {
subjects, err := models.GetSubjects()
skills, err := models.GetSkills()
if err != nil {
p.Data["json"] = SubjectsAndSkillsResponse{
Code: 400,
}
} else {
p.Data["json"] = SubjectsAndSkillsResponse{
Code: 200,
Subjects: subjects,
Skills: skills,
}
}
p.ServeJSON()
}
// ViewProject
// @Title
// @Description create project
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @Failure 403
// @router /:id/view [post]
func (p *ProjectController) ViewProject() {
pid := p.GetString(":id")
err := models.ViewProject(pid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
}
}
p.ServeJSON()
}
// CloneProject
// @Title
// @Description create project
// @Success 200 {object} Response
// @Failure 401
// @Failure 400
// @Failure 403
// @router /:id/clone [post]
func (p *ProjectController) CloneProject() {
pid, err := p.GetInt64(":id")
uid := util.GetUserId(p.GetSessionUser())
err = models.CloneProject(uid, pid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "复制成功,请到未发布项目中查看",
}
}
p.ServeJSON()
}

View File

@ -1,111 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor-go-sdk/auth"
"strconv"
)
// ProjectListController
// Operations about Projects
type ProjectListController struct {
beego.Controller
}
type ProjectList struct {
Code int `json:"code"`
Msg string `json:"msg"`
Count int64 `json:"count"`
Projects []models.ProjectDetail `json:"projects"`
}
func (pl *ProjectListController) GetSessionUser() *auth.Claims {
s := pl.GetSession("user")
if s == nil {
return nil
}
claims := &auth.Claims{}
err := util.JsonToStruct(s.(string), claims)
if err != nil {
panic(err)
}
return claims
}
// GetUserProjectList
// @Title
// @Description
// @Param projectType path string true "editing published closed // learning finished"
// @Param from query string false "from"
// @Param size query string false "size"
// @Param orderBy query string false "orderBy"
// @Param orderType query string false "orderType"
// @Param subject query string false ""
// @Param skill query string false ""
// @Param text query string false ""
// @Success 200 {object} ProjectList
// @Failure 401
// @router /:projectType [get]
func (pl *ProjectListController) GetUserProjectList() {
orderBy := pl.GetString("orderBy")
if orderBy == "" {
orderBy = "create_at"
}
orderType := pl.GetString("orderType")
if orderType == "" {
orderType = "desc"
}
t := pl.GetString(":projectType")
from, err := strconv.Atoi(pl.GetString("from"))
if err != nil {
from = 0
}
size, err := strconv.Atoi(pl.GetString("size"))
if err != nil {
size = 10
}
skill := pl.GetString("skill")
subject := pl.GetString("subject")
text := pl.GetString("text")
user := pl.GetSessionUser()
uid := util.GetUserId(user)
var data ProjectList
var projects []models.ProjectDetail
var count int64
if util.IsStudent(user) {
if t == "learning" {
projects, count, err = models.GetMyProjectListBySid(uid, from, size, subject, skill, text, orderBy, orderType, true)
} else if t == "finished" {
projects, count, err = models.GetMyProjectListBySid(uid, from, size, subject, skill, text, orderBy, orderType, false)
} else if t == "public" {
projects, count, err = models.GetPublicProjectListForStudent(uid, from, size, subject, skill, text, orderBy, orderType, false)
} else if t == "favourite" {
projects, count, err = models.GetPublicProjectListForStudent(uid, from, size, subject, skill, text, orderBy, orderType, true)
}
} else if util.IsTeacher(user) {
if t == "editing" {
projects, count, err = models.GetMyProjectListByTid(uid, from, size, subject, skill, text, orderBy, orderType, false, false)
} else if t == "published" {
projects, count, err = models.GetMyProjectListByTid(uid, from, size, subject, skill, text, orderBy, orderType, true, false)
} else if t == "finished" {
projects, count, err = models.GetMyProjectListByTid(uid, from, size, subject, skill, text, orderBy, orderType, true, true)
} else if t == "public" {
projects, count, err = models.GetPublicProjectListForTeacher(uid, from, size, subject, skill, text, orderBy, orderType, false)
} else if t == "favourite" {
projects, count, err = models.GetPublicProjectListForTeacher(uid, from, size, subject, skill, text, orderBy, orderType, true)
}
}
data = ProjectList{
Code: 200,
Count: count,
Projects: projects,
}
pl.Data["json"] = data
pl.ServeJSON()
}

View File

@ -1,112 +0,0 @@
package controllers
import (
"OpenPBL/models"
)
// GetResource
// @Title
// @Description
// @Param id path string true ""
// @Success 200 {object} models.Resource
// @router /:projectId/resource/:resourceId [get]
func (p *ProjectController) GetResource() {
var err error
rid := p.GetString(":id")
resource, err := models.GetResourceById(rid)
if err != nil {
p.Data["json"] = map[string]models.Resource{"resource": {}}
} else {
p.Data["json"] = map[string]models.Resource{"resource": resource}
}
p.ServeJSON()
}
// CreateResource
// @Title
// @Description
// @Param body body models.Resource true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/resource [post]
func (p *ProjectController) CreateResource() {
s, err := p.GetInt64("sectionId")
resource := &models.Resource{
SectionId: s,
Content: p.GetString("Content"),
}
err = resource.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "创建成功",
Data: resource.Id,
}
}
p.ServeJSON()
}
// UpdateResource
// @Title
// @Description
// @Param body body models.Resource true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/resource/:resourceId [post]
func (p *ProjectController) UpdateResource() {
s, err := p.GetInt64("sectionId")
id, err := p.GetInt64(":resourceId")
resource := &models.Resource{
Id: id,
SectionId: s,
Content: p.GetString("content"),
}
err = resource.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
}
}
p.ServeJSON()
}
// UpdateResourceContent
// @Title
// @Description
// @Param id path string true ""
// @Param content body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/resource/:resourceId/content [post]
func (p *ProjectController) UpdateResourceContent() {
id, err := p.GetInt64(":resourceId")
resource := &models.Resource{
Id: id,
Content: p.GetString("content"),
}
err = resource.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "保存成功",
}
}
p.ServeJSON()
}

View File

@ -1,371 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"encoding/json"
"strconv"
)
type SectionResponse struct {
Response
Section models.SectionDetail `json:"section"`
}
// GetSectionDetail
// @Title
// @Description
// @Param sid path string true ""
// @Param pid path string true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/section/:sectionId [get]
func (p *ProjectController) GetSectionDetail() {
sid := p.GetString(":sectionId")
section, err := models.GetSectionDetailById(sid)
if err != nil {
p.Data["json"] = SectionResponse{
Section: models.SectionDetail{},
Response: Response{
Code: 400,
Msg: err.Error(),
},
}
} else {
p.Data["json"] = SectionResponse{
Section: section,
Response: Response{
Code: 200,
},
}
}
p.ServeJSON()
}
// GetSectionFiles
// @Title
// @Description
// @Param sectionId path string true ""
// @Param projectId path string true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/section/:sectionId/files [get]
func (p *ProjectController) GetSectionFiles() {
sid := p.GetString(":sectionId")
files, err := models.GetSectionFiles(sid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: files,
}
}
p.ServeJSON()
}
// GetChapterSections
// @Title
// @Description
// @Param cid path string true "chapter id"
// @Success 200 {object} []models.Section
// @Failure 403 body is empty
// @router /:projectId/chapter/:chapterId/sections [get]
func (p *ProjectController) GetChapterSections() {
cid := p.GetString(":chapterId")
if cid != "" {
sections, err := models.GetSectionsByCid(cid)
if err != nil {
p.Data["json"] = map[string][]models.Section{"sections": nil}
} else {
p.Data["json"] = map[string][]models.Section{"sections": sections}
}
}
p.ServeJSON()
}
// CreateChapterSection
// @Title
// @Description
// @Param body body models.Section true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/chapter/:chapterId/section [post]
func (p *ProjectController) CreateChapterSection() {
cid, err := p.GetInt64(":chapterId")
sectionNumber, err := p.GetInt("sectionNumber")
chapterNumber, err := p.GetInt("chapterNumber")
section := &models.Section{
ChapterId: cid,
SectionName: p.GetString("sectionName"),
SectionNumber: sectionNumber,
ChapterNumber: chapterNumber,
SectionMinute: 1,
}
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
}
err = section.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "创建成功",
Data: strconv.FormatInt(section.Id, 10),
}
}
p.ServeJSON()
}
// UpdateChapterSection
// @Title
// @Description
// @Param body body models.Section true ""
// @Success 200 {object}
// @Failure 401
// @router /:projectId/chapter/:chapterId/section/:sectionId [post]
func (p *ProjectController) UpdateChapterSection() {
sid, err := p.GetInt64(":sectionId")
cid, err := p.GetInt64(":chapterId")
sectionNumber, err := p.GetInt("sectionNumber")
chapterNumber, err := p.GetInt("chapterNumber")
section := &models.Section{
Id: sid,
ChapterId: cid,
SectionName: p.GetString("sectionName"),
SectionNumber: sectionNumber,
ChapterNumber: chapterNumber,
}
err = section.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
Data: true,
}
}
p.ServeJSON()
}
// DeleteChapterSection
// @Title
// @Description
// @Param sid path string true ""
// @Success 200 {object}
// @Failure 401
// @router /:projectId/chapter/:chapterId/section/:sectionId/delete [post]
func (p *ProjectController) DeleteChapterSection() {
sid, err := p.GetInt64(":sectionId")
cid, err := p.GetInt64(":chapterId")
sectionNumber, err := p.GetInt("sectionNumber")
chapterNumber, err := p.GetInt("chapterNumber")
section := &models.Section{
Id: sid,
ChapterId: cid,
SectionName: p.GetString("sectionName"),
SectionNumber: sectionNumber,
ChapterNumber: chapterNumber,
}
err = section.Delete()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
Data: true,
}
}
p.ServeJSON()
}
// ExchangeChapterSection
// @Title
// @Description
// @Param sid path string true ""
// @Success 200 {object}
// @Failure 401
// @router /:projectId/chapter/:chapterId/sections/exchange [post]
func (p *ProjectController) ExchangeChapterSection() {
sid1 := p.GetString("sectionId1")
sid2 := p.GetString("sectionId2")
err := models.ExchangeSections(sid1, sid2)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: true,
}
}
p.ServeJSON()
}
// UpdateSectionsMinute
// @Title
// @Description
// @Param body body []models.Section true ""
// @Success 200 {object}
// @Failure 401
// @router /:projectId/sections-minute [post]
func (p *ProjectController) UpdateSectionsMinute() {
sections := make([]models.Section, 0)
err := json.Unmarshal([]byte(p.GetString("sections")), &sections)
err = models.UpdateSectionsMinute(sections)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
Data: true,
}
}
p.ServeJSON()
}
// UploadSectionFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/section/:sectionId/file [post]
func (p *ProjectController) UploadSectionFile() {
user := p.GetSessionUser()
if !util.IsTeacher(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
sid, err := p.GetInt64(":sectionId")
name := p.GetString("name")
url := p.GetString("url")
filePath := p.GetString("filePath")
r := &models.SectionFile{
SectionId: sid,
Name: name,
FilePath: filePath,
Url: url,
}
err = r.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "上传成功",
Data: r,
}
}
p.ServeJSON()
}
// UpdateSectionFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/section/:sectionId/file/:fileId/update [post]
func (p *ProjectController) UpdateSectionFile() {
user := p.GetSessionUser()
if !util.IsTeacher(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
sid, err := p.GetInt64(":sectionId")
fileId, err := p.GetInt64(":fileId")
name := p.GetString("name")
url := p.GetString("url")
filePath := p.GetString("filePath")
r := &models.SectionFile{
Id: fileId,
SectionId: sid,
Name: name,
FilePath: filePath,
Url: url,
}
err = r.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "上传成功",
Data: r,
}
}
p.ServeJSON()
}
// DeleteSectionFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/section/:sectionId/file/:fileId/delete [post]
func (p *ProjectController) DeleteSectionFile() {
user := p.GetSessionUser()
if !util.IsTeacher(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
fid := p.GetString(":fileId")
err := models.DeleteSectionFile(fid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
}
}
p.ServeJSON()
}

View File

@ -1,285 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"encoding/json"
"fmt"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor-go-sdk/auth"
"time"
)
// StudentController
// Operations about Student
type StudentController struct {
beego.Controller
}
func (u *StudentController) GetSessionUser() *auth.Claims {
s := u.GetSession("user")
if s == nil {
return nil
}
claims := &auth.Claims{}
err := util.JsonToStruct(s.(string), claims)
if err != nil {
panic(err)
}
return claims
}
// LearnProject
// @Title
// @Description
// @Param pid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @Failure 403
// @router /learn/:projectId [post]
func (u *StudentController) LearnProject() {
pid, err := u.GetInt64(":projectId")
var resp Response
user := u.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
uid := util.GetUserId(user)
l := &models.LearnProject{
Avatar: user.Avatar,
Name: user.Name,
StudentId: uid,
ProjectId: pid,
Learning: true,
}
err = l.Create()
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
u.Data["json"] = resp
}
resp = Response{
Code: 200,
Msg: "加入成功",
}
project, err := models.GetProjectById(pid)
if err == nil {
content := fmt.Sprintf("成功加入课程 \"%v\" ", project.ProjectTitle)
models.CreateMessage(&models.Message{
ReceiverId: uid,
MessageType: "info",
MessageTitle: "加入课程",
Content: content,
ReadMessage: false,
CreateAt: time.Time{},
})
}
u.Data["json"] = resp
u.ServeJSON()
}
// ExitProject
// @Title
// @Description
// @Param pid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @Failure 403
// @router /exit/:projectId [post]
func (u *StudentController) ExitProject() {
pid, err := u.GetInt64(":projectId")
var resp Response
user := u.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
uid := util.GetUserId(user)
l := &models.LearnProject{
StudentId: uid,
ProjectId: pid,
}
err = l.Delete()
if err != nil {
resp = Response{
Code: 400,
Msg: err.Error(),
}
u.Data["json"] = resp
}
resp = Response{
Code: 200,
Msg: "退出成功",
}
project, err := models.GetProjectById(pid)
if err == nil {
content := fmt.Sprintf("成功退出课程 \"%v\" ", project.ProjectTitle)
models.CreateMessage(&models.Message{
ReceiverId: uid,
MessageType: "info",
MessageTitle: "退出课程",
Content: content,
ReadMessage: false,
CreateAt: time.Time{},
})
}
u.Data["json"] = resp
u.ServeJSON()
}
// FinishedProject
// @Title
// @Description
// @Param body body models.LearnProject true ""
// @Success 200 {object} models.Project
// @Failure 403
// @router /finished [post]
func (u *StudentController) FinishedProject() {
var l models.LearnProject
err := json.Unmarshal(u.Ctx.Input.RequestBody, &l)
if err != nil {
u.Data["json"] = map[string]string{"error": err.Error()}
}
err = l.Update()
if err != nil {
u.Data["json"] = map[string]string{"error": err.Error()}
}
u.Data["json"] = map[string]bool{"result": true}
u.ServeJSON()
}
// GetLearnSection
// @Title
// @Description
// @Param body body models.LearnSection true ""
// @Success 200 {object} Response
// @Failure 400
// @router /project/:projectId/section/:sectionId [get]
func (u *StudentController) GetLearnSection() {
var resp Response
user := u.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
uid := util.GetUserId(user)
sid, err := u.GetInt64(":sectionId")
projectId, err := u.GetInt64(":projectId")
l, err := models.GetLearnSection(sid, uid, projectId)
if err != nil {
u.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
u.Data["json"] = Response{
Code: 200,
Data: l,
}
}
u.ServeJSON()
}
// UpdateLearnSection
// @Title
// @Description
// @Param body body models.LearnSection true ""
// @Success 200 {object} Response
// @Failure 400
// @router /project/:projectId/section/:sectionId [post]
func (u *StudentController) UpdateLearnSection() {
var resp Response
user := u.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 403,
Msg: "非法的用户",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
uid := util.GetUserId(user)
sid, err := u.GetInt64(":sectionId")
m, err := u.GetInt("learnMinute")
s, err := u.GetInt("learnSecond")
l := models.LearnSection{
StudentId: uid,
SectionId: sid,
LearnMinute: m,
LearnSecond: s,
}
pid, err := u.GetInt64(":projectId")
err = l.Update(pid)
if err != nil {
u.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
u.Data["json"] = Response{
Code: 200,
}
}
u.ServeJSON()
}
// GetLastLearnSection
// @Title
// @Description
// @Success 200 {object} Response
// @Failure 400
// @router /last-learn/project/:projectId [get]
func (u *StudentController) GetLastLearnSection() {
var resp Response
user := u.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 200,
Msg: "",
}
u.Data["json"] = resp
u.ServeJSON()
return
}
uid := util.GetUserId(user)
projectId := u.GetString(":projectId")
l, err := models.GetLastLearnSection(uid, projectId)
if err != nil {
u.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
u.Data["json"] = Response{
Code: 200,
Data: l,
}
}
u.ServeJSON()
}

View File

@ -1,279 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"encoding/json"
"strconv"
"time"
)
// CreateSubmit
// @Title
// @Description
// @Param body body models.Submit true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/task/:taskId/submit [post]
func (p *ProjectController) CreateSubmit() {
var resp Response
user := p.GetSessionUser()
if !util.IsStudent(user) {
resp = Response{
Code: 403,
Msg: "非法用户",
}
p.Data["json"] = resp
p.ServeJSON()
return
}
uid := util.GetUserId(user)
tid, err := p.GetInt64(":taskId")
pid, err := p.GetInt64(":projectId")
submit := &models.Submit{
ProjectId: pid,
StudentId: uid,
TaskId: tid,
SubmitType: p.GetString("submitType"),
SubmitTitle: p.GetString("submitTitle"),
SubmitIntroduce: p.GetString("submitIntroduce"),
SubmitContent: p.GetString("submitContent"),
CreateAt: time.Now(),
Scored: true,
Score: 100,
}
if submit.SubmitType == "file" {
submit.Scored = false
submit.Score = 0
}
var c = make([]models.Choice, 0)
if submit.SubmitType == "survey" {
err = json.Unmarshal([]byte(p.GetString("choices")), &c)
}
err = submit.Create(c)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "提交成功",
Data: strconv.FormatInt(submit.Id, 10),
}
}
p.ServeJSON()
}
// UploadSubmitFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/task/:taskId/submit/:submitId/file [post]
func (p *ProjectController) UploadSubmitFile() {
user := p.GetSessionUser()
if !util.IsStudent(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
uid := util.GetUserId(user)
tid, err := p.GetInt64(":taskId")
pid, err := p.GetInt64(":projectId")
url := p.GetString("url")
fileName := p.GetString("name")
filePath := p.GetString("filePath")
sid, err := p.GetInt64(":submitId")
if sid == 0 {
submit := &models.Submit{
ProjectId: pid,
StudentId: uid,
TaskId: tid,
SubmitType: "file",
CreateAt: time.Now(),
Scored: false,
Score: 0,
}
err = submit.Create(make([]models.Choice, 0))
sid = submit.Id
}
r := &models.SubmitFile{
SubmitId: sid,
Name: fileName,
FilePath: filePath,
Url: url,
}
err = r.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "上传成功",
}
}
p.ServeJSON()
}
// UpdateSubmitFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/task/:taskId/submit/:submitId/file/:fileId/update [post]
func (p *ProjectController) UpdateSubmitFile() {
user := p.GetSessionUser()
if !util.IsStudent(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
url := p.GetString("url")
fileName := p.GetString("name")
sid, err := p.GetInt64(":submitId")
fid, err := p.GetInt64(":fileId")
filePath := p.GetString("filePath")
r := &models.SubmitFile{
Id: fid,
SubmitId: sid,
Name: fileName,
FilePath: filePath,
Url: url,
}
err = r.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "上传成功",
}
}
p.ServeJSON()
}
// DeleteSubmitFile
// @Title
// @Description
// @Param filePath body string true ""
// @Success 200 {object} models.TeacherProject
// @Failure 400
// @router /:projectId/task/:taskId/submit/:submitId/file/:fileId/delete [post]
func (p *ProjectController) DeleteSubmitFile() {
user := p.GetSessionUser()
if !util.IsStudent(user) {
p.Data["json"] = Response{
Code: 403,
Msg: "非法用户",
}
p.ServeJSON()
return
}
fid := p.GetString(":fileId")
err := models.DeleteSubmitFile(fid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
}
}
p.ServeJSON()
}
// UpdateSubmit
// @Title
// @Description
// @Param body body models.Submit true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/task/:taskId/submit/:submitId [post]
func (p *ProjectController) UpdateSubmit() {
user := p.GetSessionUser()
var uid string
if util.IsStudent(user) {
uid = util.GetUserId(user)
}
tid, err := p.GetInt64(":taskId")
sid, err := p.GetInt64(":submitId")
pid, err := p.GetInt64(":projectId")
score, err := p.GetInt("score")
scored, err := p.GetBool("scored")
f := &models.Submit{
Id: sid,
ProjectId: pid,
StudentId: uid,
TaskId: tid,
SubmitType: p.GetString("submitType"),
SubmitTitle: p.GetString("submitTitle"),
SubmitIntroduce: p.GetString("submitIntroduce"),
SubmitContent: p.GetString("submitContent"),
CreateAt: time.Now(),
Score: score,
Scored: scored,
}
var c = make([]models.Choice, 0)
if util.IsStudent(user) && f.SubmitType == "survey" {
err = json.Unmarshal([]byte(p.GetString("choices")), &c)
}
err = f.Update(c)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "提交成功",
}
}
p.ServeJSON()
}
// GetSubmitFiles
// @Title
// @Description
// @Param body body models.Submit true ""
// @Success 200 {object}
// @Failure 403 body is empty
// @router /:projectId/task/:taskId/submit/:submitId/files [get]
func (p *ProjectController) GetSubmitFiles() {
sid := p.GetString(":submitId")
files, err := models.GetSubmitFiles(sid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "提交成功",
Data: files,
}
}
p.ServeJSON()
}

View File

@ -1,225 +0,0 @@
package controllers
import (
"OpenPBL/models"
"strconv"
)
// GetSurveyDetailByTaskId
// @Title
// @Description
// @Param sid path string true ""
// @Success 200 {object}
// @Failure 400
// @router /:projectId/task/:taskId/survey [get]
func (p *ProjectController) GetSurveyDetailByTaskId() {
tid := p.GetString(":taskId")
survey, qns, err := models.GetSurveyByTaskId(tid)
if err != nil {
p.Data["json"] = map[string]interface{}{"survey": nil, "questions": qns}
} else {
p.Data["json"] = map[string]interface{}{"survey": survey, "questions": qns}
}
p.ServeJSON()
}
// CreateSurvey unused
// @Title
// @Description
// @Param body body models.Survey true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey [post]
func (p *ProjectController) CreateSurvey() {
tid, err := p.GetInt64(":taskId")
survey := &models.Survey{
TaskId: tid,
SurveyTitle: p.GetString("surveyTitle"),
SurveyIntroduce: p.GetString("surveyIntroduce"),
}
if err != nil {
p.Data["json"] = map[string]string{"error": err.Error()}
}
err = survey.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "创建成功",
Data: strconv.FormatInt(survey.Id, 10),
}
}
p.ServeJSON()
}
// UpdateSurvey unused
// @Title
// @Description
// @Param body body models.Survey true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey/:sid [post]
func (p *ProjectController) UpdateSurvey() {
sid, err := p.GetInt64(":sid")
tid, err := p.GetInt64(":tid")
survey := &models.Survey{
Id: sid,
TaskId: tid,
SurveyTitle: p.GetString("surveyTitle"),
SurveyIntroduce: p.GetString("surveyIntroduce"),
}
if err != nil {
p.Data["json"] = map[string]string{"error": err.Error()}
}
err = survey.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
}
}
p.ServeJSON()
}
// CreateQuestion
// @Title
// @Description
// @Param body body models.Question true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey/:surveyId/question [post]
func (p *ProjectController) CreateQuestion() {
sid, err := p.GetInt64(":surveyId")
o, err := p.GetInt("questionOrder")
question := &models.Question{
SurveyId: sid,
QuestionOrder: o,
QuestionType: p.GetString("questionType"),
QuestionTitle: p.GetString("questionTitle"),
QuestionOptions: p.GetString("questionOptions"),
}
if err != nil {
p.Data["json"] = map[string]string{"error": err.Error()}
}
err = question.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "创建成功",
Data: strconv.FormatInt(question.Id, 10),
}
}
p.ServeJSON()
}
// UpdateQuestion
// @Title
// @Description
// @Param body body models.Survey true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey/:surveyId/question/:questionId [post]
func (p *ProjectController) UpdateQuestion() {
qid, err := p.GetInt64(":questionId")
sid, err := p.GetInt64(":surveyId")
o, err := p.GetInt("questionOrder")
question := &models.Question{
Id: qid,
SurveyId: sid,
QuestionOrder: o,
QuestionType: p.GetString("questionType"),
QuestionTitle: p.GetString("questionTitle"),
QuestionOptions: p.GetString("questionOptions"),
}
if err != nil {
p.Data["json"] = map[string]string{"error": err.Error()}
}
err = question.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
}
}
p.ServeJSON()
}
// ExchangeQuestion
// @Title
// @Description
// @Param body body string true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey/:surveyId/questions/exchange [post]
func (p *ProjectController) ExchangeQuestion() {
id1 := p.GetString("questionId1")
id2 := p.GetString("questionId2")
err := models.ExchangeQuestion(id1, id2)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: true,
}
}
p.ServeJSON()
}
// DeleteQuestion
// @Title
// @Description
// @Param qid path string true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task/:taskId/survey/:surveyId/question/:questionId/delete [post]
func (p *ProjectController) DeleteQuestion() {
qid, err := p.GetInt64(":questionId")
question := &models.Question{
Id: qid,
}
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
p.ServeJSON()
return
}
err = question.Delete()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
}
}
p.ServeJSON()
}

View File

@ -1,280 +0,0 @@
package controllers
import (
"OpenPBL/models"
"OpenPBL/util"
"strconv"
)
type TaskResponse struct {
Response
Tasks []models.TaskDetail `json:"tasks"`
Learning bool `json:"learning"`
Editable bool `json:"editable"`
TeacherScore bool `json:"teacherScore"`
ShowCount bool `json:"showCount"`
}
// GetSectionTasksDetail
// @Title
// @Description get section tasks with submit and survey
// @Param sid path string true ""
// @Success 200 {object} TaskResponse
// @Failure 400
// @router /:projectId/section/:sectionId/tasks [get]
func (p *ProjectController) GetSectionTasksDetail() {
sid := p.GetString(":sectionId")
var learning bool
user := p.GetSessionUser()
showCount := false
if !util.IsStudent(user) {
learning = false
}
if util.IsTeacher(user) {
showCount = true
}
uid := util.GetUserId(user)
pid := p.GetString(":projectId")
learning = models.IsLearningProject(pid, uid)
tasks, err := models.GetSectionTasks(sid, uid, learning)
if err != nil {
p.Data["json"] = TaskResponse{
Response: Response{
Code: 400,
Msg: err.Error(),
},
Tasks: nil,
Learning: false,
}
} else {
p.Data["json"] = TaskResponse{
Response: Response{
Code: 200,
},
Tasks: tasks,
Learning: learning,
Editable: learning,
ShowCount: showCount,
}
}
p.ServeJSON()
}
// GetProjectTasks
// @Title
// @Description get all the tasks of a section
// @Param sid path string true ""
// @Success 200 {object}
// @Failure 400
// @router /:projectId/tasks [get]
func (p *ProjectController) GetProjectTasks() {
pid := p.GetString(":projectId")
tasks, err := models.GetProjectTasks(pid)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: tasks,
}
}
p.ServeJSON()
}
// GetProjectTasksDetail
// @Title
// @Description get all the tasks of a section
// @Param sid path string true ""
// @Success 200 {object}
// @Failure 400
// @router /:projectId/tasks-detail [get]
func (p *ProjectController) GetProjectTasksDetail() {
var learning bool
user := p.GetSessionUser()
showSubmit := false
teacherScore := false
uid := util.GetUserId(user)
editable := true
showCount := false
pid := p.GetString(":projectId")
if util.IsTeacher(user) {
uid = p.GetString("studentId")
showSubmit = true
editable = false
teacherScore = true
showCount = true
}
if !util.IsStudent(user) {
learning = false
} else {
learning = models.IsLearningProject(pid, uid)
}
if learning {
showSubmit = true
}
tasks, err := models.GetProjectTasksDetail(pid, uid, showSubmit)
if err != nil {
p.Data["json"] = TaskResponse{
Response: Response{
Code: 400,
Msg: err.Error(),
},
Tasks: nil,
Learning: false,
}
} else {
p.Data["json"] = TaskResponse{
Response: Response{
Code: 200,
},
Tasks: tasks,
Learning: learning,
Editable: editable,
TeacherScore: teacherScore,
ShowCount: showCount,
}
}
p.ServeJSON()
}
// CreateTask
// @Title
// @Description
// @Param body body models.Task true ""
// @Success 200 {object} Response
// @Failure 400
// @router /:projectId/task [post]
func (p *ProjectController) CreateTask() {
sid, err := p.GetInt64("sectionId")
pid, err := p.GetInt64(":projectId")
o, err := p.GetInt("taskOrder")
sn, err := p.GetInt("sectionNumber")
cn, err := p.GetInt("chapterNumber")
task := &models.Task{
SectionId: sid,
ProjectId: pid,
SectionNumber: sn,
ChapterNumber: cn,
TaskOrder: o,
TaskTitle: p.GetString("taskTitle"),
TaskIntroduce: p.GetString("taskIntroduce"),
TaskType: p.GetString("taskType"),
}
if err != nil {
p.Data["json"] = map[string]string{"error": err.Error()}
}
err = task.Create()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "创建成功",
Data: strconv.FormatInt(task.Id, 10),
}
}
p.ServeJSON()
}
// UpdateTask
// @Title
// @Description
// @Param body body models.Task true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/task/:taskId [post]
func (p *ProjectController) UpdateTask() {
tid, err := p.GetInt64(":taskId")
sid, err := p.GetInt64("sectionId")
pid, err := p.GetInt64(":projectId")
o, err := p.GetInt("taskOrder")
sn, err := p.GetInt("sectionNumber")
cn, err := p.GetInt("chapterNumber")
task := &models.Task{
Id: tid,
SectionId: sid,
ProjectId: pid,
SectionNumber: sn,
ChapterNumber: cn,
TaskOrder: o,
TaskTitle: p.GetString("taskTitle"),
TaskIntroduce: p.GetString("taskIntroduce"),
TaskType: p.GetString("taskType"),
}
err = task.Update()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "更新成功",
Data: true,
}
}
p.ServeJSON()
}
// DeleteTask
// @Title
// @Description
// @Param cid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/task/:taskId/delete [post]
func (p *ProjectController) DeleteTask() {
tid, err := p.GetInt64(":taskId")
task := &models.Task{
Id: tid,
}
err = task.Delete()
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Msg: "删除成功",
Data: true,
}
}
p.ServeJSON()
}
// ExchangeTask
// @Title
// @Description
// @Param cid path string true ""
// @Success 200 {object} Response
// @Failure 401
// @router /:projectId/tasks/exchange [post]
func (p *ProjectController) ExchangeTask() {
tid1 := p.GetString(":taskId1")
tid2 := p.GetString(":taskId2")
err := models.ExchangeTasks(tid1, tid2)
if err != nil {
p.Data["json"] = Response{
Code: 400,
Msg: err.Error(),
}
} else {
p.Data["json"] = Response{
Code: 200,
Data: true,
}
}
p.ServeJSON()
}

View File

@ -1,19 +0,0 @@
version: '3.1'
services:
openpbl:
build:
context: ./
dockerfile: Dockerfile
ports:
- 5000:5000
depends_on:
- openpbl-db
openpbl-db:
restart: always
image: mysql:8.0.25
ports:
- 3308:3306
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- /usr/local/docker/mysql:/var/lib/mysql

15
go.mod
View File

@ -1,15 +0,0 @@
module OpenPBL
go 1.16
require (
github.com/astaxie/beego v1.12.3
github.com/casdoor/casdoor-go-sdk v0.0.2-FIX
github.com/go-sql-driver/mysql v1.6.0
github.com/robfig/cron v1.2.0 // indirect
github.com/smartystreets/goconvey v1.6.4
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect
xorm.io/xorm v1.1.2
)

591
go.sum
View File

@ -1,591 +0,0 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
github.com/casdoor/casdoor-go-sdk v0.0.2-FIX h1:0FtoxZCnH5fp4Gdv7UvQ5Dj5WsFMCpj9A5ahTTqq+/c=
github.com/casdoor/casdoor-go-sdk v0.0.2-FIX/go.mod h1:PlKduZO7RV1E/Gcpfk5Y1LuzROl5ZELn0PCYPGRF6o8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8=
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009 h1:u0oCo5b9wyLr++HF3AN9JicGhkUxJhMz51+8TIZH9N0=
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878=
modernc.org/ccgo/v3 v3.9.0 h1:JbcEIqjw4Agf+0g3Tc85YvfYqkkFOv6xBwS4zkfqSoA=
modernc.org/ccgo/v3 v3.9.0/go.mod h1:nQbgkn8mwzPdp4mm6BT6+p85ugQ7FrGgIcYaE7nSrpY=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.8.0 h1:Pp4uv9g0csgBMpGPABKtkieF6O5MGhfGo6ZiOdlYfR8=
modernc.org/libc v1.8.0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84 h1:rgEUzE849tFlHSoeCrKyS9cZAljC+DY7MdMHKq6R6sY=
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84/go.mod h1:PGzq6qlhyYjL6uVbSgS6WoF7ZopTW/sI7+7p+mb4ZVU=
modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
xorm.io/builder v0.3.8 h1:P/wPgRqa9kX5uE0aA1/ukJ23u9KH0aSRpHLwDKXigSE=
xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/xorm v1.1.2 h1:bje+1KZvK3m5AHtZNfUDlKEEyuw/IRHT+an0CLIG5TU=
xorm.io/xorm v1.1.2/go.mod h1:Cb0DKYTHbyECMaSfgRnIZp5aiUgQozxcJJ0vzcLGJSg=

60
main.go
View File

@ -1,60 +0,0 @@
package main
import (
"OpenPBL/controllers"
"OpenPBL/models"
"OpenPBL/routers"
_ "OpenPBL/routers"
"OpenPBL/util"
"flag"
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
_ "github.com/astaxie/beego/session/redis"
"log"
)
func main() {
var mode string
flag.StringVar(&mode, "RUNMODE", "default", "运行模式")
flag.Parse()
var err error
configPath := util.GetConfigFile(mode)
err = beego.LoadAppConfig("ini", configPath)
if err != nil {
panic(err)
}
log.Println("App start with runmode: " + mode)
log.Println("Load config file: " + configPath)
models.InitAdapter()
controllers.InitCasdoor()
models.StartTask()
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"*"},
AllowHeaders: []string{"Origin"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
beego.SetStaticPath("/static", "web/build/static")
beego.BConfig.WebConfig.DirectoryIndex = true
beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic)
beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic)
beego.BConfig.WebConfig.Session.SessionName = "openpbl_session_id"
if beego.AppConfig.String("redisEndpoint") == "" {
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
} else {
beego.BConfig.WebConfig.Session.SessionProvider = "redis"
beego.BConfig.WebConfig.Session.SessionProviderConfig = beego.AppConfig.String("redisEndpoint")
}
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 30
beego.Run()
}

View File

@ -1,115 +0,0 @@
package models
import (
"fmt"
"runtime"
"github.com/astaxie/beego"
_ "github.com/go-sql-driver/mysql"
"xorm.io/xorm"
)
var adapter *Adapter
func InitAdapter() {
adapter = NewAdapter(beego.AppConfig.String("driverName"), beego.AppConfig.String("dataSourceName"), beego.AppConfig.String("dbName"))
adapter.createTable()
}
// Adapter represents the MySQL adapter for policy storage.
type Adapter struct {
driverName string
dataSourceName string
dbName string
Engine *xorm.Engine
}
// finalizer is the destructor for Adapter.
func finalizer(a *Adapter) {
err := a.Engine.Close()
if err != nil {
panic(err)
}
}
// NewAdapter is the constructor for Adapter.
func NewAdapter(driverName string, dataSourceName string, dbName string) *Adapter {
a := &Adapter{}
a.driverName = driverName
a.dataSourceName = dataSourceName
a.dbName = dbName
// Open the DB, create it if not existed.
a.open()
// Call the destructor when the object is released.
runtime.SetFinalizer(a, finalizer)
return a
}
func (a *Adapter) createDatabase() error {
engine, err := xorm.NewEngine(a.driverName, a.dataSourceName)
if err != nil {
return err
}
defer engine.Close()
_, err = engine.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci", a.dbName))
return err
}
func (a *Adapter) open() {
if a.driverName != "postgres" {
if err := a.createDatabase(); err != nil {
panic(err)
}
}
engine, err := xorm.NewEngine(a.driverName, a.dataSourceName+a.dbName)
if err != nil {
panic(err)
}
a.Engine = engine
}
func (a *Adapter) close() {
a.Engine.Close()
a.Engine = nil
}
func (a *Adapter) createTable() {
err := a.Engine.Sync2(
new(Project),
new(Favourite),
new(LearnProject),
new(LearnSection),
new(LastLearn),
new(Chapter),
new(Section),
new(SectionFile),
new(SubmitFile),
new(Resource),
new(Task),
new(Survey),
new(Question),
new(Submit),
new(Choice),
new(ProjectSkill),
new(ProjectSubject),
new(Message),
new(Comment),
)
if err != nil {
fmt.Println(err)
panic(err)
}
}

View File

@ -1,102 +0,0 @@
package models
import (
"fmt"
"xorm.io/xorm"
)
type Chapter struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
ProjectId int64 `json:"projectId" xorm:"index"`
ChapterName string `json:"chapterName"`
ChapterNumber int `json:"chapterNumber" xorm:"index"`
}
type Outline struct {
Chapter `xorm:"extends"`
Sections []SectionMinute `json:"sections" xorm:"extends"`
}
func (p *Chapter) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *Chapter) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *Chapter) Update() (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
return
}
func (p *Chapter) Delete() (err error) {
session := adapter.Engine.NewSession()
defer session.Close()
session.Begin()
_, err = session.
Exec("update chapter set chapter_number = chapter_number - 1 " +
"where project_id = ? and chapter_number > ?", p.ProjectId, p.ChapterNumber)
fmt.Println(err)
_, err = session.Table(&Section{}).Delete(Section{ChapterId: p.Id})
_, err = session.Table(&Chapter{}).ID(p.Id).Delete(p)
session.Commit()
return
}
func ExchangeChapters(cid1 string, cid2 string) (err error) {
_, err = adapter.Engine.
Exec("update chapter c1 join chapter c2 on (c1.id = ? and c2.id = ?) " +
"set c1.chapter_number = c2.chapter_number, c2.chapter_number = c1.chapter_number", cid1, cid2)
return
}
func GetChaptersByPid(pid string, uid string) (outline []Outline, err error) {
var c []Chapter
err = (&Chapter{}).GetEngine().
Where("project_id = ?", pid).
Asc("chapter_number").
Find(&c)
outline = make([]Outline, len(c))
for i:=0; i< len(c); i++ {
sections := make([]SectionMinute, 0)
outline[i].Chapter = c[i]
if uid == "" {
err = (&Section{}).GetEngine().
Where("chapter_id = ?", c[i].Id).
Asc("section_number").
Find(&sections)
} else {
err = adapter.Engine.
SQL("select * from (select * from section where chapter_id = ?) s LEFT JOIN learn_section ls on s.id = ls.section_id and ls.student_id = ? order by s.section_number", c[i].Id, uid).
Find(&sections)
}
outline[i].Sections = sections
}
return
}
func DeleteProjectChapters(pid int64) (err error) {
var chapters []Chapter
err = (&Chapter{}).GetEngine().Where("project_id = ?", pid).Find(&chapters)
for i:=0; i< len(chapters); i++ {
c := chapters[i]
cid := c.Id
_, err = (&Chapter{}).GetEngine().ID(cid).Delete(&Chapter{})
err = DeleteChapterSections(cid)
}
return
}
func CloneProjectChapters(pid int64, newPid int64) (err error) {
var chapters []Chapter
err = (&Chapter{}).GetEngine().Where("project_id = ?", pid).Find(&chapters)
for i:=0; i< len(chapters); i++ {
c := chapters[i]
cid := c.Id
c.Id = 0
c.ProjectId = newPid
_, err = (&Chapter{}).GetEngine().Insert(&c)
newCid := c.Id
err = CloneChapterSections(newPid, cid, newCid)
}
return
}

View File

@ -1,60 +0,0 @@
package models
import (
"github.com/astaxie/beego/toolbox"
"time"
)
func StartTask() {
spec := "0 0 0 * * *"
t := toolbox.NewTask("check_project", spec, checkProject)
err := t.Run()
if err != nil {
panic(err)
}
toolbox.AddTask("check_project", t)
toolbox.StartTask()
}
func checkProject() error {
project := make([]Project, 0)
_ = adapter.Engine.Table("project").
Where("published = true").
Where("closed = false").
Where("timed_end = true").
Where("end_time < ?", time.Now().Format("2006-01-02 15:04:05")).
Find(&project)
for i:=0; i<len(project); i++ {
p := project[i]
p.Closed = true
p.ClosedAt = time.Now()
_ = UpdateClosed(p)
}
type LP struct {
ProjectTitle string
StudentId string
EndTime time.Time
}
p := make([]LP, 0)
_ = adapter.Engine.Table("project").
Join("INNER", "learn_project", "project.id = learn_project.project_id").
Where("published = true").
Where("closed = false").
Where("timed_end = true").
Where("end_time < ?", time.Now().AddDate(0, 0, 3).Format("2006-01-02 15:04:05")).
Find(&p)
for i:=0; i<len(p); i++ {
CreateMessage(&Message{
ReceiverId: p[i].StudentId,
MessageType: "warn",
MessageTitle: "您参加的课程 “" + p[i].ProjectTitle + "” 将于 " +
p[i].EndTime.Format("2006-01-02 15:04:05") + " 结束,请注意提交作业",
Content: "",
ReadMessage: false,
CreateAt: time.Now(),
})
}
return nil
}

View File

@ -1,50 +0,0 @@
package models
import (
"time"
"xorm.io/xorm"
)
type Comment struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
ProjectId int64 `json:"projectId" xorm:"not null index"`
UserId string `json:"userId" xorm:"not null index"`
UserAvatar string `json:"userAvatar" xorm:"not null"`
UserName string `json:"userName" xorm:"not null"`
IsTeacher bool `json:"isTeacher" xorm:"not null index default false"`
Content string `json:"content" xorm:"text"`
CreateAt time.Time `json:"createAt" xorm:"created"`
}
func (c *Comment) GetEngine() *xorm.Session {
return adapter.Engine.Table(c)
}
func (c *Comment) Create() (err error) {
_, err = c.GetEngine().Insert(c)
return
}
func (c *Comment) Delete() (err error) {
_, err = c.GetEngine().Delete(c)
return
}
func GetProjectComments(pid string, from int, size int, text string, teacher bool) (comments []Comment, rows int64, err error) {
s := (&Comment{}).GetEngine().Where("project_id = ?", pid)
s2 := (&Comment{}).GetEngine().Where("project_id = ?", pid)
if teacher {
s = s.Where("is_teacher = true")
s2 = s2.Where("is_teacher = true")
}
if text != "" {
s = s.Where("content like %?%", text)
s2 = s2.Where("content like %?%", text)
}
s = s.Desc("create_at").Limit(size, from)
rows, err = s2.Count(&Comment{})
err = s.Find(&comments)
return
}

View File

@ -1,25 +0,0 @@
package models
type Evaluate struct {
Chapter `xorm:"extends"`
SectionOutline `xorm:"extends"`
}
func GetProjectEvaluate(pid string) (evaluate []Evaluate, err error) {
var c []Chapter
err = (&Chapter{}).GetEngine().
Where("project_id = ?", pid).
Asc("chapter_number").
Find(&c)
evaluate = make([]Evaluate, len(c))
var outline SectionOutline
for i:=0; i< len(c); i++ {
evaluate[i].Chapter = c[i]
err = (&Section{}).GetEngine().
Where("chapter_id = ?", c[i].Id).
Find(&outline)
evaluate[i].SectionOutline = outline
}
return
}

View File

@ -1,64 +0,0 @@
package models
import (
"bytes"
"strings"
)
func getSubjectExistSql(subject string) (sql string) {
if subject == "" {
return ""
} else {
s := strings.Split(subject, ",")
sql := `
and exists (
select project_subject.project_id from project_subject where project_subject.project_id = project.id and (`
var buf bytes.Buffer
buf.WriteString(sql)
n := len(s)
for i:=0; i<n; i++ {
buf.WriteString(" project_subject.subject = '")
buf.WriteString(s[i])
buf.WriteString("' ")
if i < n-1 {
buf.WriteString(" or ")
}
}
buf.WriteString(" ) ) ")
return buf.String()
}
}
func getSkillExistSql(skill string) (sql string) {
if skill == "" {
return ""
} else {
s := strings.Split(skill, ",")
sql := `
and exists (
select project_skill.project_id from project_skill where project_skill.project_id = project.id and (`
var buf bytes.Buffer
buf.WriteString(sql)
n := len(s)
for i:=0; i<n; i++ {
buf.WriteString(" project_skill.skill = '")
buf.WriteString(s[i])
buf.WriteString("' ")
if i < n-1 {
buf.WriteString(" or ")
}
}
buf.WriteString(" ) ) ")
return buf.String()
}
}
func getTextSql(text string) (sql string) {
if text == "" {
return ""
} else {
var buf bytes.Buffer
buf.WriteString(" and project.project_title like '%")
buf.WriteString(text)
buf.WriteString("%'")
return buf.String()
}
}

View File

@ -1,11 +0,0 @@
package models
func GetLatestProjects(num int) (projects []Project, err error) {
err = (&Project{}).GetEngine().
Where("closed = false").
Where("published = true").
Desc("create_at").
Limit(num, 0).
Find(&projects)
return
}

View File

@ -1,86 +0,0 @@
package models
import (
"time"
"xorm.io/xorm"
)
type Message struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
ReceiverId string `json:"receiverId" xorm:"index"`
MessageType string `json:"messageType" xorm:"not null index"` // warn error info
MessageTitle string `json:"messageTitle" xorm:"text"`
Content string `json:"content" xorm:"longtext"`
ReadMessage bool `json:"readMessage" xorm:"default false index"`
CreateAt time.Time `json:"createAt" xorm:"created"`
}
func (m *Message) GetEngine() *xorm.Session {
return adapter.Engine.Table(m)
}
func (m *Message) Create() (err error) {
_, err = m.GetEngine().Insert(m)
return
}
func (m *Message) Delete() (err error) {
_, err = m.GetEngine().ID(m.Id).Delete(m)
return
}
func ReadMessage(messageId int64, uid string) (err error) {
_, err = (&Message{}).GetEngine().
ID(messageId).
MustCols("read_message").
Update(&Message{
Id: messageId,
ReceiverId: uid,
ReadMessage: true,
})
return
}
func ReadAllMessage(uid string) (err error) {
_, err = (&Message{}).GetEngine().
Where("receiver_id = ?", uid).
MustCols("read_message").
Update(&Message{
ReceiverId: uid,
ReadMessage: true,
})
return
}
func GetMessages(uid string, orderType string, messageType string, readType string, from int, size int) (m []Message, rows int64, err error) {
s := (&Message{}).GetEngine().
Where("receiver_id = ?", uid)
s2 := (&Message{}).GetEngine().
Where("receiver_id = ?", uid)
if readType == "read" {
s = s.Where("read_message = true")
s2 = s2.Where("read_message = true")
} else if readType == "unread" {
s = s.Where("read_message = false")
s2 = s2.Where("read_message = false")
}
rows, err = s2.Count(&Message{})
if orderType == "asc" {
s = s.Asc("create_at")
} else {
s = s.Desc("create_at")
}
err = s.Desc("create_at").Limit(size, from).Find(&m)
return
}
func CreateMessage(msg *Message) bool {
err := msg.Create()
if err != nil {
return false
}
return true
}

View File

@ -1,248 +0,0 @@
package models
import (
"errors"
"time"
"xorm.io/xorm"
)
type Project struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
Image string `json:"image" xorm:"longtext"`
ProjectTitle string `json:"projectTitle"`
ProjectIntroduce string `json:"projectIntroduce"`
ProjectGoal string `json:"projectGoal"`
TeacherId string `json:"teacherId" xorm:"index"`
Subjects string `json:"subjects" xorm:"default ''"`
Skills string `json:"skills" xorm:"default ''"`
CreateAt time.Time `json:"createAt" xorm:"created"`
Closed bool `json:"closed" xorm:"default false index"`
ClosedAt time.Time `json:"closedAt"`
Published bool `json:"published" xorm:"default false index"`
PublishedAt time.Time `json:"publishedAt"`
TimedEnd bool `json:"timedEnd"`
EndTime time.Time `json:"endTime"`
ReadNum int64 `json:"readNum" xorm:"default 0"`
JoinNum int64 `json:"joinNum" xorm:"default 0"`
LearnMinuteWeight int `json:"learnMinuteWeight" xorm:"default 100"`
}
type Favourite struct {
ProjectId int64 `json:"projectId" xorm:"not null pk"`
UserId string `json:"userId" xorm:"not null pk"`
CreateAt time.Time `json:"createAt" xorm:"created"`
}
type ProjectDetail struct {
Project `xorm:"extends"`
Learning bool `json:"learning"`
Created bool `json:"created"`
Favourite bool `json:"favourite"`
}
type ProjectSkill struct {
Skill string `json:"skill" xorm:"not null pk"`
ProjectId int64 `json:"projectId" xorm:"not null pk"`
}
type ProjectSubject struct {
Subject string `json:"subject" xorm:"not null pk"`
ProjectId int64 `json:"projectId" xorm:"not null pk"`
}
func (p *Project) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *ProjectSkill) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *ProjectSubject) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (f *Favourite) GetEngine() *xorm.Session {
return adapter.Engine.Table(f)
}
func GetProjectById(pid int64) (project Project, err error) {
var b bool
b, err = (&Project{}).GetEngine().
ID(pid).
Get(&project)
if !b {
err = errors.New("404")
}
return
}
func GetProjectByPidForTeacher(pid int64, uid string) (pd ProjectDetail, err error) {
var p Project
c, err := (&Project{}).GetEngine().
ID(pid).
Get(&p)
favourite, _ := (&Favourite{}).GetEngine().
Exist(&Favourite{
ProjectId: pid,
UserId: uid,
})
created := uid == p.TeacherId
pd = ProjectDetail{
Project: p,
Learning: false,
Created: created,
Favourite: favourite,
}
if !c {
err = errors.New("404")
}
return
}
func GetProjectByPidForStudent(pid int64, uid string) (pd ProjectDetail, err error) {
c, err := (&Project{}).GetEngine().
Where("project.id = ?", pid).
Join("LEFT OUTER", LearnProject{}, "project.id = learn_project.project_id and student_id = ?", uid).
Get(&pd)
favourite, _ := (&Favourite{}).GetEngine().
Exist(&Favourite{
ProjectId: pid,
UserId: uid,
})
pd.Favourite = favourite
if !c {
err = errors.New("404")
}
return
}
func (p *Project) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *ProjectSkill) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *ProjectSubject) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *Project) Update() (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
return
}
func UpdateWeight(p Project, t[]Task) (err error) {
session := adapter.Engine.NewSession()
defer session.Close()
session.Begin()
_, err = session.Table(&Project{}).ID(p.Id).Update(&p)
for i:=0; i< len(t); i++ {
(&t[i]).Update()
}
session.Commit()
return
}
func (p *Project) UpdateInfo(subjects []*ProjectSubject, skills []*ProjectSkill) (err error) {
_, err = p.GetEngine().ID(p.Id).MustCols("timed_end").Update(p)
n1 := len(subjects)
for i:=0; i<n1; i++ {
_ = subjects[i].Create()
}
n2 := len(skills)
for i:=0; i<n2; i++ {
_ = skills[i].Create()
}
return
}
func (p *Project) Delete() (err error) {
pid := p.Id
_, err = p.GetEngine().ID(p.Id).Delete(p)
err = DeleteProjectChapters(pid)
return
}
func UpdatePublished(p Project) (err error) {
_, err = (&Project{}).GetEngine().
Where("id = ?", p.Id).
Cols("published", "published_at").
Update(p)
return
}
func UpdateClosed(p Project) (err error) {
_, err = (&Project{}).GetEngine().
Where("id = ?", p.Id).
Cols("closed", "closed_at").
Update(p)
return
}
func AddFavourite(uid string, pid int64) (err error) {
_, err = (&Favourite{}).GetEngine().Insert(Favourite{
ProjectId: pid,
UserId: uid,
CreateAt: time.Time{},
})
return
}
func RemoveFavourite(uid string, pid int64) (err error) {
_, err = (&Favourite{}).GetEngine().Delete(Favourite{
ProjectId: pid,
UserId: uid,
})
return
}
func GetSubjects() (subjects []string, err error) {
err = (&ProjectSubject{}).GetEngine().
Cols("subject").
Distinct("subject").
Find(&subjects)
return
}
func GetSkills() (skills []string, err error) {
err = (&ProjectSkill{}).GetEngine().
Cols("skill").
Distinct("skill").
Find(&skills)
return
}
func ViewProject(pid string) (err error) {
_, err = adapter.Engine.
Exec("update project set read_num = read_num + 1 where id = ?", pid)
return
}
func CloneProject(uid string, pid int64) (err error) {
var project Project
_, err = (&Project{}).GetEngine().ID(pid).Get(&project)
project.TeacherId = uid
project.Id = 0
project.Closed = false
project.Published = false
project.CreateAt = time.Now()
project.ReadNum = 0
project.JoinNum = 0
project.ProjectTitle = project.ProjectTitle + "-副本"
_, err = (&Project{}).GetEngine().Insert(&project)
newPid := project.Id
err = CloneProjectChapters(pid, newPid)
return
}

View File

@ -1,137 +0,0 @@
package models
import (
"fmt"
)
// ============= student ===================
func GetMyProjectListBySid(sid string, from int, size int,
subject string, skill string, text string, orderBy string, orderType string, learning bool) (p []ProjectDetail, rows int64, err error) {
const baseSql = `
select %s from (
select * from project
inner join learn_project on (
learn_project.student_id = '%s' and
learn_project.learning = %v and
project.closed = false and
project.id = learn_project.project_id
)
) as project where true
%s %s %s
`
const pageSql = " order by %s %s limit %d, %d "
e1 := getSubjectExistSql(subject)
e2 := getSkillExistSql(skill)
e3 := getTextSql(text)
sql1 := fmt.Sprintf(baseSql, "*", sid, learning, e1, e2, e3) +
fmt.Sprintf(pageSql, orderBy, orderType, from, size)
sql2 := fmt.Sprintf(baseSql, "count(*)", sid, learning, e1, e2, e3)
err = adapter.Engine.
SQL(sql1).
Find(&p)
_, err = adapter.Engine.
SQL(sql2).
Get(&rows)
return
}
func GetPublicProjectListForStudent(sid string, from int, size int,
subject string, skill string, text string, orderBy string, orderType string, favourite bool) (p []ProjectDetail, rows int64, err error) {
const baseSql = `
select %s from (
select * from project where project.published = true and project.closed = false
%s %s %s %s
) as p1 left join learn_project on (
p1.id = learn_project.project_id and learn_project.student_id = '%s'
)
`
const pageSql = " order by p1.%s %s limit %d, %d "
e0 := ""
if favourite {
e0 = `
and exists (
select favourite.project_id from favourite where favourite.project_id = project.id and favourite.user_id = '%s'
)
`
e0 = fmt.Sprintf(e0, sid)
}
e1 := getSubjectExistSql(subject)
e2 := getSkillExistSql(skill)
e3 := getTextSql(text)
sql1 := fmt.Sprintf(baseSql, "*", e0, e1, e2, e3, sid) +
fmt.Sprintf(pageSql, orderBy, orderType, from, size)
sql2 := fmt.Sprintf(baseSql, "count(*)", e0, e1, e2, e3, sid)
err = adapter.Engine.
SQL(sql1).
Find(&p)
_, err = adapter.Engine.
SQL(sql2).
Get(&rows)
return
}
// ============= teacher ===================
func GetMyProjectListByTid(tid string, from int, size int,
subject string, skill string, text string, orderBy string, orderType string, published bool, closed bool) (p []ProjectDetail, rows int64, err error) {
const baseSql = `
select %s from project where teacher_id = '%s'
and published = %v
and closed = %v
%s %s %s
`
const pageSql = " order by %s %s limit %d, %d "
e1 := getSubjectExistSql(subject)
e2 := getSkillExistSql(skill)
e3 := getTextSql(text)
sql1 := fmt.Sprintf(baseSql, "*", tid, published, closed, e1, e2, e3) +
fmt.Sprintf(pageSql, orderBy, orderType, from, size)
sql2 := fmt.Sprintf(baseSql, "count(*)", tid, published, closed, e1, e2, e3)
err = adapter.Engine.
SQL(sql1).
Find(&p)
_, err = adapter.Engine.
SQL(sql2).
Get(&rows)
return
}
func GetPublicProjectListForTeacher(sid string, from int, size int,
subject string, skill string, text string, orderBy string, orderType string, favourite bool) (p []ProjectDetail, rows int64, err error) {
baseSql := "select %s from project where published = true and closed = false %s %s %s %s "
pageSql := " order by %s %s limit %d, %d "
e0 := ""
if favourite {
e0 = `
and exists (
select favourite.project_id from favourite where favourite.project_id = project.id and favourite.user_id = '%s'
)
`
e0 = fmt.Sprintf(e0, sid)
}
e1 := getSubjectExistSql(subject)
e2 := getSkillExistSql(skill)
e3 := getTextSql(text)
sql1 := fmt.Sprintf(baseSql, "*", e0, e1, e2, e3) +
fmt.Sprintf(pageSql, orderBy, orderType, from, size)
sql2 := fmt.Sprintf(baseSql, "count(*)", e0, e1, e2, e3)
err = adapter.Engine.
SQL(sql1).
Find(&p)
_, err = adapter.Engine.
SQL(sql2).
Get(&rows)
return
}

View File

@ -1,45 +0,0 @@
package models
import (
"xorm.io/xorm"
)
type Resource struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SectionId int64 `json:"sectionId" xorm:"not null index unique"`
Content string `json:"content" xorm:"longtext"`
}
func (p *Resource) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *Resource) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *Resource) Update() (err error) {
_, err = p.GetEngine().
ID(p.Id).
Update(p)
return
}
func GetResourceById(id string) (r Resource, err error) {
_, err = (&Resource{}).GetEngine().
ID(id).
Get(&r)
return
}
func DeleteSectionResource(sid int64) (err error) {
_, err = (&Resource{}).GetEngine().Where("section_id = ?", sid).Delete(&Resource{})
return
}
func CloneSectionResource(sid int64, newSid int64) (err error) {
var resource Resource
_, err = (&Resource{}).GetEngine().Where("section_id = ?", sid).Get(&resource)
resource.SectionId = newSid
resource.Id = 0
_, err = (&Resource{}).GetEngine().Insert(&resource)
return
}

View File

@ -1,156 +0,0 @@
package models
import (
"fmt"
"xorm.io/xorm"
)
type Section struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
ChapterId int64 `json:"chapterId" xorm:"index"`
SectionName string `json:"sectionName"`
SectionNumber int `json:"sectionNumber" xorm:"index"`
ChapterNumber int `json:"chapterNumber" xorm:"index"`
SectionMinute int `json:"sectionMinute" xorm:"default 1"`
}
type SectionFile struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SectionId int64 `json:"sectionId" xorm:"not null index"`
FilePath string `json:"filePath"`
Name string `json:"name"`
Url string `json:"url"`
}
type SectionMinute struct {
Section `xorm:"extends"`
LearnSection `xorm:"extends"`
}
type SectionDetail struct {
Section `xorm:"extends"`
Resource `json:"resource" xorm:"extends"`
}
type SectionOutline struct {
Section `xorm:"extends"`
Tasks []Task `json:"tasks" xorm:"extends"`
}
func (p *Section) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *SectionFile) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *SectionFile) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *SectionFile) Update() (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
return
}
func GetSectionFiles(sid string) (files []SectionFile, err error) {
err = (&SectionFile{}).GetEngine().
Where("section_id = ?", sid).
Find(&files)
return
}
func DeleteSectionFile(fid string) (err error) {
_, err = (&SectionFile{}).GetEngine().ID(fid).Delete(&SectionFile{})
return
}
func (p *Section) Create() (err error) {
session := adapter.Engine.NewSession()
defer session.Close()
session.Begin()
_, err = session.Insert(p)
_, err = session.Insert(Resource{
SectionId: p.Id,
})
session.Commit()
return
}
func (p *Section) Update() (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
return
}
func UpdateSectionsMinute(sections []Section) (err error) {
for i:=0; i< len(sections); i++ {
fmt.Println(sections[i])
err = (&sections[i]).Update()
}
return
}
func (p *Section) Delete() (err error) {
session := adapter.Engine.NewSession()
defer session.Close()
session.Begin()
_, err = session.Engine().
Exec("update section set section_number = section_number - 1 " +
"where chapter_id = ? and section_number > ?", p.ChapterId, p.SectionNumber)
_, err = session.Table(&Section{}).ID(p.Id).Delete(p)
session.Commit()
return
}
func ExchangeSections(id1 string, id2 string) (err error) {
_, err = adapter.Engine.
Exec("update section c1 join section c2 on (c1.id = ? and c2.id = ?) " +
"set c1.section_number = c2.section_number, c2.section_number = c1.section_number", id1, id2)
return
}
func GetSectionsByCid(cid string) (s []Section, err error) {
err = (&Section{}).GetEngine().
Where("chapter_id = ?", cid).
Asc("section_number").
Find(&s)
return
}
func GetSectionDetailById(sid string) (s SectionDetail, err error) {
_, err = adapter.Engine.
Table("section").
Where("section.id = ?", sid).
Join("INNER", "resource", "resource.section_id = section.id").
Get(&s)
return
}
func DeleteChapterSections(cid int64) (err error) {
var sections []Section
err = (&Section{}).GetEngine().Where("chapter_id = ?", cid).Find(&sections)
for i:=0; i< len(sections); i++ {
s := sections[i]
sid := s.Id
_, err = (&Section{}).GetEngine().ID(sid).Delete(&Section{})
err = DeleteSectionResource(sid)
err = DeleteTasks(sid)
}
return
}
func CloneChapterSections(newPid int64, cid int64, newCid int64) (err error) {
var sections []Section
err = (&Section{}).GetEngine().Where("chapter_id = ?", cid).Find(&sections)
for i:=0; i< len(sections); i++ {
s := sections[i]
sid := s.Id
s.Id = 0
s.ChapterId = newCid
_, err = (&Section{}).GetEngine().Insert(&s)
newSid := s.Id
err = CloneSectionResource(sid, newSid)
err = CloneTasks(newPid, sid, newSid)
}
return
}

View File

@ -1,23 +0,0 @@
select * from (
select * from project
inner join learn_project on (
learn_project.student_id = 1 and
learn_project.learning = true and
project.id = learn_project.project_id
)
) as project where true
and exists (
select project_subject.project_id from project_subject
where project_subject.project_id = project.id and (
project_subject.subject = '英语' or project_subject.subject = '数学'
)
)
and exists (
select project_skill.project_id from project_skill
where project_skill.project_id = project.id and (
project_skill.skill = '生活与职业技能'
)
)
and project.project_title like '%神奇%'
order by create_at desc limit 0, 10

View File

@ -1,18 +0,0 @@
select * from project where teacher_id = 1
and published = true
and closed = false
and exists (
select project_subject.project_id from project_subject
where project_subject.project_id = project.id and (
project_subject.subject = '英语' or project_subject.subject = '数学'
)
)
and exists (
select project_skill.project_id from project_skill
where project_skill.project_id = project.id and (
project_skill.skill = '生活与职业技能'
)
)
and project.project_title like '%神奇%'
order by create_at desc limit 0, 10

View File

@ -1,19 +0,0 @@
select * from (
select * from project where project.published = true
and exists (
select project_subject.project_id from project_subject
where project_subject.project_id = project.id and (
project_subject.subject = '英语' or project_subject.subject = '数学'
)
)
and exists (
select project_skill.project_id from project_skill
where project_skill.project_id = project.id and (
project_skill.skill = '生活与职业技能'
)
)
and project.project_title like '%%'
) as p1 left join learn_project on (
p1.id = learn_project.project_id and learn_project.student_id = 1
)
order by p1.create_at desc limit 0, 10

View File

@ -1,16 +0,0 @@
select * from project where published = true
and exists (
select project_subject.project_id from project_subject
where project_subject.project_id = project.id and (
project_subject.subject = '英语' or project_subject.subject = '数学'
)
)
and exists (
select project_skill.project_id from project_skill
where project_skill.project_id = project.id and (
project_skill.skill = '生活与职业技能'
)
)
and project.project_title like '%神奇%'
order by create_at desc limit 0, 10

View File

@ -1,154 +0,0 @@
package models
import (
"strconv"
"time"
"xorm.io/xorm"
)
type LearnProject struct {
Avatar string `json:"avatar" xorm:"text"`
Name string `json:"name"`
StudentId string `json:"studentId" xorm:"not null index pk"`
ProjectId int64 `json:"projectId" xorm:"not null index pk"`
Learning bool `json:"learning" xorm:"index default 0"`
JoinTime time.Time `json:"joinTime" xorm:"created"`
}
type LearnSection struct {
StudentId string `json:"studentId" xorm:"not null pk"`
SectionId int64 `json:"sectionId" xorm:"not null pk"`
LearnMinute int `json:"learnMinute" xorm:"default 0"`
LearnSecond int `json:"learnSecond" xorm:"default 0"`
}
type LastLearn struct {
StudentId string `json:"studentId" xorm:"not null pk"`
ProjectId int64 `json:"projectId" xorm:"not null pk"`
SectionId int64 `json:"sectionId" xorm:"not null index"`
ExitAt time.Time `json:"exitAt" xorm:"updated"`
}
type LastLearnSection struct {
LastLearn `xorm:"extends"`
Id int64 `json:"id"`
SectionName string `json:"sectionName"`
ChapterNumber int `json:"chapterNumber"`
SectionNumber int `json:"sectionNumber"`
Last bool `json:"last"`
}
func (l *LearnProject) GetEngine() *xorm.Session {
return adapter.Engine.Table(l)
}
func (l *LearnSection) GetEngine() *xorm.Session {
return adapter.Engine.Table(l)
}
func (l *LastLearn) GetEngine() *xorm.Session {
return adapter.Engine.Table(l)
}
func (l *LearnProject) Create() (err error) {
_, err = (&LearnProject{}).GetEngine().Insert(l)
_, err = adapter.Engine.
Exec("update project set join_num = join_num + 1 where id = ?", l.ProjectId)
return
}
func (l *LearnProject) Update() (err error) {
_, err = (&LearnProject{}).GetEngine().
Where("student_id = ?", l.StudentId).
Where("project_id = ?", l.ProjectId).
MustCols("learning").
Update(l)
return
}
func (l *LearnProject) Delete() (err error) {
_, err = (&LearnProject{}).GetEngine().
Where("student_id = ?", l.StudentId).
Where("project_id = ?", l.ProjectId).
Delete(l)
_, err = adapter.Engine.
Exec("update project set join_num = join_num - 1 where id = ?", l.ProjectId)
return
}
func IsLearningProject(pid string, uid string) (e bool) {
var err error
id, err := strconv.ParseInt(pid, 10, 64)
e, err = (&LearnProject{}).GetEngine().Exist(&LearnProject{
StudentId: uid,
ProjectId: id,
Learning: true,
})
if err != nil {
e = false
}
return
}
func GetProjectStudents(pid string, from int, size int) (s []LearnProject, rows int64, err error) {
err = (&LearnProject{}).GetEngine().
Where("project_id = ?", pid).
Desc("join_time").
Limit(size, from).
Find(&s)
rows, err = (&LearnProject{}).GetEngine().
Where("project_id = ?", pid).
Count()
return
}
func GetLearnSection(sectionId int64, studentId string, projectId int64) (l LearnSection, err error) {
var b bool
b, err = (&LearnSection{}).GetEngine().
Where("section_id = ?", sectionId).
Where("student_id = ?", studentId).
Get(&l)
if !b {
l.SectionId = sectionId
l.StudentId = studentId
err = (&l).Create(projectId)
}
return
}
func GetLastLearnSection(studentId string, projectId string) (l LastLearnSection, err error) {
var b bool
b, err = (&LastLearn{}).GetEngine().
Where("student_id = ?", studentId).
Where("project_id = ?", projectId).
Join("LEFT OUTER", Section{}, "last_learn.section_id = section.id").
Get(&l)
l.Last = b
return
}
func (l *LearnSection) Create(projectId int64) (err error) {
_, err = (&LearnSection{}).GetEngine().Insert(l)
_, err = (&LastLearn{}).GetEngine().Insert(&LastLearn{
StudentId: l.StudentId,
ProjectId: projectId,
SectionId: l.SectionId,
ExitAt: time.Now(),
})
return
}
func (l *LearnSection) Update(projectId int64) (err error) {
_, err = (&LearnSection{}).GetEngine().
Where("student_id = ?", l.StudentId).
Where("section_id = ?", l.SectionId).
Update(l)
_, err = (&LastLearn{}).GetEngine().
Where("student_id = ?", l.StudentId).
Where("project_id = ?", projectId).
Update(&LastLearn{
StudentId: l.StudentId,
ProjectId: projectId,
SectionId: l.SectionId,
ExitAt: time.Now(),
})
return
}

View File

@ -1,183 +0,0 @@
package models
import (
"strconv"
"strings"
"time"
"xorm.io/xorm"
)
type Submit struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
ProjectId int64 `json:"projectId" xorm:"not null index"`
StudentId string `json:"studentId" xorm:"not null index"`
TaskId int64 `json:"taskId" xorm:"not null index"`
SubmitType string `json:"submitType" xorm:"index"`
SubmitTitle string `json:"submitTitle"`
SubmitIntroduce string `json:"submitIntroduce" xorm:"text"`
SubmitContent string `json:"submitContent" xorm:"text"`
CreateAt time.Time `json:"createAt"`
Score int `json:"score" xorm:"default 0"`
Scored bool `json:"scored" xorm:"default false"`
}
type SubmitFile struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SubmitId int64 `json:"submitId" xorm:"not null index"`
FilePath string `json:"filePath"`
Name string `json:"name"`
Url string `json:"url"`
}
type Choice struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SubmitId int64 `json:"submitId" xorm:"not null index"`
QuestionId int64 `json:"questionId" xorm:"not null index"`
ChoiceOrder int `json:"choiceOrder"`
ChoiceOptions string `json:"choiceOptions" xorm:"text"`
}
type SubmitDetail struct {
Submit `json:"submit" xorm:"extends"`
Choices []Choice `json:"choices" xorm:"extends"`
Submitted bool `json:"submitted"`
}
func (p *Submit) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *SubmitFile) GetEngine() *xorm.Session {
return adapter.Engine.Table(p)
}
func (p *SubmitFile) Create() (err error) {
_, err = p.GetEngine().Insert(p)
return
}
func (p *SubmitFile) Update() (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
return
}
func GetSubmitFiles(sid string) (files []SectionFile, err error) {
err = (&SubmitFile{}).GetEngine().
Where("submit_id = ?", sid).
Find(&files)
return
}
func DeleteSubmitFile(fid string) (err error) {
_, err = (&SubmitFile{}).GetEngine().ID(fid).Delete(&SubmitFile{})
return
}
func (c *Choice) GetEngine() *xorm.Session {
return adapter.Engine.Table(c)
}
func (c *Choice) Create() (err error) {
_, err = c.GetEngine().Insert(c)
return
}
func (c *Choice) Update() (err error) {
_, err = c.GetEngine().ID(c.Id).Update(c)
return
}
func (p *Submit) Create(c []Choice) (err error) {
_, err = p.GetEngine().Insert(p)
if p.SubmitType == "survey" {
for i := 0; i < len(c); i ++ {
ci := &Choice{
SubmitId: p.Id,
QuestionId: c[i].QuestionId,
ChoiceOrder: c[i].ChoiceOrder,
ChoiceOptions: c[i].ChoiceOptions,
}
err = ci.Create()
}
CountSubmit(c, nil)
}
return
}
func (p *Submit) Update(c []Choice) (err error) {
_, err = p.GetEngine().ID(p.Id).Update(p)
if len(c) > 0 && p.SubmitType == "survey" {
var cs []Choice
err = (&Choice{}).GetEngine().
Where("submit_id = ?", p.Id).
Find(&cs)
for i:=0; i< len(c); i++ {
err = (&c[i]).Update()
}
CountSubmit(c, cs)
}
return
}
func CountSubmit(c []Choice, cl []Choice) {
if len(c) != len(cl) && cl != nil {
return
}
var (
err error
)
for i:=0; i< len(c); i++ {
var question Question
_, err = (&Question{}).GetEngine().ID(c[i].QuestionId).Get(&question)
if err != nil {
return
}
if question.QuestionType == "singleChoice" || question.QuestionType == "multipleChoice" ||
question.QuestionType == "scale5" || question.QuestionType == "scale7" {
l := len(strings.Split(question.QuestionOptions, ","))
count := make([]int, l)
if question.QuestionCount != "" {
count = string2List(question.QuestionCount)
}
opt := string2List(c[i].ChoiceOptions)
for j:=0; j<len(opt); j++ {
count[opt[j]] = count[opt[j]] + 1
}
if cl != nil {
opt2 := string2List(cl[i].ChoiceOptions)
for j:=0; j<len(opt2); j++ {
count[opt2[j]] = count[opt2[j]] - 1
}
}
question.QuestionCount = list2String(count)
err = question.Update()
}
}
}
func string2List(str string) []int {
var err error
l := strings.Split(str, ",")
res := make([]int, len(l))
for i:=0; i< len(l); i++ {
res[i], err = strconv.Atoi(l[i])
if err != nil {
res[i] = 0
}
}
return res
}
func list2String(l []int) string {
var s strings.Builder
for i:=0; i< len(l); i++ {
s.WriteString(strconv.Itoa(l[i]))
if i != len(l)-1 {
s.WriteString(",")
}
}
return s.String()
}

View File

@ -1,105 +0,0 @@
package models
import (
"xorm.io/xorm"
)
type Survey struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
TaskId int64 `json:"taskId" xorm:"not null index"`
SurveyTitle string `json:"surveyTitle"`
SurveyIntroduce string `json:"surveyIntroduce"`
}
type Question struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SurveyId int64 `json:"surveyId" xorm:"not null index"`
QuestionOrder int `json:"questionOrder" xorm:"not null index"`
QuestionTitle string `json:"questionTitle"`
QuestionType string `json:"questionType"`
QuestionOptions string `json:"questionOptions" xorm:"text"`
QuestionCount string `json:"questionCount" xorm:"text"`
}
type SurveyDetail struct {
Survey `json:"survey" xorm:"extends"`
Questions []Question `json:"questions" xorm:"extends"`
}
func (s *Survey) GetEngine() *xorm.Session {
return adapter.Engine.Table(s)
}
func (s *Survey) Create() (err error) {
_, err = s.GetEngine().Insert(s)
return
}
func (s *Survey) Update() (err error) {
_, err = s.GetEngine().ID(s.Id).Update(s)
return
}
func (s *Survey) Delete() (err error) {
_, err = s.GetEngine().ID(s.Id).Delete(s)
return
}
func (q *Question) GetEngine() *xorm.Session {
return adapter.Engine.Table(q)
}
func (q *Question) Create() (err error) {
_, err = q.GetEngine().Insert(q)
return
}
func (q *Question) Update() (err error) {
_, err = q.GetEngine().ID(q.Id).Update(q)
return
}
func (q *Question) Delete() (err error) {
_, err = q.GetEngine().ID(q.Id).Delete(q)
return
}
func GetSurveyByTaskId(tid string) (s Survey, qs []Question, err error) {
_, err = (&Survey{}).GetEngine().
Where("task_id = ?", tid).
Get(&s)
err = (&Question{}).GetEngine().
Where("survey_id = ?", s.Id).
Asc("question_order").
Find(&qs)
return
}
func ExchangeQuestion(id1 string, id2 string) (err error) {
_, err = adapter.Engine.
Exec("update question t1 join question t2 on (t1.id = ? and t2.id = ?) " +
"set t1.question_order = t2.question_order, t2.question_order = t1.question_order", id1, id2)
return
}
func DeleteSurvey(tid int64) (err error) {
var survey Survey
_, err = (&Survey{}).GetEngine().Where("task_id = ?", tid).Get(&survey)
suid := survey.Id
_, err = (&Survey{}).GetEngine().ID(suid).Delete(&Survey{})
_, err = (&Question{}).GetEngine().Where("survey_id = ?", suid).Delete(&Question{})
return
}
func CloneSurvey(tid int64, newTid int64) (err error) {
var survey Survey
_, err = (&Survey{}).GetEngine().Where("task_id = ?", tid).Get(&survey)
suid := survey.Id
survey.Id = 0
survey.TaskId = newTid
_, err = (&Survey{}).GetEngine().Insert(&survey)
newSuid := survey.Id
var questions []Question
err = (&Question{}).GetEngine().Where("survey_id = ?", suid).Find(&questions)
for i:=0; i< len(questions); i++ {
q := questions[i]
q.Id = 0
q.SurveyId = newSuid
q.QuestionCount = ""
_, err = (&Question{}).GetEngine().Insert(&q)
}
return
}

View File

@ -1,225 +0,0 @@
package models
import (
"xorm.io/xorm"
)
type Task struct {
Id int64 `json:"id" xorm:"not null pk autoincr"`
SectionId int64 `json:"sectionId" xorm:"not null index"`
ProjectId int64 `json:"projectId" xorm:"not null index"`
SectionNumber int `json:"sectionNumber" xorm:"index"`
ChapterNumber int `json:"chapterNumber" xorm:"index"`
TaskOrder int `json:"taskOrder"`
TaskTitle string `json:"taskTitle"`
TaskIntroduce string `json:"taskIntroduce" xorm:"text"`
TaskType string `json:"taskType" xorm:"index"`
TaskWeight int `json:"taskWeight"`
}
type TaskEvaluate struct {
Task `xorm:"extends"`
Submitted bool `json:"submitted"`
Submit Submit `json:"submit"`
}
type TaskDetail struct {
Task `xorm:"extends"`
SurveyDetail `xorm:"extends"`
SubmitDetail `xorm:"extends"`
}
func (t *Task) GetEngine() *xorm.Session {
return adapter.Engine.Table(t)
}
func (t *Task) Create() (err error) {
session := adapter.Engine.NewSession()
defer session.Close()
session.Begin()
_, err = session.Insert(t)
if t.TaskType == "survey" {
_, err = session.Insert(Survey{
TaskId: t.Id,
})
}
session.Commit()
return
}
func (t *Task) Update() (err error) {
_, err = t.GetEngine().ID(t.Id).Update(t)
return
}
func (t *Task) Delete() (err error) {
_, err = t.GetEngine().ID(t.Id).Delete(t)
return
}
func GetSectionTasks(sid string, uid string, learning bool) (t []TaskDetail, err error) {
err = (&Task{}).GetEngine().
Where("section_id = ?", sid).
Asc("task_order").
Find(&t)
var b bool
for i := 0; i < len(t); i ++ {
var s Survey
var qs []Question
var c []Choice
if t[i].TaskType == "survey" {
var m Submit
_, err = (&Survey{}).GetEngine().
Where("task_id = ?", t[i].Id).
Get(&s)
err = (&Question{}).GetEngine().
Where("survey_id = ?", s.Id).
Asc("question_order").
Find(&qs)
t[i].Survey = s
t[i].Questions = qs
if learning {
b, err = (&Submit{}).GetEngine().
Where("task_id = ?", t[i].Id).
Where("student_id = ?", uid).
Get(&m)
if b {
t[i].Submitted = true
}
t[i].Submit = m
err = (&Choice{}).GetEngine().
Where("submit_id = ?", m.Id).
Asc("choice_order").
Find(&c)
t[i].Choices = c
}
} else {
var m Submit
if learning {
b, err = (&Submit{}).GetEngine().
Where("task_id = ?", t[i].Id).
Where("student_id = ?", uid).
Get(&m)
t[i].Submit = m
if b {
t[i].Submitted = true
}
}
}
}
return
}
func ExchangeTasks(cid1 string, cid2 string) (err error) {
_, err = adapter.Engine.
Exec("update task t1 join task t2 on (t1.id = ? and t2.id = ?) " +
"set t1.task_order = t2.task_order, t2.task_order = t1.task_order", cid1, cid2)
return
}
func GetProjectTasksDetail(sid string, uid string, showSubmit bool) (t []TaskDetail, err error) {
err = (&Task{}).GetEngine().
Where("project_id = ?", sid).
Asc("chapter_number").
Asc("section_number").
Asc("task_order").
Find(&t)
var b bool
for i := 0; i < len(t); i ++ {
var s Survey
var qs []Question
var c []Choice
if t[i].TaskType == "survey" {
var m Submit
b, err = (&Survey{}).GetEngine().
Where("task_id = ?", t[i].Id).
Get(&s)
if b {
err = (&Question{}).GetEngine().
Where("survey_id = ?", s.Id).
Asc("question_order").
Find(&qs)
t[i].Questions = qs
}
t[i].Survey = s
if showSubmit {
b, err = (&Submit{}).GetEngine().
Where("task_id = ?", t[i].Id).
Where("student_id = ?", uid).
Get(&m)
if b {
t[i].Submitted = true
err = (&Choice{}).GetEngine().
Where("submit_id = ?", m.Id).
Asc("choice_order").
Find(&c)
t[i].Choices = c
}
t[i].Submit = m
}
} else {
var m Submit
if showSubmit {
b, err = (&Submit{}).GetEngine().
Where("task_id = ?", t[i].Id).
Where("student_id = ?", uid).
Get(&m)
t[i].Submit = m
if b {
t[i].Submitted = true
}
}
}
}
return
}
func GetProjectTasks(pid string) (t []TaskEvaluate, err error) {
err = (&Task{}).GetEngine().
Where("project_id = ?", pid).
Asc("chapter_number").
Asc("section_number").
Asc("task_order").
Find(&t)
return
}
func DeleteTasks(sid int64) (err error) {
var tasks []Task
err = (&Task{}).GetEngine().Where("section_id = ?", sid).Find(&tasks)
for i:=0; i<len(tasks); i++ {
t := tasks[i]
tid := t.Id
_, err = (&Task{}).GetEngine().ID(tid).Delete(&Task{})
if t.TaskType == "survey" {
err = DeleteSurvey(tid)
}
}
return
}
func CloneTasks(newPid int64, sid int64, newSid int64) (err error) {
var tasks []Task
err = (&Task{}).GetEngine().Where("section_id = ?", sid).Find(&tasks)
for i:=0; i<len(tasks); i++ {
t := tasks[i]
tid := t.Id
t.Id = 0
t.ProjectId = newPid
t.SectionId = newSid
_, err = (&Task{}).GetEngine().Insert(&t)
newTid := t.Id
if t.TaskType == "survey" {
err = CloneSurvey(tid, newTid)
}
}
return
}

View File

@ -1,46 +0,0 @@
package routers
import (
"OpenPBL/controllers"
"github.com/astaxie/beego/context"
"net/http"
"os"
"strings"
)
func apiFilter(ctx *context.Context) {
urlPath := ctx.Request.URL.Path
if strings.HasPrefix(urlPath, "/api/project-list") ||
strings.HasPrefix(urlPath, "/api/project") ||
strings.HasPrefix(urlPath, "/api/message") ||
strings.HasPrefix(urlPath, "/api/student") {
user := ctx.Input.Session("user")
if user == nil {
ctx.Output.JSON(controllers.Response{
Code: 401,
Msg: "请先登录",
}, true, false)
}
}
}
func TransparentStatic(ctx *context.Context) {
urlPath := ctx.Request.URL.Path
if strings.HasPrefix(urlPath, "/api") {
apiFilter(ctx)
return
}
path := "web/build"
if urlPath == "/" {
path += "/index.html"
} else {
path += urlPath
}
if _, err := os.Stat(path); os.IsNotExist(err) {
http.ServeFile(ctx.ResponseWriter, ctx.Request, "web/build/index.html")
} else {
http.ServeFile(ctx.ResponseWriter, ctx.Request, path)
}
}

View File

@ -1,44 +0,0 @@
// Package routers
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers
import (
"OpenPBL/controllers"
"github.com/astaxie/beego"
)
func init() {
ns := beego.NewNamespace("/api",
beego.NSNamespace("/auth",
beego.NSInclude(
&controllers.AuthController{})),
beego.NSNamespace("/project",
beego.NSInclude(
&controllers.ProjectController{})),
beego.NSNamespace("/project-list",
beego.NSInclude(
&controllers.ProjectListController{})),
beego.NSNamespace("/student",
beego.NSInclude(
&controllers.StudentController{})),
beego.NSNamespace("/message",
beego.NSInclude(
&controllers.MessageController{})),
beego.NSNamespace("/home",
beego.NSInclude(
&controllers.HomeController{})),
)
beego.AddNamespace(ns)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,93 +0,0 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</script>
</body>
</html>

View File

@ -1,53 +0,0 @@
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}
isValid = qp.state === sentState
if (oauth2.auth.schema.get("flow") === "accessCode" && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
} else {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: "Authorization failed: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
}
window.close();
}
</script>

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAyrGA;AA0lFA;AA4nFA;AA+9CA;AA+gDA;AAwrCA;AA60EA;;;;;AA6oCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAu9CA;AAy8EA;AAsiCA;AA+yFA;;;;;;;;;AAgkDA;AA2zIA;AAu7FA;AAmrFA;AAu0EA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8QA;AAmvGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":"","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AAmyHA;AAykGA;AA+9BA;AA6iCA;AAojCA;AAu5BA","sourceRoot":""}

View File

@ -1,39 +0,0 @@
package test
import (
"github.com/astaxie/beego/logs"
"net/http"
"net/http/httptest"
"testing"
"runtime"
"path/filepath"
_ "OpenPBL/routers"
"github.com/astaxie/beego"
. "github.com/smartystreets/goconvey/convey"
)
func init() {
_, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(apppath)
}
// TestGet is a sample to run an endpoint test
func TestGet(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/object", nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)
logs.Info("testing", "TestGet", "Code[%d]\n%s", w.Code, w.Body.String())
Convey("Subject: Test Station Endpoint\n", t, func() {
Convey("Status Code Should Be 200", func() {
So(w.Code, ShouldEqual, 200)
})
Convey("The Result Should Not Be Empty", func() {
So(w.Body.Len(), ShouldBeGreaterThan, 0)
})
})
}

View File

@ -1,30 +0,0 @@
package util
import "os"
func GetConfigFile(mode string) string {
if mode == "prod" {
if FileExist("conf/app-prod.conf") {
return "conf/app-prod.conf"
} else {
return "conf/app.conf"
}
} else if mode == "dev" {
if FileExist("conf/app-dev.conf") {
return "conf/app-dev.conf"
} else {
return "conf/app.conf"
}
} else {
return "conf/app.conf"
}
}
func FileExist(path string) bool {
_, err := os.Stat(path)
if err != nil {
return false
}
return true
}

View File

@ -1,16 +0,0 @@
package util
import "encoding/json"
func StructToJson(v interface{}) string {
data, err := json.Marshal(v)
if err != nil {
panic(err)
}
return string(data)
}
func JsonToStruct(data string, v interface{}) error {
return json.Unmarshal([]byte(data), v)
}

View File

@ -1,14 +0,0 @@
package util
import "github.com/casdoor/casdoor-go-sdk/auth"
func GetUserId(claims *auth.Claims) (id string) {
return claims.Name
}
func IsStudent(claims *auth.Claims) (b bool) {
return claims.Tag != "老师"
}
func IsTeacher(claims *auth.Claims) (b bool) {
return claims.Tag == "老师"
}

View File

@ -1,8 +0,0 @@
REACT_APP_CASDOOR_ENDPOINT=
REACT_APP_CLIENT_ID=
REACT_APP_APP_NAME=
REACT_APP_CASDOOR_ORGANIZATION='openct'
GENERATE_SOURCEMAP=false
SKIP_PREFLIGHT_CHECK=true

2
web/.eslintignore Normal file
View File

@ -0,0 +1,2 @@
node_modules
build

95
web/.eslintrc Normal file
View File

@ -0,0 +1,95 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"version": "detect"
}
},
"plugins": ["unused-imports"],
"extends": ["eslint:recommended", "plugin:react/recommended"],
"rules": {
// "eqeqeq": "error",
"semi": ["error", "always"],
"indent": ["error", 2],
// follow antd's style guide
"quotes": ["error", "double"],
"jsx-quotes": ["error", "prefer-double"],
"space-in-parens": ["error", "never"],
"object-curly-spacing": ["error", "never"],
"array-bracket-spacing": ["error", "never"],
"comma-spacing": ["error", { "before": false, "after": true }],
"react/jsx-curly-spacing": [
"error",
{ "when": "never", "allowMultiline": true, "children": true }
],
"arrow-spacing": ["error", { "before": true, "after": true }],
"space-before-blocks": ["error", "always"],
"spaced-comment": ["error", "always"],
"react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
"block-spacing": ["error", "never"],
"space-before-function-paren": ["error", "never"],
"no-trailing-spaces": ["error", { "ignoreComments": true }],
"eol-last": ["error", "always"],
// "no-var": ["error"],
"curly": ["error", "all"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"no-mixed-spaces-and-tabs": "error",
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true
}
],
"no-multiple-empty-lines": [
"error",
{ "max": 1, "maxBOF": 0, "maxEOF": 0 }
],
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"space-infix-ops": "error",
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"comma-style": ["error", "last"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "never",
"exports": "never",
"functions": "never"
}
],
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "none",
"argsIgnorePattern": "^_"
}
],
"react/prop-types": "off",
"react/display-name": "off",
"react/react-in-jsx-scope": "off",
// don't use strict mod now, otherwise there are a lot of errors in the codebase
"no-unused-vars": "off",
"react/no-deprecated": "warn",
"no-case-declarations": "warn",
"react/jsx-key": "warn"
}
}

8
web/.gitignore vendored
View File

@ -21,11 +21,3 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
.vscode
### Config file
.env.development
.env.production

View File

@ -6,20 +6,20 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
In the project directory, you can run:
### `yarn start`
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `yarn test`
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
@ -29,15 +29,15 @@ Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
@ -65,6 +65,6 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/a
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `yarn build` fails to minify
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

View File

@ -1,29 +1,17 @@
const CracoLessPlugin = require('craco-less');
const path = require("path");
const resolve = dir => path.resolve(__dirname, dir);
const CracoLessPlugin = require("craco-less");
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
javascriptEnabled: true,
},
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {"@primary-color": "rgb(45,120,213)"},
javascriptEnabled: true,
},
},
],
babel: {
plugins: [
['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
['@babel/plugin-proposal-decorators', { legacy: true }]
]
},
},
webpack: {
alias: {
'@': resolve("src"),
}
}
],
};

View File

@ -3,66 +3,51 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@craco/craco": "^6.2.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"antd": "^4.16.6",
"antd-img-crop": "^3.14.2",
"axios": "^0.21.1",
"babel-plugin-import": "^1.13.3",
"craco-less": "^1.18.0",
"echarts": "^5.1.2",
"echarts-for-react": "^3.0.1",
"enquire-js": "^0.2.1",
"file-saver": "^2.0.5",
"html-docx-js": "^0.3.1",
"localStorage": "^1.0.4",
"lodash": "^4.17.21",
"prop-types": "^15.7.2",
"qs": "^6.10.1",
"rc-banner-anim": "^2.4.5",
"rc-queue-anim": "^1.8.5",
"rc-scroll-anim": "^2.7.6",
"rc-tween-one": "^2.7.3",
"react": "^17.0.2",
"react-document-title": "^2.0.3",
"react-dom": "^17.0.2",
"react-github-button": "^0.1.11",
"react-lz-editor": "^0.12.1",
"react-pdf": "^5.3.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"serve": "^12.0.0",
"web-vitals": "^1.0.1"
"@ant-design/icons": "4.6.2",
"@craco/craco": "6.4.5",
"antd": "4.16.0",
"babel-eslint": "^10.1.0",
"braft-editor": "^2.3.9",
"casdoor-js-sdk": "^0.2.7",
"copy-to-clipboard": "^3.3.1",
"craco-less": "2.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"i18next": "^19.8.9",
"moment": "^2.29.1",
"react": "17.0.2",
"react-device-detect": "1.17.0",
"react-dom": "17.0.2",
"react-i18next": "^11.8.7",
"react-router-dom": "5.1.2",
"react-scripts": "5.0.1"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"start": "set PORT=8201 && craco start",
"build": "del build.zip 2>nul && set \"GENERATE_SOURCEMAP=false\" && set \"SKIP_PREFLIGHT_CHECK=true\" && craco build && 360zip.exe -ar build %cd%/build.zip || ECHO.",
"test": "craco test",
"eject": "react-scripts eject"
"eject": "craco eject",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"fix": "eslint --fix ."
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
"not op_mini all",
"ie 9, ie 10, ie 11"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
"last 1 safari version",
"ie 9, ie 10, ie 11"
]
},
"devDependencies": {
"rc-animate": "^3.1.1"
"eslint": "^7.11.0",
"eslint-plugin-react": "^7.30.1"
}
}

View File

@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>OpenItem</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "OpenItem",
"name": "OpenItem",
"icons": [
{
"src": "favicon.ico",

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -1,22 +0,0 @@
import {Route, BrowserRouter, Switch, Redirect} from "react-router-dom";
import './App.less';
import AuthCallback from "./pages/User/Auth/AuthCallback";
import HeaderLayout from "./pages/component/Layout/HeaderLayout";
import StudentEvidenceContent from "./pages/Project/Evidence/component/StudentEvidenceContent";
function App() {
return (
<div className="App">
<BrowserRouter>
<Route exact path="/" render={() => (
<Redirect to="/home"/>
)}/>
<Route path="/home" component={HeaderLayout} />
<Route exact path="/export/project/:projectId/student/:studentId/evidence" component={StudentEvidenceContent} />
<Route exact path="/callback" component={AuthCallback} />
</BrowserRouter>
</div>
);
}
export default App;

View File

@ -1,40 +0,0 @@
@import '~antd/dist/antd.less';
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -1,26 +0,0 @@
import request from './request'
import qs from 'qs';
const AuthApi = {
login(code, state) {
return request({
url: '/auth/login',
method: 'post',
data: qs.stringify({code: code, state: state}),
})
},
logout() {
return request({
url: '/auth/logout',
method: 'post'
})
},
getAccount() {
return request({
url: '/auth/account',
method: 'get',
})
}
}
export default AuthApi

View File

@ -1,43 +0,0 @@
import request from "./request";
import qs from "qs";
const ChapterApi = {
getProjectChapters(id, studentId) {
return request({
url: `/project/${id}/chapters`,
method: 'get',
params: {studentId: studentId}
})
},
createProjectChapter(chapter) {
return request({
url: `/project/${chapter.projectId}/chapter`,
method: 'post',
data: qs.stringify(chapter)
})
},
updateProjectChapter(chapter) {
return request({
url: `/project/${chapter.projectId}/chapter/${chapter.id}`,
method: 'post',
data: qs.stringify(chapter)
})
},
deleteProjectChapter(c) {
return request({
url: `/project/${c.projectId}/chapter/${c.id}/delete`,
method: 'post',
data: qs.stringify(c)
})
},
exchangeProjectChapter(pid, id1, id2) {
return request({
url: `/project/${pid}/chapters/exchange`,
method: 'post',
data: qs.stringify({chapterId1: id1, chapterId2: id2})
})
},
}
export default ChapterApi

View File

@ -1,27 +0,0 @@
import request from "./request";
import qs from 'qs'
const CommentApi = {
getProjectComments(pid, q) {
return request({
url: `/project/${pid}/comments`,
method: 'get',
params: q
})
},
createComment(pid, data) {
return request({
url: `/project/${pid}/comment`,
method: 'post',
data: qs.stringify(data)
})
},
deleteComment(pid, cid) {
return request({
url: `/project/${pid}/comment/${cid}/delete`,
method: 'post',
})
}
}
export default CommentApi

View File

@ -1,25 +0,0 @@
import qs from 'qs'
import {getCasdoorService} from "../pages/User/Auth/Auth";
const FileApi = {
uploadFile(owner, tag, parent, fullFilePath, file, provider="") {
let request = getCasdoorService()
let formData = new FormData();
formData.append("file", file);
return request({
url: `/api/upload-resource?owner=${owner}&tag=${tag}&parent=${parent}&fullFilePath=${encodeURIComponent(fullFilePath)}&provider=${provider}`,
method: 'post',
data: formData
})
},
deleteFile(data, provider="") {
let request = getCasdoorService()
return request({
url: `/api/delete-resource?provider=${provider}`,
method: 'post',
data: data
})
}
}
export default FileApi

View File

@ -1,13 +0,0 @@
import request from "./request";
const HomeApi = {
getLatestProjects(num) {
return request({
url: '/home/projects/latest',
method: 'get',
params: {num: num}
})
}
}
export default HomeApi

View File

@ -1,33 +0,0 @@
import request from "./request";
import qs from 'qs'
const MessageApi = {
getUserMessages(query) {
return request({
url: `/message`,
method: 'get',
params: query
})
},
readMessage(m) {
return request({
url: `/message/${m.id}/read`,
method: 'post',
data: qs.stringify(m)
})
},
readAllMessage() {
return request({
url: `/message/read-all`,
method: 'post',
})
},
deleteMessage(m) {
return request({
url: `/message/${m.id}/delete`,
method: 'post',
})
}
}
export default MessageApi

View File

@ -1,109 +0,0 @@
import request from './request'
import qs from 'qs'
const ProjectApi = {
getProjectDetail(id) {
return request({
url:'/project/' + id,
method: 'get'
})
},
createProject(data) {
return request({
url:'/project',
method: 'post',
data: qs.stringify(data)
})
},
updateProject(data, id) {
return request({
url:'/project/' + id,
method: 'post',
data: qs.stringify(data)
})
},
publishProject(pid) {
return request({
url: `/project/${pid}/publish`,
method: 'post',
})
},
closeProject(pid) {
return request({
url: `/project/${pid}/close`,
method: 'post',
})
},
deleteProject(pid) {
return request({
url: `/project/${pid}/delete`,
method: 'post',
})
},
getSectionFiles(id) {
return request({
url:'/project/chapter/section/files/' + id,
method: 'get',
})
},
createSectionFile(f) {
return request({
url:'/project/chapter/section/file',
method: 'post',
data: qs.stringify(f)
})
},
getProjectStudents(pid) {
return request({
url: `/project/${pid}/students`,
method: 'get',
})
},
removeStudent(pid, sid) {
return request({
url: `/project/${pid}/remove/${sid}`,
method: 'post'
})
},
updateWeight(pid, data) {
return request({
url: `/project/${pid}/weight`,
method: 'post',
data: qs.stringify(data)
})
},
addFavourite(pid) {
return request({
url: `/project/${pid}/favourite/add`,
method: 'post',
})
},
removeFavourite(pid) {
return request({
url: `/project/${pid}/favourite/remove`,
method: 'post',
})
},
getSubjectsAndSkills(pid) {
return request({
url: `/project/${pid}/subjects-skills`,
method: 'get'
})
},
viewProject(pid) {
return request({
url: `/project/${pid}/view`,
method: 'post'
})
},
cloneProject(pid) {
return request({
url: `/project/${pid}/clone`,
method: 'post'
})
}
}
export default ProjectApi

View File

@ -1,13 +0,0 @@
import request from './request'
const ProjectListApi = {
getUserProjectList(mode, q) {
return request({
url: '/project-list/' + mode,
params: q,
method: 'get'
})
},
}
export default ProjectListApi

View File

@ -1,35 +0,0 @@
import request from "./request";
import qs from 'qs'
const ResourceApi = {
getResource(pid, id) {
return request({
url: `project/${pid}/resource/${id}`,
method: 'get',
})
},
createResource(pid, q) {
return request({
url: `/project/${pid}/resource`,
method: 'post',
data: qs.stringify(q)
})
},
updateResource(pid, q) {
return request({
url: `/project/${pid}/resource/${q.id}`,
method: 'post',
data: qs.stringify(q)
})
},
updateResourceContent(pid, id, content) {
return request({
url: `/project/${pid}/resource/${id}/content`,
method: 'post',
data: qs.stringify({content: content})
})
},
}
export default ResourceApi

View File

@ -1,84 +0,0 @@
import request from "./request";
import qs from "qs";
const SectionApi = {
getChapterSections(item) {
return request({
url: `/project/${item.projectId}/chapter/${item.id}/sections`,
method: 'get',
})
},
createChapterSection(pid, section) {
return request({
url: `/project/${pid}/chapter/${section.chapterId}/section`,
method: 'post',
data: qs.stringify(section)
})
},
updateChapterSection(pid, section) {
return request({
url: `/project/${pid}/chapter/${section.chapterId}/section/${section.id}`,
method: 'post',
data: qs.stringify(section)
})
},
updateSectionsMinute(pid, sections) {
return request({
url: `/project/${pid}/sections-minute`,
method: 'post',
data: qs.stringify(sections)
})
},
deleteChapterSection(pid, s) {
return request({
url: `/project/${pid}/chapter/${s.chapterId}/section/${s.id}/delete`,
method: 'post',
data: qs.stringify(s)
})
},
exchangeChapterSection(chapter, id1, id2) {
return request({
url: `/project/${chapter.projectId}/chapter/${chapter.id}/sections/exchange`,
method: 'post',
data: qs.stringify({
sectionId1: id1,
sectionId2: id2
})
})
},
getSectionDetail(sid, pid) {
return request({
url: `/project/${pid}/section/${sid}`,
method: 'get',
})
},
getSectionFiles(sid, pid) {
return request({
url: `/project/${pid}/section/${sid}/files`,
method: 'get',
})
},
uploadSectionFile(sid, pid, data) {
return request({
url: `/project/${pid}/section/${sid}/file`,
method: 'post',
data: qs.stringify(data)
})
},
updateSectionFile(sid, pid, f) {
return request({
url: `/project/${pid}/section/${sid}/file/${f.id}/update`,
method: 'post',
data: qs.stringify(f)
})
},
deleteSectionFile(sid, pid, fid) {
return request({
url: `/project/${pid}/section/${sid}/file/${fid}/delete`,
method: 'post'
})
}
}
export default SectionApi

View File

@ -1,49 +0,0 @@
import request from './request'
import qs from 'qs'
const StudentApi = {
learnProject(pid) {
return request({
url: '/student/learn/' + pid,
method: 'post',
})
},
exitProject(pid) {
return request({
url: '/student/exit/' + pid,
method: 'post',
})
},
FinishedProject(sid, pid) {
return request({
url: '/student/finished',
method: 'post',
data: qs.stringify({
studentId: sid,
projectId: pid,
learning: false
})
})
},
getLearnSection(pid, sid) {
return request({
url: `/student/project/${pid}/section/${sid}`,
method: 'get'
})
},
updateLearnSection(pid, sid, data) {
return request({
url: `/student/project/${pid}/section/${sid}`,
method: 'post',
data: qs.stringify(data)
})
},
getLastLearnSection(pid) {
return request({
url: `/student/last-learn/project/${pid}`,
method: 'get'
})
}
}
export default StudentApi

View File

@ -1,47 +0,0 @@
import request from "./request";
import qs from "qs";
const SubmitApi = {
createSubmit(pid, tid, data) {
return request({
url: `/project/${pid}/task/${tid}/submit`,
method: 'post',
data: qs.stringify(data)
})
},
updateSubmit(pid, tid, sid, data) {
return request({
url: `/project/${pid}/task/${tid}/submit/${sid}`,
method: 'post',
data: qs.stringify(data)
})
},
getSubmitFiles(pid, tid, sid) {
return request({
url: `/project/${pid}/task/${tid}/submit/${sid}/files`,
method: 'get',
})
},
uploadSubmitFile(pid, tid, sid, data) {
return request({
url: `/project/${pid}/task/${tid}/submit/${sid}/file`,
method: 'post',
data: qs.stringify(data)
})
},
updateSubmitFile(pid, tid, sid, file) {
return request({
url: `/project/${pid}/task/${tid}/submit/${sid}/file/${file.id}/update`,
method: 'post',
data: qs.stringify(file)
})
},
deleteSubmitFile(pid, tid, sid, fid) {
return request({
url: `/project/${pid}/task/${tid}/submit/${sid}/file/${fid}/delete`,
method: 'post'
})
}
}
export default SubmitApi

View File

@ -1,43 +0,0 @@
import request from "./request";
import qs from 'qs'
const SurveyApi = {
getSurveyDetailByTaskId(pid, tid) {
return request({
url: `/project/${pid}/task/${tid}/survey`,
method: 'get'
})
},
createQuestion(pid, tid, q) {
return request({
url: `/project/${pid}/task/${tid}/survey/${q.surveyId}/question`,
method: 'post',
data: qs.stringify(q)
})
},
updateQuestion(pid, tid, q) {
return request({
url: `/project/${pid}/task/${tid}/survey/${q.surveyId}/question/${q.id}`,
method: 'post',
data: qs.stringify(q)
})
},
deleteQuestion(pid, tid, sid, qid) {
return request({
url: `/project/${pid}/task/${tid}/survey/${sid}/question/${qid}/delete`,
method: 'post',
})
},
exchangeQuestion(pid, tid, suid, id1, id2) {
return request({
url: `/project/${pid}/task/${tid}/survey/${suid}/questions/exchange`,
method: 'post',
data: qs.stringify({
questionId1: id1,
questionId2: id2
})
})
}
}
export default SurveyApi

View File

@ -1,58 +0,0 @@
import request from "./request";
import qs from 'qs'
const TaskApi = {
getSectionTasks(sid, pid) {
return request({
url: `/project/${pid}/section/${sid}/tasks`,
method: 'get',
})
},
getProjectTasks(pid) {
return request({
url: `/project/${pid}/tasks`,
method: 'get',
})
},
getProjectTasksDetail(pid, sid) {
return request({
url: `/project/${pid}/tasks-detail`,
method: 'get',
params: {
studentId: sid
}
})
},
createTask(pid, q) {
return request({
url: `/project/${pid}/task`,
method: 'post',
data: qs.stringify(q)
})
},
updateTask(pid, q) {
return request({
url: `/project/${pid}/task/${q.id}`,
method: 'post',
data: qs.stringify(q)
})
},
deleteTask(pid, id) {
return request({
url: `/project/${pid}/task/${id}/delete`,
method: 'post'
})
},
exchangeTask(pid, id1, id2) {
return request({
url: `/project/${pid}/tasks/exchange`,
method: 'post',
data: qs.stringify({
taskId1: id1,
taskId2: id2
})
})
}
}
export default TaskApi

View File

@ -1,34 +0,0 @@
import axios from 'axios'
import {message} from 'antd'
function getServerUrl() {
const hostname = window.location.hostname
if (hostname === 'localhost') {
return `http://${hostname}:5000/api`
}
return '/api'
}
const request = axios.create({
baseURL: getServerUrl(),
timeout: 10000,
withCredentials: true
})
request.interceptors.response.use(res=>{
if (res.data.code === 401) {
message.error(res.data.msg)
setTimeout(()=>{
window.location.href = '/'
}, 1000)
} else if (res.data.code === 403) {
message.error(res.data.msg)
setTimeout(()=>{
window.location.href = '/'
}, 1000)
} else {
return res
}
})
export default request

View File

@ -1,13 +0,0 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View File

@ -1,17 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,196 +0,0 @@
import React from 'react';
import BannerAnim from 'rc-banner-anim';
import {Image} from 'antd';
import TweenOne, {TweenOneGroup} from 'rc-tween-one';
import 'rc-banner-anim/assets/index.css';
import './carousel-pbl.less';
const {Element, Arrow, Thumb} = BannerAnim;
const BgElement = Element.BgElement;
class CarouselPBL extends React.Component {
constructor(props) {
super(props);
this.imgArray = [
{
img: 'https://cdn.open-ct.com/task-resources//carousel-top-1.png',
title: '',
text: '',
},
{
img: 'https://cdn.open-ct.com/task-resources//carousel-top-2.png',
title: '',
text: '',
},
{
img: 'https://cdn.open-ct.com/task-resources//carousel-top-3.png',
title: '',
text: '',
},
];
this.state = {
intShow: 0,
prevEnter: false,
nextEnter: false,
thumbEnter: false,
};
[
'onChange',
'prevEnter',
'prevLeave',
'nextEnter',
'nextLeave',
'onMouseEnter',
'onMouseLeave',
].forEach((method) => this[method] = this[method].bind(this));
}
onChange(type, int) {
if (type === 'before') {
this.setState({
intShow: int,
});
}
}
getNextPrevNumber() {
let nextInt = this.state.intShow + 1;
let prevInt = this.state.intShow - 1;
if (nextInt >= this.imgArray.length) {
nextInt = 0;
}
if (prevInt < 0) {
prevInt = this.imgArray.length - 1;
}
return [prevInt, nextInt];
}
prevEnter() {
this.setState({
prevEnter: true,
});
}
prevLeave() {
this.setState({
prevEnter: false,
});
}
nextEnter() {
this.setState({
nextEnter: true,
});
}
nextLeave() {
this.setState({
nextEnter: false,
});
}
onMouseEnter() {
this.setState({
thumbEnter: true,
});
}
onMouseLeave() {
this.setState({
thumbEnter: false,
});
}
render() {
const intArray = this.getNextPrevNumber();
const thumbChildren = this.imgArray.map((item, i) =>
(
<span key={i.toString()}>
<Image src={item.img}/>
</span>
));
return (
<BannerAnim
onChange={this.onChange}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
prefixCls="custom-arrow-thumb"
autoPlay
>
{this.imgArray.map((item, index) => (
<Element key={index.toString()} prefixCls="banner-user-elem">
<BgElement
key="bg"
className="bg"
style={{
backgroundImage: `url(${item.img})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
/>
<TweenOne className="banner-user-title" animation={{y: 30, opacity: 0, type: 'from'}}>
<div style={{fontSize: '100px'}}>{item.title}</div>
</TweenOne>
<TweenOne className="banner-user-text" animation={{y: 30, opacity: 0, type: 'from', delay: 100}}>
<div style={{fontSize: '30px'}}>{item.text}</div>
</TweenOne>
</Element>
))}
<Arrow
arrowType="prev"
key="prev"
prefixCls="user-arrow"
component={TweenOne}
onMouseEnter={this.prevEnter}
onMouseLeave={this.prevLeave}
animation={{left: this.state.prevEnter ? 0 : -120}}
>
<div className="arrow"/>
<TweenOneGroup
enter={{opacity: 0, type: 'from'}}
leave={{opacity: 0}}
appear={false}
className="img-wrapper"
component="ul"
>
<li style={{backgroundImage: `url(${this.imgArray[intArray[0]].img})`}} key={intArray[0]}/>
</TweenOneGroup>
</Arrow>
<Arrow
arrowType="next"
key="next"
prefixCls="user-arrow"
component={TweenOne}
onMouseEnter={this.nextEnter}
onMouseLeave={this.nextLeave}
animation={{right: this.state.nextEnter ? 0 : -120}}
>
<div className="arrow"/>
<TweenOneGroup
enter={{opacity: 0, type: 'from'}}
leave={{opacity: 0}}
appear={false}
className="img-wrapper"
component="ul"
>
<li style={{backgroundImage: `url(${this.imgArray[intArray[1]].img})`}} key={intArray[1]}/>
</TweenOneGroup>
</Arrow>
<Thumb
prefixCls="user-thumb"
key="thumb"
component={TweenOne}
animation={{bottom: this.state.thumbEnter ? 0 : -70}}
>
{thumbChildren}
</Thumb>
</BannerAnim>
);
}
}
export default CarouselPBL;

View File

@ -1,114 +0,0 @@
import React, {useEffect, useState} from "react";
import {Card, Col, Divider, Image, Row, Empty} from "antd";
import {Link} from "react-router-dom";
import {EyeOutlined, TeamOutlined} from "@ant-design/icons";
import HomeApi from "../../../api/HomeApi";
import util from "../../component/Util";
const topColResponsiveProps = {
xs: 12,
sm: 12,
md: 8,
lg: 8,
xl: 6,
};
function LatestProject(obj) {
const [projects, setProjects] = useState([])
useEffect(() => {
getLatestProject()
}, [])
const getLatestProject = () => {
HomeApi.getLatestProjects(4)
.then(res => {
if (res.data.code === 200) {
if (res.data.projects !== null) {
setProjects(res.data.projects)
}
}
})
.catch(e => {
console.log(e)
})
}
return (
<div style={{maxWidth: '1200px', margin: 'auto'}}>
<Row gutter={[20, 20]}>
{
projects.map((item, index) => (
<Col key={index.toString()} {...topColResponsiveProps}>
<Link to={`/home/project/${item.id}/info`}>
<Card
hoverable
bordered={false}
style={{
borderRadius: '10px',
}}
cover={
<Image
src={item.image}
preview={false}
style={{
borderTopLeftRadius: '10px',
borderTopRightRadius: '10px',
}}
fallback={"https://cdn.open-ct.com/task-resources//openpbl-empty-project.png"}
/>
}
>
<Card.Meta
title={
item.projectTitle === '' ? '无':item.projectTitle
}
description={
<div>
{item.subjects === '' ? '无' : item.subjects}
</div>
}
/>
<span
style={{
color: 'gray',
fontSize: 'small',
}}
>
<EyeOutlined/>&nbsp;
{item.readNum}
</span>
<Divider type="vertical"/>
<span
style={{
color: 'gray',
fontSize: 'small',
}}
>
<TeamOutlined/>&nbsp;
{item.joinNum}
</span>
<span
style={{
color: 'gray',
fontSize: 'small',
float: 'right',
}}
>
{util.FilterMoment(item.createAt)}
</span>
</Card>
</Link>
</Col>
))
}
</Row>
{projects.length === 0 ?
<Empty /> : null
}
</div>
)
}
export default LatestProject

View File

@ -1,143 +0,0 @@
.custom-arrow-thumb {
height: 450px;
}
.custom-arrow-thumb .user-arrow {
top: 50%;
margin-top: -40px;
}
.custom-arrow-thumb .user-arrow .img-wrapper {
width: 120px;
height: 80px;
float: left;
position: relative;
}
.custom-arrow-thumb .user-arrow .img-wrapper li {
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
position: absolute;
}
.custom-arrow-thumb .user-arrow .arrow {
width: 20px;
height: 80px;
background: rgba(0, 0, 0, 0.3);
position: relative;
}
.custom-arrow-thumb .user-arrow .arrow:before,
.custom-arrow-thumb .user-arrow .arrow:after {
width: 2px;
height: 15px;
background: #fff;
display: block;
content: ' ';
position: absolute;
}
.custom-arrow-thumb .user-arrow.next {
right: -120px;
}
.custom-arrow-thumb .user-arrow.next .arrow {
float: left;
}
.custom-arrow-thumb .user-arrow.next .arrow:before {
-webkit-transform: rotate(-40deg);
transform: rotate(-40deg);
top: 28px;
left: 10px;
}
.custom-arrow-thumb .user-arrow.next .arrow:after {
-webkit-transform: rotate(40deg);
transform: rotate(40deg);
bottom: 27px;
left: 10px;
}
.custom-arrow-thumb .user-arrow.prev {
left: -120px;
}
.custom-arrow-thumb .user-arrow.prev .arrow {
float: right;
}
.custom-arrow-thumb .user-arrow.prev .arrow:before {
-webkit-transform: rotate(40deg);
transform: rotate(40deg);
top: 28px;
left: 8px;
}
.custom-arrow-thumb .user-arrow.prev .arrow:after {
-webkit-transform: rotate(-40deg);
transform: rotate(-40deg);
bottom: 27px;
left: 8px;
}
.custom-arrow-thumb .user-thumb {
overflow: hidden;
background: rgba(255, 255, 255, 0.15);
height: 40px;
}
.custom-arrow-thumb .user-thumb > span {
width: 50px;
height: 30px;
margin: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-webkit-transition: background .3s;
transition: background .3s;
background: transparent;
}
.custom-arrow-thumb .user-thumb > span.active {
background: rgba(255, 255, 255, 0.45);
}
.custom-arrow-thumb .user-thumb > span i {
display: block;
width: 46px;
height: 26px;
margin: 2px;
background-size: cover;
background-position: center;
}
.banner-user {
height: 220px;
}
.banner-user-elem {
text-align: center;
color: #fff;
position: relative;
overflow: hidden;
}
.banner-user-elem .banner-user-title {
font-size: 32px;
top: 30%;
}
.banner-user-elem .banner-user-text {
top: 40%;
}
.banner-anim-elem .bg {
max-width: 1200px;
margin: auto;
width: 100%;
height: 100%;
top: 0;
left: 0;
overflow: hidden;
}

View File

@ -1,28 +0,0 @@
import React from "react";
import CarouselPBL from "./component/CarouselPBL";
import DocumentTitle from 'react-document-title'
import LatestProject from "./component/LatestProject";
import {Divider} from "antd";
class Home extends React.PureComponent {
render() {
return (
<DocumentTitle title="Home">
<div
style={{
margin: 'auto',
padding: '20px',
}}
>
<CarouselPBL/><br/>
<Divider orientation="center">最近的项目</Divider>
<div>
<LatestProject />
</div>
</div>
</DocumentTitle>
);
}
}
export default Home

View File

@ -1,12 +0,0 @@
import React from "react";
import MessageList from "../component/MessageList";
function AllMessage() {
return (
<div>
<MessageList readType="all"/>
</div>
)
}
export default AllMessage

View File

@ -1,11 +0,0 @@
import React from "react";
import MessageList from "../component/MessageList";
function ReadMessage() {
return (
<div>
<MessageList readType="read"/>
</div>
)
}
export default ReadMessage

View File

@ -1,12 +0,0 @@
import React from "react";
import MessageList from "../component/MessageList";
function UnreadMessage() {
return (
<div>
<MessageList readType="unread"/>
</div>
)
}
export default UnreadMessage

Some files were not shown because too many files have changed in this diff Show More