Commit 0829c0f2 by zhangjiec

1. 增加部分接口

parent fcc5ecad
......@@ -6,15 +6,25 @@ import (
)
/*********************************************************全国行政区域**/
var provinceMap []District // 省份列表[]District
var cityMap sync.Map // 城市列表map[uint32][]District //省份ID作为KEY
var countyMap sync.Map // 区县列表map[uint32][]District //城市ID作为KEY
type District struct {
var ProvinceMap []DistrictStruct // 省份列表[]District
var CityMap sync.Map // 城市列表map[uint32][]District //省份ID作为KEY
var CountyMap sync.Map // 区县列表map[uint32][]District //城市ID作为KEY
type DistrictStruct struct {
Id uint32 `json:"id" example:"1"`
Name string `json:"name" example:"四川省"`
Initial string `json:"initial" example:"S"`
}
/******************************************************区域(校区)**/
var AreaMap sync.Map //area_id 作为KEY AreaStruct 作为VALUE
type AreaStruct struct { // AreaStruct 区域信息缓存,通过区域ID查出,后续再加支付信息
Name string
Loc []uint32
CountyID uint32
Status uint8 //校区状态 0 不展示 1展示 2测试校区
CreatAt time.Time
}
/*********************************************************代理商**/
//// AgentMap 代理商
//var AgentMap sync.Map
......@@ -45,7 +55,7 @@ type AreaServiceStruct struct { //
var adminMap sync.Map //后台管理用户 LoginAccount(string) 作为KEY
type AdminStruct struct {
Password [16]byte
tokenCreatTime uint32
tokenCreatTime int64
Name string
upAdminID uint32
//Phone string
......@@ -63,24 +73,12 @@ type RoleAuthStruct struct {
MenuRole map[uint32][]uint32 // 菜单、按钮权限
}
/*---------------------------------------------------------------*/
/******************************************************区域(校区)**/
var areaMap sync.Map //area_id 作为KEY AreaStruct 作为VALUE
type AreaStruct struct { // AreaStruct 区域信息缓存,通过区域ID查出,后续再加支付信息
Name string
Loc [2]uint32
CountyID uint32
Status bool //校区状态
}
/*---------------------------------------------------------------*/
/***************************************************微信用户(家长)**/
var wechatCustomerMap sync.Map //微信的WechatUnionID(string)作为KEY
type WechatCustomerStruct struct {
tokenCreatTime uint32
testRole uint8 // 测试用户(可看到测试校区)
wePhone string //
nickname string //微信昵称
masterCardUserID []uint32 //自己创建的学生用户
slaveCardUserID []uint32 //被邀请查看的学生用户
......@@ -93,21 +91,24 @@ var cardUserMap sync.Map //卡用户 CardUserID卡用户ID(uint32) 作为KEY
type CardUserType struct {
MasterWechatUnionID string
SlaveWechatUnionID []string
ShareCode string
Role uint8 //角色0学生,1教师,2职工,default0
AreaID uint32
Name string
Sex uint8
Sex bool //false女 true男
// Birthday
Grade uint8
Class uint8
StudentNo string
Grade uint8
Class uint8
StudentNo string
PhoneAreaServiceID uint32
SimCard uint32
WaterAreaServiceID uint32
WaterCard uint32
LocationAreaServiceID uint32
LocationCard uint32
WaterAreaServiceID uint32
PosAreaServiceID uint32
PosCard uint32
SimCardID string
LocationCardID uint32
IcCardID uint32
}
/*---------------------------------------------------------------*/
......@@ -184,10 +185,13 @@ type CardUserTrendType struct {
/*---------------------------------------------------------------*/
func Init() {
initOperatorMap()
initWechatCustomerMap()
initCardUserMap()
initAreaServiceMap()
initPhone20DeviceMap()
initSimFamilyNumMap()
initBCityMaps() // 初始化行政区域省市区缓存
initAreaMap()
//initOperatorMap()
//initWechatCustomerMap()
//initCardUserMap()
//initAreaServiceMap()
//initPhone20DeviceMap()
//initSimFamilyNumMap()
}
package cache
import (
"dc_golang_server_1/dbmodel"
"fmt"
"log"
"time"
)
func initAreaMap() {
fmt.Println(time.Now(), "cache: initAreaMap begin")
var areaID uint32
var temp AreaStruct
rows, err := dbmodel.PgDb.Query("SELECT id,county_id,name,location,status,create_at FROM b_area") //
defer rows.Close()
if err != nil {
log.Panicln("SelectAreaToMap rows", err)
}
var test2 string
for rows.Next() {
err = rows.Scan(&areaID, &temp.CountyID, &temp.Name, &test2, &temp.Status, &temp.CreatAt) //todo 它娘的location这个POINT取不来,咋个是string哦
if err != nil {
log.Panicln("SelectAreaToMap rows.Scan", err)
}
AreaMap.Store(areaID, temp)
}
// 处理完毕后,需要判断一次遍历过程中是否有错误产生
if err = rows.Err(); err != nil {
log.Panicln(time.Now(), "initAreaMap rows.Err()", err)
}
fmt.Println(time.Now(), "cache: initAreaMap OK")
}
package cache
import (
"dc_golang_server_1/dbmodel"
"dc_golang_server_1/logger"
"fmt"
"go.uber.org/zap"
"log"
"sync"
"time"
)
// 初始化行政区域缓存
//var ProvinceMap []District // 省份列表[]District
//var CityMap sync.Map // 城市列表map[uint32][]District //省份ID作为KEY
//var CountyMap sync.Map // 区县列表map[uint32][]District //城市ID作为KEY
//type DistrictStruct struct {
// Id uint32 `json:"id" example:"1"`
// Name string `json:"name" example:"四川省"`
// Initial string `json:"initial" example:"S"`
//}
func initBCityMaps() {
fmt.Println(time.Now(), "cache: initBCityMaps begin")
go func() bool {
ProvinceMap = []DistrictStruct{} //先清空原来的缓存
var temp DistrictStruct
rows, err := dbmodel.PgDb.Query("SELECT id,name,initial FROM b_city WHERE level=1 ORDER BY sort")
defer rows.Close()
if err != nil {
log.Panicln("ProvinceMap SELECT b_city rows", err)
}
for rows.Next() {
err = rows.Scan(&temp.Id, &temp.Name, &temp.Initial)
if err != nil {
log.Panicln("ProvinceMap SELECT b_city rows.Scan", err)
}
ProvinceMap = append(ProvinceMap, temp)
}
// 处理完毕后,需要判断一次遍历过程中是否有错误产生
if err = rows.Err(); err != nil {
log.Panicln("cache: ProvinceMap rows.Err()", err)
}
return true
}()
selectToDistrictMap(2, &CityMap)
selectToDistrictMap(3, &CountyMap)
fmt.Println(time.Now(), "cache: initBCityMaps OK")
}
func selectToDistrictMap(level uint8, tempMap *sync.Map) bool {
// 清空
tempMap.Range(func(k, _ interface{}) bool {
tempMap.Delete(k)
return true
})
var parentID uint32
var temp DistrictStruct
rows, err := dbmodel.PgDb.Query("SELECT id,name,parent_id,initial FROM b_city WHERE level=$1 ORDER BY sort", level)
defer rows.Close()
if err != nil {
log.Panicln("SELECT b_city rows", err, level)
}
for rows.Next() {
err = rows.Scan(&temp.Id, &temp.Name, &parentID, &temp.Initial)
if err != nil {
log.Panicln("SELECT b_city rows.Scan", err, level)
}
var bufStruct []DistrictStruct
if v, ok := tempMap.Load(parentID); ok { //map已经有了
if bufStruct, ok = v.([]DistrictStruct); ok == false { //类型断言错误
tempMap.Delete(parentID)
logger.Log.Error("[]DistrictStruct 类型断言错误",
zap.Uint8("level", level),
zap.String("src", "selectToDistrictMap"))
}
}
bufStruct = append(bufStruct, temp)
tempMap.Store(parentID, bufStruct)
}
// 处理完毕后,需要判断一次遍历过程中是否有错误产生
if err = rows.Err(); err != nil {
log.Panicln("cache: selectToDistrictMap rows.Err()", err, level)
}
return true
}
package cache
import (
"dc_golang_server_1/dbmodel"
"dc_golang_server_1/logger"
"fmt"
"go.uber.org/zap"
"log"
"time"
)
//id integer NOT NULL DEFAULT nextval('u_card_user_id_seq'::regclass),
//role smallint DEFAULT 0,
//name character varying(16) COLLATE pg_catalog."default",
//sex boolean,
//area_id integer,
//grade smallint,
//class smallint,
//student_num character varying(32) COLLATE pg_catalog."default",
//create_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
//update_at timestamp without time zone
func initCardUserMap() {
fmt.Println(time.Now(), "cache: initCardUserMap begin")
var cardUserID uint32
var temp CardUserType
rows, err := dbmodel.PgDb.Query("SELECT id,role,name,sex,area_id,grade,class,student_num,we_uid,share_code FROM u_card_user") //
defer rows.Close()
if err != nil {
log.Panicln("Select u_card_user To Map rows", err)
}
for rows.Next() {
err = rows.Scan(&cardUserID, &temp.Role, &temp.Name, &temp.Sex, &temp.AreaID, &temp.Grade, &temp.Class, &temp.StudentNo, &temp.MasterWechatUnionID, &temp.ShareCode)
if err != nil {
log.Panicln("SelectAreaToMap rows.Scan", err)
}
AreaMap.Store(cardUserID, temp)
}
// 处理完毕后,需要判断一次遍历过程中是否有错误产生
if err = rows.Err(); err != nil {
log.Panicln(time.Now(), "initCardUserMap rows.Err()", err)
}
// todo 读电话卡绑定信息
fmt.Println(time.Now(), "cache: initCardUserMap OK")
}
func CreatNewCardUser(newUser CardUserType) {
}
......
......@@ -32,7 +32,7 @@ func initPhone20DeviceMap() {
zap.String("src", "initDeviceMap"))
fmt.Println(time.Now(), "initDeviceMap rows.Err()", err)
} else {
fmt.Println(time.Now(), "cache: initDeviceMap end")
fmt.Println(time.Now(), "cache: initDeviceMap OK")
}
}
......
[database]
#阿里云9.9 外网
dbDSN = "user=higher password=hj^&bhjb789j$^* dbname=dctest1 host=pgm-2ze3yp0bss39cxvh1o.pg.rds.aliyuncs.com port=1921 sslmode=disable"
#dbDSN = "user=higher password=hj^&bhjb789j$^* dbname=dctest1 host=pgm-2ze3yp0bss39cxvh1o.pg.rds.aliyuncs.com port=1921 sslmode=disable"
#阿里云9.9 内网 pgm-2ze3yp0bss39cxvh129210.pg.rds.aliyuncs.com
#dbDSN = "user=higher password=hj^&bhjb789j$^* dbname=jeff_study host=pgm-2ze3yp0bss39cxvh129210.pg.rds.aliyuncs.com port=1921 sslmode=disable"
......@@ -10,9 +10,9 @@ dbDSN = "user=higher password=hj^&bhjb789j$^* dbname=dctest1 host=pgm-2ze3yp0bss
#dbDSN = "user=postgres password=buzhidao123 dbname=dctest1 host=to-chengdu-office.168cad.top port=50032 sslmode=disable"
#ECS外网
#DbDSN = "user=postgres password=buzhidao123. dbname=testlog host=60.205.190.129 port=5432 sslmode=disable"
dbDSN = "user=postgres password=buzhidao123. dbname=dcpgdb1 host=60.205.190.129 port=5432 sslmode=disable"
#ECS内网
#DbDSN = "user=postgres password=buzhidao123. dbname=testlog host=127.0.0.1 port=5432 sslmode=disable"
#dbDSN = "user=postgres password=buzhidao123. dbname=testlog host=127.0.0.1 port=5432 sslmode=disable"
[http_server]
#debug release
......
......@@ -33,7 +33,7 @@ var (
LogErrorMaxFileDay int
)
func ConfigInit() {
func Init() {
file, err := ini.Load("./config.ini")
if err != nil {
// logger.Log.Panic("配置文件读取错误")
......
......@@ -21,16 +21,16 @@ import (
// createAt timestamp.Timestamp
//}
func InsertDevHexCommandErr(devId uint32, ciphertext string, errMsg string) {
func InsertDevCommandErr(devId uint32, ciphertext string, errMsg string) {
var err error
for i := 0; i < 10; i++ {
_, err = PgDb.Exec("INSERT INTO d_hex_command_err VALUES($1,$2,$3)", devId, ciphertext, errMsg)
_, err = PgDb.Exec("INSERT INTO d_command_err VALUES($1,$2,$3)", devId, ciphertext, errMsg)
if err == nil {
return
}
fmt.Println("InsertDevHexCommandErr:", i, err)
fmt.Println("InsertDevCommandErr:", i, err)
time.Sleep(3 * time.Second)
}
logger.Log.Error("InsertDevHexCommandErr Err",
logger.Log.Error("InsertDevCommandErr Err",
zap.Error(err))
}
......@@ -28,10 +28,9 @@ type TableDevHexCommandRecord struct {
Ciphertext string
Direction uint8
createAt time.Time
retry uint8 //测试用字段,后面压测完了可以删他妈的
}
func InsertDevHexCommandRecord(insertData TableDevHexCommandRecord) {
func InsertDevCommandRecord(insertData TableDevHexCommandRecord) {
var err error
for i := 0; i < 10; i++ {
// _, err = StmtDevHexRecord.Exec(rData.DevID, rData.TimeUtc, strconv.FormatUint(uint64(rData.CtrlCode), 16), rData.Length, hex.EncodeToString(rData.Data[:rData.Length]), ciphertext, direction)
......@@ -42,14 +41,13 @@ func InsertDevHexCommandRecord(insertData TableDevHexCommandRecord) {
insertData.DataHex,
insertData.Ciphertext,
insertData.Direction,
i,
)
if err == nil {
return
}
fmt.Println("InsertDevHexCommandRecord:", i, err)
fmt.Println("InsertDevCommandRecord:", i, err)
time.Sleep(100 * time.Millisecond)
}
logger.Log.Error("InsertDevHexCommandRecord Error",
logger.Log.Error("InsertDevCommandRecord Error",
zap.Error(err))
}
......@@ -14,16 +14,16 @@ import (
//create_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
//)
// state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
func DevHexConnectRecord(devId uint32, state uint8) {
func DevConnectRecord(devId uint32, state uint8) {
var err error
for i := 0; i < 100; i++ {
_, err = stmtInsertDevHexConnectRecord.Exec(devId, state)
_, err = stmtInsertDevConnectRecord.Exec(devId, state)
if err == nil {
return
}
fmt.Println("DevHexConnectRecord:", i, err)
fmt.Println("DevConnectRecord:", i, err)
time.Sleep(20 * time.Millisecond)
}
logger.Log.Error("DevHexConnectRecord Err",
logger.Log.Error("DevConnectRecord Err",
zap.Error(err))
}
......@@ -27,7 +27,7 @@ type TableDevHexResetRecord struct {
createAt time.Time
}
func InsertDevHexResetRecord(insertData TableDevHexResetRecord) {
func InsertDevResetRecord(insertData TableDevHexResetRecord) {
var err error
for i := 0; i < 100; i++ {
_, err = stmtInsertDevHexCommandRecord.Exec(
......@@ -42,9 +42,9 @@ func InsertDevHexResetRecord(insertData TableDevHexResetRecord) {
if err == nil {
return
}
fmt.Println("InsertDevHexResetRecord:", i, err)
fmt.Println("InsertDevResetRecord:", i, err)
time.Sleep(100 * time.Millisecond)
}
logger.Log.Error("InsertDevHexResetRecord Err",
logger.Log.Error("InsertDevResetRecord Err",
zap.Error(err))
}
......@@ -8,7 +8,7 @@ import (
var PgDb *sql.DB
var stmtInsertDevHexCommandRecord *sql.Stmt
var stmtInsertDevHexConnectRecord *sql.Stmt
var stmtInsertDevConnectRecord *sql.Stmt
var stmtInsertDevHexResetRecord *sql.Stmt
// var stmtInsertUCallRecordAndUpdateUSimInfo *sql.Stmt //用事务处理
......@@ -16,6 +16,7 @@ var stmtInsertUserCardUser *sql.Stmt
func InitDb() {
var err error
// fmt.Println("DBDSN",config.DbDSN)
PgDb, err = sql.Open("postgres", config.DbDSN)
if err != nil {
panic("数据库连接失败" + err.Error())
......@@ -27,31 +28,31 @@ func InitDb() {
//PgDb.Stats()
// 建立常用的预处理
stmtInsertDevHexCommandRecord, err = PgDb.Prepare("INSERT INTO d_command_record VALUES($1,$2,$3,$4,$5,$6,$7,$8)") //("INSERT INTO d_hex_command_record(device_id,ctrl_code,data_len,data_hex,ciphertext)VALUES($1,$2,$3,$4,$5)")
if err != nil {
panic("建立stmtDevHexCommandRecord失败:" + err.Error())
}
stmtInsertDevHexConnectRecord, err = PgDb.Prepare("INSERT INTO d_connect_record VALUES($1,$2)")
if err != nil {
panic("建立stmtDevHexConnectRecord失败:" + err.Error())
}
stmtInsertDevHexResetRecord, err = PgDb.Prepare("INSERT INTO d_reset_record VALUES($1,$2,$3,$4,point($5,$6),$7)")
if err != nil {
panic("建立stmtDevHexConnectRecord失败:" + err.Error())
}
//stmtInsertUserCallRecord, err = PgDb.Prepare("INSERT INTO u_call_record VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)")
//stmtInsertDevHexCommandRecord, err = PgDb.Prepare("INSERT INTO d_command_record VALUES($1,$2,$3,$4,$5,$6,$7,$8)") //("INSERT INTO d_hex_command_record(device_id,ctrl_code,data_len,data_hex,ciphertext)VALUES($1,$2,$3,$4,$5)")
//if err != nil {
// panic("建立stmtUserCallRecord失败:" + err.Error())
// panic("建立stmtDevHexCommandRecord失败:" + err.Error())
//}
//stmtInsertDevConnectRecord, err = PgDb.Prepare("INSERT INTO d_connect_record VALUES($1,$2)")
//if err != nil {
// panic("建立stmtDevHexConnectRecord失败:" + err.Error())
//}
//stmtInsertDevHexResetRecord, err = PgDb.Prepare("INSERT INTO d_reset_record VALUES($1,$2,$3,$4,point($5,$6),$7)")
//if err != nil {
// panic("建立stmtDevHexConnectRecord失败:" + err.Error())
//}
////stmtInsertUserCallRecord, err = PgDb.Prepare("INSERT INTO u_call_record VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)")
////if err != nil {
//// panic("建立stmtUserCallRecord失败:" + err.Error())
////}
//stmtInsertUserCardUser, err = PgDb.Prepare("INSERT INTO u_card_user VALUES($1,$2,$3,$4,$5,$6,$7,$8)")
//if err != nil {
// panic("建立stmtUserCardUser失败:" + err.Error())
//}
stmtInsertUserCardUser, err = PgDb.Prepare("INSERT INTO u_card_user VALUES($1,$2,$3,$4,$5,$6,$7,$8)")
if err != nil {
panic("建立stmtUserCardUser失败:" + err.Error())
}
}
func CloseDb() {
_ = stmtInsertDevHexCommandRecord.Close()
_ = stmtInsertDevHexConnectRecord.Close()
_ = stmtInsertDevConnectRecord.Close()
_ = stmtInsertDevHexResetRecord.Close()
//_ = stmtInsertUCallRecordAndUpdateUSimInfo.Close()
_ = stmtInsertUserCardUser.Close()
......
......@@ -37,7 +37,7 @@ type HexData struct {
}
func /*(d *DCLongTCPHex)*/ insertDevHexCommandRecord(data *HexData, ciphertext string, direction uint8) {
go dbmodel.InsertDevHexCommandRecord(dbmodel.TableDevHexCommandRecord{
go dbmodel.InsertDevCommandRecord(dbmodel.TableDevHexCommandRecord{
DevID: data.DevID,
DevUtc: data.TimeUtc,
CtrlCode: strconv.FormatUint(uint64(data.CtrlCode), 16),
......@@ -52,20 +52,20 @@ func (d *DCLongTCPHex) receiveResponse(conn *net.TCPConn, data []byte, nowConnDe
c, err := util.DecryptBase64ToBytes(data, d.password, d.iv)
if err != nil {
if nowConnDevID != 0 {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "Decrypt err")
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "Decrypt err")
}
return 0
}
if util.CheckCRC(c) == false {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "CheckCRC err")
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "CheckCRC err")
return 0
}
cLen := len(c)
if cLen < 12 {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "cLen<12")
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "cLen<12")
return 0
} else if int(c[9])+12 != cLen {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "cLen!=c[9]+12")
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "cLen!=c[9]+12")
return 0
}
......@@ -75,13 +75,13 @@ func (d *DCLongTCPHex) receiveResponse(conn *net.TCPConn, data []byte, nowConnDe
// 时间有效性判断
nowTimeUtc := uint32(time.Now().Unix())
if nowTimeUtc > rData.TimeUtc+300 || rData.TimeUtc > nowTimeUtc+300 {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "utc err:"+strconv.FormatUint(uint64(rData.TimeUtc), 10))
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "utc err:"+strconv.FormatUint(uint64(rData.TimeUtc), 10))
return 0
}
// 设备类型判断
if c[4] != d.devType {
dbmodel.InsertDevHexCommandErr(nowConnDevID, string(data), "devType error")
dbmodel.InsertDevCommandErr(nowConnDevID, string(data), "devType error")
return 0
}
......@@ -109,7 +109,7 @@ func (d *DCLongTCPHex) receiveResponse(conn *net.TCPConn, data []byte, nowConnDe
// zap.String("SendStr", string(sendStr)),
// zap.String("Conn", conn.RemoteAddr().String()))
//if nowConnDevID == 0 { //刚才没有ID的在这里记
// model.InsertDevHexCommandErr(rData.DevID,string(data),"A error")
// model.InsertDevCommandErr(rData.DevID,string(data),"A error")
//}
return 0
}
......@@ -139,9 +139,9 @@ func (d *DCLongTCPHex) TCPSend(data *HexData) bool {
_ = c.Close()
d.ConnectMap.Delete(data.DevID)
/*if errC != nil {
model.DevHexConnectRecord(data.DevID,false,'W')
model.DevConnectRecord(data.DevID,false,'W')
} else {
model.DevHexConnectRecord(data.DevID,false,'w')
model.DevConnectRecord(data.DevID,false,'w')
}*/
//logger.Log.Debug("conn.Write(sendStr) error", //
// zap.String("Src", "TCP-SERVER-TCPSend"),
......
......@@ -573,7 +573,7 @@ func insertDevHexResetRecord(data *devproduct.HexData) {
d, err := strconv.ParseFloat(strTemp[0], 64)
if err != nil {
logger.Log.Error("Longitude ParseFloat error",
zap.String("Src", "InsertDevHexResetRecord"),
zap.String("Src", "InsertDevResetRecord"),
zap.Uint32("DevID", data.DevID),
zap.Uint8("DataLen", data.Length),
zap.Uint8s("RecvData", data.Data),
......@@ -585,7 +585,7 @@ func insertDevHexResetRecord(data *devproduct.HexData) {
d, err = strconv.ParseFloat(strTemp[1], 64)
if err != nil {
logger.Log.Error("Latitude ParseFloat error",
zap.String("Src", "InsertDevHexResetRecord"),
zap.String("Src", "InsertDevResetRecord"),
zap.Uint32("DevID", data.DevID),
zap.Uint8("DataLen", data.Length),
zap.Uint8s("RecvData", data.Data),
......@@ -595,7 +595,7 @@ func insertDevHexResetRecord(data *devproduct.HexData) {
}
firmwareVersion = strTemp[2] //
}
go dbmodel.InsertDevHexResetRecord(dbmodel.TableDevHexResetRecord{
go dbmodel.InsertDevResetRecord(dbmodel.TableDevHexResetRecord{
DevId: data.DevID,
DevUtc: data.TimeUtc,
ResetReason: resetReason,
......
......@@ -93,7 +93,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
if co, ok := connMyID.(*net.TCPConn); ok { // 类型断言
if co == conn {
s.ConnectMap.Delete(myDevID)
dbmodel.DevHexConnectRecord(myDevID, 1) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
dbmodel.DevConnectRecord(myDevID, 1) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
//logger.Log.Debug("device offline",
// zap.String("Src", "TCP-SERVER-connectionHandle"),
// zap.Uint32("DevID", myDevID),
......@@ -101,7 +101,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
// zap.String("State", "offline"))
} else {
// s.ConnectMap.Delete(myDevID) 这里人家存了新的,不能去删了噻
dbmodel.DevHexConnectRecord(myDevID, 3) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
dbmodel.DevConnectRecord(myDevID, 3) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
//logger.Log.Debug("have a new link,close old link",
// zap.String("Src", "TCP-SERVER-connectionHandle"),
// zap.Uint32("DevID", myDevID),
......@@ -115,7 +115,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
// zap.Uint32("DevID", myDevID),
// zap.String("Conn", conn.RemoteAddr().String()),
// zap.String("State", "offline")) // 类型断言失败
dbmodel.DevHexConnectRecord(myDevID, 4) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
dbmodel.DevConnectRecord(myDevID, 4) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
}
} else {
//logger.Log.Debug("map no have myDevID",
......@@ -123,7 +123,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
// zap.Uint32("DevID", myDevID),
// zap.String("Conn", conn.RemoteAddr().String()),
// zap.String("State", "offline"))
dbmodel.DevHexConnectRecord(myDevID, 2) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
dbmodel.DevConnectRecord(myDevID, 2) // state 0:新连接来了 1:设备正常离线 2:正常离线 3:新连接挤掉就连接 4:未知异常(连接池类型断言失败)
}
}
......@@ -221,7 +221,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
}*/
}
// logger 新链接来的合法设备
dbmodel.DevHexConnectRecord(newID, 0)
dbmodel.DevConnectRecord(newID, 0)
//logger.Log.Debug("a new link is coming",
// zap.String("Src", "TCP-SERVER-connectionHandle"),
// zap.Uint32("DevID", newID),
......
......@@ -45,12 +45,12 @@ var doc = `{
}
],
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
......@@ -79,12 +79,90 @@ var doc = `{
}
],
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
}
}
},
"/base/countyarea/{countyID}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据区县ID获取学校列表",
"tags": [
"公用接口"
],
"summary": "根据区县ID获取学校列表",
"parameters": [
{
"type": "integer",
"default": 2725,
"description": "区县id",
"name": "countyID",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "排序好的学校列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.countyAreaRes"
}
}
}
}
}
},
"/base/locarea": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据经纬度获取附近20所学校列表",
"tags": [
"公用接口"
],
"summary": "根据经纬度获取附近20所学校列表",
"parameters": [
{
"type": "integer",
"default": 103000000,
"description": "经度*1000000",
"name": "longitude",
"in": "query",
"required": true
},
{
"type": "integer",
"default": 30000000,
"description": "纬度*1000000",
"name": "latitude",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": "排序好的学校列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.locationAreaRes"
}
}
}
......@@ -104,18 +182,414 @@ var doc = `{
],
"summary": "获取全国省份列表",
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
}
}
},
"/we/bindcarduser/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "获取学生副家长列表及邀请码内容(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "副家长信息列表及邀请码",
"schema": {
"$ref": "#/definitions/v1.getBindCardUserRes"
}
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "副家长解绑学生",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/bindcarduser/{share_code}": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生的邀请码,后台返回学生信息",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "副家长绑定学生",
"parameters": [
{
"type": "string",
"description": "学生的邀请码",
"name": "share_code",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "学生信息",
"schema": {
"$ref": "#/definitions/v1.bindCardUserRes"
}
}
}
}
},
"/we/cardbind/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型、卡号至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "绑定卡",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "卡号",
"name": "code",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "解绑卡",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardloss/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "卡挂失/解挂",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "true挂失,false解挂",
"name": "loss",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/carduser": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传新建学生信息至后台,后台返回学生id,以及对应校区的service",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "创建一个学生",
"parameters": [
{
"description": "学生信息",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.weCreateCardUserReq"
}
}
],
"responses": {
"0": {
"description": "",
"schema": {
"$ref": "#/definitions/v1.creatCardUserRes"
}
}
}
}
},
"/we/carduser/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及新信息至后台,后台返回成功失败",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "修改学生信息",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "学生信息",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.PutCardUserReq"
}
}
],
"responses": {
"0": {
"description": ""
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "主家长删除一个学生",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardusershareoff/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "关闭邀请码开关(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardusershareon/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "打开邀请码开关(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/login/{code}": {
"post": {
"description": "微信code传至后台,后台返回token,token有效时长:24小时",
......@@ -133,15 +607,87 @@ var doc = `{
}
],
"responses": {
"200": {
"description": "{\"code\": 200, \"token\": string}",
"0": {
"description": "",
"schema": {
"type": "string"
"$ref": "#/definitions/v1.weLoginRes"
}
}
}
}
},
"/we/phonecardstatus/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回卡信息",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "获取学生公话卡状态",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "公话卡状态信息",
"schema": {
"$ref": "#/definitions/v1.getPhoneCardStatusRes"
}
}
}
}
},
"/we/slaveweuser/{id}": {
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID和微信UnionID,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "删除副家长(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "副家长微信UnionID",
"name": "unionid",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/trend/:id": {
"get": {
"description": "微信学生首页,获取近20条用户最新动态",
......@@ -170,7 +716,7 @@ var doc = `{
}
},
"definitions": {
"cache.District": {
"cache.DistrictStruct": {
"type": "object",
"properties": {
"id": {
......@@ -186,12 +732,370 @@ var doc = `{
"example": "四川省"
}
}
},
"v1.PutCardUserReq": {
"type": "object",
"properties": {
"class": {
"description": "选填,班级,number",
"type": "integer"
},
"grade": {
"description": "必填,\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"name": {
"description": "必填,学生名字,maxLen=16",
"type": "string",
"example": "汤圆"
},
"sex": {
"description": "选填,0女1男",
"type": "integer"
},
"stuNum": {
"description": "选填,学号,字符串,maxLen=32",
"type": "string"
}
}
},
"v1.bindCardUserRes": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
}
}
},
"v1.countyAreaRes": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "海科学校"
}
}
},
"v1.creatCardUserRes": {
"type": "object",
"properties": {
"id": {
"description": "新创建的学生ID",
"type": "integer"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
}
}
},
"v1.getBindCardUserRes": {
"type": "object",
"properties": {
"shareCode": {
"description": "学生的邀请码,长度固定16,若为空,则表示邀请码开关关闭",
"type": "string"
},
"weUser": {
"description": "副家长微信信息列表",
"type": "array",
"items": {
"$ref": "#/definitions/v1.slaveWeUserRes"
}
}
}
},
"v1.getPhoneCardStatusRes": {
"type": "object",
"properties": {
"changeable": {
"description": "本月可修改亲情号次数",
"type": "integer"
},
"expiryAt": {
"description": "到期时间",
"type": "string"
},
"family": {
"description": "亲情号列表",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"phone": {
"type": "string"
}
}
}
},
"monthMin": {
"description": "月套餐使用分钟数",
"type": "integer"
},
"monthPack": {
"description": "月套餐分钟数",
"type": "integer"
},
"simID": {
"description": "卡号",
"type": "string"
},
"status": {
"description": "状态 0未绑定卡 1 正常使用 2 服务已到期 3 已挂失",
"type": "integer"
}
}
},
"v1.locationAreaRes": {
"type": "object",
"properties": {
"district": {
"type": "string",
"example": "四川省成都市温江区"
},
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "海科学校"
}
}
},
"v1.slaveWeUserRes": {
"type": "object",
"properties": {
"avatarURL": {
"description": "头像URL",
"type": "string"
},
"createAt": {
"description": "绑定时间",
"type": "string"
},
"nickname": {
"description": "微信昵称",
"type": "string"
},
"unionID": {
"description": "微信UnionID",
"type": "string"
}
}
},
"v1.weCreateCardUserReq": {
"type": "object",
"properties": {
"areaID": {
"description": "必填,校区ID",
"type": "integer",
"example": 1
},
"class": {
"description": "选填,班级,number",
"type": "integer"
},
"grade": {
"description": "必填,\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"name": {
"description": "必填,学生名字,maxLen=16",
"type": "string",
"example": "汤圆"
},
"sex": {
"description": "选填,0女1男",
"type": "integer"
},
"stuNum": {
"description": "选填,学号,字符串,maxLen=32",
"type": "string"
}
}
},
"v1.weLoginRes": {
"type": "object",
"properties": {
"master": {
"description": "自己创建的学生列表(主家长)",
"type": "array",
"items": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
},
"topUp": {
"description": "是否已充值(已充值则不能删除,未充值可以删除)",
"type": "boolean"
}
}
}
},
"slave": {
"description": "添加的学生列表(副家长)",
"type": "array",
"items": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
}
}
}
},
"token": {
"type": "string"
},
"weInfo": {
"description": "是否已获取到微信用户信息",
"type": "boolean"
},
"wePhone": {
"description": "是否已获取到微信电话",
"type": "boolean"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"name": "token",
"in": "header"
}
}
......
......@@ -30,12 +30,12 @@
}
],
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
......@@ -64,12 +64,90 @@
}
],
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
}
}
},
"/base/countyarea/{countyID}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据区县ID获取学校列表",
"tags": [
"公用接口"
],
"summary": "根据区县ID获取学校列表",
"parameters": [
{
"type": "integer",
"default": 2725,
"description": "区县id",
"name": "countyID",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "排序好的学校列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.countyAreaRes"
}
}
}
}
}
},
"/base/locarea": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据经纬度获取附近20所学校列表",
"tags": [
"公用接口"
],
"summary": "根据经纬度获取附近20所学校列表",
"parameters": [
{
"type": "integer",
"default": 103000000,
"description": "经度*1000000",
"name": "longitude",
"in": "query",
"required": true
},
{
"type": "integer",
"default": 30000000,
"description": "纬度*1000000",
"name": "latitude",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": "排序好的学校列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.locationAreaRes"
}
}
}
......@@ -89,18 +167,414 @@
],
"summary": "获取全国省份列表",
"responses": {
"200": {
"0": {
"description": "按首字母排序好的列表,可直接用作展示",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/cache.District"
"$ref": "#/definitions/cache.DistrictStruct"
}
}
}
}
}
},
"/we/bindcarduser/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "获取学生副家长列表及邀请码内容(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "副家长信息列表及邀请码",
"schema": {
"$ref": "#/definitions/v1.getBindCardUserRes"
}
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "副家长解绑学生",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/bindcarduser/{share_code}": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生的邀请码,后台返回学生信息",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "副家长绑定学生",
"parameters": [
{
"type": "string",
"description": "学生的邀请码",
"name": "share_code",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "学生信息",
"schema": {
"$ref": "#/definitions/v1.bindCardUserRes"
}
}
}
}
},
"/we/cardbind/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型、卡号至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "绑定卡",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "卡号",
"name": "code",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "解绑卡",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardloss/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及卡类型至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "卡挂失/解挂",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "true挂失,false解挂",
"name": "loss",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)",
"name": "type",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/carduser": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传新建学生信息至后台,后台返回学生id,以及对应校区的service",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "创建一个学生",
"parameters": [
{
"description": "学生信息",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.weCreateCardUserReq"
}
}
],
"responses": {
"0": {
"description": "",
"schema": {
"$ref": "#/definitions/v1.creatCardUserRes"
}
}
}
}
},
"/we/carduser/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生id及新信息至后台,后台返回成功失败",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "修改学生信息",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "学生信息",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.PutCardUserReq"
}
}
],
"responses": {
"0": {
"description": ""
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "主家长删除一个学生",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardusershareoff/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "关闭邀请码开关(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/cardusershareon/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "打开邀请码开关(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/login/{code}": {
"post": {
"description": "微信code传至后台,后台返回token,token有效时长:24小时",
......@@ -118,15 +592,87 @@
}
],
"responses": {
"200": {
"description": "{\"code\": 200, \"token\": string}",
"0": {
"description": "",
"schema": {
"type": "string"
"$ref": "#/definitions/v1.weLoginRes"
}
}
}
}
},
"/we/phonecardstatus/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID至后台,后台返回卡信息",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "获取学生公话卡状态",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "公话卡状态信息",
"schema": {
"$ref": "#/definitions/v1.getPhoneCardStatusRes"
}
}
}
}
},
"/we/slaveweuser/{id}": {
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "传学生ID和微信UnionID,后台返回成功失败",
"produces": [
"application/json"
],
"tags": [
"家长微信"
],
"summary": "删除副家长(仅主家长有权限)",
"parameters": [
{
"type": "integer",
"description": "学生ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "副家长微信UnionID",
"name": "unionid",
"in": "query",
"required": true
}
],
"responses": {
"0": {
"description": ""
}
}
}
},
"/we/trend/:id": {
"get": {
"description": "微信学生首页,获取近20条用户最新动态",
......@@ -155,7 +701,7 @@
}
},
"definitions": {
"cache.District": {
"cache.DistrictStruct": {
"type": "object",
"properties": {
"id": {
......@@ -171,12 +717,370 @@
"example": "四川省"
}
}
},
"v1.PutCardUserReq": {
"type": "object",
"properties": {
"class": {
"description": "选填,班级,number",
"type": "integer"
},
"grade": {
"description": "必填,\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"name": {
"description": "必填,学生名字,maxLen=16",
"type": "string",
"example": "汤圆"
},
"sex": {
"description": "选填,0女1男",
"type": "integer"
},
"stuNum": {
"description": "选填,学号,字符串,maxLen=32",
"type": "string"
}
}
},
"v1.bindCardUserRes": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
}
}
},
"v1.countyAreaRes": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "海科学校"
}
}
},
"v1.creatCardUserRes": {
"type": "object",
"properties": {
"id": {
"description": "新创建的学生ID",
"type": "integer"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
}
}
},
"v1.getBindCardUserRes": {
"type": "object",
"properties": {
"shareCode": {
"description": "学生的邀请码,长度固定16,若为空,则表示邀请码开关关闭",
"type": "string"
},
"weUser": {
"description": "副家长微信信息列表",
"type": "array",
"items": {
"$ref": "#/definitions/v1.slaveWeUserRes"
}
}
}
},
"v1.getPhoneCardStatusRes": {
"type": "object",
"properties": {
"changeable": {
"description": "本月可修改亲情号次数",
"type": "integer"
},
"expiryAt": {
"description": "到期时间",
"type": "string"
},
"family": {
"description": "亲情号列表",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"phone": {
"type": "string"
}
}
}
},
"monthMin": {
"description": "月套餐使用分钟数",
"type": "integer"
},
"monthPack": {
"description": "月套餐分钟数",
"type": "integer"
},
"simID": {
"description": "卡号",
"type": "string"
},
"status": {
"description": "状态 0未绑定卡 1 正常使用 2 服务已到期 3 已挂失",
"type": "integer"
}
}
},
"v1.locationAreaRes": {
"type": "object",
"properties": {
"district": {
"type": "string",
"example": "四川省成都市温江区"
},
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "海科学校"
}
}
},
"v1.slaveWeUserRes": {
"type": "object",
"properties": {
"avatarURL": {
"description": "头像URL",
"type": "string"
},
"createAt": {
"description": "绑定时间",
"type": "string"
},
"nickname": {
"description": "微信昵称",
"type": "string"
},
"unionID": {
"description": "微信UnionID",
"type": "string"
}
}
},
"v1.weCreateCardUserReq": {
"type": "object",
"properties": {
"areaID": {
"description": "必填,校区ID",
"type": "integer",
"example": 1
},
"class": {
"description": "选填,班级,number",
"type": "integer"
},
"grade": {
"description": "必填,\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"name": {
"description": "必填,学生名字,maxLen=16",
"type": "string",
"example": "汤圆"
},
"sex": {
"description": "选填,0女1男",
"type": "integer"
},
"stuNum": {
"description": "选填,学号,字符串,maxLen=32",
"type": "string"
}
}
},
"v1.weLoginRes": {
"type": "object",
"properties": {
"master": {
"description": "自己创建的学生列表(主家长)",
"type": "array",
"items": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
},
"topUp": {
"description": "是否已充值(已充值则不能删除,未充值可以删除)",
"type": "boolean"
}
}
}
},
"slave": {
"description": "添加的学生列表(副家长)",
"type": "array",
"items": {
"type": "object",
"properties": {
"area": {
"description": "区域名字",
"type": "string",
"example": "四川省成都市温江区实验中学"
},
"class": {
"type": "integer"
},
"grade": {
"description": "\"1~9对应一年级~九年级,10~12对应高一~高三\"",
"type": "integer"
},
"id": {
"description": "学生ID",
"type": "integer"
},
"name": {
"type": "string"
},
"service": {
"description": "对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)",
"type": "array",
"items": {
"type": "integer"
},
"example": [
1,
2,
2,
0,
0,
0
]
},
"sex": {
"description": "0女 1男",
"type": "integer"
},
"stuNum": {
"type": "string"
}
}
}
},
"token": {
"type": "string"
},
"weInfo": {
"description": "是否已获取到微信用户信息",
"type": "boolean"
},
"wePhone": {
"description": "是否已获取到微信电话",
"type": "boolean"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"name": "token",
"in": "header"
}
}
......
basePath: /
definitions:
cache.District:
cache.DistrictStruct:
properties:
id:
example: 1
......@@ -12,6 +12,266 @@ definitions:
example: 四川省
type: string
type: object
v1.PutCardUserReq:
properties:
class:
description: 选填,班级,number
type: integer
grade:
description: 必填,"1~9对应一年级~九年级,10~12对应高一~高三"
type: integer
name:
description: 必填,学生名字,maxLen=16
example: 汤圆
type: string
sex:
description: 选填,0女1男
type: integer
stuNum:
description: 选填,学号,字符串,maxLen=32
type: string
type: object
v1.bindCardUserRes:
properties:
area:
description: 区域名字
example: 四川省成都市温江区实验中学
type: string
class:
type: integer
grade:
description: '"1~9对应一年级~九年级,10~12对应高一~高三"'
type: integer
id:
description: 学生ID
type: integer
name:
type: string
service:
description: 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
example:
- 1
- 2
- 2
- 0
- 0
- 0
items:
type: integer
type: array
sex:
description: 0女 1男
type: integer
stuNum:
type: string
type: object
v1.countyAreaRes:
properties:
id:
example: 1
type: integer
name:
example: 海科学校
type: string
type: object
v1.creatCardUserRes:
properties:
id:
description: 新创建的学生ID
type: integer
service:
description: 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
example:
- 1
- 2
- 2
- 0
- 0
- 0
items:
type: integer
type: array
type: object
v1.getBindCardUserRes:
properties:
shareCode:
description: 学生的邀请码,长度固定16,若为空,则表示邀请码开关关闭
type: string
weUser:
description: 副家长微信信息列表
items:
$ref: '#/definitions/v1.slaveWeUserRes'
type: array
type: object
v1.getPhoneCardStatusRes:
properties:
changeable:
description: 本月可修改亲情号次数
type: integer
expiryAt:
description: 到期时间
type: string
family:
description: 亲情号列表
items:
properties:
name:
type: string
phone:
type: string
type: object
type: array
monthMin:
description: 月套餐使用分钟数
type: integer
monthPack:
description: 月套餐分钟数
type: integer
simID:
description: 卡号
type: string
status:
description: 状态 0未绑定卡 1 正常使用 2 服务已到期 3 已挂失
type: integer
type: object
v1.locationAreaRes:
properties:
district:
example: 四川省成都市温江区
type: string
id:
example: 1
type: integer
name:
example: 海科学校
type: string
type: object
v1.slaveWeUserRes:
properties:
avatarURL:
description: 头像URL
type: string
createAt:
description: 绑定时间
type: string
nickname:
description: 微信昵称
type: string
unionID:
description: 微信UnionID
type: string
type: object
v1.weCreateCardUserReq:
properties:
areaID:
description: 必填,校区ID
example: 1
type: integer
class:
description: 选填,班级,number
type: integer
grade:
description: 必填,"1~9对应一年级~九年级,10~12对应高一~高三"
type: integer
name:
description: 必填,学生名字,maxLen=16
example: 汤圆
type: string
sex:
description: 选填,0女1男
type: integer
stuNum:
description: 选填,学号,字符串,maxLen=32
type: string
type: object
v1.weLoginRes:
properties:
master:
description: 自己创建的学生列表(主家长)
items:
properties:
area:
description: 区域名字
example: 四川省成都市温江区实验中学
type: string
class:
type: integer
grade:
description: '"1~9对应一年级~九年级,10~12对应高一~高三"'
type: integer
id:
description: 学生ID
type: integer
name:
type: string
service:
description: 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
example:
- 1
- 2
- 2
- 0
- 0
- 0
items:
type: integer
type: array
sex:
description: 0女 1男
type: integer
stuNum:
type: string
topUp:
description: 是否已充值(已充值则不能删除,未充值可以删除)
type: boolean
type: object
type: array
slave:
description: 添加的学生列表(副家长)
items:
properties:
area:
description: 区域名字
example: 四川省成都市温江区实验中学
type: string
class:
type: integer
grade:
description: '"1~9对应一年级~九年级,10~12对应高一~高三"'
type: integer
id:
description: 学生ID
type: integer
name:
type: string
service:
description: 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
example:
- 1
- 2
- 2
- 0
- 0
- 0
items:
type: integer
type: array
sex:
description: 0女 1男
type: integer
stuNum:
type: string
type: object
type: array
token:
type: string
weInfo:
description: 是否已获取到微信用户信息
type: boolean
wePhone:
description: 是否已获取到微信电话
type: boolean
type: object
info:
contact: {}
description: 用于家长端微信小程序及web端管理后台
......@@ -28,11 +288,11 @@ paths:
required: true
type: integer
responses:
"200":
"0":
description: 按首字母排序好的列表,可直接用作展示
schema:
items:
$ref: '#/definitions/cache.District'
$ref: '#/definitions/cache.DistrictStruct'
type: array
security:
- ApiKeyAuth: []
......@@ -49,32 +309,330 @@ paths:
required: true
type: integer
responses:
"200":
"0":
description: 按首字母排序好的列表,可直接用作展示
schema:
items:
$ref: '#/definitions/cache.District'
$ref: '#/definitions/cache.DistrictStruct'
type: array
security:
- ApiKeyAuth: []
summary: 通过城市ID获取区县列表
tags:
- 公用接口
/base/countyarea/{countyID}:
get:
description: 根据区县ID获取学校列表
parameters:
- default: 2725
description: 区县id
in: path
name: countyID
required: true
type: integer
responses:
"0":
description: 排序好的学校列表,可直接用作展示
schema:
items:
$ref: '#/definitions/v1.countyAreaRes'
type: array
security:
- ApiKeyAuth: []
summary: 根据区县ID获取学校列表
tags:
- 公用接口
/base/locarea:
get:
description: 根据经纬度获取附近20所学校列表
parameters:
- default: 103000000
description: 经度*1000000
in: query
name: longitude
required: true
type: integer
- default: 30000000
description: 纬度*1000000
in: query
name: latitude
required: true
type: integer
responses:
"0":
description: 排序好的学校列表,可直接用作展示
schema:
items:
$ref: '#/definitions/v1.locationAreaRes'
type: array
security:
- ApiKeyAuth: []
summary: 根据经纬度获取附近20所学校列表
tags:
- 公用接口
/base/province:
get:
description: 获取带首字母的省份列表
responses:
"200":
"0":
description: 按首字母排序好的列表,可直接用作展示
schema:
items:
$ref: '#/definitions/cache.District'
$ref: '#/definitions/cache.DistrictStruct'
type: array
security:
- ApiKeyAuth: []
summary: 获取全国省份列表
tags:
- 公用接口
/we/bindcarduser/{id}:
delete:
description: 传学生ID至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 副家长解绑学生
tags:
- 家长微信
get:
description: 传学生ID至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: 副家长信息列表及邀请码
schema:
$ref: '#/definitions/v1.getBindCardUserRes'
security:
- ApiKeyAuth: []
summary: 获取学生副家长列表及邀请码内容(仅主家长有权限)
tags:
- 家长微信
/we/bindcarduser/{share_code}:
post:
description: 传学生的邀请码,后台返回学生信息
parameters:
- description: 学生的邀请码
in: path
name: share_code
required: true
type: string
produces:
- application/json
responses:
"0":
description: 学生信息
schema:
$ref: '#/definitions/v1.bindCardUserRes'
security:
- ApiKeyAuth: []
summary: 副家长绑定学生
tags:
- 家长微信
/we/cardbind/{id}:
delete:
description: 传学生id及卡类型至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
- description: 卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)
in: query
name: type
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 解绑卡
tags:
- 家长微信
put:
description: 传学生id及卡类型、卡号至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
- description: 卡号
in: query
name: code
required: true
type: string
- description: 卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)
in: query
name: type
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 绑定卡
tags:
- 家长微信
/we/cardloss/{id}:
put:
description: 传学生id及卡类型至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
- description: true挂失,false解挂
in: query
name: loss
required: true
type: boolean
- description: 卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)
in: query
name: type
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 卡挂失/解挂
tags:
- 家长微信
/we/carduser:
post:
consumes:
- application/json
description: 传新建学生信息至后台,后台返回学生id,以及对应校区的service
parameters:
- description: 学生信息
in: body
name: data
required: true
schema:
$ref: '#/definitions/v1.weCreateCardUserReq'
produces:
- application/json
responses:
"0":
description: ""
schema:
$ref: '#/definitions/v1.creatCardUserRes'
security:
- ApiKeyAuth: []
summary: 创建一个学生
tags:
- 家长微信
/we/carduser/{id}:
delete:
description: 传学生ID至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 主家长删除一个学生
tags:
- 家长微信
put:
consumes:
- application/json
description: 传学生id及新信息至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
- description: 学生信息
in: body
name: data
required: true
schema:
$ref: '#/definitions/v1.PutCardUserReq'
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 修改学生信息
tags:
- 家长微信
/we/cardusershareoff/{id}:
put:
description: 传学生ID至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 关闭邀请码开关(仅主家长有权限)
tags:
- 家长微信
/we/cardusershareon/{id}:
put:
description: 传学生ID至后台,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 打开邀请码开关(仅主家长有权限)
tags:
- 家长微信
/we/login/{code}:
post:
description: 微信code传至后台,后台返回token,token有效时长:24小时
......@@ -85,13 +643,58 @@ paths:
required: true
type: string
responses:
"200":
description: '{"code": 200, "token": string}'
"0":
description: ""
schema:
type: string
$ref: '#/definitions/v1.weLoginRes'
summary: 登录
tags:
- 家长微信
/we/phonecardstatus/{id}:
get:
description: 传学生ID至后台,后台返回卡信息
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"0":
description: 公话卡状态信息
schema:
$ref: '#/definitions/v1.getPhoneCardStatusRes'
security:
- ApiKeyAuth: []
summary: 获取学生公话卡状态
tags:
- 家长微信
/we/slaveweuser/{id}:
delete:
description: 传学生ID和微信UnionID,后台返回成功失败
parameters:
- description: 学生ID
in: path
name: id
required: true
type: integer
- description: 副家长微信UnionID
in: query
name: unionid
required: true
type: string
produces:
- application/json
responses:
"0":
description: ""
security:
- ApiKeyAuth: []
summary: 删除副家长(仅主家长有权限)
tags:
- 家长微信
/we/trend/:id:
get:
description: 微信学生首页,获取近20条用户最新动态
......@@ -112,6 +715,6 @@ paths:
securityDefinitions:
ApiKeyAuth:
in: header
name: Authorization
name: token
type: apiKey
swagger: "2.0"
{"level":"WARN","ts":"2021-10-07 16:08:55.565","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"GET","Path":"/swagger/","DataSize":18,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
{"level":"WARN","ts":"2021-10-07 16:09:16.983","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"GET","Path":"/favicon.ico","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
{"level":"WARN","ts":"2021-10-09 14:42:58.848","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"GET","Path":"/","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3875.400 QQBrowser/10.8.4492.400"}
{"level":"WARN","ts":"2021-10-09 14:42:59.535","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"GET","Path":"/favicon.ico","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3875.400 QQBrowser/10.8.4492.400"}
{"level":"WARN","ts":"2021-10-10 00:17:49.872","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"GET","Path":"/","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3875.400 QQBrowser/10.8.4492.400"}
{"level":"WARN","ts":"2021-10-13 15:03:27.882","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"DELETE","Path":"/we/carduser","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
{"level":"WARN","ts":"2021-10-13 15:03:35.683","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"DELETE","Path":"/we/carduser","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
{"level":"WARN","ts":"2021-10-13 16:18:48.126","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"POST","Path":"/we/bindcarduser","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
{"level":"WARN","ts":"2021-10-13 16:18:55.598","msg":"","HostName":"DESKTOP-2789F62","Status":404,"SpendNanoS":0,"Ip":"127.0.0.1","Method":"POST","Path":"/we/bindcarduser","DataSize":0,"Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"}
......@@ -12,7 +12,7 @@ import (
var Log *zap.Logger
func InitLogger() {
func Init() {
config := zapcore.EncoderConfig{
MessageKey: "msg", //结构化(json)输出:msg的key
LevelKey: "level", //结构化(json)输出:日志级别的key(INFO,WARN,ERROR等)
......
package main
import (
"dc_golang_server_1/cache"
"dc_golang_server_1/config"
"dc_golang_server_1/dbmodel"
"dc_golang_server_1/devproduct/dcphone20"
"dc_golang_server_1/logger"
"dc_golang_server_1/web"
......@@ -10,41 +12,24 @@ import (
"time"
)
//func init() {
//
//}
func initConfigAndLogger() {
config.ConfigInit()
logger.InitLogger()
//突然发现这种方式瓜眉日眼的,以后不用了,直接在shell脚本里面重定向输出文件
//f, err := os.OpenFile(config.LogPath+"panic.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0755)
//if err != nil {
// logger.Log.Panic(err.Error())
//}
//redirectStderrWindows(f)
//redirectStderrLinux(f)
}
// @title 多彩中小学一卡通系统
// @version V0.0.1
// @Description 用于家长端微信小程序及web端管理后台
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @name token
// @BasePath /
func main() { //
fmt.Println(time.Now(), "system init")
runtime.GOMAXPROCS(runtime.NumCPU())
initConfigAndLogger()
config.Init()
logger.Init()
dbmodel.InitDb()
defer dbmodel.CloseDb()
//dbmodel.InitDb()
//defer dbmodel.CloseDb()
//
//cache.Init()
cache.Init()
dcphone20.NewDCPhone20()
//dcdrinking60.NewDCDrinking60()
......
......@@ -29,15 +29,41 @@ func InitRouter() { //*gin.Engine{
// base.Use(CheckToken())
{
base.GET("province", v1.GetProvinceList)
base.GET("city/:provinceID", v1.GetCityList)
base.GET("county/:cityID", v1.GetCountyList)
base.GET("city/:id", v1.GetCityList)
base.GET("county/:id", v1.GetCountyList)
base.GET("locarea", v1.GetAreaByLocation)
base.GET("countyarea/:id", v1.GetAreaByCounty)
}
r.POST("we/login/:code", v1.WeLogin)
wechat := r.Group("we/")
// wechat.Use(CheckToken())
{ // 需要token的
wechat.GET("trend/:id", v1.GetCardUsersTrend)
wechat.POST("carduser", v1.CreateCardUser) //创建学生
wechat.DELETE("carduser/:id", v1.DeleteCardUser) //删除学生
wechat.POST("bindcarduser/:share_code", v1.BindCardUser) //副家长绑定学生
wechat.DELETE("bindcarduser/:id", v1.DeleteBindCardUser) //副家长解绑学生
wechat.GET("trend/:id", v1.GetCardUsersTrend) //获取学生最新动态
wechat.GET("bindcarduser/:id", v1.GetBindCardUser) //获取学生副家长列表及邀请码内容(仅主家长有权限)
wechat.PUT("cardusershareon/:id", v1.PutCardUserShareOn) //打开邀请码开关(仅主家长有权限)
wechat.PUT("cardusershareoff/:id", v1.PutCardUserShareOff) //关闭邀请码开关(仅主家长有权限)
wechat.DELETE("slaveweuser", v1.DeleteSlaveWeUser) //删除副家长(仅主家长有权限)
wechat.PUT("carduser/:id", v1.PutCardUser) //修改学生信息
wechat.PUT("cardloss/:id", v1.CardLoss) //卡挂失/解挂
wechat.PUT("cardbind/:id", v1.CardBind) //绑定卡
wechat.DELETE("cardbind/:id", v1.DeleteCardBind) //解绑卡
wechat.GET("phonecardstatus/:id", v1.GetPhoneCardStatus) //获取学生公话卡状态
//wechat.GET("callrecord/:id",v1.GetCallRecord) // 查询通话记录
//添加亲情号
//修改亲情号
//删除亲情号
//缴费
//查询缴费记录
//获取学生定位卡状态
//查询通行记录
//缴费
//查询缴费记录
}
//router := r.Group("web/")
......
......@@ -4,6 +4,7 @@ import (
"dc_golang_server_1/cache"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
)
// GetProvinceList 获取省份列表
......@@ -11,36 +12,32 @@ import (
// @Summary 获取全国省份列表
// @Description 获取带首字母的省份列表
// @Product json
// @Success 200 {object} []cache.District "按首字母排序好的列表,可直接用作展示"
// @Success 0 {object} []cache.DistrictStruct "按首字母排序好的列表,可直接用作展示"
// @Router /base/province [GET]
// @Security ApiKeyAuth
func GetProvinceList(c *gin.Context) {
data := []cache.District{
{1, "四川省", "S"},
{1, "四川省", "S"},
}
c.JSON(http.StatusOK, gin.H{
"status": 200,
"data": data,
"code": SUCCSE,
"data": cache.ProvinceMap,
})
}
// GetCityList 获取城市列表
// GetCityList 获取城市或区县列表
// @Tags 公用接口
// @Summary 通过省份ID获取城市列表
// @Description 获取带首字母的城市列表
// @Param provinceID path integer true "省份id"
// @Product json
// @Success 200 {object} []cache.District "按首字母排序好的列表,可直接用作展示"
// @Success 0 {object} []cache.DistrictStruct "按首字母排序好的列表,可直接用作展示"
// @Router /base/city/{provinceID} [GET]
// @Security ApiKeyAuth
func GetCityList(c *gin.Context) {
//province, _ := strconv.Atoi(c.Param("provinceID"))
data := make(map[string][]string)
data["S"] = append(data["C"], "成都市")
para, _ := strconv.Atoi(c.Param("id"))
v, _ := cache.CityMap.Load(uint32(para)) // 如果查不到就直接返回空data
// data, _ := v.([]cache.DistrictStruct)
c.JSON(http.StatusOK, gin.H{
"status": 200,
"data": data,
"code": SUCCSE,
"data": v,
})
}
......@@ -50,15 +47,113 @@ func GetCityList(c *gin.Context) {
// @Description 获取带首字母的城市列表
// @Param cityID path integer true "城市ID"
// @Product json
// @Success 200 {object} []cache.District "按首字母排序好的列表,可直接用作展示"
// @Success 0 {object} []cache.DistrictStruct "按首字母排序好的列表,可直接用作展示"
// @Router /base/county/{cityID} [GET]
// @Security ApiKeyAuth
func GetCountyList(c *gin.Context) {
//province, _ := strconv.Atoi(c.Param("cityID"))
data := make(map[string][]string)
data["S"] = append(data["W"], "温江区")
para, _ := strconv.Atoi(c.Param("id"))
v, _ := cache.CountyMap.Load(uint32(para)) // 如果查不到就直接返回空data
// data, _ := v.([]cache.DistrictStruct)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"data": v,
})
}
type countyAreaRes struct {
Name string `json:"name" example:"海科学校"`
ID int `json:"id" example:"1"`
}
// GetAreaByCounty 根据区县ID获取学校列表
// @Tags 公用接口
// @Summary 根据区县ID获取学校列表
// @Description 根据区县ID获取学校列表
// @Param countyID path integer true "区县id" default(2725)
// @Product json
// @Success 0 {object} []countyAreaRes "排序好的学校列表,可直接用作展示"
// @Router /base/countyarea/{countyID} [GET]
// @Security ApiKeyAuth
func GetAreaByCounty(c *gin.Context) {
para, _ := strconv.Atoi(c.Param("id")) //todo
var data []countyAreaRes
if para == 2725 {
v, _ := cache.AreaMap.Load(uint32(1)) //
if a, ok := v.(cache.AreaStruct); ok { //类型断言正确
data = append(data, countyAreaRes{
a.Name,
1,
})
}
}
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
"data": data,
})
}
type locationAreaRes struct {
Name string `json:"name" example:"海科学校"`
District string `json:"district" example:"四川省成都市温江区"`
ID int `json:"id" example:"1"`
}
// GetAreaByLocation 根据经纬度获取附近学校列表
// @Tags 公用接口
// @Summary 根据经纬度获取附近20所学校列表
// @Description 根据经纬度获取附近20所学校列表
// @Param longitude query integer true "经度*1000000" default(103000000)
// @Param latitude query integer true "纬度*1000000" default(30000000)
// @Product json
// @Success 0 {object} []locationAreaRes "排序好的学校列表,可直接用作展示"
// @Router /base/locarea [GET]
// @Security ApiKeyAuth
func GetAreaByLocation(c *gin.Context) {
longitude, err := strconv.Atoi(c.Query("longitude"))
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 2001,
"message": "经度格式错误",
})
return
}
if longitude < -180000000 || longitude > 180000000 {
c.JSON(http.StatusOK, gin.H{
"code": 2001,
"message": "经度范围错误",
})
return
}
latitude, err := strconv.Atoi(c.Query("latitude"))
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 2001,
"message": "纬度格式错误",
})
return
}
if latitude < -90000000 || latitude > 90000000 {
c.JSON(http.StatusOK, gin.H{
"code": 2001,
"message": "纬度范围错误",
})
return
}
var data []locationAreaRes
v, _ := cache.AreaMap.Load(uint32(1)) // todo 根据经纬度计算距离 还要看status 和 用户的权限
if a, ok := v.(cache.AreaStruct); ok { //类型断言正确
data = append(data, locationAreaRes{
a.Name,
"四川省成都市温江区",
1,
})
}
c.JSON(http.StatusOK, gin.H{
"status": 200,
"data": data,
"code": SUCCSE,
"data": data,
})
}
package web
package v1
const (
SUCCSE = 200
SUCCSE = 0
ERROR = 500
// code = 1000...用户模块的错误
......
package v1
import (
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"time"
)
type weLoginRes struct {
// 自己创建的学生列表(主家长)
Master []struct {
// 学生ID
ID uint32 `json:"id"`
Name string `json:"name"`
// 0女 1男
Sex uint8 `json:"sex"`
// 区域名字
Area string `json:"area" example:"四川省成都市温江区实验中学"`
// "1~9对应一年级~九年级,10~12对应高一~高三"
Grade int8 `json:"grade"`
Class int8 `json:"class"`
StuNum string `json:"stuNum"`
// 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
Service []uint8 `json:"service" example:"1,2,2,0,0,0"`
// 是否已充值(已充值则不能删除,未充值可以删除)
TopUp bool `json:"topUp"`
} `json:"master"`
// 添加的学生列表(副家长)
Slave []struct {
// 学生ID
ID uint32 `json:"id"`
Name string `json:"name"`
// 0女 1男
Sex uint8 `json:"sex"`
// 区域名字
Area string `json:"area" example:"四川省成都市温江区实验中学"`
// "1~9对应一年级~九年级,10~12对应高一~高三"
Grade int8 `json:"grade"`
Class int8 `json:"class"`
StuNum string `json:"stuNum"`
// 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
Service []uint8 `json:"service" example:"1,2,2,0,0,0"`
} `json:"slave"`
// 是否已获取到微信电话
WePhone bool `json:"wePhone"`
// 是否已获取到微信用户信息
WeInfo bool `json:"weInfo"`
Token string `json:"token"`
}
// WeLogin 微信登录
// @Tags 家长微信
// @Summary 登录
// @Description 微信code传至后台,后台返回token,token有效时长:24小时
// @Param code path string true "用户微信的code"
// @Product json
// @Success 200 {object} string "{"code": 200, "token": string}"
// @Success 0 {object} weLoginRes
// @Router /we/login/{code} [POST]
func WeLogin(c *gin.Context) {
code := c.Param("code")
fmt.Println(code)
//todo 拿code去找腾讯要东西
var res weLoginRes
//todo 拿code去找腾讯要东西 生成token
res.Token = code
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
"data": res,
})
}
type weCreateCardUserReq struct {
// 必填,学生名字,maxLen=16
Name string `json:"name" example:"汤圆"`
// 必填,校区ID
AreaID uint32 `json:"areaID" example:"1"`
// 必填,"1~9对应一年级~九年级,10~12对应高一~高三"
Grade int8 `json:"grade"`
// 选填,0女1男
Sex uint8 `json:"sex,omitempty"`
// 选填,班级,number
Class int8 `json:"class,omitempty"`
// 选填,学号,字符串,maxLen=32
StudentNo string `json:"stuNum,omitempty"`
}
type creatCardUserRes struct {
// 新创建的学生ID
ID uint32 `json:"id"`
// 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
Service [6]uint8 `json:"service" example:"1,2,2,0,0,0"`
}
// CreateCardUser 创建一个学生
// @Tags 家长微信
// @Summary 创建一个学生
// @Description 传新建学生信息至后台,后台返回学生id,以及对应校区的service
// @Accept json
// @Produce json
// @Param data body weCreateCardUserReq true "学生信息"
// @Success 0 {object} creatCardUserRes
// @Router /we/carduser [POST]
// @Security ApiKeyAuth
func CreateCardUser(c *gin.Context) {
res := creatCardUserRes{
1,
[6]uint8{1, 2, 2, 0, 0, 0},
}
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
"data": res,
})
}
// DeleteCardUser 主家长删除一个学生
// @Tags 家长微信
// @Summary 主家长删除一个学生
// @Description 传学生ID至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0
// @Router /we/carduser/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteCardUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
type bindCardUserRes struct {
// 学生ID
ID uint32 `json:"id"`
Name string `json:"name"`
// 0女 1男
Sex uint8 `json:"sex"`
// 区域名字
Area string `json:"area" example:"四川省成都市温江区实验中学"`
// "1~9对应一年级~九年级,10~12对应高一~高三"
Grade int8 `json:"grade"`
Class int8 `json:"class"`
StuNum string `json:"stuNum"`
// 对应6个数字对应公话、定位、饮水、卡消费、洗浴、洗衣机图标(0不显示,1正常,2显示但提示校区暂未开通该服务)
Service []uint8 `json:"service" example:"1,2,2,0,0,0"`
}
// BindCardUser 副家长绑定学生
// @Tags 家长微信
// @Summary 副家长绑定学生
// @Description 传学生的邀请码,后台返回学生信息
// @Produce json
// @Param share_code path string true "学生的邀请码"
// @Success 0 {object} bindCardUserRes "学生信息"
// @Router /we/bindcarduser/{share_code} [POST]
// @Security ApiKeyAuth
func BindCardUser(c *gin.Context) {
res := bindCardUserRes{}
c.JSON(http.StatusOK, gin.H{
"status": 200,
"token": "diohafuahfuihaeuifhrgjkngk3134",
"code": SUCCSE,
"data": res,
})
}
// DeleteBindCardUser 副家长解绑学生
// @Tags 家长微信
// @Summary 副家长解绑学生
// @Description 传学生ID至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0
// @Router /we/bindcarduser/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteBindCardUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
type slaveWeUserRes struct {
// 微信UnionID
UnionID string `json:"unionID"`
// 微信昵称
Nickname string `json:"nickname"`
// 头像URL
AvatarURL string `json:"avatarURL"`
// 绑定时间
CreateAt time.Time `json:"createAt"`
}
type getBindCardUserRes struct {
// 副家长微信信息列表
WeUser []slaveWeUserRes `json:"weUser"`
// 学生的邀请码,长度固定16,若为空,则表示邀请码开关关闭
ShareCode string `json:"shareCode"`
}
// GetBindCardUser 获取学生副家长列表及邀请码内容(仅主家长有权限)
// @Tags 家长微信
// @Summary 获取学生副家长列表及邀请码内容(仅主家长有权限)
// @Description 传学生ID至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0 {object} getBindCardUserRes "副家长信息列表及邀请码"
// @Router /we/bindcarduser/{id} [GET]
// @Security ApiKeyAuth
func GetBindCardUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
"data": getBindCardUserRes{},
})
}
// PutCardUserShareOn 打开邀请码开关(仅主家长有权限)
// @Tags 家长微信
// @Summary 打开邀请码开关(仅主家长有权限)
// @Description 传学生ID至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0
// @Router /we/cardusershareon/{id} [PUT]
// @Security ApiKeyAuth
func PutCardUserShareOn(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
// PutCardUserShareOff 关闭邀请码开关(仅主家长有权限)
// @Tags 家长微信
// @Summary 关闭邀请码开关(仅主家长有权限)
// @Description 传学生ID至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0
// @Router /we/cardusershareoff/{id} [PUT]
// @Security ApiKeyAuth
func PutCardUserShareOff(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
// DeleteSlaveWeUser 删除副家长(仅主家长有权限)
// @Tags 家长微信
// @Summary 删除副家长(仅主家长有权限)
// @Description 传学生ID和微信UnionID,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Param unionid query string true "副家长微信UnionID"
// @Success 0
// @Router /we/slaveweuser/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteSlaveWeUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
type PutCardUserReq struct {
// 必填,学生名字,maxLen=16
Name string `json:"name" example:"汤圆"`
// 必填,"1~9对应一年级~九年级,10~12对应高一~高三"
Grade int8 `json:"grade"`
// 选填,0女1男
Sex uint8 `json:"sex,omitempty"`
// 选填,班级,number
Class int8 `json:"class,omitempty"`
// 选填,学号,字符串,maxLen=32
StudentNo string `json:"stuNum,omitempty"`
}
// PutCardUser 修改学生信息
// @Tags 家长微信
// @Summary 修改学生信息
// @Description 传学生id及新信息至后台,后台返回成功失败
// @Accept json
// @Produce json
// @Param id path integer true "学生ID"
// @Param data body PutCardUserReq true "学生信息"
// @Success 0
// @Router /we/carduser/{id} [PUT]
// @Security ApiKeyAuth
func PutCardUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
// CardLoss 卡挂失/解挂
// @Tags 家长微信
// @Summary 卡挂失/解挂
// @Description 传学生id及卡类型至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Param loss query bool true "true挂失,false解挂"
// @Param type query integer true "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)"
// @Success 0
// @Router /we/cardloss/{id} [PUT]
// @Security ApiKeyAuth
func CardLoss(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
// CardBind 绑定卡
// @Tags 家长微信
// @Summary 绑定卡
// @Description 传学生id及卡类型、卡号至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Param code query string true "卡号"
// @Param type query integer true "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)"
// @Success 0
// @Router /we/cardbind/{id} [PUT]
// @Security ApiKeyAuth
func CardBind(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
// DeleteCardBind 解绑卡
// @Tags 家长微信
// @Summary 解绑卡
// @Description 传学生id及卡类型至后台,后台返回成功失败
// @Produce json
// @Param id path integer true "学生ID"
// @Param type query integer true "卡类型:1电话卡,2定位卡,3IC卡(饮水、消费、洗浴、洗衣机均为IC卡,固任何一个服务的卡挂失状态改变,其余也跟随改变)"
// @Success 0
// @Router /we/cardbind/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteCardBind(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
})
}
type getPhoneCardStatusRes struct {
// 状态 0未绑定卡 1 正常使用 2 服务已到期 3 已挂失
Status uint8 `json:"status"`
// 卡号
SimID string `json:"simID"`
// 到期时间
ExpiryAt time.Time `json:"expiryAt"`
// 月套餐使用分钟数
MonthMin uint16 `json:"monthMin"`
// 月套餐分钟数
MonthPack uint16 `json:"monthPack"`
// 本月可修改亲情号次数
Changeable uint8 `json:"changeable"`
// 亲情号列表
Family []struct {
Phone string `json:"phone"`
Name string `json:"name"`
} `json:"family"`
}
// GetPhoneCardStatus 获取学生公话卡状态
// @Tags 家长微信
// @Summary 获取学生公话卡状态
// @Description 传学生ID至后台,后台返回卡信息
// @Produce json
// @Param id path integer true "学生ID"
// @Success 0 {object} getPhoneCardStatusRes "公话卡状态信息"
// @Router /we/phonecardstatus/{id} [GET]
// @Security ApiKeyAuth
func GetPhoneCardStatus(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": SUCCSE,
"data": getPhoneCardStatusRes{},
})
}
type getCallRecordRes struct {
// 状态 0未绑定卡 1 正常使用 2 服务已到期 3 已挂失
Status uint8 `json:"status"`
// 卡号
SimID string `json:"simID"`
// 到期时间
ExpiryAt time.Time `json:"expiryAt"`
// 月套餐使用分钟数
MonthMin uint16 `json:"monthMin"`
// 月套餐分钟数
MonthPack uint16 `json:"monthPack"`
// 本月可修改亲情号次数
Changeable uint8 `json:"changeable"`
// 亲情号列表
Family []struct {
Phone string `json:"phone"`
Name string `json:"name"`
} `json:"family"`
}
//// GetCallRecord 查询通话记录
//// @Tags 家长微信
//// @Summary 查询通话记录
//// @Description 传学生ID至后台,后台返回通话记录列表
//// @Produce json
//// @Param id path integer true "学生ID"
//// @Param pnum query integer true "页数"
//// @Param psize query integer true "页条数"
//// @Param start quety string false "起始时间 2020-10-10 10:00:00"
//// @Param end quety string false "结束时间 2030-10-10 10:00:00"
//// @Param asc quety bool false "是否升序" default(false)
//// @Success 0 {object} []getPhoneCardStatusRes "通话记录列表"
//// @Router /we/callrecord/{id} [GET]
//// @Security ApiKeyAuth
//func GetCallRecord(c *gin.Context) {
// c.JSON(http.StatusOK, gin.H{
// "code": SUCCSE,
// "data": getPhoneCardStatusRes{},
// })
//}
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