Commit cb54c46f by Li Feifei

测试完成

parents
# Default ignored files
/workspace.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ppt_server.iml" filepath="$PROJECT_DIR$/.idea/ppt_server.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
appname = ppt_server
httpport = 8081
runmode = dev
autorender = false
copyrequestbody = true
EnableDocs = true
sqlconn =
\ No newline at end of file
package controllers
import (
"github.com/astaxie/beego"
"ppt_server/models"
"ppt_server/upload"
)
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
type UploadController struct {
beego.Controller
}
func (this *UploadController) newResponse(code int, msg string) {
response := &Response{
Code: code,
}
if msg != "" {
response.Msg = msg
}
this.Data["json"] = response
this.ServeJSON()
}
func (this *UploadController) Post() {
u := models.XyuSmallTempFiles{}
if err := this.ParseForm(&u); err != nil {
//handle error
this.newResponse(100, "参数绑定失败")
return
}
if u.RoomNum == "" || u.Uuid == "" || u.Url == "" || u.Type == 0 {
this.newResponse(100, "参数不正确")
return
}
go upload.Upload(&u)
this.newResponse(200, "成功")
return
//fmt.Println(u)
}
\ No newline at end of file
module ppt_server
go 1.12
require (
github.com/aliyun/aliyun-oss-go-sdk v2.0.6+incompatible
github.com/astaxie/beego v1.12.1
github.com/go-sql-driver/mysql v1.4.1
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
)
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
github.com/aliyun/aliyun-oss-go-sdk v2.0.6+incompatible h1:ZDgadcjGIrbHMBLSqQVHkMOdNd/jF6bsSRJd/Ysxlos=
github.com/aliyun/aliyun-oss-go-sdk v2.0.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/astaxie/beego v1.12.1 h1:dfpuoxpzLVgclveAXe4PyNKqkzgm5zF4tgF2B3kkM2I=
github.com/astaxie/beego v1.12.1/go.mod h1:kPBWpSANNbSdIqOc8SUL9h+1oyBMZhROeYsXQDbidWQ=
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/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/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/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/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/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/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
This diff is collapsed. Click to expand it.
package models
import (
"fmt"
"log"
"ppt_server/utils"
"sync"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
)
var (
user string = utils.ConfigObject.DBuser
pass string = utils.ConfigObject.DBpass
host string = utils.ConfigObject.DBHost
port string = utils.ConfigObject.DBPort
dbname string = utils.ConfigObject.DBname
charset string = utils.ConfigObject.DBcharset
driver string = utils.ConfigObject.Driver
maxFreeConn int = utils.ConfigObject.MaxFreeLink
maxConn int = utils.ConfigObject.MaxLink
prefix string = utils.ConfigObject.DBprefix
)
type XyuRoom struct {
Id int `json:"id"`
RoomNum string `json:"room_num"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
Status int `json:"status"`
TeacherPassword string `json:"teacher_password"`
AssistantPassword string `json:"assistant_password"`
StudentPassword string `json:"student_password"`
HostPassword string `json:"host_password"`
SupervisePassword string `json:"supervise_password"`
IsRecording int
RoomType int `json:"room_type"`
ActualPush int
}
type XyuSmallRoom struct {
Id int
RoomId int
MaxPush int
RoomMode int
AllowMic int
}
type XyuSmallRoomWindow struct {
Id int
RoomNum string `json:"room_num"`
WId int `json:"wndindex"`
EId string `json:"e_id"`
PId string `json:"pid"`
Role string `json:"role"`
UserId string `json:"user_id"`
SetType int `json:"set_type"`
CreateTime string `json:"create_time"`
Status int
}
type XyuRoomUsers struct {
Id int `json:"id"`
Role string `json:"role"`
RoomNum string `json:"room_num"`
Token string `json:"token"`
}
type XyuSmallRoomPeople struct {
Id int
RoomNum string `pk;json:"room_num";`
Teacher int
Assistant int
Student int
Host int
Supervise int
}
type XyuSmallRoomRecord struct {
Id int
RoomNum string
Sessid string
Peerid string
RecordName string
TimeStamp string
}
type XyuSmallTempFiles struct {
Id int
RoomNum string `form:"room_num"`
Type int `form:"type"`
Url string `form:"url"`
Time string `form:"time"'`
Uuid string `form:"uuid"`
Status int
}
type XyuRoomFiles struct {
Id int
RoomId int
Name string
}
var once sync.Once
func init() {
once.Do(func() {
init_mysql()
})
}
func init_mysql() {
dbConfStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s",
user, pass, host, port, dbname, charset)
log.Println("dbconf => ", dbConfStr)
_ = orm.RegisterDriver(driver, orm.DRMySQL)
err := orm.RegisterDataBase("default", driver, dbConfStr, maxFreeConn, maxConn)
if err != nil {
log.Println("db connect error => ", err)
return
}
orm.RegisterModel(new(XyuRoom), new(XyuRoomUsers), new(XyuSmallRoom), new(XyuSmallRoomWindow),
new(XyuSmallRoomPeople), new(XyuSmallRoomRecord), new(XyuSmallTempFiles), new(XyuRoomFiles))
//orm.Debug = true
log.Println("MySQL connect success")
}
File added
// @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 (
"ppt_server/controllers"
"github.com/astaxie/beego"
)
func init() {
beego.Router("/file/upload", &controllers.UploadController{})
}
package utils
const (
ROOM_FIELD = "room_num"
CREATEROOM = "auth-createroom"
JOINROOM = "auth-push"
LEAVEROOM = "auth-unpush"
LEAVEPOD = "auth-podexit"
LEAVEEDGEID = "auth-edgeexit"
RECORDCREATE = "record-create"
TIME_FORMAT = "2006-01-02 15:04:05"
TABLE_XYU_ROOM_USERS = "xyu_room_users"
TABLE_XYU_ROOM = "xyu_room"
TABLE_XYU_SMAIL_ROOM = "xyu_small_room"
TABLE_XYU_SMAIL_ROOM_WINDOW = "xyu_small_room_window"
TABLE_XYU_SMALL_PEOPLE = "xyu_small_room_people"
TABLE_XYU_SMALL_RECORD = "xyu_small_room_record"
TEACHER = "teacher"
ASSISTANT = "assistant"
STUDENT = "student"
HOST = "host"
SUPERVISE = "supervise"
)
package utils
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"time"
)
type RabbitMqConf struct {
Username string
Password string
Host string
Port int
ConfFilePath string
Driver string
DBHost string
DBPort string
DBpass string
DBuser string
DBname string
DBcharset string
DBprefix string
ReconnectionTime time.Duration
MaxFreeLink int
MaxLink int
}
var ConfigObject *RabbitMqConf
func (r *RabbitMqConf) Reload() {
if confFileExists, _ := PathExists(r.ConfFilePath); !confFileExists {
fmt.Println("Config File ", r.ConfFilePath, " is not exist!!")
return
}
data, err := ioutil.ReadFile(r.ConfFilePath)
if err != nil {
panic(err)
}
//将json数据解析到struct中
err = json.Unmarshal(data, r)
if err != nil {
panic(err)
}
}
//判断一个文件是否存在
func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
func init() {
//ConfigObject = &RabbitMqConf{
// Host: os.Getenv("rb_host"),
// Username: os.Getenv("rb_user"),
// Password: os.Getenv("rb_pass"),
// DBHost: os.Getenv("write_sql"),
// DBuser: os.Getenv("write_user"),
// DBpass: os.Getenv("write_pass"),
// Port: 5672,
// ConfFilePath: "conf/rmq.conf",
// ReconnectionTime: 10 * time.Second,
//}
//ConfigObject.Reload()
ConfigObject = &RabbitMqConf{
DBHost: "rm-2zevlk47ul0ovuci80o.mysql.rds.aliyuncs.com",
DBuser: "video",
DBpass: "vlty&AxMwT$lmLv6bN8dkDuBYlh%N5pe",
DBPort: "3306",
DBname: "xyu",
Driver: "mysql",
DBcharset: "utf8",
Username: "admin",
Password: "admin",
Host: "192.168.10.156",
Port: 5672,
ConfFilePath: "conf/rmq.conf",
ReconnectionTime: 1 * time.Second,
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment