add swagger demo

This commit is contained in:
wangchuxiao
2022-06-24 17:45:33 +08:00
parent db7ef3ac4b
commit 99062805ec
16 changed files with 367 additions and 50 deletions
+1
View File
@@ -7,6 +7,7 @@ type Register struct {
Password string `gorm:"column:password;type:varchar(255)" json:"password"`
Ex string `gorm:"column:ex;size:1024" json:"ex"`
UserID string `gorm:"column:user_id;type:varchar(255)" json:"userID"`
AreaCode string `gorm:"column:area_code;type:varchar(255)"`
}
//
@@ -5,22 +5,23 @@ import (
_ "github.com/jinzhu/gorm"
)
func GetRegister(account string) (*db.Register, error) {
func GetRegister(account, areaCode string) (*db.Register, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
var r db.Register
return &r, dbConn.Table("registers").Where("account = ?",
account).Take(&r).Error
return &r, dbConn.Table("registers").Where("account = ? or account =? and area_code=?",
account, account, areaCode).Take(&r).Error
}
func SetPassword(account, password, ex, userID string) error {
func SetPassword(account, password, ex, userID, areaCode string) error {
r := db.Register{
Account: account,
Password: password,
Ex: ex,
UserID: userID,
AreaCode: areaCode,
}
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {