Merge remote-tracking branch 'origin/superGroup' into superGroup

This commit is contained in:
Gordon
2022-07-05 16:33:26 +08:00
6 changed files with 38 additions and 24 deletions
@@ -5,14 +5,14 @@ import (
_ "github.com/jinzhu/gorm"
)
func GetRegister(account, areaCode string) (*db.Register, error) {
func GetRegister(account, areaCode, userID 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 = ? or account =? and area_code=?",
account, account, areaCode).Take(&r).Error
return &r, dbConn.Table("registers").Where("user_id = ? and user_id != ? or account = ? or account =? and area_code=?",
userID, "", account, account, areaCode).Take(&r).Error
}
func SetPassword(account, password, ex, userID, areaCode string) error {
@@ -302,6 +302,6 @@ func GetRandomDepartmentID() (string, error) {
return "", err
}
department := &db.Department{}
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ? AND department_id != ?", "", "0").First(department).Error
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ? AND department_id != ? AND department_type = ?", "", "0", 1).First(department).Error
return department.DepartmentID, err
}