Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

v0.0.4-pre #30

Merged
merged 16 commits into from
May 1, 2020
Merged
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: "386"
Expand All @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: amd64
Expand All @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: arm
Expand All @@ -40,7 +40,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: arm64
Expand All @@ -51,7 +51,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: "386"
Expand All @@ -62,7 +62,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: amd64
Expand All @@ -73,7 +73,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: "386"
Expand All @@ -84,7 +84,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: compile and release
uses: wuhan005/[email protected].2
uses: wuhan005/[email protected].3
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GOARCH: amd64
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[![Build](https://travis-ci.com/vidar-team/Cardinal.svg?branch=master)](https://travis-ci.org/vidar-team/Cardinal)
[![GoReport](https://goreportcard.com/badge/github.com/vidar-team/Cardinal)](https://goreportcard.com/report/github.com/vidar-team/Cardinal)
[![codecov](https://codecov.io/gh/vidar-team/Cardinal/branch/master/graph/badge.svg)](https://codecov.io/gh/vidar-team/Cardinal)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

<!-- ALL-CONTRIBUTORS-BADGE:END -->
## 介绍

Cardinal 是由 Vidar-Team 开发的 AWD 比赛平台,使用 Go 编写。本程序可以作为 CTF 线下比赛平台,亦可用于团队内部 AWD 模拟练习。
Expand Down Expand Up @@ -83,7 +85,13 @@ chmod +x ./Cardinal

十分欢迎您和我们一起改进 Cardinal,您可以改进现有程序,加入新功能,完善文档,优化代码等。

[![Contributors](http://ergatejs.implements.io/badges/contributors/vidar-team/Cardinal_1280_96_10.png)](https://github.com/vidar-team/Cardinal/graphs/contributors)
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

## 协议与许可

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Cardinal
module github.com/vidar-team/Cardinal

go 1.13

Expand Down Expand Up @@ -37,9 +37,11 @@ require (
github.com/theplant/cldr v0.0.0-20190423050709-9f76f7ce4ee8 // indirect
github.com/vidar-team/Cardinal_frontend v0.0.0-20200408105230-89ca4c2e48db
github.com/vidar-team/Cardinal_manager_frontend v0.0.4
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 // indirect
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
golang.org/x/text v0.3.0
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
moul.io/http2curl v1.0.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/nt
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down
46 changes: 24 additions & 22 deletions src/bulletin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/vidar-team/Cardinal/src/locales"
"github.com/vidar-team/Cardinal/src/utils"
"strconv"
)

Expand All @@ -26,7 +28,7 @@ type BulletinRead struct {
func (s *Service) GetAllBulletins() (int, interface{}) {
var bulletins []Bulletin
s.Mysql.Model(&Bulletin{}).Order("`id` DESC").Find(&bulletins)
return s.makeSuccessJSON(bulletins)
return utils.MakeSuccessJSON(bulletins)
}

// NewBulletin is post new bulletin handler for manager.
Expand All @@ -38,8 +40,8 @@ func (s *Service) NewBulletin(c *gin.Context) (int, interface{}) {
var inputForm InputForm
err := c.BindJSON(&inputForm)
if err != nil {
return s.makeErrJSON(400, 40000,
s.I18n.T(c.GetString("lang"), "general.error_payload"),
return utils.MakeErrJSON(400, 40000,
locales.I18n.T(c.GetString("lang"), "general.error_payload"),
)
}

Expand All @@ -49,12 +51,12 @@ func (s *Service) NewBulletin(c *gin.Context) (int, interface{}) {
Content: inputForm.Content,
}).RowsAffected != 1 {
tx.Rollback()
return s.makeErrJSON(500, 50000,
s.I18n.T(c.GetString("lang"), "bulletin.post_error"),
return utils.MakeErrJSON(500, 50000,
locales.I18n.T(c.GetString("lang"), "bulletin.post_error"),
)
}
tx.Commit()
return s.makeSuccessJSON(s.I18n.T(c.GetString("lang"), "bulletin.post_success"))
return utils.MakeSuccessJSON(locales.I18n.T(c.GetString("lang"), "bulletin.post_success"))
}

// EditBulletin is edit new bulletin handler for manager.
Expand All @@ -67,16 +69,16 @@ func (s *Service) EditBulletin(c *gin.Context) (int, interface{}) {
var inputForm InputForm
err := c.BindJSON(&inputForm)
if err != nil {
return s.makeErrJSON(400, 40000,
s.I18n.T(c.GetString("lang"), "general.error_payload"),
return utils.MakeErrJSON(400, 40000,
locales.I18n.T(c.GetString("lang"), "general.error_payload"),
)
}

var checkBulletin Bulletin
s.Mysql.Where(&Bulletin{Model: gorm.Model{ID: inputForm.ID}}).Find(&checkBulletin)
if checkBulletin.ID == 0 {
return s.makeErrJSON(404, 40400,
s.I18n.T(c.GetString("lang"), "bulletin.not_found"),
return utils.MakeErrJSON(404, 40400,
locales.I18n.T(c.GetString("lang"), "bulletin.not_found"),
)
}

Expand All @@ -87,45 +89,45 @@ func (s *Service) EditBulletin(c *gin.Context) (int, interface{}) {
tx := s.Mysql.Begin()
if tx.Model(&Bulletin{}).Where(&Bulletin{Model: gorm.Model{ID: inputForm.ID}}).Updates(&newBulletin).RowsAffected != 1 {
tx.Rollback()
return s.makeErrJSON(500, 50001,
s.I18n.T(c.GetString("lang"), "bulletin.put_error"),
return utils.MakeErrJSON(500, 50001,
locales.I18n.T(c.GetString("lang"), "bulletin.put_error"),
)
}
tx.Commit()

return s.makeSuccessJSON(s.I18n.T(c.GetString("lang"), "bulletin.put_success"))
return utils.MakeSuccessJSON(locales.I18n.T(c.GetString("lang"), "bulletin.put_success"))
}

// DeleteBulletin is delete new bulletin handler for manager.
func (s *Service) DeleteBulletin(c *gin.Context) (int, interface{}) {
idStr, ok := c.GetQuery("id")
if !ok {
return s.makeErrJSON(400, 40000,
s.I18n.T(c.GetString("lang"), "general.error_query"),
return utils.MakeErrJSON(400, 40000,
locales.I18n.T(c.GetString("lang"), "general.error_query"),
)
}
id, err := strconv.Atoi(idStr)
if err != nil {
return s.makeErrJSON(400, 40000,
s.I18n.T(c.GetString("lang"), "general.must_be_number", gin.H{"key": "id"}),
return utils.MakeErrJSON(400, 40000,
locales.I18n.T(c.GetString("lang"), "general.must_be_number", gin.H{"key": "id"}),
)
}

var checkBulletin Bulletin
s.Mysql.Where(&Bulletin{Model: gorm.Model{ID: uint(id)}}).Find(&checkBulletin)
if checkBulletin.ID == 0 {
return s.makeErrJSON(404, 40400,
s.I18n.T(c.GetString("lang"), "bulletin.not_found"),
return utils.MakeErrJSON(404, 40400,
locales.I18n.T(c.GetString("lang"), "bulletin.not_found"),
)
}

tx := s.Mysql.Begin()
if tx.Where("id = ?", id).Delete(&Bulletin{}).RowsAffected != 1 {
tx.Rollback()
return s.makeErrJSON(500, 50002,
s.I18n.T(c.GetString("lang"), "bulletin.delete_error"),
return utils.MakeErrJSON(500, 50002,
locales.I18n.T(c.GetString("lang"), "bulletin.delete_error"),
)
}
tx.Commit()
return s.makeSuccessJSON(s.I18n.T(c.GetString("lang"), "bulletin.delete_success"))
return utils.MakeSuccessJSON(locales.I18n.T(c.GetString("lang"), "bulletin.delete_success"))
}
Loading