add some components 2 #4

Open
binary wants to merge 1 commits from binary/OpenPBL:pr3 into master
174 changed files with 3262 additions and 27589 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

31
web/.gitignore vendored
View File

@ -1,31 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
.vscode
### Config file
.env.development
.env.production

View File

@ -1,70 +0,0 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `yarn 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`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
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`
**Note: this is a one-way operation. Once you `eject`, you cant 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.
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.
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.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
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
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 +0,0 @@
const CracoLessPlugin = require('craco-less');
const path = require("path");
const resolve = dir => path.resolve(__dirname, dir);
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
javascriptEnabled: true,
},
},
},
},
],
babel: {
plugins: [
['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
['@babel/plugin-proposal-decorators', { legacy: true }]
]
},
webpack: {
alias: {
'@': resolve("src"),
}
}
};

View File

@ -1,68 +0,0 @@
{
"name": "web",
"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"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"rc-animate": "^3.1.1"
}
}

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="https://cdn.open-ct.com/static/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="https://cdn.open-ct.com/static/favicon.ico" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
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>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

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

@ -0,0 +1,168 @@
// 封装的材料仓库组件
import React, {Component} from "react";
import {Empty, Input, Pagination, Upload, message} from "antd";
import ModulaCard from "./ModulaCard";
import UpLoadModal from "./UpLoadModal";
import {FileExcelFilled, FileMarkdownFilled, FilePptFilled, FileTextFilled, FileZipFilled, PlusOutlined} from "@ant-design/icons";
import "./MaterialWarehouse.less";
const {Search} = Input;
export default class inedx extends Component {
state = {
fileType: [<FileTextFilled key={1} />, <FileExcelFilled key={2} />, <FileZipFilled key={3} />, <FileMarkdownFilled key={4} />, <FilePptFilled key={5} />],
fileList: [],
upLoadVisible: false,
getFileLoading: false,
}
downLoadFile = (file_id) => {
message.info(`开始下载文件:${file_id}`);
// request({
// url:baseURL+`/review/file/${file_id}`,
// // url:`http://49.232.73.36:8081/review/file/${file_id}`,
// method: "GET",
// responseType:"blob"
// }).then(res => {
// console.log(res);
// const filename = res.headers["content-disposition"];
// const blob = new Blob([res.data]);
// var downloadElement = document.createElement("a");
// var href = window.URL.createObjectURL(blob);
// downloadElement.href = href;
// downloadElement.download = decodeURIComponent(filename.split("filename*=")[1].replace("utf-8''", ""));
// document.body.appendChild(downloadElement);
// downloadElement.click();
// document.body.removeChild(downloadElement);
// window.URL.revokeObjectURL(href);
// message.success("文件下载成功!");
// }).catch(err => {
// message.error("文件下载失败!");
// });
message.success("文件下载成功");
}
componentDidMount() {
this.getFileList();
}
getFileList = () => {
this.setState({
getFileLoading: true,
});
// request({
// url:baseURL+`/review/proj/detailed/${this.props.projectId}`,
// // url:`http://49.232.73.36:8081/review/proj/detailed/${this.props.projectId}`,
// method:"GET"
// }).then(res => {
// request({
// url:baseURL+"/review/query/file",
// // url:"http://49.232.73.36:8081/review/query/file",
// method:"POST",
// data:{
// id_list:res.data.materials.files
// }
// }).then(res => {
// this.setState({
// fileList:Object.values(res.data),
// getFileLoading:false
// });
// }).catch(err => {
this.setState({
getFileLoading: false,
});
// });
// }).catch(err => {
// this.setState({
// getFileLoading:false
// });
// });
}
fileViewLoader = () => {
if(this.props.role === "2" && this.state.fileList.length === 0) {
return (
<div className="empty-state-box">
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>
);
}else if((this.props.role === "2" && this.state.fileList.length !== 0) || this.props.role === "3" || this.props.role === "4") {
return this.state.fileList.map(item => (
<div className="file-item" key={item.Id} onClick={this.downLoadFile.bind(this, item.uuid)}>
<div className="icon">
<FileTextFilled key={item.Id} />
</div>
<div className="name">
<span>{item.name}</span>
</div>
</div>
));
}
return (
<></>
);
}
render() {
return (
<ModulaCard title="材料仓库" right={<Search placeholder="input search text" size="small" style={{width: 200}} />}>
<div className="material-warehouse-box" data-component="material-warehouse-box">
<div className="container">
{
this.props.role === "3" || (this.props.role === "4" && this.props.stepName !== "测试框架与论证报告") ? (
<div className="upload-download-box" onClick={() => {
this.setState({
upLoadVisible: true,
});
}}>
<Upload
name="avatar"
listType="picture-card"
showUploadList={false}
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
openFileDialogOnClick={false}
>
<div className="file-load-btn" onClick={() => {
this.setState({
upLoadVisible: true,
});
}}>
<PlusOutlined />
<div style={{marginTop: 8, width: "100%"}}>上传</div>
</div>
</Upload>
</div>
) : (
<></>
)
}
{this.fileViewLoader()}
<UpLoadModal
show={this.state.upLoadVisible}
projectId={this.props.projectId}
stepId = {this.props.stepId}
onClose={() => {
this.setState({
upLoadVisible: false,
});
}}
onUpdate = {() => {
this.getFileList();
}}
></UpLoadModal>
</div>
<div className="footer">
<Pagination
total={85}
showTotal={total => `Total ${total} items`}
defaultPageSize={20}
defaultCurrent={1}
size="small"
/>
</div>
</div>
</ModulaCard>
);
}
}

View File

@ -0,0 +1,78 @@
[data-component=material-warehouse-box]{
width: 100%;
height: calc(100% - .38rem);
box-sizing: border-box;
padding:0rem .21rem 0rem .23rem;
> .container{
width: 100%;
height: calc(100% - .4rem);
.empty-state-box{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
> .ant-empty{
margin: 0;
}
}
.file-item{
width: 1rem;
height: 1rem;
background-color: #F3F3F3;
float: left;
margin-right: .1rem;
display: flex;
align-content: center;
justify-content: center;
flex-wrap: wrap;
cursor: pointer;
> .icon{
width: 100%;
height: .5rem;
display: flex;
align-items: center;
justify-content: center;
font-size: .32rem;
}
> .name{
text-align: center;
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
box-sizing: border-box;
padding: 0px .08rem;
> span{
font-size: .08rem;
}
}
}
> .upload-download-box{
float: left;
margin-right: .1rem;
.file-load-btn{
width: 100%;
height: 100%;
display: flex;
align-content: center;
justify-content: center;
flex-wrap: wrap;
}
> .ant-upload-picture-card-wrapper{
width: 1rem;
height: 1rem;
> .ant-upload{
width: 100%;
height: 100%;
margin: 0;
}
}
}
}
> .footer{
display: flex;
align-items: flex-end;
width: 100%;
height: .4rem;
}
}

View File

@ -0,0 +1,153 @@
import React, {Component} from "react";
import {Modal, Space, Spin, Table} from "antd";
import {FileTextTwoTone} from "@ant-design/icons";
import "./ModifyRecordModal.less";
export default class index extends Component {
state = {
recordList: [{
key: "1",
date: "2021-08-11",
result: 0,
reviewMaterials: "待评审材料1",
feedback: "反馈意见",
}, {
key: "2",
date: "2021-08-11",
result: 1,
reviewMaterials: "待评审材料1",
feedback: "反馈意见",
}, {
key: "3",
date: "2021-08-11",
result: 2,
reviewMaterials: "待评审材料1",
feedback: "反馈意见",
}, {
key: "4",
date: "2021-08-11",
result: 3,
reviewMaterials: "待评审材料1",
feedback: "",
}],
submitInfo: {},
loadingState: false,
}
getRecordList() {
// this.setState({
// loadingState:true
// });
// request({
// url:baseURL+`/review/proj/submit/${this.props.submitId}`,
// method:"GET"
// }).then(res => {
// this.setState({
// submitInfo:res.data,
// loadingState:false
// });
// }).catch(err => {
// this.setState({
// loadingState:false
// });
// message.error("加载错误");
// this.props.onComplete();
// });
}
recordListColums = [{
title: "ID",
dataIndex: "uuid",
align: "center",
key: "id",
}, {
title: "评论",
dataIndex: "comment",
align: "center",
key: "comment",
}, {
title: "评审材料",
key: "review-materials",
align: "center",
width: 220,
render: (text, record) => (
<Space size="middle">
<span style={{cursor: "pointer"}} onClick={this.downLoadFile.bind(this, record.uuid)}>点击下载</span><FileTextTwoTone />
</Space>
),
}, {
title: "版本",
dataIndex: "version",
align: "center",
key: "version",
}]
downLoadFile(file_id) {
// message.info(`开始下载文件:${file_id}`);
// request({
// url:baseURL+`/review/file/${file_id}`,
// // url:`http://49.232.73.36:8081/review/file/${file_id}`,
// method: "GET",
// responseType:"blob"
// }).then(res => {
// console.log(res);
// const filename = res.headers["content-disposition"];
// const blob = new Blob([res.data]);
// var downloadElement = document.createElement("a");
// var href = window.URL.createObjectURL(blob);
// downloadElement.href = href;
// downloadElement.download = decodeURIComponent(filename.split("filename*=")[1].replace("utf-8''", ""));
// document.body.appendChild(downloadElement);
// downloadElement.click();
// document.body.removeChild(downloadElement);
// window.URL.revokeObjectURL(href);
// message.success("文件下载成功!");
// }).catch(err => {
// message.error("文件下载失败!");
// });
}
render() {
return (
<Modal title="修改记录"
width="9.51rem"
visible={this.props.show}
cancelText="关闭"
okText="确认"
confirmLoading={this.state.loadingState}
closable={!this.state.loadingState}
maskClosable={!this.state.loadingState}
keyboard={!this.state.loadingState}
onOk={() => {
this.props.onComplete();
}}
onCancel={() => {
this.props.onCancel();
}}
>
{
this.state.loadingState ? (
<Spin spinning={this.state.loadingState} tip="加载中"></Spin>
) : (
<div className="modify-record-box" data-component="modify-record-box">
<div className="basic">
<div className="id">
材料编号:{this.state.submitInfo.uuid}
</div>
<div className="date">
截止日期:未知
</div>
</div>
<Table
dataSource={this.state.submitInfo.contents || []}
columns={this.recordListColums} size="small"
pagination={false}
/>
</div>
)
}
</Modal>
);
}
}

View File

@ -0,0 +1,31 @@
[data-component=modify-record-box]{
width: 100%;
> .basic{
width: 100%;
height: 1.49rem;
box-sizing: border-box;
padding: .16rem .16rem 0px .16rem;
border: 1px solid #F0F0F0;
border-radius: .02rem;
margin-bottom: .32rem;
> .id{
font-size: .16rem;
line-height: .24rem;
font-weight: 400;
color: #000000;
height: .24rem;
}
> .date{
height: .22rem;
line-height: .22rem;
font-size: .14rem;
color: rgba(0, 0, 0, 0.45);
}
}
.ant-table-cell{
font-size: .14rem;
}
.ant-table-thead,.ant-table-row{
height: .56rem;
}
}

19
web/src/ModulaCard.js Normal file
View File

@ -0,0 +1,19 @@
import React, {Component} from "react";
import "./ModulaCard.less";
export default class index extends Component {
render() {
return (
<div className="modula-card-box" data-component="modula-card-box">
<div className="title">
<div className="icon"></div>
<span>{this.props.title}</span>
<div className="right">
{this.props.right}
</div>
</div>
{this.props.children}
</div>
);
}
}

35
web/src/ModulaCard.less Normal file
View File

@ -0,0 +1,35 @@
[data-component=modula-card-box]{
width: 100%;
height: 100%;
background-color: #fff;
box-sizing: border-box;
padding: .16rem 0rem ;
> .title{
width: 100%;
height: .22rem;
box-sizing: border-box;
padding: 0px .26rem;
display: flex;
align-items: center;
margin-bottom: .16rem;
position: relative;
> .icon{
display: block;
width: .06rem;
height: .18rem;
background-color: #1890FF;
margin-right: .16rem;
}
> span{
font-size: .16rem;
font-weight: 400;
line-height: .22rem;
}
> .right{
position: absolute;
height: 100%;
right: .14rem;
top: 0;
}
}
}

324
web/src/PendingTaskPage.js Normal file
View File

@ -0,0 +1,324 @@
import React, {Component} from "react";
import {Button, Dropdown, Form, Input, Layout, Menu, Modal, Pagination, Space, Spin, Table, Tag, message} from "antd";
import {DownOutlined, PlusCircleOutlined} from "@ant-design/icons";
import * as ProjectBackend from "./backend/ProjectBackend";
import ChangeTags from "./ChangeTags";
import "./PendingTaskPage.less";
const {Header, Footer, Content} = Layout;
const {Search, TextArea} = Input;
export default class PeddingTasks extends Component {
constructor(props) {
super(props);
this.state = {
classes: props,
data: [],
tableHeight: 0,
loadingState: false,
isCreateProjectVisible: false,
createLoading: false,
form: {
current: 1,
pageSize: 10,
pageSizeOptions: [5, 10, 15, 20],
showSizeChanger: true,
total: 50,
},
createForm: {
name: "",
grade_range: [],
subjects: [],
description: "",
requirement: "",
summary: "",
target: "",
},
};
}
createFormRef = React.createRef()
columns = [
{
title: "项目名称",
key: "name",
align: "center",
width: 210,
render: (text, record) => (
// <Space size="middle">
// <Button type="link" onClick={this.seekProjectManagement.bind(this,record)}>{
// record.basic_info.name
// }</Button>
// </Space>
<span key={1}>{record.basic_info.name}</span>
),
},
{
title: "学科",
key: "subject",
dataIndex: "subject",
align: "center",
width: 210,
render: (text, record) => (
<>
{
record.basic_info.subjects.map((item, index) => (
<Tag key={index} color="green">
{
item
}
</Tag>
))
}
</>
),
},
{
title: "学段",
key: "period",
align: "center",
render: (text, record) => (
<>
{
record.basic_info.grade_range.map((item, index) => (
<Tag key={index} color="green">
{
item
}
</Tag>
))
}
</>
),
},
{
title: "试卷",
key: "paper",
align: "center",
width: 142,
render: record => (
<span>0</span>
),
},
{
title: "试题",
key: "questions",
align: "center",
width: 121,
render: record => (
<span>0</span>
),
},
{
title: "创建时间",
dataIndex: "created_time",
key: "create-time",
align: "center",
width: 342,
render: (text, record) => (
<span>{this.dateFilter(record.created_time)}</span>
),
},
{
title: "操作",
key: "title",
align: "center",
render: (text, record) => (
<Space size="middle">
<Button type="link" onClick={this.seekProjectManagement.bind(this, record)}>访问项目</Button>
<Button type="link" danger>删除</Button>
</Space>
),
},
]
pendingTaskMenu = () => {
return (
<Menu>
<Menu.Item key="1">任务1</Menu.Item>
<Menu.Item key="2">任务2</Menu.Item>
<Menu.Item disabled key="3">任务3</Menu.Item>
<Menu.Item key="4">任务4</Menu.Item>
</Menu>
);
}
componentDidMount = () => {
this.getProjectList(this.state.classes.account);
}
seekProjectManagement = (state) => {
let project_id = state.project_id.split("/").join("_");
this.props.history.push(`/project-management/${project_id}/${state.role}`);
}
dateFilter(time) {
let date = new Date(time);
return `${date.getFullYear()}-${date.getMonth().toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
}
getProjectList = (account) => {
ProjectBackend.GetUserAssignments(account.id).then(res => {
let id_list = res.data.map(item => item.project_id);
let role_lits = res.data.map(item => item.role);
let project_id_list = res.data.map(item => item.project_id);
ProjectBackend.GetProjectList(id_list).then(res => {
let data = Object.values(res.data);
data = data.map((item, index) => {
item.role = role_lits[index];
item.project_id = project_id_list[index];
return item;
});
this.setState({
data,
loadingState: false,
});
}).catch(err => {
message.error(err || "请求错误!");
}).catch(err => {
message.error(err || "请求错误!");
});
});
}
render() {
return (
<Layout className="pending-tasks-page" data-component="pending-tasks-page">
<Header>
<span className="title">项目列表/待处理任务</span>
<div className="right-box">
<Search placeholder="input search text" style={{width: "2.64rem", height: ".32rem"}} />
<Dropdown overlay={this.pendingTaskMenu()}>
<span>待处理任务<DownOutlined /></span>
</Dropdown>
<Button type="primary" icon={<PlusCircleOutlined />} onClick={() => {
this.setState({
isCreateProjectVisible: true,
});
}}>添加项目</Button>
</div>
</Header>
<Content>
<Table
loading={this.state.loadingState}
columns={this.columns}
dataSource={this.state.data}
rowSelection={{}}
size="small"
rowKey={record => record.num}
pagination={false}
scroll={{y: "calc(100vh - 2.2rem)"}}
/>
</Content>
<Footer>
<Pagination
size="small"
total={85}
showSizeChanger
showQuickJumper
/>
<Modal
title="创建项目"
visible={this.state.isCreateProjectVisible}
cancelText="取消创建"
okText="创建项目"
closable={!this.state.createLoading}
confirmLoading={this.state.createLoading}
maskClosable={!this.state.createLoading}
keyboard={!this.state.createLoading}
onOk={() => {
const form = this.createFormRef.current;
form.validateFields().then(data => {
this.setState({
createLoading: true,
});
ProjectBackend.CreatTemplateProject(data).then(res => {
if (res.status == "ok") {
message.success("项目创建成功!");
this.createFormRef.current.resetFields();
this.getProjectList(this.state.classes.account);
} else {
message.error("项目创建失败!");
}
this.setState({
createLoading: false,
isCreateProjectVisible: false,
});
}).catch(err => {
console.log("err:" + err);
this.setState({
createLoading: false,
});
message.error(err.message || "未知错误");
});
}).catch(err => {
message.warning("请按要求填写表单项!");
});
}}
onCancel={() => {
if (this.state.createLoading) {
message.error("项目创建中,不可阻断!");
} else {
this.createFormRef.current.resetFields();
this.setState({
isCreateProjectVisible: false,
});
}
}}
>
<Spin spinning={this.state.createLoading} tip="项目创建中,请等待!">
<Form labelCol={{span: 4}} wrapperCol={{span: 20}} ref={this.createFormRef} name="createForm" initialValues={this.state.createForm}>
<Form.Item name="name" label="项目名称" rules={[{required: true, message: "项目名称不能为空!"}]}>
<Input placeholder="请输入项目名称" />
</Form.Item>
<Form.Item name="grade_range" label="年级范围" rules={[{required: true, message: "请至少创建一个年级"}]}>
<ChangeTags onChange={grade_range => {
let createForm = Object.assign(this.state.createForm, {
grade_range,
});
this.setState({
createForm,
});
}}></ChangeTags>
</Form.Item>
<Form.Item name="subjects" label="涉及学科" rules={[{required: true, message: "请至少创建一个学科!"}]}>
<ChangeTags onChange={subjects => {
let createForm = Object.assign(this.state.createForm, {
subjects,
});
this.setState({
createForm,
});
}}></ChangeTags>
</Form.Item>
<Form.Item name="target" label="目标说明" rules={[{required: true, message: "目标说明不能为空!"}]}>
<TextArea
placeholder="请输入项目目标说明,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="summary" label="项目摘要" rules={[{required: true, message: "项目摘要不能为空!"}]}>
<TextArea
placeholder="请输入项目摘要,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="description" label="项目描述" rules={[{required: true, message: "项目描述不能为空!"}]}>
<TextArea
placeholder="请输入项目描述,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="requirement" label="项目要求" rules={[{required: true, message: "项目要求不能为空!"}]}>
<TextArea
placeholder="请输入项目要求,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
</Form>
</Spin>
</Modal>
</Footer>
</Layout>
);
}
}

View File

@ -0,0 +1,63 @@
[data-component=pending-tasks-page]{
width: 100%;
// height: 100%;
height: 80vh;
> .ant-layout-header{
width: 100%;
min-width: 700px;
// height: .64rem;
height: 64px;
background: #FFFFFF;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0rem .08rem;
// line-height: .64rem;
line-height: 64px;
> .title{
font-size: .16rem;
color: #000000D9;
}
> .right-box{
display: flex;
align-items: center;
height: .64rem;
> .ant-dropdown-trigger,.ant-input-search{
margin-right: .16rem;
}
> .ant-dropdown-trigger{
font-size: .14rem;
}
}
}
> .ant-layout-content{
height: 100%;
background-color: #FFFFFF;
.ant-table-header{
> .table{
height: .48rem;
}
.ant-table-cell::before{
display: none;
}
}
.ant-table-row{
height: .48rem;
> .ant-table-cell{
height: .48rem;
padding: 0;
font-size: 14px;
}
}
}
> .ant-layout-footer{
margin-bottom: 0rem;
padding: 0rem .2rem 0rem 0rem;
height: .5rem;
background-color: #ffffff;
display: flex;
align-items: center;
flex-direction: row-reverse;
}
}

View File

@ -0,0 +1,239 @@
import React, {Component} from "react";
import {Redirect, Route, Switch} from "react-router-dom";
import {Button, Descriptions, Form, Input, Modal, PageHeader, Spin, Tabs, message} from "antd";
import * as ProjectBackend from "./backend/ProjectBackend";
import ChangeTags from "./ChangeTags";
import Step from "./Step";
import BuildTeam from "./BuildTeam";
import "./ProjectManagementPage.less";
const {TabPane} = Tabs;
const {TextArea} = Input;
export default class ProjectManagementPage extends Component {
constructor(props) {
super(props);
this.state = {
demo: "Hello",
classes: props,
projectBaseInfo: {},
loadingState: true,
isCreateProjectVisible: false,
createLoading: false,
};
}
createFormRef = React.createRef();
componentDidMount() {
this.getProjectBaseInfo();
}
getProjectBaseInfo() {
this.setState({
loadingState: true,
});
ProjectBackend.GetDetailedInfo(this.props.match.params.project_id.split("_").join("/")).then(res => {
this.setState({
projectBaseInfo: res.data,
ProjectInfo: res.data.basic_info.basic_info,
loadingState: false,
});
}).catch(err => {
this.props.history.push("/home");
message.error(err.message || "项目信息加载失败,请重试!");
this.setState({
loadingState: false,
});
});
}
dateFilter(time) {
let date = new Date(time);
return `${date.getFullYear()}-${date.getMonth().toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
}
tabCruuent = () => {
let path_list = this.props.location.pathname.split("/");
return `${path_list[path_list.length - 1]}_${path_list[path_list.length - 2]}`;
}
render() {
return (
<div className="project-management-page" data-component="project-management-page" key="project-management-page">
<PageHeader
ghost={false}
onBack={() => this.props.history.push("/pending-tasks")}
title="项目管理"
subTitle={this.state.loadingState ? "加载中" : this.state.projectBaseInfo.basic_info.basic_info.name}
extra={[
<Button key="2" onClick={() => {
this.setState({
isCreateProjectVisible: true,
});
}}>编辑项目</Button>,
<Button key="1">导出成员</Button>,
]
}
footer = {
this.state.loadingState ? (
<Spin spinning={this.state.loadingState} tip="加载中" />
) : (
<Tabs defaultActiveKey={`${this.state.projectBaseInfo.steps[0].uuid}_${this.state.projectBaseInfo.steps[0].name}`} type="card" activeKey={this.tabCruuent()} onChange={(e) => {
this.props.history.push(`/project-management/${this.props.match.params.project_id}/${this.props.match.params.role}/${e.split("_")[1]}/${e.split("_")[0]}`, this.state.classes.account);
}}>
{
this.state.projectBaseInfo.steps.map(item => (
<TabPane key={`${item.uuid}_${item.name}`} tab={item.name}></TabPane>
))
}
</Tabs>
)
}
>
{
this.state.loadingState ? (
<Spin spinning={this.state.loadingState} tip="加载中..." />
) : (
<Descriptions size="small" column={3} style={{width: "auto"}}>
<Descriptions.Item label="创建时间">{this.dateFilter(this.state.projectBaseInfo.basic_info.created_time)}</Descriptions.Item>
<Descriptions.Item label="学科">
{
this.state.projectBaseInfo.basic_info.basic_info.subjects.map((item, index) => (
<span key={index}>{`${item}${index === this.state.projectBaseInfo.basic_info.basic_info.subjects.length - 1 ? "" : "、"}`}</span>
))
}
</Descriptions.Item>
<Descriptions.Item label="学段">
{
this.state.projectBaseInfo.basic_info.basic_info.grade_range.map((item, index) => (
<span key={index}>{`${item}${index === this.state.projectBaseInfo.basic_info.basic_info.grade_range.length - 1 ? "" : "、"}`}</span>
))
}
</Descriptions.Item>
<Descriptions.Item label="试卷">0</Descriptions.Item>
<Descriptions.Item label="试题">0</Descriptions.Item>
</Descriptions>
)
}
</PageHeader>
<div className="page-content-box">
{
this.state.loadingState ? (<></>) : (
<Switch>
{
this.state.projectBaseInfo.steps.map(item => (
<Route path={`/project-management/:project_id/:role/${item.name}/:step_id`} component={item.name === "组建团队" ? BuildTeam : Step} exact key={item.Id}></Route>
))
}
<Redirect from={`/project-management/${this.props.match.params.project_id}/${this.props.match.params.role}`} to={`/project-management/${this.props.match.params.project_id}/${this.props.match.params.role}/${this.state.projectBaseInfo.steps[0].name}/${this.state.projectBaseInfo.steps[0].uuid}`}></Redirect>
{/* <Route component={NotFound} key="404"></Route> */}
</Switch>
)
}
</div>
<Modal
title="编辑项目"
visible={this.state.isCreateProjectVisible}
cancelText="取消更改"
okText="确定更改"
closable={!this.state.createLoading}
confirmLoading={this.state.createLoading}
maskClosable={!this.state.createLoading}
keyboard={!this.state.createLoading}
onOk={() => {
const form = this.createFormRef.current;
form.validateFields().then(data => {
this.setState({
createLoading: true,
});
ProjectBackend.CreatTemplateProject(data).then(res => {
if (res.status == "ok") {
message.success("项目修改成功!");
this.createFormRef.current.resetFields();
this.getProjectList(this.state.classes.account);
} else {
message.error("项目修改失败!");
}
this.setState({
createLoading: false,
isCreateProjectVisible: false,
});
}).catch(err => {
message.error(err.message || "未知错误");
this.setState({
createLoading: false,
});
message.error(err.message || "未知错误");
});
}).catch(err => {
message.warning("请按要求填写表单项!");
});
}}
onCancel={() => {
if (this.state.createLoading) {
message.error("项目修改中,不可阻断!");
} else {
this.createFormRef.current.resetFields();
this.setState({
isCreateProjectVisible: false,
});
}
}}
>
<Spin spinning={this.state.createLoading} tip="项目修改中,请等待!">
<Form labelCol={{span: 4}} wrapperCol={{span: 20}} ref={this.createFormRef} name="createForm" initialValues={this.state.createForm}>
<Form.Item name="name" label="项目名称" rules={[{required: true, message: "项目名称不能为空!"}]}>
<Input placeholder="请输入项目名称" />
</Form.Item>
<Form.Item name="grade_range" label="年级范围" rules={[{required: true, message: "请至少创建一个年级"}]}>
<ChangeTags onChange={grade_range => {
let createForm = Object.assign(this.state.createForm, {
grade_range,
});
this.setState({
createForm,
});
}}></ChangeTags>
</Form.Item>
<Form.Item name="subjects" label="涉及学科" rules={[{required: true, message: "请至少创建一个学科!"}]}>
<ChangeTags onChange={subjects => {
let createForm = Object.assign(this.state.createForm, {
subjects,
});
this.setState({
createForm,
});
}}></ChangeTags>
</Form.Item>
<Form.Item name="target" label="目标说明" rules={[{required: true, message: "目标说明不能为空!"}]}>
<TextArea
placeholder="请输入项目目标说明,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="summary" label="项目摘要" rules={[{required: true, message: "项目摘要不能为空!"}]}>
<TextArea
placeholder="请输入项目摘要,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="description" label="项目描述" rules={[{required: true, message: "项目描述不能为空!"}]}>
<TextArea
placeholder="请输入项目描述,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
<Form.Item name="requirement" label="项目要求" rules={[{required: true, message: "项目要求不能为空!"}]}>
<TextArea
placeholder="请输入项目要求,若无,请填写无"
autoSize={{minRows: 3, maxRows: 5}}
/>
</Form.Item>
</Form>
</Spin>
</Modal>
</div >
);
}
}

View File

@ -0,0 +1,49 @@
[data-component=project-management-page]{
width: 100%;
height: 100%;
background-color: #EEEEEE;
overflow-y: scroll;
> .ant-page-header{
background-color: #FFFFFF;
padding: .16rem 0rem 0rem 0rem;
> .ant-page-header-heading{
box-sizing: border-box;
padding: 0rem .24rem;
}
> .ant-page-header-content{
padding-left: .564rem;
}
.ant-page-header-heading-title{
font-size: .2rem;
font-weight: 500;
line-height: .28rem;
color: #000000;
}
.ant-page-header-heading-sub-title{
font-size: .14rem;
line-height: .22rem;
color: rgba(0, 0, 0, 0.85);
}
.ant-tabs-nav-list{
padding-left: .564rem
}
.ant-descriptions{
width: 6.62rem;
}
.ant-tabs-tab-btn{
font-size: .14rem;
}
}
> .container{
width: 100%;
}
.ant-spin-nested-loading{
height: auto;
background-color: white;
}
.page-content-box{
width: 100%;
box-sizing: border-box;
padding: .3rem;
}
}

View File

@ -0,0 +1,541 @@
import React, {Component} from "react";
import {Button, Card, Col, Modal, Pagination, Radio, Row, Space, Spin, Table, message} from "antd";
import UpLoadQuestionModal from "./UpLoadQuestionModal";
import {EditOutlined, EllipsisOutlined, LockOutlined} from "@ant-design/icons";
import "./PropositionPaperHome.less";
import * as PropositionBackend from "./backend/PropositionBackend";
const {Meta} = Card;
export default class PropositionPaperHome extends Component {
constructor(props) {
super(props);
this.state = {
account: props.location.state.account,
mode: "testpaper",
questionData: [],
testpaperData: [],
recordData: [{
key: "1",
date: "text",
content: "/",
param1: "/",
param2: "/",
param3: "/",
}, {
key: "2",
date: "text",
content: "内容修改版本的文字内容......",
param1: "内容纬度1内容纬度2",
param2: "/",
param3: "/",
}, {
key: "3",
date: "text",
content: "/",
param1: "/",
param2: "/",
param3: "/",
}, {
key: "4",
date: "text",
content: "/",
param1: "/",
param2: "/",
param3: "/",
}, {
key: "5",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "6",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "7",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "8",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "9",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "10",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "11",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "12",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "13",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}, {
key: "14",
date: "text",
content: "text",
param1: "text",
param2: "text",
param3: "text",
}],
upLoadQuestionModalParams: {
show: false,
type: "create",
},
questionRecord: {
Id: "",
viewIndex: 0,
recordList: [],
},
modifyRecordVisible: false,
upLoadQuestionVisible: false,
editQuestionVisible: false,
createPaperVisible: false,
loadingState: false,
recordLoading: true,
testpaperVisible: {
show: false,
id_list: [],
loadingState: false,
questionList: [],
},
};
}
columns = [{
title: "时间",
key: "date",
width: 110,
render: (text, record) => (
<span>{this.timeFilter(record.create_at)}</span>
),
}, {
title: "内容",
key: "content",
width: 110,
render: (text, record) => (
<span>{record.basic_props.description}</span>
),
}, {
title: "难度",
key: "param1",
width: 110,
render: (text, record) => (
<span>{record.advanced_props.irt_level}</span>
),
}, {
title: "阶段",
key: "param2",
width: 110,
render: (text, record) => (
<span>{record.apply_record.grade_fits}</span>
),
}, {
title: "学科",
key: "param3",
width: 110,
render: (text, record) => (
<span>{record.basic_props.subject}</span>
),
}, {
title: "操作",
key: "operate",
render: (text, record) => {
return (
<Button type="link" onClick={() => {
this.setState({
questionRecord: Object.assign(this.state.questionRecord, {viewIndex: this.state.questionRecord.recordList.findIndex(item => item.Id === record.Id)}),
});
}}>预览</Button>
);
},
}];
handleModeChange = e => {
const mode = e.target.value;
if (e.target.value === "questions") {
this.getUserQuestionList(this.state.account.id);
} else {
this.getUserTestpaperList(this.state.account.id);
}
this.setState({mode});
};
getQuestionRecord = (qid) => {
this.setState({
recordLoading: true,
});
PropositionBackend.TraceQuestionVersion(qid).then(res => {
this.setState({
questionRecord: Object.assign(this.state.questionRecord, {recordList: res.data, viewIndex: 0}),
recordLoading: false,
});
}).catch(err => {
this.setState({
recordLoading: false,
modifyRecordVisible: false,
});
message.error(err.message || "请求错误!");
});
}
getQuestionListInfo = () => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {loadingState: true}),
});
PropositionBackend.GetTempQuestionList(this.state.testpaperVisible.id_list).then(res => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {loadingState: false, questionList: Object.values(res.data)}),
});
}).catch(err => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {loadingState: false, show: false}),
});
message.error(err.message || "请求错误");
});
}
loadQuestionData = () => {
if (this.state.mode === "questions") {
return this.state.questionData.map((item, index) => (
<Card key={index}
style={{width: 300, float: "left"}}
actions={[
<LockOutlined key="lock" />,
<EditOutlined key="edit" onClick={() => {
this.setState({
upLoadQuestionModalParams: {
type: "update",
show: true,
},
});
}} />,
<EllipsisOutlined key="ellipsis" onClick={() => {
this.setState({
modifyRecordVisible: true,
});
this.getQuestionRecord(item.uuid);
}} />,
]}
>
<Meta
title={(
<div className="header" style={{display: "flex", alignItems: "center", justifyContent: "space-between"}}>
<span>{item.basic_props.subject || "未知"}</span>
<span>{this.timeFilter(item.create_at)}</span>
</div>
)}
description={item.info.title}
/>
</Card>
));
} else {
return this.state.testpaperData.map((item, index) => (
<Card key={index}
style={{width: 300, float: "left"}}
actions={[
<LockOutlined key="lock" />,
<EditOutlined key="edit" onClick={() => {
this.setState({
upLoadQuestionModalParams: {
type: "update-paper",
show: true,
},
});
}} />,
<EllipsisOutlined key="ellipsis" onClick={() => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {id_list: item.info[0].question_list.map(item => item.question_id), show: true}),
});
this.getQuestionListInfo();
}} />,
]}
>
<Meta
title={(
<div className="header" style={{display: "flex", alignItems: "center", justifyContent: "space-between"}}>
<span>{item.props.subjects[0] || "未知"}</span>
<span>{this.timeFilter(item.create_at)}</span>
</div>
)}
description={item.info[0].description}
/>
</Card>
));
}
}
timeFilter = (time) => {
let date = new Date(time);
// ${date.getHours().toString().padStart(2,'0')}:${date.getMinutes().toString().padStart(2,'0')}:${date.getSeconds().toString().padStart(2,'0')}
return `${date.getFullYear()}-${date.getMonth().toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
}
componentDidMount = () => {
this.state.mode === "testpaper" ? this.getUserTestpaperList(this.state.account.id) : this.getUserQuestionList(this.state.account.id);
}
getUserQuestionList = (uid) => {
this.setState({
loadingState: true,
});
PropositionBackend.GetUserTempQuestions(uid).then(res => {
this.setState({
questionData: res.data ? res.data : [],
loadingState: false,
});
}).catch(err => {
this.setState({
loadingState: false,
});
message.error(err.message || "加载失败");
});
}
getUserTestpaperList = (uid) => {
this.setState({
loadingState: true,
});
PropositionBackend.GetUserTempTestpaper(uid).then(res => {
this.setState({
testpaperData: res.data ? res.data : [],
loadingState: false,
});
}).catch(err => {
this.setState({
loadingState: false,
});
message.error(err.message || "加载失败");
});
}
render() {
return (
<div className="proposition-paper-home-page" data-component="proposition-paper-home-page">
<div className="header">
<div className="describe">
<div className="content">
<h1>实现高效命题组卷</h1>
<div className="context">
单题编辑上传试卷调用轻松快捷<br />
xxxxxxxxxx示例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言例宣传语言
</div>
</div>
<div className="btn-box">
<Button type="primary" onClick={() => {
this.setState({
upLoadQuestionModalParams: {
type: "create",
show: true,
},
});
}}>上传试题</Button>
<Button type="primary" style={{marginLeft: ".18rem"}} onClick={() => {
this.setState({
upLoadQuestionModalParams: {
type: "create-paper",
show: true,
},
});
}}>创建试卷</Button>
</div>
</div>
<img src="https://item-cdn.open-ct.com/img/proposition-paper-icon.png" alt="图片" className="icon"></img>
</div>
<div className="container">
<div className="category-list">
<Radio.Group onChange={this.handleModeChange} value={this.state.mode} >
<Radio.Button value="questions">我的试题</Radio.Button>
<Radio.Button value="testpaper" style={{marginLeft: 4}}>我的试卷库</Radio.Button>
</Radio.Group>
</div>
<div className="main">
<Spin spinning={this.state.loadingState} tip="加载中">
{
this.state.loadingState ? "" : this.loadQuestionData()
}
</Spin>
</div>
</div>
<UpLoadQuestionModal
{...this.state.upLoadQuestionModalParams}
uid={this.state.account.id}
onClose={() => {
let upLoadQuestionModalParams = Object.assign(this.state.upLoadQuestionModalParams, {show: false});
this.setState({
upLoadQuestionModalParams,
});
}}
/>
<Modal
title="修改记录"
visible={this.state.modifyRecordVisible}
footer={null}
onCancel={() => {
this.setState({
modifyRecordVisible: false,
});
}}
width="16.12rem"
>
<Spin spinning={this.state.recordLoading} tip="加载中">
<div className="question-modify-record-box">
<div className="preview-box">
<div className="header">
<span>题目效果预览窗</span>
</div>
<div className="view-box" dangerouslySetInnerHTML={{
__html: this.state.recordLoading ? "加载中" : (
this.state.questionRecord.recordList[this.state.questionRecord.viewIndex] ? this.state.questionRecord.recordList[this.state.questionRecord.viewIndex].info.body : "渲染失败"
),
}}>
</div>
</div>
<div className="record-box">
<Space align="center">
修改历史版本
</Space>
<div className="container">
<Table
dataSource={this.state.questionRecord.recordList}
columns={this.columns}
pagination={false}
scroll={{y: "calc(100% - .56rem)"}}
/>
</div>
<div className="footer">
<Pagination
total={85}
showTotal={total => `Total ${total} items`}
defaultPageSize={20}
defaultCurrent={1}
size="small"
/>
</div>
</div>
</div>
</Spin>
</Modal>
<Modal
title="试卷详情"
visible={this.state.testpaperVisible.show}
width="80%"
onOk={() => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {show: false}),
});
}}
onCancel={() => {
this.setState({
testpaperVisible: Object.assign(this.state.testpaperVisible, {show: false}),
});
}}
>
<Spin spinning={this.state.testpaperVisible.loadingState} tip="加载中">
{
this.state.testpaperVisible.loadingState ? "" : (
<>
{
this.state.testpaperVisible.questionList.map((item, index) => (
<div className="paper-question-item" key={item.id}>
<Row className="header">
<Col span="4">
<span>序号<span style={{fontWeight: "bold", color: "red"}}>{index + 1}</span></span>
</Col>
<Col span="6">
<span>
测试年份<span style={{fontWeight: "bold", color: "green"}}>{item.apply_record.test_year}</span>
</span>
</Col>
<Col span="4">
<span>
试题难度<span style={{fontWeight: "bold", color: "blue"}}>{item.advanced_props.irt_level}</span>
</span>
</Col>
<Col span="4">
<span>
试题类型{item.info.type}
</span>
</Col>
<Col span="4">
<span>
题目答案{item.info.answer || "无"}
</span>
</Col>
</Row>
<div className="body" dangerouslySetInnerHTML={{__html: item.info.body}}></div>
<div className="footer">
<Button type="primary" style={{float: "right"}} onClick={() => {
this.getQuestionRecord(item.uuid);
this.setState({
modifyRecordVisible: true,
});
}}>查看历史版本</Button>
</div>
<br />
<br />
</div>
))
}
</>
)
}
</Spin>
</Modal>
</div>
);
}
}

View File

@ -0,0 +1,227 @@
[data-component=proposition-paper-home-page]{
width: 100%;
height: 100%;
overflow-y: scroll;
> .header{
width: 100%;
height: 4.53rem;
background-color: #FFFFFF;
box-sizing: border-box;
padding: 0px 1.44rem;
display: flex;
align-items: center;
justify-content: space-between;
> .describe{
width: 4.27rem;
height: 100%;
box-sizing: border-box;
padding-top: 1.605rem;
> .content{
width: 4.27rem;
height: 1.32rem;
margin-bottom: .315rem;
> h1{
height: .32rem;
font-weight: 500;
font-size: .24rem;
line-height: .32rem;
margin-bottom: .16rem;
}
> .context{
font-size: .14rem;
line-height: .22rem;
color: #000000A6;
}
}
> .btn-box{
width: max-content;
height: .32rem;
display: flex;
align-items: center;
}
}
> .icon{
width: 4.04rem;
height: 4.04rem;
}
}
> .container{
width: 100%;
//height: calc(100% - 4.53rem);
box-sizing: border-box;
padding: .66rem 1.44rem .92rem 1.44rem;
> .category-list{
width: 100%;
height: .38rem;
margin-bottom: .19rem;
.ant-radio-button-wrapper {
background-color: #FAFAFA;
border: none;
box-shadow: none;
&::before{
display: none;
}
> .ant-radio-button-checked{
background-color: #FFFFFF;
}
}
}
> .main{
width: 100%;
height: 3.54rem;
.ant-spin{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
// display: flex;
// flex-wrap: wrap;
// align-content: space-between;
// justify-content: space-between;
}
}
.question-item{
width: 2.4rem;
height: 1.64rem;
background-color: #FFFFFF;
float: left;
margin-bottom: .1rem;
margin-right: .1rem;
> .header{
box-sizing: border-box;
padding: 0px .16rem;
width: 100%;
height: .38rem;
display: flex;
align-items: center;
justify-content: space-between;
> .category{
font-size: .14rem;
color: #000000D9;
}
> .date{
font-size: .14rem;
color: #D9D9D9;
}
}
> .container{
width: 100%;
height: .86rem;
box-sizing: border-box;
padding: .16rem;
border-bottom: 1px solid #ccc;
> .info{
width: 100%;
height: .24rem;
line-height: .24rem;
margin-bottom: .08rem;
> span{
font-size: .16rem;
color: #000000D9;
}
}
> .project{
width: 100%;
height: .22rem;
line-height: .22rem;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
> span{
font-size: .14rem;
color: #00000073;
}
}
}
> .footer{
width: 100%;
height: .4rem;
display: flex;
align-items: center;
justify-content: space-between;
> .b-right{
border-right: 1px solid #ccc;
}
> .action-item{
width: calc(100% / 3);
height: .16rem;
cursor: pointer;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
> .action{
color: #00000073;
}
}
}
}
}
.question-modify-record-box{
width: 100%;
height: 8.36rem;
box-sizing: border-box;
padding: .24rem .23rem .39rem 0rem;
display: flex;
align-items: center;
justify-content: space-between;
> .preview-box{
width: 5.53rem;
height: 100%;
box-sizing: border-box;
border: 1px solid #1890FF;
> .header{
width: 100%;
height: .35rem;
box-sizing: border-box;
padding-left: .46rem;
padding-top: .13rem;
line-height: .22rem;
}
> .view-box{
width: 100%;
box-sizing: border-box;
padding: 0rem .2rem;
height: calc(100% - .35rem);
overflow-y: scroll;
margin-top: .2rem;
}
}
> .record-box{
width: calc(100% - 5.88rem);
height: 100%;
.ant-space{
height: .32rem;
margin-bottom: .08rem;
}
.ant-table-thead,.ant-table-row{
height: .56rem;
}
> .container{
width: 100%;
height: calc(100% - .9rem);
.ant-table,.ant-table-wrapper,.ant-table-container {
width: 100%;
height: 100%;
}
}
> .footer{
width: 100%;
height: .5rem;
display: flex;
flex-direction: column-reverse;
}
}
}
.upLoad-question-title{
width: 100%;
margin-bottom: .27rem;
> span{
font-size: .14rem;
color: #898989;
}
}

View File

@ -0,0 +1,34 @@
import React, {Component} from "react";
import {Redirect, Route, Switch} from "react-router-dom";
import CreatePaper from "./CreatePaper";
import UploadQuestions from "./UploadQuestions";
import Home from "./PropositionPaperHome";
export default class PropositionPaperHome extends Component {
constructor(props) {
super(props);
this.state = {
classes: props,
};
}
componentDidMount() {
this.props.history.push({
path: "/proposition-paper/home",
state: {
account: this.props.account,
},
});
}
render() {
return (
<div className="proposition-paper-page" data-component="proposition-paper-page" style={{width: "100%", height: "100%"}}>
<Switch>
<Route path="/proposition-paper/home" component={Home} ></Route>
<Route path="/proposition-paper/create-paper/:project/:subject/:ability/:content/:type/:uid" component={CreatePaper} ></Route>
<Route path="/proposition-paper/upload-questions/:project/:subject/:ability/:content/:type/:uid" component={UploadQuestions}></Route>
<Redirect to="/proposition-paper/home" ></Redirect>
</Switch>
</div>
);
}
}

52
web/src/Step.js Normal file
View File

@ -0,0 +1,52 @@
import React, {Component} from "react";
import {Col, Row} from "antd";
import TaskRequirements from "./TaskRequirements";
import CompletionStatus from "./CompletionStatus";
import MaterialWarehouse from "./MaterialWarehouse";
import DataTable from "./DataTable";
import "./Step.less";
export default class index extends Component {
render() {
return (
<div className="step-page" data-component="step-page">
<Row style={{height: "7.48rem", marginBottom: ".22rem"}} gutter={24}>
<Col span={9}>
<Row style={{height: "1.9rem", marginBottom: ".22rem"}}>
<TaskRequirements
role={this.props.match.params.role}
stepId={this.props.match.params.step_id}
projectId={this.props.match.params.project_id}
></TaskRequirements>
</Row>
<Row style={{height: "1.9rem", marginBottom: ".12rem"}}>
<CompletionStatus
title="自项目创建截止今日情况"
stepId = {this.props.match.params.step_id}
/>
</Row>
<Row style={{height: "3.34rem"}}>
<MaterialWarehouse
role = {this.props.match.params.role}
projectId = {this.props.match.params.project_id}
stepId = {this.props.match.params.step_id}
stepName = {this.props.location.pathname.split("/")[this.props.location.pathname.split("/").length - 2]}
>
</MaterialWarehouse>
</Row>
</Col>
<Col span={15}>
<DataTable
title="材料评审"
stepName={this.props.location.pathname.split("/")[this.props.location.pathname.split("/").length - 2]}
role={this.props.match.params.role}
stepId={this.props.match.params.step_id}
>
</DataTable>
</Col>
</Row>
</div>
);
}
}

9
web/src/Step.less Normal file
View File

@ -0,0 +1,9 @@
[data-component=step-page]{
width: 100%;
height: auto;
.addition-box{
width: 100%;
height: 100%;
background-color: white;
}
}

208
web/src/TaskRequirements.js Normal file
View File

@ -0,0 +1,208 @@
import React, {Component} from "react";
import {Button, Upload, message} from "antd";
import ModulaCard from "./ModulaCard";
import CalendarButton from "./CalendarButton";
import {FieldTimeOutlined, LinkOutlined} from "@ant-design/icons";
import "./TaskRequirements.less";
export default class index extends Component {
state = {
stepInfo: {},
loadingState: false,
upLoadState: false,
}
upLoadFile(info) {
this.setState({
upLoadState: true,
});
message.info("开始上传文件:" + info.file.name);
const formData = new FormData();
formData.append("file", info.file);
formData.append("source_project", this.props.projectId);
formData.append("tags", "无");
formData.append("description", "步骤附件");
// request({
// url:baseURL+"/review/file",
// // url:'http://49.232.73.36:8081/review/file',
// method:"POST",
// data:formData,
// headers:{
// "Content-Type":"multipart/form-data;"
// }
// }).then(res => {
// request({
// url:baseURL+"/review/proj/step/attachment",
// // url:'http://49.232.73.36:8081/review/proj/step/attachment',
// method:"POST",
// data:{
// files_ids:[res.data.uuid],
// step_id:this.props.stepId
// }
// }).then(res => {
// console.log(res);
// this.setState({
// upLoadState:false
// });
// this.getStepInfo();
// message.success("文件上传成功");
// }).catch(err => {
// this.setState({
// upLoadState:false
// });
// message.error("文件上传失败");
// });
// }).catch(err => {
// this.setState({
// upLoadState:false
// });
// message.error("文件上传失败");
// });
}
downLoadFile = () => {
if (this.state.stepInfo.attachments.length === 0) {
message.warning("暂无可下载附件");
} else {
message.info(`开始下载文件:${this.state.stepInfo.attachments[0]}`);
// request({
// url:baseURL+`/review/file/${this.state.stepInfo.attachments[0]}`,
// // url:`http://49.232.73.36:8081/review/file/${this.state.stepInfo.attachments[0]}`,
// method: "GET",
// responseType:"blob"
// }).then(res => {
// console.log(res);
// const filename = res.headers["content-disposition"];
// const blob = new Blob([res.data]);
// var downloadElement = document.createElement("a");
// var href = window.URL.createObjectURL(blob);
// downloadElement.href = href;
// downloadElement.download = decodeURIComponent(filename.split("filename*=")[1].replace("utf-8''", ""));
// document.body.appendChild(downloadElement);
// downloadElement.click();
// document.body.removeChild(downloadElement);
// window.URL.revokeObjectURL(href);
// message.success("文件下载成功!");
// }).catch(err => {
// message.error("文件下载失败!");
// });
}
}
// 根据不同身份加载不同操作情况
operationRender = () => {
let operationDomList = [() => (
<div className="choice-box">
<CalendarButton label="截止时间2021年8月20日" icon={<FieldTimeOutlined />} onDateChange={(date) => {
message.error("改操作暂不可用");
}} />
<Upload
name="filename"
showUploadList={false}
beforeUpload={() => {
if (this.state.upLoadState) {
message.error("当前存在上传中文件,请勿频繁上传!");
return false;
}
return true;
}}
customRequest={this.upLoadFile.bind(this)}
>
<Button size="small" icon={<LinkOutlined />} style={{marginLeft: ".1246rem"}}>{
this.state.stepInfo.attachments ? "已上传" : "暂无文件"
}</Button>
</Upload>
</div>
), () => (
<div className="choice-box">
<Button size="small" style={{marginRight: ".1246rem"}} icon={<FieldTimeOutlined />}>截止时间2021年8月20日</Button>
<Button size="small" icon={<LinkOutlined />} onClick={this.downLoadFile}>{
this.state.stepInfo.attachments ? "已上传" : "暂无文件"
}</Button>
</div>
), () => (
<div className="choice-box">
<Button size="small" style={{marginRight: ".1246rem"}} icon={<FieldTimeOutlined />}>截止时间2021年8月20日</Button>
<Button size="small" icon={<LinkOutlined />} onClick={this.downLoadFile}>{
this.state.stepInfo.attachments ? "已上传" : "暂无文件"
}</Button>
</div>
)];
return operationDomList[(this.props.role === "1" || this.props.role === "5") ? 0 : this.props.role - 2]();
}
componentDidMount() {
this.getStepInfo();
}
getStepInfo = () => {
this.setState({
loadingState: true,
});
// request({
// url:baseURL+`/review/proj/step/${this.props.stepId}`,
// // url:`http://49.232.73.36:8081/review/proj/step/${this.props.stepId}`,
// method:"GET"
// }).then(res => {
// this.setState({
// stepInfo:res.data,
// loadingState:false,
// });
// }).catch(err => {
// this.setState({
// loadingState:false,
// });
// });
var res = {
"operation_code": 1000,
"message": "",
"data": {
"Id": "62e4b170b686c0cf874cf17e",
"CreateAt": "2022-07-30T04:20:00.14Z",
"UpdateAt": "2022-07-30T04:20:00.14Z",
"uuid": "a17143e3-e428-4058-9ee7-7c1d7998fd97",
"project_id": "5677cb5a-e047-4be4-9d40-718a6c9371ef",
"index": 1,
"name": "测试框架与论证报告",
"description": "",
"requirement": "",
"status": 0,
"deadline": 0,
"timetable": null,
"creator": "2ab2770e-b6e7-476b-969c-2db815e878e6",
"attachments": [
"847ee0d9-a5bb-4186-9c59-852f9436f63e",
],
},
};
this.setState({
stepInfo: res.data,
loadingState: false,
});
}
render() {
return (
<ModulaCard title="任务要求">
{
this.state.loadingState ? (
<></>
) : (
<div className="task-requirements-box" data-component="task-requirements-box">
<div className="describe-box">
<div className="context">
<p>{this.state.stepInfo.requirement || "无"}</p>
</div>
<div className="btn-box">
{this.props.role === 2 ? (<Button type="link">编辑</Button>) : ""}
</div>
</div>
{this.operationRender()}
</div>
)
}
</ModulaCard>
);
}
}

View File

@ -0,0 +1,37 @@
[data-component=task-requirements-box]{
width: 100%;
height: calc(100% - .38rem);
> .describe-box{
width: 100%;
height: .66rem;
box-sizing: border-box;
padding: 0rem 0rem 0rem .5rem;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: .21rem;
> .context{
width: 5rem;
height: 100%;
> p{
font-size: .14rem;
line-height: .22rem;
margin: 0;
}
}
> .btn-box{
height: 100%;
}
}
> .choice-box{
width: 100%;
height: .32rem;
box-sizing: border-box;
padding: 0rem 0rem 0rem .5rem;
display: flex;
.ant-btn {
border-color: #1890FF;
color: #1890FF;
}
}
}

228
web/src/UpLoadModal.js Normal file
View File

@ -0,0 +1,228 @@
// 上传文件弹出框组件
import React, {Component} from "react";
import {Form, Input, Modal, Radio, Upload, message} from "antd";
import {InboxOutlined} from "@ant-design/icons";
import "./UpLoadModal.less";
export default class index extends Component {
state = {
upLoadFileList: [],
upLoadState: false, // 用于控制文件上传
createLoading: false,
submitForm: {
type: 1,
},
}
upLoadFormRef = React.createRef()
upLoadFile(info) {
this.setState({
upLoadState: true,
});
message.info("开始上传文件:" + info.file.name);
const formData = new FormData();
formData.append("file", info.file);
formData.append("source_project", this.props.projectId);
formData.append("tags", "无");
formData.append("description", "步骤附件");
// request({
// url:baseURL+"/review/file",
// // url:'http://49.232.73.36:8081/review/file',
// method:"POST",
// data:formData,
// headers:{
// "Content-Type":"multipart/form-data;"
// }
// }).then(res => {
// console.log(res);
// let upLoadFileList = Object.assign(this.state.upLoadFileList, {});
// upLoadFileList[upLoadFileList.length-1].status = "done";
// upLoadFileList[upLoadFileList.length-1].id = res.data.uuid;
// this.setState({
// upLoadFileList,
// upLoadState:false
// });
message.success("文件上传成功");
// }).catch(err => {
// let upLoadFileList = Object.assign(this.state.upLoadFileList, {});
// upLoadFileList[upLoadFileList.length-1].status = "error";
// this.setState({
// upLoadFileList,
// upLoadState:false
// });
// message.error("文件上传失败");
// });
}
createSubmit = () => {
if(this.state.upLoadFileList.length === 0) {
message.warning("请至少上传一个文件");
}else{
this.setState({
createLoading: true,
});
}
this.setState({
createLoading: false,
upLoadFileList: [],
});
// request({
// url:baseURL+"/review/proj/submit",
// // url:"http://49.232.73.36:8081/review/proj/submit",
// method:"POST",
// data:{
// description:"暂无",
// step_id:this.props.stepId,
// title:"一个新的提交"
// }
// }).then(res => {
// request({
// url:baseURL+"/review/proj/submit/content",
// // url:"http://49.232.73.36:8081/review/proj/submit/content",
// method:"POST",
// data:{
// comment:"一个新的文件",
// item_id:this.state.upLoadFileList[0].id,
// submit_id:res.data.uuid,
// type:this.state.submitForm.type,
// version:"1.0.0"
// }
// }).then(res => {
// this.upLoadFormRef.current.resetFields();
// this.setState({
// createLoading:false,
// upLoadFileList:[]
// });
// this.props.onClose();
// message.success("创建成功");
// this.props.onUpdate();
// }).catch(err => {
// this.setState({
// createLoading:false
// });
// message.error(err.message||"创建失败");
// });
// }).catch(err => {
// this.setState({
// createLoading:false
// });
// message.error(err.message||"创建失败");
// });
// }
}
render() {
return (
<Modal title="上传材料"
width="6.26rem"
okText="确认创建"
cancelText="放弃创建"
visible={this.props.show}
closable={!this.state.createLoading}
keyboard={!this.state.createLoading}
confirmLoading={this.state.createLoading}
onCancel={() => {
if(this.state.createLoading) {
message.info("请等待");
}else{
this.upLoadFormRef.current.resetFields();
this.setState({
upLoadFileList: [],
});
this.props.onClose();
}
}}
onOk={this.createSubmit}
>
<div className="up-load-modal-box" data-component="up-load-modal-box">
<Form
name="material"
labelCol={{span: 6}}
wrapperCol={{span: 18}}
initialValues = {this.state.submitForm}
ref={this.upLoadFormRef}
>
<Form.Item
label="材料内容"
name="type"
rules={[{required: true}]}
>
<Radio.Group size="small"
onChange={(e) => {
this.setState({
upLoadFormData: Object.assign({}, this.state.submitForm, {type: e.target.value}),
});
}}
>
<Radio value={1} key="option_1">新材料</Radio>
<Radio value={2} key="option_2">再修改材料</Radio>
<Radio value={3} key="option_3">驳回修改材料</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
label="材料编号"
name="material-id"
className="material__id"
rules={[{required: true}]}
extra="新材料自动生成材料编号,不可修改"
>
<Input placeholder="AK9800000123" disabled />
</Form.Item>
<Form.Item
label="上传"
rules={[{required: true}]}
labelCol={{span: 4}}
required={true}
>
<Upload.Dragger
name="filename"
fileList={this.state.upLoadFileList}
headers={{
// "Token":getCookie("token")
"Token": "demo",
}}
beforeUpload={(e) => {
if(this.state.upLoadState || this.state.createLoading) {
message.warning("当前存在上传中文件,请等待");
return false;
}else{
let upLoadFileList = [...this.state.upLoadFileList];
upLoadFileList.push({
name: e.name,
status: "uploading",
});
this.setState({
upLoadFileList,
});
return true;
}
}}
customRequest={this.upLoadFile.bind(this)}
onRemove={(e) => {
// uid
let upLoadFileList = Object.assign(this.state.upLoadFileList, {});
upLoadFileList = upLoadFileList.splice(upLoadFileList.findIndex(item => item.uid === e.uid), 1);
this.setState({
upLoadFileList,
});
console.log(this.state.upLoadFileList);
}}
>
<p className="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p className="ant-upload-text">Click or drag file to this area to upload</p>
<p className="ant-upload-hint" style={{fontSize: ".1rem"}}>Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files</p>
</Upload.Dragger>
</Form.Item>
</Form>
</div>
</Modal>
);
}
}

37
web/src/UpLoadModal.less Normal file
View File

@ -0,0 +1,37 @@
[data-component=up-load-modal-box]{
width: 100%;
.material__id{
display: block;
.ant-form-item-control{
box-sizing: border-box;
padding-left: 0.4008rem;
max-width: 91.66666667%;
.ant-form-item-control-input{
width: 100%;
max-width: 100%;
.ant-input {
background-color: #FFFFFF;
}
}
.ant-form-item-extra{
font-size: .14rem;
line-height: .22rem;
color: #00000073;
}
}
}
.upload-file-item{
width: 100%;
height: .22rem;
line-height: .22rem;
> .anticon{
color: #00000073;
font-size: .11rem;
}
> span{
font-size: .14rem;
color: #1890FF;
cursor: pointer;
}
}
}

View File

@ -0,0 +1,282 @@
import React, {Component} from "react";
import {Form, Modal, Select, Tag, message} from "antd";
import {withRouter} from "react-router-dom";
import {ExclamationCircleOutlined} from "@ant-design/icons";
import * as PorjectBackend from "./backend/ProjectBackend";
const {Option} = Select;
const {confirm} = Modal;
class index extends Component {
state = {
form: {
project: null,
subject: null,
content: [],
ability: [],
type: null,
},
projectLoading: false,
projectList: [],
}
contentOption = [{
value: "数与代数",
}, {
value: "历史认知",
}, {
value: "积累与运用",
}]
abilityOption = [{
value: "听力",
}, {
value: "了解",
}, {
value: "认识与知识",
}, {
value: "古诗文积累",
}]
formRef = React.createRef()
titleList=[{
type: "create",
value: "上传试题信息",
}, {
type: "update",
value: "编辑试题信息",
}, {
type: "edit",
value: "编辑试题信息",
}, {
type: "create-paper",
value: "上传试卷信息",
}, {
type: "update-paper",
value: "更新试卷信息",
}]
componentDidMount() {
this.getProjectList();
}
getProjectList = () => {
this.setState({
projectLoading: true,
});
let uid = this.props.uid ? this.props.uid : this.props.match.params.uid;
PorjectBackend.GetUserAssignments(uid).then(res => {
let id_list = [];
for(let i = 0;i < res.data.length;i++) {
id_list.push(res.data[i].project_id);
}
PorjectBackend.GetProjectList(id_list).then(res => {
this.setState({
projectList: Object.values(res.data),
projectLoading: false,
});
}).catch(err => {
message.error(err.message || "加载失败,请重试");
this.setState({
projectLoading: false,
});
});
}).catch(err => {
message.error(err.message || "加载失败,请重试");
this.setState({
projectLoading: false,
});
});
}
tagRender = (props) => {
let colorList = ["gold", "lime", "green", "cyan"];
const {label, closable, onClose} = props;
const onPreventMouseDown = event => {
event.preventDefault();
event.stopPropagation();
};
return (
<Tag
color={colorList[Math.floor(Math.random() * (3))]}
onMouseDown={onPreventMouseDown}
closable={closable}
onClose={onClose}
style={{marginRight: 3}}
>
{label}
</Tag>
);
}
render() {
return (
<Modal
title={this.titleList[this.titleList.findIndex(item => item.type === this.props.type)].value}
cancelText="取消"
okText={this.props.type === "create" || this.props.type === "create-paper" ? "下一步" : "保存"}
visible={this.props.show}
onOk={() => {
this.formRef.current.validateFields().then(data => {
if(this.props.type === "create") {
this.props.history.push(`/proposition-paper/upload-questions/${data.project}/${data.subject}/${data.ability}/${data.content}/${data.type}/${this.props.uid}`);
}else if(this.props.type === "update") {
let that = this;
confirm({
icon: <ExclamationCircleOutlined />,
content: "此操作将覆盖当前撰写的试题,是否继续?",
onOk() {
that.props.onClose();
that.props.history.push(`/proposition-paper/upload-questions/${data.project}/${data.subject}/${data.ability}/${data.content}/${data.type}/${this.props.uid}`);
},
onCancel() {
that.props.onClose();
},
});
}else if(this.props.type === "edit") {
console.log("开始保存");
this.props.onClose();
}else if(this.props.type === "create-paper") {
this.props.history.push(`/proposition-paper/create-paper/${data.project}/${data.subject}/${data.ability}/${data.content}/${data.type}/${this.props.uid}`);
}else if(this.props.type === "update-paper") {
let that = this;
confirm({
icon: <ExclamationCircleOutlined />,
content: "此操作将覆盖当前撰写的试卷,是否继续?",
onOk() {
that.props.onClose();
that.props.history.push(`/proposition-paper/create-paper/${data.project}/${data.subject}/${data.ability}/${data.content}/${data.type}/${this.props.uid}`);
},
onCancel() {
that.props.onClose();
},
});
}else{
message.error("组件参数异常,失败!");
this.props.onClose();
}
}).catch(err => {
message.warning("请按要求选择选项");
});
}}
onCancel={() => {
this.formRef.current.resetFields();
this.props.onClose();
}}
>
<div className="upLoad-question-title">
<span>试题编号编号:absnahghj自动生成</span>
</div>
<Form
labelCol={{span: 5}}
wrapperCol={{span: 19}}
labelAlign="left"
ref={this.formRef}
initialValues={this.state.form}
>
<Form.Item
name="project"
label="项目"
rules={[{required: true, message: "请选择项目名称"}]}
>
<Select placeholder="选择项目名称" loading={this.state.projectLoading} onFocus={this.getProjectList} onSelect={(e) => {
let from = Object.assign(this.state.form, {project: e});
this.setState({
from,
});
}}>
{
this.state.projectLoading ? (
<></>
) : this.state.projectList.map(item => (
<Option key={item.basic_info.owner + item.basic_info.name} value={item.basic_info.name}>{item.basic_info.name}</Option>
))
}
</Select>
</Form.Item>
<Form.Item
name="subject"
label="学科"
rules={[{required: true, message: "请选择学科"}]}
>
<Select placeholder="选择学科" loading={this.state.projectLoading} onFocus={() => {
if(!this.state.form.project) {
message.warning("请先选择项目");
}
}} onSelect={(e) => {
let form = Object.assign(this.state.form, {subject: e});
this.setState({
form,
});
}}>
{
!this.state.form.project ? (
<></>
) : this.state.projectList[this.state.projectList.findIndex(item => item.name === this.state.form.project)].basic_info.subjects.map((item, index) => (
<Option key={index} value={item}>{item}</Option>
))
}
</Select>
</Form.Item>
<Form.Item
name="content"
label="内容纬度"
rules={[{required: true, message: "请选择内容纬度"}]}
>
<Select
mode="multiple"
showArrow
tagRender={this.tagRender}
style={{width: "100%"}}
options={this.contentOption}
onChange={(e) => {
let form = Object.assign(this.state.form, {content: e});
this.setState({
form,
});
}}
/>
</Form.Item>
<Form.Item
name="ability"
label="能力维度"
rules={[{required: true, message: "请选择能力维度"}]}
>
<Select
mode="multiple"
showArrow
tagRender={this.tagRender}
style={{width: "100%"}}
options={this.abilityOption}
onChange={(e) => {
let form = Object.assign(this.state.form, {ability: e});
this.setState({
form,
});
}}
/>
</Form.Item>
<Form.Item
name="type"
label="题型"
rules={[{required: true, message: "请选择题型"}]}
>
<Select placeholder="选择题型" onSelect={(e) => {
let form = Object.assign(this.state.form, {type: e});
this.setState({
form,
});
}}>
<Option value="1">选择题</Option>
<Option value="2">填空题</Option>
<Option value="3">简答题</Option>
</Select>
</Form.Item>
</Form>
</Modal>
);
}
}
export default withRouter(index);

159
web/src/UploadQuestions.js Normal file
View File

@ -0,0 +1,159 @@
import React, {Component} from "react";
import {Button, Descriptions, Input, Layout, Menu, PageHeader, Pagination, Spin, message} from "antd";
import ChoiceQuestionEditer from "./ChoiceQuestionEditer";
import HistoryQuestion from "./HistoryQuestion";
import UpLoadQuestionModal from "./UpLoadQuestionModal";
import "./UploadQuestions.less";
import * as ProjectBackend from "./backend/ProjectBackend";
const {Search} = Input;
const {Sider, Content} = Layout;
export default class UploadQuestions extends Component {
state = {
difficultyValue: 4,
createTime: 0,
projectInfo: {},
initLoading: true,
upLoadQuestionModalParams: {
show: false,
type: "update",
},
}
componentDidMount() {
let t = new Date();
this.setState({
createTime: `${t.getFullYear()}-${t.getMonth().toString().padStart(2, "0")}-${t.getDate().toString().padStart(2, "0")} ${t.getHours().toString().padStart(2, "0")}:${t.getMinutes().toString().padStart(2, "0")}:${t.getSeconds().toString().padStart(2, "0")}`,
});
this.getProjectInfo();
}
getProjectInfo=() => {
let newParms = this.props.match.params;
ProjectBackend.GetDetailedInfo(newParms.uid + "/" + newParms.project).then(res => {
this.setState({
projectInfo: res.data.basic_info,
initLoading: false,
});
}).catch(err => {
this.setState({
initLoading: false,
});
this.props.history.goBack();
message.error("编辑器加载失败!");
});
}
render() {
return (
<div className="upLoad-question-page" data-component="upLoad-question-page">
<PageHeader
ghost={false}
onBack={() => this.props.history.goBack()}
title="命题组卷"
subTitle="上传试题"
extra={[
<Button key="1" onClick={() => {
this.setState({
upLoadQuestionModalParams: {
show: true,
type: "update",
},
});
}}>编辑内容</Button>,
]}
>
{
this.state.initLoading ? (
<Spin spinning={true} tip="初始化中"></Spin>
) : (
<Descriptions size="small" column={3}>
<Descriptions.Item label="创建时间" key="createAt">{this.state.createTime}</Descriptions.Item>
<Descriptions.Item label="项目" key="peojects">{this.state.projectInfo.basic_info.name}</Descriptions.Item>
<Descriptions.Item label="学科" key="subjects">{
this.state.projectInfo.basic_info.subjects.map((item, index) => (
<span key={index}>{item}{index === this.state.projectInfo.basic_info.subjects.length - 1 ? "" : "、"}</span>
))
}</Descriptions.Item>
<Descriptions.Item label="内容纬度" key="content">{
this.props.match.params.content.split(",").map((item, index) => (
<span key={index}>{item}{index === this.props.match.params.content.split(",").length - 1 ? "" : "、"}</span>
))
}</Descriptions.Item>
<Descriptions.Item label="能力纬度" key="ability">
{
this.props.match.params.ability.split(",").map((item, index) => (
<span key={index}>{item}{index === this.props.match.params.ability.split(",").length - 1 ? "" : "、"}</span>
))
}
</Descriptions.Item>
</Descriptions>
)
}
</PageHeader>
<div className="main">
<Layout className="container">
<Sider theme="light" width="2.4rem" style={{backgroundColor: "#FAFAFA"}}>
<Menu
style={{width: "2.4rem"}}
defaultSelectedKeys={[this.props.match.params.type]}
defaultOpenKeys={[this.props.match.params.type]}
mode="vertical"
theme="light"
onClick = {(e) => {
let data = this.props.match.params;
this.props.history.push(`/proposition-paper/upload-questions/${data.project}/${data.subject}/${data.ability}/${data.content}/${e.key}`);
}}
>
<Menu.Item key="1">选择题</Menu.Item>
<Menu.Item key="2">填空题</Menu.Item>
<Menu.Item key="3">阅读题</Menu.Item>
</Menu>
</Sider>
<Content style={{backgroundColor: "white"}} className="content">
<ChoiceQuestionEditer
author={this.props.match.params.uid}
defaultSubjectValue={this.props.match.params.subject}
subjectList={this.state.initLoading ? [] : this.state.projectInfo.basic_info.subjects}
ability={this.props.match.params.ability.split(",")}
content={this.props.match.params.content.split(",")}
grade_range={this.state.initLoading ? [] : this.state.projectInfo.basic_info.grade_range}
projectId={this.props.match.params.project}
/>
</Content>
<Sider theme="light" width="7.47rem" className="question-box">
<div className="question-content-box">
<div className="title">相关题目</div>
<div className="filter-box">
<span>筛选</span>
<Search placeholder="input search text" style={{width: 200}} size="small" />
</div>
<HistoryQuestion
/>
<HistoryQuestion
/>
<HistoryQuestion
/>
<Pagination defaultCurrent={1} total={50} className="page-spare" />
</div>
</Sider>
</Layout>
</div>
<UpLoadQuestionModal
{...this.state.upLoadQuestionModalParams}
onClose={() => {
let upLoadQuestionModalParams = Object.assign(this.state.upLoadQuestionModalParams, {show: false});
this.setState({
upLoadQuestionModalParams,
});
}}
/>
</div>
);
}
}

View File

@ -0,0 +1,289 @@
[data-component=upLoad-question-page]{
width: 100%;
height: 100%;
.main{
background-color: white;
> .container{
width: 100%;
height: 100%;
}
}
.ant-menu-inline{
border-right: none;
}
.ant-menu-item{
padding-left: .7rem;
box-sizing: border-box;
}
.ant-menu-item-selected{
border-right: 3px solid #1890ff;
}
.content{
box-sizing: border-box;
padding: .3rem .3rem 0rem .3rem;
> .title{
width: 100%;
> p{
font-size: .12rem;
font-weight: 400;
}
}
.line{
width: 100%;
height: .01rem;
background-color: #D9D9D9;
margin: .15rem 0px;
}
.edit-box{
width: 100%;
min-height: 4.67rem;
margin-top: .2rem;
> .edit-core-box{
width: 100%;
height: 5.27rem;
}
}
.header-title{
width: 100%;
height: .41rem;
background-color: #EEEEEE;
box-sizing: border-box;
padding: .13rem .1rem 0rem .1rem;
display: flex;
justify-content: space-between;
> .title{
font-size: .14rem;
}
> svg{
width: .19rem;
}
> .right-box{
width: 1.92rem;
height: 100%;
margin-right: .57rem;
display: flex;
justify-content: space-between;
> span{
font-size: .1rem;
color: #00000066;
}
}
}
.subject-edit-box,.params-edit-box{
width: 100%;
height: calc(100% - .45rem);
box-sizing: border-box;
border: .01rem solid #D9D9D9;
margin-top: .04rem;
border-radius: .02rem;
padding: .1rem .05rem 0rem .08rem;
}
.subject-edit-box{
> .ant-input{
border: none;
box-shadow: none;
}
}
.difficulty{
width: 100%;
height: .32rem;
display: flex;
align-items: center;
justify-content: center;
> .content-box{
width: 100%;
height: 4px;
background-color: #F5F5F5;
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
> .value-box{
position: absolute;
height: 100%;
background-color: #91D5FF;
transition: all .2s;
}
> .value-item{
width: .08rem;
height: .08rem;
background-color: #F5F5F5;
border-radius: .08rem;
cursor: pointer;
position: relative;
> .value{
width: .16rem;
height: .16rem;
font-size: .14rem;
position: absolute;
bottom: -0.18rem;
left: -0.04rem;
text-align: center;
}
&::before{
content:"";
display: block;
width: .04rem;
height: .04rem;
background-color: white;
border-radius: .04rem;
position: absolute;
top: .02rem;
left: .02rem;
z-index: 2;
}
&::after{
content:"";
display: block;
width: .08rem;
height: .08rem;
background-color: #69C0FF;
border-radius: .08rem;
position: absolute;
top: 0rem;
left: 0rem;
z-index: 1;
}
}
> .select-value{
width: .15rem;
height: .15rem;
border-radius: .15rem;
background-color: white;
&::before{
display: block;
content: "";
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
border-radius: .15rem;
background-color: #91D5FF;
z-index: 1;
}
&::after{
display: block;
content: "";
width: .09rem;
height: .09rem;
position: absolute;
left: .03rem;
top: .03rem;
border-radius: .09rem;
background-color: white;
z-index: 2;
}
}
> .big-value{
&::after{
display: none;
}
}
}
}
.params-item{
height: .22rem;
float: left;
min-width: .5rem;
background-color: #FAFAFA;
box-sizing: border-box;
border: .01rem solid #D9D9D9;
font-size: .11rem;
color: #000000A6;
margin-right: .04rem;
margin-top: .09rem;
display: flex;
align-items: center;
justify-content: center;
}
.option-box{
padding: 0px;
margin-top: .15rem;
margin-bottom: .5rem;
}
.option-item{
width: 100%;
height: .49rem;
margin-top: .04rem;
box-sizing: border-box;
padding-right: .57rem;
display: flex;
align-items: center;
justify-content: space-between;
> .oper-box{
width: 2rem;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
.oper-icon{
font-size: .26rem;
}
}
> .value-box{
width: calc(100% - 2.5rem);
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
> .oper-box{
width:.7rem;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-left: .2rem;
> .oper-icon{
font-size: .26rem;
}
}
}
}
.btn-box{
width: 100%;
margin: .8rem 0rem;
}
}
.question-box{
box-sizing: border-box;
padding:0rem 1.03rem .57rem .27rem;
.question-content-box{
height: 100%;
box-sizing: border-box;
background-color: #F5FBFF;
padding: .35rem .16rem 0px .1rem;
border: 1px solid #1890FF;
> .title{
width: 100%;
text-align: center;
font-size: .14rem;
}
> .filter-box{
display: flex;
justify-content: center;
align-items: center;
margin-top: .27rem;
> span{
font-size: .14rem;
margin-right: .2rem;
}
}
.page-spare{
margin: .2rem;
.ant-pagination-item-link,.ant-pagination-item{
background: #91D5FF;
border: 1px solid #FFFEFE;
box-sizing: border-box;
border-radius: 2px;
.anticon{
color: white;
}
}
}
}
}
}

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

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